Anonymous avatar Anonymous committed b597fbe Merge

CWS-TOOLING: integrate CWS sw34bf04

Comments (0)

Files changed (58)

sc/source/filter/xml/xmlimprt.cxx

 {
     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();
 }
 

sc/source/filter/xml/xmlwrap.cxx

 			{ 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;

sd/source/filter/xml/sdxmlwrp.cxx

 		{ 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,

svl/inc/svl/nfkeytab.hxx

 #ifndef INCLUDED_SVTOOLS_NFKEYTAB_HXX
 #define INCLUDED_SVTOOLS_NFKEYTAB_HXX
 
+#include <vector>
 #include <tools/string.hxx>
 
 //! For ImpSvNumberformatScan: first the short symbols, then the long symbols!
     NF_KEYWORD_ENTRIES_COUNT
 };
 
-typedef String NfKeywordTable [NF_KEYWORD_ENTRIES_COUNT];
+class NfKeywordTable
+{
+    typedef ::std::vector<String> Keywords_t;
+    Keywords_t m_keywords;
+
+public:
+    NfKeywordTable() : m_keywords(NF_KEYWORD_ENTRIES_COUNT) {};
+    virtual ~NfKeywordTable() {}
+
+    String & operator[] (Keywords_t::size_type n) { return m_keywords[n]; }
+    const String & operator[] (Keywords_t::size_type n) const { return m_keywords[n]; }
+};
 
 #endif // INCLUDED_SVTOOLS_NFKEYTAB_HXX
 

svl/source/numbers/zforlist.cxx

         LanguageType eLang )
 {
 	ChangeIntl( eLang );
-    const String* pTable = pFormatScanner->GetKeywords();
+    const NfKeywordTable & rTable = pFormatScanner->GetKeywords();
 	for ( sal_uInt16 i = 0; i < NF_KEYWORD_ENTRIES_COUNT; ++i )
     {
-        rKeywords[i] = pTable[i];
+        rKeywords[i] = rTable[i];
     }
 }
 
 String SvNumberFormatter::GetKeyword( LanguageType eLnge, sal_uInt16 nIndex )
 {
 	ChangeIntl(eLnge);
-    const String* pTable = pFormatScanner->GetKeywords();
-	if ( pTable && nIndex < NF_KEYWORD_ENTRIES_COUNT )
-		return pTable[nIndex];
+    const NfKeywordTable & rTable = pFormatScanner->GetKeywords();
+	if ( nIndex < NF_KEYWORD_ENTRIES_COUNT )
+		return rTable[nIndex];
 
 	DBG_ERROR("GetKeyword: invalid index");
 	return String();
 		CLOffset + SetIndexTable( NF_FRACTION_2, ZF_STANDARD_FRACTION+1 ));
 
 	// Week of year   must be appended here because of nNewExtended
-    const String* pKeyword = pFormatScanner->GetKeywords();
-	aSingleFormatCode.Code = pKeyword[NF_KEY_WW];
+    const NfKeywordTable & rKeyword = pFormatScanner->GetKeywords();
+	aSingleFormatCode.Code = rKeyword[NF_KEY_WW];
 	ImpInsertNewStandardFormat( aSingleFormatCode,
 		CLOffset + SetIndexTable( NF_DATE_WW, nNewExtended++ ),
 		SV_NUMBERFORMATTER_VERSION_NF_DATE_WW );

svl/source/numbers/zformat.cxx

     xub_StrLen nLen = rString.Len();
     ScanState eState = SsStart;
     sSymbol.Erase();
-    const String* pKeywords = rScan.GetKeywords();
+    const NfKeywordTable & rKeywords = rScan.GetKeywords();
     while (nPos < nLen && eState != SsStop)
     {
         cToken = rString.GetChar(nPos);
                                 BRACKET_SYMBOLTYPE_DBNUM1 - (cDBNum - '1'));
                             eState = SsGetPrefix;
                         }
-                        else if (cUpper == pKeywords[NF_KEY_H].GetChar(0)   ||  // H
-                            cUpper == pKeywords[NF_KEY_MI].GetChar(0)   ||  // M
-                            cUpper == pKeywords[NF_KEY_S].GetChar(0)    )   // S
+                        else if (cUpper == rKeywords[NF_KEY_H].GetChar(0)   ||  // H
+                            cUpper == rKeywords[NF_KEY_MI].GetChar(0)   ||  // M
+                            cUpper == rKeywords[NF_KEY_S].GetChar(0)    )   // S
                         {
                             sSymbol += cToken;
                             eState = SsGetTime;
                 else
                 {
                     sal_Unicode cUpper = rChrCls().toUpper( rString, nPos-1, 1 ).GetChar(0);
-                    if (cUpper == pKeywords[NF_KEY_H].GetChar(0)    ||  // H
-                        cUpper == pKeywords[NF_KEY_MI].GetChar(0)   ||  // M
-                        cUpper == pKeywords[NF_KEY_S].GetChar(0)    )   // S
+                    if (cUpper == rKeywords[NF_KEY_H].GetChar(0)    ||  // H
+                        cUpper == rKeywords[NF_KEY_MI].GetChar(0)   ||  // M
+                        cUpper == rKeywords[NF_KEY_S].GetChar(0)    )   // S
                     {
                         if (cLetter == cToken)
                         {
         const String& rColorName = NumFor[n].GetColorName();
         if ( rColorName.Len() )
         {
-            const String* pKey = rScan.GetKeywords() + NF_KEY_FIRSTCOLOR;
-            for ( int j=NF_KEY_FIRSTCOLOR; j<=NF_KEY_LASTCOLOR; j++, pKey++ )
+            const NfKeywordTable & rKey = rScan.GetKeywords();
+            for ( int j=NF_KEY_FIRSTCOLOR; j<=NF_KEY_LASTCOLOR; j++ )
             {
-                if ( *pKey == rColorName )
+                if ( rKey[j] == rColorName )
                 {
                     aPrefix += '[';
                     aPrefix += rKeywords[j];

svl/source/numbers/zforscan.cxx

 Color* ImpSvNumberformatScan::GetColor(String& sStr)
 {
 	String sString = pFormatter->GetCharClass()->upper(sStr);
-    const String* pKeyword = GetKeywords();
+    const NfKeywordTable & rKeyword = GetKeywords();
 	size_t i = 0;
 	while (i < NF_MAX_DEFAULT_COLORS &&
-           sString != pKeyword[NF_KEY_FIRSTCOLOR+i] )
+           sString != rKeyword[NF_KEY_FIRSTCOLOR+i] )
 		i++;
     if ( i >= NF_MAX_DEFAULT_COLORS )
     {
     Color* pResult = NULL;
 	if (i >= NF_MAX_DEFAULT_COLORS)
 	{
-        const String& rColorWord = pKeyword[NF_KEY_COLOR];
+        const String& rColorWord = rKeyword[NF_KEY_COLOR];
 		xub_StrLen nPos = sString.Match(rColorWord);
 		if (nPos > 0)
 		{
 			pFormatter->ChangeIntl(eTmpLnge);
 		}
 		else
-            sStr = pKeyword[NF_KEY_FIRSTCOLOR+i];
+            sStr = rKeyword[NF_KEY_FIRSTCOLOR+i];
 
 		pResult = &(StandardColor[i]);
 	}
 short ImpSvNumberformatScan::GetKeyWord( const String& sSymbol, xub_StrLen nPos )
 {
 	String sString = pFormatter->GetCharClass()->toUpper( sSymbol, nPos, sSymbol.Len() - nPos );
-    const String* pKeyword = GetKeywords();
+    const NfKeywordTable & rKeyword = GetKeywords();
 	// #77026# for the Xcl perverts: the GENERAL keyword is recognized anywhere
-    if ( sString.Search( pKeyword[NF_KEY_GENERAL] ) == 0 )
+    if ( sString.Search( rKeyword[NF_KEY_GENERAL] ) == 0 )
 		return NF_KEY_GENERAL;
 	//! MUST be a reverse search to find longer strings first
 	short i = NF_KEYWORD_ENTRIES_COUNT-1;
 	sal_Bool bFound = sal_False;
     for ( ; i > NF_KEY_LASTKEYWORD_SO5; --i )
     {
-        bFound = sString.Search(pKeyword[i]) == 0;
+        bFound = sString.Search(rKeyword[i]) == 0;
         if ( bFound )
         {
             break;
 	if ( !bFound )
 	{	// skip the gap of colors et al between new and old keywords and search on
 		i = NF_KEY_LASTKEYWORD;
-        while ( i > 0 && sString.Search(pKeyword[i]) != 0 )
+        while ( i > 0 && sString.Search(rKeyword[i]) != 0 )
 			i--;
-        if ( i > NF_KEY_LASTOLDKEYWORD && sString != pKeyword[i] )
+        if ( i > NF_KEY_LASTOLDKEYWORD && sString != rKeyword[i] )
 		{	// found something, but maybe it's something else?
 			// e.g. new NNN is found in NNNN, for NNNN we must search on
 			short j = i - 1;
-            while ( j > 0 && sString.Search(pKeyword[j]) != 0 )
+            while ( j > 0 && sString.Search(rKeyword[j]) != 0 )
 				j--;
-            if ( j && pKeyword[j].Len() > pKeyword[i].Len() )
+            if ( j && rKeyword[j].Len() > rKeyword[i].Len() )
 				return j;
 		}
 	}

svl/source/numbers/zforscan.hxx

 	const LocaleDataWrapper& GetLoc() const		{ return *pFormatter->GetLocaleData(); }
 	CalendarWrapper& GetCal() const				{ return *pFormatter->GetCalendar(); }
 
-    const String* GetKeywords() const
+    const NfKeywordTable & GetKeywords() const
         {
             if ( bKeywordsNeedInit )
                 InitKeywords();

sw/JunitTest_sw_complex.mk

 	complex.writer.TextPortionEnumerationTest \
 ))
 
-# currently fails (should run again in os146) (except on windows)
-#	complex.writer.CheckBookmarks \
+# CheckBookmarks currently fails on windows because the hashes are different
+ifneq ($(OS),WNT)
+$(eval $(call gb_JunitTest_add_classes,sw_complex,\
+	complex.writer.CheckBookmarks \
+))
+endif
 
 # vim: set noet sw=4 ts=4:

sw/source/core/crsr/bookmrk.cxx

         , 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);

sw/source/core/crsr/findattr.cxx

 		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;
 // --------------------------------------------------------------

sw/source/core/doc/doccorr.cxx

     getIDocumentMarkAccess()->correctMarksAbsolute(rOldNode, rNewPos, nOffset);
     {   // fix redlines
         SwRedlineTbl& rTbl = *pRedlineTbl;
-        for( sal_uInt16 n = 0; n < rTbl.Count(); ++n )
+        for (sal_uInt16 n = 0; n < rTbl.Count(); )
         {
             // is on position ??
-            lcl_PaMCorrAbs(*rTbl[ n ], *aPam.Start(), *aPam.End(), aNewPos);
+            SwRedline *const pRedline( rTbl[ n ] );
+            bool const bChanged =
+                lcl_PaMCorrAbs(*pRedline, *aPam.Start(), *aPam.End(), aNewPos);
+            // clean up empty redlines: docredln.cxx asserts these as invalid
+            if (bChanged && (*pRedline->GetPoint() == *pRedline->GetMark())
+                         && (pRedline->GetContentIdx() == NULL))
+            {
+                rTbl.DeleteAndDestroy(n);
+            }
+            else
+            {
+                ++n;
+            }
         }
     }
 

sw/source/core/doc/docedt.cxx

 			rPam.GetMark()->nNode = aPtNd;
 			rPam.GetMark()->nContent.Assign( aPtNd.GetNode().GetCntntNode(),
 												nPtCnt );
-			if( bJoinTxt )
-				rPam.Move( fnMoveBackward );
 
 			if( pUndoRpl )
             {
 				return sal_False;
 			}
 		}
-			// text::Bookmarks usw. verschieben
-		CorrAbs( aRg.aStart, aRg.aEnd, *rPam.GetPoint(), sal_True );
+        // move bookmarks, redlines etc.
+        if (aRg.aStart == aRg.aEnd) // only first CorrAbs variant handles this
+        {
+            CorrAbs( aRg.aStart, *rPam.GetPoint(), 0, sal_True );
+        }
+        else
+        {
+            CorrAbs( aRg.aStart, aRg.aEnd, *rPam.GetPoint(), sal_True );
+        }
 
 			// was ist mit Fly's ??
 		{

sw/source/core/doc/docfmt.cxx

 		SwTxtNode* pTNd = aTmpStt.GetNode().GetTxtNode();
         if( pTNd && pTNd->HasSwAttrSet() && pTNd->GetpSwAttrSet()->Count() )
 		{
-			SfxItemIter aIter( *pTNd->GetpSwAttrSet() );
-			const SfxPoolItem* pItem = aIter.GetCurItem();
-            SfxItemSet aCharSet( GetAttrPool(), RES_CHRATR_BEGIN, RES_CHRATR_END );
-
-            while( sal_True )
-			{
-				if( IsInRange( aCharFmtSetRange, pItem->Which() ))
-				{
-                    pTNd->GetOrCreateSwpHints();
-
-                    aCharSet.Put( *pItem );
-
-                    if( pHst )
-                    {
-                        SwRegHistory aRegH( pTNd, *pTNd, pHst );
-                        pTNd->ResetAttr( pItem->Which() );
-                    }
-                    else
-                        pTNd->ResetAttr( pItem->Which() );
-				}
-				if( aIter.IsAtEnd() )
-					break;
-				pItem = aIter.NextItem();
-			}
-
-            if ( aCharSet.Count() )
+            if (pHst)
             {
-                if ( pHst )
-                {
-                    SwRegHistory history( pTNd, *pTNd, pHst );
-                    history.InsertItems( aCharSet, 0, pTNd->GetTxt().Len(),
-                        nsSetAttrMode::SETATTR_NOFORMATATTR );
-                }
-                else
-                {
-                    SwTxtAttr* pNew =
-                        MakeTxtAttr( *this, aCharSet, 0, pTNd->GetTxt().Len() );
-                    pTNd->InsertHint( pNew );
-                }
+                SwRegHistory history(pTNd, *pTNd, pHst);
+                pTNd->FmtToTxtAttr(pTNd);
+            }
+            else
+            {
+                pTNd->FmtToTxtAttr(pTNd);
             }
 		}
 
 		SwTxtNode* pTNd = aTmpEnd.GetNode().GetTxtNode();
         if( pTNd && pTNd->HasSwAttrSet() && pTNd->GetpSwAttrSet()->Count() )
 		{
-			SfxItemIter aIter( *pTNd->GetpSwAttrSet() );
-			const SfxPoolItem* pItem = aIter.GetCurItem();
-			while( sal_True )
-			{
-				if( IsInRange( aCharFmtSetRange, pItem->Which() ))
-                {
-                    SwTxtAttr* pTAttr = MakeTxtAttr( *this,
-                        const_cast<SfxPoolItem&>(*pItem),
-                        0, pTNd->GetTxt().Len() );
-                    SwpHints & rHints = pTNd->GetOrCreateSwpHints();
-                    rHints.SwpHintsArray::Insert( pTAttr );
-                    if ( pHst )
-                    {
-						SwRegHistory aRegH( pTNd, *pTNd, pHst );
-						pTNd->ResetAttr( pItem->Which() );
-                        pHst->Add( pTAttr, aTmpEnd.GetIndex(), true );
-                    }
-                    else
-						pTNd->ResetAttr( pItem->Which() );
-				}
-				if( aIter.IsAtEnd() )
-					break;
-				pItem = aIter.NextItem();
-			}
+            if (pHst)
+            {
+                SwRegHistory history(pTNd, *pTNd, pHst);
+                pTNd->FmtToTxtAttr(pTNd);
+            }
+            else
+            {
+                pTNd->FmtToTxtAttr(pTNd);
+            }
 		}
 	}
 

sw/source/core/layout/fly.cxx

     // Assure the control objects and group objects containing controls are on the control layer
     if ( ::CheckControlLayer( _rNewObj.DrawObj() ) )
     {
-        const IDocumentDrawModelAccess* pIDDMA = GetUpper()->GetFmt()->getIDocumentDrawModelAccess();
+        const IDocumentDrawModelAccess* pIDDMA = (IsFlyFrm())
+            ? static_cast<SwFlyFrm*>(this)->GetFmt()->
+                    getIDocumentDrawModelAccess()
+            : GetUpper()->GetFmt()->getIDocumentDrawModelAccess();
         const SdrLayerID aCurrentLayer(_rNewObj.DrawObj()->GetLayer());
         const SdrLayerID aControlLayerID(pIDDMA->GetControlsId());
         const SdrLayerID aInvisibleControlLayerID(pIDDMA->GetInvisibleControlsId());

sw/source/core/txtnode/thints.cxx

         const SwTxtAttr* const pAutoStyle(i_rAttrSpan.second);
         SfxItemIter aIter(m_rAttrSet);
         const SfxPoolItem* pItem(aIter.GetCurItem());
-        while (true)
+        while (pItem)
         {
             const sal_uInt16 nWhich(pItem->Which());
             if (CharFmt::IsItemIncluded(nWhich, pAutoStyle))
             const AttrSpan_t aSpan(*pHint->GetStart(), *pHint->GetEnd());
             o_rSpanMap.insert(AttrSpanMap_t::value_type(aSpan, pHint));
 
-            if (aSpan.first != nLastEnd)
+            // < not != because there may be multiple CHARFMT at same range
+            if (nLastEnd < aSpan.first)
             {
                 // insert dummy span covering the gap
                 o_rSpanMap.insert(AttrSpanMap_t::value_type(

sw/source/core/unocore/unoframe.cxx

                     aFrmSet.Put( SwFmtAnchor( FLY_AT_PAGE, 1 ));
                 }
 
+                aPam.DeleteMark(); // mark position node will be deleted!
+                aIntPam.DeleteMark(); // mark position node will be deleted!
                 pFmt = pDoc->MakeFlyAndMove( *m_pCopySource, aFrmSet,
                                0,
                                pParentFrmFmt );

sw/source/core/unocore/unoportenum.cxx

             ++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));

sw/source/core/unocore/unotext.cxx

             // DelFullPara is called
             const uno::Reference< text::XTextRange> xInsertTextRange =
                 new SwXTextRange(aStartPam, this);
+            aStartPam.DeleteMark(); // mark position node may be deleted!
             pNewFrame->attach( xInsertTextRange );
             pNewFrame->setName(m_pImpl->m_pDoc->GetUniqueFrameName());
         }
 
-        if (!aStartPam.GetTxt().Len())
+        SwTxtNode *const pTxtNode(aStartPam.GetNode()->GetTxtNode());
+        OSL_ASSERT(pTxtNode);
+        if (!pTxtNode || !pTxtNode->Len()) // don't remove if it contains text!
         {
-            bool bMoved = false;
             {   // has to be in a block to remove the SwIndexes before
                 // DelFullPara is called
                 SwPaM aMovePam( *aStartPam.GetNode() );
                     m_pImpl->m_pDoc->SetAttr(
                         aNewAnchor, *pNewFrame->GetFrmFmt() );
                 }
-                bMoved = true;
             }
-            if (bMoved)
-            {
-                aStartPam.DeleteMark();
-//                    SwPaM aDelPam( *aStartPam.GetNode() );
-                m_pImpl->m_pDoc->DelFullPara(aStartPam/*aDelPam*/);
-            }
+            m_pImpl->m_pDoc->DelFullPara(aStartPam);
         }
     }
     catch (lang::IllegalArgumentException& rIllegal)

sw/source/filter/ww1/fltshell.cxx

 
 sal_Bool SwFltStackEntry::MakeRegion(SwDoc* pDoc, SwPaM& rRegion, sal_Bool bCheck )
 {
-	// wird ueberhaupt ein Bereich umspannt ??
-	// - ist kein Bereich, dann nicht returnen wenn am Anfang vom Absatz
-	// - Felder aussortieren, koennen keinen Bereich haben !!
-	if (
-	     nMkNode.GetIndex() == nPtNode.GetIndex() && nMkCntnt == nPtCntnt &&
-		 nPtCntnt && RES_TXTATR_FIELD != pAttr->Which()
-	   )
+    // does this range actually contain something?
+    // empty range is allowed if at start of empty paragraph
+    // fields are special: never have range, so leave them
+    SwCntntNode *const pCntntNode(
+        SwNodeIndex(nMkNode, +1).GetNode().GetCntntNode());
+    if ((nMkNode.GetIndex() == nPtNode.GetIndex()) && (nMkCntnt == nPtCntnt)
+        && ((0 != nPtCntnt) || (pCntntNode && (0 != pCntntNode->Len())))
+        && (RES_TXTATR_FIELD != pAttr->Which()))
 	{
 		return sal_False;
 	}

sw/source/filter/ww8/WW8TableInfo.cxx

         pWidths = WidthsPtr(new Widths);
         // number of cell written
         sal_uInt32 nBoxes = rTabBoxes.Count();
-        if ( nBoxes > 32 )
-            nBoxes = 32;
+        if ( nBoxes > MAXTABLECELLS )
+            nBoxes = MAXTABLECELLS;
         
         for (sal_uInt32 n = 0; n < nBoxes; n++)
         {
         const SwTableBoxes & rTabBoxes = pTabLine->GetTabBoxes();
 
         sal_uInt32 nBoxes = rTabBoxes.Count();
-        if (nBoxes > 32)
-            nBoxes = 32;
+        if (nBoxes > MAXTABLECELLS)
+            nBoxes = MAXTABLECELLS;
         
         for (sal_uInt32 n = 0; n < nBoxes; ++n)
         {

sw/source/filter/ww8/WW8TableInfo.hxx

 {
 using namespace ::std;
 
+const unsigned int MAXTABLECELLS = 63;
+
 class WW8TableNodeInfo;
 typedef boost::shared_ptr<SwRect> SwRectPtr; 
 typedef ::std::vector<const SwTableBox *> TableBoxVector;

sw/source/filter/ww8/wrtw8nds.cxx

 // Mit OutAttr() werden die Attribute an der angegebenen SwPos
 // ausgegeben.
 
-class SwAttrIter : public MSWordAttrIter
+class WW8SwAttrIter : public MSWordAttrIter
 {
 private:
     const SwTxtNode& rNd;
     void IterToCurrent();
 
     //No copying
-    SwAttrIter(const SwAttrIter&);
-    SwAttrIter& operator=(const SwAttrIter&);
+    WW8SwAttrIter(const WW8SwAttrIter&);
+    WW8SwAttrIter& operator=(const WW8SwAttrIter&);
 public:
-    SwAttrIter( MSWordExportBase& rWr, const SwTxtNode& rNd );
+    WW8SwAttrIter( MSWordExportBase& rWr, const SwTxtNode& rNd );
 
     bool IsTxtAttr( xub_StrLen nSwPos );
     bool IsRedlineAtEnd( xub_StrLen nPos ) const;
     }
 };
 
-void SwAttrIter::IterToCurrent()
+void WW8SwAttrIter::IterToCurrent()
 {
     ASSERT(maCharRuns.begin() != maCharRuns.end(), "Impossible");
     mnScript = maCharRunIter->mnScript;
     mbCharIsRTL = maCharRunIter->mbRTL;
 }
 
-SwAttrIter::SwAttrIter(MSWordExportBase& rWr, const SwTxtNode& rTxtNd) :
+WW8SwAttrIter::WW8SwAttrIter(MSWordExportBase& rWr, const SwTxtNode& rTxtNd) :
     MSWordAttrIter(rWr),
     rNd(rTxtNd),
     maCharRuns(GetPseudoCharRuns(rTxtNd, 0, !rWr.HackIsWW8OrHigher())),
     return min;
 }
 
-xub_StrLen SwAttrIter::SearchNext( xub_StrLen nStartPos )
+xub_StrLen WW8SwAttrIter::SearchNext( xub_StrLen nStartPos )
 {
     xub_StrLen nPos;
     xub_StrLen nMinPos = STRING_MAXLEN;
     return nMinPos;
 }
 
-void SwAttrIter::OutAttr( xub_StrLen nSwPos )
+void WW8SwAttrIter::OutAttr( xub_StrLen nSwPos )
 {
     m_rExport.AttrOutput().RTLAndCJKState( IsCharRTL(), GetScript() );
 
                         : nSwPos == *pHt->GetStart() )
             {
                 sal_uInt16 nWhich = pHt->GetAttr().Which();
-                if (nWhich == nFontId)
-                    pFont = &(item_cast<SvxFontItem>(pHt->GetAttr()));
-                else if( nWhich == RES_TXTATR_AUTOFMT )
+                if (nWhich == RES_TXTATR_AUTOFMT)
                 {
                     const SwFmtAutoFmt& rAutoFmt = static_cast<const SwFmtAutoFmt&>(pHt->GetAttr());
                     const boost::shared_ptr<SfxItemSet> pSet = rAutoFmt.GetStyleHandle();
     }
 }
 
-void SwAttrIter::OutFlys(xub_StrLen nSwPos)
+void WW8SwAttrIter::OutFlys(xub_StrLen nSwPos)
 {
     /*
      #i2916#
     }
 }
 
-bool SwAttrIter::IsTxtAttr( xub_StrLen nSwPos )
+bool WW8SwAttrIter::IsTxtAttr( xub_StrLen nSwPos )
 {
     // search for attrs with CH_TXTATR
     if (const SwpHints* pTxtAttrs = rNd.GetpSwpHints())
     return false;
 }
 
-bool SwAttrIter::IsDropCap( int nSwPos )
+bool WW8SwAttrIter::IsDropCap( int nSwPos )
 {
     // see if the current position falls on a DropCap
     int nDropChars = mrSwFmtDrop.GetChars();
     return false;
 }
 
-bool SwAttrIter::RequiresImplicitBookmark()
+bool WW8SwAttrIter::RequiresImplicitBookmark()
 {
     SwImplBookmarksIter bkmkIterEnd = m_rExport.maImplicitBookmarks.end();
     for ( SwImplBookmarksIter aIter = m_rExport.maImplicitBookmarks.begin(); aIter != bkmkIterEnd; ++aIter )
 // Attribut-Anfangposition fragen kann.
 // Es koennen nur Attribute mit Ende abgefragt werden.
 // Es wird mit bDeep gesucht
-const SfxPoolItem* SwAttrIter::HasTextItem( sal_uInt16 nWhich ) const
+const SfxPoolItem* WW8SwAttrIter::HasTextItem( sal_uInt16 nWhich ) const
 {
     const SfxPoolItem* pRet = 0;
     const SwpHints* pTxtAttrs = rNd.GetpSwpHints();
         rItems.Insert((*pO)[nI], rItems.Count());
 }
 
-const SfxPoolItem& SwAttrIter::GetItem(sal_uInt16 nWhich) const
+const SfxPoolItem& WW8SwAttrIter::GetItem(sal_uInt16 nWhich) const
 {
     const SfxPoolItem* pRet = HasTextItem(nWhich);
     return pRet ? *pRet : rNd.SwCntntNode::GetAttr(nWhich);
         INetURLObject::DECODE_UNAMBIGUOUS, RTL_TEXTENCODING_ASCII_US);
 }
 
-void SwAttrIter::OutSwFmtRefMark(const SwFmtRefMark& rAttr, bool)
+void WW8SwAttrIter::OutSwFmtRefMark(const SwFmtRefMark& rAttr, bool)
 {
     if ( m_rExport.HasRefToObject( REF_SETREFATTR, &rAttr.GetRefName(), 0 ) )
         m_rExport.AppendBookmark( m_rExport.GetBookmarkName( REF_SETREFATTR,
         FieldVanish( sTxt, eType );
 }
 
-int SwAttrIter::OutAttrWithRange(xub_StrLen nPos)
+int WW8SwAttrIter::OutAttrWithRange(xub_StrLen nPos)
 {
     int nRet = 0;
     if ( const SwpHints* pTxtAttrs = rNd.GetpSwpHints() )
     return nRet;
 }
 
-bool SwAttrIter::IsRedlineAtEnd( xub_StrLen nEnd ) const
+bool WW8SwAttrIter::IsRedlineAtEnd( xub_StrLen nEnd ) const
 {
     bool bRet = false;
     // search next Redline
     return bRet;
 }
 
-const SwRedlineData* SwAttrIter::GetRedline( xub_StrLen nPos )
+const SwRedlineData* WW8SwAttrIter::GetRedline( xub_StrLen nPos )
 {
     if( pCurRedline )
     {
 ridicously complicated title case attribute mapping to hardcoded upper case
 because word doesn't have the feature
 */
-String SwAttrIter::GetSnippet(const String &rStr, xub_StrLen nAktPos,
+String WW8SwAttrIter::GetSnippet(const String &rStr, xub_StrLen nAktPos,
     xub_StrLen nLen) const
 {
     String aSnippet(rStr, nAktPos, nLen);
     m_rWW8Export.pO->Remove( 0, m_rWW8Export.pO->Count() );
 }
 
-xub_StrLen MSWordExportBase::GetNextPos( SwAttrIter* aAttrIter, const SwTxtNode& rNode, xub_StrLen nAktPos  )
+xub_StrLen MSWordExportBase::GetNextPos( WW8SwAttrIter* aAttrIter, const SwTxtNode& rNode, xub_StrLen nAktPos  )
 {
     // Get the bookmarks for the normal run
     xub_StrLen nNextPos = aAttrIter->WhereNext();
     return std::min( nNextPos, nNextBookmark );
 }
 
-void MSWordExportBase::UpdatePosition( SwAttrIter* aAttrIter, xub_StrLen nAktPos, xub_StrLen /*nEnd*/ )
+void MSWordExportBase::UpdatePosition( WW8SwAttrIter* aAttrIter, xub_StrLen nAktPos, xub_StrLen /*nEnd*/ )
 {
     xub_StrLen nNextPos;
 
     // have to remember it in nStyle
     sal_uInt16 nStyle = nStyleBeforeFly;
 
-    SwAttrIter aAttrIter( *this, rNode );
+    WW8SwAttrIter aAttrIter( *this, rNode );
     rtl_TextEncoding eChrSet = aAttrIter.GetCharSet();
 
     if ( bStartTOX )
     String aStr( rNode.GetTxt() );
 
     xub_StrLen nAktPos = 0;
-    xub_StrLen nEnd = aStr.Len();
+    xub_StrLen const nEnd = aStr.Len();
     bool bRedlineAtEnd = false;
     int nOpenAttrWithRange = 0;
 
         if ( aAttrIter.IsDropCap( nNextAttr ) )
             AttrOutput().FormatDrop( rNode, aAttrIter.GetSwFmtDrop(), nStyle, pTextNodeInfo, pTextNodeInfoInner );
 
+        if (0 != nEnd)
+        {
+            // Output the character attributes
+            // #i51277# do this before writing flys at end of paragraph
+            AttrOutput().StartRunProperties();
+            aAttrIter.OutAttr( nAktPos );
+            AttrOutput().EndRunProperties( pRedlineData );
+        }
+
         // At the end of line, output the attributes until the CR.
         // Exception: footnotes at the end of line
         if ( nNextAttr == nEnd )
                 }
             }
         }
-        
-        // Output the character attributes
-        AttrOutput().StartRunProperties();
-        aAttrIter.OutAttr( nAktPos );   // nAktPos - 1 ??
-        AttrOutput().EndRunProperties( pRedlineData );
+
+        if (0 == nEnd)
+        {
+            // Output the character attributes
+            // do it after WriteCR for an empty paragraph (otherwise
+            // WW8_WrFkp::Append throws SPRMs away...)
+            AttrOutput().StartRunProperties();
+            aAttrIter.OutAttr( nAktPos );
+            AttrOutput().EndRunProperties( pRedlineData );
+        }
 
         // Exception: footnotes at the end of line
         if ( nNextAttr == nEnd )

sw/source/filter/ww8/wrtww8.cxx

         pTableTextNodeInfoInner->getTableBoxesOfRow();
     // number of cell written
     sal_uInt32 nBoxes = pTableBoxes->size();
+    if (nBoxes > ww8::MAXTABLECELLS)
+        nBoxes = ww8::MAXTABLECELLS;
     
     // sprm header
     m_rWW8Export.InsUInt16( NS_sprm::LN_TDefTable );
 
 MSWordExportBase::MSWordExportBase( SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam )
     : aMainStg(sMainStream), pISet(0), pUsedNumTbl(0), mpTopNodeOfHdFtPage(0),
-    pBmpPal(0), pKeyMap(0), pOLEExp(0), pOCXExp(0), pOleMap(0), 
+    pBmpPal(0), pOLEExp(0), pOCXExp(0), pOleMap(0), 
     mpTableInfo(new ww8::WW8TableInfo()), nUniqueList(0),
     mnHdFtIndex(0), pAktPageDesc(0), pPapPlc(0), pChpPlc(0), pChpIter(0),
     pStyles( NULL ),
 MSWordExportBase::~MSWordExportBase()
 {
     delete pBmpPal;
-    if (pKeyMap)
-        delete[] (NfKeywordTable*)pKeyMap;
     delete pOLEExp;
     delete pOCXExp;
     delete pOleMap;
 #endif
 }
 
+const NfKeywordTable & MSWordExportBase::GetNfKeywordTable()
+{
+    if (pKeyMap.get() == NULL)
+    {
+        pKeyMap.reset(new NfKeywordTable);
+        NfKeywordTable & rKeywordTable = *pKeyMap;
+        rKeywordTable[NF_KEY_D] = ::rtl::OUString::createFromAscii("d");
+        rKeywordTable[NF_KEY_DD] = ::rtl::OUString::createFromAscii("dd");
+        rKeywordTable[NF_KEY_DDD] = ::rtl::OUString::createFromAscii("ddd");
+        rKeywordTable[NF_KEY_DDDD] = ::rtl::OUString::createFromAscii("dddd");
+        rKeywordTable[NF_KEY_M] = ::rtl::OUString::createFromAscii("M");
+        rKeywordTable[NF_KEY_MM] = ::rtl::OUString::createFromAscii("MM");
+        rKeywordTable[NF_KEY_MMM] = ::rtl::OUString::createFromAscii("MMM");
+        rKeywordTable[NF_KEY_MMMM] = ::rtl::OUString::createFromAscii("MMMM");
+        rKeywordTable[NF_KEY_NN] = ::rtl::OUString::createFromAscii("ddd");
+        rKeywordTable[NF_KEY_NNN] = ::rtl::OUString::createFromAscii("dddd");
+        rKeywordTable[NF_KEY_NNNN] = ::rtl::OUString::createFromAscii("dddd");
+        rKeywordTable[NF_KEY_YY] = ::rtl::OUString::createFromAscii("yy");
+        rKeywordTable[NF_KEY_YYYY] = ::rtl::OUString::createFromAscii("yyyy");
+        rKeywordTable[NF_KEY_H] = ::rtl::OUString::createFromAscii("H");
+        rKeywordTable[NF_KEY_HH] = ::rtl::OUString::createFromAscii("HH");
+        rKeywordTable[NF_KEY_MI] = ::rtl::OUString::createFromAscii("m");
+        rKeywordTable[NF_KEY_MMI] = ::rtl::OUString::createFromAscii("mm");
+        rKeywordTable[NF_KEY_S] = ::rtl::OUString::createFromAscii("s");
+        rKeywordTable[NF_KEY_SS] = ::rtl::OUString::createFromAscii("ss");
+        rKeywordTable[NF_KEY_AMPM] = ::rtl::OUString::createFromAscii("AM/PM");
+    }
+
+    return *pKeyMap;
+}
+
 /* vi:set tabstop=4 shiftwidth=4 expandtab: */

sw/source/filter/ww8/wrtww8.hxx

     class MSCodec_Std97;
 }
 
-class SwAttrIter;
+class WW8SwAttrIter;
 class AttributeOutputBase;
 class DocxAttributeOutput;
 class RtfAttributeOutput;
     WW8_WrtBookmarks* pBkmks;
     WW8_WrtRedlineAuthor* pRedlAuthors;
     BitmapPalette* pBmpPal;
-    void* pKeyMap;
+    boost::shared_ptr<NfKeywordTable> pKeyMap;
     SvxMSExportOLEObjects* pOLEExp;
     SwMSConvertControls* pOCXExp;
     WW8OleMaps* pOleMap;
     virtual void ExportDocument_Impl() = 0;
 
     /// Get the next position in the text node to output
-    virtual xub_StrLen GetNextPos( SwAttrIter* pAttrIter, const SwTxtNode& rNode, xub_StrLen nAktPos );
+    virtual xub_StrLen GetNextPos( WW8SwAttrIter* pAttrIter, const SwTxtNode& rNode, xub_StrLen nAktPos );
 
     /// Update the information for GetNextPos().
-    virtual void UpdatePosition( SwAttrIter* pAttrIter, xub_StrLen nAktPos, xub_StrLen nEnd );
+    virtual void UpdatePosition( WW8SwAttrIter* pAttrIter, xub_StrLen nAktPos, xub_StrLen nEnd );
 
     /// Output SwTxtNode
     void OutputTextNode( const SwTxtNode& );
     bool GetBookmarks( const SwTxtNode& rNd, xub_StrLen nStt, xub_StrLen nEnd,
             IMarkVector& rArr );
 
+    const NfKeywordTable & GetNfKeywordTable();
+
 public:
     MSWordExportBase( SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam );
     virtual ~MSWordExportBase();

sw/source/filter/ww8/ww8atr.cxx

     //section.
     bool bBreakSet = false;
 
+    const SwPageDesc * pPageDesc = rNd.FindPageDesc(sal_False);
+	
+    if (pAktPageDesc != pPageDesc)
+    {
+        bBreakSet = true;
+        bNewPageDesc = true;
+        pAktPageDesc = pPageDesc;
+    }
+
     if ( pSet && pSet->Count() )
     {
-        if ( SFX_ITEM_SET == pSet->GetItemState( RES_PAGEDESC, false, &pItem )
-             && ( (SwFmtPageDesc*)pItem )->KnowsPageDesc() )
+        if ( SFX_ITEM_SET == pSet->GetItemState( RES_PAGEDESC, false, &pItem ) && 
+             dynamic_cast<const SwFmtPageDesc*>(pItem)->GetRegisteredIn() != NULL)
         {
             bBreakSet = true;
             bNewPageDesc = true;
     const SvNumberformat* pNumFmt = pNFmtr->GetEntry( nFmtIdx );
     if( pNumFmt )
     {
-        //sal_uInt16 nLng = rFld.GetLanguage();
-        LocaleDataWrapper aLocDat( pNFmtr->GetServiceManager(),
-            MsLangId::convertLanguageToLocale( LANGUAGE_ENGLISH_US ) );
-
-        if( !pKeyMap )
-        {
-            pKeyMap = new NfKeywordTable;
-            NfKeywordTable& rKeyMap = *(NfKeywordTable*)pKeyMap;
-            pNFmtr->FillKeywordTable( rKeyMap, LANGUAGE_ENGLISH_US );
-        }
-
-        String sFmt(pNumFmt->GetMappedFormatstring(*(NfKeywordTable*)pKeyMap,
+        sal_uInt16 nLng = rFld.GetLanguage();
+        LocaleDataWrapper aLocDat(pNFmtr->GetServiceManager(),
+                                  MsLangId::convertLanguageToLocale(nLng));
+
+        String sFmt(pNumFmt->GetMappedFormatstring(GetNfKeywordTable(),
             aLocDat));
+
         if (sFmt.Len())
         {
             sw::ms::SwapQuotesInField(sFmt);

sw/source/filter/xml/swxml.cxx

         }
     }
 
-    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"

sw/source/filter/xml/xmlbrshi.hxx

  *
  ************************************************************************/
 
-#ifndef _XMLBRSHI_HXX
-#define _XMLBRSHI_HXX
+#ifndef SW_XMLBRSHI_HXX
+#define SW_XMLBRSHI_HXX
+
+#include <com/sun/star/io/XOutputStream.hpp>
+
+#include <xmloff/xmlictxt.hxx>
 
 class SvXMLImport;
 class SvXMLUnitConverter;

sw/source/filter/xml/xmlimp.cxx

         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

sw/source/filter/xml/xmlimp.hxx

  *
  ************************************************************************/
 
-#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;
 
 	inline const SvXMLUnitConverter& GetTwipUnitConverter() const;
 	inline const SvXMLImportItemMapper& GetTableItemMapper() const;
+    inline       SvXMLImportItemMapper& GetTableItemMapper();
 	SvXMLImportContext *CreateTableItemImportContext( sal_uInt16 nPrefix,
 				const ::rtl::OUString& rLocalName,
 				const ::com::sun::star::uno::Reference<
 
     // 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
 	return *pTableItemMapper;
 }
 
+inline       SvXMLImportItemMapper& SwXMLImport::GetTableItemMapper()
+{
+    return *pTableItemMapper;
+}
+
 inline void SwXMLImport::SetProgressValue( sal_Int32 nValue )
 {
 	if ( bShowProgress ) 

sw/source/filter/xml/xmlimpit.cxx

 {
 }
 
+void
+SvXMLImportItemMapper::setMapEntries( SvXMLItemMapEntriesRef rMapEntries )
+{
+	mrMapEntries = rMapEntries;
+}
+
 /** fills the given itemset with the attributes in the given list */
 void SvXMLImportItemMapper::importXML( SfxItemSet& rSet,
 									  uno::Reference< xml::sax::XAttributeList > xAttrList,
 									  const SvXMLUnitConverter& rUnitConverter,
-	 								  const SvXMLNamespaceMap& rNamespaceMap ) const
+                                      const SvXMLNamespaceMap& rNamespaceMap )
 {
 	sal_Int16 nAttr = xAttrList->getLength();
 
 		delete pUnknownItem;
 	}
 
-	finished( rSet );
+    finished(rSet, rUnitConverter);
 }
 
 /** this method is called for every item that has the
 											SfxItemSet& /*rSet*/,
 											const OUString& /*rValue*/,
 											const SvXMLUnitConverter& /*rUnitConverter*/,
-											const SvXMLNamespaceMap& /*rNamespaceMap*/ ) const
+                                            const SvXMLNamespaceMap& /*rNamespaceMap*/ )
 {
 	DBG_ERROR( "unsuported special item in xml import" );
 	return sal_False;
 										   SfxItemSet& /*rSet*/,
 										   const OUString& /*rValue*/,
 										   const SvXMLUnitConverter& /*rUnitConverter*/,
-										   const SvXMLNamespaceMap& /*rNamespaceMap*/ ) const
+                                           const SvXMLNamespaceMap& /*rNamespaceMap*/ )
 {
 	DBG_ERROR( "unsuported no item in xml import" );
 	return sal_False;
 }
 
-void SvXMLImportItemMapper::finished( SfxItemSet& ) const
+void
+SvXMLImportItemMapper::finished(SfxItemSet &, SvXMLUnitConverter const&) const
 {
 	// nothing to do here
 }

sw/source/filter/xml/xmlimpit.hxx

 	void importXML( SfxItemSet& rSet,
 					::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > xAttrList,
 					const SvXMLUnitConverter& rUnitConverter,
-					const SvXMLNamespaceMap& rNamespaceMap ) const;
+                    const SvXMLNamespaceMap& rNamespaceMap );
 
 	/** this method is called for every item that has the
 		MID_SW_FLAG_SPECIAL_ITEM_IMPORT flag set */
 									SfxItemSet& rSet,
 									const ::rtl::OUString& rValue,
 									const SvXMLUnitConverter& rUnitConverter,
-									const SvXMLNamespaceMap& rNamespaceMap ) const;
+                                    const SvXMLNamespaceMap& rNamespaceMap );
 
 	/** this method is called for every item that has the
 		MID_SW_FLAG_NO_ITEM_IMPORT flag set */
 							   SfxItemSet& rSet,
 							   const ::rtl::OUString& rValue,
 							   const SvXMLUnitConverter& rUnitConverter,
-							   const SvXMLNamespaceMap& rNamespaceMap ) const;
+                               const SvXMLNamespaceMap& rNamespaceMap );
 
 	/** This method is called when all attributes have benn processed. It
 	  * may be used to remove items that are incomplete */
-	virtual void finished( SfxItemSet& rSet ) const;
+    virtual void finished(SfxItemSet & rSet,
+                          SvXMLUnitConverter const& rUnitConverter) const;
 
-	inline void setMapEntries( SvXMLItemMapEntriesRef rMapEntries );
+    virtual void setMapEntries( SvXMLItemMapEntriesRef rMapEntries );
 	inline SvXMLItemMapEntriesRef getMapEntries() const;
 
 
         const SvXMLUnitConverter& rUnitConverter );
 };
 
-inline void
-SvXMLImportItemMapper::setMapEntries( SvXMLItemMapEntriesRef rMapEntries )
-{
-	mrMapEntries = rMapEntries;
-}
-
 inline SvXMLItemMapEntriesRef
 SvXMLImportItemMapper::getMapEntries() const
 {

sw/source/filter/xml/xmlitem.cxx

 										  const OUString& rLName,
 										  const uno::Reference< xml::sax::XAttributeList >& xAttrList,
 										  SfxItemSet& rISet,
-										  const SvXMLImportItemMapper& rIMap,
+                                          SvXMLImportItemMapper& rIMap,
 										  const SvXMLUnitConverter& rUnitConverter ):
 	SvXMLImportContext( rImp, nPrfx, rLName ),
 	rItemSet( rISet ),
 	rIMapper( rIMap ),
 	rUnitConv( rUnitConverter )
-
 {
-	rIMapper.importXML( rItemSet, xAttrList, rUnitConv,
+    rIMap.importXML( rItemSet, xAttrList, rUnitConv,
 			   			GetImport().GetNamespaceMap() );
 }
 

sw/source/filter/xml/xmlitem.hxx

 						 const ::rtl::OUString& rLName,
 						 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList,
 						 SfxItemSet&  rItemSet,
-						 const SvXMLImportItemMapper& rIMappper,
+                         SvXMLImportItemMapper& rIMap,
 						 const SvXMLUnitConverter& rUnitConv );
 
 	virtual ~SvXMLItemSetContext();

sw/source/filter/xml/xmlitemi.cxx

 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_sw.hxx"
 
+#include <rtl/ustring.hxx>
 
+#include <rsc/rscsfx.hxx>
 
-#include <hintids.hxx>
-#include <rtl/ustring.hxx>
-#include <rsc/rscsfx.hxx>
-#include "xmlitmap.hxx"
-#include "xmlimpit.hxx"
-#include "xmlitem.hxx"
 #include <xmloff/i18nmap.hxx>
 #include <xmloff/xmluconv.hxx>
-#ifndef _XMLOFF_FAMILIES_HXX
 #include <xmloff/families.hxx>
-#endif
-#include <svx/unomid.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/xmltoken.hxx>
+
 #include <editeng/boxitem.hxx>
 #include <editeng/fontitem.hxx>
 #include <editeng/tstpitem.hxx>
 #include <editeng/boxitem.hxx>
 #include <editeng/brshitem.hxx>
 #include <editeng/langitem.hxx>
+#include <editeng/memberids.hrc>
 
-#ifndef _XMLOFF_XMLTABI_HXX
-//#include <xmloff/xmltabi.hxx>
-#endif
-#include "xmlbrshi.hxx"
+#include <svx/unomid.hxx>
+
+#include <hintids.hxx>
 #include <paratr.hxx>
 #include <doc.hxx>
-#ifndef _UNOMID_H
 #include <unomid.h>
-#endif
+#include "xmlbrshi.hxx"
 #include "xmlimp.hxx"
+#include "xmlitmap.hxx"
+#include "xmlimpit.hxx"
+#include "xmlitem.hxx"
 
 using ::rtl::OUString;
 using namespace ::com::sun::star;
 								SfxItemSet& rSet,
 								const OUString& rValue,
 								const SvXMLUnitConverter& rUnitConverter,
-								const SvXMLNamespaceMap& rNamespaceMap ) const;
-	virtual void finished( SfxItemSet& rSet ) const;
+                                const SvXMLNamespaceMap& rNamespaceMap );
+
+    virtual sal_Bool
+    handleNoItem(SvXMLItemMapEntry const& rEntry,
+                 SfxItemSet & rSet,
+                 ::rtl::OUString const& rValue,
+                 SvXMLUnitConverter const& rUnitConverter,
+                 SvXMLNamespaceMap const& rNamespaceMap);
+
+    virtual void finished(SfxItemSet & rSet,
+                          SvXMLUnitConverter const& rUnitConverter) const;
+
+    virtual void setMapEntries( SvXMLItemMapEntriesRef rMapEntries );
+
+private:
+    void Reset();
+
+    ::rtl::OUString m_FoMarginValue;
+    enum { LEFT = 0, RIGHT = 1, TOP = 2, BOTTOM = 3 };
+    bool m_bHaveMargin[4];
 };
 
 SwXMLImportTableItemMapper_Impl::SwXMLImportTableItemMapper_Impl(
 										SvXMLItemMapEntriesRef rMapEntries ) :
 	SvXMLImportItemMapper( rMapEntries, RES_UNKNOWNATR_CONTAINER)
 {
+    Reset();
 }
 
 SwXMLImportTableItemMapper_Impl::~SwXMLImportTableItemMapper_Impl()
 {
 }
 
+void SwXMLImportTableItemMapper_Impl::Reset()
+{
+    m_FoMarginValue = ::rtl::OUString();
+    for (int i = 0; i < 3; ++i)
+    {
+        m_bHaveMargin[i] = false;
+    }
+}
+
+void SwXMLImportTableItemMapper_Impl::setMapEntries(
+        SvXMLItemMapEntriesRef rMapEntries )
+{
+    Reset();
+    SvXMLImportItemMapper::setMapEntries(rMapEntries);
+}
+
 sal_Bool SwXMLImportTableItemMapper_Impl::handleSpecialItem(
 										const SvXMLItemMapEntry& rEntry,
 										SfxPoolItem& rItem,
 										SfxItemSet& rItemSet,
 										const OUString& rValue,
 										const SvXMLUnitConverter& rUnitConv,
-										const SvXMLNamespaceMap& ) const
+                                        const SvXMLNamespaceMap& )
 {
 	sal_Bool bRet = sal_False;
     sal_uInt16 nMemberId = static_cast< sal_Int16 >(rEntry.nMemberId & MID_SW_FLAG_MASK);
 	switch( rItem.Which() )
 	{
+    case RES_LR_SPACE:
+        switch (nMemberId)
+        {
+            case MID_L_MARGIN:
+                m_bHaveMargin[LEFT] = true;
+                break;
+            case MID_R_MARGIN:
+                m_bHaveMargin[RIGHT] = true;
+                break;
+        }
+        bRet = SvXMLImportItemMapper::PutXMLValue(
+                rItem, rValue, nMemberId, rUnitConv);
+        break;
+    case RES_UL_SPACE:
+        switch (nMemberId)
+        {
+            case MID_UP_MARGIN:
+                m_bHaveMargin[TOP] = true;
+                break;
+            case MID_LO_MARGIN:
+                m_bHaveMargin[BOTTOM] = true;
+                break;
+        }
+        bRet = SvXMLImportItemMapper::PutXMLValue(
+                rItem, rValue, nMemberId, rUnitConv);
+        break;
 	case RES_FRM_SIZE:
 		switch( nMemberId )
 		{
 	return bRet;
 }
 
-void SwXMLImportTableItemMapper_Impl::finished( SfxItemSet& /*rSet*/ ) const
+
+sal_Bool SwXMLImportTableItemMapper_Impl::handleNoItem(
+     SvXMLItemMapEntry const& rEntry,
+     SfxItemSet & rSet,
+     ::rtl::OUString const& rValue,
+     SvXMLUnitConverter const& rUnitConverter,
+     SvXMLNamespaceMap const& rNamespaceMap)
 {
+    if ((XML_NAMESPACE_FO == rEntry.nNameSpace) &&
+        (xmloff::token::XML_MARGIN == rEntry.eLocalName))
+    {
+        m_FoMarginValue = rValue;
+        return true;
+    }
+    else
+    {
+        return SvXMLImportItemMapper::handleNoItem(
+                rEntry, rSet, rValue, rUnitConverter, rNamespaceMap);
+    }
+}
+
+void SwXMLImportTableItemMapper_Impl::finished(
+        SfxItemSet & rSet, SvXMLUnitConverter const& rUnitConverter) const
+{
+    if (m_FoMarginValue.getLength())
+    {
+        sal_uInt16 const Ids[4][2] = {
+            { RES_LR_SPACE, MID_L_MARGIN },
+            { RES_LR_SPACE, MID_R_MARGIN },
+            { RES_UL_SPACE, MID_UP_MARGIN },
+            { RES_UL_SPACE, MID_LO_MARGIN },
+        };
+        for (int i = 0; i < 4; ++i)
+        {
+            if (m_bHaveMargin[i])
+            {
+                continue; // already read fo:margin-top etc.
+            }
+            // first get item from itemset
+            SfxPoolItem const* pItem = 0;
+            SfxItemState eState =
+                rSet.GetItemState(Ids[i][0], sal_True, &pItem);
+
+            // if not set, try the pool
+            if ((SFX_ITEM_SET != eState) && (SFX_WHICH_MAX > Ids[i][0]))
+            {
+                pItem = &rSet.GetPool()->GetDefaultItem(Ids[i][0]);
+            }
+
+            // do we have an item?
+            if (eState >= SFX_ITEM_DEFAULT && pItem)
+            {
+                SfxPoolItem *const pNewItem = pItem->Clone();
+                bool const bPut = PutXMLValue(
+                        *pNewItem, m_FoMarginValue, Ids[i][1], rUnitConverter);
+                if (bPut)
+                {
+                    rSet.Put(*pNewItem);
+                }
+            }
+            else
+            {
+                OSL_ENSURE(false, "could not get item");
+            }
+        }
+    }
 }
 
 // ---------------------------------------------------------------------
 				  const OUString& rLName,
 				  const Reference< xml::sax::XAttributeList > & xAttrList,
 				  SfxItemSet&  rItemSet,
-				  const SvXMLImportItemMapper& rIMapper,
+                  SvXMLImportItemMapper & rIMapper,
 				  const SvXMLUnitConverter& rUnitConv );
 	virtual ~SwXMLItemSetContext_Impl();
 
 				 const OUString& rLName,
 				 const Reference< xml::sax::XAttributeList > & xAttrList,
 				 SfxItemSet&  _rItemSet,
-				 const SvXMLImportItemMapper& _rIMapper,
+                 SvXMLImportItemMapper & _rIMapper,
 				 const SvXMLUnitConverter& _rUnitConv ) :
 	SvXMLItemSetContext( rImport, nPrfx, rLName, xAttrList,
 					     _rItemSet, _rIMapper, _rUnitConv )

sw/source/filter/xml/xmlitemm.cxx

 	{ XML_NAMESPACE_##p, XML_##l, w, MID_SW_FLAG_SPECIAL_ITEM_IMPORT|m }
 #define M_E_SE( p, l, w, m ) \
 	{ XML_NAMESPACE_##p, XML_##l, w, MID_SW_FLAG_SPECIAL_ITEM_EXPORT|m }
+#define M_E_SIE( p, l, w, m ) \
+    { XML_NAMESPACE_##p, XML_##l, w, MID_SW_FLAG_SPECIAL_ITEM_EXPORT|MID_SW_FLAG_SPECIAL_ITEM_IMPORT|m }
 
 #define M_END { 0, XML_TOKEN_INVALID, 0, 0 }
 
 	// RES_PAPER_BIN
 	// not required
 	// TODO: RES_LR_SPACE
-	M_E_SE( FO,	MARGIN_LEFT,		RES_LR_SPACE,	MID_L_MARGIN ),
-	M_E_SE( FO,	MARGIN_RIGHT,		RES_LR_SPACE,	MID_R_MARGIN ),
+    M_E_SE( FO,     MARGIN,             -1,     MID_SW_FLAG_NO_ITEM_IMPORT),
+    M_E_SIE( FO,    MARGIN_LEFT,        RES_LR_SPACE,   MID_L_MARGIN ),
+    M_E_SIE( FO,    MARGIN_RIGHT,       RES_LR_SPACE,   MID_R_MARGIN ),
 	// RES_UL_SPACE
-    MAP_ENTRY( FO,   MARGIN_TOP,         RES_UL_SPACE,   MID_UP_MARGIN ),
-    MAP_ENTRY( FO,   MARGIN_BOTTOM,      RES_UL_SPACE,   MID_LO_MARGIN ),
+    M_E_SI( FO,     MARGIN_TOP,         RES_UL_SPACE,   MID_UP_MARGIN ),
+    M_E_SI( FO,     MARGIN_BOTTOM,      RES_UL_SPACE,   MID_LO_MARGIN ),
 	// RES_PAGEDESC
     MAP_ENTRY( STYLE,    PAGE_NUMBER,        RES_PAGEDESC,   MID_PAGEDESC_PAGENUMOFFSET),
 	// RES_BREAK

sw/source/filter/xml/xmlmeta.cxx

 
 // ---------------------------------------------------------------------
 
+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,

sw/source/ui/docvw/AnnotationWin.cxx

 {
     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();

sw/source/ui/index/idxmrk.src

 	#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
 {

sw/source/ui/ribbar/inputwin.cxx

         {
             SW_MOD()->GetUndoOptions().SetUndoCount(0);
         }
+        m_bResetUndo = false; // #i117122# once is enough :)
     }
 }
 

unoxml/qa/complex/unoxml/RDFRepositoryTest.java

 
             try {
                 xRep.createGraph(foo);
-                assertFalse("creating duplicate graph was allowed", false);
+                fail("creating duplicate graph was allowed");
             } catch (ElementExistException e) {
                 // ignore
             }
 
             try {
                 xRep.createGraph(null);
-                assertFalse("invalid graph name was allowed", false);
+                fail("invalid graph name was allowed");
             } catch (IllegalArgumentException e) {
                 // ignore
             }
             xFooIn = new StreamSimulator(tempDir + "foo.rdf", true, param);
             try {
                 xRep.importGraph(FileFormat.RDF_XML, xFooIn, bar, base);
-                assertFalse("importing existing graph did not fail", false);
+                fail("importing existing graph did not fail");
             } catch (ElementExistException e) {
                 // ignore
             }
 
             try {
                 xBazGraph.clear();
-                assertFalse("deleted graph not invalid (clear)", false);
+                fail("deleted graph not invalid (clear)");
             } catch (NoSuchElementException e) {
                 // ignore
             }
 
             try {
                 xBazGraph.addStatement(foo, foo, foo);
-                assertFalse("deleted graph not invalid (add)", false);
+                fail("deleted graph not invalid (add)");
             } catch (NoSuchElementException e) {
                 // ignore
             }
 
             try {
                 xBazGraph.removeStatements(null, null, null);
-                assertFalse("deleted graph not invalid (remove)", false);
+                fail("deleted graph not invalid (remove)");
             } catch (NoSuchElementException e) {
                 // ignore
             }
 
             try {
                 xBazGraph.getStatements(null, null, null);
-                assertFalse("deleted graph not invalid (get)", false);
+                fail("deleted graph not invalid (get)");
             } catch (NoSuchElementException e) {
                 // ignore
             }