sw/source/filter/ww8/wrtw8nds.cxx |   14 ++++----------
 sw/source/filter/ww8/wrtww8.hxx   |    2 +-
 2 files changed, 5 insertions(+), 11 deletions(-)

New commits:
commit f261fae4af72b1328bc3e93fc52a9a24ce0975b3
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Thu Jan 13 14:14:44 2022 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Thu Jan 13 19:09:26 2022 +0100

    tdf#143039 tdf#143106 sw: DOCX export: don't export duplicate flys
    
    The problem is that at the end of the paragraph a second call to
    OutFlys() is made in line 2730 and that causes the duplication; for
    this call the value FLY_POSTPONED must be returned, not FLY_NONE.
    
    (regression from 3eced2d52415abeac266804ab682bee022322a19)
    
    Also revert commit deb892628a1501527c8c41b85a65282df95b81b1 because its
    test fails now as 0 comments are exported; it was apparently another
    problem introduced by the above commit, and apparently this fix helps
    for duplication of comments too.
    
    Change-Id: Ib9706e4c24db38c15a0170ba2e8f08fba5327f98
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128386
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sw/source/filter/ww8/wrtw8nds.cxx 
b/sw/source/filter/ww8/wrtw8nds.cxx
index bf6e6fb2ea3d..2cd392279f01 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -394,7 +394,7 @@ sal_Int32 SwWW8AttrIter::SearchNext( sal_Int32 nStartPos )
     return nMinPos;
 }
 
-void SwWW8AttrIter::OutAttr(sal_Int32 nSwPos, bool bWriteCombChars, bool 
bPostponeSingleUse)
+void SwWW8AttrIter::OutAttr(sal_Int32 nSwPos, bool bWriteCombChars)
 {
     m_rExport.AttrOutput().RTLAndCJKState( mbCharIsRTL, GetScript() );
 
@@ -458,13 +458,6 @@ void SwWW8AttrIter::OutAttr(sal_Int32 nSwPos, bool 
bWriteCombChars, bool bPostpo
                         nWhichId = aIter.NextWhich();
                     }
                 }
-                else if (bPostponeSingleUse &&
-                         (nWhich == RES_TXTATR_FTN || nWhich == 
RES_TXTATR_ANNOTATION || nWhich == RES_TXTATR_FIELD))
-                {
-                    // Do not duplicate these multiple times when the 
character run is split.
-                    // Skip this time - it will be attempted later.
-                    // ?? also RES_TXTATR_REFMARK: RES_TXTATR_TOXMARK: 
RES_TXTATR_META: RES_TXTATR_METAFIELD: ??
-                }
                 else
                     aRangeItems[nWhich] = (&(pHt->GetAttr()));
             }
@@ -717,7 +710,8 @@ FlyProcessingState SwWW8AttrIter::OutFlys(sal_Int32 nSwPos)
 
     if (maFlyIter == maFlyFrames.end())
     {
-        return FLY_NONE;
+        // tdf#143039 postponed prevents fly duplication at end of paragraph
+        return m_rExport.AttrOutput().IsFlyProcessingPostponed() ? 
FLY_POSTPONED : FLY_NONE;
     }
 
     /*
@@ -2655,7 +2649,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
                 // Output the character attributes
                 // #i51277# do this before writing flys at end of paragraph
                 AttrOutput().StartRunProperties();
-                aAttrIter.OutAttr(nCurrentPos, false, bPostponeWritingText);
+                aAttrIter.OutAttr(nCurrentPos, false);
                 AttrOutput().EndRunProperties( pRedlineData );
             }
 
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index bd960da05d7a..4df6d5c24fe8 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -1542,7 +1542,7 @@ public:
 
     void NextPos() { if ( nCurrentSwPos < SAL_MAX_INT32 ) nCurrentSwPos = 
SearchNext( nCurrentSwPos + 1 ); }
 
-    void OutAttr(sal_Int32 nSwPos, bool bWriteCombinedChars, bool 
bPostponeSingleUse = false);
+    void OutAttr(sal_Int32 nSwPos, bool bWriteCombinedChars);
     virtual const SfxPoolItem* HasTextItem( sal_uInt16 nWhich ) const override;
     virtual const SfxPoolItem& GetItem( sal_uInt16 nWhich ) const override;
     int OutAttrWithRange(const SwTextNode& rNode, sal_Int32 nPos);

Reply via email to