[Libreoffice-commits] core.git: Branch 'libreoffice-5-0' - sc/inc sc/source

Eike Rathke erack at redhat.com
Sun Jul 19 12:50:52 PDT 2015


 sc/inc/dbdata.hxx                  |    5 +++++
 sc/source/core/tool/dbdata.cxx     |   21 +++++++++++++++++++++
 sc/source/ui/docshell/dbdocfun.cxx |    3 +++
 3 files changed, 29 insertions(+)

New commits:
commit e6241675a74e305b1af1049374be648ec63c37d8
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Jul 16 17:52:29 2015 +0200

    Resolves: tdf#88402 remember sort "has headers" at anonymous database ranges
    
    Change-Id: I4a126f40589fd401f3a63f74be5e86e3df947ef6
    (cherry picked from commit 33255f974fc712b9e9e2965a350c65a2195a7ae6)
    Reviewed-on: https://gerrit.libreoffice.org/17136
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/inc/dbdata.hxx b/sc/inc/dbdata.hxx
index 4965e94..fdcf678 100644
--- a/sc/inc/dbdata.hxx
+++ b/sc/inc/dbdata.hxx
@@ -128,6 +128,10 @@ public:
     void        GetSortParam(ScSortParam& rSortParam) const;
     void        SetSortParam(const ScSortParam& rSortParam);
 
+    /** Remember some more settings of ScSortParam, only to be called at
+        anonymous DB ranges as it at least overwrites bHasHeader. */
+    void        UpdateFromSortParam( const ScSortParam& rSortParam );
+
     SC_DLLPUBLIC void       GetQueryParam(ScQueryParam& rQueryParam) const;
     SC_DLLPUBLIC void       SetQueryParam(const ScQueryParam& rQueryParam);
     SC_DLLPUBLIC bool       GetAdvancedQuerySource(ScRange& rSource) const;
@@ -228,6 +232,7 @@ public:
         ScDBData* getByRange(const ScRange& rRange);
         void insert(ScDBData* p);
         bool empty() const;
+        bool has( const ScDBData* p ) const;
         bool operator== (const AnonDBs& r) const;
     };
 
diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx
index e51da5d..e91f2b1 100644
--- a/sc/source/core/tool/dbdata.cxx
+++ b/sc/source/core/tool/dbdata.cxx
@@ -346,6 +346,11 @@ void ScDBData::SetSortParam( const ScSortParam& rSortParam )
     bByRow = rSortParam.bByRow;
 }
 
+void ScDBData::UpdateFromSortParam( const ScSortParam& rSortParam )
+{
+    bHasHeader = rSortParam.bHasHeader;
+}
+
 void ScDBData::GetQueryParam( ScQueryParam& rQueryParam ) const
 {
     rQueryParam = *mpQueryParam;
@@ -744,6 +749,17 @@ public:
     }
 };
 
+class FindByPointer : public unary_function<ScDBData, bool>
+{
+    const ScDBData* mpDBData;
+public:
+    FindByPointer(const ScDBData* pDBData) : mpDBData(pDBData) {}
+    bool operator() (const ScDBData& r) const
+    {
+        return &r == mpDBData;
+    }
+};
+
 }
 
 ScDBCollection::NamedDBs::NamedDBs(ScDBCollection& rParent, ScDocument& rDoc) :
@@ -894,6 +910,11 @@ bool ScDBCollection::AnonDBs::empty() const
     return maDBs.empty();
 }
 
+bool ScDBCollection::AnonDBs::has( const ScDBData* p ) const
+{
+    return find_if( maDBs.begin(), maDBs.end(), FindByPointer(p)) != maDBs.end();
+}
+
 bool ScDBCollection::AnonDBs::operator== (const AnonDBs& r) const
 {
     return maDBs == r.maDBs;
diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx
index 567e100..ff748c4 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -574,6 +574,9 @@ bool ScDBDocFunc::Sort( SCTAB nTab, const ScSortParam& rSortParam,
     }
 
     pDBData->SetSortParam(rSortParam);
+    // Remember additional settings on anonymous database ranges.
+    if (pDBData == rDoc.GetAnonymousDBData( nTab) || rDoc.GetDBCollection()->getAnonDBs().has( pDBData))
+        pDBData->UpdateFromSortParam( rSortParam);
 
     if (nStartRow <= aLocalParam.nRow2)
     {


More information about the Libreoffice-commits mailing list