summaryrefslogtreecommitdiff
path: root/sw/qa/extras/ooxmlexport
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-09-18 15:47:59 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-09-18 15:57:12 +0200
commit419054c0f19acb323a0e51c7ef49a1a2d9f42ac8 (patch)
tree551edbbc0d7e249fe0a86b7b46e15f1ec8c33c99 /sw/qa/extras/ooxmlexport
parent1c1fe7afb77e0538cdc4081ee266a7bda80f7b05 (diff)
DOCX import: fix handling of dropdown SDT around cell
There were two problems here: 1) The CT_SdtContentCell handlers didn't emit the usual NS_ooxml::LN_CT_SdtBlock_sdtContent / NS_ooxml::LN_CT_SdtBlock_sdtEndContent tokens, so the dropdown control was not created (and then was created with the wrong anchor). 2) In case the SDT was around the cell, the newline character was also added to the text of the currently selected entry, resulting in an invalid argument of SwXText::convertToTable(), so no table was created. Change-Id: I4806626181f40c6d26ff7b25f5dbb863967d8077
Diffstat (limited to 'sw/qa/extras/ooxmlexport')
-rw-r--r--sw/qa/extras/ooxmlexport/data/dropdown-in-cell.docxbin0 -> 13262 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx17
2 files changed, 17 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/dropdown-in-cell.docx b/sw/qa/extras/ooxmlexport/data/dropdown-in-cell.docx
new file mode 100644
index 000000000000..8abe25f82e2c
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/dropdown-in-cell.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 4dd7dfc9ad1e..92965f09a9ed 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -25,6 +25,7 @@
#include <com/sun/star/text/XTextFramesSupplier.hpp>
#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
#include <com/sun/star/text/XTextSection.hpp>
+#include <com/sun/star/text/XTextRangeCompare.hpp>
#include <com/sun/star/style/CaseMap.hpp>
#include <com/sun/star/style/ParagraphAdjust.hpp>
#include <com/sun/star/style/LineSpacing.hpp>
@@ -253,6 +254,22 @@ DECLARE_OOXMLEXPORT_TEST(testEmptyAnnotationMark, "empty-annotation-mark.docx")
}
}
+DECLARE_OOXMLEXPORT_TEST(testDropdownInCell, "dropdown-in-cell.docx")
+{
+ // First problem: table was missing from the document, this was 0.
+ uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
+
+ // Second problem: dropdown shape wasn't anchored inside the B1 cell.
+ uno::Reference<text::XTextContent> xShape(getShape(1), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xAnchor = xShape->getAnchor();
+ uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xCell(xTable->getCellByName("B1"), uno::UNO_QUERY);
+ uno::Reference<text::XTextRangeCompare> xTextRangeCompare(xCell, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextRangeCompare->compareRegionStarts(xAnchor, xCell));
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */