summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2019-07-10 18:23:48 +0200
committerAndras Timar <andras.timar@collabora.com>2019-07-14 00:19:55 +0200
commitfa53a9ec758a31ca890a484fb3399fa63987eef4 (patch)
tree12c8507c026258cb2d63c4e71913c3d6e335f2ed /sw
parent6424765accef4fdce2fc23e6310cebafb70f6173 (diff)
MSForms: Test import / export of character formatting for date field
* With the rework, now the character formatting is fully supported. * Remove the other related test, which tested only a interop grabbag implementation. Reviewed-on: https://gerrit.libreoffice.org/75460 Tested-by: Jenkins Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com> (cherry picked from commit 01f6c6ad6ba1adce817daa782bf3520fafc512a0) Change-Id: I598a21691c08a161933a5fef659e7ca21092dd0c Reviewed-on: https://gerrit.libreoffice.org/75553 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/globalfilter/data/date_form_field_char_formatting.odtbin0 -> 8432 bytes
-rw-r--r--sw/qa/extras/globalfilter/globalfilter.cxx51
-rw-r--r--sw/qa/extras/ooxmlexport/data/sdt-date-charformat.docxbin12924 -> 0 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx11
4 files changed, 51 insertions, 11 deletions
diff --git a/sw/qa/extras/globalfilter/data/date_form_field_char_formatting.odt b/sw/qa/extras/globalfilter/data/date_form_field_char_formatting.odt
new file mode 100644
index 000000000000..eb770262056a
--- /dev/null
+++ b/sw/qa/extras/globalfilter/data/date_form_field_char_formatting.odt
Binary files differ
diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx
index 10dca218b702..fcb40c24e409 100644
--- a/sw/qa/extras/globalfilter/globalfilter.cxx
+++ b/sw/qa/extras/globalfilter/globalfilter.cxx
@@ -26,6 +26,7 @@
#include <IDocumentMarkAccess.hxx>
#include <IMark.hxx>
#include <bookmrk.hxx>
+#include <com/sun/star/awt/FontWeight.hpp>
class Test : public SwModelTestBase
{
@@ -49,6 +50,7 @@ public:
void testCheckBoxFormField();
void testDropDownFormField();
void testDateFormField();
+ void testDateFormFieldCharacterFormatting();
CPPUNIT_TEST_SUITE(Test);
CPPUNIT_TEST(testSwappedOutImageExport);
@@ -67,6 +69,7 @@ public:
CPPUNIT_TEST(testCheckBoxFormField);
CPPUNIT_TEST(testDropDownFormField);
CPPUNIT_TEST(testDateFormField);
+ CPPUNIT_TEST(testDateFormFieldCharacterFormatting);
CPPUNIT_TEST_SUITE_END();
};
@@ -1230,6 +1233,54 @@ void Test::testDateFormField()
}
}
+void Test::testDateFormFieldCharacterFormatting()
+{
+ const OUString aFilterNames[] = {
+ "writer8",
+ "Office Open XML Text",
+ };
+
+ for (const OUString& rFilterName : aFilterNames)
+ {
+ if (mxComponent.is())
+ mxComponent->dispose();
+ mxComponent = loadFromDesktop(m_directories.getURLFromSrc("/sw/qa/extras/globalfilter/data/date_form_field_char_formatting.odt"), "com.sun.star.text.TextDocument");
+
+ const OString sFailedMessage = OString("Failed on filter: ") + rFilterName.toUtf8();
+
+ // Export the document and import again for a check
+ uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
+ utl::MediaDescriptor aMediaDescriptor;
+ aMediaDescriptor["FilterName"] <<= rFilterName;
+ utl::TempFile aTempFile;
+ aTempFile.EnableKillingFile();
+ xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
+ uno::Reference< lang::XComponent > xComponent(xStorable, uno::UNO_QUERY);
+ xComponent->dispose();
+ mxComponent = loadFromDesktop(aTempFile.GetURL(), "com.sun.star.text.TextDocument");
+
+ // Check the document after round trip
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
+ CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), pTextDoc);
+ SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
+ IDocumentMarkAccess* pMarkAccess = pDoc->getIDocumentMarkAccess();
+
+ // Check that we have the field at the right place
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(1), pMarkAccess->getAllMarksCount());
+ ::sw::mark::IDateFieldmark* pFieldmark = dynamic_cast<::sw::mark::IDateFieldmark*>(pMarkAccess->getAllMarksBegin()->get());
+ CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), pFieldmark);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), OUString(ODF_FORMDATE), pFieldmark->GetFieldname());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(0), pFieldmark->GetMarkStart().nContent.GetIndex());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(10), pFieldmark->GetMarkEnd().nContent.GetIndex());
+
+ // We have one date field, first half of the field has bold character weight and second part has red character color
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), awt::FontWeight::BOLD, getProperty<float>(getRun(getParagraph(1), 2), "CharWeight"));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(COL_AUTO), getProperty<sal_Int32>(getRun(getParagraph(1), 2), "CharColor"));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), awt::FontWeight::NORMAL, getProperty<float>(getRun(getParagraph(1), 3), "CharWeight"));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(0xff0000), getProperty<sal_Int32>(getRun(getParagraph(1), 3), "CharColor"));
+ }
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/qa/extras/ooxmlexport/data/sdt-date-charformat.docx b/sw/qa/extras/ooxmlexport/data/sdt-date-charformat.docx
deleted file mode 100644
index 22c4d4e1f8c3..000000000000
--- a/sw/qa/extras/ooxmlexport/data/sdt-date-charformat.docx
+++ /dev/null
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 355163fb5927..870c654f855d 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -96,17 +96,6 @@ DECLARE_OOXMLEXPORT_TEST(testSdtAlias, "sdt-alias.docx")
assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:alias", "val", "Subtitle");
}
-/*DECLARE_OOXMLEXPORT_TEST(testSdtDateCharformat, "sdt-date-charformat.docx")
-{
- if (xmlDocPtr pXmlDoc = parseExport())
- {
- // character formatting (bold) was missing, this was 0
- assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r/w:rPr/w:b", 1);
- // alias was also missing.
- assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:alias", 1);
- }
-}*/
-
DECLARE_OOXMLEXPORT_TEST(testFooterBodyDistance, "footer-body-distance.docx")
{
if (xmlDocPtr pXmlDoc = parseExport())