diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-07-28 17:54:24 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-07-28 22:08:22 -0400 |
commit | ab409bf7fbe8a9af75fdd253a760ffbaf92a8376 (patch) | |
tree | af056cd23985f09e4e3cf974302e1474c13f2bb4 /sc | |
parent | 7f0e4cf20ede44240d48d327b3a58bc9d81426f5 (diff) |
Move this fucntion to ScDBDocFunc.
so that it could be usable from unit test.
Change-Id: Iea10cb473bc17d7e030c018fd2c84fbeccce3e47
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/dbgui/dbnamdlg.cxx | 7 | ||||
-rw-r--r-- | sc/source/ui/docshell/dbdocfun.cxx | 39 | ||||
-rw-r--r-- | sc/source/ui/inc/dbdocfun.hxx | 3 | ||||
-rw-r--r-- | sc/source/ui/inc/dbfunc.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/view/dbfunc.cxx | 45 |
5 files changed, 47 insertions, 49 deletions
diff --git a/sc/source/ui/dbgui/dbnamdlg.cxx b/sc/source/ui/dbgui/dbnamdlg.cxx index b49a148ecc63..c70040ffd968 100644 --- a/sc/source/ui/dbgui/dbnamdlg.cxx +++ b/sc/source/ui/dbgui/dbnamdlg.cxx @@ -31,6 +31,7 @@ #include "rangenam.hxx" #include "globalnames.hxx" #include "dbnamdlg.hxx" +#include <dbdocfun.hxx> #define ABS_SREF SCA_VALID \ | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE @@ -373,8 +374,10 @@ IMPL_LINK_NOARG(ScDbNameDlg, OkBtnHdl) // beide werden nur als Referenz uebergeben, so dass an dieser // Stelle keine Speicherleichen entstehen koennen: if ( pViewData ) - pViewData->GetView()-> - NotifyCloseDbNameDlg( aLocalDbCol, aRemoveList ); + { + ScDBDocFunc aFunc(*pViewData->GetDocShell()); + aFunc.ModifyAllDBData(aLocalDbCol, aRemoveList); + } Close(); return 0; diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx index 187621dc2b26..0ecb0aa5a1e5 100644 --- a/sc/source/ui/docshell/dbdocfun.cxx +++ b/sc/source/ui/docshell/dbdocfun.cxx @@ -241,6 +241,45 @@ bool ScDBDocFunc::ModifyDBData( const ScDBData& rNewData ) return bDone; } +void ScDBDocFunc::ModifyAllDBData( const ScDBCollection& rNewColl, const std::vector<ScRange>& rDelAreaList ) +{ + ScDocShellModificator aModificator(rDocShell); + ScDocument& rDoc = rDocShell.GetDocument(); + ScDBCollection* pOldColl = rDoc.GetDBCollection(); + ScDBCollection* pUndoColl = NULL; + bool bRecord = rDoc.IsUndoEnabled(); + + std::vector<ScRange>::const_iterator iter; + for (iter = rDelAreaList.begin(); iter != rDelAreaList.end(); ++iter) + { + // unregistering target in SBA no longer necessary + const ScAddress& rStart = iter->aStart; + const ScAddress& rEnd = iter->aEnd; + rDocShell.DBAreaDeleted( + rStart.Tab(), rStart.Col(), rStart.Row(), rEnd.Col(), rEnd.Row()); + } + + if (bRecord) + pUndoColl = new ScDBCollection( *pOldColl ); + + // register target in SBA no longer necessary + + rDoc.CompileDBFormula( true ); // CreateFormulaString + rDoc.SetDBCollection( new ScDBCollection( rNewColl ) ); + rDoc.CompileDBFormula( false ); // CompileFormulaString + pOldColl = NULL; + rDocShell.PostPaint(ScRange(0, 0, 0, MAXCOL, MAXROW, MAXTAB), PAINT_GRID); + aModificator.SetDocumentModified(); + SfxGetpApp()->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) ); + + if (bRecord) + { + ScDBCollection* pRedoColl = new ScDBCollection(rNewColl); + rDocShell.GetUndoManager()->AddUndoAction( + new ScUndoDBData(&rDocShell, pUndoColl, pRedoColl)); + } +} + bool ScDBDocFunc::RepeatDB( const OUString& rDBName, bool bRecord, bool bApi, bool bIsUnnamed, SCTAB aTab ) { //! auch fuer ScDBFunc::RepeatDB benutzen! diff --git a/sc/source/ui/inc/dbdocfun.hxx b/sc/source/ui/inc/dbdocfun.hxx index 13fd9bce5a64..714a2dbcceda 100644 --- a/sc/source/ui/inc/dbdocfun.hxx +++ b/sc/source/ui/inc/dbdocfun.hxx @@ -35,6 +35,7 @@ class ScDocShell; class ScAddress; class ScRange; class ScDPObject; +class ScDBCollection; namespace com { namespace sun { namespace star { namespace beans { @@ -85,6 +86,8 @@ public: bool RenameDBRange( const OUString& rOld, const OUString& rNew ); bool ModifyDBData( const ScDBData& rNewData ); // Name unveraendert + void ModifyAllDBData( const ScDBCollection& rNewColl, const std::vector<ScRange>& rDelAreaList ); + bool RepeatDB( const OUString& rDBName, bool bRecord, bool bApi, bool bIsUnnamed=false, SCTAB aTab = 0); bool DataPilotUpdate( ScDPObject* pOldObj, const ScDPObject* pNewObj, diff --git a/sc/source/ui/inc/dbfunc.hxx b/sc/source/ui/inc/dbfunc.hxx index 0e3b197bd442..72c376c55ae7 100644 --- a/sc/source/ui/inc/dbfunc.hxx +++ b/sc/source/ui/inc/dbfunc.hxx @@ -70,8 +70,6 @@ public: ScDBData* GetDBData( bool bMarkArea = true, ScGetDBMode eMode = SC_DB_MAKE, ScGetDBSelection eSel = SC_DBSEL_KEEP); ScDBData* GetAnonymousDBData(); - void NotifyCloseDbNameDlg( const ScDBCollection& rNewColl, const std::vector<ScRange> &rDelAreaList ); - void Consolidate( const ScConsolidateParam& rParam, bool bRecord = true ); bool MakePivotTable( diff --git a/sc/source/ui/view/dbfunc.cxx b/sc/source/ui/view/dbfunc.cxx index a1a5fc215a5b..50d638cdcf50 100644 --- a/sc/source/ui/view/dbfunc.cxx +++ b/sc/source/ui/view/dbfunc.cxx @@ -191,51 +191,6 @@ ScDBData* ScDBFunc::GetAnonymousDBData() return pDocSh->GetAnonymousDBData(aRange); } -// change database range (dialog) - -void ScDBFunc::NotifyCloseDbNameDlg( const ScDBCollection& rNewColl, const std::vector<ScRange> &rDelAreaList ) -{ - - ScDocShell* pDocShell = GetViewData().GetDocShell(); - ScDocShellModificator aModificator( *pDocShell ); - ScDocument& rDoc = pDocShell->GetDocument(); - ScDBCollection* pOldColl = rDoc.GetDBCollection(); - ScDBCollection* pUndoColl = NULL; - const bool bRecord (rDoc.IsUndoEnabled()); - - std::vector<ScRange>::const_iterator iter; - for (iter = rDelAreaList.begin(); iter != rDelAreaList.end(); ++iter) - { - // unregistering target in SBA no longer necessary - const ScAddress& rStart = iter->aStart; - const ScAddress& rEnd = iter->aEnd; - pDocShell->DBAreaDeleted( rStart.Tab(), - rStart.Col(), rStart.Row(), - rEnd.Col(), rEnd.Row() ); - - } - - if (bRecord) - pUndoColl = new ScDBCollection( *pOldColl ); - - // register target in SBA no longer necessary - - rDoc.CompileDBFormula( true ); // CreateFormulaString - rDoc.SetDBCollection( new ScDBCollection( rNewColl ) ); - rDoc.CompileDBFormula( false ); // CompileFormulaString - pOldColl = NULL; - pDocShell->PostPaint(ScRange(0, 0, 0, MAXCOL, MAXROW, MAXTAB), PAINT_GRID); - aModificator.SetDocumentModified(); - SfxGetpApp()->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) ); - - if (bRecord) - { - ScDBCollection* pRedoColl = new ScDBCollection( rNewColl ); - pDocShell->GetUndoManager()->AddUndoAction( - new ScUndoDBData( pDocShell, pUndoColl, pRedoColl ) ); - } -} - // main functions // Sort |