editeng/source/editeng/editview.cxx         |   10 +++++++
 editeng/source/editeng/impedit.cxx          |   23 +++++++++++++++++
 editeng/source/editeng/impedit.hxx          |    2 +
 editeng/source/misc/svxacorr.cxx            |    2 -
 include/editeng/editview.hxx                |    2 +
 sd/source/ui/func/fuformatpaintbrush.cxx    |   36 +++++++++++++++++++++++-----
 svx/source/svdraw/svdedxv.cxx               |   18 +++++++++-----
 sw/source/uibase/docvw/edtwin.cxx           |    7 +++--
 sw/source/uibase/uiview/formatclipboard.cxx |   15 +++++++----
 9 files changed, 94 insertions(+), 21 deletions(-)

New commits:
commit 170860775de552f255a48a1f1b37c9b3460c033d
Author:     Sarper Akdemir <sarper.akdemir.ext...@allotropia.de>
AuthorDate: Mon Jul 31 17:11:04 2023 +0300
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Thu Feb 22 13:13:28 2024 +0100

    tdf#103706: tdf#142857: sd: context aware paste for clone format
    
    Introduces selection aware pasting for Impress/Draw's Clone
    Format where paragraph properties are applied when the selection
    contains a whole paragraph or there's no selection at all (i.e.
    clone format applied with just a left click - without drag).
    
    Change-Id: I37e7197580c2b8da333ada1a60408f40f85d7ef5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155108
    Tested-by: Jenkins
    Reviewed-by: Sarper Akdemir <sarper.akdemir.ext...@allotropia.de>

diff --git a/editeng/source/editeng/editview.cxx 
b/editeng/source/editeng/editview.cxx
index 0e3985c49459..72bdd4d18f1c 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -316,6 +316,16 @@ bool EditView::HasSelection() const
     return pImpEditView->HasSelection();
 }
 
+bool EditView::IsSelectionFullPara() const
+{
+    return pImpEditView->IsSelectionFullPara();
+}
+
+bool EditView::IsSelectionWithinSinglePara() const
+{
+    return pImpEditView->IsSelectionInSinglePara();
+}
+
 bool EditView::IsSelectionAtPoint(const Point& rPointPixel)
 {
     return pImpEditView->IsSelectionAtPoint(rPointPixel);
diff --git a/editeng/source/editeng/impedit.cxx 
b/editeng/source/editeng/impedit.cxx
index 92af0e24b848..d03a2185a929 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -2047,6 +2047,29 @@ bool ImpEditView::IsInSelection( const EditPaM& rPaM )
     return false;
 }
 
+bool ImpEditView::IsSelectionFullPara() const
+{
+    if (!IsSelectionInSinglePara())
+        return false;
+
+    sal_Int32 nSelectionStartPos = GetEditSelection().Min().GetIndex();
+    sal_Int32 nSelectionEndPos = GetEditSelection().Max().GetIndex();
+
+    if (nSelectionStartPos > nSelectionEndPos)
+        std::swap(nSelectionStartPos, nSelectionEndPos);
+
+    if (nSelectionStartPos != 0)
+        return false;
+
+    const ContentNode* pNode = GetEditSelection().Min().GetNode();
+    return pNode->Len() == nSelectionEndPos;
+}
+
+bool ImpEditView::IsSelectionInSinglePara() const
+{
+    return GetEditSelection().Min().GetNode() == 
GetEditSelection().Max().GetNode();
+}
+
 void ImpEditView::CreateAnchor()
 {
     pEditEngine->SetInSelectionMode(true);
diff --git a/editeng/source/editeng/impedit.hxx 
b/editeng/source/editeng/impedit.hxx
index 5ff09c67257a..503e79bde400 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -416,6 +416,8 @@ public:
     bool            IsSelectionAtPoint( const Point& rPosPixel );
     bool            IsInSelection( const EditPaM& rPaM );
 
+    bool            IsSelectionFullPara() const;
+    bool            IsSelectionInSinglePara() const;
 
     void            SetAnchorMode( EEAnchorMode eMode );
     EEAnchorMode    GetAnchorMode() const           { return eAnchorMode; }
diff --git a/include/editeng/editview.hxx b/include/editeng/editview.hxx
index f014e3abfeb9..ce0407c36530 100644
--- a/include/editeng/editview.hxx
+++ b/include/editeng/editview.hxx
@@ -210,6 +210,8 @@ public:
     void            SelectCurrentWord( sal_Int16 nWordType = 
css::i18n::WordType::ANYWORD_IGNOREWHITESPACES );
     /// Returns the rectangles of the current selection in TWIPs.
     void GetSelectionRectangles(std::vector<tools::Rectangle>& rLogicRects) 
const;
+    bool IsSelectionFullPara() const;
+    bool IsSelectionWithinSinglePara() const;
 
     bool            IsInsertMode() const;
     void            SetInsertMode( bool bInsert );
diff --git a/sd/source/ui/func/fuformatpaintbrush.cxx 
b/sd/source/ui/func/fuformatpaintbrush.cxx
index ae8f2f79ab74..9bbd30939d53 100644
--- a/sd/source/ui/func/fuformatpaintbrush.cxx
+++ b/sd/source/ui/func/fuformatpaintbrush.cxx
@@ -37,6 +37,25 @@
 
 #include <Window.hxx>
 
+namespace
+{
+// Paragraph properties are pasted if the selection contains a whole paragraph
+// or there was no selection at all (i.e. just a left click)
+bool ShouldPasteParaFormatPerSelection(const OutlinerView* pOLV)
+{
+    if(!pOLV)
+        return true;
+
+    if(!pOLV->GetEditView().HasSelection())
+        return true;
+
+    if(!pOLV->GetEditView().IsSelectionWithinSinglePara())
+        return true;
+
+    return pOLV->GetEditView().IsSelectionFullPara();
+}
+}
+
 namespace sd {
 
 
@@ -166,16 +185,21 @@ bool FuFormatPaintBrush::MouseButtonUp(const MouseEvent& 
rMEvt)
 {
     if( mxItemSet && mpView && mpView->AreObjectsMarked() )
     {
+        OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
+
         bool bNoCharacterFormats = false;
-        bool bNoParagraphFormats = false;
+        bool bNoParagraphFormats = !ShouldPasteParaFormatPerSelection(pOLV);
+
+        if ((rMEvt.GetModifier() & KEY_MOD1) && (rMEvt.GetModifier() & 
KEY_SHIFT))
+        {
+            bNoCharacterFormats = true;
+            bNoParagraphFormats = false;
+        }
+        else if (rMEvt.GetModifier() & KEY_MOD1)
         {
-            if( (rMEvt.GetModifier()&KEY_MOD1) && 
(rMEvt.GetModifier()&KEY_SHIFT) )
-                bNoCharacterFormats = true;
-            else if( rMEvt.GetModifier() & KEY_MOD1 )
-                bNoParagraphFormats = true;
+            bNoParagraphFormats = true;
         }
 
-        OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
         if( pOLV )
             pOLV->MouseButtonUp(rMEvt);
 
commit ecc98d3fa0827f4c078610c9f43faebd62452387
Author:     Sarper Akdemir <sarper.akdemir.ext...@allotropia.de>
AuthorDate: Mon Jul 31 14:05:08 2023 +0300
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Thu Feb 22 13:12:54 2024 +0100

    tdf#103706: tdf#142857: sw: context aware paste for clone format
    
    Introduces selection aware pasting for Writer's Clone Format
    where paragraph properties are applied when the selection
    contains a whole paragraph or there's no selection at all (i.e.
    clone format applied with just a left click - without drag).
    
    Change-Id: I9f3eedb4544bf53dabed4bb659ce2e44313a692a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155107
    Tested-by: Jenkins
    Reviewed-by: Sarper Akdemir <sarper.akdemir.ext...@allotropia.de>

diff --git a/sw/source/uibase/docvw/edtwin.cxx 
b/sw/source/uibase/docvw/edtwin.cxx
index a5bde9e9a1da..418d8bf385a0 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -5121,7 +5121,10 @@ void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt)
             SwWrtShell& rWrtShell = m_rView.GetWrtShell();
             SfxStyleSheetBasePool* pPool=nullptr;
             bool bNoCharacterFormats = false;
-            bool bNoParagraphFormats = false;
+            // Paste paragraph properties if the selection contains a whole 
paragraph or
+            // there was no selection at all (i.e. just a left click)
+            bool bNoParagraphFormats = rSh.HasSelection() && 
rSh.IsSelOnePara() && !rSh.IsSelFullPara();
+
             {
                 SwDocShell* pDocSh = m_rView.GetDocShell();
                 if(pDocSh)
commit 880343d7ed563e13bc3f35445512a1a6c44414be
Author:     Sarper Akdemir <sarper.akdemir.ext...@allotropia.de>
AuthorDate: Mon Jul 31 09:15:28 2023 +0300
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Thu Feb 22 13:12:36 2024 +0100

    related tdf#103706: sw: correct format paintbrush attribute reset
    
    Reset all direct formatting before applying **any** attributes.
    
    For instance, before this patch paragraph font colors were lost
    on apply.
    
    Change-Id: I62d202713e60e7e3690c67d63989179c3d5dc900
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155106
    Tested-by: Jenkins
    Reviewed-by: Sarper Akdemir <sarper.akdemir.ext...@allotropia.de>

diff --git a/sw/source/uibase/uiview/formatclipboard.cxx 
b/sw/source/uibase/uiview/formatclipboard.cxx
index 3065875c3d95..9dfcb06ba030 100644
--- a/sw/source/uibase/uiview/formatclipboard.cxx
+++ b/sw/source/uibase/uiview/formatclipboard.cxx
@@ -450,6 +450,15 @@ void SwFormatClipboard::Paste( SwWrtShell& rWrtShell, 
SfxStyleSheetBasePool* pPo
 
     ItemVector aItemVector;
 
+    if (m_pItemSet_TextAttr && !( nSelectionType & SelectionType::DrawObject))
+    {
+        // reset all direct formatting before applying anything
+        o3tl::sorted_vector<sal_uInt16> aAttrs;
+        for (sal_uInt16 nWhich = RES_CHRATR_BEGIN; nWhich < RES_CHRATR_END; 
nWhich++)
+            aAttrs.insert(nWhich);
+        rWrtShell.ResetAttr({ aAttrs });
+    }
+
     if( nSelectionType & SelectionType::Text )
     {
         // apply the named text and paragraph formatting
@@ -544,12 +553,6 @@ void SwFormatClipboard::Paste( SwWrtShell& rWrtShell, 
SfxStyleSheetBasePool* pPo
                 // copy the stored automatic text attributes in a temporary 
SfxItemSet
                 pTemplateItemSet->Put( *m_pItemSet_TextAttr );
 
-                // reset all direct formatting
-                o3tl::sorted_vector<sal_uInt16> aAttrs;
-                for( sal_uInt16 nWhich = RES_CHRATR_BEGIN; nWhich < 
RES_CHRATR_END; nWhich++ )
-                    aAttrs.insert( nWhich );
-                rWrtShell.ResetAttr( { aAttrs } );
-
                 // only attributes that were not apply by named style 
attributes and automatic
                 // paragraph attributes should be applied
                 lcl_RemoveEqualItems( *pTemplateItemSet, aItemVector );
commit 3379a13e6d2675920d1c9a3bc0229399e195e9f8
Author:     Sarper Akdemir <sarper.akdemir.ext...@allotropia.de>
AuthorDate: Thu Jul 27 21:38:34 2023 +0300
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Thu Feb 22 13:12:26 2024 +0100

    tdf#103706: sw: Revert "Format paintbrush default behaviour"
    
    This reverts commit 1574c76ec20d1da479ed7e9c85a6cefacc132dfe.
    
    Reason for revert: The default behavior should copy *all* formatting.
    
    Change-Id: If3ae81d412374433f2d95a04345c651a788de4f6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155103
    Tested-by: Jenkins
    Reviewed-by: Sarper Akdemir <sarper.akdemir.ext...@allotropia.de>

diff --git a/sw/source/uibase/docvw/edtwin.cxx 
b/sw/source/uibase/docvw/edtwin.cxx
index 47a6a62fef09..a5bde9e9a1da 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -5121,7 +5121,7 @@ void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt)
             SwWrtShell& rWrtShell = m_rView.GetWrtShell();
             SfxStyleSheetBasePool* pPool=nullptr;
             bool bNoCharacterFormats = false;
-            bool bNoParagraphFormats = true;
+            bool bNoParagraphFormats = false;
             {
                 SwDocShell* pDocSh = m_rView.GetDocShell();
                 if(pDocSh)
@@ -5132,7 +5132,7 @@ void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt)
                     bNoParagraphFormats = false;
                 }
                 else if( rMEvt.GetModifier() & KEY_MOD1 )
-                    bNoParagraphFormats = false;
+                    bNoParagraphFormats = true;
             }
             //execute paste
             pFormatClipboard->Paste( rWrtShell, pPool, bNoCharacterFormats, 
bNoParagraphFormats );
commit 416b633613c05947dd8c559177ad99af8873cfc3
Author:     Oliver Specht <oliver.spe...@cib.de>
AuthorDate: Tue Feb 20 15:38:36 2024 +0100
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Thu Feb 22 12:42:25 2024 +0100

    tdf#159797 replace dash also between sentences
    
    Autocorrection replaces " - " with " <enDash/emDash> " also after
    dot, question mark and exclamation mark.
    
    Change-Id: Iad4b6c6073ab90b0c86514b8683dd2a07197f59d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163659
    Tested-by: Jenkins
    Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de>

diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index 56228b2fbf05..cbff35b7c3b2 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -616,7 +616,7 @@ bool SvxAutoCorrect::FnChgToEnEmDash(
                             sImplEndSkipChars,(cCh = rTxt[ --n ])); )
                             ;
                     // found: "[A-z0-9][<AnyEndChars>] - 
[<AnySttChars>][A-z0-9]
-                    if( rCC.isLetterNumeric( OUString(cCh) ))
+                    if (rCC.isLetterNumeric(OUString(cCh)) || 
lcl_IsInArr(u".!?", cCh))
                     {
                         rDoc.Delete( nTmpPos, nTmpPos + nLen );
                         rDoc.Insert( nTmpPos, bAlwaysUseEmDash ? sEmDash : 
sEnDash );
commit 7559706dd498c33864e82c1bb955918a8e148bea
Author:     Oliver Specht <oliver.spe...@cib.de>
AuthorDate: Mon Feb 19 09:52:46 2024 +0100
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Thu Feb 22 12:41:00 2024 +0100

    Make Clone Formatting in Impress similar to PP
    
    In Powerpoint paragraph attributes are only applied from and to
    fully/multiple selected paragraphs.
    
    Change-Id: I7c1f3afb6c0d6fd9b3f8acf34cb5f5b3dcaf22d7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163583
    Tested-by: Jenkins
    Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de>

diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index 3a845ce84462..6955e52b3fc7 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -2785,7 +2785,7 @@ bool SdrObjEditView::SupportsFormatPaintbrush(SdrInventor 
nObjectInventor,
     }
 }
 
-static const WhichRangesContainer& GetFormatRangeImpl(bool bTextOnly)
+static const WhichRangesContainer& GetFormatRangeImpl(bool bTextOnly, bool 
withParagraphAttr = true)
 {
     static const WhichRangesContainer gFull(
         svl::Items<XATTR_LINE_FIRST, XATTR_LINE_LAST, XATTR_FILL_FIRST, 
XATTRSET_FILL,
@@ -2796,10 +2796,13 @@ static const WhichRangesContainer& 
GetFormatRangeImpl(bool bTextOnly)
                    SDRATTR_SOFTEDGE_LAST, EE_PARA_START, EE_PARA_END, 
EE_CHAR_START, EE_CHAR_END>);
 
     static const WhichRangesContainer gTextOnly(
+        svl::Items<SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST, EE_CHAR_START, 
EE_CHAR_END>);
+
+    static const WhichRangesContainer gParaTextOnly(
         svl::Items<SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST, EE_PARA_START, 
EE_PARA_END, EE_CHAR_START,
                    EE_CHAR_END>);
 
-    return bTextOnly ? gTextOnly : gFull;
+    return bTextOnly ? withParagraphAttr ? gParaTextOnly : gTextOnly : gFull;
 }
 
 sal_Int32 SdrObjEditView::TakeFormatPaintBrush(std::shared_ptr<SfxItemSet>& 
rFormatSet)
@@ -2811,12 +2814,14 @@ sal_Int32 
SdrObjEditView::TakeFormatPaintBrush(std::shared_ptr<SfxItemSet>& rFor
 
     OutlinerView* pOLV = GetTextEditOutlinerView();
 
+    bool isParaSelection = pOLV ? pOLV->GetEditView().IsSelectionFullPara() : 
false;
     rFormatSet = std::make_shared<SfxItemSet>(GetModel().GetItemPool(),
-                                              GetFormatRangeImpl(pOLV != 
nullptr));
+                                              GetFormatRangeImpl(pOLV != 
nullptr, isParaSelection));
     if (pOLV)
     {
         rFormatSet->Put(pOLV->GetAttribs());
-        nDepth = pOLV->GetDepth();
+        if (isParaSelection)
+            nDepth = pOLV->GetDepth();
     }
     else
     {
@@ -2984,10 +2989,11 @@ void SdrObjEditView::ApplyFormatPaintBrush(SfxItemSet& 
rFormatSet, sal_Int16 nDe
             const EditEngine& rEditEngine = pOutliner->GetEditEngine();
 
             ESelection aSel(pOLV->GetSelection());
+            bool fullParaSelection
+                = aSel.nEndPara != aSel.nStartPara || 
pOLV->GetEditView().IsSelectionFullPara();
             if (!aSel.HasRange())
                 pOLV->SetSelection(rEditEngine.GetWord(aSel, 
css::i18n::WordType::DICTIONARY_WORD));
-
-            const bool bRemoveParaAttribs = !bNoParagraphFormats;
+            const bool bRemoveParaAttribs = !bNoParagraphFormats && 
!fullParaSelection;
             pOLV->RemoveAttribsKeepLanguages(bRemoveParaAttribs);
             SfxItemSet aSet(pOLV->GetAttribs());
             SfxItemSet aPaintSet(CreatePaintSet(GetFormatRangeImpl(true), 
*aSet.GetPool(),

Reply via email to