diff options
author | Markus Mohrhard <markus.mohrhard@collabora.co.uk> | 2015-03-10 00:34:07 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2015-03-12 16:55:58 +0100 |
commit | 648d3022bd77e66fdf3fe42132b6dc207c5a2804 (patch) | |
tree | 87d835f3aa68f1dc7af0b1b02f9700b2d504c270 /oox/source/core/xmlfilterbase.cxx | |
parent | ca698a076f017a73c8c6f27f57139b3e350f0f6b (diff) |
detect MSO 2007 OOXML documents
(cherry picked from commit 15174177091367332b57cd79575e2f7dd27388b2)
Conflicts:
oox/source/core/xmlfilterbase.cxx
Change-Id: I4052c6f1e5dde71ce4cede1ec9a313f461861d71
Diffstat (limited to 'oox/source/core/xmlfilterbase.cxx')
-rw-r--r-- | oox/source/core/xmlfilterbase.cxx | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx index 1608aed57888..70d01d567dd5 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 |