tdf#151261 DOCX import: fix dropdown SDT when the item display text is missing
commitf726fbc2699b05199a8dec3055710a7131e0aad6
authorMiklos Vajna <vmiklos@collabora.com>
Mon, 10 Oct 2022 08:07:10 +0000 (10 10:07 +0200)
committerMiklos Vajna <vmiklos@collabora.com>
Mon, 10 Oct 2022 14:05:53 +0000 (10 16:05 +0200)
tree72c4cb6493236a32d32b00654dd886a948df3743
parent3e8bed6709e3a580445488b7e878001b2c2c6be9
tdf#151261 DOCX import: fix dropdown SDT when the item display text is missing

Dropdown content controls have list items, and each list item can have a
display text and a value. These are optional, and the bugdoc has a list
item where the value is set, but not the display text.

The trouble is that later in DomainMapper_Impl::PopSdt() we check if the
length of the display texts and values array match and if not, then we
throw away these arrays to avoid creating an inconsistent document
model.

Fix the problem by checking what display text and value we got at the end
of each list item; if any of them is missing, we add an empty string,
which matches the internal representation in SwContentControlListItem.

This also helps in case these array sizes matched by accident, but
display texts and values from different list items were mixed
previously.

Change-Id: Ib1eeabd2479963af4a84d4229d4f0ce4572e0f01
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141151
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
writerfilter/qa/cppunittests/dmapper/DomainMapper.cxx
writerfilter/qa/cppunittests/dmapper/data/sdt-dropdown-no-display-text.docx [new file with mode: 0644]
writerfilter/source/dmapper/DomainMapper.cxx