1. mst
  2. ooo340

Commits

Henning Brinkmann  committed 7c256e4 Merge

merge

  • Participants
  • Parent commits 35b0567, 83f4b08
  • Branches default

Comments (0)

Files changed (16)

File sc/source/filter/xml/xmlimprt.cxx

View file
 {
     SvXMLImportContext *pContext(0);
 
-    if( !IsStylesOnlyMode() && (getImportFlags() & IMPORT_META))
+    if (getImportFlags() & IMPORT_META)
     {
         uno::Reference<xml::sax::XDocumentHandler> xDocBuilder(
             mxServiceFactory->createInstance(::rtl::OUString::createFromAscii(
             uno::UNO_QUERY_THROW);
         uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
             GetModel(), uno::UNO_QUERY_THROW);
+        uno::Reference<document::XDocumentProperties> const xDocProps(
+            (IsStylesOnlyMode()) ? 0 : xDPS->getDocumentProperties());
         pContext = new SvXMLMetaDocumentContext(*this,
             XML_NAMESPACE_OFFICE, rLocalName,
-            xDPS->getDocumentProperties(), xDocBuilder);
+            xDocProps, xDocBuilder);
     }
 
     if( !pContext )
         }
     }
 
+    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();
 }
 

File sc/source/filter/xml/xmlwrap.cxx

View file
 			{ 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<container::XNameAccess> *)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 }
 		};
 		    }
 	    }
 
+        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<uno::Any> aMetaArgs(1);
-			uno::Any* pMetaArgs = aMetaArgs.getArray();
-            pMetaArgs[0] <<= xInfoSet;
+        uno::Sequence<uno::Any> 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;

File sd/source/filter/xml/sdxmlwrp.cxx

View file
 		{ MAP_LEN( "BuildId" ), 0,
 			  &::getCppuType( (OUString *)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 }
 	};
 
 		}
 	}
 
+    if (SDXMLMODE_Organizer == meFilterMode)
+    {
+        ::rtl::OUString const sOrganizerMode(
+            RTL_CONSTASCII_USTRINGPARAM("OrganizerMode"));
+        xInfoSet->setPropertyValue(sOrganizerMode, uno::makeAny(sal_True));
+    }
+
 	// -------------------------------------
 
 	if( 0 == nRet )
 		sal_uInt32 nWarn = 0;
 		sal_uInt32 nWarn2 = 0;
 		// read storage streams
+        // #i103539#: always read meta.xml for generator
+        nWarn = ReadThroughComponent(
+            xStorage, xModelComp, "meta.xml", "Meta.xml", xServiceFactory,
+            pServices->mpMeta,
+            aEmptyArgs, aName, sal_False );
+
 		if( meFilterMode != SDXMLMODE_Organizer )
 		{
-			nWarn = ReadThroughComponent(
-				xStorage, xModelComp, "meta.xml", "Meta.xml", xServiceFactory,
-				pServices->mpMeta,
-				aEmptyArgs, aName, sal_False );
-
 			nWarn2 = ReadThroughComponent(
 				xStorage, xModelComp, "settings.xml", NULL, xServiceFactory,
 				pServices->mpSettings,

File sw/source/core/crsr/bookmrk.cxx

View file
         , m_aName(rName)
     {
         lcl_FixPosition(*m_pPos1);
-        if(aPaM.HasMark())
+        if (aPaM.HasMark() && (*aPaM.GetMark() != *aPaM.GetPoint()))
         {
             MarkBase::SetOtherMarkPos(*(aPaM.GetMark()));
             lcl_FixPosition(*m_pPos2);

File sw/source/core/crsr/findattr.cxx

View file
 		pItem = aIter.NextItem();
 	}
 }
+
+static bool
+lcl_IsAttributeIgnorable(xub_StrLen const nNdStart, xub_StrLen const nNdEnd,
+        _SwSrchChrAttr const& rTmp)
+{
+    // #i115528#: if there is a paragraph attribute, it has been added by the
+    // SwAttrCheckArr ctor, and nFound is 1.
+    // if the paragraph is entirely covered by hints that override the paragraph
+    // attribute, then this function must find an attribute to decrement nFound!
+    // so check for an empty search range, let attributes that start/end there
+    // cover it, and hope for the best...
+    return ((nNdEnd == nNdStart)
+            ? ((rTmp.nEnd <  nNdStart) || (nNdEnd <  rTmp.nStt))
+            : ((rTmp.nEnd <= nNdStart) || (nNdEnd <= rTmp.nStt)));
+}
+
 int SwAttrCheckArr::SetAttrFwd( const SwTxtAttr& rAttr )
 {
 	_SwSrchChrAttr aTmp( rAttr.GetAttr(), *rAttr.GetStart(), *rAttr.GetAnyEnd() );
-	// alle die nicht im Bereich sind -> ignorieren
-	if( aTmp.nEnd <= nNdStt || aTmp.nStt >= nNdEnd )
-		return Found();
+
+    // ignore all attributes not in search range
+    if (lcl_IsAttributeIgnorable(nNdStt, nNdEnd, aTmp))
+    {
+        return Found();
+    }
 
 	const SfxPoolItem* pItem;
-
 // --------------------------------------------------------------
 // Hier wird jetzt ausdruecklich auch in Zeichenvorlagen gesucht
 // --------------------------------------------------------------
 int SwAttrCheckArr::SetAttrBwd( const SwTxtAttr& rAttr )
 {
 	_SwSrchChrAttr aTmp( rAttr.GetAttr(), *rAttr.GetStart(), *rAttr.GetAnyEnd() );
-	// alle die nicht im Bereich sind -> ignorieren
-	if( aTmp.nEnd < nNdStt || aTmp.nStt >= nNdEnd )
-		return Found();
+
+    // ignore all attributes not in search range
+    if (lcl_IsAttributeIgnorable(nNdStt, nNdEnd, aTmp))
+    {
+        return Found();
+    }
 
 	const SfxPoolItem* pItem;
 // --------------------------------------------------------------

File sw/source/core/doc/docedt.cxx

View file
 			rPam.GetMark()->nNode = aPtNd;
 			rPam.GetMark()->nContent.Assign( aPtNd.GetNode().GetCntntNode(),
 												nPtCnt );
-			if( bJoinTxt )
-				rPam.Move( fnMoveBackward );
 
 			if( pUndoRpl )
             {

File sw/source/core/unocore/unoportenum.cxx

View file
             ++ppMark)
         {
             ::sw::mark::IMark* const pBkmk = ppMark->get();
-            bool hasOther = pBkmk->IsExpanded();
+            ::sw::mark::CrossRefBookmark *const pCrossRefMark(
+                    dynamic_cast< ::sw::mark::CrossRefBookmark*>(pBkmk));
+            bool const hasOther = pBkmk->IsExpanded();
 
             const SwPosition& rStartPos = pBkmk->GetMarkStart();
             if(rStartPos.nNode == nOwnNode)
             {
-                const sal_uInt8 nType = hasOther ? BKM_TYPE_START : BKM_TYPE_START_END;
+                // #i109272#: cross reference marks: need special handling!
+                sal_uInt8 const nType = (hasOther || pCrossRefMark)
+                    ? BKM_TYPE_START : BKM_TYPE_START_END;
                 rBkmArr.insert(SwXBookmarkPortion_ImplSharedPtr(
                     new SwXBookmarkPortion_Impl(
                             SwXBookmark::CreateXBookmark(rDoc, *pBkmk),
                 auto_ptr<SwPosition> pCrossRefEndPos;
                 const SwPosition* pEndPos = NULL;
                 if(hasOther)
+                {
                     pEndPos = &rEndPos;
-                else if(dynamic_cast< ::sw::mark::CrossRefBookmark*>(pBkmk))
+                }
+                else if (pCrossRefMark)
                 {
                     // Crossrefbookmarks only remember the start position but have to span the whole paragraph
                     pCrossRefEndPos = auto_ptr<SwPosition>(new SwPosition(rEndPos));

File sw/source/filter/xml/swxml.cxx

View file
         }
     }
 
-    sal_uInt32 nWarn = 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;
-	// read storage streams
 	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"

File sw/source/filter/xml/xmlimp.cxx

View file
         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

File sw/source/filter/xml/xmlimp.hxx

View file
  *
  ************************************************************************/
 
-#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 <xmloff/xmlimp.hxx>
+
 #include "xmlitmap.hxx"
-#include <xmloff/xmlimp.hxx>
 
 class SwDoc;
 class SwPaM;
 
     // 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

File sw/source/filter/xml/xmlmeta.cxx

View file
 
 // ---------------------------------------------------------------------
 
+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()) )
-	{
-        uno::Reference<xml::sax::XDocumentHandler> xDocBuilder(
+    if (getImportFlags() & IMPORT_META)
+    {
+        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 )
 		pContext = new SvXMLImportContext( *this,

File sw/source/ui/docvw/AnnotationWin.cxx

View file
 {
     if ( Engine()->IsModified() )
     {
-        SwTxtFld* pTxtFld = mpFmtFld->GetTxtFld();
-        SwPosition aPosition( pTxtFld->GetTxtNode() );
-        aPosition.nContent = *pTxtFld->GetStart();
-        SwField* pOldField = mpFld->Copy();
+        IDocumentUndoRedo & rUndoRedo(
+            DocView().GetDocShell()->GetDoc()->GetIDocumentUndoRedo());
+        ::std::auto_ptr<SwField> pOldField;
+        if (rUndoRedo.DoesUndo())
+        {
+            pOldField.reset(mpFld->Copy());
+        }
         mpFld->SetPar2(Engine()->GetEditEngine().GetText());
         mpFld->SetTextObject(Engine()->CreateParaObject());
-        DocView().GetDocShell()->GetDoc()->GetIDocumentUndoRedo().AppendUndo(
-            new SwUndoFieldFromDoc(aPosition, *pOldField, *mpFld, 0, true));
-        delete pOldField;
+        if (rUndoRedo.DoesUndo())
+        {
+            SwTxtFld *const pTxtFld = mpFmtFld->GetTxtFld();
+            SwPosition aPosition( pTxtFld->GetTxtNode() );
+            aPosition.nContent = *pTxtFld->GetStart();
+            rUndoRedo.AppendUndo(
+                new SwUndoFieldFromDoc(aPosition, *pOldField, *mpFld, 0, true));
+        }
         // so we get a new layout of notes (anchor position is still the same and we would otherwise not get one)
         Mgr().SetLayout();
         // #i98686# if we have several views, all notes should update their text
     // lets insert an undo step so the initial text can be easily deleted
     // but do not use UpdateData() directly, would set modified state again and reentrance into Mgr
     Engine()->SetModifyHdl( Link() );
-    SwTxtFld* pTxtFld = mpFmtFld->GetTxtFld();
-    SwPosition aPosition( pTxtFld->GetTxtNode() );
-    aPosition.nContent = *pTxtFld->GetStart();
-    SwField* pOldField = mpFld->Copy();
+    IDocumentUndoRedo & rUndoRedo(
+        DocView().GetDocShell()->GetDoc()->GetIDocumentUndoRedo());
+    ::std::auto_ptr<SwField> pOldField;
+    if (rUndoRedo.DoesUndo())
+    {
+        pOldField.reset(mpFld->Copy());
+    }
     mpFld->SetPar2(Engine()->GetEditEngine().GetText());
     mpFld->SetTextObject(Engine()->CreateParaObject());
-    DocView().GetDocShell()->GetDoc()->GetIDocumentUndoRedo().AppendUndo(
-        new SwUndoFieldFromDoc(aPosition, *pOldField, *mpFld, 0, true));
-    delete pOldField;
+    if (rUndoRedo.DoesUndo())
+    {
+        SwTxtFld *const pTxtFld = mpFmtFld->GetTxtFld();
+        SwPosition aPosition( pTxtFld->GetTxtNode() );
+        aPosition.nContent = *pTxtFld->GetStart();
+        rUndoRedo.AppendUndo(
+            new SwUndoFieldFromDoc(aPosition, *pOldField, *mpFld, 0, true));
+    }
     Engine()->SetModifyHdl( LINK( this, SwAnnotationWin, ModifyHdl ) );
     Engine()->ClearModifyFlag();
     Engine()->GetUndoManager().Clear();

File sw/source/ui/index/idxmrk.src

View file
 	#define COL_BUTTONS_2	(COL_BUTTONS+26)
 	#define WINDOW_HEIGHT	118
 	IDX_DIALOG_WINDOW
+    #undef IDX_WIN_WIDTH
+    #undef GB_HEIGHT
+    #undef DCB_INDEX_WIDTH
+    #undef PHONETIC_HIDDEN
+    #undef LIST_WIDTH
+    #undef COL_BUTTONS
+    #undef COL_BUTTONS_2
+    #undef WINDOW_HEIGHT
 };
 ModalDialog DLG_EDIT_IDXMARK_CJK
 {
 	#define COL_BUTTONS_2	(COL_BUTTONS+26)
 	#define WINDOW_HEIGHT	118
 	IDX_DIALOG_WINDOW
+    #undef IDX_WIN_WIDTH
+    #undef GB_HEIGHT
+    #undef DCB_INDEX_WIDTH
+    #undef PHONETIC_HIDDEN
+    #undef LIST_WIDTH
+    #undef COL_BUTTONS
+    #undef COL_BUTTONS_2
+    #undef WINDOW_HEIGHT
 };
 ModelessDialog DLG_INSIDXMARK
 {
 	#define COL_BUTTONS_2	(COL_BUTTONS+26)
 	#define WINDOW_HEIGHT	138
 	IDX_DIALOG_WINDOW
+    #undef IDX_WIN_WIDTH
+    #undef GB_HEIGHT
+    #undef DCB_INDEX_WIDTH
+    #undef PHONETIC_HIDDEN
+    #undef LIST_WIDTH
+    #undef COL_BUTTONS
+    #undef COL_BUTTONS_2
+    #undef WINDOW_HEIGHT
 };
 ModelessDialog DLG_INSIDXMARK_CJK
 {
 	#define COL_BUTTONS_2	(COL_BUTTONS+26)
 	#define WINDOW_HEIGHT	138
 	IDX_DIALOG_WINDOW
+    #undef IDX_WIN_WIDTH
+    #undef GB_HEIGHT
+    #undef DCB_INDEX_WIDTH
+    #undef PHONETIC_HIDDEN
+    #undef LIST_WIDTH
+    #undef COL_BUTTONS
+    #undef COL_BUTTONS_2
+    #undef WINDOW_HEIGHT
 };
 ModalDialog DLG_NEW_USER_IDX
 {
 	Size = MAP_APPFONT ( 218 , 118 ) ;
 	#define RADIO_BUTTON_HEIGHT 0
 	AUTH_DIALOG_WINDOW
+    #undef RADIO_BUTTON_HEIGHT
 };
 ModelessDialog DLG_INSAUTHMARK
 {
 	Size = MAP_APPFONT ( 218 , 118 + RADIO_BUTTON_HEIGHT) ;
 //	Moveable = TRUE ;
 	AUTH_DIALOG_WINDOW
+    #undef RADIO_BUTTON_HEIGHT
 };
 ModalDialog DLG_CREATE_AUTH_ENTRY
 {

File xmloff/inc/xmloff/xmlmetai.hxx

View file
  *
  ************************************************************************/
 
-#ifndef _XMLOFF_XMLMETAI_HXX
-#define _XMLOFF_XMLMETAI_HXX
+#ifndef XMLOFF_XMLMETAI_HXX
+#define XMLOFF_XMLMETAI_HXX
 
 #include "sal/config.h"
 #include "xmloff/dllapi.h"
 
     virtual void EndElement();
 
-protected:
-    /// initialize DocumentProperties object with DOM and base URL
-    void initDocumentProperties();
-    // set the BuildId property at the importer
-    void setBuildId(const ::rtl::OUString & i_rBuildId);
-
 public:
     static void setBuildId(const ::rtl::OUString & rGenerator,
         const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& xImportInfo );

File xmloff/source/draw/sdxmlimp.cxx

View file
 
 #include <tools/string.hxx>
 
-#ifndef _XMLOFF_XMLMETAI_HXX
 #include <xmloff/xmlscripti.hxx>
-#endif
 #include "sdxmlimp_impl.hxx"
 #include "ximpbody.hxx"
 
-#ifndef _SFX_XMLMETAI_HXX
 #include <xmloff/xmlmetai.hxx>
-#endif
 #include "ximpstyl.hxx"
 #include "xmloff/xmlnmspe.hxx"
 #include <xmloff/xmltoken.hxx>
 
 		if( xInfoSetInfo->hasPropertyByName( msPreview ) )
 			xInfoSet->getPropertyValue( msPreview ) >>= mbPreview;
-	}
+
+        ::rtl::OUString const sOrganizerMode(
+            RTL_CONSTASCII_USTRINGPARAM("OrganizerMode"));
+        if (xInfoSetInfo->hasPropertyByName(sOrganizerMode))
+        {
+            sal_Bool bStyleOnly(sal_False);
+            if (xInfoSet->getPropertyValue(sOrganizerMode) >>= bStyleOnly)
+            {
+                mbLoadDoc = !bStyleOnly;
+            }
+        }
+    }
 }
 
 //////////////////////////////////////////////////////////////////////////////
 {
 	SvXMLImportContext* pContext = 0L;
 
-	if (!IsStylesOnlyMode() && (getImportFlags() & IMPORT_META))
-	{
+    if (getImportFlags() & IMPORT_META)
+    {
         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::UNO_QUERY_THROW);
+        uno::Reference<document::XDocumentProperties> const xDocProps(
+            (IsStylesOnlyMode()) ? 0 : xDPS->getDocumentProperties());
         pContext = new SvXMLMetaDocumentContext(*this,
                         XML_NAMESPACE_OFFICE, rLocalName,
-                        xDPS->getDocumentProperties(), xDocBuilder);
+                        xDocProps, xDocBuilder);
 	}
 
 	if(!pContext)

File xmloff/source/meta/xmlmetai.cxx

View file
 
 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
 #include <com/sun/star/xml/dom/XSAXDocumentBuilder.hpp>
+#include <com/sun/star/xml/xpath/XXPathAPI.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/beans/XPropertySetInfo.hpp>
 
 
 //===========================================================================
 
+static void
+lcl_initDocumentProperties(SvXMLImport & rImport,
+        uno::Reference<xml::sax::XDocumentHandler> const& xDocBuilder,
+        uno::Reference<document::XDocumentProperties> const& xDocProps)
+{
+    uno::Sequence< uno::Any > aSeq(1);
+    uno::Reference< xml::dom::XSAXDocumentBuilder > const xDB(xDocBuilder,
+        uno::UNO_QUERY_THROW);
+    aSeq[0] <<= xDB->getDocument();
+    uno::Reference< lang::XInitialization > const xInit(xDocProps,
+        uno::UNO_QUERY_THROW);
+    try {
+        xInit->initialize(aSeq);
+        rImport.SetStatistics(xDocProps->getDocumentStatistics());
+        // convert all URLs from relative to absolute
+        xDocProps->setTemplateURL(rImport.GetAbsoluteReference(
+            xDocProps->getTemplateURL()));
+        xDocProps->setAutoloadURL(rImport.GetAbsoluteReference(
+            xDocProps->getAutoloadURL()));
+        SvXMLMetaDocumentContext::setBuildId(
+            xDocProps->getGenerator(), rImport.getImportInfo());
+    } catch (uno::RuntimeException) {
+        throw;
+    } catch (uno::Exception & e) {
+        throw lang::WrappedTargetRuntimeException(
+            ::rtl::OUString::createFromAscii(
+                "SvXMLMetaDocumentContext::initDocumentProperties: "
+                "properties init exception"),
+            rImport, makeAny(e));
+    }
+}
+
+static void
+lcl_initGenerator(SvXMLImport & rImport,
+        uno::Reference<xml::sax::XDocumentHandler> const& xDocBuilder)
+{
+    uno::Reference< xml::dom::XSAXDocumentBuilder > const xDB(xDocBuilder,
+        uno::UNO_QUERY_THROW);
+    uno::Reference< xml::dom::XDocument > const xDoc(xDB->getDocument(),
+        uno::UNO_SET_THROW);
+    try {
+        uno::Reference< xml::xpath::XXPathAPI > const xPath(
+            rImport.getServiceFactory()->createInstance(
+                ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+                    "com.sun.star.xml.xpath.XPathAPI"))),
+            uno::UNO_QUERY_THROW );
+        xPath->registerNS(GetXMLToken(XML_NP_OFFICE),GetXMLToken(XML_N_OFFICE));
+        xPath->registerNS(GetXMLToken(XML_NP_META), GetXMLToken(XML_N_META));
+
+        ::rtl::OUString const expr(RTL_CONSTASCII_USTRINGPARAM(
+            "string(/office:document-meta/office:meta/meta:generator)"));
+        uno::Reference< xml::xpath::XXPathObject > const xObj(
+            xPath->eval(xDoc.get(), expr), uno::UNO_SET_THROW);
+        OUString const value(xObj->getString());
+        SvXMLMetaDocumentContext::setBuildId(value, rImport.getImportInfo());
+    } catch (uno::RuntimeException) {
+        throw;
+    } catch (uno::Exception & e) {
+        throw lang::WrappedTargetRuntimeException(
+            ::rtl::OUString::createFromAscii(
+                "SvXMLMetaDocumentContext::initGenerator: exception"),
+            rImport, makeAny(e));
+    }
+}
+
 SvXMLMetaDocumentContext::SvXMLMetaDocumentContext(SvXMLImport& rImport,
             sal_uInt16 nPrfx, const rtl::OUString& rLName,
             const uno::Reference<document::XDocumentProperties>& xDocProps,
     mxDocProps(xDocProps),
     mxDocBuilder(xDocBuilder)
 {
-    DBG_ASSERT(xDocProps.is(), "SvXMLMetaDocumentContext: no document props");
-    DBG_ASSERT(xDocBuilder.is(), "SvXMLMetaDocumentContext: no document hdlr");
+// #i103539#: must always read meta.xml for generator, xDocProps unwanted then
+//    OSL_ENSURE(xDocProps.is(), "SvXMLMetaDocumentContext: no document props");
+    OSL_ENSURE(xDocBuilder.is(), "SvXMLMetaDocumentContext: no document hdlr");
     // here are no attributes
 }
 
     mxDocBuilder->startElement(
         GetImport().GetNamespaceMap().GetQNameByKey(GetPrefix(),
             GetXMLToken(XML_DOCUMENT_META)), xAttrList);
+
 }
 
 void SvXMLMetaDocumentContext::EndElement()
         GetImport().GetNamespaceMap().GetQNameByKey(GetPrefix(),
             GetXMLToken(XML_DOCUMENT_META)));
     mxDocBuilder->endDocument();
-    initDocumentProperties();
-}
-
-void SvXMLMetaDocumentContext::initDocumentProperties()
-{
-    uno::Sequence< uno::Any > aSeq(1);
-    uno::Reference< xml::dom::XSAXDocumentBuilder > xDB (mxDocBuilder,
-        uno::UNO_QUERY_THROW);
-    aSeq[0] <<= xDB->getDocument();
-    uno::Reference< lang::XInitialization > xInit(mxDocProps,
-        uno::UNO_QUERY_THROW);
-    try {
-        xInit->initialize(aSeq);
-        GetImport().SetStatistics(mxDocProps->getDocumentStatistics());
-        // convert all URLs from relative to absolute
-        mxDocProps->setTemplateURL(GetImport().GetAbsoluteReference(
-            mxDocProps->getTemplateURL()));
-        mxDocProps->setAutoloadURL(GetImport().GetAbsoluteReference(
-            mxDocProps->getAutoloadURL()));
-        setBuildId(mxDocProps->getGenerator());
-    } catch (uno::RuntimeException) {
-        throw;
-    } catch (uno::Exception & e) {
-        throw lang::WrappedTargetRuntimeException(
-            ::rtl::OUString::createFromAscii(
-                "SvXMLMetaDocumentContext::initDocumentProperties: "
-                "properties init exception"),
-            GetImport(), makeAny(e));
+    if (mxDocProps.is())
+    {
+        lcl_initDocumentProperties(GetImport(), mxDocBuilder, mxDocProps);
+    }
+    else
+    {
+        lcl_initGenerator(GetImport(), mxDocBuilder);
     }
 }
 
-void SvXMLMetaDocumentContext::setBuildId(const ::rtl::OUString & i_rBuildId)
-{
-    SvXMLMetaDocumentContext::setBuildId( i_rBuildId, GetImport().getImportInfo() );
-}
-
-//static
 void SvXMLMetaDocumentContext::setBuildId(::rtl::OUString const& i_rBuildId, const uno::Reference<beans::XPropertySet>& xImportInfo )
 {
     OUString sBuildId;