diff options
author | Justin Luth <justin.luth@collabora.com> | 2023-01-25 16:29:55 -0500 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2023-01-27 07:32:52 +0000 |
commit | 52d5f2e247e6b0a638fc0ec83f5dbc1cca30d1cd (patch) | |
tree | e44816656269963881af758f5e82260a148a9d0c | |
parent | edcfb4632a514c5595540d69f7b217b4a12bac5c (diff) |
tdf#151548 sw content controls: preserve tabIndex val="-1"
Either we have to read sal_uInt32
(which I can't figure out how to do)
or else we have to write it out as sal_Int32.
Microsoft isn't much help here because their documentation
does not give any example of a non-tabsltop,
and one errata document indicates that MS Word
simply ignores tabIndex altogether for Sdt (and ffData).
According to the documentation,
tabIndex is a CT_UnsignedDecimalNumber
which we do not have in our model.xml
so it was defined as being a CT_DecimalNumber
which works fine for reading something human sensible like -1.
However, in our exporting we were exporting a sal_uInt32
which creates large, all positive numbers
which were not being read on import.
Nothing I tried worked to read these large numbers.
Perhaps it is even illegal to do so in MS formats?
Since it doesn't seem to matter to MS Word,
and for a human it is easier to understand -1,
and it is easier to solve in export than import,
I'm taking the easy road.
Change-Id: I6b296703c9a37149d9e11f29901e6db32bd041b7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146149
Tested-by: Jenkins
Reviewed-by: Justin Luth <jluth@mail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport17.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 4 | ||||
-rw-r--r-- | writerfilter/qa/cppunittests/dmapper/SdtHelper.cxx | 2 | ||||
-rw-r--r-- | writerfilter/qa/cppunittests/dmapper/data/sdt-run-rich-text.docx | bin | 5405 -> 5406 bytes |
4 files changed, 6 insertions, 4 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx index a04a7813f9c6..bfc09d934343 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx @@ -426,7 +426,7 @@ CPPUNIT_TEST_FIXTURE(Test, testDateContentControlExport) xContentControlProps->setPropertyValue("Alias", uno::Any(OUString("myalias"))); xContentControlProps->setPropertyValue("Tag", uno::Any(OUString("mytag"))); xContentControlProps->setPropertyValue("Id", uno::Any(static_cast<sal_Int32>(123))); - xContentControlProps->setPropertyValue("TabIndex", uno::Any(sal_uInt32(2))); + xContentControlProps->setPropertyValue("TabIndex", uno::Any(sal_uInt32(4294967295))); // -1 xContentControlProps->setPropertyValue("Lock", uno::Any(OUString("sdtLocked"))); xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true); @@ -453,7 +453,7 @@ CPPUNIT_TEST_FIXTURE(Test, testDateContentControlExport) assertXPath(pXmlDoc, "//w:sdt/w:sdtPr/w:alias", "val", "myalias"); assertXPath(pXmlDoc, "//w:sdt/w:sdtPr/w:tag", "val", "mytag"); assertXPath(pXmlDoc, "//w:sdt/w:sdtPr/w:id", "val", "123"); - assertXPath(pXmlDoc, "//w:sdt/w:sdtPr/w:tabIndex", "val", "2"); + assertXPath(pXmlDoc, "//w:sdt/w:sdtPr/w:tabIndex", "val", "-1"); assertXPath(pXmlDoc, "//w:sdt/w:sdtPr/w:lock", "val", "sdtLocked"); } diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 01809ae0c0cc..3280b212064f 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -2440,8 +2440,10 @@ void DocxAttributeOutput::WriteContentControlStart() if (m_pContentControl->GetTabIndex()) { + // write the unsigned value as as if it were signed since that is all we can import + const sal_Int32 nTabIndex = static_cast<sal_Int32>(m_pContentControl->GetTabIndex()); m_pSerializer->singleElementNS(XML_w, XML_tabIndex, FSNS(XML_w, XML_val), - OString::number(m_pContentControl->GetTabIndex())); + OString::number(nTabIndex)); } if (!m_pContentControl->GetLock().isEmpty()) diff --git a/writerfilter/qa/cppunittests/dmapper/SdtHelper.cxx b/writerfilter/qa/cppunittests/dmapper/SdtHelper.cxx index fc99cd2e3416..6300a488b409 100644 --- a/writerfilter/qa/cppunittests/dmapper/SdtHelper.cxx +++ b/writerfilter/qa/cppunittests/dmapper/SdtHelper.cxx @@ -78,7 +78,7 @@ CPPUNIT_TEST_FIXTURE(Test, testSdtRunRichText) sal_uInt32 nTabIndex = 0; xContentControlProps->getPropertyValue("TabIndex") >>= nTabIndex; // This was 0 - CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(5), nTabIndex); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(4294967295), nTabIndex); OUString aLock; xContentControlProps->getPropertyValue("Lock") >>= aLock; // This was empty. diff --git a/writerfilter/qa/cppunittests/dmapper/data/sdt-run-rich-text.docx b/writerfilter/qa/cppunittests/dmapper/data/sdt-run-rich-text.docx Binary files differindex d5644f33e9d9..0d1004ef8a6e 100644 --- a/writerfilter/qa/cppunittests/dmapper/data/sdt-run-rich-text.docx +++ b/writerfilter/qa/cppunittests/dmapper/data/sdt-run-rich-text.docx |