sw/qa/extras/uiwriter/uiwriter.cxx |   49 -------------------------------------
 sw/source/uibase/wrtsh/wrtsh1.cxx  |   21 ---------------
 2 files changed, 70 deletions(-)

New commits:
commit 08ede5d51a33f83ededee8a03c10f9bb8244690e
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Wed Oct 13 14:56:44 2021 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu Oct 14 12:23:37 2021 +0200

    tdf#134426 tdf#138873 sw:  Revert "tdf#79717 ...
    
    ...save/restore character format on selection overwrite"
    which might also fix tdf#144638 as well.
    
    This reverts LO 6.3 commit 6abed0ea006f3616e40faf2ae782cf64f8ac2914.
    
    This 6.3 fix for bug 79717 has caused too many other problems
    that are not being looked at, so it should just be reverted.
    It is spamming documents with direct formatting which
    is a terrible thing to have happen by accident.
    It completely wrecks the proper use of styles.
    
    Also revert asscoiated follow-up commits:
    Revert "tdf#79717 save/restore character style on selection overwrite"
    This reverts commit 6.3 04bd1925706360414438b814046b543c5e317d0a.
    
    Revert "tdf#79717: sw_uiwriter: Add unittest"
    This reverts commit 7.1 b05955b480fe4d32852e7be8a118d46ca7e6dbfa.
    
    These effectively revert 7.0.4 12eac5bcbc9b71bf00cb88b918988826229cca35
    but its unit test is left intact.
    
    Change-Id: Ideced4d38bfdf4c82f1744534afbaad29689fded
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123566
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <justin_l...@sil.org>
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123577
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx 
b/sw/qa/extras/uiwriter/uiwriter.cxx
index 702dc90636fd..8579f46b9b87 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -216,7 +216,6 @@ public:
     void testCaretPositionMovingUp();
     void testTdf93441();
     void testTdf81226();
-    void testTdf79717();
     void testTdf137532();
     void testFdo87448();
     void testTextCursorInvalidation();
@@ -451,7 +450,6 @@ public:
     CPPUNIT_TEST(testCaretPositionMovingUp);
     CPPUNIT_TEST(testTdf93441);
     CPPUNIT_TEST(testTdf81226);
-    CPPUNIT_TEST(testTdf79717);
     CPPUNIT_TEST(testTdf137532);
     CPPUNIT_TEST(testFdo87448);
     CPPUNIT_TEST(testTextCursorInvalidation);
@@ -2069,53 +2067,6 @@ void SwUiWriterTest::testTdf81226()
     CPPUNIT_ASSERT_EQUAL(OUString("beforeafter"), 
getParagraph(1)->getString());
 }
 
-void SwUiWriterTest::testTdf79717()
-{
-    SwDoc* const pDoc = createDoc();
-    SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
-    pWrtShell->Insert("normal");
-    lcl_setWeight(pWrtShell, WEIGHT_BOLD);
-    pWrtShell->Insert("bold");
-    pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, 
/*bBasicCall=*/false);
-    // Select 'bol' and replace it
-    pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/true, 3, 
/*bBasicCall=*/false);
-    pWrtShell->Insert("bol");
-
-    // Without the fix in place, 'bol' would have been replaced with normal 
font weight
-
-    auto xText = getParagraph(1)->getText();
-    CPPUNIT_ASSERT(xText.is());
-    {
-        auto xCursor(xText->createTextCursorByRange(getRun(getParagraph(1), 
1)));
-        CPPUNIT_ASSERT(xCursor.is());
-        CPPUNIT_ASSERT_EQUAL(OUString("normal"), xCursor->getString());
-        CPPUNIT_ASSERT_EQUAL(awt::FontWeight::NORMAL, 
getProperty<float>(xCursor, "CharWeight"));
-    }
-    {
-        auto xCursor(xText->createTextCursorByRange(getRun(getParagraph(1), 
2)));
-        CPPUNIT_ASSERT(xCursor.is());
-        CPPUNIT_ASSERT_EQUAL(OUString("bold"), xCursor->getString());
-        CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, 
getProperty<float>(xCursor, "CharWeight"));
-    }
-
-    // Now select characters from both runs and replace them
-    pWrtShell->EndPara();
-    pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/true, 5, 
/*bBasicCall=*/false);
-    pWrtShell->Insert("new");
-    {
-        auto xCursor(xText->createTextCursorByRange(getRun(getParagraph(1), 
1)));
-        CPPUNIT_ASSERT(xCursor.is());
-        CPPUNIT_ASSERT_EQUAL(OUString("norma"), xCursor->getString());
-        CPPUNIT_ASSERT_EQUAL(awt::FontWeight::NORMAL, 
getProperty<float>(xCursor, "CharWeight"));
-    }
-    {
-        auto xCursor(xText->createTextCursorByRange(getRun(getParagraph(1), 
2)));
-        CPPUNIT_ASSERT(xCursor.is());
-        CPPUNIT_ASSERT_EQUAL(OUString("new"), xCursor->getString());
-        CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, 
getProperty<float>(xCursor, "CharWeight"));
-    }
-}
-
 void SwUiWriterTest::testTdf137532()
 {
     SwDoc* const pDoc = createDoc();
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx 
b/sw/source/uibase/wrtsh/wrtsh1.cxx
index 8251a9978142..bec2831d5531 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -198,11 +198,6 @@ void SwWrtShell::Insert( const OUString &rStr )
          bCallIns = m_bIns /*|| bHasSel*/;
     bool bDeleted = false;
 
-    typedef svl::Items<RES_CHRATR_BEGIN, RES_CHRATR_RSID - 1,
-                       RES_CHRATR_RSID + 1, RES_CHRATR_END - 1,
-                       RES_TXTATR_CHARFMT, RES_TXTATR_CHARFMT> CharItems;
-    SfxItemSet aCharAttrSet(GetAttrPool(), CharItems{});
-
     if( bHasSel || ( !m_bIns && SelectHiddenRange() ) )
     {
             // Only here parenthesizing, because the normal
@@ -220,12 +215,6 @@ void SwWrtShell::Insert( const OUString &rStr )
             aRewriter.AddRule(UndoArg3, aTmpStr);
         }
 
-        // tdf#79717 Save character formatting of the start of the selection
-        const SwPosition *pStart = GetCursor()->Start();
-        SwPaM aPaM(pStart->nNode.GetNode(), pStart->nContent.GetIndex(),
-                   pStart->nNode.GetNode(), pStart->nContent.GetIndex() + 1);
-        GetPaMAttr(&aPaM, aCharAttrSet);
-
         StartUndo(SwUndoId::REPLACE, &aRewriter);
         bStarted = true;
         Push();
@@ -238,16 +227,6 @@ void SwWrtShell::Insert( const OUString &rStr )
     bCallIns ?
         SwEditShell::Insert2( rStr, bDeleted ) : SwEditShell::Overwrite( rStr 
);
 
-    if( bDeleted )
-    {
-        // tdf#79717 Restore formatting of the deleted selection
-        SwPosition* pEnd = GetCursor()->Start();
-        SwPaM aPaM(pEnd->nNode.GetNode(), pEnd->nContent.GetIndex() - 
rStr.getLength(),
-                   pEnd->nNode.GetNode(), pEnd->nContent.GetIndex());
-
-        SetAttrSet(aCharAttrSet, SetAttrMode::DEFAULT, &aPaM);
-    }
-
     if( bStarted )
     {
         EndUndo();

Reply via email to