Index: sc/inc/dbcolect.hxx =================================================================== --- sc/inc/dbcolect.hxx (revision 1372257) +++ sc/inc/dbcolect.hxx (working copy) @@ -136,6 +136,8 @@ 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 @@ 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 @@ void SetRefreshHandler( const Link& rLink ) { aRefreshHandler = rLink; } const Link& GetRefreshHandler() const { return aRefreshHandler; } + String GetNewDefaultDBName(); + /*sal_Bool IsFiltered(SCTAB nTab, SCROW nRow);*/ }; #endif Index: sc/inc/document.hxx =================================================================== --- sc/inc/document.hxx (revision 1372257) +++ sc/inc/document.hxx (working copy) @@ -505,6 +505,7 @@ //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; Index: sc/inc/global.hxx =================================================================== --- sc/inc/global.hxx (revision 1372257) +++ sc/inc/global.hxx (working copy) @@ -406,7 +406,11 @@ { 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() Index: sc/source/core/data/documen3.cxx =================================================================== --- sc/source/core/data/documen3.cxx (revision 1372257) +++ sc/source/core/data/documen3.cxx (working copy) @@ -192,6 +192,13 @@ 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::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 ) Index: sc/source/core/tool/dbcolect.cxx =================================================================== --- sc/source/core/tool/dbcolect.cxx (revision 1372257) +++ sc/source/core/tool/dbcolect.cxx (working copy) @@ -36,6 +36,7 @@ #include "queryparam.hxx" #include "globstr.hrc" +#define SC_DBNAME_UNNAMED "__Anonymous_Sheet_DB__" //--------------------------------------------------------------------------------------- @@ -690,8 +691,13 @@ { 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* 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* 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 @@ 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; +} Index: sc/source/core/tool/rangeutl.cxx =================================================================== --- sc/source/core/tool/rangeutl.cxx (revision 1372257) +++ sc/source/core/tool/rangeutl.cxx (working copy) @@ -1032,7 +1032,8 @@ 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(); Index: sc/source/ui/dbgui/dbnamdlg.cxx =================================================================== --- sc/source/ui/dbgui/dbnamdlg.cxx (revision 1372257) +++ sc/source/ui/dbgui/dbnamdlg.cxx (working copy) @@ -266,7 +266,8 @@ && (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 @@ if ( pDbData ) { pDbData->GetName( aString ); - if ( aString != aStrNoName ) + //if ( aString != aStrNoName ) + if ( !pDbData->IsBuildin() ) aEdName.InsertEntry( aString ); } } Index: sc/source/ui/dbgui/foptmgr.cxx =================================================================== --- sc/source/ui/dbgui/foptmgr.cxx (revision 1372257) +++ sc/source/ui/dbgui/foptmgr.cxx (working copy) @@ -186,7 +186,7 @@ rBtnHeader.Check( pDBData->HasHeader() ); pDBData->GetName( theDbName ); - if ( theDbName != rStrNoName ) + if ( !pDBData->IsBuildin() ) { rBtnHeader.Disable(); } Index: sc/source/ui/docshell/dbdocfun.cxx =================================================================== --- sc/source/ui/docshell/dbdocfun.cxx (revision 1372257) +++ sc/source/ui/docshell/dbdocfun.cxx (working copy) @@ -592,7 +592,7 @@ 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 @@ 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) { Index: sc/source/ui/docshell/docsh5.cxx =================================================================== --- sc/source/ui/docshell/docsh5.cxx (revision 1372257) +++ sc/source/ui/docshell/docsh5.cxx (working copy) @@ -150,6 +150,8 @@ 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 @@ 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 @@ 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 @@ 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; iSetQueryParam( 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; iSetSortParam( 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; Index: sc/source/ui/inc/dbfunc.hxx =================================================================== --- sc/source/ui/inc/dbfunc.hxx (revision 1372257) +++ sc/source/ui/inc/dbfunc.hxx (working copy) @@ -75,6 +75,7 @@ // 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 ); Index: sc/source/ui/inc/docsh.hxx =================================================================== --- sc/source/ui/inc/docsh.hxx (revision 1372257) +++ sc/source/ui/inc/docsh.hxx (working copy) @@ -158,6 +158,7 @@ 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 @@ 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) Index: sc/source/ui/navipi/content.cxx =================================================================== --- sc/source/ui/navipi/content.cxx (revision 1372257) +++ sc/source/ui/navipi/content.cxx (working copy) @@ -734,7 +734,8 @@ { ScDBData* pData = (*pDbNames)[i]; String aStrName = pData->GetName(); - if ( aStrName != aStrNoName ) + //if ( aStrName != aStrNoName ) + if ( !pData->IsBuildin() ) InsertContent( SC_CONTENT_DBAREA, aStrName ); } } Index: sc/source/ui/undo/undobase.cxx =================================================================== --- sc/source/ui/undo/undobase.cxx (revision 1372257) +++ sc/source/ui/undo/undobase.cxx (working copy) @@ -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 @@ 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 @@ 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 @@ 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 @@ 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; iDBAreaDeleted( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 ); pNoNameData->SetSortParam( ScSortParam() ); Index: sc/source/ui/undo/undoutil.cxx =================================================================== --- sc/source/ui/undo/undoutil.cxx (revision 1372257) +++ sc/source/ui/undo/undoutil.cxx (working copy) @@ -93,7 +93,8 @@ { 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 @@ 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 ); Index: sc/source/ui/view/cellsh2.cxx =================================================================== --- sc/source/ui/view/cellsh2.cxx (revision 1372257) +++ sc/source/ui/view/cellsh2.cxx (working copy) @@ -357,7 +357,8 @@ 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 @@ //#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 @@ 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 @@ 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 @@ 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(); Index: sc/source/ui/view/dbfunc.cxx =================================================================== --- sc/source/ui/view/dbfunc.cxx (revision 1372257) +++ sc/source/ui/view/dbfunc.cxx (working copy) @@ -334,35 +334,37 @@ 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 @@ } 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 @@ 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; Index: sc/source/ui/view/tabvwshc.cxx =================================================================== --- sc/source/ui/view/tabvwshc.cxx (revision 1372257) +++ sc/source/ui/view/tabvwshc.cxx (working copy) @@ -171,7 +171,7 @@ 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 @@ 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,