[Libreoffice-commits] .: Branch 'feature/dp-named-range-source' - 2 commits - sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Fri Jan 21 19:19:25 PST 2011


 sc/source/filter/xml/xmldpimp.cxx |  155 +++++++++++++++++++-------------------
 sc/source/filter/xml/xmldpimp.hxx |    2 
 sc/source/filter/xml/xmlimprt.cxx |    3 
 sc/source/filter/xml/xmlimprt.hxx |    3 
 4 files changed, 87 insertions(+), 76 deletions(-)

New commits:
commit 6a7304ee5777b404f0de160d9c29d0aa9564a3b6
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Fri Jan 21 22:19:00 2011 -0500

    Import source range name properly from ods document.

diff --git a/sc/source/filter/xml/xmldpimp.cxx b/sc/source/filter/xml/xmldpimp.cxx
index d28a82d..dc644dc 100644
--- a/sc/source/filter/xml/xmldpimp.cxx
+++ b/sc/source/filter/xml/xmldpimp.cxx
@@ -447,7 +447,11 @@ void ScXMLDataPilotTableContext::EndElement()
             if (bSourceCellRange)
             {
                 ScSheetSourceDesc aSheetDesc(pDoc);
-                aSheetDesc.SetSourceRange(aSourceCellRangeAddress);
+                if (sSourceRangeName.getLength())
+                    // Range name takes precedence.
+                    aSheetDesc.SetRangeName(sSourceRangeName);
+                else
+                    aSheetDesc.SetSourceRange(aSourceCellRangeAddress);
                 aSheetDesc.SetQueryParam(aSourceQueryParam);
                 pDPObject->SetSheetDesc(aSheetDesc);
             }
@@ -856,6 +860,9 @@ ScXMLSourceCellRangeContext::ScXMLSourceCellRangeContext( ScXMLImport& rImport,
                     pDataPilotTable->SetSourceCellRangeAddress(aSourceRangeAddress);
             }
             break;
+            case XML_TOK_SOURCE_CELL_RANGE_ATTR_NAME:
+                pDataPilotTable->SetSourceRangeName(sValue);
+            break;
         }
     }
 }
diff --git a/sc/source/filter/xml/xmldpimp.hxx b/sc/source/filter/xml/xmldpimp.hxx
index 1e9ac07..311c82e 100644
--- a/sc/source/filter/xml/xmldpimp.hxx
+++ b/sc/source/filter/xml/xmldpimp.hxx
@@ -106,6 +106,7 @@ class ScXMLDataPilotTableContext : public SvXMLImportContext
     rtl::OUString	sServiceUsername;
     rtl::OUString	sServicePassword;
     rtl::OUString	sButtons;
+    rtl::OUString   sSourceRangeName;
     ScRange			aSourceCellRangeAddress;
     ScRange			aTargetRangeAddress;
     ScRange			aFilterSourceRange;
@@ -157,6 +158,7 @@ public:
     void SetServiceSourceObject(const rtl::OUString& sValue) { sServiceSourceObject = sValue; }
     void SetServiceUsername(const rtl::OUString& sValue) { sServiceUsername = sValue; }
     void SetServicePassword(const rtl::OUString& sValue) { sServicePassword = sValue; }
+    void SetSourceRangeName(const rtl::OUString& sValue) { sSourceRangeName = sValue; bSourceCellRange = true; }
     void SetSourceCellRangeAddress(const ScRange& aValue) { aSourceCellRangeAddress = aValue; bSourceCellRange = sal_True; }
     void SetSourceQueryParam(const ScQueryParam& aValue) { aSourceQueryParam = aValue; }
 //	void SetFilterUseRegularExpressions(const sal_Bool bValue) { aSourceQueryParam.bRegExp = bValue; }
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index fb39fbe..27d661b 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -1430,7 +1430,8 @@ const SvXMLTokenMap& ScXMLImport::GetDataPilotTableSourceCellRangeAttrTokenMap()
     {
         static SvXMLTokenMapEntry aDataPilotTableSourceCellRangeAttrTokenMap[] =
         {
-            { XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS,		XML_TOK_SOURCE_CELL_RANGE_ATTR_CELL_RANGE_ADDRESS},
+            { XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, XML_TOK_SOURCE_CELL_RANGE_ATTR_CELL_RANGE_ADDRESS },
+            { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_SOURCE_CELL_RANGE_ATTR_NAME },
             XML_TOKEN_MAP_END
         };
 
diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx
index 1ec6ef5..6a53601 100644
--- a/sc/source/filter/xml/xmlimprt.hxx
+++ b/sc/source/filter/xml/xmlimprt.hxx
@@ -530,7 +530,8 @@ enum ScXMLDataPilotTableSourceCellRangeElemTokens
 
 enum ScXMLDataPilotTableSourceCellRangeAttrTokens
 {
-    XML_TOK_SOURCE_CELL_RANGE_ATTR_CELL_RANGE_ADDRESS
+    XML_TOK_SOURCE_CELL_RANGE_ATTR_CELL_RANGE_ADDRESS,
+    XML_TOK_SOURCE_CELL_RANGE_ATTR_NAME
 };
 
 enum ScXMLDataPilotFieldAttrTokens
commit cbaf9eb3d076e9e7b3c42d398ad429e06535e177
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Fri Jan 21 21:57:16 2011 -0500

    Reduced indent levels again.

diff --git a/sc/source/filter/xml/xmldpimp.cxx b/sc/source/filter/xml/xmldpimp.cxx
index 09659e0..d28a82d 100644
--- a/sc/source/filter/xml/xmldpimp.cxx
+++ b/sc/source/filter/xml/xmldpimp.cxx
@@ -398,90 +398,90 @@ void ScXMLDataPilotTableContext::AddGroupDim(const ScDPSaveGroupDimension& aGrou
 
 void ScXMLDataPilotTableContext::EndElement()
 {
-    if (bTargetRangeAddress)
+    if (!bTargetRangeAddress)
+        return;
+
+    pDPObject->SetName(sDataPilotTableName);
+    pDPObject->SetTag(sApplicationData);
+    pDPObject->SetOutRange(aTargetRangeAddress);
+    pDPObject->SetHeaderLayout(bHeaderGridLayout);
+    switch (nSourceType)
     {
-        pDPObject->SetName(sDataPilotTableName);
-        pDPObject->SetTag(sApplicationData);
-        pDPObject->SetOutRange(aTargetRangeAddress);
-        pDPObject->SetHeaderLayout(bHeaderGridLayout);
-        switch (nSourceType)
+        case SQL :
         {
-            case SQL :
-            {
-                ScImportSourceDesc aImportDesc;
-                aImportDesc.aDBName = sDatabaseName;
-                aImportDesc.aObject = sSourceObject;
-                aImportDesc.nType = sheet::DataImportMode_SQL;
-                aImportDesc.bNative = bIsNative;
-                pDPObject->SetImportDesc(aImportDesc);
-            }
-            break;
-            case TABLE :
-            {
-                ScImportSourceDesc aImportDesc;
-                aImportDesc.aDBName = sDatabaseName;
-                aImportDesc.aObject = sSourceObject;
-                aImportDesc.nType = sheet::DataImportMode_TABLE;
-                pDPObject->SetImportDesc(aImportDesc);
-            }
-            break;
-            case QUERY :
-            {
-                ScImportSourceDesc aImportDesc;
-                aImportDesc.aDBName = sDatabaseName;
-                aImportDesc.aObject = sSourceObject;
-                aImportDesc.nType = sheet::DataImportMode_QUERY;
-                pDPObject->SetImportDesc(aImportDesc);
-            }
-            break;
-            case SERVICE :
-            {
-                ScDPServiceDesc aServiceDesk(sServiceName, sServiceSourceName, sServiceSourceObject,
-                                    sServiceUsername, sServicePassword);
-                pDPObject->SetServiceData(aServiceDesk);
-            }
-            break;
-            case CELLRANGE :
+            ScImportSourceDesc aImportDesc;
+            aImportDesc.aDBName = sDatabaseName;
+            aImportDesc.aObject = sSourceObject;
+            aImportDesc.nType = sheet::DataImportMode_SQL;
+            aImportDesc.bNative = bIsNative;
+            pDPObject->SetImportDesc(aImportDesc);
+        }
+        break;
+        case TABLE :
+        {
+            ScImportSourceDesc aImportDesc;
+            aImportDesc.aDBName = sDatabaseName;
+            aImportDesc.aObject = sSourceObject;
+            aImportDesc.nType = sheet::DataImportMode_TABLE;
+            pDPObject->SetImportDesc(aImportDesc);
+        }
+        break;
+        case QUERY :
+        {
+            ScImportSourceDesc aImportDesc;
+            aImportDesc.aDBName = sDatabaseName;
+            aImportDesc.aObject = sSourceObject;
+            aImportDesc.nType = sheet::DataImportMode_QUERY;
+            pDPObject->SetImportDesc(aImportDesc);
+        }
+        break;
+        case SERVICE :
+        {
+            ScDPServiceDesc aServiceDesk(sServiceName, sServiceSourceName, sServiceSourceObject,
+                                sServiceUsername, sServicePassword);
+            pDPObject->SetServiceData(aServiceDesk);
+        }
+        break;
+        case CELLRANGE :
+        {
+            if (bSourceCellRange)
             {
-                if (bSourceCellRange)
-                {
-                    ScSheetSourceDesc aSheetDesc(pDoc);
-                    aSheetDesc.SetSourceRange(aSourceCellRangeAddress);
-                    aSheetDesc.SetQueryParam(aSourceQueryParam);
-                    pDPObject->SetSheetDesc(aSheetDesc);
-                }
+                ScSheetSourceDesc aSheetDesc(pDoc);
+                aSheetDesc.SetSourceRange(aSourceCellRangeAddress);
+                aSheetDesc.SetQueryParam(aSourceQueryParam);
+                pDPObject->SetSheetDesc(aSheetDesc);
             }
-            break;
         }
+        break;
+    }
 
-        pDPSave->SetRowGrand(maRowGrandTotal.mbVisible);
-        pDPSave->SetColumnGrand(maColGrandTotal.mbVisible);
-        if (maRowGrandTotal.maDisplayName.getLength())
-            // TODO: Right now, we only support one grand total name for both 
-            // column and row totals.  Take the value from the row total for
-            // now.
-            pDPSave->SetGrandTotalName(maRowGrandTotal.maDisplayName);
-
-        pDPSave->SetIgnoreEmptyRows(bIgnoreEmptyRows);
-        pDPSave->SetRepeatIfEmpty(bIdentifyCategories);
-        pDPSave->SetFilterButton(bShowFilter);
-        pDPSave->SetDrillDown(bDrillDown);
-        if (pDPDimSaveData)
-            pDPSave->SetDimensionData(pDPDimSaveData);
-        pDPObject->SetSaveData(*pDPSave);
-        if (pDoc)
-        {
-            ScDPCollection* pDPCollection = pDoc->GetDPCollection();
+    pDPSave->SetRowGrand(maRowGrandTotal.mbVisible);
+    pDPSave->SetColumnGrand(maColGrandTotal.mbVisible);
+    if (maRowGrandTotal.maDisplayName.getLength())
+        // TODO: Right now, we only support one grand total name for both
+        // column and row totals.  Take the value from the row total for
+        // now.
+        pDPSave->SetGrandTotalName(maRowGrandTotal.maDisplayName);
+
+    pDPSave->SetIgnoreEmptyRows(bIgnoreEmptyRows);
+    pDPSave->SetRepeatIfEmpty(bIdentifyCategories);
+    pDPSave->SetFilterButton(bShowFilter);
+    pDPSave->SetDrillDown(bDrillDown);
+    if (pDPDimSaveData)
+        pDPSave->SetDimensionData(pDPDimSaveData);
+    pDPObject->SetSaveData(*pDPSave);
+    if (pDoc)
+    {
+        ScDPCollection* pDPCollection = pDoc->GetDPCollection();
 
-            // #i94570# Names have to be unique, or the tables can't be accessed by API.
-            if ( pDPCollection->GetByName(pDPObject->GetName()) )
-                pDPObject->SetName( String() );     // ignore the invalid name, create a new name in AfterXMLLoading
+        // #i94570# Names have to be unique, or the tables can't be accessed by API.
+        if ( pDPCollection->GetByName(pDPObject->GetName()) )
+            pDPObject->SetName( String() );     // ignore the invalid name, create a new name in AfterXMLLoading
 
-            pDPObject->SetAlive(sal_True);
-            pDPCollection->InsertNewTable(pDPObject);
-        }
-        SetButtons();
+        pDPObject->SetAlive(sal_True);
+        pDPCollection->InsertNewTable(pDPObject);
     }
+    SetButtons();
 }
 
 void ScXMLDataPilotTableContext::SetGrandTotal(


More information about the Libreoffice-commits mailing list