[Libreoffice-commits] core.git: sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Mar 13 10:28:19 UTC 2019


 sw/source/uibase/wrtsh/wrtsh1.cxx |   28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

New commits:
commit 6abed0ea006f3616e40faf2ae782cf64f8ac2914
Author:     Phil Krylov <phil.krylov at gmail.com>
AuthorDate: Sun Feb 10 04:31:15 2019 +0300
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Wed Mar 13 11:27:52 2019 +0100

    tdf#79717 save/restore character format on selection overwrite
    
    Change-Id: Ic82c50d07cf4a2208a6e2956c8b9ebc4f8630b31
    Reviewed-on: https://gerrit.libreoffice.org/67597
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx
index 6d9a11eeb984..8ea052499b4f 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -41,6 +41,7 @@
 #include <svtools/ehdl.hxx>
 #include <svtools/soerr.hxx>
 #include <unotools/moduleoptions.hxx>
+#include <editeng/rsiditem.hxx>
 #include <editeng/sizeitem.hxx>
 #include <editeng/formatbreakitem.hxx>
 #include <editeng/svxacorr.hxx>
@@ -185,6 +186,10 @@ void SwWrtShell::Insert( const OUString &rStr )
          bCallIns = m_bIns /*|| bHasSel*/;
     bool bDeleted = false;
 
+    SfxItemSet aCharAttrSet(
+        GetAttrPool(),
+        svl::Items<RES_CHRATR_BEGIN, RES_CHRATR_END - 1>{});
+
     if( bHasSel || ( !m_bIns && SelectHiddenRange() ) )
     {
             // Only here parenthesizing, because the normal
@@ -204,6 +209,13 @@ 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);
+        aCharAttrSet.ClearItem(RES_CHRATR_RSID);
+        GetPaMAttr(&aPaM, aCharAttrSet);
+
         StartUndo(SwUndoId::REPLACE, &aRewriter);
         bStarted = true;
         bDeleted = DelRight();
@@ -212,6 +224,22 @@ 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());
+
+        std::set<sal_uInt16> aAttribs;
+        for (sal_uInt16 i = RES_CHRATR_BEGIN; i < RES_CHRATR_END; ++i)
+            if (i != sal_uInt16(RES_CHRATR_RSID))
+                aAttribs.insert(aAttribs.end(), i);
+        ResetAttr(aAttribs, &aPaM);
+
+        SetAttrSet(aCharAttrSet, SetAttrMode::DEFAULT, &aPaM);
+    }
+
     if( bStarted )
     {
         EndAllAction();


More information about the Libreoffice-commits mailing list