diff options
-rw-r--r-- | sc/inc/dbcolect.hxx | 5 | ||||
-rw-r--r-- | sc/inc/document.hxx | 1 | ||||
-rw-r--r-- | sc/inc/global.hxx | 6 | ||||
-rw-r--r-- | sc/source/core/data/documen3.cxx | 10 | ||||
-rw-r--r-- | sc/source/core/tool/dbcolect.cxx | 77 | ||||
-rw-r--r-- | sc/source/core/tool/rangeutl.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/dbgui/dbnamdlg.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/dbgui/foptmgr.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/docshell/dbdocfun.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh5.cxx | 173 | ||||
-rw-r--r-- | sc/source/ui/inc/dbfunc.hxx | 1 | ||||
-rw-r--r-- | sc/source/ui/inc/docsh.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/navipi/content.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/undo/undobase.cxx | 23 | ||||
-rw-r--r-- | sc/source/ui/undo/undoutil.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/view/cellsh2.cxx | 11 | ||||
-rw-r--r-- | sc/source/ui/view/dbfunc.cxx | 31 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwshc.cxx | 4 |
18 files changed, 329 insertions, 39 deletions
diff --git a/sc/inc/dbcolect.hxx b/sc/inc/dbcolect.hxx index 0d35f7cd5d5e..3c436d9f3e98 100644 --- a/sc/inc/dbcolect.hxx +++ b/sc/inc/dbcolect.hxx @@ -136,6 +136,8 @@ public: void GetArea(SCTAB& rTab, SCCOL& rCol1, SCROW& rRow1, SCCOL& rCol2, SCROW& rRow2) const; SC_DLLPUBLIC void GetArea(ScRange& rRange) const; void SetArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2); + //If the name of DBData is started with "unnamed", it will be recognized as build in DBData + sal_Bool IsBuildin(); void MoveTo(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2); sal_Bool IsByRow() const { return bByRow; } void SetByRow(sal_Bool bByR) { bByRow = bByR; } @@ -216,6 +218,7 @@ public: ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Bool bStartOnly) const; ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const; ScDBData* GetFilterDBAtTable(SCTAB nTab) const; + ScDBData* GetDBAtTable(SCTAB nTab, ScGetDBMode eMode) const; sal_Bool SearchName( const String& rName, sal_uInt16& rIndex ) const; @@ -234,6 +237,8 @@ public: void SetRefreshHandler( const Link& rLink ) { aRefreshHandler = rLink; } const Link& GetRefreshHandler() const { return aRefreshHandler; } + String GetNewDefaultDBName(); + /*sal_Bool IsFiltered(SCTAB nTab, SCROW nRow);*/ }; #endif diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index cd4048f3a7bc..34259c158ecb 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -505,6 +505,7 @@ public: //UNUSED2008-05 ScRangeData* GetRangeAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, //UNUSED2008-05 sal_Bool bStartOnly = sal_False) const; SC_DLLPUBLIC ScRangeData* GetRangeAtBlock( const ScRange& rBlock, String* pName=NULL ) const; + ScDBData* GetDBAtTable(SCTAB nTab, ScGetDBMode eMode) const; SC_DLLPUBLIC ScDPCollection* GetDPCollection(); ScDPObject* GetDPAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab) const; diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx index ef83dce5e90b..d2206aa46bb2 100644 --- a/sc/inc/global.hxx +++ b/sc/inc/global.hxx @@ -406,7 +406,11 @@ enum ScGetDBMode { SC_DB_MAKE, // wenn noetig, "unbenannt" anlegen SC_DB_IMPORT, // wenn noetig, "Importx" anlegen - SC_DB_OLD // nicht neu anlegen + SC_DB_OLD, // nicht neu anlegen + SC_DB_MAKE_FILTER, // to create a new filter/sort/subtotal + SC_DB_MAKE_SORT, + SC_DB_MAKE_SUBTOTAL, + SC_DB_OLD_FILTER //to find a existed filter }; /// For ScDBFunc::GetDBData() diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx index 87ec83d1e246..7e19b6734e2c 100644 --- a/sc/source/core/data/documen3.cxx +++ b/sc/source/core/data/documen3.cxx @@ -192,6 +192,13 @@ ScDBData* ScDocument::GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nC else return NULL; } +ScDBData* ScDocument::GetDBAtTable(SCTAB nTab, ScGetDBMode eMode) const +{ + if (pDBCollection) + return pDBCollection->GetDBAtTable(nTab, eMode); + else + return NULL; +} ScDBData* ScDocument::GetFilterDBAtTable(SCTAB nTab) const { @@ -1291,7 +1298,8 @@ sal_Bool ScDocument::CreateQueryParam(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCR sal_Bool ScDocument::HasAutoFilter( SCCOL nCurCol, SCROW nCurRow, SCTAB nCurTab ) { - ScDBData* pDBData = GetDBAtCursor( nCurCol, nCurRow, nCurTab ); + //ScDBData* pDBData = GetDBAtCursor( nCurCol, nCurRow, nCurTab ); + ScDBData* pDBData = GetDBAtTable(nCurTab, SC_DB_OLD_FILTER); sal_Bool bHasAutoFilter = ( pDBData != NULL ); if ( pDBData ) diff --git a/sc/source/core/tool/dbcolect.cxx b/sc/source/core/tool/dbcolect.cxx index 621e1e75040f..bc1c1db78c2e 100644 --- a/sc/source/core/tool/dbcolect.cxx +++ b/sc/source/core/tool/dbcolect.cxx @@ -36,6 +36,7 @@ #include "queryparam.hxx" #include "globstr.hrc" +#define SC_DBNAME_UNNAMED "__Anonymous_Sheet_DB__" //--------------------------------------------------------------------------------------- @@ -690,7 +691,12 @@ ScDataObject* ScDBData::Clone() const { return new ScDBData(*this); } - +sal_Bool ScDBData::IsBuildin() +{ + String aNoName = String::CreateFromAscii(SC_DBNAME_UNNAMED); + String aBeginName = aName.Copy(0,22); + return (sal_Bool)(!ScGlobal::GetpTransliteration()->compareString( aNoName, aBeginName )); +} //--------------------------------------------------------------------------------------- // Compare zum Sortieren @@ -714,13 +720,12 @@ ScDBData* ScDBCollection::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_ ScDBData* pNoNameData = NULL; if (pItems) { - const String& rNoName = ScGlobal::GetRscString( STR_DB_NONAME ); for (sal_uInt16 i = 0; i < nCount; i++) if (((ScDBData*)pItems[i])->IsDBAtCursor(nCol, nRow, nTab, bStartOnly)) { ScDBData* pDB = (ScDBData*)pItems[i]; - if ( pDB->GetName() == rNoName ) + if ( pDB->IsBuildin() ) pNoNameData = pDB; else return pDB; @@ -734,13 +739,12 @@ ScDBData* ScDBCollection::GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCO ScDBData* pNoNameData = NULL; if (pItems) { - const String& rNoName = ScGlobal::GetRscString( STR_DB_NONAME ); for (sal_uInt16 i = 0; i < nCount; i++) if (((ScDBData*)pItems[i])->IsDBAtArea(nTab, nCol1, nRow1, nCol2, nRow2)) { ScDBData* pDB = (ScDBData*)pItems[i]; - if ( pDB->GetName() == rNoName ) + if ( pDB->IsBuildin() ) pNoNameData = pDB; else return pDB; @@ -903,6 +907,67 @@ sal_Bool ScDBCollection::Insert(ScDataObject* pScDataObject) return bInserted; } +String ScDBCollection::GetNewDefaultDBName() +{ + String aNoName = String::CreateFromAscii(SC_DBNAME_UNNAMED); + String aNewName; + unsigned short nDummy; + int i = 1; + do + { + aNewName = aNoName; + aNewName += String::CreateFromInt32( i++ ); + }while(SearchName(aNewName,nDummy)); + return aNewName; +} +/* +sal_Bool ScDBCollection::IsFiltered(SCTAB nTab, SCROW nRow) +{ + SCCOL nLastCol; + SCROW nLastRow; + pDoc->GetLastAttrCellArea(nTab, nLastCol, nLastRow); + if ( pItems ) + { + for (unsigned short i = 0; i < nCount; i++) + { + ScDBData* pData = (ScDBData*)pItems[i]; + if ( pData->nTable == nTab && pData->HasQueryParam() && pData->bQueryInplace ) + if ( nRow >= (pData->nStartRow + (pData->HasHeader()?1:0)) && nRow <= pData->nEndRow && nRow <= nLastRow ) + return sal_True; + } + } + return sal_False; +} +*/ +ScDBData* ScDBCollection::GetDBAtTable(SCTAB nTab, ScGetDBMode eMode) const +{ + ScDBData* pDataEmpty = NULL; + if (pItems) + { + for (unsigned short i = 0; i < nCount; i++) + { + ScDBData* pDBTemp = (ScDBData*)pItems[i]; + if ( pDBTemp->nTable == nTab ) //Sym2_7885 mod + { + sal_Bool bImport = pDBTemp->HasImportParam(); + sal_Bool bFilter = pDBTemp->HasAutoFilter() || pDBTemp->HasQueryParam(); + sal_Bool bSort = pDBTemp->HasSortParam(); + sal_Bool bSubtotal = pDBTemp->HasSubTotalParam(); + sal_Bool bAnyParam = bImport || bFilter || bSort || bSubtotal; + if ( ((eMode == SC_DB_MAKE_SORT) && bSort && !bFilter) || //Sym2_7334 mod 20100420 + ((eMode == SC_DB_MAKE_SUBTOTAL) && bSubtotal && !bFilter ) || + ((eMode == SC_DB_MAKE_FILTER || eMode == SC_DB_OLD_FILTER) && bFilter ) ) + { + return pDBTemp; + } + else if ( pDBTemp->IsBuildin() && !bAnyParam ) //Sym2_7885 mod + { + pDataEmpty = pDBTemp; + } + } + } + } - + return pDataEmpty; +} diff --git a/sc/source/core/tool/rangeutl.cxx b/sc/source/core/tool/rangeutl.cxx index 730155d36911..ae36c671088a 100644 --- a/sc/source/core/tool/rangeutl.cxx +++ b/sc/source/core/tool/rangeutl.cxx @@ -1032,7 +1032,8 @@ sal_Bool ScAreaNameIterator::Next( String& rName, ScRange& rRange ) if ( pDBCollection && nPos < pDBCollection->GetCount() ) { ScDBData* pData = (*pDBCollection)[nPos++]; - if (pData && pData->GetName() != aStrNoName) +// if (pData && pData->GetName() != aStrNoName) + if (pData && !pData->IsBuildin()) { pData->GetArea( rRange ); rName = pData->GetName(); diff --git a/sc/source/ui/dbgui/dbnamdlg.cxx b/sc/source/ui/dbgui/dbnamdlg.cxx index 4021b3784aba..cc843cc87688 100644 --- a/sc/source/ui/dbgui/dbnamdlg.cxx +++ b/sc/source/ui/dbgui/dbnamdlg.cxx @@ -266,7 +266,8 @@ void ScDbNameDlg::Init() && (rEnd.Col() == nCol2) && (rEnd.Row() == nRow2 ) ) { pDBData->GetName( theDbName ); - if ( theDbName != aStrNoName ) + //if ( theDbName != aStrNoName ) + if ( !pDBData->IsBuildin() ) aEdName.SetText( theDbName ); else aEdName.SetText( EMPTY_STRING ); @@ -378,7 +379,8 @@ void ScDbNameDlg::UpdateNames() if ( pDbData ) { pDbData->GetName( aString ); - if ( aString != aStrNoName ) + //if ( aString != aStrNoName ) + if ( !pDbData->IsBuildin() ) aEdName.InsertEntry( aString ); } } diff --git a/sc/source/ui/dbgui/foptmgr.cxx b/sc/source/ui/dbgui/foptmgr.cxx index 77522e32aeb5..0e7c546b8313 100644 --- a/sc/source/ui/dbgui/foptmgr.cxx +++ b/sc/source/ui/dbgui/foptmgr.cxx @@ -186,7 +186,7 @@ void ScFilterOptionsMgr::Init() rBtnHeader.Check( pDBData->HasHeader() ); pDBData->GetName( theDbName ); - if ( theDbName != rStrNoName ) + if ( !pDBData->IsBuildin() ) { rBtnHeader.Disable(); } diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx index 9ed1afbb137d..921d1271e58e 100644 --- a/sc/source/ui/docshell/dbdocfun.cxx +++ b/sc/source/ui/docshell/dbdocfun.cxx @@ -592,7 +592,7 @@ sal_Bool ScDBDocFunc::Sort( SCTAB nTab, const ScSortParam& rSortParam, if (pDestData) pNewData = pDestData; // Bereich vorhanden -> anpassen else // Bereich ab Cursor/Markierung wird angelegt - pNewData = rDocShell.GetDBData(aDestPos, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); + pNewData = rDocShell.GetDBData(aDestPos, SC_DB_MAKE_SORT, SC_DBSEL_FORCE_MARK ); if (pNewData) { pNewData->SetArea( nTab, @@ -919,7 +919,7 @@ sal_Bool ScDBDocFunc::Query( SCTAB nTab, const ScQueryParam& rQueryParam, pNewData = rDocShell.GetDBData( ScRange( aLocalParam.nCol1, aLocalParam.nRow1, nDestTab, aLocalParam.nCol2, aLocalParam.nRow2, nDestTab ), - SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); + SC_DB_MAKE_FILTER, SC_DBSEL_FORCE_MARK ); if (pNewData) { diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx index f9bc5c4eec13..4a8aa83bac3a 100644 --- a/sc/source/ui/docshell/docsh5.cxx +++ b/sc/source/ui/docshell/docsh5.cxx @@ -150,6 +150,8 @@ ScDBData* lcl_GetDBNearCursor( ScDBCollection* pColl, SCCOL nCol, SCROW nRow, SC ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGetDBSelection eSel ) { + if ( eMode == SC_DB_MAKE_FILTER || eMode == SC_DB_MAKE_SORT || eMode == SC_DB_MAKE_SUBTOTAL || eMode == SC_DB_OLD_FILTER ) + return GetDBDataAdd(rMarked, eMode, eSel); SCCOL nCol = rMarked.aStart.Col(); SCROW nRow = rMarked.aStart.Row(); SCTAB nTab = rMarked.aStart.Tab(); @@ -184,7 +186,8 @@ 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 = ( pData->GetName() == ScGlobal::GetRscString( STR_DB_NONAME ) ); + sal_Bool bIsNoName = pData->IsBuildin(); if (!bSelected) { @@ -322,7 +325,9 @@ ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGe while (pColl->SearchName( aNewName, nDummy )); } else - aNewName = ScGlobal::GetRscString( STR_DB_NONAME ); + //aNewName = ScGlobal::GetRscString( STR_DB_NONAME ); + aNewName = pColl->GetNewDefaultDBName(); + pNoNameData = new ScDBData( aNewName, nTab, nStartCol,nStartRow, nEndCol,nEndRow, sal_True, bHasHeader ); @@ -351,6 +356,170 @@ ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGe return pData; } +ScDBData* ScDocShell::GetDBDataAdd( const ScRange& rMarked, ScGetDBMode eMode, ScGetDBSelection eSel ) +{ + SCCOL nCol = rMarked.aStart.Col(); + SCROW nRow = rMarked.aStart.Row(); + SCTAB nTab = rMarked.aStart.Tab(); + + SCCOL nStartCol = nCol; + SCROW nStartRow = nRow; + SCTAB nStartTab = nTab; + SCCOL nEndCol = rMarked.aEnd.Col(); + SCROW nEndRow = rMarked.aEnd.Row(); + SCTAB nEndTab = rMarked.aEnd.Tab(); + + ScDBData* pData = NULL; + ScDBData* pCursorData; + pCursorData = aDocument.GetDBAtArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow ); + if ( !pCursorData ) + pCursorData = aDocument.GetDBAtCursor( nStartCol, nStartRow, nTab ); + + //Get DBData at current table + ScDBData* pTableData = aDocument.GetDBAtTable( nTab, eMode ); + + if ( eMode == SC_DB_OLD_FILTER ) + return pTableData; + + sal_Bool bSelected = ( eSel == SC_DBSEL_FORCE_MARK || rMarked.aStart != rMarked.aEnd ); + bool bOnlyDown = (!bSelected && eSel == SC_DBSEL_ROW_DOWN && rMarked.aStart.Row() == rMarked.aEnd.Row()); + + sal_Bool bUseThis = sal_False; + if (pCursorData) + { + SCTAB nDummy; + SCCOL nOldCol1; + SCROW nOldRow1; + SCCOL nOldCol2; + SCROW nOldRow2; + pCursorData->GetArea( nDummy, nOldCol1,nOldRow1, nOldCol2,nOldRow2 ); + if ( !bSelected ) + { + ScRange tmpRange; + if ( !pCursorData->IsBuildin() && pCursorData->GetAdvancedQuerySource(tmpRange)) + bUseThis = sal_True; + else + { + nStartCol = nCol; + nStartRow = nRow; + nEndCol = nStartCol; + nEndRow = nStartRow; + aDocument.GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, sal_False, bOnlyDown ); + if ( nOldCol1 != nStartCol || nOldCol2 != nEndCol || nOldRow1 != nStartRow ) + bUseThis = sal_False; + else + { + bUseThis = sal_True; + if ( nOldRow2 != nEndRow )// Range of new end-line expand + pCursorData->SetArea( nTab, nOldCol1,nOldRow1, nOldCol2,nEndRow ); + } + } + + } + else + { + if ( nOldCol1 == nStartCol && nOldRow1 == nStartRow && nOldCol2 == nEndCol && nOldRow2 == nEndRow ) + bUseThis = sal_True; + else + bUseThis = sal_False; // Always take mark (Bug 11964) + } + } + + if ( bUseThis ) + { + pData = pCursorData; + if ( pTableData && eMode == SC_DB_MAKE_FILTER && !(*pTableData == *pCursorData ) ) + { + if ( !pOldAutoDBRange ) + pOldAutoDBRange = new ScDBData(*pTableData); + SCCOL nOldX1; + SCROW nOldY1; + SCCOL nOldX2; + SCROW nOldY2; + SCTAB nOldTab; + pTableData->GetArea( nOldTab, nOldX1, nOldY1, nOldX2, nOldY2 ); + + if (pTableData->HasQueryParam()) + { + ScQueryParam aParam; + pTableData->GetQueryParam(aParam); + SCSIZE nEC = aParam.GetEntryCount(); + for (SCSIZE i=0; i<nEC; i++) + aParam.GetEntry(i).bDoQuery = sal_False; + aParam.bDuplicate = sal_True; + ScDBDocFunc aDBDocFunc( *this ); + aDBDocFunc.Query( nTab, aParam, NULL, sal_False, sal_False ); + } + + DBAreaDeleted( nOldTab, nOldX1, nOldY1, nOldX2, nOldY2 ); + pTableData->SetQueryParam( ScQueryParam() ); + pTableData->SetAutoFilter( sal_False ); + } + + } + else + { + if ( bSelected ) + { +// bMark = sal_False; + } + else + { + nStartCol = nCol; + nStartRow = nRow; + nEndCol = nStartCol; + nEndRow = nStartRow; + aDocument.GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, sal_False, bOnlyDown ); + } + sal_Bool bHasHeader = aDocument.HasColHeader( nStartCol,nStartRow, nEndCol,nEndRow, nTab ); + ScDBCollection* pColl = aDocument.GetDBCollection(); + if ( pTableData ) + { + if ( !pOldAutoDBRange ) + pOldAutoDBRange = new ScDBData(*pTableData); + SCCOL nOldX1; + SCROW nOldY1; + SCCOL nOldX2; + SCROW nOldY2; + SCTAB nOldTab; + pTableData->GetArea( nOldTab, nOldX1, nOldY1, nOldX2, nOldY2 ); + + if (pTableData->HasQueryParam()) + { + ScQueryParam aParam; + pTableData->GetQueryParam(aParam); + SCSIZE nEC = aParam.GetEntryCount(); + for (SCSIZE i=0; i<nEC; i++) + aParam.GetEntry(i).bDoQuery = sal_False; + aParam.bDuplicate = sal_True; + ScDBDocFunc aDBDocFunc( *this ); + aDBDocFunc.Query( nTab, aParam, NULL, sal_False, sal_False ); + } + + DBAreaDeleted( nOldTab, nOldX1, nOldY1, nOldX2, nOldY2 ); + + pTableData->SetSortParam( ScSortParam() ); + pTableData->SetQueryParam( ScQueryParam() ); + pTableData->SetSubTotalParam( ScSubTotalParam() ); + + pTableData->SetArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow ); + pTableData->SetByRow( sal_True ); + pTableData->SetHeader( bHasHeader ); + pTableData->SetAutoFilter( sal_False ); + } + else + { + String aNewName = pColl->GetNewDefaultDBName(); + pTableData = new ScDBData( aNewName, nTab, nStartCol,nStartRow, nEndCol,nEndRow, sal_True, bHasHeader ); + pColl->Insert( pTableData ); + } + pData = pTableData; + } + + return pData; +} + + ScDBData* ScDocShell::GetOldAutoDBRange() { ScDBData* pRet = pOldAutoDBRange; diff --git a/sc/source/ui/inc/dbfunc.hxx b/sc/source/ui/inc/dbfunc.hxx index 141286bdeca4..39a9fae84d3c 100644 --- a/sc/source/ui/inc/dbfunc.hxx +++ b/sc/source/ui/inc/dbfunc.hxx @@ -75,6 +75,7 @@ public: // DB-Bereich vom Cursor ScDBData* GetDBData( sal_Bool bMarkArea = sal_True, ScGetDBMode eMode = SC_DB_MAKE, ScGetDBSelection eSel = SC_DBSEL_KEEP ); + //ScRange GetDBRange( BOOL bMark, bool bIgnoreNotes ); void NotifyCloseDbNameDlg( const ScDBCollection& rNewColl, const List& rDelAreaList ); void Consolidate( const ScConsolidateParam& rParam, sal_Bool bRecord = sal_True ); diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx index 7eb6bad64b2e..b2fdf1cd52e1 100644 --- a/sc/source/ui/inc/docsh.hxx +++ b/sc/source/ui/inc/docsh.hxx @@ -158,6 +158,7 @@ class SC_DLLPUBLIC ScDocShell: public SfxObjectShell, public SfxListener SC_DLLPRIVATE void EnableSharedSettings( bool bEnable ); SC_DLLPRIVATE ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > LoadSharedDocument(); + ScDBData* GetDBDataAdd( const ScRange& rMarked, ScGetDBMode eMode, ScGetDBSelection eSel ); SC_DLLPRIVATE void UseSheetSaveEntries(); @@ -306,6 +307,7 @@ public: ScDBData* GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGetDBSelection eSel ); ScDBData* GetOldAutoDBRange(); // has to be deleted by caller! void CancelAutoDBRange(); // called when dialog is cancelled + ScDBCollection* GetDBCollection(){ return aDocument.GetDBCollection();} void UpdateLinks(); // Link-Eintraege aktuallisieren sal_Bool ReloadTabLinks(); // Links ausfuehren (Inhalt aktualisieren) diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx index c916404b747e..1a5bb02d293a 100644 --- a/sc/source/ui/navipi/content.cxx +++ b/sc/source/ui/navipi/content.cxx @@ -734,7 +734,8 @@ void ScContentTree::GetDbNames() { ScDBData* pData = (*pDbNames)[i]; String aStrName = pData->GetName(); - if ( aStrName != aStrNoName ) + //if ( aStrName != aStrNoName ) + if ( !pData->IsBuildin() ) InsertContent( SC_CONTENT_DBAREA, aStrName ); } } diff --git a/sc/source/ui/undo/undobase.cxx b/sc/source/ui/undo/undobase.cxx index de7e3bdf0da6..74838288d28a 100644 --- a/sc/source/ui/undo/undobase.cxx +++ b/sc/source/ui/undo/undobase.cxx @@ -33,6 +33,7 @@ #include "undobase.hxx" #include "refundo.hxx" #include "docsh.hxx" +#include "dbdocfun.hxx" #include "tabvwsh.hxx" #include "undoolk.hxx" #include "undodraw.hxx" @@ -390,7 +391,7 @@ void ScDBFuncUndo::EndUndo() sal_uInt16 nNoNameIndex; ScDocument* pDoc = pDocShell->GetDocument(); ScDBCollection* pColl = pDoc->GetDBCollection(); - if ( pColl->SearchName( ScGlobal::GetRscString( STR_DB_NONAME ), nNoNameIndex ) ) + if ( pColl->SearchName( pAutoDBRange->GetName(), nNoNameIndex ) ) { ScDBData* pNoNameData = (*pColl)[nNoNameIndex]; @@ -403,6 +404,13 @@ void ScDBFuncUndo::EndUndo() pDocShell->DBAreaDeleted( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 ); *pNoNameData = *pAutoDBRange; + /*if (pAutoDBRange->HasQueryParam()) //maybe conflict with AOO + { + ScQueryParam aParam; + pAutoDBRange->GetQueryParam(aParam); + ScDBDocFunc aDBDocFunc( *pDocShell ); + aDBDocFunc.Query( nRangeTab, aParam, NULL, sal_False, sal_False ); + }*/ if ( pAutoDBRange->HasAutoFilter() ) { @@ -425,7 +433,7 @@ void ScDBFuncUndo::BeginRedo() sal_uInt16 nNoNameIndex; ScDocument* pDoc = pDocShell->GetDocument(); ScDBCollection* pColl = pDoc->GetDBCollection(); - if ( pColl->SearchName( ScGlobal::GetRscString( STR_DB_NONAME ), nNoNameIndex ) ) + if ( pColl->SearchName( pAutoDBRange->GetName(), nNoNameIndex ) ) { ScDBData* pNoNameData = (*pColl)[nNoNameIndex]; @@ -435,6 +443,17 @@ void ScDBFuncUndo::BeginRedo() SCROW nRangeY2; SCTAB nRangeTab; pNoNameData->GetArea( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 ); + /*if (pAutoDBRange->HasQueryParam()) + { + ScQueryParam aParam; + pAutoDBRange->GetQueryParam(aParam); + SCSIZE nEC = aParam.GetEntryCount(); + for (SCSIZE i=0; i<nEC; i++) + aParam.GetEntry(i).bDoQuery = sal_False; + aParam.bDuplicate = sal_True; + ScDBDocFunc aDBDocFunc( *pDocShell ); + aDBDocFunc.Query( nRangeTab, aParam, NULL, sal_False, sal_False ); + }*/ pDocShell->DBAreaDeleted( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 ); pNoNameData->SetSortParam( ScSortParam() ); diff --git a/sc/source/ui/undo/undoutil.cxx b/sc/source/ui/undo/undoutil.cxx index 80c249568a2d..16d3963e39ac 100644 --- a/sc/source/ui/undo/undoutil.cxx +++ b/sc/source/ui/undo/undoutil.cxx @@ -93,7 +93,8 @@ ScDBData* ScUndoUtil::GetOldDBData( ScDBData* pUndoData, ScDocument* pDoc, SCTAB { String aName; pUndoData->GetName( aName ); - if ( aName == ScGlobal::GetRscString( STR_DB_NONAME ) ) +// if ( aName == ScGlobal::GetRscString( STR_DB_NONAME ) ) + if (pUndoData->IsBuildin()) bWasTemp = sal_True; } DBG_ASSERT(bWasTemp, "Undo: didn't find database range"); @@ -104,7 +105,8 @@ ScDBData* ScUndoUtil::GetOldDBData( ScDBData* pUndoData, ScDocument* pDoc, SCTAB pRet = (*pColl)[nIndex]; else { - pRet = new ScDBData( ScGlobal::GetRscString( STR_DB_NONAME ), nTab, + String aNoNamed = pColl->GetNewDefaultDBName(); + pRet = new ScDBData( aNoNamed/*ScGlobal::GetRscString( STR_DB_NONAME )*/, nTab, nCol1,nRow1, nCol2,nRow2, sal_True, pDoc->HasColHeader( nCol1,nRow1,nCol2,nRow2,nTab ) ); pColl->Insert( pRet ); diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx index 34484b50a982..f6c68fcc997a 100644 --- a/sc/source/ui/view/cellsh2.cxx +++ b/sc/source/ui/view/cellsh2.cxx @@ -357,7 +357,8 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq ) ScSubTotalParam aSubTotalParam; SfxItemSet aArgSet( GetPool(), SCITEM_SUBTDATA, SCITEM_SUBTDATA ); - ScDBData* pDBData = pTabViewShell->GetDBData(); + //ScDBData* pDBData = pTabViewShell->GetDBData(); + ScDBData* pDBData = pTabViewShell->GetDBData(sal_True, SC_DB_MAKE_SUBTOTAL); pDBData->GetSubTotalParam( aSubTotalParam ); aSubTotalParam.bRemoveOnly = sal_False; @@ -411,7 +412,7 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq ) //#i60401 ux-ctest: Calc does not support all users' strategies regarding sorting data //the patch comes from maoyg ScSortParam aSortParam; - ScDBData* pDBData = pTabViewShell->GetDBData(); + ScDBData* pDBData = pTabViewShell->GetDBData(sal_True, SC_DB_MAKE_SORT); ScViewData* pData = GetViewData(); pDBData->GetSortParam( aSortParam ); @@ -462,7 +463,7 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq ) if ( pArgs ) // Basic { ScSortParam aSortParam; - ScDBData* pDBData = pTabViewShell->GetDBData(); + ScDBData* pDBData = pTabViewShell->GetDBData(sal_True, SC_DB_MAKE_SORT); ScViewData* pData = GetViewData(); pDBData->GetSortParam( aSortParam ); @@ -525,7 +526,7 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq ) else { ScSortParam aSortParam; - ScDBData* pDBData = pTabViewShell->GetDBData(); + ScDBData* pDBData = pTabViewShell->GetDBData(sal_True, SC_DB_MAKE_SORT); ScViewData* pData = GetViewData(); pDBData->GetSortParam( aSortParam ); @@ -680,7 +681,7 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq ) case SID_UNFILTER: { ScQueryParam aParam; - ScDBData* pDBData = pTabViewShell->GetDBData(); + ScDBData* pDBData = pTabViewShell->GetDBData(sal_True, SC_DB_OLD_FILTER); pDBData->GetQueryParam( aParam ); SCSIZE nEC = aParam.GetEntryCount(); diff --git a/sc/source/ui/view/dbfunc.cxx b/sc/source/ui/view/dbfunc.cxx index f8cc329609db..f82507aea973 100644 --- a/sc/source/ui/view/dbfunc.cxx +++ b/sc/source/ui/view/dbfunc.cxx @@ -334,35 +334,37 @@ void ScDBFunc::ToggleAutoFilter() ScQueryParam aParam; ScDocument* pDoc = GetViewData()->GetDocument(); - ScDBData* pDBData = GetDBData( sal_False, SC_DB_MAKE, SC_DBSEL_ROW_DOWN ); + ScDBData* pDBData = GetDBData( sal_False, SC_DB_OLD_FILTER, SC_DBSEL_ROW_DOWN ); + - pDBData->SetByRow( sal_True ); //! Undo, vorher abfragen ?? - pDBData->GetQueryParam( aParam ); SCCOL nCol; - SCROW nRow = aParam.nRow1; + SCROW nRow; SCTAB nTab = GetViewData()->GetTabNo(); sal_Int16 nFlag; - sal_Bool bHasAuto = sal_True; - sal_Bool bHeader = pDBData->HasHeader(); + //sal_Bool bHasAuto = sal_True; + sal_Bool bHeader; sal_Bool bPaint = sal_False; //! stattdessen aus DB-Bereich abfragen? - for (nCol=aParam.nCol1; nCol<=aParam.nCol2 && bHasAuto; nCol++) + /*for (nCol=aParam.nCol1; nCol<=aParam.nCol2 && bHasAuto; nCol++) { nFlag = ((ScMergeFlagAttr*) pDoc-> GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG ))->GetValue(); if ( (nFlag & SC_MF_AUTO) == 0 ) bHasAuto = sal_False; - } + }*/ - if (bHasAuto) // aufheben + if (pDBData && pDBData->HasAutoFilter()) // aufheben { // Filterknoepfe ausblenden - + pDBData->SetByRow( sal_True ); //! Undo, vorher abfragen ?? + pDBData->GetQueryParam( aParam ); + nRow = aParam.nRow1; + bHeader = pDBData->HasHeader(); for (nCol=aParam.nCol1; nCol<=aParam.nCol2; nCol++) { nFlag = ((ScMergeFlagAttr*) pDoc-> @@ -396,6 +398,12 @@ void ScDBFunc::ToggleAutoFilter() } else // Filterknoepfe einblenden { + pDBData = GetDBData(sal_False, SC_DB_MAKE_FILTER); + pDBData->SetByRow(sal_True); + pDBData->GetQueryParam(aParam); + nRow = aParam.nRow1; + bHeader = pDBData->HasHeader(); + if ( !pDoc->IsBlockEmpty( nTab, aParam.nCol1, aParam.nRow1, aParam.nCol2, aParam.nRow2 ) ) @@ -457,7 +465,8 @@ void ScDBFunc::HideAutoFilter() ScDocument* pDoc = pDocSh->GetDocument(); ScQueryParam aParam; - ScDBData* pDBData = GetDBData( sal_False ); + //ScDBData* pDBData = GetDBData( FALSE ); + ScDBData* pDBData = GetDBData(sal_False, SC_DB_OLD_FILTER); SCTAB nTab; SCCOL nCol1, nCol2; diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx index f5bd19d25caf..42c07bd8bd7f 100644 --- a/sc/source/ui/view/tabvwshc.cxx +++ b/sc/source/ui/view/tabvwshc.cxx @@ -171,7 +171,7 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog( SCITEM_QUERYDATA, SCITEM_QUERYDATA ); - ScDBData* pDBData = GetDBData( sal_True, SC_DB_MAKE, SC_DBSEL_ROW_DOWN); + ScDBData* pDBData = GetDBData( sal_True, SC_DB_MAKE_FILTER, SC_DBSEL_ROW_DOWN); pDBData->GetQueryParam( aQueryParam ); ScQueryItem aItem( SCITEM_QUERYDATA, GetViewData(), &aQueryParam ); @@ -196,7 +196,7 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog( SCITEM_QUERYDATA, SCITEM_QUERYDATA ); - ScDBData* pDBData = GetDBData( sal_True, SC_DB_MAKE, SC_DBSEL_ROW_DOWN); + ScDBData* pDBData = GetDBData( sal_True, SC_DB_MAKE_FILTER, SC_DBSEL_ROW_DOWN); pDBData->GetQueryParam( aQueryParam ); aArgSet.Put( ScQueryItem( SCITEM_QUERYDATA, |