sw/qa/extras/ww8export/ww8export3.cxx |    5 ++---
 sw/source/filter/ww8/ww8atr.cxx       |    6 ++++--
 2 files changed, 6 insertions(+), 5 deletions(-)

New commits:
commit daef39352b008fc1f903fd8c09288ff5e772fa42
Author:     Justin Luth <justin_l...@sil.org>
AuthorDate: Wed Mar 9 12:31:14 2022 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Fri Apr 1 14:10:30 2022 +0200

    tdf#147861 ww8export: DI_CUSTOM write fixed field, not plain txt
    
    It looks like we just punt on fields, and try to avoid
    round-tripping them as much as possible. And for good reason
    since they are tough and poorly handled.
    
    But since import of DI_CUSTOM has improved for DOC,
    it would be nice to be able to round-trip it as well,
    so that is what this allows.
    It also opens the door to round-trip more field
    situations as well.
    
    This patch depends on the earlier related patch
    that removes " (fixed)" from the FieldName.
    
    RTF and DOCX also export OK, but import needs some love.
    
    (cherry picked from commit 7974d5ef1446f106a5f7c45b76ea2728fe4b18ce)
    
    Change-Id: I32d9aa1fea12763cc30a79bcfa6d1d1e19d2c619
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132399
    Tested-by: Miklos Vajna <vmik...@collabora.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/qa/extras/ww8export/ww8export3.cxx 
b/sw/qa/extras/ww8export/ww8export3.cxx
index e798a8cf66b6..80f0daf11f93 100644
--- a/sw/qa/extras/ww8export/ww8export3.cxx
+++ b/sw/qa/extras/ww8export/ww8export3.cxx
@@ -107,15 +107,14 @@ DECLARE_WW8EXPORT_TEST(testTdf147861_customField, 
"tdf147861_customField.doc")
     getParagraph(2, " INSERT Custom Title here"); // matches current 
DocProperty
     getParagraph(3, "My Title"); // edited
 
-    if (mbExported)
-        return;
-
     // Verify that these are fields, and not just plain text
     uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, 
uno::UNO_QUERY);
     auto xFieldsAccess(xTextFieldsSupplier->getTextFields());
     uno::Reference<container::XEnumeration> 
xFields(xFieldsAccess->createEnumeration());
     uno::Reference<text::XTextField> xField(xFields->nextElement(), 
uno::UNO_QUERY);
     CPPUNIT_ASSERT_EQUAL(OUString("CustomEditedTitle"), 
xField->getPresentation(false));
+    // The " (fixed)" part is unnecessary, but it must be consistent across a 
round-trip
+    CPPUNIT_ASSERT_EQUAL(OUString("DocInformation:Title (fixed)"), 
xField->getPresentation(true));
 }
 
 DECLARE_WW8EXPORT_TEST(testTdf138345_paraCharHighlight, 
"tdf138345_paraCharHighlight.doc")
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 4dba4eaed63e..6a0e38eb6677 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -2916,7 +2916,7 @@ void AttributeOutputBase::TextField( const SwFormatField& 
rField )
     case SwFieldIds::DocInfo:    // Last printed, last edited,...
         if( DI_SUB_FIXED & nSubType )
             bWriteExpand = true;
-        else
+
         {
             OUString sStr;
             ww::eField eField(ww::eNONE);
@@ -2971,13 +2971,15 @@ void AttributeOutputBase::TextField( const 
SwFormatField& rField )
 
                         if (pDocInfoField != nullptr)
                             sStr = "\"" + pDocInfoField->GetName() + "\"";
+
+                        bWriteExpand = false;
                     }
                     break;
                 default:
                     break;
             }
 
-            if (eField != ww::eNONE)
+            if (!bWriteExpand && eField != ww::eNONE)
             {
                 GetExport().OutputField(pField, eField, FieldString(eField) + 
sStr);
             }

Reply via email to