[Libreoffice-commits] .: sw/qa

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Oct 2 01:27:27 PDT 2012


 sw/qa/extras/ooxmlimport/data/n779957.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx   |   46 +++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+)

New commits:
commit 2cf0f5fe6244e1a98f82a1aca77b32c029c73e27
Author: Pierre-Eric Pelloux-Prayer <pierre-eric at lanedo.com>
Date:   Thu Sep 27 14:44:41 2012 +0200

    docx import: add table position unit test
    
    Change-Id: I21aa721e20be4b7f9984bf6910a94a7b7bf09c7a
    Reviewed-on: https://gerrit.libreoffice.org/715
    Reviewed-by: Miklos Vajna <vmiklos at suse.cz>
    Tested-by: Miklos Vajna <vmiklos at suse.cz>

diff --git a/sw/qa/extras/ooxmlimport/data/n779957.docx b/sw/qa/extras/ooxmlimport/data/n779957.docx
new file mode 100644
index 0000000..4347854
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/n779957.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 1267eac..ceb2381 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -50,6 +50,9 @@
 #include <com/sun/star/style/BreakType.hpp>
 #include <com/sun/star/style/ParagraphAdjust.hpp>
 #include <com/sun/star/table/ShadowFormat.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <com/sun/star/table/BorderLine2.hpp>
+
 
 #include <vcl/svapp.hxx>
 
@@ -93,6 +96,7 @@ public:
     void testN779834();
     void testN779627();
     void testN779941();
+    void testN779957();
     void testFdo55187();
     void testN780563();
     void testN780853();
@@ -138,6 +142,7 @@ public:
     CPPUNIT_TEST(testN779834);
     CPPUNIT_TEST(testN779627);
     CPPUNIT_TEST(testN779941);
+    CPPUNIT_TEST(testN779957);
     CPPUNIT_TEST(testFdo55187);
     CPPUNIT_TEST(testN780563);
     CPPUNIT_TEST(testN780853);
@@ -1031,6 +1036,47 @@ void Test::testN779941()
     }
 }
 
+void Test::testN779957()
+{
+    /*
+     * n779957.docx contains 4 tables. This test verifies their X position.
+     * We compare cursor position in LibreOffice to table indentation in Office, because it's
+     * where text starts in tables.
+     */
+    sal_Int32 xCoordsFromOffice[] = { 2500, -1000, 0, 0 };
+    sal_Int32 cellLeftMarginFromOffice[] = { 250, 100, 0, 0 };
+
+    load("n779957.docx");
+    uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
+
+    for (int i=0; i<4; i++) {
+        uno::Reference<text::XTextTable> xTable1 (xTables->getByIndex(i), uno::UNO_QUERY);
+        // Verify X coord
+        uno::Reference<view::XSelectionSupplier> xCtrl(xModel->getCurrentController(), uno::UNO_QUERY);
+        xCtrl->select(uno::makeAny(xTable1));
+        uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xCtrl, uno::UNO_QUERY);
+        uno::Reference<text::XTextViewCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
+        awt::Point pos = xCursor->getPosition();
+        CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Incorrect X coord computed from docx",
+            xCoordsFromOffice[i], pos.X, 1);
+
+        // Verify left margin of 1st cell :
+        //  * Office left margins are measured relative to the right of the border
+        //  * LO left spacing is measured from the center of the border
+        uno::Reference<table::XCell> xCell = xTable1->getCellByName("A1");
+        uno::Reference< beans::XPropertySet > xPropSet(xCell, uno::UNO_QUERY_THROW);
+        sal_Int32 aLeftMargin = -1;
+        xPropSet->getPropertyValue("LeftBorderDistance") >>= aLeftMargin;
+        uno::Any aLeftBorder = xPropSet->getPropertyValue("LeftBorder");
+        table::BorderLine2 aLeftBorderLine;
+        aLeftBorder >>= aLeftBorderLine;
+        CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Incorrect left spacing computed from docx cell margin",
+            cellLeftMarginFromOffice[i], aLeftMargin - 0.5 * aLeftBorderLine.LineWidth, 1);
+    }
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();


More information about the Libreoffice-commits mailing list