summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2013-11-22 13:01:53 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2013-11-22 15:29:56 +0100
commite04d21afee4a286d63f836e7375d573dd4b7f73a (patch)
tree5beb1f4fdd35cc690bb53d23561f1f493aaa0000
parent37441c602381804ff186088ee94f045a59aae6e3 (diff)
DOCX drawingML shape filter: import wps:txbx inside the shape
The problem was that previously the shape text was imported normally, and the shape itself was simply appended after the text. In case of the VML import, the following mechanism made it possible to have the shape earlier: OOXMLFastContextHandlerShape::sendShape() is called twice, early in OOXMLFastContextHandlerWrapper::lcl_createFastChildContext(), in case the shape had text, and later in OOXMLFastContextHandlerShape::lcl_endFastElement(), in case the shape didn't have text. This works because the parent element of v:textbox (v:shape) is already something that isn't handled in writerfilter, so the parent of the w:txbxContent's parent was a OOXMLFastContextHandlerWrapper. In case of WPS, the problem was that the parent of w:txbxContent is wps:txbx, and the parent of that is wps:wsp, which is something (unlike v:shape) we do handle in writerfilter. Fix this by adding an early call to sendShape() in OOXMLFastContextHandlerShape::lcl_createFastChildContext() as well. Change-Id: Ia24678871d7bbad89d18b1d5f468c17f68feec10
-rwxr-xr-xsw/qa/extras/ooxmlimport/data/textbox-wps-only.docxbin0 -> 13762 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx8
-rw-r--r--writerfilter/source/ooxml/OOXMLFastContextHandler.cxx6
3 files changed, 14 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/textbox-wps-only.docx b/sw/qa/extras/ooxmlimport/data/textbox-wps-only.docx
new file mode 100755
index 000000000000..897dcbcac375
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/textbox-wps-only.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 90956106eb1f..ea6f8e609b86 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1533,6 +1533,14 @@ DECLARE_OOXMLIMPORT_TEST(lineWpsOnly, "line-wps-only.docx")
CPPUNIT_ASSERT_EQUAL(sal_Int32(210), xShape->getPosition().X);
}
+DECLARE_OOXMLIMPORT_TEST(textboxWpsOnly, "textbox-wps-only.docx")
+{
+ uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("Hello world!"), xFrame->getString());
+}
+
DECLARE_OOXMLIMPORT_TEST(testFdo70457, "fdo70457.docx")
{
// The document contains a rotated bitmap
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index 2b9be07b420e..35a63269a6f4 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -2197,6 +2197,12 @@ OOXMLFastContextHandlerShape::lcl_createFastChildContext
break;
}
+ // VML import of shape text is already handled by
+ // OOXMLFastContextHandlerWrapper::lcl_createFastChildContext(), here we
+ // handle the WPS import of shape text, as there the parent context is a
+ // Shape one, so a different situation.
+ if (Element == static_cast<sal_Int32>(NS_wps | OOXML_txbx))
+ sendShape(Element);
return xContextHandler;
}