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

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Thu Dec 19 14:11:56 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 27b6c82b79f4af2ab16d53de3b2065df0acebdb8
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Wed Dec 18 18:08:23 2019 +0100
Commit:     Michael Stahl <michael.stahl at cib.de>
CommitDate: Thu Dec 19 15:11:03 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>

diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index a7fa401c393b..ef3353987e37 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 c1c5c12b4d8d..17eb147c6c21 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -77,6 +77,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>
@@ -5395,9 +5396,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