diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2011-03-24 23:14:28 -0400 |
---|---|---|
committer | Kohei Yoshida <kyoshida@novell.com> | 2011-04-01 00:11:02 -0400 |
commit | 7df4c7feacf51c141a7beaa2a8404d932d7c2e86 (patch) | |
tree | 382fc1f4af02a368cc905f9e7dd341e152f9965c /sc/source/ui | |
parent | d8e16e5559b715b8c2853f262a0636e79f5c1853 (diff) |
Support sheet-local anonymous database ranges.
This is for an Easy Hack to allow one autofilter per sheet, not per
document.
Diffstat (limited to 'sc/source/ui')
-rw-r--r-- | sc/source/ui/dbgui/dbnamdlg.cxx | 7 | ||||
-rw-r--r-- | sc/source/ui/dbgui/foptmgr.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/dbgui/pfiltdlg.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/dbgui/tpsort.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/docshell/dbdocfun.cxx | 33 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh5.cxx | 85 | ||||
-rw-r--r-- | sc/source/ui/inc/pfiltdlg.hxx | 1 | ||||
-rw-r--r-- | sc/source/ui/inc/tpsort.hxx | 1 | ||||
-rw-r--r-- | sc/source/ui/inc/undobase.hxx | 1 | ||||
-rw-r--r-- | sc/source/ui/navipi/content.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/undo/undobase.cxx | 14 | ||||
-rw-r--r-- | sc/source/ui/undo/undodat.cxx | 19 | ||||
-rw-r--r-- | sc/source/ui/undo/undoutil.cxx | 15 | ||||
-rw-r--r-- | sc/source/ui/unoobj/datauno.cxx | 114 | ||||
-rw-r--r-- | sc/source/ui/view/cellsh2.cxx | 5 |
15 files changed, 192 insertions, 118 deletions
diff --git a/sc/source/ui/dbgui/dbnamdlg.cxx b/sc/source/ui/dbgui/dbnamdlg.cxx index fcf29c814933..f1523d07c1e7 100644 --- a/sc/source/ui/dbgui/dbnamdlg.cxx +++ b/sc/source/ui/dbgui/dbnamdlg.cxx @@ -43,6 +43,7 @@ #include "globstr.hrc" #include "dbnamdlg.hrc" #include "rangenam.hxx" // IsNameValid +#include "globalnames.hxx" #define _DBNAMDLG_CXX #include "dbnamdlg.hxx" @@ -165,7 +166,7 @@ ScDbNameDlg::ScDbNameDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent, aStrAdd ( ScResId( STR_ADD ) ), aStrModify ( ScResId( STR_MODIFY ) ), - aStrNoName ( ScGlobal::GetRscString(STR_DB_NONAME) ), + aStrNoName ( RTL_CONSTASCII_USTRINGPARAM(STR_DB_LOCAL_NONAME)), aStrInvalid ( ScResId( STR_DB_INVALID ) ), // pViewData ( ptrViewData ), @@ -272,7 +273,7 @@ void ScDbNameDlg::Init() && (rEnd.Col() == nCol2) && (rEnd.Row() == nRow2 ) ) { pDBData->GetName( theDbName ); - if ( theDbName != aStrNoName ) + if (theDbName!=aStrNoName ) aEdName.SetText( theDbName ); else aEdName.SetText( EMPTY_STRING ); @@ -384,7 +385,7 @@ void ScDbNameDlg::UpdateNames() if ( pDbData ) { pDbData->GetName( aString ); - if ( aString != aStrNoName ) + if (aString!=aStrNoName ) aEdName.InsertEntry( aString ); } } diff --git a/sc/source/ui/dbgui/foptmgr.cxx b/sc/source/ui/dbgui/foptmgr.cxx index d6f9d28b98ea..60b00bf459ee 100644 --- a/sc/source/ui/dbgui/foptmgr.cxx +++ b/sc/source/ui/dbgui/foptmgr.cxx @@ -111,6 +111,7 @@ ScFilterOptionsMgr::~ScFilterOptionsMgr() void ScFilterOptionsMgr::Init() { +//moggi:TODO DBG_ASSERT( pViewData && pDoc, "Init failed :-/" ); rLbCopyPos.SetSelectHdl ( LINK( this, ScFilterOptionsMgr, LbPosSelHdl ) ); @@ -191,7 +192,7 @@ void ScFilterOptionsMgr::Init() rBtnHeader.Check( pDBData->HasHeader() ); pDBData->GetName( theDbName ); - if ( theDbName != rStrNoName ) + if ( theDbName!=rStrNoName ) { rBtnHeader.Disable(); } diff --git a/sc/source/ui/dbgui/pfiltdlg.cxx b/sc/source/ui/dbgui/pfiltdlg.cxx index 5cdf37116f13..ab96a0348a74 100644 --- a/sc/source/ui/dbgui/pfiltdlg.cxx +++ b/sc/source/ui/dbgui/pfiltdlg.cxx @@ -43,6 +43,7 @@ #include "document.hxx" #include "uiitems.hxx" #include "global.hxx" +#include "globalnames.hxx" #include "dbcolect.hxx" #include "scresid.hxx" @@ -90,7 +91,6 @@ ScPivotFilterDlg::ScPivotFilterDlg( Window* pParent, aBtnHelp ( this, ScResId( BTN_HELP ) ), aBtnMore ( this, ScResId( BTN_MORE ) ), aStrUndefined ( ScResId( SCSTR_UNDEFINED ) ), - aStrNoName ( ScGlobal::GetRscString(STR_DB_NONAME) ), aStrNone ( ScResId( SCSTR_NONE ) ), aStrEmpty ( ScResId( SCSTR_EMPTY ) ), aStrNotEmpty ( ScResId( SCSTR_NOTEMPTY ) ), @@ -175,7 +175,7 @@ void ScPivotFilterDlg::Init( const SfxItemSet& rArgSet ) nSrcTab ) ); ScDBCollection* pDBColl = pDoc->GetDBCollection(); String theDbArea; - String theDbName = aStrNoName; + String theDbName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(STR_DB_LOCAL_NONAME)); /* * Ueberpruefen, ob es sich bei dem uebergebenen diff --git a/sc/source/ui/dbgui/tpsort.cxx b/sc/source/ui/dbgui/tpsort.cxx index 6974e7d2135a..5145389cdc0a 100644 --- a/sc/source/ui/dbgui/tpsort.cxx +++ b/sc/source/ui/dbgui/tpsort.cxx @@ -43,6 +43,7 @@ #include "viewdata.hxx" #include "document.hxx" #include "global.hxx" +#include "globalnames.hxx" #include "dbcolect.hxx" #include "userlist.hxx" #include "rangeutl.hxx" @@ -582,7 +583,6 @@ ScTabPageSortOptions::ScTabPageSortOptions( Window* pParent, aStrRowLabel ( ScResId( STR_ROW_LABEL ) ), aStrColLabel ( ScResId( STR_COL_LABEL ) ), aStrUndefined ( ScResId( SCSTR_UNDEFINED ) ), - aStrNoName ( ScGlobal::GetRscString(STR_DB_NONAME) ), // nWhichSort ( rArgSet.GetPool()->GetWhich( SID_SORT ) ), rSortData ( ((const ScSortItem&) @@ -648,8 +648,8 @@ void ScTabPageSortOptions::Init() String theArea; ScDBCollection* pDBColl = pDoc->GetDBCollection(); String theDbArea; - String theDbName = aStrNoName; const SCTAB nCurTab = pViewData->GetTabNo(); + String theDbName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(STR_DB_LOCAL_NONAME)); const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention(); aLbOutPos.Clear(); diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx index 7ff1efa3cb78..8991706293a1 100644 --- a/sc/source/ui/docshell/dbdocfun.cxx +++ b/sc/source/ui/docshell/dbdocfun.cxx @@ -46,6 +46,7 @@ #include "docsh.hxx" #include "docfunc.hxx" #include "globstr.hrc" +#include "globalnames.hxx" #include "tabvwsh.hxx" #include "patattr.hxx" #include "rangenam.hxx" @@ -82,10 +83,18 @@ sal_Bool ScDBDocFunc::AddDBRange( const String& rName, const ScRange& rRange, sa // so CompileDBFormula would never find any name (index) tokens, and would // unnecessarily loop through all cells. sal_Bool bCompile = !pDoc->IsImportingXML(); - + sal_Bool bOk; if ( bCompile ) pDoc->CompileDBFormula( sal_True ); // CreateFormulaString - sal_Bool bOk = pDocColl->Insert( pNew ); + if (rtl::OUString(rName)==rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(STR_DB_LOCAL_NONAME))) + { + pDoc->SetAnonymousDBData(rRange.aStart.Tab() , pNew); + bOk = true; + } + else + { + bOk = pDocColl->Insert( pNew ); + } if ( bCompile ) pDoc->CompileDBFormula( false ); // CompileFormulaString @@ -200,13 +209,23 @@ sal_Bool ScDBDocFunc::ModifyDBData( const ScDBData& rNewData, sal_Bool /* bApi * ScDBCollection* pDocColl = pDoc->GetDBCollection(); sal_Bool bUndo (pDoc->IsUndoEnabled()); - sal_uInt16 nPos = 0; - if (pDocColl->SearchName( rNewData.GetName(), nPos )) + ScDBData* pData = NULL; + if (rtl::OUString(rNewData.GetName())==rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(STR_DB_LOCAL_NONAME))) + { + ScRange aRange; + rNewData.GetArea(aRange); + SCTAB nTab = aRange.aStart.Tab(); + pData = pDoc->GetAnonymousDBData(nTab); + } + else + { + sal_uInt16 nPos = 0; + if (pDocColl->SearchName( rNewData.GetName(), nPos )) + pData = (*pDocColl)[nPos]; + } + if (pData) { ScDocShellModificator aModificator( rDocShell ); - - ScDBData* pData = (*pDocColl)[nPos]; - ScRange aOldRange, aNewRange; pData->GetArea(aOldRange); rNewData.GetArea(aNewRange); diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx index 4fafac178e2f..88df90702bba 100644 --- a/sc/source/ui/docshell/docsh5.cxx +++ b/sc/source/ui/docshell/docsh5.cxx @@ -50,6 +50,7 @@ #include "docsh.hxx" #include "global.hxx" #include "globstr.hrc" +#include "globalnames.hxx" #include "undodat.hxx" #include "undotab.hxx" #include "undoblk.hxx" @@ -130,43 +131,6 @@ void ScDocShell::DBAreaDeleted( SCTAB nTab, SCCOL nX1, SCROW nY1, SCCOL nX2, SCR aDocument.BroadcastUno( SfxSimpleHint( SFX_HINT_DATACHANGED ) ); } -ScDBData* lcl_GetDBNearCursor( ScDBCollection* pColl, SCCOL nCol, SCROW nRow, SCTAB nTab ) -{ - //! nach document/dbcolect verschieben - - if (!pColl) - return NULL; - - ScDBData* pNoNameData = NULL; - ScDBData* pNearData = NULL; - sal_uInt16 nCount = pColl->GetCount(); - String aNoName = ScGlobal::GetRscString( STR_DB_NONAME ); - SCTAB nAreaTab; - SCCOL nStartCol, nEndCol; - SCROW nStartRow, nEndRow; - for (sal_uInt16 i = 0; i < nCount; i++) - { - ScDBData* pDB = (*pColl)[i]; - pDB->GetArea( nAreaTab, nStartCol, nStartRow, nEndCol, nEndRow ); - if ( nTab == nAreaTab && nCol+1 >= nStartCol && nCol <= nEndCol+1 && - nRow+1 >= nStartRow && nRow <= nEndRow+1 ) - { - if ( pDB->GetName() == aNoName ) - pNoNameData = pDB; - else if ( nCol < nStartCol || nCol > nEndCol || nRow < nStartRow || nRow > nEndRow ) - { - if (!pNearData) - pNearData = pDB; // ersten angrenzenden Bereich merken - } - else - return pDB; // nicht "unbenannt" und Cursor steht wirklich drin - } - } - if (pNearData) - return pNearData; // angrenzender, wenn nichts direkt getroffen - return pNoNameData; // "unbenannt" nur zurueck, wenn sonst nichts gefunden -} - ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGetDBSelection eSel ) { SCCOL nCol = rMarked.aStart.Col(); @@ -179,14 +143,13 @@ ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGe SCCOL nEndCol = rMarked.aEnd.Col(); SCROW nEndRow = rMarked.aEnd.Row(); SCTAB nEndTab = rMarked.aEnd.Tab(); - // Nicht einfach GetDBAtCursor: Der zusammenhaengende Datenbereich // fuer "unbenannt" (GetDataArea) kann neben dem Cursor legen, also muss auch ein // benannter DB-Bereich dort gesucht werden. - + ScDBCollection* pColl = aDocument.GetDBCollection(); ScDBData* pData = aDocument.GetDBAtArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow ); - if (!pData) - pData = lcl_GetDBNearCursor( aDocument.GetDBCollection(), nCol, nRow, nTab ); + if (!pData && pColl) + pData = pColl->GetDBNearCursor(nCol, nRow, nTab ); sal_Bool bSelected = ( eSel == SC_DBSEL_FORCE_MARK || (rMarked.aStart != rMarked.aEnd && eSel != SC_DBSEL_ROW_DOWN) ); @@ -203,7 +166,7 @@ ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGe SCCOL nOldCol2; SCROW nOldRow2; pData->GetArea( nDummy, nOldCol1,nOldRow1, nOldCol2,nOldRow2 ); - sal_Bool bIsNoName = ( pData->GetName() == ScGlobal::GetRscString( STR_DB_NONAME ) ); + sal_Bool bIsNoName = ( rtl::OUString(pData->GetName()) == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(STR_DB_LOCAL_NONAME)) ); if (!bSelected) { @@ -282,13 +245,9 @@ ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGe sal_Bool bHasHeader = aDocument.HasColHeader( nStartCol,nStartRow, nEndCol,nEndRow, nTab ); - ScDBData* pNoNameData; - sal_uInt16 nNoNameIndex; - ScDBCollection* pColl = aDocument.GetDBCollection(); - if ( eMode != SC_DB_IMPORT && - pColl->SearchName( ScGlobal::GetRscString( STR_DB_NONAME ), nNoNameIndex ) ) + ScDBData* pNoNameData = aDocument.GetAnonymousDBData(nTab); + if ( eMode != SC_DB_IMPORT && pNoNameData) { - pNoNameData = (*pColl)[nNoNameIndex]; if ( !pOldAutoDBRange ) { @@ -334,13 +293,21 @@ ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGe aNewName += String::CreateFromInt32( nCount ); } while (pColl->SearchName( aNewName, nDummy )); + pNoNameData = new ScDBData( aNewName, nTab, + nStartCol,nStartRow, nEndCol,nEndRow, + sal_True, bHasHeader ); + pColl->Insert( pNoNameData ); } else - aNewName = ScGlobal::GetRscString( STR_DB_NONAME ); - pNoNameData = new ScDBData( aNewName, nTab, + { + aNewName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(STR_DB_LOCAL_NONAME)); + pNoNameData = new ScDBData(aNewName , nTab, nStartCol,nStartRow, nEndCol,nEndRow, sal_True, bHasHeader ); - pColl->Insert( pNoNameData ); + aDocument.SetAnonymousDBData(nTab, pNoNameData); + } + + if ( pUndoColl ) { @@ -372,23 +339,22 @@ ScDBData* ScDocShell::GetOldAutoDBRange() void ScDocShell::CancelAutoDBRange() { // called when dialog is cancelled +//moggi:TODO if ( pOldAutoDBRange ) { - sal_uInt16 nNoNameIndex; - ScDBCollection* pColl = aDocument.GetDBCollection(); - if ( pColl->SearchName( ScGlobal::GetRscString( STR_DB_NONAME ), nNoNameIndex ) ) + SCTAB nTab = GetCurTab(); + ScDBData* pDBData = aDocument.GetAnonymousDBData(nTab); + if ( pDBData ) { - ScDBData* pNoNameData = (*pColl)[nNoNameIndex]; - SCCOL nRangeX1; SCROW nRangeY1; SCCOL nRangeX2; SCROW nRangeY2; SCTAB nRangeTab; - pNoNameData->GetArea( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 ); + pDBData->GetArea( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 ); DBAreaDeleted( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 ); - *pNoNameData = *pOldAutoDBRange; // restore old settings + *pDBData = *pOldAutoDBRange; // restore old settings if ( pOldAutoDBRange->HasAutoFilter() ) { @@ -507,8 +473,7 @@ String lcl_GetAreaName( ScDocument* pDoc, ScArea* pArea ) if (pData) { pData->GetName( aName ); - if ( aName != ScGlobal::GetRscString( STR_DB_NONAME ) ) - bOk = sal_True; + bOk = sal_True; } if (!bOk) diff --git a/sc/source/ui/inc/pfiltdlg.hxx b/sc/source/ui/inc/pfiltdlg.hxx index bb68e07b3891..0c35cc916a13 100644 --- a/sc/source/ui/inc/pfiltdlg.hxx +++ b/sc/source/ui/inc/pfiltdlg.hxx @@ -90,7 +90,6 @@ private: HelpButton aBtnHelp; MoreButton aBtnMore; const String aStrUndefined; - const String aStrNoName; const String aStrNone; const String aStrEmpty; const String aStrNotEmpty; diff --git a/sc/source/ui/inc/tpsort.hxx b/sc/source/ui/inc/tpsort.hxx index 8f22696c879d..fefd0575f3d2 100644 --- a/sc/source/ui/inc/tpsort.hxx +++ b/sc/source/ui/inc/tpsort.hxx @@ -188,7 +188,6 @@ private: LocalizedString aStrRowLabel; LocalizedString aStrColLabel; LocalizedString aStrUndefined; - String aStrNoName; String aStrAreaLabel; const sal_uInt16 nWhichSort; diff --git a/sc/source/ui/inc/undobase.hxx b/sc/source/ui/inc/undobase.hxx index abc6770157e0..701378430d2d 100644 --- a/sc/source/ui/inc/undobase.hxx +++ b/sc/source/ui/inc/undobase.hxx @@ -101,6 +101,7 @@ protected: class ScDBFuncUndo: public ScSimpleUndo { +protected: ScDBData* pAutoDBRange; ScRange aOriginalRange; SdrUndoAction* mpDrawUndo; diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx index 90d83f861008..ad957181e12f 100644 --- a/sc/source/ui/navipi/content.cxx +++ b/sc/source/ui/navipi/content.cxx @@ -708,13 +708,11 @@ void ScContentTree::GetDbNames() sal_uInt16 nCount = pDbNames->GetCount(); if ( nCount > 0 ) { - String aStrNoName( ScGlobal::GetRscString(STR_DB_NONAME) ); for ( sal_uInt16 i=0; i<nCount; i++ ) { ScDBData* pData = (*pDbNames)[i]; String aStrName = pData->GetName(); - if ( aStrName != aStrNoName ) - InsertContent( SC_CONTENT_DBAREA, aStrName ); + InsertContent( SC_CONTENT_DBAREA, aStrName ); } } } diff --git a/sc/source/ui/undo/undobase.cxx b/sc/source/ui/undo/undobase.cxx index f7da441529bc..20d38fc9a89a 100644 --- a/sc/source/ui/undo/undobase.cxx +++ b/sc/source/ui/undo/undobase.cxx @@ -371,13 +371,11 @@ void ScDBFuncUndo::EndUndo() if ( pAutoDBRange ) { - sal_uInt16 nNoNameIndex; ScDocument* pDoc = pDocShell->GetDocument(); - ScDBCollection* pColl = pDoc->GetDBCollection(); - if ( pColl->SearchName( ScGlobal::GetRscString( STR_DB_NONAME ), nNoNameIndex ) ) + SCTAB nTab = pDoc->GetVisibleTab(); + ScDBData* pNoNameData = pDoc->GetAnonymousDBData(nTab); + if (pNoNameData ) { - ScDBData* pNoNameData = (*pColl)[nNoNameIndex]; - SCCOL nRangeX1; SCROW nRangeY1; SCCOL nRangeX2; @@ -406,12 +404,10 @@ void ScDBFuncUndo::BeginRedo() { // move the database range to this function's position again (see ScDocShell::GetDBData) - sal_uInt16 nNoNameIndex; ScDocument* pDoc = pDocShell->GetDocument(); - ScDBCollection* pColl = pDoc->GetDBCollection(); - if ( pColl->SearchName( ScGlobal::GetRscString( STR_DB_NONAME ), nNoNameIndex ) ) + ScDBData* pNoNameData = pDoc->GetAnonymousDBData(aOriginalRange.aStart.Tab()); + if ( pNoNameData ) { - ScDBData* pNoNameData = (*pColl)[nNoNameIndex]; SCCOL nRangeX1; SCROW nRangeY1; diff --git a/sc/source/ui/undo/undodat.cxx b/sc/source/ui/undo/undodat.cxx index dc23ff8f6aeb..b1c3bc5693ef 100644 --- a/sc/source/ui/undo/undodat.cxx +++ b/sc/source/ui/undo/undodat.cxx @@ -45,6 +45,7 @@ #include "pivot.hxx" #include "globstr.hrc" #include "global.hxx" +#include "globalnames.hxx" #include "target.hxx" #include "chartarr.hxx" #include "dbdocfun.hxx" @@ -1111,10 +1112,22 @@ void ScUndoAutoFilter::DoChange( sal_Bool bUndo ) sal_uInt16 nIndex; ScDocument* pDoc = pDocShell->GetDocument(); - ScDBCollection* pColl = pDoc->GetDBCollection(); - if ( pColl->SearchName( aDBName, nIndex ) ) + ScDBData* pDBData=NULL; + if (rtl::OUString(aDBName) == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(STR_DB_LOCAL_NONAME))) + { + SCTAB nTab = aOriginalRange.aStart.Tab(); + pDBData = pDoc->GetAnonymousDBData(nTab); + } + else + { + ScDBCollection* pColl = pDoc->GetDBCollection(); + if (pColl->SearchName( aDBName, nIndex )) + pDBData = (*pColl)[nIndex]; + } + + + if ( pDBData ) { - ScDBData* pDBData = (*pColl)[nIndex]; pDBData->SetAutoFilter( bNewFilter ); SCCOL nRangeX1; diff --git a/sc/source/ui/undo/undoutil.cxx b/sc/source/ui/undo/undoutil.cxx index 9668e5b0d4ac..f022e0492ce6 100644 --- a/sc/source/ui/undo/undoutil.cxx +++ b/sc/source/ui/undo/undoutil.cxx @@ -42,6 +42,7 @@ #include "document.hxx" #include "dbcolect.hxx" #include "globstr.hrc" +#include "globalnames.hxx" #include "global.hxx" void ScUndoUtil::MarkSimpleBlock( ScDocShell* pDocShell, @@ -98,22 +99,18 @@ ScDBData* ScUndoUtil::GetOldDBData( ScDBData* pUndoData, ScDocument* pDoc, SCTAB { String aName; pUndoData->GetName( aName ); - if ( aName == ScGlobal::GetRscString( STR_DB_NONAME ) ) + if ( rtl::OUString(aName) == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(STR_DB_LOCAL_NONAME) ) ) bWasTemp = sal_True; } DBG_ASSERT(bWasTemp, "Undo: didn't find database range"); (void)bWasTemp; - - sal_uInt16 nIndex; - ScDBCollection* pColl = pDoc->GetDBCollection(); - if (pColl->SearchName( ScGlobal::GetRscString( STR_DB_NONAME ), nIndex )) - pRet = (*pColl)[nIndex]; - else + pRet = pDoc->GetAnonymousDBData(nTab); + if (!pRet) { - pRet = new ScDBData( ScGlobal::GetRscString( STR_DB_NONAME ), nTab, + pRet = new ScDBData( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(STR_DB_LOCAL_NONAME)), nTab, nCol1,nRow1, nCol2,nRow2, sal_True, pDoc->HasColHeader( nCol1,nRow1,nCol2,nRow2,nTab ) ); - pColl->Insert( pRet ); + pDoc->SetAnonymousDBData(nTab,pRet); } } diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx index 7c8ef5b8fcd4..b44b1c760c4f 100644 --- a/sc/source/ui/unoobj/datauno.cxx +++ b/sc/source/ui/unoobj/datauno.cxx @@ -1636,6 +1636,15 @@ ScDBData* ScDatabaseRangeObj::GetDBData_Impl() const ScDBData* pRet = NULL; if (pDocShell) { + ScDocument* pDoc = pDocShell->GetDocument(); + if (rtl::OUString(aName).match(ScGlobal::GetRscString(STR_DB_NONAME))) + { + rtl::OUString aDBNoName(aName); + aDBNoName = aDBNoName.replaceAt(0,rtl::OUString(ScGlobal::GetRscString(STR_DB_NONAME)).getLength(),rtl::OUString()); + SCTAB nTab = aDBNoName.toInt32(); + if (pDoc->GetAnonymousDBData(nTab)) + return pDoc->GetAnonymousDBData(nTab); + } ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection(); if (pNames) { @@ -2184,9 +2193,29 @@ ScDatabaseRangeObj* ScDatabaseRangesObj::GetObjectByIndex_Impl(sal_uInt16 nIndex { if (pDocShell) { - ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection(); + ScDocument* pDoc = pDocShell->GetDocument(); + ScDBCollection* pNames = pDoc->GetDBCollection(); if (pNames && nIndex < pNames->GetCount()) return new ScDatabaseRangeObj( pDocShell, (*pNames)[nIndex]->GetName() ); + else + { + sal_uInt16 nCount = 0; + if (pNames) + nCount = pNames->GetCount(); + for (SCTAB nTab = 0; nTab < pDoc->GetTableCount(); ++nTab) + { + if (pDoc->GetAnonymousDBData(nTab)) + { + if (nIndex==nCount) + { + rtl::OUStringBuffer aBuffer(ScGlobal::GetRscString( STR_DB_NONAME )); + aBuffer.append(nTab); + return new ScDatabaseRangeObj( pDocShell, aBuffer.makeStringAndClear()); + } + ++nCount; + } + } + } } return NULL; } @@ -2210,12 +2239,28 @@ void SAL_CALL ScDatabaseRangesObj::addNewByName( const rtl::OUString& aName, sal_Bool bDone = false; if (pDocShell) { - ScDBDocFunc aFunc(*pDocShell); - - String aString(aName); - ScRange aNameRange( (SCCOL)aRange.StartColumn, (SCROW)aRange.StartRow, aRange.Sheet, - (SCCOL)aRange.EndColumn, (SCROW)aRange.EndRow, aRange.Sheet ); - bDone = aFunc.AddDBRange( aString, aNameRange, sal_True ); + //moggi + if (aName.match(ScGlobal::GetRscString( STR_DB_NONAME ))) + { + rtl::OUString aDBNoName(aName); + aDBNoName = aDBNoName.replaceAt(0,rtl::OUString(ScGlobal::GetRscString(STR_DB_NONAME)).getLength(),rtl::OUString()); + SCTAB nTab = aDBNoName.toInt32(); + String aNewName = ScGlobal::GetRscString( STR_DB_NONAME ); + ScDBData* pNoNameData = new ScDBData(aNewName , nTab, + (SCCOL)aRange.StartColumn,(SCROW)aRange.StartRow, + (SCCOL)aRange.EndColumn,(SCROW)aRange.EndRow, + sal_True, true );//moggi + pDocShell->GetDocument()->SetAnonymousDBData(nTab,pNoNameData); + bDone = true; + } + else + { + ScDBDocFunc aFunc(*pDocShell); + String aString(aName); + ScRange aNameRange( (SCCOL)aRange.StartColumn, (SCROW)aRange.StartRow, aRange.Sheet, + (SCCOL)aRange.EndColumn, (SCROW)aRange.EndRow, aRange.Sheet ); + bDone = aFunc.AddDBRange( aString, aNameRange, sal_True ); + } } if (!bDone) throw uno::RuntimeException(); // no other exceptions specified @@ -2255,9 +2300,17 @@ sal_Int32 SAL_CALL ScDatabaseRangesObj::getCount() throw(uno::RuntimeException) if (pDocShell) { - ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection(); + sal_Int32 nCountAnonymousDBData; + ScDocument* pDoc = pDocShell->GetDocument(); + for (SCTAB nTab=0; nTab<pDoc->GetTableCount();nTab++) + { + if (pDoc->GetAnonymousDBData(nTab)) + ++nCountAnonymousDBData; + } + ScDBCollection* pNames = pDoc->GetDBCollection(); if (pNames) - return pNames->GetCount(); + return pNames->GetCount() + nCountAnonymousDBData ; + return nCountAnonymousDBData; } return 0; } @@ -2310,16 +2363,36 @@ uno::Sequence<rtl::OUString> SAL_CALL ScDatabaseRangesObj::getElementNames() if (pDocShell) { - ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection(); + ScDocument* pDoc = pDocShell->GetDocument(); + sal_uInt16 nCountAnonymousDBData=0; + for (SCTAB nTab=0; nTab<pDoc->GetTableCount();nTab++) + { + if (pDoc->GetAnonymousDBData(nTab)) + nCountAnonymousDBData++; + } + ScDBCollection* pNames = pDoc->GetDBCollection(); + sal_uInt16 nCountDBData = 0; if (pNames) { - sal_uInt16 nCount = pNames->GetCount(); + nCountDBData = pNames->GetCount(); String aName; - uno::Sequence<rtl::OUString> aSeq(nCount); + uno::Sequence<rtl::OUString> aSeq(nCountDBData + nCountAnonymousDBData); rtl::OUString* pAry = aSeq.getArray(); - for (sal_uInt16 i=0; i<nCount; i++) + for (sal_uInt16 i=0; i<nCountDBData; i++) + { pAry[i] = (*pNames)[i]->GetName(); - + } + for (SCTAB nTab=0;nTab<pDoc->GetTableCount();nTab++) + { + sal_uInt16 i =0; + if (pDoc->GetAnonymousDBData(nTab)) + { + rtl::OUStringBuffer aStrBuffer(ScGlobal::GetRscString( STR_DB_NONAME )); + aStrBuffer.append(nTab); + pAry[nCountDBData+i]=aStrBuffer.makeStringAndClear(); + i++; + } + } return aSeq; } } @@ -2335,7 +2408,18 @@ sal_Bool SAL_CALL ScDatabaseRangesObj::hasByName( const rtl::OUString& aName ) if (pDocShell) { - ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection(); + ScDocument* pDoc = pDocShell->GetDocument(); + if (aName.match(ScGlobal::GetRscString(STR_DB_NONAME))) + { + rtl::OUString aDBNoName(aName); + aDBNoName = aDBNoName.replaceAt(0,rtl::OUString(ScGlobal::GetRscString(STR_DB_NONAME)).getLength(),rtl::OUString()); + SCTAB nTab = aDBNoName.toInt32(); + if (pDoc->GetAnonymousDBData(nTab)) + return sal_True; + else + return sal_False; + } + ScDBCollection* pNames = pDoc->GetDBCollection(); if (pNames) { String aString(aName); diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx index 8091d579ac6c..f7d8431b7fbb 100644 --- a/sc/source/ui/view/cellsh2.cxx +++ b/sc/source/ui/view/cellsh2.cxx @@ -56,6 +56,7 @@ #include "sc.hrc" #include "globstr.hrc" #include "global.hxx" +#include "globalnames.hxx" #include "scmod.hxx" #include "docsh.hxx" #include "document.hxx" @@ -722,7 +723,7 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq ) if ( pDBCol ) { - const String aStrNoName( ScGlobal::GetRscString(STR_DB_NONAME) ); + const String aStrNoName( RTL_CONSTASCII_USTRINGPARAM(STR_DB_LOCAL_NONAME) ); List aList; sal_uInt16 nDBCount = pDBCol->GetCount(); ScDBData* pDbData = NULL; @@ -736,7 +737,7 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq ) pDBName = new String; pDbData->GetName( *pDBName ); - if ( *pDBName != aStrNoName ) + if ( *pDBName!=aStrNoName ) aList.Insert( pDBName ); else DELETEZ(pDBName); |