diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2019-08-05 03:37:34 +0200 |
---|---|---|
committer | Tamás Zolnai <tamas.zolnai@collabora.com> | 2019-08-05 12:41:03 +0200 |
commit | b36ef83ea59eeaca239e58b95aa0b1acdcb99efc (patch) | |
tree | 50979d2ed563aebaa548e921cb4ec4cf24248f3a /sw | |
parent | ce6b0a675b504290411e2f1c58b12de12406c5e6 (diff) |
tdf126701: MSForms: Fix import of date field at the end of the paragraph.
We need to create date field before the paragraph is finished
(line break is inserted). A date field can not span between
paragraphs.
Extend other related unit tests too. In other use cases, the field
content changes to an invalid data.
Change-Id: Id274649e0aaaf6e3c31e042afd126cefc368c858
Reviewed-on: https://gerrit.libreoffice.org/76971
Tested-by: Jenkins
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/date_field_at_end_of_paragraph.docx | bin | 0 -> 22693 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx | 42 |
2 files changed, 42 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/date_field_at_end_of_paragraph.docx b/sw/qa/extras/ooxmlexport/data/date_field_at_end_of_paragraph.docx Binary files differnew file mode 100644 index 000000000000..6514b2a53089 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/date_field_at_end_of_paragraph.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx index 872fb9651fb1..9e5fc9ccb3d4 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx @@ -8,6 +8,9 @@ */ #include <swmodeltestbase.hxx> +#include <xmloff/odffields.hxx> +#include <IDocumentMarkAccess.hxx> +#include <IMark.hxx> class Test : public SwModelTestBase { @@ -517,6 +520,18 @@ DECLARE_OOXMLEXPORT_TEST(testSdtDateDuplicate, "sdt-date-duplicate.docx") // Single <w:sdt> was exported as 2 <w:sdt> elements. assertXPath(pXmlDoc, "//w:sdt", 1); } + + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); + IDocumentMarkAccess* pMarkAccess = pDoc->getIDocumentMarkAccess(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), 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("4/26/2012"), pFieldmark->GetContent()); } DECLARE_OOXMLEXPORT_TEST(testFdo81492, "fdo81492.docx") @@ -667,6 +682,33 @@ DECLARE_OOXMLEXPORT_TEST( testTdf66401, "tdf66401.docx") DECLARE_OOXMLEXPORT_TEST( testDateFieldInShape, "date_field_in_shape.docx" ) { // This was crashed on export. + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); + IDocumentMarkAccess* pMarkAccess = pDoc->getIDocumentMarkAccess(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), 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("Click here to enter a date."), pFieldmark->GetContent()); +} + +DECLARE_OOXMLEXPORT_TEST( testDateFieldAtEndOfParagraph, "date_field_at_end_of_paragraph.docx" ) +{ + // Additional line end was added by import and it was crashed on export + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); + IDocumentMarkAccess* pMarkAccess = pDoc->getIDocumentMarkAccess(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), 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("Click here to enter a date."), pFieldmark->GetContent()); } CPPUNIT_PLUGIN_IMPLEMENT(); |