summaryrefslogtreecommitdiff
path: root/sc/source/ui/view/dbfunc.cxx
diff options
context:
space:
mode:
authorOliver-Rainer Wittmann <orw@apache.org>2013-09-06 15:26:36 +0000
committerOliver-Rainer Wittmann <orw@apache.org>2013-09-06 15:26:36 +0000
commit2e1614441cf56ed174572e2b92a451055ad626bd (patch)
treed51318b842f9aa55e512c89243eed2a817531592 /sc/source/ui/view/dbfunc.cxx
parent8e46b8bc28fffec586137b4b525d2e23648cceac (diff)
122862: adjust code for issue 12666 in order to solve regressions 122862, 122870, 122955, 123161 and 123163
For 12666 new internal database ranges have been introduced. The fix reduced its usage to the once needed for the Auto Filter function. Standard Filter and Special Filter should be untouched now.
Notes
Notes: prefer: 7df4c7feacf51c141a7beaa2a8404d932d7c2e86
Diffstat (limited to 'sc/source/ui/view/dbfunc.cxx')
-rw-r--r--sc/source/ui/view/dbfunc.cxx175
1 files changed, 93 insertions, 82 deletions
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();