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

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Thu Mar 28 13:38:27 UTC 2019


 sw/qa/extras/uiwriter/data2/tdf122942.odt |binary
 sw/qa/extras/uiwriter/uiwriter2.cxx       |   34 ++++++++++++++++++++++++++++++
 sw/source/core/frmedt/feshview.cxx        |   23 ++++++++++++--------
 3 files changed, 48 insertions(+), 9 deletions(-)

New commits:
commit 099623ce41dde76e80f8559abcbb9e03f292d688
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Jan 28 17:18:34 2019 +0100
Commit:     Xisco FaulĂ­ <xiscofauli at libreoffice.org>
CommitDate: Thu Mar 28 14:38:00 2019 +0100

    tdf#122942 sw: update shape insert UI for the AddVerticalFrameOffsets option
    
    Regression from commit 50223ea6e212b60b7d33839c2753c5601fb50f95
    (tdf#98987 sw: add AddVerticalFrameOffsets compat mode, 2016-03-31),
    SwFEShell::ImpEndCreate() was not adapted to call
    SwTextFrame::GetBaseVertOffsetForFly() when determining the vertical
    position of the inserted shape.
    
    The call can be unconditional, the returned value is already 0 when the
    DocumentSettingId::ADD_VERTICAL_FLY_OFFSETS compat setting is false.
    
    (cherry picked from commit 4218caf142a7ecac34548c6d38c6f6fbebb898b9)
    
    Conflicts:
            sw/qa/extras/uiwriter/uiwriter2.cxx
    
    Change-Id: Iec6af5a6d1ff3466e08377853cc8ca84f33a76d1
    Reviewed-on: https://gerrit.libreoffice.org/69766
    Tested-by: Jenkins
    Reviewed-by: Xisco FaulĂ­ <xiscofauli at libreoffice.org>

diff --git a/sw/qa/extras/uiwriter/data2/tdf122942.odt b/sw/qa/extras/uiwriter/data2/tdf122942.odt
new file mode 100644
index 000000000000..c56583d305f2
Binary files /dev/null and b/sw/qa/extras/uiwriter/data2/tdf122942.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index c0d4fdd1d34b..52768e05086e 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -22,6 +22,7 @@
 #include <wrtsh.hxx>
 #include <redline.hxx>
 #include <UndoManager.hxx>
+#include <fmtornt.hxx>
 
 namespace
 {
@@ -43,6 +44,7 @@ public:
     void testTdf105413();
     void testTdf101873();
     void testTableWidth();
+    void testTdf122942();
 
     CPPUNIT_TEST_SUITE(SwUiWriterTest2);
     CPPUNIT_TEST(testRedlineMoveInsertInDelete);
@@ -56,6 +58,7 @@ public:
     CPPUNIT_TEST(testTdf105413);
     CPPUNIT_TEST(testTdf101873);
     CPPUNIT_TEST(testTableWidth);
+    CPPUNIT_TEST(testTdf122942);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -497,6 +500,37 @@ void SwUiWriterTest2::testTableWidth()
                          getProperty<sal_Int16>(xTables->getByIndex(0), "RelativeWidth"));
 }
 
+void SwUiWriterTest2::testTdf122942()
+{
+    load(DATA_DIRECTORY, "tdf122942.odt");
+    SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+    SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+
+    // Do the moral equivalent of mouse button down, move and up.
+    // Start creating a custom shape that overlaps with the rounded rectangle
+    // already present in the document.
+    Point aStartPos(8000, 3000);
+    pWrtShell->BeginCreate(static_cast<sal_uInt16>(OBJ_CUSTOMSHAPE), aStartPos);
+
+    // Set its size.
+    Point aMovePos(10000, 5000);
+    pWrtShell->MoveCreate(aMovePos);
+
+    // Finish creation.
+    pWrtShell->EndCreate(SdrCreateCmd::ForceEnd);
+
+    // Make sure that the shape is inserted.
+    SwDoc* pDoc = pWrtShell->GetDoc();
+    const SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats();
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rFormats.size());
+
+    // Without the accompanying fix in place, this test would have failed with
+    // 'Expected less than: 0; Actual  : 1030', i.e. the shape was below the
+    // paragraph mark, not above it.
+    const SwFormatVertOrient& rVert = rFormats[1]->GetVertOrient();
+    CPPUNIT_ASSERT_LESS(static_cast<SwTwips>(0), rVert.GetPos());
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest2);
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx
index 0343286e18b5..0d7a871c52c3 100644
--- a/sw/source/core/frmedt/feshview.cxx
+++ b/sw/source/core/frmedt/feshview.cxx
@@ -1951,17 +1951,22 @@ bool SwFEShell::ImpEndCreate()
             nXOffset = pAnch->getFrameArea().Left()+pAnch->getFrameArea().Width()-rBound.Right();
         else
             nXOffset = rBound.Left() - pAnch->getFrameArea().Left();
-        if( pAnch->IsTextFrame() && static_cast<const SwTextFrame*>(pAnch)->IsFollow() )
+        if (pAnch->IsTextFrame())
         {
             const SwTextFrame* pTmp = static_cast<const SwTextFrame*>(pAnch);
-            do {
-                pTmp = pTmp->FindMaster();
-                OSL_ENSURE( pTmp, "Where's my Master?" );
-                // OD 2004-03-30 #i26791# - correction: add frame area height
-                // of master frames.
-                nYOffset += pTmp->IsVertical() ?
-                            pTmp->getFrameArea().Width() : pTmp->getFrameArea().Height();
-            } while ( pTmp->IsFollow() );
+            if (pTmp->IsFollow())
+            {
+                do {
+                    pTmp = pTmp->FindMaster();
+                    OSL_ENSURE(pTmp, "Where's my Master?");
+                    // OD 2004-03-30 #i26791# - correction: add frame area height
+                    // of master frames.
+                    nYOffset += pTmp->IsVertical() ?
+                                pTmp->getFrameArea().Width() : pTmp->getFrameArea().Height();
+                } while (pTmp->IsFollow());
+            }
+
+            nYOffset -= pTmp->GetBaseVertOffsetForFly(false);
         }
     }
 


More information about the Libreoffice-commits mailing list