summaryrefslogtreecommitdiff
path: root/sc/source/ui/view/viewfun3.cxx
diff options
context:
space:
mode:
authorNoel Power <noel.power@novell.com>2010-10-13 09:48:44 +0100
committerNoel Power <noel.power@novell.com>2010-10-13 10:01:42 +0100
commitbef01b6751dc826beff29426ad6ac3c3a5f9dbcc (patch)
treeee8414c8bf833f7b98da20fb0c177d389e080781 /sc/source/ui/view/viewfun3.cxx
parentc4712cc4f3f8cf5e68d8d6b717e6f1f4a9b445f0 (diff)
parentc76ef5619cebf8ebd31db94d15a0861905783a4e (diff)
Merge branch 'vba' fix conflics, trailing ws & tab issues
additionally the following iz patches are rolled up with this commit i#113356, i#112998 i#113955 i#113358 i#113515 i#112531 i#112596 i#112530
Diffstat (limited to 'sc/source/ui/view/viewfun3.cxx')
-rw-r--r--sc/source/ui/view/viewfun3.cxx186
1 files changed, 168 insertions, 18 deletions
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index 8fc5acde8..aed6fc662 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -1,7 +1,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -210,6 +210,7 @@
#include "drwtrans.hxx"
#include "docuno.hxx"
#include "clipparam.hxx"
+#include "undodat.hxx" // Amelia Wang
using namespace com::sun::star;
@@ -434,7 +435,7 @@ BOOL ScViewFunc::CopyToClip( ScDocument* pClipDoc, BOOL bCut, BOOL bApi, BOOL bI
if (nRowDelta)
aClipParam.meDirection = ScClipParam::Row;
}
-
+
SCCOL nColSize = p->aEnd.Col() - p->aStart.Col() + 1;
SCROW nRowSize = p->aEnd.Row() - p->aStart.Row() + 1;
@@ -446,7 +447,7 @@ BOOL ScViewFunc::CopyToClip( ScDocument* pClipDoc, BOOL bCut, BOOL bApi, BOOL bI
}
if (aClipParam.meDirection == ScClipParam::Row && nColSize != nPrevColSize)
{
- // likewise, row-oriented ranges must have identical
+ // likewise, row-oriented ranges must have identical
// column size.
bValidRanges = false;
break;
@@ -506,6 +507,76 @@ BOOL ScViewFunc::CopyToClip( ScDocument* pClipDoc, BOOL bCut, BOOL bApi, BOOL bI
return bDone;
}
+// Copy the content of the Range into clipboard. Adding this method for VBA API: Range.Copy().
+BOOL ScViewFunc::CopyToClip( ScDocument* pClipDoc, const ScRange& rRange, BOOL bCut, BOOL bApi, BOOL bIncludeObjects, BOOL bStopEdit )
+{
+ BOOL bDone = FALSE;
+ if ( bStopEdit )
+ UpdateInputLine();
+
+ ScRange aRange = rRange;
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ if ( pDoc && !pDoc->HasSelectedBlockMatrixFragment( aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aStart.Tab() ) )
+ {
+ BOOL bSysClip = FALSE;
+ if ( !pClipDoc )
+ {
+ // Create one (deleted by ScTransferObj).
+ pClipDoc = new ScDocument( SCDOCMODE_CLIP );
+ bSysClip = TRUE;
+ }
+ if ( !bCut )
+ {
+ ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->ResetLastCut();
+ }
+
+ if ( bSysClip && bIncludeObjects )
+ {
+ BOOL bAnyOle = pDoc->HasOLEObjectsInArea( aRange );
+ // Update ScGlobal::pDrawClipDocShellRef.
+ ScDrawLayer::SetGlobalDrawPersist( ScTransferObj::SetDrawClipDoc( bAnyOle ) );
+ }
+
+ ScClipParam aClipParam( aRange, bCut );
+ pDoc->CopyToClip4VBA( aClipParam, pClipDoc, false, bIncludeObjects );
+ if ( bSysClip )
+ {
+ ScDrawLayer::SetGlobalDrawPersist(NULL);
+ ScGlobal::SetClipDocName( pDoc->GetDocumentShell()->GetTitle( SFX_TITLE_FULLNAME ) );
+ }
+ pClipDoc->ExtendMerge( aRange, TRUE );
+
+ if ( bSysClip )
+ {
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ TransferableObjectDescriptor aObjDesc;
+ pDocSh->FillTransferableObjectDescriptor( aObjDesc );
+ aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
+
+ ScTransferObj* pTransferObj = new ScTransferObj( pClipDoc, aObjDesc );
+ uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
+ if ( ScGlobal::pDrawClipDocShellRef )
+ {
+ SfxObjectShellRef aPersistRef( &(*ScGlobal::pDrawClipDocShellRef) );
+ pTransferObj->SetDrawPersist( aPersistRef );
+ }
+ pTransferObj->CopyToClipboard( GetActiveWin() );
+ SC_MOD()->SetClipObject( pTransferObj, NULL );
+ }
+
+ bDone = TRUE;
+ }
+ else
+ {
+ if ( !bApi )
+ ErrorMessage(STR_MATRIXFRAGMENTERR);
+ }
+
+ return bDone;
+}
+
ScTransferObj* ScViewFunc::CopyToTransferable()
{
ScRange aRange;
@@ -1210,7 +1281,7 @@ BOOL ScViewFunc::PasteFromClip( USHORT nFlags, ScDocument* pClipDoc,
// pDoc->HasCommonAttr( StartCol,nStartRow, nUndoEndCol,nUndoEndRow, nStartTab,
// pClipDoc, nClipStartX, nClipStartY );
- ScDocFunc& rDocFunc = pDocSh->GetDocFunc();
+ ScDocFunc& rDocFunc = pDocSh->GetDocFunc();
if ( bRecord )
{
String aUndo = ScGlobal::GetRscString( pClipDoc->IsCutMode() ? STR_UNDO_MOVE : STR_UNDO_COPY );
@@ -1459,7 +1530,7 @@ BOOL ScViewFunc::PasteFromClip( USHORT nFlags, ScDocument* pClipDoc,
bool ScViewFunc::PasteMultiRangesFromClip(
sal_uInt16 nFlags, ScDocument* pClipDoc, sal_uInt16 nFunction,
- bool bSkipEmpty, bool bTranspose, bool bAsLink, bool bAllowDialogs,
+ bool bSkipEmpty, bool bTranspose, bool bAsLink, bool bAllowDialogs,
InsCellCmd eMoveMode, sal_uInt16 /*nContFlags*/, sal_uInt16 nUndoFlags)
{
ScViewData& rViewData = *GetViewData();
@@ -1505,7 +1576,7 @@ bool ScViewFunc::PasteMultiRangesFromClip(
// For multi-selection paste, we don't support cell duplication for larger
// destination range. In case the destination is marked, we reset it to
// the clip size.
- ScRange aMarkedRange(rCurPos.Col(), rCurPos.Row(), nTab1,
+ ScRange aMarkedRange(rCurPos.Col(), rCurPos.Row(), nTab1,
rCurPos.Col()+nColSize-1, rCurPos.Row()+nRowSize-1, nTab2);
// Extend the marked range to account for filtered rows in the destination
@@ -1516,8 +1587,8 @@ bool ScViewFunc::PasteMultiRangesFromClip(
return false;
}
- bool bAskIfNotEmpty =
- bAllowDialogs && (nFlags & IDF_CONTENTS) &&
+ bool bAskIfNotEmpty =
+ bAllowDialogs && (nFlags & IDF_CONTENTS) &&
nFunction == PASTE_NOFUNC && SC_MOD()->GetInputOptions().GetReplaceCellsWarn();
if (bAskIfNotEmpty)
@@ -1566,10 +1637,10 @@ bool ScViewFunc::PasteMultiRangesFromClip(
CursorSwitcher aCursorSwitch(this);
sal_uInt16 nNoObjFlags = nFlags & ~IDF_OBJECTS;
- pDoc->CopyMultiRangeFromClip(rCurPos, aMark, nNoObjFlags, pClipDoc,
+ pDoc->CopyMultiRangeFromClip(rCurPos, aMark, nNoObjFlags, pClipDoc,
true, bAsLink, false, bSkipEmpty);
- if (pMixDoc.get())
+ if (pMixDoc.get())
pDoc->MixDocument(aMarkedRange, nFunction, bSkipEmpty, pMixDoc.get());
AdjustBlockHeight(); // update row heights before pasting objects
@@ -1577,7 +1648,7 @@ bool ScViewFunc::PasteMultiRangesFromClip(
if (nFlags & IDF_OBJECTS)
{
// Paste the drawing objects after the row heights have been updated.
- pDoc->CopyMultiRangeFromClip(rCurPos, aMark, IDF_OBJECTS, pClipDoc,
+ pDoc->CopyMultiRangeFromClip(rCurPos, aMark, IDF_OBJECTS, pClipDoc,
true, false, false, true);
}
@@ -1599,13 +1670,13 @@ bool ScViewFunc::PasteMultiRangesFromClip(
aOptions.bAsLink = bAsLink;
aOptions.eMoveMode = eMoveMode;
- ScUndoPaste* pUndo = new ScUndoPaste(pDocSh,
- aMarkedRange.aStart.Col(),
- aMarkedRange.aStart.Row(),
- aMarkedRange.aStart.Tab(),
- aMarkedRange.aEnd.Col(),
- aMarkedRange.aEnd.Row(),
- aMarkedRange.aEnd.Tab(),
+ ScUndoPaste* pUndo = new ScUndoPaste(pDocSh,
+ aMarkedRange.aStart.Col(),
+ aMarkedRange.aStart.Row(),
+ aMarkedRange.aStart.Tab(),
+ aMarkedRange.aEnd.Col(),
+ aMarkedRange.aEnd.Row(),
+ aMarkedRange.aEnd.Tab(),
aMark, pUndoDoc.release(), NULL, nFlags|nUndoFlags, NULL, NULL, NULL, NULL, false, &aOptions);
if (bInsertCells)
@@ -1784,6 +1855,85 @@ BOOL ScViewFunc::LinkBlock( const ScRange& rSource, const ScAddress& rDestPos, B
return TRUE;
}
+void ScViewFunc::DataFormPutData( SCROW nCurrentRow ,
+ SCROW nStartRow , SCCOL nStartCol ,
+ SCROW nEndRow , SCCOL nEndCol ,
+ Edit** pEdits ,
+ sal_uInt16 aColLength )
+{
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ ScDocShellModificator aModificator( *pDocSh );
+ SfxUndoManager* pUndoMgr = pDocSh->GetUndoManager();
+ if ( pDoc )
+ {
+ const BOOL bRecord( pDoc->IsUndoEnabled());
+ ScDocument* pUndoDoc = NULL;
+ ScDocument* pRedoDoc = NULL;
+ ScDocument* pRefUndoDoc = NULL;
+ ScRefUndoData* pUndoData = NULL;
+ SCTAB nTab = GetViewData()->GetTabNo();
+ SCTAB nStartTab = nTab;
+ SCTAB nEndTab = nTab;
+ {
+ ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->ResetLastCut(); // kein CutMode mehr
+ }
+ ScRange aUserRange( nStartCol, nCurrentRow, nStartTab, nEndCol, nCurrentRow, nEndTab );
+ BOOL bColInfo = ( nStartRow==0 && nEndRow==MAXROW );
+ BOOL bRowInfo = ( nStartCol==0 && nEndCol==MAXCOL );
+ SCCOL nUndoEndCol = nStartCol+aColLength-1;
+ SCROW nUndoEndRow = nCurrentRow;
+ USHORT nUndoFlags = IDF_NONE;
+
+ if ( bRecord )
+ {
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndoSelected( pDoc , rMark , bColInfo , bRowInfo );
+ pDoc->CopyToDocument( aUserRange , 1 , FALSE , pUndoDoc );
+ }
+ USHORT nExtFlags = 0;
+ pDocSh->UpdatePaintExt( nExtFlags, nStartCol, nStartRow, nStartTab , nEndCol, nEndRow, nEndTab ); // content before the change
+ //rMark.SetMarkArea( aUserRange );
+ pDoc->BeginDrawUndo();
+
+ for(sal_uInt16 i = 0; i < aColLength; i++)
+ {
+ if (pEdits[i])
+ {
+ String aFieldName=pEdits[i]->GetText();
+ pDoc->SetString( nStartCol + i, nCurrentRow, nTab, aFieldName );
+ }
+ }
+ //pDoc->ExtendMergeSel( nStartCol, nStartRow, nEndCol, nEndRow, rMark, TRUE ); // Refresh
+ pDocSh->UpdatePaintExt( nExtFlags, nStartCol, nCurrentRow, nStartTab, nEndCol, nCurrentRow, nEndTab ); // content after the change
+ SfxUndoAction* pUndo = new ScUndoDataForm( pDocSh,
+ nStartCol, nCurrentRow, nStartTab,
+ nUndoEndCol, nUndoEndRow, nEndTab, rMark,
+ pUndoDoc, pRedoDoc, nUndoFlags,
+ pUndoData, NULL, NULL, NULL,
+ FALSE ); // FALSE = Redo data not yet copied
+ pUndoMgr->AddUndoAction( new ScUndoWrapper( pUndo ), TRUE );
+
+ USHORT nPaint = PAINT_GRID;
+ if (bColInfo)
+ {
+ nPaint |= PAINT_TOP;
+ nUndoEndCol = MAXCOL; // nur zum Zeichnen !
+ }
+ if (bRowInfo)
+ {
+ nPaint |= PAINT_LEFT;
+ nUndoEndRow = MAXROW; // nur zum Zeichnen !
+ }
+
+ pDocSh->PostPaint( nStartCol, nCurrentRow, nStartTab,
+ nUndoEndCol, nUndoEndRow, nEndTab, nPaint, nExtFlags );
+ pDocSh->UpdateOle(GetViewData());
+ }
+}