diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2015-04-19 02:59:39 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2015-04-19 03:03:24 +0200 |
commit | 914b4fb5a3c159bfd7cd8be2639185144f11d7ed (patch) | |
tree | 26963139e7ad1e2b10aaf11005b8bbe093c497b1 | |
parent | 6f969d256fdbbc0b93d7baeec089afbbea94fc0e (diff) |
import chart MSO 2007 streams correctly for docx files, tdf#82216
Change-Id: Icda809faf315dac5953d38781b2b401d51f7a40a
-rw-r--r-- | include/oox/core/xmlfilterbase.hxx | 3 | ||||
-rw-r--r-- | offapi/com/sun/star/xml/sax/XFastShapeContextHandler.idl | 2 | ||||
-rw-r--r-- | oox/source/core/xmlfilterbase.cxx | 21 | ||||
-rw-r--r-- | oox/source/shape/ShapeContextHandler.cxx | 13 | ||||
-rw-r--r-- | oox/source/shape/ShapeContextHandler.hxx | 7 | ||||
-rw-r--r-- | writerfilter/source/ooxml/OOXMLFastContextHandler.cxx | 2 |
6 files changed, 36 insertions, 12 deletions
diff --git a/include/oox/core/xmlfilterbase.hxx b/include/oox/core/xmlfilterbase.hxx index d522fd66951e..9a8203ebe9d4 100644 --- a/include/oox/core/xmlfilterbase.hxx +++ b/include/oox/core/xmlfilterbase.hxx @@ -236,6 +236,9 @@ public: bool isMSO2007Document() const; + void checkDocumentProperties( + com::sun::star::uno::Reference<com::sun::star::document::XDocumentProperties> xDocProps); + protected: virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > implGetInputStream( utl::MediaDescriptor& rMediaDesc ) const SAL_OVERRIDE; diff --git a/offapi/com/sun/star/xml/sax/XFastShapeContextHandler.idl b/offapi/com/sun/star/xml/sax/XFastShapeContextHandler.idl index de141555a90e..a15ae8d3b58a 100644 --- a/offapi/com/sun/star/xml/sax/XFastShapeContextHandler.idl +++ b/offapi/com/sun/star/xml/sax/XFastShapeContextHandler.idl @@ -24,6 +24,7 @@ #include <com/sun/star/drawing/XDrawPage.idl> #include <com/sun/star/frame/XModel.idl> #include <com/sun/star/io/XInputStream.idl> +#include <com/sun/star/document/XDocumentProperties.idl> module com { module sun { module star { module xml { module sax { @@ -43,6 +44,7 @@ interface XFastShapeContextHandler: com::sun::star::xml::sax::XFastContextHandle [attribute] string RelationFragmentPath; [attribute] long StartToken; [attribute] com::sun::star::awt::Point Position; + [attribute] com::sun::star::document::XDocumentProperties DocumentProperties; }; diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx index 5597a5865cf5..4ff011aa9161 100644 --- a/oox/source/core/xmlfilterbase.cxx +++ b/oox/source/core/xmlfilterbase.cxx @@ -223,33 +223,30 @@ XmlFilterBase::~XmlFilterBase() mxImpl->maFastParser.setDocumentHandler( 0 ); } -namespace { - -bool is2007MSODocument(Reference<XDocumentProperties> xDocProps) +void XmlFilterBase::checkDocumentProperties(Reference<XDocumentProperties> xDocProps) { + mbMSO2007 = false; if (!xDocProps->getGenerator().startsWithIgnoreAsciiCase("Microsoft")) - return false; + return; uno::Reference<beans::XPropertyAccess> xUserDefProps(xDocProps->getUserDefinedProperties(), uno::UNO_QUERY); if (!xUserDefProps.is()) - return false; + return; comphelper::SequenceAsHashMap aUserDefinedProperties(xUserDefProps->getPropertyValues()); comphelper::SequenceAsHashMap::iterator it = aUserDefinedProperties.find("AppVersion"); if (it == aUserDefinedProperties.end()) - return false; + return; OUString aValue; if (!(it->second >>= aValue)) - return false; + return; if (!aValue.startsWithIgnoreAsciiCase("12.")) - return false; + return; SAL_WARN("oox", "a MSO 2007 document"); - return true; -} - + mbMSO2007 = true; } void XmlFilterBase::importDocumentProperties() @@ -270,7 +267,7 @@ void XmlFilterBase::importDocumentProperties() Reference< XDocumentPropertiesSupplier > xPropSupplier( xModel, UNO_QUERY); Reference< XDocumentProperties > xDocProps = xPropSupplier->getDocumentProperties(); xImporter->importProperties( xDocumentStorage, xDocProps ); - mbMSO2007 = is2007MSODocument(xDocProps); + checkDocumentProperties(xDocProps); } FastParser* XmlFilterBase::createParser() const diff --git a/oox/source/shape/ShapeContextHandler.cxx b/oox/source/shape/ShapeContextHandler.cxx index e4910ad037d0..39cc970f0be1 100644 --- a/oox/source/shape/ShapeContextHandler.cxx +++ b/oox/source/shape/ShapeContextHandler.cxx @@ -620,6 +620,19 @@ void SAL_CALL ShapeContextHandler::setPosition(const awt::Point& rPosition) thro maPosition = rPosition; } +void SAL_CALL ShapeContextHandler::setDocumentProperties(const uno::Reference<document::XDocumentProperties>& xDocProps) + throw (css::uno::RuntimeException, std::exception) +{ + mxDocumentProperties = xDocProps; + mxFilterBase->checkDocumentProperties(mxDocumentProperties); +} + +uno::Reference<document::XDocumentProperties> SAL_CALL ShapeContextHandler::getDocumentProperties() + throw (css::uno::RuntimeException, std::exception) +{ + return mxDocumentProperties; +} + OUString ShapeContextHandler::getImplementationName() throw (css::uno::RuntimeException, std::exception) { diff --git a/oox/source/shape/ShapeContextHandler.hxx b/oox/source/shape/ShapeContextHandler.hxx index 7697e2a6c4a8..ad57ad933416 100644 --- a/oox/source/shape/ShapeContextHandler.hxx +++ b/oox/source/shape/ShapeContextHandler.hxx @@ -30,6 +30,7 @@ #include "oox/core/xmlfilterbase.hxx" #include "ShapeFilterBase.hxx" #include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/document/XDocumentProperties.hpp> namespace oox { namespace shape { @@ -138,6 +139,11 @@ public: virtual css::awt::Point SAL_CALL getPosition() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE; virtual void SAL_CALL setPosition(const css::awt::Point& rPosition) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL setDocumentProperties(const css::uno::Reference<css::document::XDocumentProperties>& xDocProps) + throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual css::uno::Reference<css::document::XDocumentProperties> SAL_CALL getDocumentProperties() + throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + private: ShapeContextHandler(ShapeContextHandler &) SAL_DELETED_FUNCTION; void operator =(ShapeContextHandler &) SAL_DELETED_FUNCTION; @@ -159,6 +165,7 @@ private: css::uno::Reference<css::drawing::XShape> mxSavedShape; css::uno::Reference<XFastContextHandler> mxWpgContext; css::uno::Reference<XFastContextHandler> mxChartShapeContext; + css::uno::Reference<css::document::XDocumentProperties> mxDocumentProperties; core::XmlFilterRef mxFilterBase; drawingml::ThemePtr mpThemePtr; diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx index 85c5f1bad1b1..dc18eaee885c 100644 --- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx +++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx @@ -1532,6 +1532,8 @@ OOXMLFastContextHandlerShape::OOXMLFastContextHandlerShape } mrShapeContext->setModel(getDocument()->getModel()); + uno::Reference<document::XDocumentPropertiesSupplier> xDocSupplier(getDocument()->getModel(), uno::UNO_QUERY_THROW); + mrShapeContext->setDocumentProperties(xDocSupplier->getDocumentProperties()); mrShapeContext->setDrawPage(getDocument()->getDrawPage()); mrShapeContext->setInputStream(getDocument()->getStorageStream()); |