diff options
author | Michael Stahl <mst@openoffice.org> | 2011-03-01 16:05:30 +0100 |
---|---|---|
committer | Michael Stahl <mst@openoffice.org> | 2011-03-01 16:05:30 +0100 |
commit | 6db3d54a19c2f16be2fc2d05618c4593055c38c5 (patch) | |
tree | df357acbb9337f5ae8b2ef9982a7aa5a909ee2a6 /sw | |
parent | 230fcf4a456636bb466f72834cd57238621d206d (diff) |
sw34bf04: #i103539#: always import meta.xml, to extract the BuildId:
SvXMLMetaDocumentContext: refactor to not require DocumentProperties,
and always set the BuildId from the meta:generator element.
{Sc,Sd,Sw}XMLImport::CreateMetaContext(): always create context.
sc, sd: add OrganizerMode property to ODF import.
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/filter/xml/swxml.cxx | 17 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlimp.cxx | 18 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlimp.hxx | 15 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlmeta.cxx | 26 |
4 files changed, 49 insertions, 27 deletions
diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx index 98ae19039002..a892761023e5 100644 --- a/sw/source/filter/xml/swxml.cxx +++ b/sw/source/filter/xml/swxml.cxx @@ -925,18 +925,19 @@ sal_uLong XMLReader::Read( SwDoc &rDoc, const String& rBaseURL, SwPaM &rPaM, con } } - sal_uInt32 nWarn = 0; - sal_uInt32 nWarn2 = 0; // read storage streams + + // #i103539#: always read meta.xml for generator + sal_uInt32 const nWarn = ReadThroughComponent( + xStorage, xModelComp, "meta.xml", "Meta.xml", xServiceFactory, + (bOASIS ? "com.sun.star.comp.Writer.XMLOasisMetaImporter" + : "com.sun.star.comp.Writer.XMLMetaImporter"), + aEmptyArgs, rName, sal_False ); + + sal_uInt32 nWarn2 = 0; if( !(IsOrganizerMode() || IsBlockMode() || aOpt.IsFmtsOnly() || bInsertMode) ) { - nWarn = ReadThroughComponent( - xStorage, xModelComp, "meta.xml", "Meta.xml", xServiceFactory, - (bOASIS ? "com.sun.star.comp.Writer.XMLOasisMetaImporter" - : "com.sun.star.comp.Writer.XMLMetaImporter"), - aEmptyArgs, rName, sal_False ); - nWarn2 = ReadThroughComponent( xStorage, xModelComp, "settings.xml", NULL, xServiceFactory, (bOASIS ? "com.sun.star.comp.Writer.XMLOasisSettingsImporter" diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx index 279df96eb7cb..6c83855f1719 100644 --- a/sw/source/filter/xml/xmlimp.cxx +++ b/sw/source/filter/xml/xmlimp.cxx @@ -419,23 +419,23 @@ SvXMLImportContext *SwXMLImport::CreateContext( pContext = CreateMetaContext(rLocalName); } else if ( XML_NAMESPACE_OFFICE==nPrefix && + IsXMLToken( rLocalName, XML_DOCUMENT_STYLES ) ) + { + pContext = new SwXMLDocStylesContext_Impl( *this, nPrefix, rLocalName, + xAttrList ); + } + else if ( XML_NAMESPACE_OFFICE==nPrefix && IsXMLToken( rLocalName, XML_DOCUMENT ) ) { uno::Reference<xml::sax::XDocumentHandler> xDocBuilder( mxServiceFactory->createInstance(::rtl::OUString::createFromAscii( "com.sun.star.xml.dom.SAXDocumentBuilder")), uno::UNO_QUERY_THROW); - uno::Reference<document::XDocumentPropertiesSupplier> xDPS( - GetModel(), UNO_QUERY_THROW); + uno::Reference<document::XDocumentProperties> const xDocProps( + GetDocumentProperties()); // flat OpenDocument file format pContext = new SwXMLOfficeDocContext_Impl( *this, nPrefix, rLocalName, - xAttrList, xDPS->getDocumentProperties(), xDocBuilder); - } - else if ( XML_NAMESPACE_OFFICE==nPrefix && - IsXMLToken( rLocalName, XML_DOCUMENT_STYLES ) ) - { - pContext = new SwXMLDocStylesContext_Impl( *this, nPrefix, rLocalName, - xAttrList ); + xAttrList, xDocProps, xDocBuilder); } // <-- else diff --git a/sw/source/filter/xml/xmlimp.hxx b/sw/source/filter/xml/xmlimp.hxx index c670aaad9073..bec7a88719d4 100644 --- a/sw/source/filter/xml/xmlimp.hxx +++ b/sw/source/filter/xml/xmlimp.hxx @@ -25,14 +25,18 @@ * ************************************************************************/ -#ifndef _XMLIMP_HXX -#define _XMLIMP_HXX +#ifndef SW_XMLIMP_HXX +#define SW_XMLIMP_HXX + +#include <com/sun/star/document/XDocumentProperties.hpp> #include <sot/storage.hxx> + #include <xmloff/xmlictxt.hxx> -#include "xmlitmap.hxx" #include <xmloff/xmlimp.hxx> +#include "xmlitmap.hxx" + class SwDoc; class SwPaM; class SvXMLUnitConverter; @@ -211,6 +215,11 @@ public: // initialize XForms virtual void initXForms(); + + // get the document properties, but only if they actually need importing + ::com::sun::star::uno::Reference< + ::com::sun::star::document::XDocumentProperties> + GetDocumentProperties() const; }; inline const SvXMLUnitConverter& SwXMLImport::GetTwipUnitConverter() const diff --git a/sw/source/filter/xml/xmlmeta.cxx b/sw/source/filter/xml/xmlmeta.cxx index c337e231017a..473b8065d992 100644 --- a/sw/source/filter/xml/xmlmeta.cxx +++ b/sw/source/filter/xml/xmlmeta.cxx @@ -57,22 +57,34 @@ using namespace ::xmloff::token; // --------------------------------------------------------------------- +uno::Reference<document::XDocumentProperties> +SwXMLImport::GetDocumentProperties() const +{ + if (IsOrganizerMode() || IsStylesOnlyMode() || + IsBlockMode() || IsInsertMode()) + { + return 0; + } + uno::Reference<document::XDocumentPropertiesSupplier> const xDPS( + GetModel(), UNO_QUERY_THROW); + return xDPS->getDocumentProperties(); +} + SvXMLImportContext *SwXMLImport::CreateMetaContext( const OUString& rLocalName ) { SvXMLImportContext *pContext = 0; - if( !(IsStylesOnlyMode() || IsInsertMode()) ) + if (getImportFlags() & IMPORT_META) { - uno::Reference<xml::sax::XDocumentHandler> xDocBuilder( + uno::Reference<xml::sax::XDocumentHandler> const xDocBuilder( mxServiceFactory->createInstance(::rtl::OUString::createFromAscii( "com.sun.star.xml.dom.SAXDocumentBuilder")), - uno::UNO_QUERY_THROW); - uno::Reference<document::XDocumentPropertiesSupplier> xDPS( - GetModel(), UNO_QUERY_THROW); + uno::UNO_QUERY_THROW); + uno::Reference<document::XDocumentProperties> const xDocProps( + GetDocumentProperties()); pContext = new SvXMLMetaDocumentContext(*this, - XML_NAMESPACE_OFFICE, rLocalName, - xDPS->getDocumentProperties(), xDocBuilder); + XML_NAMESPACE_OFFICE, rLocalName, xDocProps, xDocBuilder); } if( !pContext ) |