diff options
author | Noel Power <noel.power@novell.com> | 2010-10-06 10:15:43 +0100 |
---|---|---|
committer | Noel Power <noel.power@novell.com> | 2010-10-06 10:15:43 +0100 |
commit | f13fd7b138caee676cf5dbeae3474e4a4b0b177a (patch) | |
tree | 58bbab934d3fd26a8fd886a2dbc52b5a2d283092 /sc/source/ui/view | |
parent | 44231089eeda805727f6c7143729612059891b02 (diff) |
initial commit for vba blob ( not including container_control stuff )
Diffstat (limited to 'sc/source/ui/view')
-rw-r--r-- | sc/source/ui/view/cellsh2.cxx | 14 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin5.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/view/tabview3.cxx | 7 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwsh4.cxx | 7 | ||||
-rw-r--r-- | sc/source/ui/view/viewfun2.cxx | 59 | ||||
-rw-r--r-- | sc/source/ui/view/viewfun3.cxx | 150 |
6 files changed, 187 insertions, 52 deletions
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx index 2e318a920898..38794bdca38e 100644 --- a/sc/source/ui/view/cellsh2.cxx +++ b/sc/source/ui/view/cellsh2.cxx @@ -334,6 +334,20 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq ) } break; + case SID_DATA_FORM: + { + ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 + + AbstractScDataFormDlg* pDlg = pFact->CreateScDataFormDlg( pTabViewShell->GetDialogParent(),RID_SCDLG_DATAFORM, pTabViewShell); + DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001 + + pDlg->Execute(); + + rReq.Done(); + } + break; + case SID_SUBTOTALS: { const SfxItemSet* pArgs = rReq.GetArgs(); diff --git a/sc/source/ui/view/gridwin5.cxx b/sc/source/ui/view/gridwin5.cxx index 4a9dbbaf98b6..592a5392ba20 100644 --- a/sc/source/ui/view/gridwin5.cxx +++ b/sc/source/ui/view/gridwin5.cxx @@ -343,14 +343,12 @@ void ScGridWindow::RequestHelp(const HelpEvent& rHEvt) if ( pDrView->PickObj(aMDPos, pDrView->getHitTolLog(), pHit, pPV, SDRSEARCH_DEEP ) ) pObj = pHit; } -#ifdef ISSUE66550_HLINK_FOR_SHAPES ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj ); if ( pInfo && (pInfo->GetHlink().getLength() > 0) ) { aPixRect = LogicToPixel(aVEvt.pObj->GetLogicRect()); aHelpText = pInfo->GetHlink(); } -#endif } } } diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx index 983113760bb9..cf9a8dc84cd6 100644 --- a/sc/source/ui/view/tabview3.cxx +++ b/sc/source/ui/view/tabview3.cxx @@ -1419,9 +1419,11 @@ void ScTabView::MarkRange( const ScRange& rRange, BOOL bSetCursor, BOOL bContinu { SCCOL nAlignX = rRange.aStart.Col(); SCROW nAlignY = rRange.aStart.Row(); - if ( rRange.aStart.Col() == 0 && rRange.aEnd.Col() == MAXCOL ) + bool bCol = ( rRange.aStart.Col() == 0 && rRange.aEnd.Col() == MAXCOL ) && !aViewData.GetDocument()->IsInVBAMode(); + bool bRow = ( rRange.aStart.Row() == 0 && rRange.aEnd.Row() == MAXROW ); + if ( bCol ) nAlignX = aViewData.GetPosX(WhichH(aViewData.GetActivePart())); - if ( rRange.aStart.Row() == 0 && rRange.aEnd.Row() == MAXROW ) + if ( bRow ) nAlignY = aViewData.GetPosY(WhichV(aViewData.GetActivePart())); AlignToCursor( nAlignX, nAlignY, SC_FOLLOW_JUMP ); } @@ -1535,6 +1537,7 @@ void ScTabView::SetTabNo( SCTAB nTab, BOOL bNew, BOOL bExtendSelection ) // nicht InputEnterHandler wegen Referenzeingabe ! ScDocument* pDoc = aViewData.GetDocument(); + pDoc->MakeTable( nTab ); // Update pending row heights before switching the sheet, so Reschedule from the progress bar diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx index 769a840dab63..8ae63b6e22d1 100644 --- a/sc/source/ui/view/tabvwsh4.cxx +++ b/sc/source/ui/view/tabvwsh4.cxx @@ -1769,6 +1769,13 @@ void ScTabViewShell::Construct( BYTE nForceDesignMode ) if ( pDocSh->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) { SCTAB nInitTabCount = 3; //! konfigurierbar !!! + // Get the customized initial tab count, we only can set the count by VBA API currently. + const ScAppOptions& rAppOpt = SC_MOD()->GetAppOptions(); + SCTAB nNewTabCount = rAppOpt.GetTabCountInNewSpreadsheet(); + if ( nNewTabCount >= 1 && nNewTabCount <= MAXTAB ) + { + nInitTabCount = nNewTabCount; + } for (SCTAB i=1; i<nInitTabCount; i++) pDoc->MakeTable(i,false); } diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index e2763b7c888e..e4feab7d3457 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -52,6 +52,11 @@ #include <vcl/sound.hxx> #include <vcl/waitobj.hxx> +#include <basic/sbstar.hxx> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/script/XLibraryContainer.hpp> +using namespace com::sun::star; + #include "viewfunc.hxx" #include "sc.hrc" @@ -2189,6 +2194,8 @@ BOOL ScViewFunc::DeleteTables(const SvShorts &TheTabs, BOOL bRecord ) WaitObject aWait( GetFrameWin() ); if (bRecord && !pDoc->IsUndoEnabled()) bRecord = FALSE; + if ( bVbaEnabled ) + bRecord = FALSE; while ( nNewTab > 0 && !pDoc->IsVisible( nNewTab ) ) --nNewTab; @@ -2296,6 +2303,7 @@ BOOL ScViewFunc::DeleteTables(const SvShorts &TheTabs, BOOL bRecord ) pDocSh->PostPaintExtras(); pDocSh->SetDocumentModified(); + SfxApplication* pSfxApp = SFX_APP(); // Navigator pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) ); @@ -2440,8 +2448,8 @@ void ScViewFunc::ImportTables( ScDocShell* pSrcShell, { SCTAB nSrcTab = pSrcTabs[i]; SCTAB nDestTab1=nTab+i; - ULONG nErrVal = pDoc->TransferTab( pSrcDoc, nSrcTab, nDestTab1, - FALSE ); // no insert + ULONG nErrVal = pDocSh->TransferTab( *pSrcShell, nSrcTab, nDestTab1, + FALSE, FALSE ); // no insert switch (nErrVal) { @@ -2459,25 +2467,6 @@ void ScViewFunc::ImportTables( ScDocShell* pSrcShell, break; } - // TransferTab doesn't copy drawing objects with bInsertNew=FALSE - if ( !bError ) - pDoc->TransferDrawPage( pSrcDoc, nSrcTab, nDestTab1 ); - - if(!bError &&pSrcDoc->IsScenario(nSrcTab)) - { - String aComment; - Color aColor; - USHORT nFlags; - - pSrcDoc->GetScenarioData(nSrcTab, aComment,aColor, nFlags); - pDoc->SetScenario( nDestTab1,TRUE); - pDoc->SetScenarioData( nTab+i,aComment,aColor,nFlags); - BOOL bActive = pSrcDoc->IsActiveScenario(nSrcTab ); - pDoc->SetActiveScenario( nDestTab1, bActive ); - BOOL bVisible=pSrcDoc->IsVisible(nSrcTab); - pDoc->SetVisible(nDestTab1,bVisible ); - - } } if (bLink) @@ -2661,33 +2650,7 @@ void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy ) nDestTab1 = nDestTab; for(USHORT i=0;i<TheTabs.Count();i++) { - nErrVal = pDestDoc->TransferTab( pDoc, TheTabs[i], nDestTab1, - FALSE ); // no insert - - // TransferTab doesn't copy drawing objects with bInsertNew=FALSE - if ( nErrVal > 0 ) - pDestDoc->TransferDrawPage( pDoc, TheTabs[i], nDestTab1 ); - - if(nErrVal>0 && pDoc->IsScenario(TheTabs[i])) - { - String aComment; - Color aColor; - USHORT nFlags; - - pDoc->GetScenarioData(TheTabs[i], aComment,aColor, nFlags); - pDestDoc->SetScenario(nDestTab1,TRUE); - pDestDoc->SetScenarioData(nDestTab1,aComment,aColor,nFlags); - BOOL bActive = pDoc->IsActiveScenario(TheTabs[i]); - pDestDoc->SetActiveScenario(nDestTab1, bActive ); - - BOOL bVisible=pDoc->IsVisible(TheTabs[i]); - pDestDoc->SetVisible(nDestTab1,bVisible ); - - } - - if ( nErrVal > 0 && pDoc->IsTabProtected( TheTabs[i] ) ) - pDestDoc->SetTabProtection(nDestTab1, pDoc->GetTabProtection(TheTabs[i])); - + nErrVal = pDestShell->TransferTab( *pDocShell, static_cast<SCTAB>(TheTabs[i]), static_cast<SCTAB>(nDestTab1), FALSE, FALSE ); nDestTab1++; } } diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx index 24fab9ac2eba..773dc85d63f3 100644 --- a/sc/source/ui/view/viewfun3.cxx +++ b/sc/source/ui/view/viewfun3.cxx @@ -210,6 +210,7 @@ #include "drwtrans.hxx" #include "docuno.hxx" #include "clipparam.hxx" +#include "undodat.hxx" // Amelia Wang using namespace com::sun::star; @@ -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; @@ -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()); + } +} |