[Libreoffice-commits] core.git: sw/qa sw/source

Justin Luth (via logerrit) logerrit at kemper.freedesktop.org
Fri Apr 16 06:27:34 UTC 2021


 sw/qa/extras/ooxmlexport/data/tdf134951_duplicates.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport16.cxx             |    9 +++++++++
 sw/qa/extras/ooxmlexport/ooxmlexport5.cxx              |    4 ++++
 sw/source/filter/ww8/wrtw8nds.cxx                      |   11 +++++++++--
 sw/source/filter/ww8/wrtww8.hxx                        |    2 +-
 5 files changed, 23 insertions(+), 3 deletions(-)

New commits:
commit deb892628a1501527c8c41b85a65282df95b81b1
Author:     Justin Luth <justin_luth at sil.org>
AuthorDate: Thu Apr 15 14:55:56 2021 +0200
Commit:     Justin Luth <justin_luth at sil.org>
CommitDate: Fri Apr 16 08:26:50 2021 +0200

    tdf#134951 docxexport: stop duplicating stuff in postponed text
    
    Certain attributes like comments, fields, and footnotes
    should not be duplicated when a character run is split
    by the bPostponeWritingText hack.
    
    Only DOCX PostponesWritingText.
    
    The comment-with-range is still not perfect,
    but at least it is not fully duplicated.
    Best would be to just get rid of the hack?
    
    A few more items suggested themselves as belonging
    to this list, but I don't really know what they are,
    and no instances of them in this position were found
    in the existing unit tests. So I just left them as a
    commented possibility.
    
    Change-Id: I950c4250b5f7ed62d63eeff71cabaa10b67dca5f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114148
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <justin_luth at sil.org>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf134951_duplicates.odt b/sw/qa/extras/ooxmlexport/data/tdf134951_duplicates.odt
new file mode 100644
index 000000000000..53c7076b3eeb
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf134951_duplicates.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
index c272a5878ff6..ee982194ff19 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
@@ -16,6 +16,7 @@
 
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/drawing/FillStyle.hpp>
+#include <com/sun/star/text/XEndnotesSupplier.hpp>
 #include <com/sun/star/text/XFootnotesSupplier.hpp>
 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
 #include <com/sun/star/text/XTextTable.hpp>
@@ -146,6 +147,14 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf134619_numberingProps, "tdf134619_num
     CPPUNIT_ASSERT_EQUAL(72.f, getProperty<float>(xStyle, "CharHeight"));
 }
 
+DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf134951_duplicates, "tdf134951_duplicates.odt")
+{
+    uno::Reference<text::XEndnotesSupplier> xEndnotesSupplier(mxComponent, uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xEndnotesSupplier->getEndnotes()->getCount());
+
+    getParagraph(5, "Duplicate fields: 1");
+}
+
 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf135773_numberingShading, "tdf135774_numberingShading.docx")
 {
     // This test uses preTest to export CharBackground as Highlight instead of the 7.0 default of Shading.
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
index 404db9c59ef9..98ba668c7231 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
@@ -131,6 +131,10 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testfdo79008, "fdo79008.docx")
      */
     parseExport("word/document.xml");
 
+    // tdf#134951: there is only one comment
+    xmlDocUniquePtr pXmlSettings = parseExport("word/comments.xml");
+    assertXPath(pXmlSettings, "/w:comments/w:comment", 1);
+
     // Read-only is set, but it is not enforced, so it should be off...
     SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
     CPPUNIT_ASSERT(pTextDoc);
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index 729c8dc0db97..5f96377e7d2c 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -395,7 +395,7 @@ sal_Int32 SwWW8AttrIter::SearchNext( sal_Int32 nStartPos )
     return nMinPos;
 }
 
-void SwWW8AttrIter::OutAttr( sal_Int32 nSwPos, bool bWriteCombChars)
+void SwWW8AttrIter::OutAttr(sal_Int32 nSwPos, bool bWriteCombChars, bool bPostponeSingleUse)
 {
     m_rExport.AttrOutput().RTLAndCJKState( mbCharIsRTL, GetScript() );
 
@@ -460,6 +460,13 @@ void SwWW8AttrIter::OutAttr( sal_Int32 nSwPos, bool bWriteCombChars)
                         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()));
             }
@@ -2613,7 +2620,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 );
+                aAttrIter.OutAttr(nCurrentPos, false, bPostponeWritingText);
                 AttrOutput().EndRunProperties( pRedlineData );
             }
 
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index 66c4573dc96a..1c4c3e936d82 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -1538,7 +1538,7 @@ public:
 
     void NextPos() { if ( nCurrentSwPos < SAL_MAX_INT32 ) nCurrentSwPos = SearchNext( nCurrentSwPos + 1 ); }
 
-    void OutAttr( sal_Int32 nSwPos, bool bWriteCombinedChars );
+    void OutAttr(sal_Int32 nSwPos, bool bWriteCombinedChars, bool bPostponeSingleUse = false);
     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);


More information about the Libreoffice-commits mailing list