summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2014-02-25 12:50:46 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-02-25 15:32:48 +0000
commitc1bbe64bead02e4f525f0fcfe169ab4a54a89fe4 (patch)
tree2995dd2472f48b7c862ef1ac8c3572e5045bb4de /sw
parenta606751087a2de4233c3e1fd14a7ddba993ddcea (diff)
rhbz#1065629: RTF import: re-implement nested tables
The previous fix for this bug only fixed a symptom, this a fix for the real problem; with the real problem fixed the nCellEnds is unnecessary. Given that top-level table properties may be put either before or after the table cells, the only way that works to import tables is to buffer a whole top-level table row, but currently the buffer is replayed already at the end of a nested table row. Fortunately the RTF spec guarantees that \nesttableprops must occur after the nested table cells of the nested row, so it should be sufficient to remember the cell properties for the current nested table row only, in addition to the cell properties for the top-level table row. With this change, skipping a \nesttableprops destination when there is a table style turns out to mangle ooo98040-1.rtf badly, so stop doing that workaround. RTFDocumentImpl::popState() was copying various buffers up the state stack which is a clear indication that these shouldn't be members of RTFParserState in the first place, move them to RTFDocumentImpl. (cherry picked from commit c8f83ce1dbf5544f6aaa91775db6820a69c3c061) Conflicts: writerfilter/source/rtftok/rtfdocumentimpl.cxx Change-Id: Ic2d8f7b3e00844b224d61605b405ca651239e5f7 Reviewed-on: https://gerrit.libreoffice.org/8221 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/rtfimport/data/rhbz1065629.rtf20
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx32
2 files changed, 52 insertions, 0 deletions
diff --git a/sw/qa/extras/rtfimport/data/rhbz1065629.rtf b/sw/qa/extras/rtfimport/data/rhbz1065629.rtf
index b22ec506622c..7f37594efb57 100644
--- a/sw/qa/extras/rtfimport/data/rhbz1065629.rtf
+++ b/sw/qa/extras/rtfimport/data/rhbz1065629.rtf
@@ -6,6 +6,26 @@
\f3\ftech\fcharset2 Symbol;
\f4\fswiss\fcharset0 Helvetica;
}
+{\colortbl
+;
+\red127\green255\blue212;
+\red0\green0\blue0;
+\red0\green0\blue255;
+\red255\green0\blue255;
+\red190\green190\blue190;
+\red0\green255\blue0;
+\red50\green205\blue50;
+\red176\green48\blue96;
+\red0\green0\blue128;
+\red85\green107\blue47;
+\red160\green32\blue240;
+\red255\green0\blue0;
+\red192\green192\blue192;
+\red0\green128\blue128;
+\red255\green255\blue255;
+\red255\green255\blue0;
+\red204\green0\blue0;
+}
{\info
{\*\userprops
{\propname creator}\proptype30
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index b389af65f3ed..099bb0b0d644 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -1381,6 +1381,38 @@ DECLARE_RTFIMPORT_TEST(testNestedTable, "rhbz1065629.rtf")
xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(OUString("Nom: John Doe"), xPara->getString());
+
+ // outer table: background color, borders for B1/B2 cell
+ xTable.set(xTables->getByIndex(2), uno::UNO_QUERY);
+ xCell.set(xTable->getCellByName("A1"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xCell.is());
+ table::BorderLine2 fullPtSolid(
+ 1, 0, 35, 0, table::BorderLineStyle::SOLID, 35);
+ CPPUNIT_ASSERT_BORDER_EQUAL(fullPtSolid,
+ getProperty<table::BorderLine2>(xCell, "LeftBorder"));
+ CPPUNIT_ASSERT_BORDER_EQUAL(fullPtSolid,
+ getProperty<table::BorderLine2>(xCell, "RightBorder"));
+ CPPUNIT_ASSERT_BORDER_EQUAL(fullPtSolid,
+ getProperty<table::BorderLine2>(xCell, "TopBorder"));
+ CPPUNIT_ASSERT_BORDER_EQUAL(fullPtSolid,
+ getProperty<table::BorderLine2>(xCell, "BottomBorder"));
+ CPPUNIT_ASSERT_EQUAL(0xCC0000, getProperty<sal_Int32>(xCell, "BackColor"));
+ xCell.set(xTable->getCellByName("A2"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xCell.is());
+ table::BorderLine2 halfPtSolid(
+ /*0*/1, 0, 18, 0, table::BorderLineStyle::SOLID, 18);
+ CPPUNIT_ASSERT_BORDER_EQUAL(halfPtSolid,
+ getProperty<table::BorderLine2>(xCell, "LeftBorder"));
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xffffffff),
+ getProperty<sal_Int32>(xCell, "BackColor"));
+ xCell.set(xTable->getCellByName("B2"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xCell.is());
+ CPPUNIT_ASSERT_BORDER_EQUAL(halfPtSolid,
+ getProperty<table::BorderLine2>(xCell, "LeftBorder"));
+ CPPUNIT_ASSERT_BORDER_EQUAL(halfPtSolid,
+ getProperty<table::BorderLine2>(xCell, "RightBorder"));
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xffffffff),
+ getProperty<sal_Int32>(xCell, "BackColor"));
}
DECLARE_RTFIMPORT_TEST(testCp1000016, "hello.rtf")