diff options
author | Eike Rathke <erack@redhat.com> | 2015-07-17 15:21:48 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2015-07-17 15:26:49 +0200 |
commit | 8eadeb91cde9709f006e8c5e19e98bff44dbd177 (patch) | |
tree | 095b5a5c73d4f6ecd6773c3cecba7e3dea8d3fdb /sc | |
parent | 9dd4b06304a615d2d600d6b1cdf0d6d445311b0d (diff) |
Resolves: tdf#77479 do not reset AutoFilter range for temporary operations
Change-Id: I22f5e74ca91eb188ce669762927dd25604a256ff
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/document.hxx | 8 | ||||
-rw-r--r-- | sc/inc/global.hxx | 7 | ||||
-rw-r--r-- | sc/source/core/data/documen2.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/document.cxx | 11 | ||||
-rw-r--r-- | sc/source/core/tool/dbdata.cxx | 22 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh5.cxx | 16 | ||||
-rw-r--r-- | sc/source/ui/view/dbfunc.cxx | 2 |
7 files changed, 62 insertions, 6 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 0e6c7e34cbfb..74f25b8f10d6 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -319,6 +319,7 @@ private: ScScriptTypeData* pScriptTypeData; ScRefreshTimerControl* pRefreshTimerControl; rtl::Reference<SvxForbiddenCharactersTable> xForbiddenCharacters; + ScDBData* mpAnonymousDBData; ScFieldEditEngine* pCacheFieldEditEngine; @@ -612,6 +613,13 @@ public: SC_DLLPUBLIC void SetAnonymousDBData(SCTAB nTab, ScDBData* pDBData); SC_DLLPUBLIC ScDBData* GetAnonymousDBData(SCTAB nTab); + /** One document global anonymous database range for temporary operations, + used if the corresponding sheet-local anonymous database range is + already used with AutoFilter and range differs. Not stored in document + files. */ + SC_DLLPUBLIC void SetAnonymousDBData(ScDBData* pDBData); + SC_DLLPUBLIC ScDBData* GetAnonymousDBData(); + SC_DLLPUBLIC SCTAB GetTableCount() const; SvNumberFormatterIndexTable* GetFormatExchangeList() const { return pFormatExchangeList; } diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx index 1691745006e2..c7e250fedb77 100644 --- a/sc/inc/global.hxx +++ b/sc/inc/global.hxx @@ -408,9 +408,10 @@ enum ScAnchorType // anchor of a character object enum ScGetDBMode { - SC_DB_MAKE, // create "untitled" (if necessary) - SC_DB_IMPORT, // create "Importx" (if necessary) - SC_DB_OLD // don't create + SC_DB_MAKE, ///< create "untitled" (if necessary) + SC_DB_AUTOFILTER, ///< force use of sheet-local instead of document global anonymous range + SC_DB_IMPORT, ///< create "Importx" (if necessary) + SC_DB_OLD ///< don't create }; /// For ScDBFunc::GetDBData() diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index 8d3e4e3d3b8f..5b02cf7d4b39 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -156,6 +156,7 @@ ScDocument::ScDocument( ScDocumentMode eMode, SfxObjectShell* pDocShell ) : pUnoRefUndoList( NULL ), pChangeViewSettings( NULL ), pScriptTypeData( NULL ), + mpAnonymousDBData( NULL ), pCacheFieldEditEngine( NULL ), pViewOptions( NULL ), pDocOptions( NULL ), @@ -427,6 +428,7 @@ ScDocument::~ScDocument() pVirtualDevice_100th_mm.disposeAndClear(); delete pDPCollection; + delete mpAnonymousDBData; // delete the EditEngine before destroying the xPoolHelper delete pCacheFieldEditEngine; diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 95655f295cdd..c0f83ca17ef2 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -302,6 +302,17 @@ void ScDocument::SetAnonymousDBData(SCTAB nTab, ScDBData* pDBData) maTabs[nTab]->SetAnonymousDBData(pDBData); } +void ScDocument::SetAnonymousDBData( ScDBData* pDBData ) +{ + delete mpAnonymousDBData; + mpAnonymousDBData = pDBData; +} + +ScDBData* ScDocument::GetAnonymousDBData() +{ + return mpAnonymousDBData; +} + bool ScDocument::ValidTabName( const OUString& rName ) { if (rName.isEmpty()) diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx index e91f2b1bf061..92c47e56928d 100644 --- a/sc/source/core/tool/dbdata.cxx +++ b/sc/source/core/tool/dbdata.cxx @@ -945,6 +945,8 @@ const ScDBData* ScDBCollection::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab if (pData) return pData; + // Do NOT check for the document global temporary anonymous db range here. + return NULL; } @@ -967,6 +969,8 @@ ScDBData* ScDBCollection::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool if (pData) return const_cast<ScDBData*>(pData); + // Do NOT check for the document global temporary anonymous db range here. + return NULL; } @@ -986,7 +990,17 @@ const ScDBData* ScDBCollection::GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1 return pNoNameData; // Lastly, check the global anonymous db ranges. - return maAnonDBs.findByRange(aRange); + const ScDBData* pData = maAnonDBs.findByRange(aRange); + if (pData) + return pData; + + // As a last resort, check for the document global temporary anonymous db range. + pNoNameData = pDoc->GetAnonymousDBData(); + if (pNoNameData) + if (pNoNameData->IsDBAtArea(nTab, nCol1, nRow1, nCol2, nRow2)) + return pNoNameData; + + return NULL; } ScDBData* ScDBCollection::GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) @@ -1009,6 +1023,12 @@ ScDBData* ScDBCollection::GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCO if (pData) return const_cast<ScDBData*>(pData); + // As a last resort, check for the document global temporary anonymous db range. + pNoNameData = pDoc->GetAnonymousDBData(); + if (pNoNameData) + if (pNoNameData->IsDBAtArea(nTab, nCol1, nRow1, nCol2, nRow2)) + return pNoNameData; + return NULL; } diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx index 3ee3d0000a28..b34d9e903daa 100644 --- a/sc/source/ui/docshell/docsh5.cxx +++ b/sc/source/ui/docshell/docsh5.cxx @@ -145,7 +145,7 @@ ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGe if (!bSelected) { bUseThis = true; - if ( bIsNoName && eMode == SC_DB_MAKE ) + if ( bIsNoName && (eMode == SC_DB_MAKE || eMode == SC_DB_AUTOFILTER) ) { // If nothing marked or only one row marked, adapt // "unbenannt"/"unnamed" to contiguous area. @@ -222,6 +222,20 @@ ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGe ScDBData* pNoNameData = aDocument.GetAnonymousDBData(nTab); if ( eMode != SC_DB_IMPORT && pNoNameData) { + // Do not reset AutoFilter range during temporary operations on + // 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. + if (eMode != SC_DB_AUTOFILTER && pNoNameData->HasAutoFilter()) + { + pNoNameData = aDocument.GetAnonymousDBData(); + if (!pNoNameData) + { + pNoNameData = new ScDBData( STR_DB_LOCAL_NONAME, + nTab, nStartCol, nStartRow, nEndCol, nEndRow, true, bHasHeader); + aDocument.SetAnonymousDBData( pNoNameData); + } + } if ( !pOldAutoDBRange ) { diff --git a/sc/source/ui/view/dbfunc.cxx b/sc/source/ui/view/dbfunc.cxx index 2821c202d0cf..da44ac4a43b9 100644 --- a/sc/source/ui/view/dbfunc.cxx +++ b/sc/source/ui/view/dbfunc.cxx @@ -287,7 +287,7 @@ void ScDBFunc::ToggleAutoFilter() ScQueryParam aParam; ScDocument* pDoc = GetViewData().GetDocument(); - ScDBData* pDBData = GetDBData(false, SC_DB_MAKE, SC_DBSEL_ROW_DOWN); + ScDBData* pDBData = GetDBData(false, SC_DB_AUTOFILTER, SC_DBSEL_ROW_DOWN); pDBData->SetByRow( true ); //! undo, retrieve beforehand ?? pDBData->GetQueryParam( aParam ); |