sw content controls, plain text: enable DOCX filter with data binding

Desktop / LibreOffice - Miklos Vajna [collabora.com] - 19 September 2022 09:31 UTC

- writerfilter/ had explicit code to not map plain text SDT to Writer content controls if it has data bindings specified, lift this limitation and set the
value of content control from data binding, like Word does and Writer did it for input fields since b5c616d10bff3213840d4893d13b4493de71fa56 (tdf#104823: support for sdt plain text fields, 2021-11-24)

- call DocxExport::AddSdtData() on the export side to do the opposite on export

- give up on the idea to export content controls to DOCX by finding the text attribute in SwWW8AttrIter::OutAttrWithRange(): this needs buffering in both directions (need to start the SDT before the start of the run, need to end it after the end of the run), and solving this using marks and merges at a fast-serializer level looks like hacks on top of hacks. To be more specific, CppunitTest_sw_ooxmlexport7's testSdtAndShapeOverlapping seems to be very hard to fix with this design

- instead, give not only the start position but also the length of the run to DocxAttributeOutput::EndRun(), which has random access to the doc model and can look up if there is a content control start or end that needs writing at the current position of the XML output, without any buffering, which also means less code

- adapt CppunitTest_sw_ooxmlfieldexport's testSdtBeforeField, which didn't like the empty run at the start of content controls, which seems to be harmless otherwise

- fix CppunitTest_sw_ooxmlfieldexport CPPUNIT_TEST_NAME=testSdtDateDuplicate by disabling the "set content control value from data binding" logic for date pickers because that logic in writerfilter/ sets the value as-is and it has to consider the requested date format before this can be enabled

As a side effect, this gives PDF export for plain text SDTs, even if they have data binding set. CppunitTest_sw_ooxmlfieldexport's testTdf104823 is now updated to ensure that we import such SDTs as Writer content controls.

Change-Id: I749a845b5a25454c51066b8ded892682f523b6b4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140134

de90c192cb8f sw content controls, plain text: enable DOCX filter with data binding
sw/inc/txatbase.hxx | 2 +-
sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx | 43 +++++-------
sw/source/filter/ww8/attributeoutputbase.hxx | 8 +--
sw/source/filter/ww8/docxattributeoutput.cxx | 86 ++++++++++++-----------
sw/source/filter/ww8/docxattributeoutput.hxx | 11 +--
sw/source/filter/ww8/docxexport.cxx | 2 +-
sw/source/filter/ww8/rtfattributeoutput.cxx | 3 +-
sw/source/filter/ww8/rtfattributeoutput.hxx | 3 +-
sw/source/filter/ww8/wrtw8nds.cxx | 29 ++------
sw/source/filter/ww8/ww8atr.cxx | 4 +-
sw/source/filter/ww8/ww8attributeoutput.hxx | 2 +-
writerfilter/source/dmapper/DomainMapper.cxx | 15 ++--
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 8 +++
writerfilter/source/dmapper/SdtHelper.hxx | 4 +-
14 files changed, 93 insertions(+), 127 deletions(-)

Upstream: cgit.freedesktop.org

  • Share