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

Michael Stahl mstahl at redhat.com
Fri Mar 14 11:19:59 PDT 2014


 editeng/source/items/borderline.cxx      |    4 +-
 sw/qa/extras/rtfimport/data/fdo68779.rtf |   25 ++++++++++++
 sw/qa/extras/rtfimport/rtfimport.cxx     |   62 +++++++++++++++++++++++++++++++
 3 files changed, 90 insertions(+), 1 deletion(-)

New commits:
commit 84f4de3b65cd0f861e80c69b773004f28f9f8d9f
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Mar 14 19:03:09 2014 +0100

    fdo#68779: RTF import: set borders without explicit width
    
    Word reportedly uses 0.75pt as a default if \brdrw is missing.
    
    Change-Id: I263c56f756c65ff6bb30870aa70806564d5826a6

diff --git a/editeng/source/items/borderline.cxx b/editeng/source/items/borderline.cxx
index b919e58..d3eef13 100644
--- a/editeng/source/items/borderline.cxx
+++ b/editeng/source/items/borderline.cxx
@@ -177,9 +177,11 @@ static const double OUTSET_line1 = 15.0;
 static const double INSET_line2  = 15.0;
 
 double
-ConvertBorderWidthFromWord(SvxBorderStyle const eStyle, double const fWidth,
+ConvertBorderWidthFromWord(SvxBorderStyle const eStyle, double const i_fWidth,
         int const nWordLineStyle)
 {
+    // fdo#68779: at least for RTF, 0.75pt is the default if width is missing
+    double const fWidth((i_fWidth == 0.0) ? 15.0 : i_fWidth);
     switch (eStyle)
     {
         // Single lines
diff --git a/sw/qa/extras/rtfimport/data/fdo68779.rtf b/sw/qa/extras/rtfimport/data/fdo68779.rtf
new file mode 100644
index 0000000..5dc7683
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo68779.rtf
@@ -0,0 +1,25 @@
+{\rtf1\ansi\ansicpg1251
+\paperw11907\paperh16840\psz9\margl1418\margr1984\margt2438\margb1531
+{\colortbl\red0\green0\blue0;}\deflang1049
+
+\trowd
+\clbrdrt\brdrs\clbrdrl\brdrs\clbrdrb\brdrs\clbrdrr\brdrs\cellx8335
+\pard\plain \intbl foo\cell \pard \intbl \row
+\pard \par
+
+\trowd
+\clbrdrt\brdrdot\clbrdrl\brdrdot\clbrdrb\brdrdot\clbrdrr\brdrdot\cellx8335
+\pard\plain \intbl foo\cell \pard \intbl \row
+\pard \par
+
+\trowd
+\clbrdrt\brdrdb\clbrdrl\brdrdb\clbrdrb\brdrdb\clbrdrr\brdrdb\cellx8335
+\pard\plain \intbl foo\cell \pard \intbl \row
+\pard \par
+
+\trowd
+\clbrdrt\brdrtnthmg\clbrdrl\brdrtnthmg\clbrdrb\brdrtnthmg\clbrdrr\brdrtnthmg\cellx8335
+\pard\plain \intbl foo\cell \pard \intbl \row
+\pard \par
+
+\pard \par}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index f11f5ea..0be7aff 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -1484,6 +1484,68 @@ DECLARE_RTFIMPORT_TEST(testFdo65090, "fdo65090.rtf")
     CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators").getLength());
 }
 
+DECLARE_RTFIMPORT_TEST(testTableBorderDefaults, "fdo68779.rtf")
+{
+    // table borders without \brdrw were not imported
+    uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
+    uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
+    uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xCell.is());
+    table::BorderLine2 solid(
+            1, 0, 26, 0, table::BorderLineStyle::SOLID, 26);
+    CPPUNIT_ASSERT_BORDER_EQUAL(solid,
+        getProperty<table::BorderLine2>(xCell, "LeftBorder"));
+    CPPUNIT_ASSERT_BORDER_EQUAL(solid,
+        getProperty<table::BorderLine2>(xCell, "RightBorder"));
+    CPPUNIT_ASSERT_BORDER_EQUAL(solid,
+        getProperty<table::BorderLine2>(xCell, "TopBorder"));
+    CPPUNIT_ASSERT_BORDER_EQUAL(solid,
+        getProperty<table::BorderLine2>(xCell, "BottomBorder"));
+
+    xTable.set(xTables->getByIndex(1), uno::UNO_QUERY);
+    xCell.set(xTable->getCellByName("A1"), uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xCell.is());
+    table::BorderLine2 dotted(
+            1, 0, 26, 0, table::BorderLineStyle::DOTTED, 26);
+    CPPUNIT_ASSERT_BORDER_EQUAL(dotted,
+        getProperty<table::BorderLine2>(xCell, "LeftBorder"));
+    CPPUNIT_ASSERT_BORDER_EQUAL(dotted,
+        getProperty<table::BorderLine2>(xCell, "RightBorder"));
+    CPPUNIT_ASSERT_BORDER_EQUAL(dotted,
+        getProperty<table::BorderLine2>(xCell, "TopBorder"));
+    CPPUNIT_ASSERT_BORDER_EQUAL(dotted,
+        getProperty<table::BorderLine2>(xCell, "BottomBorder"));
+
+    xTable.set(xTables->getByIndex(2), uno::UNO_QUERY);
+    xCell.set(xTable->getCellByName("A1"), uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xCell.is());
+    table::BorderLine2 doubled(
+            1, 26, 26, 26, table::BorderLineStyle::DOUBLE, 79);
+    CPPUNIT_ASSERT_BORDER_EQUAL(doubled,
+        getProperty<table::BorderLine2>(xCell, "LeftBorder"));
+    CPPUNIT_ASSERT_BORDER_EQUAL(doubled,
+        getProperty<table::BorderLine2>(xCell, "RightBorder"));
+    CPPUNIT_ASSERT_BORDER_EQUAL(doubled,
+        getProperty<table::BorderLine2>(xCell, "TopBorder"));
+    CPPUNIT_ASSERT_BORDER_EQUAL(doubled,
+        getProperty<table::BorderLine2>(xCell, "BottomBorder"));
+
+    xTable.set(xTables->getByIndex(3), uno::UNO_QUERY);
+    xCell.set(xTable->getCellByName("A1"), uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xCell.is());
+    table::BorderLine2 thinThickMG(
+            1, 14, 26, 14, table::BorderLineStyle::THINTHICK_MEDIUMGAP, 53);
+    CPPUNIT_ASSERT_BORDER_EQUAL(thinThickMG,
+        getProperty<table::BorderLine2>(xCell, "LeftBorder"));
+    CPPUNIT_ASSERT_BORDER_EQUAL(thinThickMG,
+        getProperty<table::BorderLine2>(xCell, "RightBorder"));
+    CPPUNIT_ASSERT_BORDER_EQUAL(thinThickMG,
+        getProperty<table::BorderLine2>(xCell, "TopBorder"));
+    CPPUNIT_ASSERT_BORDER_EQUAL(thinThickMG,
+        getProperty<table::BorderLine2>(xCell, "BottomBorder"));
+}
+
 DECLARE_RTFIMPORT_TEST(testShpzDhgt, "shpz-dhgt.rtf")
 {
     // Test that shpz has priority over dhght and not the other way around.


More information about the Libreoffice-commits mailing list