[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - sw/source writerfilter/source

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Sat Dec 21 09:08:10 UTC 2019


 sw/source/filter/ww8/ww8par5.cxx                  |    2 ++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   13 ++++++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

New commits:
commit 821a6d4ed6423b5e07c6add33c74fb75757ef338
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Wed Dec 18 18:08:23 2019 +0100
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Sat Dec 21 10:07:08 2019 +0100

    tdf#129247 writerfilter,sw: improve handling of CONTROL fields
    
    The "CONTROL Forms.CheckBox.1" field has a shape as its result.
    
    Previously this was imported as an unknown generic field by writerfilter
    and exported as a CONTROL field followed by a SHAPE field; the CONTROL
    field was discarded by Writer on a subsequent import.
    
    Now this is exported as nested fields to WW8, i.e., SHAPE inside the
    result of CONTROL, which is an improvement.
    
    Unfortunately the WW8 import discards the result of the CONTROL field,
    because its field code is written as ww::eUNKNOWN = 1, not
    ww::eCONTROL = 87.
    
    To fix that, set the ODF_ID_PARAM parameter in writerfilter for these
    fields, which is checked in MSWordExportBase::OutputTextNode().
    
    This reveals that the field code was set wrongly on the fieldmark too,
    it should be set as a ODF_CODE_PARAM parameter and not as the type.
    
    Furthermore the WW8 import needs to allow nested fields in the eCONTROL
    field.
    
    Change-Id: If79a186ea30c3b4a933ba1d8325111215250b833
    Reviewed-on: https://gerrit.libreoffice.org/85418
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>
    Tested-by: Michael Stahl <michael.stahl at cib.de>
    (cherry picked from commit 27b6c82b79f4af2ab16d53de3b2065df0acebdb8)
    Reviewed-on: https://gerrit.libreoffice.org/85527
    Tested-by: Jenkins
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index ea0a435371a3..694782a1e1ed 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -715,6 +715,8 @@ static bool AcceptableNestedField(sal_uInt16 nFieldCode)
         // Accept AutoTextList field as nested field.
         // Thus, the field result is imported as plain text.
         case ww::eAUTOTEXTLIST:
+        // tdf#129247 CONTROL contains a nested SHAPE field in the result
+        case ww::eCONTROL:
             return true;
         default:
             return false;
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index dd4a7a2e599b..2b48e0342bbd 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -75,6 +75,7 @@
 #include <editeng/unotext.hxx>
 #include <o3tl/temporary.hxx>
 #include <oox/mathml/import.hxx>
+#include <xmloff/odffields.hxx>
 #include <rtl/uri.hxx>
 #include "GraphicHelpers.hxx"
 #include <dmapper/GraphicZOrderHelper.hxx>
@@ -5285,9 +5286,19 @@ void DomainMapper_Impl::CloseFieldCommand()
                     uno::Reference<text::XFormField> const xFormField(xFieldInterface, uno::UNO_QUERY);
                     InsertFieldmark(m_aTextAppendStack, xFormField, pContext->GetStartRange(),
                             pContext->GetFieldId());
-                    xFormField->setFieldType(aCode);
+                    xFormField->setFieldType(ODF_UNHANDLED);
                     m_bStartGenericField = true;
                     pContext->SetFormField( xFormField );
+                    uno::Reference<container::XNameContainer> const xNameCont(xFormField->getParameters());
+                    // note: setting the code to empty string is *required* in
+                    // m_bForceGenericFields mode, or the export will write
+                    // the ODF_UNHANDLED string!
+                    assert(!m_bForceGenericFields || aCode.isEmpty());
+                    xNameCont->insertByName(ODF_CODE_PARAM, uno::makeAny(aCode));
+                    if (std::get<0>(field) == "CONTROL")
+                    { // tdf#129247 HACK probably this should be imported as something else, like in ww8?
+                        xNameCont->insertByName(ODF_ID_PARAM, uno::makeAny(OUString::number(87))); // ww8::eCONTROL
+                    }
                 }
                 else
                     m_bParaHadField = false;


More information about the Libreoffice-commits mailing list