summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2015-03-10 00:34:07 +0100
committerMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2015-03-10 01:00:03 +0100
commit15174177091367332b57cd79575e2f7dd27388b2 (patch)
tree1e0c01a8fd7595bbf28277f3794447a35c2b9048
parent180e1de3f6bad36b00dfe3aeba43172e5e9a735e (diff)
detect MSO 2007 OOXML documents
Change-Id: I4052c6f1e5dde71ce4cede1ec9a313f461861d71
-rw-r--r--include/oox/core/xmlfilterbase.hxx2
-rw-r--r--oox/source/core/xmlfilterbase.cxx41
2 files changed, 41 insertions, 2 deletions
diff --git a/include/oox/core/xmlfilterbase.hxx b/include/oox/core/xmlfilterbase.hxx
index 9fccf1fd1cdc..d522fd66951e 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 4920cc62047b..3eccfe950551 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