summaryrefslogtreecommitdiff
path: root/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
diff options
context:
space:
mode:
authorPierre-Eric Pelloux-Prayer <pierre-eric@lanedo.com>2012-09-27 14:44:41 +0200
committerMiklos Vajna <vmiklos@suse.cz>2012-10-02 08:27:08 +0000
commit2cf0f5fe6244e1a98f82a1aca77b32c029c73e27 (patch)
treed527dc52ba5f0542e1eade345e47dd9d9b139261 /sw/qa/extras/ooxmlimport/ooxmlimport.cxx
parent3cb619bd15a6017f253891f4c377fc790d8aae82 (diff)
docx import: add table position unit test
Change-Id: I21aa721e20be4b7f9984bf6910a94a7b7bf09c7a Reviewed-on: https://gerrit.libreoffice.org/715 Reviewed-by: Miklos Vajna <vmiklos@suse.cz> Tested-by: Miklos Vajna <vmiklos@suse.cz>
Diffstat (limited to 'sw/qa/extras/ooxmlimport/ooxmlimport.cxx')
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx46
1 files changed, 46 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 1267eac0c742..ceb2381621db 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();