summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-12-21 16:02:12 +0100
committerMiklos Vajna <vmiklos@collabora.com>2020-12-21 16:39:50 +0100
commit714b8efc9c4143da31d435f7ccb2bf02704a1b5f (patch)
tree389ffccf09f6a2e77e16759c596566b83bab89b3
parent67ab09b0765321f055160cfe5e2413c6dd24e02e (diff)
Revert "tdf#138739 sw: fix regression of first paragraph"
This reverts commit 25ca25ee25278536c56a2ac4a63af91100ce4d2e. cd sw; make -sr CppunitTest_sw_uiwriter3 CPPUNIT_TEST_NAME="testTdf130805" breaks with this one, it just went in due to an old baseline. Change-Id: Ie68f2847b936aefba3198ddd915316a204210d4b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108105 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rwxr-xr-xsw/qa/extras/ooxmlexport/data/tdf138739.docxbin16780 -> 0 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport15.cxx8
-rw-r--r--sw/source/core/doc/textboxhelper.cxx19
3 files changed, 17 insertions, 10 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf138739.docx b/sw/qa/extras/ooxmlexport/data/tdf138739.docx
deleted file mode 100755
index 7b5bb302bfa1..000000000000
--- a/sw/qa/extras/ooxmlexport/data/tdf138739.docx
+++ /dev/null
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
index b06f90fe9622..c91488efb93b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
@@ -425,14 +425,6 @@ DECLARE_OOXMLEXPORT_TEST(testTdf98000_changePageStyle, "tdf98000_changePageStyle
CPPUNIT_ASSERT_MESSAGE("Different page1/page2 styles", sPageOneStyle != sPageTwoStyle);
}
-DECLARE_OOXMLEXPORT_TEST(testTdf138739, "tdf138739.docx")
-{
- uno::Reference<beans::XPropertySet> xParaProps(getParagraph(1), uno::UNO_QUERY);
-
- CPPUNIT_ASSERT_EQUAL_MESSAGE("Font type name does not match!", OUString("Comic Sans MS"),
- xParaProps->getPropertyValue("CharFontName").get<OUString>());
-}
-
DECLARE_OOXMLEXPORT_TEST(testTdf135216_evenOddFooter, "tdf135216_evenOddFooter.odt")
{
uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx
index 0e2aa715cbd8..cbf1384bd27c 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -83,8 +83,23 @@ void SwTextBoxHelper::create(SwFrameFormat* pShape, bool bCopyText)
pShape->GetDoc()->GetDocShell()->GetBaseModel(), uno::UNO_QUERY);
uno::Reference<text::XTextContentAppend> xTextContentAppend(xTextDocument->getText(),
uno::UNO_QUERY);
- xTextContentAppend->appendTextContent(xTextFrame, uno::Sequence<beans::PropertyValue>());
-
+ try
+ {
+ SdrObject* pSourceSDRShape = pShape->FindRealSdrObject();
+ uno::Reference<text::XTextContent> XSourceShape(pSourceSDRShape->getUnoShape(),
+ uno::UNO_QUERY_THROW);
+ xTextContentAppend->insertTextContentWithProperties(
+ xTextFrame, uno::Sequence<beans::PropertyValue>(), XSourceShape->getAnchor());
+ }
+ catch (uno::Exception&)
+ {
+ // Before the textframe was appended now it is inserted to the begin of the doc in order
+ // to prevent crash when someone removes the para where the textframe anchored:
+ uno::Reference<text::XTextCursor> xCursor = xTextDocument->getText()->createTextCursor();
+ xCursor->gotoStart(false);
+ xTextContentAppend->insertTextContentWithProperties(
+ xTextFrame, uno::Sequence<beans::PropertyValue>(), xCursor->getStart());
+ }
// Link FLY and DRAW formats, so it becomes a text box (needed for syncProperty calls).
uno::Reference<text::XTextFrame> xRealTextFrame(xTextFrame, uno::UNO_QUERY);
auto pTextFrame = dynamic_cast<SwXTextFrame*>(xRealTextFrame.get());