[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - sw/qa sw/source

Attila Bakos (via logerrit) logerrit at kemper.freedesktop.org
Fri Jun 19 13:13:06 UTC 2020


 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 2479ae3ee20fc5f3cbb0c88eb09110a36e86710c
Author:     Attila Bakos <bakos.attilakaroly at nisz.hu>
AuthorDate: Tue May 26 10:09:51 2020 +0200
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Fri Jun 19 15:12:34 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 <nemeth at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>
    (cherry picked from commit 06e2cbb31d0ea703df872b91eb8eacdcaced7653)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95976
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.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 2ba1db6974d2..cdb1e5c3bb41 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>
 
@@ -525,6 +529,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 e2b1e9fa6498..ae7084605e4c 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -63,8 +63,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());


More information about the Libreoffice-commits mailing list