diff options
author | Czeber László Ádám <czeber.laszloadam@nisz.hu> | 2023-04-18 15:01:14 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2023-04-26 10:55:29 +0200 |
commit | e898f95bfab16ddd9b04e516293cb6eb7e0a3847 (patch) | |
tree | 10e5589df2d1c51091163f23c4949d5e81b57470 /sw | |
parent | 5dc84674816e5f3cad9a45b9307723de3dd25b71 (diff) |
tdf#138093 DOCX import: fix broken date selector control in table
In tables, first character of the text value of the date selector
control left outside of the control during the import, resulting
broken date selector, e.g. 2[023] instead of [2023]. (Clicking on
the broken control, according to the year *023*, the selector listed
the lowest possible value, year 1900, and selecting that, the result
became 2[1900].)
Note: the fix works well with nested tables, too, so likely the
condition with tables is obsolete.
Perhaps regression from commit b36ef83ea59eeaca239e58b95aa0b1acdcb99efc
"tdf126701: MSForms: Fix import of date field at the end of the
paragraph." and commit 68e1be4ccbb90ee9a788962219a88312c4ffbea2
"MSForms: Rework text-based date form field's representation".
Change-Id: Ib217a3a06522bfe7b3b0fbc884f98504f628fc59
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150575
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf138093.docx | bin | 0 -> 39532 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport19.cxx | 55 |
2 files changed, 55 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf138093.docx b/sw/qa/extras/ooxmlexport/data/tdf138093.docx Binary files differnew file mode 100644 index 000000000000..097fbb1351cc --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf138093.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx index 9e01ca72ca17..729fd09724a9 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx @@ -33,6 +33,8 @@ #include <flyfrms.hxx> #include <sortedobjs.hxx> #include <txtfrm.hxx> +#include <IDocumentMarkAccess.hxx> +#include <xmloff/odffields.hxx> class Test : public SwModelTestBase { @@ -894,6 +896,59 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf133363) "0"); } +DECLARE_OOXMLEXPORT_TEST(testTdf138093, "tdf138093.docx") +{ + if (isExported()) + { + xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); + assertXPath(pXmlDoc, "//w:sdt", 3); + uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), + uno::UNO_QUERY); + uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY); + uno::Reference<table::XCell> xCell = xTable->getCellByName("B1"); + uno::Reference<container::XEnumerationAccess> xParagraphsAccess(xCell, uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xParagraphs + = xParagraphsAccess->createEnumeration(); + uno::Reference<container::XEnumerationAccess> xParagraph(xParagraphs->nextElement(), + uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xPortions = xParagraph->createEnumeration(); + uno::Reference<beans::XPropertySet> xTextPortion(xPortions->nextElement(), uno::UNO_QUERY); + + OUString aPortionType; + xTextPortion->getPropertyValue("TextPortionType") >>= aPortionType; + CPPUNIT_ASSERT_EQUAL(OUString("ContentControl"), aPortionType); + + uno::Reference<text::XTextContent> xContentControl; + xTextPortion->getPropertyValue("ContentControl") >>= xContentControl; + uno::Reference<beans::XPropertySet> xContentControlProps(xContentControl, uno::UNO_QUERY); + bool bDate{}; + xContentControlProps->getPropertyValue("Date") >>= bDate; + CPPUNIT_ASSERT(bDate); + uno::Reference<container::XEnumerationAccess> xContentControlEnumAccess(xContentControl, + uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xContentControlEnum + = xContentControlEnumAccess->createEnumeration(); + uno::Reference<text::XTextRange> xTextPortionRange(xContentControlEnum->nextElement(), + uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("2017"), xTextPortionRange->getString()); + } + else + { + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); + IDocumentMarkAccess* pMarkAccess = pDoc->getIDocumentMarkAccess(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), pMarkAccess->getAllMarksCount()); + + ::sw::mark::IDateFieldmark* pFieldmark + = dynamic_cast<::sw::mark::IDateFieldmark*>(*pMarkAccess->getAllMarksBegin()); + CPPUNIT_ASSERT(pFieldmark); + CPPUNIT_ASSERT_EQUAL(OUString(ODF_FORMDATE), pFieldmark->GetFieldname()); + CPPUNIT_ASSERT_EQUAL(OUString("2017"), pFieldmark->GetContent()); + } +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |