Commits

Michael Stahl  committed 7a64be9

sw34bf04: #i89751#: SwDoc::ResetAttrs: fix autoformat regression:
replace old and broken para attr to hint conversion with call to FmtToTxtAttr

  • Participants
  • Parent commits 96bf77a

Comments (0)

Files changed (1)

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