summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCzeber László Ádám <czeber.laszloadam@nisz.hu>2023-04-18 15:01:14 +0200
committerLászló Németh <nemeth@numbertext.org>2023-04-26 10:55:29 +0200
commite898f95bfab16ddd9b04e516293cb6eb7e0a3847 (patch)
tree10e5589df2d1c51091163f23c4949d5e81b57470
parenttdf#155006 don't show "InsertObjectFloatingFrame" by default in menus and too... (diff)
downloadcore-e898f95bfab16ddd9b04e516293cb6eb7e0a3847.tar.gz
core-e898f95bfab16ddd9b04e516293cb6eb7e0a3847.zip
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>
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf138093.docxbin0 -> 39532 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport19.cxx55
-rw-r--r--writerfilter/source/dmapper/SdtHelper.cxx4
3 files changed, 58 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf138093.docx b/sw/qa/extras/ooxmlexport/data/tdf138093.docx
new file mode 100644
index 000000000000..097fbb1351cc
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf138093.docx
Binary files differ
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: */
diff --git a/writerfilter/source/dmapper/SdtHelper.cxx b/writerfilter/source/dmapper/SdtHelper.cxx
index ce2cb3e9b136..f9cedcbf19eb 100644
--- a/writerfilter/source/dmapper/SdtHelper.cxx
+++ b/writerfilter/source/dmapper/SdtHelper.cxx
@@ -381,8 +381,10 @@ void SdtHelper::createDateContentControl()
try
{
xCrsr->gotoRange(m_xDateFieldStartRange, false);
+ // tdf#138093: Date selector reset, if placed inside table
+ // Modified to XOR relationship
bool bIsInTable = (m_rDM_Impl.hasTableManager() && m_rDM_Impl.getTableManager().isInTable())
- || (m_rDM_Impl.m_nTableDepth > 0);
+ != (m_rDM_Impl.m_nTableDepth > 0);
if (bIsInTable)
xCrsr->goRight(1, false);
xCrsr->gotoEnd(true);