[Libreoffice-commits] core.git: include/xmloff sc/inc sc/source xmloff/source

Markus Mohrhard markus.mohrhard at googlemail.com
Fri Apr 17 08:50:43 PDT 2015


 include/xmloff/xmltoken.hxx                 |    1 +
 sc/inc/dpsave.hxx                           |    1 +
 sc/source/core/data/dpsave.cxx              |   13 +++++++++++++
 sc/source/filter/xml/XMLExportDataPilot.cxx |   12 +++++++++++-
 sc/source/filter/xml/xmldpimp.cxx           |   11 +++++++++++
 sc/source/filter/xml/xmlimprt.cxx           |    1 +
 sc/source/filter/xml/xmlimprt.hxx           |    1 +
 xmloff/source/core/xmltoken.cxx             |    1 +
 8 files changed, 40 insertions(+), 1 deletion(-)

New commits:
commit c172b75b8ea5653246174399a530d238b1680ce0
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Apr 17 09:26:34 2015 +0200

    add attribute mandated by ODF
    
    Make sure that it does not confuse our importer by adding an attibute to
    ignore it when the new elements have been added.
    
    Change-Id: I15991be9dd993e2aeb18c440a14de3711f8001f4

diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx
index 64a0826..4ad2936 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -994,6 +994,7 @@ namespace xmloff { namespace token {
         XML_IDEOGRAPH_ALPHA,
         XML_IGNORE_CASE,
         XML_IGNORE_EMPTY_ROWS,
+        XML_IGNORE_SELECTED_PAGE, // used for ODF compatibility
         XML_ILLUSTRATION_INDEX,
         XML_ILLUSTRATION_INDEX_ENTRY_TEMPLATE,
         XML_ILLUSTRATION_INDEX_SOURCE,
diff --git a/sc/inc/dpsave.hxx b/sc/inc/dpsave.hxx
index 20d5ffb..9973b99 100644
--- a/sc/inc/dpsave.hxx
+++ b/sc/inc/dpsave.hxx
@@ -203,6 +203,7 @@ public:
     void SetLayoutInfo(const ::com::sun::star::sheet::DataPilotFieldLayoutInfo* pNew);
 
     void SetCurrentPage( const OUString* pPage ); // NULL = no selection (all)
+    OUString GetCurrentPage() const; // only for ODF compatibility
 
     sal_uInt16 GetOrientation() const
         { return nOrientation; }
diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx
index 93e9839..fc86515 100644
--- a/sc/source/core/data/dpsave.cxx
+++ b/sc/source/core/data/dpsave.cxx
@@ -509,6 +509,19 @@ void ScDPSaveDimension::SetCurrentPage( const OUString* pPage )
     }
 }
 
+OUString ScDPSaveDimension::GetCurrentPage() const
+{
+    MemberList::const_iterator it = maMemberList.begin(), itEnd = maMemberList.end();
+    for (; it != itEnd; ++it)
+    {
+        const ScDPSaveMember* pMem = *it;
+        if (pMem->GetIsVisible())
+            return pMem->GetName();
+    }
+
+    return OUString();
+}
+
 ScDPSaveMember* ScDPSaveDimension::GetExistingMemberByName(const OUString& rName)
 {
     MemberHash::const_iterator res = maMemberHash.find (rName);
diff --git a/sc/source/filter/xml/XMLExportDataPilot.cxx b/sc/source/filter/xml/XMLExportDataPilot.cxx
index 09a3390..793bec5 100644
--- a/sc/source/filter/xml/XMLExportDataPilot.cxx
+++ b/sc/source/filter/xml/XMLExportDataPilot.cxx
@@ -690,8 +690,9 @@ void ScXMLExportDataPilot::WriteDimension(ScDPSaveDimension* pDim, const ScDPDim
     if (pDim->IsDataLayout())
         rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_IS_DATA_LAYOUT_FIELD, XML_TRUE);
     OUString sValueStr;
+    sheet::DataPilotFieldOrientation eOrientation = (sheet::DataPilotFieldOrientation) pDim->GetOrientation();
     ScXMLConverter::GetStringFromOrientation( sValueStr,
-        (sheet::DataPilotFieldOrientation) pDim->GetOrientation() );
+         eOrientation);
     if( !sValueStr.isEmpty() )
         rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ORIENTATION, sValueStr );
     if (pDim->GetUsedHierarchy() != 1)
@@ -704,6 +705,15 @@ void ScXMLExportDataPilot::WriteDimension(ScDPSaveDimension* pDim, const ScDPDim
         (sheet::GeneralFunction) pDim->GetFunction() );
     rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_FUNCTION, sValueStr);
 
+    if (eOrientation == sheet::DataPilotFieldOrientation_PAGE)
+    {
+        if (rExport.getDefaultVersion() > SvtSaveOptions::ODFVER_012)
+        {
+            rExport.AddAttribute(XML_NAMESPACE_LO_EXT, XML_IGNORE_SELECTED_PAGE, "true");
+        }
+        rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_SELECTED_PAGE, pDim->GetCurrentPage());
+    }
+
     SvXMLElementExport aElemDPF(rExport, XML_NAMESPACE_TABLE, XML_DATA_PILOT_FIELD, true, true);
     WriteLevels(pDim);
     WriteFieldReference(pDim);
diff --git a/sc/source/filter/xml/xmldpimp.cxx b/sc/source/filter/xml/xmldpimp.cxx
index c080158..0ee00a0 100644
--- a/sc/source/filter/xml/xmldpimp.cxx
+++ b/sc/source/filter/xml/xmldpimp.cxx
@@ -1000,6 +1000,7 @@ ScXMLDataPilotFieldContext::ScXMLDataPilotFieldContext( ScXMLImport& rImport,
 {
     bool bHasName = false;
     bool bDataLayout = false;
+    bool bIgnoreSelectedPage = false;
     OUString aDisplayName;
     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
     const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotFieldAttrTokenMap();
@@ -1046,6 +1047,11 @@ ScXMLDataPilotFieldContext::ScXMLDataPilotFieldContext( ScXMLImport& rImport,
                 bSelectedPage = true;
             }
             break;
+            case XML_TOK_DATA_PILOT_FIELD_ATTR_IGNORE_SELECTED_PAGE:
+            {
+                bIgnoreSelectedPage = true;
+            }
+            break;
             case XML_TOK_DATA_PILOT_FIELD_ATTR_USED_HIERARCHY :
             {
                 nUsedHierarchy = sValue.toInt32();
@@ -1053,6 +1059,11 @@ ScXMLDataPilotFieldContext::ScXMLDataPilotFieldContext( ScXMLImport& rImport,
             break;
         }
     }
+
+    // use the new extension elements
+    if (bIgnoreSelectedPage)
+        bSelectedPage = false;
+
     if (bHasName)
     {
         pDim = new ScDPSaveDimension(sName, bDataLayout);
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index 72fd4fb..695f847 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -1682,6 +1682,7 @@ const SvXMLTokenMap& ScXMLImport::GetDataPilotFieldAttrTokenMap()
             { XML_NAMESPACE_TABLE,     XML_FUNCTION,             XML_TOK_DATA_PILOT_FIELD_ATTR_FUNCTION             },
             { XML_NAMESPACE_TABLE,     XML_ORIENTATION,          XML_TOK_DATA_PILOT_FIELD_ATTR_ORIENTATION          },
             { XML_NAMESPACE_TABLE,     XML_SELECTED_PAGE,        XML_TOK_DATA_PILOT_FIELD_ATTR_SELECTED_PAGE        },
+            { XML_NAMESPACE_LO_EXT,    XML_IGNORE_SELECTED_PAGE, XML_TOK_DATA_PILOT_FIELD_ATTR_IGNORE_SELECTED_PAGE },
             { XML_NAMESPACE_TABLE,     XML_USED_HIERARCHY,       XML_TOK_DATA_PILOT_FIELD_ATTR_USED_HIERARCHY       },
             XML_TOKEN_MAP_END
         };
diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx
index 53435a8..766ab01 100644
--- a/sc/source/filter/xml/xmlimprt.hxx
+++ b/sc/source/filter/xml/xmlimprt.hxx
@@ -640,6 +640,7 @@ enum ScXMLDataPilotFieldAttrTokens
     XML_TOK_DATA_PILOT_FIELD_ATTR_FUNCTION,
     XML_TOK_DATA_PILOT_FIELD_ATTR_ORIENTATION,
     XML_TOK_DATA_PILOT_FIELD_ATTR_SELECTED_PAGE,
+    XML_TOK_DATA_PILOT_FIELD_ATTR_IGNORE_SELECTED_PAGE,
     XML_TOK_DATA_PILOT_FIELD_ATTR_USED_HIERARCHY
 };
 
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index eb88687..2f7352d 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -999,6 +999,7 @@ namespace xmloff { namespace token {
         TOKEN( "ideograph-alpha",                 XML_IDEOGRAPH_ALPHA ),
         TOKEN( "ignore-case",                     XML_IGNORE_CASE ),
         TOKEN( "ignore-empty-rows",               XML_IGNORE_EMPTY_ROWS ),
+        TOKEN( "ignore-selected-page",            XML_IGNORE_SELECTED_PAGE ),
         TOKEN( "illustration-index",              XML_ILLUSTRATION_INDEX ),
         TOKEN( "illustration-index-entry-template",       XML_ILLUSTRATION_INDEX_ENTRY_TEMPLATE ),
         TOKEN( "illustration-index-source",       XML_ILLUSTRATION_INDEX_SOURCE ),


More information about the Libreoffice-commits mailing list