summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorCzeber László Ádám <czeber.laszloadam@nisz.hu>2023-04-27 09:48:50 +0200
committerLászló Németh <nemeth@numbertext.org>2023-04-27 18:47:48 +0200
commitfd79c5ed9b13516bdb0f2a29806296698ddda7b2 (patch)
treec30fa580f87f3b9f2aed6736875db56df35d97d8 /sw
parente59fdc8b800aa3ab551b3f4fec4bc58366df582e (diff)
tdf#131722 DOCX import: fix lost first character in date selector
Fix another date selector control bug, date picker first character goes out of the control. The first character of the date separator in the first row of the table is out of control. The fix takes into account the placement of the dummy paragraph in the first row of the table, which caused the date separator to be corrupted. Thanks to Gabor Kelemen for pointing out this error to me. Follow-up to commit e898f95bfab16ddd9b04e516293cb6eb7e0a3847 "tdf#138093 DOCX import: fix broken date selector control in table". Change-Id: I91d272b786a3d3dc047334c2a4a039f987c94ce0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151087 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/tdf131722.docxbin0 -> 18825 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport19.cxx57
2 files changed, 57 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf131722.docx b/sw/qa/extras/ooxmlexport/data/tdf131722.docx
new file mode 100644
index 000000000000..8b72ad4b86a7
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf131722.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
index 729fd09724a9..059d652d0a33 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
@@ -949,6 +949,63 @@ DECLARE_OOXMLEXPORT_TEST(testTdf138093, "tdf138093.docx")
}
}
+DECLARE_OOXMLEXPORT_TEST(testTdf131722, "tdf131722.docx")
+{
+ if (isExported())
+ {
+ xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+ assertXPath(pXmlDoc, "//w:sdt", 4);
+ 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("A1");
+ 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("Enter a date here!"), 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->getFieldmarksCount());
+
+ for (auto aIter = pMarkAccess->getFieldmarksBegin();
+ aIter != pMarkAccess->getFieldmarksEnd(); ++aIter)
+ {
+ ::sw::mark::IDateFieldmark* pFieldmark
+ = dynamic_cast<::sw::mark::IDateFieldmark*>(*aIter);
+ CPPUNIT_ASSERT(pFieldmark);
+ CPPUNIT_ASSERT_EQUAL(OUString(ODF_FORMDATE), pFieldmark->GetFieldname());
+ CPPUNIT_ASSERT_EQUAL(OUString("Enter a date here!"), pFieldmark->GetContent());
+ }
+ }
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */