diff options
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/core/data/documen3.cxx | 15 | ||||
-rw-r--r-- | sc/source/core/tool/dbcolect.cxx | 96 | ||||
-rw-r--r-- | sc/source/core/tool/rangeutl.cxx | 8 | ||||
-rw-r--r-- | sc/source/ui/dbgui/dbnamdlg.cxx | 17 | ||||
-rw-r--r-- | sc/source/ui/dbgui/foptmgr.cxx | 8 | ||||
-rw-r--r-- | sc/source/ui/docshell/dbdocfun.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh5.cxx | 404 | ||||
-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 | 7 | ||||
-rw-r--r-- | sc/source/ui/undo/undoutil.cxx | 33 | ||||
-rw-r--r-- | sc/source/ui/view/cellsh2.cxx | 19 | ||||
-rw-r--r-- | sc/source/ui/view/dbfunc.cxx | 175 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwshc.cxx | 4 |
14 files changed, 324 insertions, 469 deletions
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx index 1795f9b38481..df4183e7948f 100644 --- a/sc/source/core/data/documen3.cxx +++ b/sc/source/core/data/documen3.cxx @@ -192,13 +192,6 @@ 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 { @@ -1296,10 +1289,12 @@ sal_Bool ScDocument::CreateQueryParam(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCR return sal_False; } -sal_Bool ScDocument::HasAutoFilter( SCCOL /*nCurCol*/, SCROW /*nCurRow*/, SCTAB nCurTab ) +sal_Bool ScDocument::HasAutoFilter( + const SCCOL nCurCol, + const SCROW nCurRow, + const SCTAB nCurTab ) { - //ScDBData* pDBData = GetDBAtCursor( nCurCol, nCurRow, nCurTab ); - ScDBData* pDBData = GetDBAtTable(nCurTab, SC_DB_OLD_FILTER); + ScDBData* pDBData = GetDBAtCursor( nCurCol, nCurRow, nCurTab ); sal_Bool bHasAutoFilter = ( pDBData != NULL ); if ( pDBData ) diff --git a/sc/source/core/tool/dbcolect.cxx b/sc/source/core/tool/dbcolect.cxx index bc1c1db78c2e..e5e3334a89d3 100644 --- a/sc/source/core/tool/dbcolect.cxx +++ b/sc/source/core/tool/dbcolect.cxx @@ -691,11 +691,18 @@ ScDataObject* ScDBData::Clone() const { return new ScDBData(*this); } -sal_Bool ScDBData::IsBuildin() + + +bool ScDBData::IsInternalUnnamed() const { - String aNoName = String::CreateFromAscii(SC_DBNAME_UNNAMED); - String aBeginName = aName.Copy(0,22); - return (sal_Bool)(!ScGlobal::GetpTransliteration()->compareString( aNoName, aBeginName )); + return GetName() == ScGlobal::GetRscString( STR_DB_NONAME ); +} + +bool ScDBData::IsInternalForAutoFilter() const +{ + const String aNoName = String::CreateFromAscii(SC_DBNAME_UNNAMED); + const String aBeginName = aName.Copy( 0, aNoName.Len() ); + return aBeginName == aNoName; } //--------------------------------------------------------------------------------------- @@ -717,7 +724,7 @@ sal_Bool ScDBCollection::IsEqual(ScDataObject* pKey1, ScDataObject* pKey2) const ScDBData* ScDBCollection::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Bool bStartOnly) const { - ScDBData* pNoNameData = NULL; + ScDBData* pInternalDBData = NULL; if (pItems) { @@ -725,32 +732,42 @@ ScDBData* ScDBCollection::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_ if (((ScDBData*)pItems[i])->IsDBAtCursor(nCol, nRow, nTab, bStartOnly)) { ScDBData* pDB = (ScDBData*)pItems[i]; - if ( pDB->IsBuildin() ) - pNoNameData = pDB; + if ( pDB->IsInternalUnnamed() + || pDB->IsInternalForAutoFilter() ) + { + pInternalDBData = pDB; + } else + { return pDB; + } } } - return pNoNameData; // "unbenannt" nur zurueck, wenn sonst nichts gefunden + return pInternalDBData; } -ScDBData* ScDBCollection::GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const +ScDBData* ScDBCollection::GetDBAtArea( + const SCTAB nTab, + const SCCOL nCol1, + const SCROW nRow1, + const SCCOL nCol2, + const SCROW nRow2 ) const { - ScDBData* pNoNameData = NULL; + ScDBData* pInternalDBData = NULL; if (pItems) { - 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->IsBuildin() ) - pNoNameData = pDB; + if ( pDB->IsInternalUnnamed() + || pDB->IsInternalForAutoFilter() ) + pInternalDBData = pDB; else return pDB; } } - return pNoNameData; // "unbenannt" nur zurueck, wenn sonst nichts gefunden + return pInternalDBData; } ScDBData* ScDBCollection::GetFilterDBAtTable(SCTAB nTab) const @@ -920,54 +937,3 @@ String ScDBCollection::GetNewDefaultDBName() }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 ae36c671088a..2fb3271f7003 100644 --- a/sc/source/core/tool/rangeutl.cxx +++ b/sc/source/core/tool/rangeutl.cxx @@ -997,8 +997,7 @@ sal_Bool ScArea::operator==( const ScArea& r ) const //------------------------------------------------------------------------ -ScAreaNameIterator::ScAreaNameIterator( ScDocument* pDoc ) : - aStrNoName( ScGlobal::GetRscString(STR_DB_NONAME) ) +ScAreaNameIterator::ScAreaNameIterator( ScDocument* pDoc ) { pRangeName = pDoc->GetRangeName(); pDBCollection = pDoc->GetDBCollection(); @@ -1032,8 +1031,9 @@ 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->IsBuildin()) + if ( pData + && !pData->IsInternalUnnamed() + && !pData->IsInternalForAutoFilter() ) { pData->GetArea( rRange ); rName = pData->GetName(); diff --git a/sc/source/ui/dbgui/dbnamdlg.cxx b/sc/source/ui/dbgui/dbnamdlg.cxx index cc843cc87688..7652853b1856 100644 --- a/sc/source/ui/dbgui/dbnamdlg.cxx +++ b/sc/source/ui/dbgui/dbnamdlg.cxx @@ -160,7 +160,6 @@ ScDbNameDlg::ScDbNameDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent, aStrAdd ( ScResId( STR_ADD ) ), aStrModify ( ScResId( STR_MODIFY ) ), - aStrNoName ( ScGlobal::GetRscString(STR_DB_NONAME) ), aStrInvalid ( ScResId( STR_DB_INVALID ) ), // pViewData ( ptrViewData ), @@ -237,10 +236,10 @@ void ScDbNameDlg::Init() ScDBData* pDBData = NULL; pViewData->GetSimpleArea( nStartCol, nStartRow, nStartTab, - nEndCol, nEndRow, nEndTab ); + nEndCol, nEndRow, nEndTab ); theCurArea = ScRange( ScAddress( nStartCol, nStartRow, nStartTab ), - ScAddress( nEndCol, nEndRow, nEndTab ) ); + ScAddress( nEndCol, nEndRow, nEndTab ) ); theCurArea.Format( theAreaStr, ABS_DREF3D, pDoc, aAddrDetails ); @@ -266,11 +265,15 @@ void ScDbNameDlg::Init() && (rEnd.Col() == nCol2) && (rEnd.Row() == nRow2 ) ) { pDBData->GetName( theDbName ); - //if ( theDbName != aStrNoName ) - if ( !pDBData->IsBuildin() ) + if ( !pDBData->IsInternalUnnamed() + && !pDBData->IsInternalForAutoFilter() ) + { aEdName.SetText( theDbName ); + } else + { aEdName.SetText( EMPTY_STRING ); + } aBtnHeader.Check( pDBData->HasHeader() ); aBtnDoSize.Check( pDBData->IsDoSize() ); aBtnKeepFmt.Check( pDBData->IsKeepFmt() ); @@ -379,8 +382,8 @@ void ScDbNameDlg::UpdateNames() if ( pDbData ) { pDbData->GetName( aString ); - //if ( aString != aStrNoName ) - if ( !pDbData->IsBuildin() ) + if ( !pDbData->IsInternalUnnamed() + && !pDbData->IsInternalForAutoFilter() ) aEdName.InsertEntry( aString ); } } diff --git a/sc/source/ui/dbgui/foptmgr.cxx b/sc/source/ui/dbgui/foptmgr.cxx index 0e7c546b8313..fef0f5d62d01 100644 --- a/sc/source/ui/dbgui/foptmgr.cxx +++ b/sc/source/ui/dbgui/foptmgr.cxx @@ -178,15 +178,15 @@ void ScFilterOptionsMgr::Init() { ScAddress& rStart = theCurArea.aStart; ScAddress& rEnd = theCurArea.aEnd; - ScDBData* pDBData = pDBColl->GetDBAtArea( rStart.Tab(), - rStart.Col(), rStart.Row(), - rEnd.Col(), rEnd.Row() ); + ScDBData* pDBData = pDBColl->GetDBAtArea( + rStart.Tab(), rStart.Col(), rStart.Row(), rEnd.Col(), rEnd.Row() ); if ( pDBData ) { rBtnHeader.Check( pDBData->HasHeader() ); pDBData->GetName( theDbName ); - if ( !pDBData->IsBuildin() ) + if ( !pDBData->IsInternalUnnamed() + && !pDBData->IsInternalForAutoFilter() ) { rBtnHeader.Disable(); } diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx index 40be175302be..0b97c5820bf8 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_SORT, SC_DBSEL_FORCE_MARK ); + pNewData = rDocShell.GetDBData(aDestPos, SC_DB_MAKE, 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_FILTER, SC_DBSEL_FORCE_MARK ); + SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); if (pNewData) { diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx index 52d3c23d51e6..6f2129b0377a 100644 --- a/sc/source/ui/docshell/docsh5.cxx +++ b/sc/source/ui/docshell/docsh5.cxx @@ -111,17 +111,21 @@ 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 ) + +ScDBData* lcl_GetDBNearCursor( + const ScDBCollection* pColl, + const SCCOL nCol, + const SCROW nRow, + const SCTAB nTab ) { //! nach document/dbcolect verschieben if (!pColl) return NULL; - ScDBData* pNoNameData = NULL; + ScDBData* pInternalDBData = NULL; ScDBData* pNearData = NULL; sal_uInt16 nCount = pColl->GetCount(); - String aNoName = ScGlobal::GetRscString( STR_DB_NONAME ); SCTAB nAreaTab; SCCOL nStartCol, nEndCol; SCROW nStartRow, nEndRow; @@ -129,14 +133,20 @@ ScDBData* lcl_GetDBNearCursor( ScDBCollection* pColl, SCCOL nCol, SCROW nRow, SC { 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 ( nTab == nAreaTab + && nCol+1 >= nStartCol + && nCol <= nEndCol+1 + && nRow+1 >= nStartRow + && nRow <= nEndRow+1 ) { - if ( pDB->GetName() == aNoName ) - pNoNameData = pDB; + if ( pDB->IsInternalUnnamed() + || pDB->IsInternalForAutoFilter() ) + { + pInternalDBData = pDB; + } else if ( nCol < nStartCol || nCol > nEndCol || nRow < nStartRow || nRow > nEndRow ) { - if (!pNearData) + if ( !pNearData ) pNearData = pDB; // ersten angrenzenden Bereich merken } else @@ -145,60 +155,57 @@ ScDBData* lcl_GetDBNearCursor( ScDBCollection* pColl, SCCOL nCol, SCROW nRow, SC } if (pNearData) return pNearData; // angrenzender, wenn nichts direkt getroffen - return pNoNameData; // "unbenannt" nur zurueck, wenn sonst nichts gefunden + return pInternalDBData; } 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(); + const SCCOL nCol = rMarked.aStart.Col(); + const SCROW nRow = rMarked.aStart.Row(); + const 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(); - - // Wegen #49655# nicht einfach GetDBAtCursor: Der zusammenhaengende Datenbereich - // fuer "unbenannt" (GetDataArea) kann neben dem Cursor legen, also muss auch ein - // benannter DB-Bereich dort gesucht werden. - ScDBData* pData = aDocument.GetDBAtArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow ); - if (!pData) - pData = lcl_GetDBNearCursor( aDocument.GetDBCollection(), nCol, nRow, nTab ); + ScDBData* pFoundDBData = aDocument.GetDBAtArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow ); + if ( pFoundDBData == NULL ) + { + pFoundDBData = lcl_GetDBNearCursor( aDocument.GetDBCollection(), nCol, nRow, nTab ); + } - sal_Bool bSelected = ( eSel == SC_DBSEL_FORCE_MARK || - (rMarked.aStart != rMarked.aEnd && eSel != SC_DBSEL_ROW_DOWN) ); - bool bOnlyDown = (!bSelected && eSel == SC_DBSEL_ROW_DOWN && rMarked.aStart.Row() == rMarked.aEnd.Row()); + const bool bSelected = + ( eSel == SC_DBSEL_FORCE_MARK + || ( rMarked.aStart != rMarked.aEnd + && eSel != SC_DBSEL_ROW_DOWN ) ); + const bool bOnlyDown = ( !bSelected + && eSel == SC_DBSEL_ROW_DOWN + && rMarked.aStart.Row() == rMarked.aEnd.Row()); - sal_Bool bUseThis = sal_False; - if (pData) + bool bUseFoundDBData = false; + if ( pFoundDBData ) { - // Bereich nehmen, wenn nichts anderes markiert - + // check, if found database range can be used SCTAB nDummy; SCCOL nOldCol1; SCROW nOldRow1; 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->IsBuildin(); + pFoundDBData->GetArea( nDummy, nOldCol1, nOldRow1, nOldCol2, nOldRow2 ); - if (!bSelected) + const bool bIsUnnamedOne = pFoundDBData->IsInternalUnnamed(); + const bool bIsInternalForAutoFilter = pFoundDBData->IsInternalForAutoFilter(); + if ( !bSelected ) { - bUseThis = sal_True; - if ( bIsNoName && eMode == SC_DB_MAKE ) + bUseFoundDBData = true; + if ( ( bIsUnnamedOne || bIsInternalForAutoFilter ) + && ( eMode == SC_DB_MAKE || eMode == SC_DB_MAKE_AUTOFILTER ) ) { - // If nothing marked or only one row marked, adapt - // "unbenannt"/"unnamed" to contiguous area. + // If nothing marked or only one row marked, adapt found database range to contiguous area. nStartCol = nCol; nStartRow = nRow; - if (bOnlyDown) + if ( bOnlyDown ) { nEndCol = rMarked.aEnd.Col(); nEndRow = rMarked.aEnd.Row(); @@ -210,50 +217,63 @@ ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGe } aDocument.GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, sal_False, bOnlyDown ); if ( nOldCol1 != nStartCol || nOldCol2 != nEndCol || nOldRow1 != nStartRow ) - bUseThis = sal_False; // passt gar nicht + { + bUseFoundDBData = false; + } else if ( nOldRow2 != nEndRow ) { - // Bereich auf neue End-Zeile erweitern - pData->SetArea( nTab, nOldCol1,nOldRow1, nOldCol2,nEndRow ); + // adapt found internal database range to new end row + pFoundDBData->SetArea( nTab, nOldCol1,nOldRow1, nOldCol2,nEndRow ); } } } else { - if ( nOldCol1 == nStartCol && nOldRow1 == nStartRow && - nOldCol2 == nEndCol && nOldRow2 == nEndRow ) // genau markiert? - bUseThis = sal_True; + if ( nOldCol1 == nStartCol + && nOldRow1 == nStartRow + && nOldCol2 == nEndCol + && nOldRow2 == nEndRow ) + { + bUseFoundDBData = true; + } else - bUseThis = sal_False; // immer Markierung nehmen (Bug 11964) + { + bUseFoundDBData = false; + } } - // fuer Import nie "unbenannt" nehmen + // adapt internal unnamed database range to an auto filter one + // otherwise the auto filter is lost when the internal unnamed one is changed/reused/deleted + if ( bUseFoundDBData + && eMode == SC_DB_MAKE_AUTOFILTER + && bIsUnnamedOne ) + { + pFoundDBData->SetName( aDocument.GetDBCollection()->GetNewDefaultDBName() ); + } - if ( bUseThis && eMode == SC_DB_IMPORT && bIsNoName ) - bUseThis = sal_False; + // no internal database range for Import + if ( bUseFoundDBData + && eMode == SC_DB_IMPORT + && ( bIsUnnamedOne || bIsInternalForAutoFilter ) ) + { + bUseFoundDBData = false; + } } - if ( bUseThis ) + if ( bUseFoundDBData ) { - pData->GetArea( nStartTab, nStartCol,nStartRow, nEndCol,nEndRow ); - nEndTab = nStartTab; + return pFoundDBData; } - else if ( eMode == SC_DB_OLD ) + + if ( eMode == SC_DB_OLD ) { - pData = NULL; // nichts gefunden - nStartCol = nEndCol = nCol; - nStartRow = nEndRow = nRow; - nStartTab = nEndTab = nTab; -// bMark = sal_False; // nichts zu markieren + // no existing database range found + return NULL; } - else + else // eMode == SC_DB_MAKE||SC_DB_IMPORT||SC_DB_MAKE_AUTOFILTER { - if ( bSelected ) + if ( !bSelected ) { -// bMark = sal_False; - } - else - { // zusammenhaengender Bereich nStartCol = nCol; nStartRow = nRow; if (bOnlyDown) @@ -269,49 +289,52 @@ ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGe aDocument.GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, sal_False, bOnlyDown ); } - sal_Bool bHasHeader = aDocument.HasColHeader( nStartCol,nStartRow, nEndCol,nEndRow, nTab ); + const sal_Bool bHasHeader = aDocument.HasColHeader( nStartCol, nStartRow, nEndCol, nEndRow, nTab ); - ScDBData* pNoNameData; - sal_uInt16 nNoNameIndex; + ScDBData* pDBData = NULL; + sal_uInt16 nUnnamedDBIndex; ScDBCollection* pColl = aDocument.GetDBCollection(); - if ( eMode != SC_DB_IMPORT && - pColl->SearchName( ScGlobal::GetRscString( STR_DB_NONAME ), nNoNameIndex ) ) + if ( eMode == SC_DB_MAKE && + pColl->SearchName( ScGlobal::GetRscString( STR_DB_NONAME ), nUnnamedDBIndex ) ) { - pNoNameData = (*pColl)[nNoNameIndex]; + // adapt existing unnamed database range + pDBData = (*pColl)[nUnnamedDBIndex]; if ( !pOldAutoDBRange ) { // store the old unnamed database range with its settings for undo // (store at the first change, get the state before all changes) - pOldAutoDBRange = new ScDBData( *pNoNameData ); + pOldAutoDBRange = new ScDBData( *pDBData ); } - SCCOL nOldX1; // alten Bereich sauber wegnehmen - SCROW nOldY1; //! (UNDO ???) + SCCOL nOldX1; + SCROW nOldY1; SCCOL nOldX2; SCROW nOldY2; SCTAB nOldTab; - pNoNameData->GetArea( nOldTab, nOldX1, nOldY1, nOldX2, nOldY2 ); + pDBData->GetArea( nOldTab, nOldX1, nOldY1, nOldX2, nOldY2 ); DBAreaDeleted( nOldTab, nOldX1, nOldY1, nOldX2, nOldY2 ); - pNoNameData->SetSortParam( ScSortParam() ); // Parameter zuruecksetzen - pNoNameData->SetQueryParam( ScQueryParam() ); - pNoNameData->SetSubTotalParam( ScSubTotalParam() ); + pDBData->SetSortParam( ScSortParam() ); + pDBData->SetQueryParam( ScQueryParam() ); + pDBData->SetSubTotalParam( ScSubTotalParam() ); - pNoNameData->SetArea( nTab, nStartCol,nStartRow, nEndCol,nEndRow ); // neu setzen - pNoNameData->SetByRow( sal_True ); - pNoNameData->SetHeader( bHasHeader ); - pNoNameData->SetAutoFilter( sal_False ); + pDBData->SetArea( nTab, nStartCol,nStartRow, nEndCol,nEndRow ); + pDBData->SetByRow( sal_True ); + pDBData->SetHeader( bHasHeader ); + pDBData->SetAutoFilter( sal_False ); } else { ScDBCollection* pUndoColl = NULL; String aNewName; - if (eMode==SC_DB_IMPORT) + switch ( eMode ) + { + case SC_DB_IMPORT: { - aDocument.CompileDBFormula( sal_True ); // CreateFormulaString - pUndoColl = new ScDBCollection( *pColl ); // Undo fuer Import1-Bereich + aDocument.CompileDBFormula( sal_True ); + pUndoColl = new ScDBCollection( *pColl ); String aImport = ScGlobal::GetRscString( STR_DBNAME_IMPORT ); long nCount = 0; @@ -324,197 +347,51 @@ ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGe } while (pColl->SearchName( aNewName, nDummy )); } - else - //aNewName = ScGlobal::GetRscString( STR_DB_NONAME ); - aNewName = pColl->GetNewDefaultDBName(); - - pNoNameData = new ScDBData( aNewName, nTab, - nStartCol,nStartRow, nEndCol,nEndRow, - sal_True, bHasHeader ); - pColl->Insert( pNoNameData ); + break; - if ( pUndoColl ) + case SC_DB_MAKE_AUTOFILTER: { - aDocument.CompileDBFormula( sal_False ); // CompileFormulaString + aDocument.CompileDBFormula( sal_True ); + pUndoColl = new ScDBCollection( *pColl ); - ScDBCollection* pRedoColl = new ScDBCollection( *pColl ); - GetUndoManager()->AddUndoAction( new ScUndoDBData( this, pUndoColl, pRedoColl ) ); + aNewName = pColl->GetNewDefaultDBName(); } + break; - // neuen Bereich am Sba anmelden nicht mehr noetig - - // "Import1" etc am Navigator bekanntmachen - if (eMode==SC_DB_IMPORT) - SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) ); - } - pData = pNoNameData; - } - -// if (bMark) -// MarkRange( ScRange( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab ), sal_False ); - - 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; - SCCOL nEndCol = rMarked.aEnd.Col(); - SCROW nEndRow = rMarked.aEnd.Row(); - - 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 ); - } + case SC_DB_MAKE: + { + aNewName = ScGlobal::GetRscString( STR_DB_NONAME ); } + break; - } - else - { - if ( nOldCol1 == nStartCol && nOldRow1 == nStartRow && nOldCol2 == nEndCol && nOldRow2 == nEndRow ) - bUseThis = sal_True; - else - bUseThis = sal_False; // Always take mark (Bug 11964) - } - } + default: + DBG_ERROR( "<ScDocShell::GetDBData(..)> - unexcepted <eMode>" ); + break; + } - 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 ); + pDBData = new ScDBData( + aNewName, nTab, nStartCol, nStartRow, nEndCol, nEndRow, sal_True, bHasHeader ); + pColl->Insert( pDBData ); - if (pTableData->HasQueryParam()) + if ( pUndoColl ) { - 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 ); - } + aDocument.CompileDBFormula( 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 ); + ScDBCollection* pRedoColl = new ScDBCollection( *pColl ); + GetUndoManager()->AddUndoAction( new ScUndoDBData( this, pUndoColl, pRedoColl ) ); + } - if (pTableData->HasQueryParam()) + // notify Navigator about database range "Import[X]" + if ( eMode==SC_DB_IMPORT ) { - 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 ); + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) ); } - - 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 pDBData; } - return pData; + return NULL; // never reached } @@ -657,18 +534,19 @@ void ScDocShell::RefreshPivotTables( const ScRange& rSource ) String lcl_GetAreaName( ScDocument* pDoc, ScArea* pArea ) { String aName; - sal_Bool bOk = sal_False; - ScDBData* pData = pDoc->GetDBAtArea( pArea->nTab, pArea->nColStart, pArea->nRowStart, - pArea->nColEnd, pArea->nRowEnd ); + bool bOk = false; + ScDBData* pData = pDoc->GetDBAtArea( pArea->nTab, pArea->nColStart, pArea->nRowStart, pArea->nColEnd, pArea->nRowEnd ); if (pData) { pData->GetName( aName ); - if ( aName != ScGlobal::GetRscString( STR_DB_NONAME ) ) - bOk = sal_True; + if ( !pData->IsInternalUnnamed() ) + bOk = true; } if (!bOk) + { pDoc->GetName( pArea->nTab, aName ); + } return aName; } diff --git a/sc/source/ui/inc/dbfunc.hxx b/sc/source/ui/inc/dbfunc.hxx index 39a9fae84d3c..141286bdeca4 100644 --- a/sc/source/ui/inc/dbfunc.hxx +++ b/sc/source/ui/inc/dbfunc.hxx @@ -75,7 +75,6 @@ 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 c22747f484a7..1a121d8048bb 100644 --- a/sc/source/ui/inc/docsh.hxx +++ b/sc/source/ui/inc/docsh.hxx @@ -158,7 +158,6 @@ 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(); @@ -307,7 +306,6 @@ 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 1a5bb02d293a..8d42d3743bcd 100644 --- a/sc/source/ui/navipi/content.cxx +++ b/sc/source/ui/navipi/content.cxx @@ -729,14 +729,15 @@ 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 ) - if ( !pData->IsBuildin() ) + if ( !pData->IsInternalUnnamed() + && !pData->IsInternalForAutoFilter() ) + { InsertContent( SC_CONTENT_DBAREA, aStrName ); + } } } } diff --git a/sc/source/ui/undo/undoutil.cxx b/sc/source/ui/undo/undoutil.cxx index 16d3963e39ac..c4b345b4d256 100644 --- a/sc/source/ui/undo/undoutil.cxx +++ b/sc/source/ui/undo/undoutil.cxx @@ -82,33 +82,44 @@ void ScUndoUtil::MarkSimpleBlock( ScDocShell* pDocShell, ScDBData* ScUndoUtil::GetOldDBData( ScDBData* pUndoData, ScDocument* pDoc, SCTAB nTab, - SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) + SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) { ScDBData* pRet = pDoc->GetDBAtArea( nTab, nCol1, nRow1, nCol2, nRow2 ); if (!pRet) { - sal_Bool bWasTemp = sal_False; + bool bWasInternalUnnamed = false; + bool bWasInternalForAutoFilter = false; if ( pUndoData ) { String aName; pUndoData->GetName( aName ); -// if ( aName == ScGlobal::GetRscString( STR_DB_NONAME ) ) - if (pUndoData->IsBuildin()) - bWasTemp = sal_True; + if ( pUndoData->IsInternalUnnamed() ) + { + bWasInternalUnnamed = true; + } + else if (pUndoData->IsInternalForAutoFilter()) + { + bWasInternalForAutoFilter = true; + } } - DBG_ASSERT(bWasTemp, "Undo: didn't find database range"); + DBG_ASSERT( bWasInternalUnnamed || bWasInternalForAutoFilter, "Undo: didn't find database range"); sal_uInt16 nIndex; ScDBCollection* pColl = pDoc->GetDBCollection(); - if (pColl->SearchName( ScGlobal::GetRscString( STR_DB_NONAME ), nIndex )) + if ( bWasInternalUnnamed + && pColl->SearchName( ScGlobal::GetRscString( STR_DB_NONAME ), nIndex )) + { pRet = (*pColl)[nIndex]; + } else { - 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 ) ); + String aNewNamed = bWasInternalForAutoFilter + ? pColl->GetNewDefaultDBName() + : ScGlobal::GetRscString( STR_DB_NONAME ); + pRet = new ScDBData( + aNewNamed, 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 f6c68fcc997a..c26936d6a4b1 100644 --- a/sc/source/ui/view/cellsh2.cxx +++ b/sc/source/ui/view/cellsh2.cxx @@ -357,8 +357,7 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq ) ScSubTotalParam aSubTotalParam; SfxItemSet aArgSet( GetPool(), SCITEM_SUBTDATA, SCITEM_SUBTDATA ); - //ScDBData* pDBData = pTabViewShell->GetDBData(); - ScDBData* pDBData = pTabViewShell->GetDBData(sal_True, SC_DB_MAKE_SUBTOTAL); + ScDBData* pDBData = pTabViewShell->GetDBData(); pDBData->GetSubTotalParam( aSubTotalParam ); aSubTotalParam.bRemoveOnly = sal_False; @@ -412,7 +411,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(sal_True, SC_DB_MAKE_SORT); + ScDBData* pDBData = pTabViewShell->GetDBData(); ScViewData* pData = GetViewData(); pDBData->GetSortParam( aSortParam ); @@ -463,7 +462,7 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq ) if ( pArgs ) // Basic { ScSortParam aSortParam; - ScDBData* pDBData = pTabViewShell->GetDBData(sal_True, SC_DB_MAKE_SORT); + ScDBData* pDBData = pTabViewShell->GetDBData(); ScViewData* pData = GetViewData(); pDBData->GetSortParam( aSortParam ); @@ -526,7 +525,7 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq ) else { ScSortParam aSortParam; - ScDBData* pDBData = pTabViewShell->GetDBData(sal_True, SC_DB_MAKE_SORT); + ScDBData* pDBData = pTabViewShell->GetDBData(); ScViewData* pData = GetViewData(); pDBData->GetSortParam( aSortParam ); @@ -681,7 +680,7 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq ) case SID_UNFILTER: { ScQueryParam aParam; - ScDBData* pDBData = pTabViewShell->GetDBData(sal_True, SC_DB_OLD_FILTER); + ScDBData* pDBData = pTabViewShell->GetDBData(); pDBData->GetQueryParam( aParam ); SCSIZE nEC = aParam.GetEntryCount(); @@ -945,7 +944,6 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq ) if ( pDBCol ) { - const String aStrNoName( ScGlobal::GetRscString(STR_DB_NONAME) ); List aList; sal_uInt16 nDBCount = pDBCol->GetCount(); ScDBData* pDbData = NULL; @@ -959,18 +957,13 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq ) pDBName = new String; pDbData->GetName( *pDBName ); - if ( *pDBName != aStrNoName ) + if ( !pDbData->IsInternalUnnamed() ) aList.Insert( pDBName ); else DELETEZ(pDBName); } } -//CHINA001 ScSelEntryDlg* pDlg = -//CHINA001 new ScSelEntryDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_SELECTDB, -//CHINA001 String(ScResId(SCSTR_SELECTDB)), -//CHINA001 String(ScResId(SCSTR_AREAS)), -//CHINA001 aList ); ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 diff --git a/sc/source/ui/view/dbfunc.cxx b/sc/source/ui/view/dbfunc.cxx index f82507aea973..c0771d074bd4 100644 --- a/sc/source/ui/view/dbfunc.cxx +++ b/sc/source/ui/view/dbfunc.cxx @@ -332,119 +332,119 @@ void ScDBFunc::ToggleAutoFilter() ScDocShell* pDocSh = GetViewData()->GetDocShell(); ScDocShellModificator aModificator( *pDocSh ); - ScQueryParam aParam; - ScDocument* pDoc = GetViewData()->GetDocument(); - ScDBData* pDBData = GetDBData( sal_False, SC_DB_OLD_FILTER, SC_DBSEL_ROW_DOWN ); - - + ScDBData* pDBData = GetDBData( sal_False, SC_DB_MAKE_AUTOFILTER, SC_DBSEL_ROW_DOWN ); + if ( pDBData == NULL ) + { + return; + } + // use a list action for the AutoFilter buttons (ScUndoAutoFilter) and the filter operation + const String aUndo = ScGlobal::GetRscString( STR_UNDO_QUERY ); + pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo ); - SCCOL nCol; - SCROW nRow; - SCTAB nTab = GetViewData()->GetTabNo(); - sal_Int16 nFlag; - //sal_Bool bHasAuto = sal_True; - sal_Bool bHeader; - sal_Bool bPaint = sal_False; + pDBData->SetByRow( sal_True ); + ScQueryParam aParam; + pDBData->GetQueryParam( aParam ); - //! stattdessen aus DB-Bereich abfragen? + ScDocument* pDoc = GetViewData()->GetDocument(); - /*for (nCol=aParam.nCol1; nCol<=aParam.nCol2 && bHasAuto; nCol++) + bool bHasAutoFilter = true; + const SCROW nRow = aParam.nRow1; + const SCTAB nTab = GetViewData()->GetTabNo(); + for ( SCCOL nCol=aParam.nCol1; nCol<=aParam.nCol2 && bHasAutoFilter; ++nCol ) { - nFlag = ((ScMergeFlagAttr*) pDoc-> - GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG ))->GetValue(); + const sal_Int16 nFlag = + ((ScMergeFlagAttr*) pDoc->GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG ))->GetValue(); if ( (nFlag & SC_MF_AUTO) == 0 ) - bHasAuto = sal_False; - }*/ + bHasAutoFilter = false; + } - if (pDBData && pDBData->HasAutoFilter()) // aufheben + bool bPaint = false; + + if ( bHasAutoFilter ) { - // 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++) + // switch filter buttons + for ( SCCOL nCol=aParam.nCol1; nCol<=aParam.nCol2; ++nCol ) { - nFlag = ((ScMergeFlagAttr*) pDoc-> - GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG ))->GetValue(); + const sal_Int16 nFlag = + ((ScMergeFlagAttr*) pDoc->GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG ))->GetValue(); pDoc->ApplyAttr( nCol, nRow, nTab, ScMergeFlagAttr( nFlag & ~SC_MF_AUTO ) ); } - // use a list action for the AutoFilter buttons (ScUndoAutoFilter) and the filter operation - - String aUndo = ScGlobal::GetRscString( STR_UNDO_QUERY ); - pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo ); - ScRange aRange; pDBData->GetArea( aRange ); - pDocSh->GetUndoManager()->AddUndoAction( - new ScUndoAutoFilter( pDocSh, aRange, pDBData->GetName(), sal_False ) ); + pDocSh->GetUndoManager()->AddUndoAction( new ScUndoAutoFilter( pDocSh, aRange, pDBData->GetName(), sal_False ) ); pDBData->SetAutoFilter(sal_False); - // Filter aufheben (incl. Paint / Undo) - - SCSIZE nEC = aParam.GetEntryCount(); - for (SCSIZE i=0; i<nEC; i++) + // switch off filter + const SCSIZE nEC = aParam.GetEntryCount(); + for ( SCSIZE i=0; i<nEC; ++i ) + { aParam.GetEntry(i).bDoQuery = sal_False; + } aParam.bDuplicate = sal_True; Query( aParam, NULL, sal_True ); - pDocSh->GetUndoManager()->LeaveListAction(); + // delete internal database range for auto filter + if ( pDBData->IsInternalForAutoFilter() ) + { + ScDBDocFunc aFunc(*pDocSh); + aFunc.DeleteDBRange( pDBData->GetName(), sal_False ); + } + pDBData = NULL; - bPaint = sal_True; + bPaint = true; } - else // Filterknoepfe einblenden + else { - 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 ) ) + if ( !pDoc->IsBlockEmpty( + nTab, + aParam.nCol1, + aParam.nRow1, + aParam.nCol2, + aParam.nRow2 ) ) { - if (!bHeader) + if ( !pDBData->HasHeader() ) { - if ( MessBox( GetViewData()->GetDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES), - ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_0 ), // "StarCalc" - ScGlobal::GetRscString( STR_MSSG_MAKEAUTOFILTER_0 ) // Koepfe aus erster Zeile? - ).Execute() == RET_YES ) + if ( MessBox( + GetViewData()->GetDialogParent(), + WinBits(WB_YES_NO | WB_DEF_YES), + ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_0 ), + ScGlobal::GetRscString( STR_MSSG_MAKEAUTOFILTER_0 ) ).Execute() == RET_YES ) { - pDBData->SetHeader( sal_True ); //! Undo ?? - bHeader = sal_True; + pDBData->SetHeader( sal_True ); } } ScRange aRange; pDBData->GetArea( aRange ); - pDocSh->GetUndoManager()->AddUndoAction( - new ScUndoAutoFilter( pDocSh, aRange, pDBData->GetName(), sal_True ) ); + pDocSh->GetUndoManager()->AddUndoAction( new ScUndoAutoFilter( pDocSh, aRange, pDBData->GetName(), sal_True ) ); pDBData->SetAutoFilter(sal_True); - for (nCol=aParam.nCol1; nCol<=aParam.nCol2; nCol++) + for ( SCCOL nCol=aParam.nCol1; nCol<=aParam.nCol2; ++nCol ) { - nFlag = ((ScMergeFlagAttr*) pDoc-> - GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG ))->GetValue(); + const sal_Int16 nFlag = + ((ScMergeFlagAttr*) pDoc->GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG ))->GetValue(); pDoc->ApplyAttr( nCol, nRow, nTab, ScMergeFlagAttr( nFlag | SC_MF_AUTO ) ); } - pDocSh->PostPaint( aParam.nCol1, nRow, nTab, aParam.nCol2, nRow, nTab, - PAINT_GRID ); - bPaint = sal_True; + pDocSh->PostPaint( aParam.nCol1, nRow, nTab, aParam.nCol2, nRow, nTab, PAINT_GRID ); + bPaint = true; } else { - ErrorBox aErrorBox( GetViewData()->GetDialogParent(), WinBits( WB_OK | WB_DEF_OK ), - ScGlobal::GetRscString( STR_ERR_AUTOFILTER ) ); + ErrorBox aErrorBox( + GetViewData()->GetDialogParent(), + WinBits( WB_OK | WB_DEF_OK ), + ScGlobal::GetRscString( STR_ERR_AUTOFILTER ) ); aErrorBox.Execute(); } } + pDocSh->GetUndoManager()->LeaveListAction(); + if ( bPaint ) { aModificator.SetDocumentModified(); @@ -462,30 +462,41 @@ void ScDBFunc::HideAutoFilter() ScDocShell* pDocSh = GetViewData()->GetDocShell(); ScDocShellModificator aModificator( *pDocSh ); - ScDocument* pDoc = pDocSh->GetDocument(); - - ScQueryParam aParam; - //ScDBData* pDBData = GetDBData( FALSE ); - ScDBData* pDBData = GetDBData(sal_False, SC_DB_OLD_FILTER); - + ScDBData* pDBData = GetDBData( sal_False ); SCTAB nTab; SCCOL nCol1, nCol2; SCROW nRow1, nRow2; pDBData->GetArea(nTab, nCol1, nRow1, nCol2, nRow2); - for (SCCOL nCol=nCol1; nCol<=nCol2; nCol++) { - sal_Int16 nFlag = ((ScMergeFlagAttr*) pDoc-> - GetAttr( nCol, nRow1, nTab, ATTR_MERGE_FLAG ))->GetValue(); - pDoc->ApplyAttr( nCol, nRow1, nTab, ScMergeFlagAttr( nFlag & ~SC_MF_AUTO ) ); + ScDocument* pDoc = pDocSh->GetDocument(); + for (SCCOL nCol=nCol1; nCol<=nCol2; nCol++) + { + const sal_Int16 nFlag = + ((ScMergeFlagAttr*) pDoc->GetAttr( nCol, nRow1, nTab, ATTR_MERGE_FLAG ))->GetValue(); + pDoc->ApplyAttr( nCol, nRow1, nTab, ScMergeFlagAttr( nFlag & ~SC_MF_AUTO ) ); + } } - ScRange aRange; - pDBData->GetArea( aRange ); - pDocSh->GetUndoManager()->AddUndoAction( - new ScUndoAutoFilter( pDocSh, aRange, pDBData->GetName(), sal_False ) ); + const String aUndo = ScGlobal::GetRscString( STR_UNDO_QUERY ); + pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo ); + { + ScRange aRange; + pDBData->GetArea( aRange ); + pDocSh->GetUndoManager()->AddUndoAction( + new ScUndoAutoFilter( pDocSh, aRange, pDBData->GetName(), sal_False ) ); - pDBData->SetAutoFilter(sal_False); + pDBData->SetAutoFilter(sal_False); + + // delete internal database range for auto filter + if ( pDBData->IsInternalForAutoFilter() ) + { + ScDBDocFunc aFunc(*pDocSh); + aFunc.DeleteDBRange( pDBData->GetName(), sal_False ); + } + pDBData = NULL; + } + pDocSh->GetUndoManager()->LeaveListAction(); pDocSh->PostPaint( nCol1,nRow1,nTab, nCol2,nRow1,nTab, PAINT_GRID ); aModificator.SetDocumentModified(); diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx index 42c07bd8bd7f..f5bd19d25caf 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_FILTER, SC_DBSEL_ROW_DOWN); + ScDBData* pDBData = GetDBData( sal_True, SC_DB_MAKE, 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_FILTER, SC_DBSEL_ROW_DOWN); + ScDBData* pDBData = GetDBData( sal_True, SC_DB_MAKE, SC_DBSEL_ROW_DOWN); pDBData->GetQueryParam( aQueryParam ); aArgSet.Put( ScQueryItem( SCITEM_QUERYDATA, |