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

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Fri May 3 13:28:38 UTC 2019


 sw/qa/extras/uiwriter/data/test_anchor_as_character.odt |binary
 sw/qa/extras/uiwriter/uiwriter.cxx                      |   21 ++++++++++++++++
 sw/source/core/edit/autofmt.cxx                         |    4 ++-
 sw/source/core/txtnode/atrflyin.cxx                     |    2 -
 4 files changed, 25 insertions(+), 2 deletions(-)

New commits:
commit b6d8403847c02c95b2b8570cffb68fd57a999ef4
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Thu May 2 18:27:07 2019 +0200
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Fri May 3 15:27:53 2019 +0200

    tdf#123285 sw_redlinehide: fix SwAutoFormat::DelMoreLinesBlanks()
    
    The "Delete spaces and tabs at end and start of line" AutoFormat
    option was deleting the wrong characters: on the 2nd line, it deletes
    the spaces as it should, but on subsequent lines the selection is off by
    the number of characters that have already been removed.
    
    The range indexes are now integers, so not automatically corrected on
    deletions like the SwIndex they were before; in this case, where only
    plain characters are deleted, it should suffice to iterate the ranges in
    reverse order to avoid the problem.
    
    (regression from 180e5f515c9cd21fb8057c797a480eca7d9ed260)
    
    Change-Id: Ie8e08c00803d94e700cd5b64f29edb0b841eda2b
    Reviewed-on: https://gerrit.libreoffice.org/71686
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>
    (cherry picked from commit b69bc0facc6e0fbc2006125e656b82a7c2556203)
    Reviewed-on: https://gerrit.libreoffice.org/71721
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx
index b12d9a1605ff..456008c5fdd5 100644
--- a/sw/source/core/edit/autofmt.cxx
+++ b/sw/source/core/edit/autofmt.cxx
@@ -1309,8 +1309,10 @@ void SwAutoFormat::DelMoreLinesBlanks( bool bWithLineBreaks )
         std::vector<std::pair<TextFrameIndex, TextFrameIndex>> spaces;
         aFInfo.GetSpaces(spaces, !m_aFlags.bAFormatByInput || bWithLineBreaks);
 
-        for (auto & rSpaceRange : spaces)
+        // tdf#123285 iterate backwards - delete invalidates following indexes
+        for (auto iter = spaces.rbegin(); iter != spaces.rend(); ++iter)
         {
+            auto & rSpaceRange(*iter);
             assert(rSpaceRange.first != rSpaceRange.second);
             bool const bHasBlanks = HasSelBlanks(
                     m_pCurTextFrame, rSpaceRange.first,
commit 45362d31ce0504ebcb7bbcf846d9dcc57d7210bd
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Thu May 2 17:10:30 2019 +0200
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Fri May 3 15:27:44 2019 +0200

    tdf#125039 sw_redlinehide: keep shape selected when changing anchor type
    
    Avoid the problem by not moving the drawing object to the invisible
    layer, which isn't necessary because it will be inserted immediately
    anyway.
    
    (regression from 214e6ed5286566e689a4ef13a9115e2ad38fff57)
    
    Change-Id: I9936de990d1db56fa4c00c37d05b4ed2923790ff
    Reviewed-on: https://gerrit.libreoffice.org/71685
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>
    (cherry picked from commit 40df8019ff3a8b1fd87b3e20e154fc487ab4a7db)
    Reviewed-on: https://gerrit.libreoffice.org/71720
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/sw/qa/extras/uiwriter/data/test_anchor_as_character.odt b/sw/qa/extras/uiwriter/data/test_anchor_as_character.odt
new file mode 100644
index 000000000000..cad88f5bfd09
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/test_anchor_as_character.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index e8ed45a9f13b..e16e78beba22 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -177,6 +177,7 @@ public:
     void testTdf98512();
     void testShapeTextboxSelect();
     void testShapeTextboxDelete();
+    void testAnchorChangeSelection();
     void testCp1000071();
     void testShapeTextboxVertadjust();
     void testShapeTextboxAutosize();
@@ -377,6 +378,7 @@ public:
     CPPUNIT_TEST(testTdf98512);
     CPPUNIT_TEST(testShapeTextboxSelect);
     CPPUNIT_TEST(testShapeTextboxDelete);
+    CPPUNIT_TEST(testAnchorChangeSelection);
     CPPUNIT_TEST(testCp1000071);
     CPPUNIT_TEST(testShapeTextboxVertadjust);
     CPPUNIT_TEST(testShapeTextboxAutosize);
@@ -1259,6 +1261,25 @@ void SwUiWriterTest::testShapeTextboxDelete()
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), nActual);
 }
 
+void SwUiWriterTest::testAnchorChangeSelection()
+{
+    SwDoc* pDoc = createDoc("test_anchor_as_character.odt");
+    SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+    SdrPage* pPage = pDoc->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
+    SdrObject* pObject = pPage->GetObj(0);
+    CPPUNIT_ASSERT(pObject);
+
+    // Then select it.
+    pWrtShell->SelectObj(Point(), 0, pObject);
+    const SdrMarkList& rMarkList = pWrtShell->GetDrawView()->GetMarkedObjectList();
+    CPPUNIT_ASSERT_EQUAL(pObject, rMarkList.GetMark(0)->GetMarkedSdrObj());
+
+    pWrtShell->ChgAnchor(RndStdIds::FLY_AS_CHAR);
+
+    // tdf#125039 shape must still be selected, extensions depend on that
+    CPPUNIT_ASSERT_EQUAL(pObject, rMarkList.GetMark(0)->GetMarkedSdrObj());
+}
+
 void SwUiWriterTest::testCp1000071()
 {
     SwDoc* pDoc = createDoc("cp1000071.odt");
diff --git a/sw/source/core/txtnode/atrflyin.cxx b/sw/source/core/txtnode/atrflyin.cxx
index a8fe920630a3..1509c0cf3d40 100644
--- a/sw/source/core/txtnode/atrflyin.cxx
+++ b/sw/source/core/txtnode/atrflyin.cxx
@@ -198,7 +198,7 @@ void SwTextFlyCnt::SetAnchor( const SwTextNode *pNode )
         {
             if (SdrObject const*const pObj = pFormat->FindSdrObject())
             {   // tdf#123259 disconnect with *old* anchor position
-                static_cast<SwDrawContact*>(::GetUserCall(pObj))->DisconnectFromLayout();
+                static_cast<SwDrawContact*>(::GetUserCall(pObj))->DisconnectFromLayout(false);
             }
         }
         pFormat->SetFormatAttr( aAnchor );  // only set the anchor


More information about the Libreoffice-commits mailing list