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 | 4 +- oox/source/drawingml/shape.cxx | 3 + sc/source/filter/oox/excelfilter.cxx | 23 ++++++++---- 7 files changed, 70 insertions(+), 14 deletions(-)
New commits: commit e4c6dcef807d24be29975d8fa1ad0ca435e914c5 Author: Markus Mohrhard <markus.mohrh...@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 Change-Id: I9be8b019fae69cd206203591982a89648965692f diff --git a/sc/source/filter/oox/excelfilter.cxx b/sc/source/filter/oox/excelfilter.cxx index 6c2d6bd..8495767 100644 --- a/sc/source/filter/oox/excelfilter.cxx +++ b/sc/source/filter/oox/excelfilter.cxx @@ -105,11 +105,7 @@ 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 = WorkbookHelper::constructGlobals( *this ); - if ( xBookGlob.get() && importFragment( new WorkbookFragment( *xBookGlob, aWorkbookPath ) ) ) + try { try { @@ -119,8 +115,23 @@ bool ExcelFilter::importDocument() throw() { SAL_WARN("sc", "exception when importing document properties " << e.Message); } - return true; + catch( ... ) + { + SAL_WARN("sc", "exception when importing document properties"); + } + /* 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 648d3022bd77e66fdf3fe42132b6dc207c5a2804 Author: Markus Mohrhard <markus.mohrh...@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 Change-Id: I4052c6f1e5dde71ce4cede1ec9a313f461861d71 diff --git a/include/oox/core/xmlfilterbase.hxx b/include/oox/core/xmlfilterbase.hxx index 351910d..da0a400 100644 --- a/include/oox/core/xmlfilterbase.hxx +++ b/include/oox/core/xmlfilterbase.hxx @@ -237,6 +237,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; @@ -256,6 +258,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 1608aed..70d01d5 100644 --- a/oox/source/core/xmlfilterbase.cxx +++ b/oox/source/core/xmlfilterbase.cxx @@ -20,6 +20,7 @@ #include "oox/core/xmlfilterbase.hxx" #include <cstdio> +#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> @@ -188,7 +189,8 @@ XmlFilterBase::XmlFilterBase( const Reference< XComponentContext >& rxContext ) FilterBase( rxContext ), mxImpl( new XmlFilterBaseImpl( rxContext ) ), mnRelId( 1 ), - mnMaxDocId( 0 ) + mnMaxDocId( 0 ), + mbMSO2007(false) { } @@ -204,6 +206,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() @@ -222,7 +253,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 @@ -779,7 +812,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 ca698a076f017a73c8c6f27f57139b3e350f0f6b Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Thu Mar 12 15:19:37 2015 +0100 handle MSO 2007 vs OOXML in auto title chart import Change-Id: Ie143751d22404dac8f31c8ecef90a0e185e07973 diff --git a/include/oox/drawingml/chart/chartspacemodel.hxx b/include/oox/drawingml/chart/chartspacemodel.hxx index f1a27d8..c2e3cab 100644 --- a/include/oox/drawingml/chart/chartspacemodel.hxx +++ b/include/oox/drawingml/chart/chartspacemodel.hxx @@ -57,7 +57,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 9917588..8df7f3b 100644 --- a/oox/source/drawingml/chart/chartspacefragment.cxx +++ b/oox/source/drawingml/chart/chartspacefragment.cxx @@ -81,8 +81,13 @@ ContextHandlerRef ChartSpaceFragment::onCreateContext( sal_Int32 nElement, const switch( nElement ) { case C_TOKEN( autoTitleDeleted ): - mrModel.mbAutoTitleDel = rAttribs.getBool( XML_val, true ); // TODO: OOXML_spec + { + 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 d36a2f2..da86a4b 100644 --- a/oox/source/drawingml/chart/chartspacemodel.cxx +++ b/oox/source/drawingml/chart/chartspacemodel.cxx @@ -25,10 +25,10 @@ namespace chart { // ============================================================================ -ChartSpaceModel::ChartSpaceModel() : +ChartSpaceModel::ChartSpaceModel(bool bMSO2007Doc) : mnDispBlanksAs( XML_gap ), // not zero as specified, TODO: OOXML_spec mnStyle( 2 ), - mbAutoTitleDel( false ), + 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 8710435..e3f324e 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -869,7 +869,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-> _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits