diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2013-07-01 12:20:09 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2013-07-02 11:55:42 +0200 |
commit | f24e4c74d7d6a7d95090c6fa6a584fed7787706c (patch) | |
tree | b94d3592a7f592e16680afdcd55016b8937e329d | |
parent | b1f78c44c1acc246f06a963383232c9bf649a06b (diff) |
fdo#46361 oox: handle multiple w:p for groupshape textboxes
One testcase had to be adjusted, as it seems previously we stripped all
newlines at the end (I consider that as a bug), and now we only strip
the last one (so the resulting number of paragraphs on the shape and in
the source document equal).
Change-Id: Ic22b96c2992b53c72e2609e2286622173b86065c
-rw-r--r-- | include/oox/vml/vmltextboxcontext.hxx | 1 | ||||
-rw-r--r-- | oox/source/vml/vmltextbox.cxx | 7 | ||||
-rw-r--r-- | oox/source/vml/vmltextboxcontext.cxx | 6 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 2 |
4 files changed, 15 insertions, 1 deletions
diff --git a/include/oox/vml/vmltextboxcontext.hxx b/include/oox/vml/vmltextboxcontext.hxx index 755d2d594e3e..1a44e41ee4b1 100644 --- a/include/oox/vml/vmltextboxcontext.hxx +++ b/include/oox/vml/vmltextboxcontext.hxx @@ -65,6 +65,7 @@ public: virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); + virtual void onEndElement(); private: TextBox& mrTextBox; diff --git a/oox/source/vml/vmltextbox.cxx b/oox/source/vml/vmltextbox.cxx index 1499091a8cfd..27b423491a4d 100644 --- a/oox/source/vml/vmltextbox.cxx +++ b/oox/source/vml/vmltextbox.cxx @@ -95,6 +95,13 @@ void TextBox::convert(uno::Reference<drawing::XShape> xShape) const xTextAppend->appendTextPortion(aIt->maText, aPropSeq); } + // Remove the last character of the shape text, if it would be a newline. + uno::Reference< text::XTextCursor > xCursor = xTextAppend->createTextCursor(); + xCursor->gotoEnd(false); + xCursor->goLeft(1, true); + if (xCursor->getString() == "\n") + xCursor->setString(""); + if ( maLayoutFlow == "vertical" ) { uno::Reference<beans::XPropertySet> xProperties(xShape, uno::UNO_QUERY); diff --git a/oox/source/vml/vmltextboxcontext.cxx b/oox/source/vml/vmltextboxcontext.cxx index c04b6244d252..4c025c9068cc 100644 --- a/oox/source/vml/vmltextboxcontext.cxx +++ b/oox/source/vml/vmltextboxcontext.cxx @@ -219,6 +219,12 @@ ContextHandlerRef TextBoxContext::onCreateContext( sal_Int32 nElement, const Att return 0; } +void TextBoxContext::onEndElement() +{ + if (getCurrentElement() == OOX_TOKEN(doc, p)) + mrTextBox.appendPortion( TextFontModel(), "\n" ); +} + // ============================================================================ } // namespace vml diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 985bd66b80cd..7eaaa9fa8e14 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -365,7 +365,7 @@ xray ThisComponent.DrawPage(1).getByIndex(0).Anchor.PageStyleName uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); uno::Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(1), uno::UNO_QUERY); uno::Reference<text::XTextRange> xShape(xShapes->getByIndex(0), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("TEXT1"), xShape->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("TEXT1\n"), xShape->getString()); // we want to test the textbox is on the first page (it was put onto another page without the fix), // use a small trick and instead of checking the page layout, check the page style uno::Reference<text::XTextContent> xTextContent(xShape, uno::UNO_QUERY); |