path: root/writerfilter
diff options
authorMichael Stahl <>2019-12-18 18:08:23 +0100
committerMichael Stahl <>2019-12-19 15:11:03 +0100
commit27b6c82b79f4af2ab16d53de3b2065df0acebdb8 (patch)
tree4a6135d658dcfcd7f2bed775ef3f5cfaae08d40e /writerfilter
parente1c2bb5712d990ba0e354fec5cce8d13121b839d (diff)
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: Reviewed-by: Michael Stahl <> Tested-by: Michael Stahl <>
Diffstat (limited to 'writerfilter')
1 files changed, 12 insertions, 1 deletions
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(),
- 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
+ }
m_bParaHadField = false;