include/oox/core/contexthandler.hxx | 4 -- include/oox/core/contexthandler2.hxx | 8 ---- include/oox/core/xmlfilterbase.hxx | 7 +-- oox/inc/drawingml/chart/chartcontextbase.hxx | 10 ----- oox/inc/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 + 9 files changed, 53 insertions(+), 34 deletions(-)
New commits: commit 23a1717881ebfa3638b969aa4bad38a81d26d29d Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Tue Mar 10 00:59:28 2015 +0100 handle MSO 2007 vs OOXML in auto title chart import Change-Id: Id884a4c90c24b38a1dd22a41d271dcc551b59adc diff --git a/oox/inc/drawingml/chart/chartspacemodel.hxx b/oox/inc/drawingml/chart/chartspacemodel.hxx index e8ddb9c..4a98bbf 100644 --- a/oox/inc/drawingml/chart/chartspacemodel.hxx +++ b/oox/inc/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 ac12bf5..eb014ef 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 ea14c3c..7dab058 100644 --- a/oox/source/drawingml/chart/chartspacemodel.cxx +++ b/oox/source/drawingml/chart/chartspacemodel.cxx @@ -24,10 +24,10 @@ namespace oox { namespace drawingml { namespace chart { -ChartSpaceModel::ChartSpaceModel() : +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 59350e2..bea5cd2 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -1271,7 +1271,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-> commit 15174177091367332b57cd79575e2f7dd27388b2 Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Tue Mar 10 00:34:07 2015 +0100 detect MSO 2007 OOXML documents Change-Id: I4052c6f1e5dde71ce4cede1ec9a313f461861d71 diff --git a/include/oox/core/xmlfilterbase.hxx b/include/oox/core/xmlfilterbase.hxx index 9fccf1f..d522fd6 100644 --- a/include/oox/core/xmlfilterbase.hxx +++ b/include/oox/core/xmlfilterbase.hxx @@ -234,6 +234,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; diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx index 4920cc6..3eccfe9 100644 --- a/oox/source/core/xmlfilterbase.cxx +++ b/oox/source/core/xmlfilterbase.cxx @@ -206,7 +206,8 @@ XmlFilterBase::XmlFilterBase( const Reference< XComponentContext >& rxContext ) FilterBase( rxContext ), mxImpl( new XmlFilterBaseImpl( rxContext ) ), mnRelId( 1 ), - mnMaxDocId( 0 ) + mnMaxDocId( 0 ), + mbMSO2007(false) { } @@ -222,6 +223,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() { Reference< XMultiServiceFactory > xFactory( getComponentContext()->getServiceManager(), UNO_QUERY ); @@ -238,7 +268,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 @@ -880,6 +912,11 @@ StorageRef XmlFilterBase::implCreateStorage( const Reference< XStream >& rxOutSt return StorageRef( new ZipStorage( getComponentContext(), rxOutStream ) ); } +bool XmlFilterBase::isMSO2007Document() const +{ + return mbMSO2007; +} + } // namespace core } // namespace oox commit 180e1de3f6bad36b00dfe3aeba43172e5e9a735e Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Mon Mar 9 23:41:33 2015 +0100 remove whitespaces Change-Id: Ie9d303a7200cf2a6bfd8c0f5f547cfffccaa0444 diff --git a/include/oox/core/contexthandler.hxx b/include/oox/core/contexthandler.hxx index a65c17e6..3df0de5 100644 --- a/include/oox/core/contexthandler.hxx +++ b/include/oox/core/contexthandler.hxx @@ -42,8 +42,6 @@ class FragmentHandler; struct Relation; class Relations; - - class ContextHandler; typedef ::rtl::Reference< ContextHandler > ContextHandlerRef; @@ -108,8 +106,6 @@ private: FragmentBaseDataRef mxBaseData; ///< Base data of the fragment. }; - - } // namespace core } // namespace oox diff --git a/include/oox/core/contexthandler2.hxx b/include/oox/core/contexthandler2.hxx index 6e4b27d..048a2ec 100644 --- a/include/oox/core/contexthandler2.hxx +++ b/include/oox/core/contexthandler2.hxx @@ -30,12 +30,8 @@ namespace oox { namespace core { - - const sal_Int32 XML_ROOT_CONTEXT = SAL_MAX_INT32; - - struct ElementInfo; /** Helper class that provides a context stack. @@ -211,8 +207,6 @@ protected: bool mbEnableTrimSpace; ///< True = trim whitespace in characters(). }; - - class OOX_DLLPUBLIC ContextHandler2 : public ContextHandler, public ContextHandler2Helper { public: @@ -264,8 +258,6 @@ public: virtual void onEndRecord() SAL_OVERRIDE; }; - - } // namespace core } // namespace oox diff --git a/include/oox/core/xmlfilterbase.hxx b/include/oox/core/xmlfilterbase.hxx index c4e4b56..9fccf1f 100644 --- a/include/oox/core/xmlfilterbase.hxx +++ b/include/oox/core/xmlfilterbase.hxx @@ -68,8 +68,6 @@ struct TextField { }; typedef std::vector< TextField > TextFieldStack; - - struct XmlFilterBaseImpl; class OOX_DLLPUBLIC XmlFilterBase : public FilterBase @@ -255,12 +253,11 @@ private: ::std::unique_ptr< XmlFilterBaseImpl > mxImpl; sal_Int32 mnRelId; sal_Int32 mnMaxDocId; + bool mbMSO2007; }; typedef ::rtl::Reference< XmlFilterBase > XmlFilterRef; - - } // namespace core } // namespace oox diff --git a/oox/inc/drawingml/chart/chartcontextbase.hxx b/oox/inc/drawingml/chart/chartcontextbase.hxx index 9bf80ce..c160fb9 100644 --- a/oox/inc/drawingml/chart/chartcontextbase.hxx +++ b/oox/inc/drawingml/chart/chartcontextbase.hxx @@ -28,8 +28,6 @@ namespace oox { namespace drawingml { namespace chart { - - template< typename ModelType > class ContextBase : public ::oox::core::ContextHandler2 { @@ -42,8 +40,6 @@ protected: ModelType& mrModel; }; - - template< typename ModelType > class FragmentBase : public ::oox::core::FragmentHandler2 { @@ -56,8 +52,6 @@ protected: ModelType& mrModel; }; - - /** Help class for all contexts that have only the c:spPr child element. */ class ShapePrWrapperContext : public ContextBase< Shape > @@ -69,8 +63,6 @@ public: virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) SAL_OVERRIDE; }; - - struct LayoutModel; /** Handler for a chart layout context (c:layout element). @@ -84,8 +76,6 @@ public: virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) SAL_OVERRIDE; }; - - } // namespace chart } // namespace drawingml } // namespace oox diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx index 5c34ead..4920cc6 100644 --- a/oox/source/core/xmlfilterbase.cxx +++ b/oox/source/core/xmlfilterbase.cxx @@ -780,7 +780,6 @@ writeCustomProperties( XmlFilterBase& rSelf, Reference< XDocumentProperties > xP pAppProps->endElement( XML_Properties ); } - XmlFilterBase& XmlFilterBase::exportDocumentProperties( Reference< XDocumentProperties > xProperties ) { if( xProperties.is() ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits