[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.3' - 3 commits - include/oox oox/source sc/source

Markus Mohrhard markus.mohrhard at collabora.co.uk
Fri Mar 13 02:28:58 PDT 2015


 include/oox/core/xmlfilterbase.hxx                |    3 +
 include/oox/drawingml/chart/chartspacemodel.hxx   |    2 -
 oox/source/core/xmlfilterbase.cxx                 |   42 ++++++++++++++++++++--
 oox/source/drawingml/chart/chartspacefragment.cxx |    7 +++
 oox/source/drawingml/chart/chartspacemodel.cxx    |    8 +---
 oox/source/drawingml/shape.cxx                    |    3 +
 sc/source/filter/oox/excelfilter.cxx              |   24 ++++++------
 7 files changed, 66 insertions(+), 23 deletions(-)

New commits:
commit b60635df9cccd0472450d79af4f8e36bddf29ff4
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Mon Feb 23 02:19:32 2015 +0100

    import the document properties before the document
    
    That allows us to potentially change the import depending on the
    producer of the document.
    
    This becomes necessary to handle MSO 2007 chart drawingml streams
    correctly.
    
    (cherry picked from commit a2fa9e2468aa5c4fd4b610c5d0ebc8959e87a072)
    
    Conflicts:
    	sc/source/filter/oox/excelfilter.cxx
    
    Conflicts:
    	sc/source/filter/oox/excelfilter.cxx
    
    Change-Id: I9be8b019fae69cd206203591982a89648965692f

diff --git a/sc/source/filter/oox/excelfilter.cxx b/sc/source/filter/oox/excelfilter.cxx
index 3da6f1c..ee4bfa2 100644
--- a/sc/source/filter/oox/excelfilter.cxx
+++ b/sc/source/filter/oox/excelfilter.cxx
@@ -99,19 +99,8 @@ bool ExcelFilter::importDocument() throw()
     if( aWorkbookPath.isEmpty() )
         return false;
 
-    /*  Construct the WorkbookGlobals object referred to by every instance of
-        the class WorkbookHelper, and execute the import filter by constructing
-        an instance of WorkbookFragment and loading the file. */
-    WorkbookGlobalsRef xBookGlob;
     try
     {
-        xBookGlob = WorkbookHelper::constructGlobals( *this );
-    }
-    catch (...)
-    {
-    }
-    if ( xBookGlob.get() && importFragment( new WorkbookFragment( *xBookGlob, aWorkbookPath ) ) )
-    {
         try
         {
             importDocumentProperties();
@@ -124,8 +113,19 @@ bool ExcelFilter::importDocument() throw()
         {
             SAL_WARN("sc", "exception when importing document properties");
         }
-        return true;
+        /*  Construct the WorkbookGlobals object referred to by every instance of
+            the class WorkbookHelper, and execute the import filter by constructing
+            an instance of WorkbookFragment and loading the file. */
+        WorkbookGlobalsRef xBookGlob(WorkbookHelper::constructGlobals(*this));
+        if (xBookGlob.get() && importFragment(new WorkbookFragment(*xBookGlob, aWorkbookPath)))
+        {
+            return true;
+        }
+    }
+    catch (...)
+    {
     }
+
     return false;
 }
 
commit c9bae5c5f0b9219391e604a1d61126ea3d2c943c
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Tue Mar 10 00:34:07 2015 +0100

    detect MSO 2007 OOXML documents
    
    (cherry picked from commit 15174177091367332b57cd79575e2f7dd27388b2)
    
    Conflicts:
    	oox/source/core/xmlfilterbase.cxx
    
    Conflicts:
    	oox/source/core/xmlfilterbase.cxx
    
    Change-Id: I4052c6f1e5dde71ce4cede1ec9a313f461861d71

diff --git a/include/oox/core/xmlfilterbase.hxx b/include/oox/core/xmlfilterbase.hxx
index a26bad8..3d12fc4 100644
--- a/include/oox/core/xmlfilterbase.hxx
+++ b/include/oox/core/xmlfilterbase.hxx
@@ -233,6 +233,8 @@ public:
 
     FastParser* createParser() const;
 
+    bool isMSO2007Document() const;
+
 protected:
     virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >
         implGetInputStream( utl::MediaDescriptor& rMediaDesc ) const SAL_OVERRIDE;
@@ -252,6 +254,7 @@ private:
     ::std::auto_ptr< XmlFilterBaseImpl > mxImpl;
     sal_Int32 mnRelId;
     sal_Int32 mnMaxDocId;
+    bool mbMSO2007;
 };
 
 typedef ::rtl::Reference< XmlFilterBase > XmlFilterRef;
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx
index 3b807df..ddc4507 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -21,6 +21,7 @@
 
 #include <cstdio>
 #include <set>
+#include <com/sun/star/beans/XPropertyAccess.hpp>
 #include <com/sun/star/container/XNameContainer.hpp>
 #include <com/sun/star/embed/XRelationshipAccess.hpp>
 #include <com/sun/star/xml/sax/InputSource.hpp>
@@ -200,7 +201,8 @@ XmlFilterBase::XmlFilterBase( const Reference< XComponentContext >& rxContext )
     FilterBase( rxContext ),
     mxImpl( new XmlFilterBaseImpl( rxContext ) ),
     mnRelId( 1 ),
-    mnMaxDocId( 0 )
+    mnMaxDocId( 0 ),
+    mbMSO2007(false)
 {
 }
 
@@ -216,6 +218,35 @@ XmlFilterBase::~XmlFilterBase()
     mxImpl->maFastParser.setDocumentHandler( 0 );
 }
 
+namespace {
+
+bool is2007MSODocument(Reference<XDocumentProperties> xDocProps)
+{
+    if (!xDocProps->getGenerator().startsWithIgnoreAsciiCase("Microsoft"))
+        return false;
+
+    uno::Reference<beans::XPropertyAccess> xUserDefProps(xDocProps->getUserDefinedProperties(), uno::UNO_QUERY);
+    if (!xUserDefProps.is())
+        return false;
+
+    comphelper::SequenceAsHashMap aUserDefinedProperties(xUserDefProps->getPropertyValues());
+    comphelper::SequenceAsHashMap::iterator it = aUserDefinedProperties.find("AppVersion");
+    if (it == aUserDefinedProperties.end())
+        return false;
+
+    OUString aValue;
+    if (!(it->second >>= aValue))
+        return false;
+
+    if (!aValue.startsWithIgnoreAsciiCase("12."))
+        return false;
+
+    SAL_WARN("oox", "a MSO 2007 document");
+    return true;
+}
+
+}
+
 
 
 void XmlFilterBase::importDocumentProperties()
@@ -234,7 +265,9 @@ void XmlFilterBase::importDocumentProperties()
             xContext);
     Reference< XOOXMLDocumentPropertiesImporter > xImporter( xTemp, UNO_QUERY );
     Reference< XDocumentPropertiesSupplier > xPropSupplier( xModel, UNO_QUERY);
-    xImporter->importProperties( xDocumentStorage, xPropSupplier->getDocumentProperties() );
+    Reference< XDocumentProperties > xDocProps = xPropSupplier->getDocumentProperties();
+    xImporter->importProperties( xDocumentStorage, xDocProps );
+    mbMSO2007 = is2007MSODocument(xDocProps);
 }
 
 FastParser* XmlFilterBase::createParser() const
@@ -785,7 +818,10 @@ StorageRef XmlFilterBase::implCreateStorage( const Reference< XStream >& rxOutSt
     return StorageRef( new ZipStorage( getComponentContext(), rxOutStream ) );
 }
 
-
+bool XmlFilterBase::isMSO2007Document() const
+{
+    return mbMSO2007;
+}
 
 } // namespace core
 } // namespace oox
commit afe0a7ec1f0a3841c96148f17c9616b861c08582
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Thu Mar 12 15:19:37 2015 +0100

    handle MSO 2007 vs OOXML in auto title chart import
    
    Conflicts:
    	oox/source/drawingml/chart/chartspacefragment.cxx
    	oox/source/drawingml/chart/chartspacemodel.cxx
    
    Change-Id: Ie143751d22404dac8f31c8ecef90a0e185e07973

diff --git a/include/oox/drawingml/chart/chartspacemodel.hxx b/include/oox/drawingml/chart/chartspacemodel.hxx
index cc9015d..1a44943 100644
--- a/include/oox/drawingml/chart/chartspacemodel.hxx
+++ b/include/oox/drawingml/chart/chartspacemodel.hxx
@@ -58,7 +58,7 @@ struct ChartSpaceModel
     bool                mbShowLabelsOverMax;/// True = show labels over chart maximum.
     bool                mbPivotChart;       /// True = pivot chart.
 
-    explicit            ChartSpaceModel();
+    explicit            ChartSpaceModel(bool bMSO2007Doc);
                         ~ChartSpaceModel();
 };
 
diff --git a/oox/source/drawingml/chart/chartspacefragment.cxx b/oox/source/drawingml/chart/chartspacefragment.cxx
index eec0f1c..4818bad 100644
--- a/oox/source/drawingml/chart/chartspacefragment.cxx
+++ b/oox/source/drawingml/chart/chartspacefragment.cxx
@@ -85,8 +85,13 @@ ContextHandlerRef ChartSpaceFragment::onCreateContext( sal_Int32 nElement, const
             switch( nElement )
             {
                 case C_TOKEN( autoTitleDeleted ):
-                    mrModel.mbAutoTitleDel = rAttribs.getBool( XML_val, true );
+                {
+                    bool bMSO2007Document = getFilter().isMSO2007Document();
+
+                    // default value is false for MSO 2007 and true in OOXML
+                    mrModel.mbAutoTitleDel = rAttribs.getBool( XML_val, !bMSO2007Document );
                     return 0;
+                }
                 case C_TOKEN( backWall ):
                     return new WallFloorContext( *this, mrModel.mxBackWall.create() );
                 case C_TOKEN( dispBlanksAs ):
diff --git a/oox/source/drawingml/chart/chartspacemodel.cxx b/oox/source/drawingml/chart/chartspacemodel.cxx
index d6e920d..b76a55c 100644
--- a/oox/source/drawingml/chart/chartspacemodel.cxx
+++ b/oox/source/drawingml/chart/chartspacemodel.cxx
@@ -23,12 +23,10 @@ namespace oox {
 namespace drawingml {
 namespace chart {
 
-
-
-ChartSpaceModel::ChartSpaceModel() :
-    mnDispBlanksAs( XML_gap ),  // not zero as specified
+ChartSpaceModel::ChartSpaceModel(bool bMSO2007Doc) :
+    mnDispBlanksAs( XML_gap ),  // not zero as specified, TODO: OOXML_spec
     mnStyle( 2 ),
-    mbAutoTitleDel( true ),
+    mbAutoTitleDel( !bMSO2007Doc ), // difference between OOXML spec and MSO 2007
     mbPlotVisOnly( false ),
     mbShowLabelsOverMax( false ),
     mbPivotChart( false )
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index ef0feb7..05bff1a 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -1249,7 +1249,8 @@ void Shape::finalizeXShape( XmlFilterBase& rFilter, const Reference< XShapes >&
                 Reference< chart2::XChartDocument > xChartDoc( xDocModel, UNO_QUERY_THROW );
 
                 // load the chart data from the XML fragment
-                chart::ChartSpaceModel aModel;
+                bool bMSO2007Doc = rFilter.isMSO2007Document();
+                chart::ChartSpaceModel aModel(bMSO2007Doc);
                 chart::ChartSpaceFragment *pChartSpaceFragment = new chart::ChartSpaceFragment(
                         rFilter, mxChartShapeInfo->maFragmentPath, aModel );
                 const OUString aThemeOverrideFragmentPath( pChartSpaceFragment->


More information about the Libreoffice-commits mailing list