[Libreoffice-commits] core.git: Branch 'private/jmux/libreoffice-4-1-6+backports' - 3 commits - sc/Library_sc.mk sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Thu Oct 8 06:10:29 PDT 2015


 sc/Library_sc.mk                     |    1 
 sc/source/core/tool/formulaopt.cxx   |    4 +
 sc/source/filter/xml/pivotsource.cxx |  121 +++++++++++++++++++++++++++++++++++
 sc/source/filter/xml/pivotsource.hxx |   90 ++++++++++++++++++++++++++
 sc/source/filter/xml/xmldpimp.cxx    |   45 +++----------
 sc/source/filter/xml/xmldpimp.hxx    |    2 
 sc/source/filter/xml/xmlimprt.cxx    |   12 +++
 sc/source/filter/xml/xmlimprt.hxx    |    8 ++
 8 files changed, 249 insertions(+), 34 deletions(-)

New commits:
commit 76026c5c50c1d24f4ef012985e36170933aac87c
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Sun Mar 9 19:11:40 2014 -0400

    fdo#75960: No point instantiating the struct when there are no pivot tables.
    
    Just a tiny micro-optimization.
    
    Change-Id: I850bebc63a3f51456326b09ce72442845ea04478
    (cherry picked from commit 98bd1911420f46380aa5373a92de6a748ced080d)

diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index 17d7b82..ab54d91 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -3250,7 +3250,9 @@ throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeE
             SetLabelRanges();
             SetNamedRanges();
             SetSheetNamedRanges();
-            GetPivotTableSources().process();
+            if (mpPivotSources)
+                // Process pivot table sources after the named ranges have been set.
+                mpPivotSources->process();
         }
         GetProgressBarHelper()->End();  // make room for subsequent SfxProgressBars
         if (pDoc)
commit 4d4b0b9c57010d4c15073415b577b38ccd6a60d6
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Sun Mar 9 18:40:13 2014 -0400

    fdo#75960: Process pivot tables after named ranges are all set.
    
    Especially for those pivot tables that reference named ranges as their
    data sources, it's critical that we process them after named ranges are
    set. Else things would start to fail.
    
    (cherry picked from commit 057d269c5d1faf45c4c935b2f8120c45e646de65)
    
    Conflicts:
    
    	sc/Library_sc.mk
    	sc/source/filter/xml/xmlimprt.cxx
    	sc/source/filter/xml/xmlimprt.hxx
    
    Change-Id: I4bf8aa1a844aae3953f2dfbeba0e4d2542a7e53f

diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index 2583937..254f146 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -275,6 +275,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
 	sc/source/filter/xml/celltextparacontext \
 	sc/source/filter/xml/editattributemap \
 	sc/source/filter/xml/importcontext \
+	sc/source/filter/xml/pivotsource \
 	sc/source/filter/xml/sheetdata \
 	sc/source/filter/xml/xmlannoi \
 	sc/source/filter/xml/xmlbodyi \
diff --git a/sc/source/filter/xml/pivotsource.cxx b/sc/source/filter/xml/pivotsource.cxx
new file mode 100644
index 0000000..43b5a4d
--- /dev/null
+++ b/sc/source/filter/xml/pivotsource.cxx
@@ -0,0 +1,121 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "pivotsource.hxx"
+
+#include <dpsave.hxx>
+
+namespace sc {
+
+PivotTableSources::SelectedPages::SelectedPages( ScDPObject* pObj, const SelectedPagesType& rSelected ) :
+    mpDP(pObj), maSelectedPages(rSelected) {}
+
+PivotTableSources::SheetSource::SheetSource( ScDPObject* pObj, const ScSheetSourceDesc& rDesc ) :
+    mpDP(pObj), maDesc(rDesc) {}
+
+PivotTableSources::DBSource::DBSource( ScDPObject* pObj, const ScImportSourceDesc& rDesc ) :
+    mpDP(pObj), maDesc(rDesc) {}
+
+PivotTableSources::ServiceSource::ServiceSource( ScDPObject* pObj, const ScDPServiceDesc& rDesc ) :
+    mpDP(pObj), maDesc(rDesc) {}
+
+PivotTableSources::PivotTableSources() {}
+
+void PivotTableSources::appendSheetSource( ScDPObject* pObj, const ScSheetSourceDesc& rDesc )
+{
+    maSheetSources.push_back(SheetSource(pObj, rDesc));
+}
+
+void PivotTableSources::appendDBSource( ScDPObject* pObj, const ScImportSourceDesc& rDesc )
+{
+    maDBSources.push_back(DBSource(pObj, rDesc));
+}
+
+void PivotTableSources::appendServiceSource( ScDPObject* pObj, const ScDPServiceDesc& rDesc )
+{
+    maServiceSources.push_back(ServiceSource(pObj, rDesc));
+}
+
+void PivotTableSources::appendSelectedPages( ScDPObject* pObj, const SelectedPagesType& rSelected )
+{
+    if (rSelected.empty())
+        return;
+
+    maSelectedPagesList.push_back(SelectedPages(pObj, rSelected));
+}
+
+namespace {
+
+struct SelectedPageProcessor : std::unary_function<PivotTableSources::SelectedPages, void>
+{
+    void operator() ( PivotTableSources::SelectedPages& rItem )
+    {
+        // Set selected pages after building all dimension members.
+        if (!rItem.mpDP)
+            return;
+
+        rItem.mpDP->BuildAllDimensionMembers();
+        ScDPSaveData* pSaveData = rItem.mpDP->GetSaveData();
+        if (!pSaveData)
+            return;
+
+        PivotTableSources::SelectedPagesType::const_iterator it = rItem.maSelectedPages.begin(), itEnd = rItem.maSelectedPages.end();
+        for (; it != itEnd; ++it)
+        {
+            const OUString& rDimName = it->first;
+            const OUString& rSelected = it->second;
+            ScDPSaveDimension* pDim = pSaveData->GetExistingDimensionByName(rDimName);
+            if (!pDim)
+                continue;
+
+            pDim->SetCurrentPage(&rSelected);
+        }
+    }
+};
+
+struct PivotSheetDescSetter : std::unary_function<sc::PivotTableSources::SheetSource, void>
+{
+    void operator() ( sc::PivotTableSources::SheetSource& rSrc )
+    {
+        ScDPObject* pObj = rSrc.mpDP;
+        pObj->SetSheetDesc(rSrc.maDesc);
+    }
+};
+
+struct PivotDBDescSetter : std::unary_function<sc::PivotTableSources::DBSource, void>
+{
+    void operator() ( sc::PivotTableSources::DBSource& rSrc )
+    {
+        ScDPObject* pObj = rSrc.mpDP;
+        pObj->SetImportDesc(rSrc.maDesc);
+    }
+};
+
+struct PivotServiceDataSetter : std::unary_function<sc::PivotTableSources::ServiceSource, void>
+{
+    void operator() ( sc::PivotTableSources::ServiceSource& rSrc )
+    {
+        ScDPObject* pObj = rSrc.mpDP;
+        pObj->SetServiceData(rSrc.maDesc);
+    }
+};
+
+}
+
+void PivotTableSources::process()
+{
+    std::for_each(maSheetSources.begin(), maSheetSources.end(), PivotSheetDescSetter());
+    std::for_each(maDBSources.begin(), maDBSources.end(), PivotDBDescSetter());
+    std::for_each(maServiceSources.begin(), maServiceSources.end(), PivotServiceDataSetter());
+    std::for_each(maSelectedPagesList.begin(), maSelectedPagesList.end(), SelectedPageProcessor());
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/xml/pivotsource.hxx b/sc/source/filter/xml/pivotsource.hxx
new file mode 100644
index 0000000..c50e3972
--- /dev/null
+++ b/sc/source/filter/xml/pivotsource.hxx
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef SC_FILER_XML_PIVOTSOURCE_HXX
+#define SC_FILER_XML_PIVOTSOURCE_HXX
+
+#include <dpshttab.hxx>
+#include <dpsdbtab.hxx>
+#include <dpobject.hxx>
+
+#include <vector>
+#include <boost/unordered_map.hpp>
+
+namespace sc {
+
+/**
+ * Store pivot table data that need to be post-processeed at the end of the
+ * import.
+ */
+struct PivotTableSources
+{
+    typedef boost::unordered_map<OUString, OUString, OUStringHash> SelectedPagesType;
+    typedef boost::unordered_map<ScDPObject*, SelectedPagesType> SelectedPagesMapType;
+
+    struct SelectedPages
+    {
+        ScDPObject* mpDP;
+        SelectedPagesType maSelectedPages;
+
+        SelectedPages( ScDPObject* pObj, const SelectedPagesType& rSelected );
+    };
+
+    struct SheetSource
+    {
+        ScDPObject* mpDP;
+        ScSheetSourceDesc maDesc;
+
+        SheetSource( ScDPObject* pObj, const ScSheetSourceDesc& rDesc );
+    };
+
+    struct DBSource
+    {
+        ScDPObject* mpDP;
+        ScImportSourceDesc maDesc;
+
+        DBSource( ScDPObject* pObj, const ScImportSourceDesc& rDesc );
+    };
+
+    struct ServiceSource
+    {
+        ScDPObject* mpDP;
+        ScDPServiceDesc maDesc;
+
+        ServiceSource( ScDPObject* pObj, const ScDPServiceDesc& rDesc );
+    };
+
+    typedef std::vector<SelectedPages> SelectedPagesListType;
+
+    typedef std::vector<SheetSource>    SheetSourcesType;
+    typedef std::vector<DBSource>       DBSourcesType;
+    typedef std::vector<ServiceSource>  ServiceSourcesType;
+
+    SelectedPagesListType maSelectedPagesList;
+
+    SheetSourcesType    maSheetSources;
+    DBSourcesType       maDBSources;
+    ServiceSourcesType  maServiceSources;
+
+    PivotTableSources();
+
+    void appendSheetSource( ScDPObject* pObj, const ScSheetSourceDesc& rDesc );
+    void appendDBSource( ScDPObject* pObj, const ScImportSourceDesc& rDesc );
+    void appendServiceSource( ScDPObject* pObj, const ScDPServiceDesc& rDesc );
+
+    void appendSelectedPages( ScDPObject* pObj, const SelectedPagesType& rSelected );
+
+    void process();
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/xml/xmldpimp.cxx b/sc/source/filter/xml/xmldpimp.cxx
index 825060c..3554b68 100644
--- a/sc/source/filter/xml/xmldpimp.cxx
+++ b/sc/source/filter/xml/xmldpimp.cxx
@@ -32,6 +32,8 @@
 #include "rangeutl.hxx"
 #include "dpoutputgeometry.hxx"
 
+#include "pivotsource.hxx"
+
 #include <xmloff/xmltkmap.hxx>
 #include <xmloff/nmspmap.hxx>
 #include <xmloff/xmltoken.hxx>
@@ -477,6 +479,9 @@ void ScXMLDataPilotTableContext::EndElement()
     pDPObject->SetTag(sApplicationData);
     pDPObject->SetOutRange(aTargetRangeAddress);
     pDPObject->SetHeaderLayout(bHeaderGridLayout);
+
+    sc::PivotTableSources& rPivotSources = GetScImport().GetPivotTableSources();
+
     switch (nSourceType)
     {
         case SQL :
@@ -486,7 +491,7 @@ void ScXMLDataPilotTableContext::EndElement()
             aImportDesc.aObject = sSourceObject;
             aImportDesc.nType = sheet::DataImportMode_SQL;
             aImportDesc.bNative = bIsNative;
-            pDPObject->SetImportDesc(aImportDesc);
+            rPivotSources.appendDBSource(pDPObject, aImportDesc);
         }
         break;
         case TABLE :
@@ -495,7 +500,7 @@ void ScXMLDataPilotTableContext::EndElement()
             aImportDesc.aDBName = sDatabaseName;
             aImportDesc.aObject = sSourceObject;
             aImportDesc.nType = sheet::DataImportMode_TABLE;
-            pDPObject->SetImportDesc(aImportDesc);
+            rPivotSources.appendDBSource(pDPObject, aImportDesc);
         }
         break;
         case QUERY :
@@ -504,14 +509,14 @@ void ScXMLDataPilotTableContext::EndElement()
             aImportDesc.aDBName = sDatabaseName;
             aImportDesc.aObject = sSourceObject;
             aImportDesc.nType = sheet::DataImportMode_QUERY;
-            pDPObject->SetImportDesc(aImportDesc);
+            rPivotSources.appendDBSource(pDPObject, aImportDesc);
         }
         break;
         case SERVICE :
         {
-            ScDPServiceDesc aServiceDesk(sServiceName, sServiceSourceName, sServiceSourceObject,
+            ScDPServiceDesc aServiceDesc(sServiceName, sServiceSourceName, sServiceSourceObject,
                                 sServiceUsername, sServicePassword);
-            pDPObject->SetServiceData(aServiceDesk);
+            rPivotSources.appendServiceSource(pDPObject, aServiceDesc);
         }
         break;
         case CELLRANGE :
@@ -525,12 +530,14 @@ void ScXMLDataPilotTableContext::EndElement()
                 else
                     aSheetDesc.SetSourceRange(aSourceCellRangeAddress);
                 aSheetDesc.SetQueryParam(aSourceQueryParam);
-                pDPObject->SetSheetDesc(aSheetDesc);
+                rPivotSources.appendSheetSource(pDPObject, aSheetDesc);
             }
         }
         break;
     }
 
+    rPivotSources.appendSelectedPages(pDPObject, maSelectedPages);
+
     pDPSave->SetRowGrand(maRowGrandTotal.mbVisible);
     pDPSave->SetColumnGrand(maColGrandTotal.mbVisible);
     if (!maRowGrandTotal.maDisplayName.isEmpty())
@@ -553,36 +560,10 @@ void ScXMLDataPilotTableContext::EndElement()
     if ( pDPCollection->GetByName(pDPObject->GetName()) )
         pDPObject->SetName( String() );     // ignore the invalid name, create a new name in AfterXMLLoading
 
-    ProcessSelectedPages();
-
     pDPCollection->InsertNewTable(pDPObject);
     SetButtons();
 }
 
-void ScXMLDataPilotTableContext::ProcessSelectedPages()
-{
-    // Set selected pages after building all dimension members.
-    if (!pDPObject)
-        return;
-
-    pDPObject->BuildAllDimensionMembers();
-    ScDPSaveData* pSaveData = pDPObject->GetSaveData();
-    if (!pSaveData)
-        return;
-
-    SelectedPagesType::const_iterator it = maSelectedPages.begin(), itEnd = maSelectedPages.end();
-    for (; it != itEnd; ++it)
-    {
-        const OUString& rDimName = it->first;
-        const OUString& rSelected = it->second;
-        ScDPSaveDimension* pDim = pSaveData->GetExistingDimensionByName(rDimName);
-        if (!pDim)
-            continue;
-
-        pDim->SetCurrentPage(&rSelected);
-    }
-}
-
 void ScXMLDataPilotTableContext::SetGrandTotal(
     XMLTokenEnum eOrientation, bool bVisible, const OUString& rDisplayName)
 {
diff --git a/sc/source/filter/xml/xmldpimp.hxx b/sc/source/filter/xml/xmldpimp.hxx
index 32f878d..d5a84fa 100644
--- a/sc/source/filter/xml/xmldpimp.hxx
+++ b/sc/source/filter/xml/xmldpimp.hxx
@@ -121,8 +121,6 @@ class ScXMLDataPilotTableContext : public SvXMLImportContext
     const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
     ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
 
-    void ProcessSelectedPages();
-
 public:
 
     ScXMLDataPilotTableContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index 3378541..17d7b82 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -67,6 +67,7 @@
 #include "editutil.hxx"
 #include "editattributemap.hxx"
 #include "documentimport.hxx"
+#include "pivotsource.hxx"
 
 #include <comphelper/extract.hxx>
 
@@ -1931,6 +1932,14 @@ const SvXMLTokenMap& ScXMLImport::GetCellTextSAttrTokenMap()
     return *pCellTextSAttrTokenMap;
 }
 
+sc::PivotTableSources& ScXMLImport::GetPivotTableSources()
+{
+    if (!mpPivotSources)
+        mpPivotSources.reset(new sc::PivotTableSources);
+
+    return *mpPivotSources;
+}
+
 SvXMLImportContext *ScXMLImport::CreateContext( sal_uInt16 nPrefix,
                                                const OUString& rLocalName,
                                                const uno::Reference<xml::sax::XAttributeList>& xAttrList )
@@ -3241,6 +3250,7 @@ throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeE
             SetLabelRanges();
             SetNamedRanges();
             SetSheetNamedRanges();
+            GetPivotTableSources().process();
         }
         GetProgressBarHelper()->End();  // make room for subsequent SfxProgressBars
         if (pDoc)
diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx
index 3fb584a..832066e 100644
--- a/sc/source/filter/xml/xmlimprt.hxx
+++ b/sc/source/filter/xml/xmlimprt.hxx
@@ -55,6 +55,10 @@ class XMLNumberFormatAttributesExportHelper;
 class ScEditEngineDefaulter;
 class ScDocumentImport;
 
+namespace sc {
+    struct PivotTableSources;
+}
+
 enum ScXMLDocTokens
 {
     XML_TOK_DOC_FONTDECLS,
@@ -807,6 +811,8 @@ class ScXMLImport: public SvXMLImport, boost::noncopyable
     boost::scoped_ptr<ScDocumentImport> mpDocImport;
     boost::scoped_ptr<ScCompiler> mpComp; // For error-checking of cached string cell values.
     boost::scoped_ptr<ScEditEngineDefaulter> mpEditEngine;
+    boost::scoped_ptr<sc::PivotTableSources> mpPivotSources;
+
     mutable boost::scoped_ptr<ScXMLEditAttributeMap> mpEditAttrMap;
     ScXMLChangeTrackingImportHelper*    pChangeTrackingImportHelper;
     ScMyViewContextList                 aViewContextList;
@@ -1078,6 +1084,8 @@ public:
     const SvXMLTokenMap& GetCellTextURLAttrTokenMap();
     const SvXMLTokenMap& GetCellTextSAttrTokenMap();
 
+    sc::PivotTableSources& GetPivotTableSources();
+
     void AddNamedExpression(ScMyNamedExpression* pMyNamedExpression)
     {
         if (!pMyNamedExpressions)
commit 8a31fbdbe053f37c2d07085b25a4665e428668d0
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date:   Thu Oct 8 12:55:21 2015 +0200

    Related tdf#93688: save CalcA1|ExcelA1 also as a global option
    
    without this patch, it's only possible to save it on per-document
    basis
    
    Change-Id: I13359b751ef766c7de53e9e21c299aadbbc0fbf4

diff --git a/sc/source/core/tool/formulaopt.cxx b/sc/source/core/tool/formulaopt.cxx
index 8e5caea..244f667 100644
--- a/sc/source/core/tool/formulaopt.cxx
+++ b/sc/source/core/tool/formulaopt.cxx
@@ -327,6 +327,9 @@ ScFormulaCfg::ScFormulaCfg() :
                             case 2: // Excel R1C1
                                 eConv = formula::FormulaGrammar::CONV_XL_R1C1;
                             break;
+                            case 3: // Calc A1 | Excel A1
+                                eConv = formula::FormulaGrammar::CONV_A1_XL_A1;
+                            break;
                             default:
                                 ;
                         }
@@ -443,6 +446,7 @@ void ScFormulaCfg::Commit()
                     case ::formula::FormulaGrammar::CONV_OOO:     nVal = 0; break;
                     case ::formula::FormulaGrammar::CONV_XL_A1:   nVal = 1; break;
                     case ::formula::FormulaGrammar::CONV_XL_R1C1: nVal = 2; break;
+                    case ::formula::FormulaGrammar::CONV_A1_XL_A1: nVal = 3; break;
                     default: break;
                 }
                 pValues[nProp] <<= nVal;


More information about the Libreoffice-commits mailing list