sw/qa/extras/ooxmlexport/ooxmlexport17.cxx                       |    4 ++--
 sw/source/filter/ww8/docxattributeoutput.cxx                     |    4 +++-
 writerfilter/qa/cppunittests/dmapper/SdtHelper.cxx               |    2 +-
 writerfilter/qa/cppunittests/dmapper/data/sdt-run-rich-text.docx |binary
 4 files changed, 6 insertions(+), 4 deletions(-)

New commits:
commit cb77f5a5d061bdc460f2606b861f436675443073
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Wed Jan 25 16:29:55 2023 -0500
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Mon Jan 30 08:32:56 2023 +0000

    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 <jl...@mail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146296
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index 42b7a0891877..98be0085ab6e 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -304,7 +304,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);
@@ -332,7 +332,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 0f65ba8cdebe..2ade8669d251 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2439,8 +2439,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 bde82531b327..f8fbce8dfdde 100644
--- a/writerfilter/qa/cppunittests/dmapper/SdtHelper.cxx
+++ b/writerfilter/qa/cppunittests/dmapper/SdtHelper.cxx
@@ -102,7 +102,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
index d5644f33e9d9..0d1004ef8a6e 100644
Binary files a/writerfilter/qa/cppunittests/dmapper/data/sdt-run-rich-text.docx 
and b/writerfilter/qa/cppunittests/dmapper/data/sdt-run-rich-text.docx differ

Reply via email to