Kaydet (Commit) ab409bf7 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Move this fucntion to ScDBDocFunc.

so that it could be usable from unit test.

Change-Id: Iea10cb473bc17d7e030c018fd2c84fbeccce3e47
üst 7f0e4cf2
......@@ -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;
......
......@@ -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!
......
......@@ -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,
......
......@@ -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(
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment