summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2014-04-23 14:34:54 +0200
committerLuboš Luňák <l.lunak@collabora.com>2014-04-23 14:57:36 +0200
commitcf33af732ed0d3d553bb74636e3b14c55d44c153 (patch)
tree2e83f55d54ab51faa1121f4bc31f71ec9e34fdd3 /sw
parent71b4af858ea698f9c3fcffdfc61e3f70a7b10f63 (diff)
handle w:gridBefore by faking cells (fdo#38414)
Docx's w:gridBefore means that there should be this given space in the table grid before any cells come. But writer requires tables to be rectangular, so the space needs to be faked using cells without border. So far so good, but now reality in the form of the retarded overdesigned writerfilter comes. The internal representation of table data (and not just one actually) is pretty non-obvious and hard to modify, seems to be modelled just to follow the parser data the way it comes. Moreover dmapper gets notified of w:gridBefore only after cells in the row have been already processed. So after futile attempts to add the fake cells somehow in dmapper I've eventually given up and hacked up input handling to fake input as if the fake cells were actually there (which was tedious to find out as well, but at least it's reasonably doable). Change-Id: I7107e13f28dd3f7093688782f64238167cead76f
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlimport/data/gridbefore.docxbin0 -> 4987 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx12
2 files changed, 12 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/gridbefore.docx b/sw/qa/extras/ooxmlimport/data/gridbefore.docx
new file mode 100644
index 000000000000..571fb48eaa9a
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/gridbefore.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 2f1f0cdb5c82..7ca648c6c9b5 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -2065,6 +2065,18 @@ DECLARE_OOXMLIMPORT_TEST(testFdo55381, "fdo55381.docx")
CPPUNIT_ASSERT_EQUAL(sal_Int16(4), xCursor->getPage());
}
+DECLARE_OOXMLIMPORT_TEST(testGridBefore, "gridbefore.docx")
+{
+ // w:gridBefore is faked by inserting two cells without border (because Writer can't do non-rectangular tables).
+ // So check the first cell in the first row is in fact 3rd and that it's more to the right than the second
+ // cell on the second row.
+ OUString textA3 = parseDump("/root/page/body/tab/row[1]/cell[1]/txt/text()" );
+ OUString leftA3 = parseDump("/root/page/body/tab/row[1]/cell[1]/infos/bounds", "left" );
+ OUString leftB2 = parseDump("/root/page/body/tab/row[2]/cell[2]/infos/bounds", "left" );
+ CPPUNIT_ASSERT_EQUAL( OUString( "A3" ), textA3 );
+ CPPUNIT_ASSERT( leftA3.toInt32() > leftB2.toInt32());
+}
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();