diff options
author | Vitaliy Anderson <vanderson@smartru.com> | 2017-02-03 03:58:02 -0800 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2017-02-15 12:17:33 +0000 |
commit | b29046814f59f5911e619cb7569bd3333b0333e5 (patch) | |
tree | dd57a5874da6be05b14e3317cd968641652850ab | |
parent | 31f4400ea5d41ed11b3aef114950d7b424df6a26 (diff) |
tdf#104349, tdf#104668 MS Word compatibility trailing blanks option part 3
Add unittest
Change-Id: I2c0671b8ba0ee899d2e77e8d29ebbadea09e7a78
Reviewed-on: https://gerrit.libreoffice.org/33883
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r-- | sw/qa/extras/uiwriter/data/MsWordCompTrailingBlanks.docx | bin | 0 -> 14629 bytes | |||
-rw-r--r-- | sw/qa/extras/uiwriter/data/MsWordCompTrailingBlanksFalse.odt | bin | 0 -> 8629 bytes | |||
-rw-r--r-- | sw/qa/extras/uiwriter/data/MsWordCompTrailingBlanksTrue.odt | bin | 0 -> 8628 bytes | |||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter.cxx | 35 |
4 files changed, 35 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/data/MsWordCompTrailingBlanks.docx b/sw/qa/extras/uiwriter/data/MsWordCompTrailingBlanks.docx Binary files differnew file mode 100644 index 000000000000..d72725c8890b --- /dev/null +++ b/sw/qa/extras/uiwriter/data/MsWordCompTrailingBlanks.docx diff --git a/sw/qa/extras/uiwriter/data/MsWordCompTrailingBlanksFalse.odt b/sw/qa/extras/uiwriter/data/MsWordCompTrailingBlanksFalse.odt Binary files differnew file mode 100644 index 000000000000..bd0abdc4d5fd --- /dev/null +++ b/sw/qa/extras/uiwriter/data/MsWordCompTrailingBlanksFalse.odt diff --git a/sw/qa/extras/uiwriter/data/MsWordCompTrailingBlanksTrue.odt b/sw/qa/extras/uiwriter/data/MsWordCompTrailingBlanksTrue.odt Binary files differnew file mode 100644 index 000000000000..407fdf46877d --- /dev/null +++ b/sw/qa/extras/uiwriter/data/MsWordCompTrailingBlanksTrue.odt diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index a085220de788..8e6479f20538 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -39,6 +39,7 @@ #include <unotbl.hxx> #include <IMark.hxx> #include <IDocumentMarkAccess.hxx> +#include <IDocumentSettingAccess.hxx> #include <pagedesc.hxx> #include <postithelper.hxx> #include <PostItMgr.hxx> @@ -227,6 +228,7 @@ public: void testTdf104492(); void testTdf105417(); void testTdf105625(); + void testMsWordCompTrailingBlanks(); CPPUNIT_TEST_SUITE(SwUiWriterTest); CPPUNIT_TEST(testReplaceForward); @@ -348,6 +350,7 @@ public: CPPUNIT_TEST(testTdf104492); CPPUNIT_TEST(testTdf105417); CPPUNIT_TEST(testTdf105625); + CPPUNIT_TEST(testMsWordCompTrailingBlanks); CPPUNIT_TEST_SUITE_END(); private: @@ -4303,6 +4306,38 @@ void SwUiWriterTest::testTdf105625() CPPUNIT_ASSERT_EQUAL(nMarksBefore, nMarksAfter + 1); } +void SwUiWriterTest::testMsWordCompTrailingBlanks() +{ + // The option is true in settings.xml + SwDoc* pDoc = createDoc( "MsWordCompTrailingBlanksTrue.odt" ); + CPPUNIT_ASSERT_EQUAL( true, pDoc->getIDocumentSettingAccess().get( DocumentSettingId::MS_WORD_COMP_TRAILING_BLANKS ) ); + calcLayout(); + // Check that trailing spaces spans have no width if option is enabled + + CPPUNIT_ASSERT_EQUAL( OUString( "" ), parseDump( "/root/page/body/txt[2]/Text[4]", "nWidth" ) ); + CPPUNIT_ASSERT_EQUAL( OUString( "" ), parseDump( "/root/page/body/txt[2]/Text[5]", "nWidth" ) ); + CPPUNIT_ASSERT_EQUAL( OUString( "" ), parseDump( "/root/page/body/txt[3]/Text[4]", "nWidth" ) ); + CPPUNIT_ASSERT_EQUAL( OUString( "" ), parseDump( "/root/page/body/txt[3]/Text[5]", "nWidth" ) ); + + // The option is false in settings.xml + pDoc = createDoc( "MsWordCompTrailingBlanksFalse.odt" ); + CPPUNIT_ASSERT_EQUAL( false, pDoc->getIDocumentSettingAccess().get( DocumentSettingId::MS_WORD_COMP_TRAILING_BLANKS ) ); + calcLayout(); + // Check that trailing spaces spans have width if option is disabled + CPPUNIT_ASSERT( !parseDump( "/root/page/body/txt[2]/Text[4]", "nWidth" ).isEmpty() ); + CPPUNIT_ASSERT( !parseDump( "/root/page/body/txt[2]/Text[5]", "nWidth" ).isEmpty() ); + CPPUNIT_ASSERT( !parseDump( "/root/page/body/txt[3]/Text[4]", "nWidth" ).isEmpty() ); + CPPUNIT_ASSERT( !parseDump( "/root/page/body/txt[3]/Text[5]", "nWidth" ).isEmpty() ); + + // MsWordCompTrailingBlanks option should be false by default in new documents + pDoc = createDoc(); + CPPUNIT_ASSERT_EQUAL( false, pDoc->getIDocumentSettingAccess().get( DocumentSettingId::MS_WORD_COMP_TRAILING_BLANKS ) ); + + // The option should be true if a .docx, .doc or .rtf document is opened + pDoc = createDoc( "MsWordCompTrailingBlanks.docx" ); + CPPUNIT_ASSERT_EQUAL( true, pDoc->getIDocumentSettingAccess().get( DocumentSettingId::MS_WORD_COMP_TRAILING_BLANKS ) ); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest); CPPUNIT_PLUGIN_IMPLEMENT(); |