From 5eea6974d937148a9a1f3d078c2174fe8d420d31 Mon Sep 17 00:00:00 2001 From: Sarper Akdemir Date: Mon, 31 Jul 2023 17:11:04 +0300 Subject: 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 --- sd/source/ui/func/fuformatpaintbrush.cxx | 36 ++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'sd') diff --git a/sd/source/ui/func/fuformatpaintbrush.cxx b/sd/source/ui/func/fuformatpaintbrush.cxx index 40bde764ffaa..0d2b29d33d75 100644 --- a/sd/source/ui/func/fuformatpaintbrush.cxx +++ b/sd/source/ui/func/fuformatpaintbrush.cxx @@ -37,6 +37,25 @@ #include +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 { @@ -165,16 +184,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); -- cgit