diff options
author | Eike Rathke <erack@redhat.com> | 2018-02-15 12:50:40 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-02-16 10:23:49 +0100 |
commit | 805f5d5b4ab022c531709d46b5dad10a1d772309 (patch) | |
tree | 93aa5d7d5eff670713a24f1523f47624882b6da6 /sc/source | |
parent | 3779c742a52d8dde3fa7b74c2a8ca8bc7d071b4e (diff) |
Resolves: tdf#115046 don't restore a sheet-local DBData from temporary
And don't clear AutoFilter button flags in the new temporary range.
Change-Id: I273de1e04632ac99c267523b2843665d257fd361
(cherry picked from commit 74d30155c5067271fb98bacbcb895c215e61678d)
Reviewed-on: https://gerrit.libreoffice.org/49809
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/ui/docshell/docsh5.cxx | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx index dd39f53522d8..3f0ca7cd4576 100644 --- a/sc/source/ui/docshell/docsh5.cxx +++ b/sc/source/ui/docshell/docsh5.cxx @@ -222,8 +222,10 @@ ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGe // other ranges, use the document global temporary anonymous range // instead. But, if AutoFilter is to be toggled then do use the // sheet-local DB range. + bool bSheetLocal = true; if (eMode != SC_DB_AUTOFILTER && pNoNameData->HasAutoFilter()) { + bSheetLocal = false; pNoNameData = aDocument.GetAnonymousDBData(); if (!pNoNameData) { @@ -231,14 +233,24 @@ ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGe nTab, nStartCol, nStartRow, nEndCol, nEndRow, true, bHasHeader); aDocument.SetAnonymousDBData( pNoNameData); } + // ScDocShell::CancelAutoDBRange() would restore the + // sheet-local anonymous DBData from pOldAutoDBRange, unset so + // that won't happen with data of a previous sheet-local + // DBData. + delete pOldAutoDBRange; + pOldAutoDBRange = nullptr; } - - if ( !pOldAutoDBRange ) + else 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 ); } + else if (pOldAutoDBRange->GetTab() != pNoNameData->GetTab()) + { + // Different sheet-local unnamed DB range than the previous one. + *pOldAutoDBRange = *pNoNameData; + } SCCOL nOldX1; // take old range away cleanly SCROW nOldY1; //! (UNDO ???) @@ -255,7 +267,10 @@ ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGe nStartCol <= nOldY2 && nOldY1 <= nEndCol) bHasHeader = true; - DBAreaDeleted( nOldTab, nOldX1, nOldY1, nOldX2 ); + // Remove AutoFilter button flags only for sheet-local DB range, + // not if a temporary is used. + if (bSheetLocal) + DBAreaDeleted( nOldTab, nOldX1, nOldY1, nOldX2 ); pNoNameData->SetSortParam( ScSortParam() ); // reset parameter pNoNameData->SetQueryParam( ScQueryParam() ); |