[Libreoffice-commits] core.git: sc/inc sc/source
Eike Rathke
erack at redhat.com
Fri Jul 17 06:27:34 PDT 2015
sc/inc/document.hxx | 8 ++++++++
sc/inc/global.hxx | 7 ++++---
sc/source/core/data/documen2.cxx | 2 ++
sc/source/core/data/document.cxx | 11 +++++++++++
sc/source/core/tool/dbdata.cxx | 22 +++++++++++++++++++++-
sc/source/ui/docshell/docsh5.cxx | 16 +++++++++++++++-
sc/source/ui/view/dbfunc.cxx | 2 +-
7 files changed, 62 insertions(+), 6 deletions(-)
New commits:
commit 8eadeb91cde9709f006e8c5e19e98bff44dbd177
Author: Eike Rathke <erack at redhat.com>
Date: Fri Jul 17 15:21:48 2015 +0200
Resolves: tdf#77479 do not reset AutoFilter range for temporary operations
Change-Id: I22f5e74ca91eb188ce669762927dd25604a256ff
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 0e6c7e3..74f25b8 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 1691745..c7e250f 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 8d3e4e3..5b02cf7 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 95655f2..c0f83ca 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 e91f2b1..92c47e5 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 3ee3d00..b34d9e9 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 2821c20..da44ac4 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 );
More information about the Libreoffice-commits
mailing list