sw/qa/extras/uiwriter/data3/tdf130805.odt |binary sw/qa/extras/uiwriter/uiwriter3.cxx | 31 ++++++++++++++++++++++++++++++ sw/source/core/doc/textboxhelper.cxx | 14 +++++++++++-- 3 files changed, 43 insertions(+), 2 deletions(-)
New commits: commit 06e2cbb31d0ea703df872b91eb8eacdcaced7653 Author: Attila Bakos <bakos.attilakar...@nisz.hu> AuthorDate: Tue May 26 10:09:51 2020 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Wed Jun 10 10:05:35 2020 +0200 tdf#130805 SwTextBoxHelper::create: fix frame position in shape Text frame added by menu option "Add Text Box" of a shape was misplaced if there were more paragraphs after the shape anchor position. Co-authored-by: Tibor Nagy (NISZ) Change-Id: I8a47aff57d3a60f7dbd2a1b75296e2664a1f745f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94822 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/sw/qa/extras/uiwriter/data3/tdf130805.odt b/sw/qa/extras/uiwriter/data3/tdf130805.odt new file mode 100644 index 000000000000..12e215123aa3 Binary files /dev/null and b/sw/qa/extras/uiwriter/data3/tdf130805.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx index 2a3a749401c9..8668749f134d 100644 --- a/sw/qa/extras/uiwriter/uiwriter3.cxx +++ b/sw/qa/extras/uiwriter/uiwriter3.cxx @@ -13,6 +13,10 @@ #include <com/sun/star/text/TextContentAnchorType.hpp> #include <comphelper/propertysequence.hxx> #include <boost/property_tree/json_parser.hpp> +#include <frameformats.hxx> +#include <textboxhelper.hxx> +#include <fmtanchr.hxx> +#include <o3tl/safeint.hxx> #include <wrtsh.hxx> @@ -548,6 +552,33 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf80663) CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTextTable->getColumns()->getCount()); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf130805) +{ + load(DATA_DIRECTORY, "tdf130805.odt"); + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + SwWrtShell* pWrtSh = pTextDoc->GetDocShell()->GetWrtShell(); + CPPUNIT_ASSERT(pWrtSh); + + const SwFrameFormats& rFrmFormats = *pWrtSh->GetDoc()->GetSpzFrameFormats(); + CPPUNIT_ASSERT(rFrmFormats.size() >= size_t(o3tl::make_unsigned(1))); + auto pShape = rFrmFormats.front(); + CPPUNIT_ASSERT(pShape); + + SwTextBoxHelper::create(pShape); + auto pTxBxFrm = SwTextBoxHelper::getOtherTextBoxFormat(getShape(1)); + CPPUNIT_ASSERT(pTxBxFrm); + + auto pTxAnch = pTxBxFrm->GetAnchor().GetContentAnchor(); + auto pShpAnch = pShape->GetAnchor().GetContentAnchor(); + CPPUNIT_ASSERT(pTxAnch); + CPPUNIT_ASSERT(pShpAnch); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("The textbox got apart!", pTxAnch->nNode, pShpAnch->nNode); + //CPPUNIT_ASSERT_EQUAL_MESSAGE("", xShp->getPosition().Y, xShp2->getPosition().Y); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf96067) { mxComponent = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument"); diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index 1dcc7e242016..5f1462e2eb49 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -62,8 +62,18 @@ void SwTextBoxHelper::create(SwFrameFormat* pShape) 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&) + { + xTextContentAppend->appendTextContent(xTextFrame, uno::Sequence<beans::PropertyValue>()); + } // 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()); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits