summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2013-07-01 12:20:09 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2013-09-06 19:30:48 +0200
commit180c8178e8c99295b5d122faffc44330cfca954d (patch)
tree0820698a0ebb1c435acaf6a03436cd0bad1b68d4
parent8f9f4232ca0cc5d2f8692083caf6a5f2494e5ce3 (diff)
bnc#779642 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 (cherry picked from commit f24e4c74d7d6a7d95090c6fa6a584fed7787706c)
-rw-r--r--oox/inc/oox/vml/vmltextboxcontext.hxx1
-rw-r--r--oox/source/vml/vmltextbox.cxx7
-rw-r--r--oox/source/vml/vmltextboxcontext.cxx6
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx2
4 files changed, 15 insertions, 1 deletions
diff --git a/oox/inc/oox/vml/vmltextboxcontext.hxx b/oox/inc/oox/vml/vmltextboxcontext.hxx
index a644026f7b4d..b3240608309c 100644
--- a/oox/inc/oox/vml/vmltextboxcontext.hxx
+++ b/oox/inc/oox/vml/vmltextboxcontext.hxx
@@ -63,6 +63,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 5a5d75c970dc..490a8973dd87 100644
--- a/oox/source/vml/vmltextbox.cxx
+++ b/oox/source/vml/vmltextbox.cxx
@@ -94,6 +94,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 17b087220c0f..903f64e49dd8 100644
--- a/oox/source/vml/vmltextboxcontext.cxx
+++ b/oox/source/vml/vmltextboxcontext.cxx
@@ -217,6 +217,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 6f07128fbdfb..9a0e08f89306 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -375,7 +375,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);