fdo#68779: RTF import: set borders without explicit width

Word reportedly uses 0.75pt as a default if \brdrw is missing.

Change-Id: I263c56f756c65ff6bb30870aa70806564d5826a6
This commit is contained in:
Michael Stahl 2014-03-14 19:03:09 +01:00
parent cc847b5885
commit 84f4de3b65
3 changed files with 90 additions and 1 deletions

View File

@ -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

View File

@ -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}

View File

@ -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.