[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-6-4' - sw/qa sw/source

Attila Bakos (via logerrit) logerrit at kemper.freedesktop.org
Thu Jul 23 13:50:20 UTC 2020


 sw/qa/extras/uiwriter/data2/tdf130805.odt |binary
 sw/qa/extras/uiwriter/uiwriter2.cxx       |   27 +++++++++++++++++++++++++++
 sw/source/core/doc/textboxhelper.cxx      |   14 ++++++++++++--
 3 files changed, 39 insertions(+), 2 deletions(-)

New commits:
commit 0ae3fb6c1ff152d9d6dc243b3893c2d6fe0946b9
Author:     Attila Bakos <bakos.attilakaroly at nisz.hu>
AuthorDate: Tue May 26 10:09:51 2020 +0200
Commit:     Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Thu Jul 23 15:49:41 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)
    
    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>
    (cherry picked from commit 2479ae3ee20fc5f3cbb0c88eb09110a36e86710c)
    
    Change-Id: I8a47aff57d3a60f7dbd2a1b75296e2664a1f745f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99202
    Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
    Reviewed-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>

diff --git a/sw/qa/extras/uiwriter/data2/tdf130805.odt b/sw/qa/extras/uiwriter/data2/tdf130805.odt
new file mode 100644
index 000000000000..12e215123aa3
Binary files /dev/null and b/sw/qa/extras/uiwriter/data2/tdf130805.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 009e62c08505..9e13ba12fa67 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -51,6 +51,7 @@
 #include <fmtcntnt.hxx>
 #include <shellio.hxx>
 #include <editeng/fontitem.hxx>
+#include <textboxhelper.hxx>
 
 namespace
 {
@@ -2475,6 +2476,32 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testOfz18563)
     TestImportDOCX(aFileStream);
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, 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(sal_uInt8(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_TEST_FIXTURE(SwUiWriterTest2, testTdf129655)
 {
     createDoc("tdf129655-vtextbox.odt");
diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx
index 51daa63f11a4..9ea6fc96b719 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -61,8 +61,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