From b002e3c521c58a4d8cd0004c801ff929076a88aa Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 1 Mar 2011 16:05:30 +0100 Subject: 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. --- sc/source/filter/xml/xmlimprt.cxx | 23 +++++++++++++++++++++-- sc/source/filter/xml/xmlwrap.cxx | 36 ++++++++++++++++++++++-------------- 2 files changed, 43 insertions(+), 16 deletions(-) diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx index f212fa2fa..34395bc9d 100644 --- a/sc/source/filter/xml/xmlimprt.cxx +++ b/sc/source/filter/xml/xmlimprt.cxx @@ -1911,7 +1911,7 @@ SvXMLImportContext *ScXMLImport::CreateMetaContext( { SvXMLImportContext *pContext(0); - if( !IsStylesOnlyMode() && (getImportFlags() & IMPORT_META)) + if (getImportFlags() & IMPORT_META) { uno::Reference xDocBuilder( mxServiceFactory->createInstance(::rtl::OUString::createFromAscii( @@ -1919,9 +1919,11 @@ SvXMLImportContext *ScXMLImport::CreateMetaContext( uno::UNO_QUERY_THROW); uno::Reference xDPS( GetModel(), uno::UNO_QUERY_THROW); + uno::Reference const xDocProps( + (IsStylesOnlyMode()) ? 0 : xDPS->getDocumentProperties()); pContext = new SvXMLMetaDocumentContext(*this, XML_NAMESPACE_OFFICE, rLocalName, - xDPS->getDocumentProperties(), xDocBuilder); + xDocProps, xDocBuilder); } if( !pContext ) @@ -2635,6 +2637,23 @@ throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeE } } + uno::Reference< beans::XPropertySet > const xImportInfo( getImportInfo() ); + uno::Reference< beans::XPropertySetInfo > const xPropertySetInfo( + xImportInfo.is() ? xImportInfo->getPropertySetInfo() : 0); + if (xPropertySetInfo.is()) + { + ::rtl::OUString const sOrganizerMode( + RTL_CONSTASCII_USTRINGPARAM("OrganizerMode")); + if (xPropertySetInfo->hasPropertyByName(sOrganizerMode)) + { + sal_Bool bStyleOnly(sal_False); + if (xImportInfo->getPropertyValue(sOrganizerMode) >>= bStyleOnly) + { + bLoadDoc = !bStyleOnly; + } + } + } + UnlockSolarMutex(); } diff --git a/sc/source/filter/xml/xmlwrap.cxx b/sc/source/filter/xml/xmlwrap.cxx index 479b855a8..8a7806f4c 100644 --- a/sc/source/filter/xml/xmlwrap.cxx +++ b/sc/source/filter/xml/xmlwrap.cxx @@ -429,6 +429,8 @@ sal_Bool ScXMLImportWrapper::Import(sal_Bool bStylesOnly, ErrCode& nError) { MAP_LEN( "BuildId" ), 0, &::getCppuType( (OUString *)0 ), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 }, { MAP_LEN( "VBACompatibilityMode" ), 0, &::getBooleanCppuType(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 }, { MAP_LEN( "ScriptConfiguration" ), 0, &::getCppuType((uno::Reference *)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0}, + { MAP_LEN( "OrganizerMode" ), 0, &::getBooleanCppuType(), + ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 }, { NULL, 0, 0, NULL, 0, 0 } }; @@ -488,26 +490,32 @@ sal_Bool ScXMLImportWrapper::Import(sal_Bool bStylesOnly, ErrCode& nError) } } + if (bStylesOnly) + { + ::rtl::OUString const sOrganizerMode( + RTL_CONSTASCII_USTRINGPARAM("OrganizerMode")); + xInfoSet->setPropertyValue(sOrganizerMode, uno::makeAny(sal_True)); + } + sal_Bool bOasis = ( SotStorage::GetVersion( xStorage ) > SOFFICE_FILEFORMAT_60 ); + // #i103539#: always read meta.xml for generator sal_uInt32 nMetaRetval(0); - if(!bStylesOnly) - { - uno::Sequence aMetaArgs(1); - uno::Any* pMetaArgs = aMetaArgs.getArray(); - pMetaArgs[0] <<= xInfoSet; + uno::Sequence aMetaArgs(1); + uno::Any* pMetaArgs = aMetaArgs.getArray(); + pMetaArgs[0] <<= xInfoSet; - RTL_LOGFILE_CONTEXT_TRACE( aLog, "meta import start" ); + RTL_LOGFILE_CONTEXT_TRACE( aLog, "meta import start" ); - nMetaRetval = ImportFromComponent(xServiceFactory, xModel, xXMLParser, aParserInput, - bOasis ? rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Calc.XMLOasisMetaImporter")) - : rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Calc.XMLMetaImporter")), - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("meta.xml")), - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Meta.xml")), aMetaArgs, - sal_False); + nMetaRetval = ImportFromComponent( + xServiceFactory, xModel, xXMLParser, aParserInput, + bOasis ? rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Calc.XMLOasisMetaImporter")) + : rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Calc.XMLMetaImporter")), + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("meta.xml")), + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Meta.xml")), aMetaArgs, + sal_False); - RTL_LOGFILE_CONTEXT_TRACE( aLog, "meta import end" ); - } + RTL_LOGFILE_CONTEXT_TRACE( aLog, "meta import end" ); SvXMLGraphicHelper* pGraphicHelper = NULL; uno::Reference< document::XGraphicObjectResolver > xGrfContainer; -- cgit v1.2.3