[Libreoffice-commits] core.git: sw/qa

Vitaliy Anderson vanderson at smartru.com
Wed Feb 15 12:17:54 UTC 2017


 sw/qa/extras/uiwriter/data/MsWordCompTrailingBlanks.docx     |binary
 sw/qa/extras/uiwriter/data/MsWordCompTrailingBlanksFalse.odt |binary
 sw/qa/extras/uiwriter/data/MsWordCompTrailingBlanksTrue.odt  |binary
 sw/qa/extras/uiwriter/uiwriter.cxx                           |   35 +++++++++++
 4 files changed, 35 insertions(+)

New commits:
commit b29046814f59f5911e619cb7569bd3333b0333e5
Author: Vitaliy Anderson <vanderson at smartru.com>
Date:   Fri Feb 3 03:58:02 2017 -0800

    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 at libreoffice.org>
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/sw/qa/extras/uiwriter/data/MsWordCompTrailingBlanks.docx b/sw/qa/extras/uiwriter/data/MsWordCompTrailingBlanks.docx
new file mode 100644
index 0000000..d72725c
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/MsWordCompTrailingBlanks.docx differ
diff --git a/sw/qa/extras/uiwriter/data/MsWordCompTrailingBlanksFalse.odt b/sw/qa/extras/uiwriter/data/MsWordCompTrailingBlanksFalse.odt
new file mode 100644
index 0000000..bd0abdc
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/MsWordCompTrailingBlanksFalse.odt differ
diff --git a/sw/qa/extras/uiwriter/data/MsWordCompTrailingBlanksTrue.odt b/sw/qa/extras/uiwriter/data/MsWordCompTrailingBlanksTrue.odt
new file mode 100644
index 0000000..407fdf4
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/MsWordCompTrailingBlanksTrue.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index a085220..8e6479f 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();
 


More information about the Libreoffice-commits mailing list