editeng/source/outliner/outlvw.cxx        |   18 ++++++++++++++++++
 include/editeng/outliner.hxx              |    2 ++
 include/svx/sdr/table/tablecontroller.hxx |    2 +-
 include/svx/selectioncontroller.hxx       |    2 +-
 include/svx/svdedxv.hxx                   |    8 ++++----
 sd/source/ui/func/fuformatpaintbrush.cxx  |    7 ++++---
 sd/source/ui/inc/fuformatpaintbrush.hxx   |    1 +
 svx/source/svdraw/selectioncontroller.cxx |    4 +++-
 svx/source/svdraw/svdedxv.cxx             |   29 ++++++++++++++++++++---------
 svx/source/table/tablecontroller.cxx      |    5 +++--
 10 files changed, 57 insertions(+), 21 deletions(-)

New commits:
commit bbe1f37645cf864c7c974d36cf2fe3a73d0c085f
Author:     Oliver Specht <oliver.spe...@cib.de>
AuthorDate: Tue Feb 6 14:08:12 2024 +0100
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Fri Feb 9 00:05:39 2024 +0100

    Clone Formatting in Impress: Include list attribute
    
    Copies list type and list level from source to target paragraph(s).
    Also switches off lists, if source is not in a list.
    
    Change-Id: I260f1d7d9936476f16c355a3a09204b3fb4592d0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163054
    Tested-by: Jenkins
    Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de>

diff --git a/editeng/source/outliner/outlvw.cxx 
b/editeng/source/outliner/outlvw.cxx
index 8daeee025c9b..e3e28207d11e 100644
--- a/editeng/source/outliner/outlvw.cxx
+++ b/editeng/source/outliner/outlvw.cxx
@@ -384,6 +384,24 @@ void OutlinerView::Select( Paragraph const * pParagraph, 
bool bSelect )
     pEditView->SetSelection( aSel );
 }
 
+void OutlinerView::SetDepth(sal_Int32 nParagraph, sal_Int16 nDepth)
+{
+    Paragraph* pParagraph = pOwner->GetParagraph(nParagraph);
+    pOwner->SetDepth(pParagraph, nDepth);
+}
+
+sal_Int16 OutlinerView::GetDepth() const
+{
+    ESelection aESelection = GetSelection();
+    aESelection.Adjust();
+    sal_Int16 nDepth = pOwner->GetDepth(aESelection.nStartPara);
+    for (sal_Int32 nPara = aESelection.nStartPara + 1; nPara <= 
aESelection.nEndPara; ++nPara)
+    {
+        if (nDepth != pOwner->GetDepth(nPara))
+            return -2;
+    }
+    return nDepth;
+}
 
 void OutlinerView::SetAttribs( const SfxItemSet& rAttrs )
 {
diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx
index 35860b762037..23158264d54b 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -243,6 +243,8 @@ public:
     void        SelectRange( sal_Int32 nFirst, sal_Int32 nCount );
     void        SetAttribs( const SfxItemSet& );
     void        Indent( short nDiff );
+    sal_Int16   GetDepth() const;
+    void        SetDepth(sal_Int32 nParagraph, sal_Int16 nDepth);
     void        AdjustDepth( short nDX );   // Later replace with Indent!
 
     void        AdjustHeight( tools::Long nDY );
diff --git a/include/svx/sdr/table/tablecontroller.hxx 
b/include/svx/sdr/table/tablecontroller.hxx
index 91b9ca7ce7b2..ecbd7642b478 100644
--- a/include/svx/sdr/table/tablecontroller.hxx
+++ b/include/svx/sdr/table/tablecontroller.hxx
@@ -67,7 +67,7 @@ public:
     SVX_DLLPRIVATE virtual bool GetStyleSheet( SfxStyleSheet* &rpStyleSheet ) 
const override;
     SVX_DLLPRIVATE virtual bool SetStyleSheet( SfxStyleSheet* pStyleSheet, 
bool bDontRemoveHardAttr ) override;
 
-    SVX_DLLPRIVATE virtual bool ApplyFormatPaintBrush( SfxItemSet& rFormatSet, 
bool bNoCharacterFormats, bool bNoParagraphFormats ) override;
+    SVX_DLLPRIVATE virtual bool ApplyFormatPaintBrush( SfxItemSet& rFormatSet, 
sal_Int16 nDepth, bool bNoCharacterFormats, bool bNoParagraphFormats ) override;
 
     // slots
     SVX_DLLPRIVATE void onInsert( sal_uInt16 nSId, const SfxItemSet* pArgs = 
nullptr );
diff --git a/include/svx/selectioncontroller.hxx 
b/include/svx/selectioncontroller.hxx
index 97adb57542c5..7794f3567f1e 100644
--- a/include/svx/selectioncontroller.hxx
+++ b/include/svx/selectioncontroller.hxx
@@ -70,7 +70,7 @@ public:
         if bNoCharacterFormats is true, no character attributes are changed.
         if bNoParagraphFormats is true, no paragraph attributes are changed.
     */
-    virtual bool ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool 
bNoCharacterFormats, bool bNoParagraphFormats );
+    virtual bool ApplyFormatPaintBrush( SfxItemSet& rFormatSet, sal_Int16 
nDepth, bool bNoCharacterFormats, bool bNoParagraphFormats );
     /// This is a table object, and one or more of its cells are selected.
     virtual bool hasSelectedCells() const;
     /// Allows adjusting the point or mark of the selection to a document 
coordinate.
diff --git a/include/svx/svdedxv.hxx b/include/svx/svdedxv.hxx
index ff3fcbd19b79..8ad7f048b682 100644
--- a/include/svx/svdedxv.hxx
+++ b/include/svx/svdedxv.hxx
@@ -301,17 +301,17 @@ public:
     /** returns true if the shape identified by its inventor and identifier 
supports format paint brush operation */
     static bool SupportsFormatPaintbrush( SdrInventor nObjectInventor, 
SdrObjKind nObjectIdentifier );
 
-    /** returns a format paint brush set from the current selection */
-    void TakeFormatPaintBrush( std::shared_ptr< SfxItemSet >& rFormatSet  );
+    /** fills a format paint brush set from the current selection and returns 
the numbering depth */
+    sal_Int32 TakeFormatPaintBrush( std::shared_ptr< SfxItemSet >& rFormatSet  
);
 
     /** applies a format paint brush set from the current selection.
         if bNoCharacterFormats is true, no character attributes are changed.
         if bNoParagraphFormats is true, no paragraph attributes are changed.
     */
-    void ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool 
bNoCharacterFormats, bool bNoParagraphFormats );
+    void ApplyFormatPaintBrush( SfxItemSet& rFormatSet, sal_Int16 nDepth, bool 
bNoCharacterFormats, bool bNoParagraphFormats );
 
     /** helper function for selections with multiple SdrText for one 
SdrTextObj (f.e. tables ) */
-    static void ApplyFormatPaintBrushToText( SfxItemSet const & rFormatSet, 
SdrTextObj& rTextObj, SdrText* pText, bool bNoCharacterFormats, bool 
bNoParagraphFormats );
+    static void ApplyFormatPaintBrushToText( SfxItemSet const & rFormatSet, 
SdrTextObj& rTextObj, SdrText* pText, sal_Int16 nDepth, bool 
bNoCharacterFormats, bool bNoParagraphFormats );
 
     void DisposeUndoManager();
 
diff --git a/sd/source/ui/func/fuformatpaintbrush.cxx 
b/sd/source/ui/func/fuformatpaintbrush.cxx
index 0d2b29d33d75..9bbd30939d53 100644
--- a/sd/source/ui/func/fuformatpaintbrush.cxx
+++ b/sd/source/ui/func/fuformatpaintbrush.cxx
@@ -61,7 +61,8 @@ namespace sd {
 
 FuFormatPaintBrush::FuFormatPaintBrush( ViewShell* pViewSh, ::sd::Window* 
pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
 : FuText(pViewSh, pWin, pView, pDoc, rReq)
-, mbPermanent( false )
+    , mnDepth(-1)
+    , mbPermanent( false )
 , mbOldIsQuickTextEditMode( true )
 {
 }
@@ -83,7 +84,7 @@ void FuFormatPaintBrush::DoExecute( SfxRequest& rReq )
 
     if( mpView )
     {
-        mpView->TakeFormatPaintBrush( mxItemSet );
+        mnDepth = mpView->TakeFormatPaintBrush( mxItemSet );
     }
 }
 
@@ -274,7 +275,7 @@ void FuFormatPaintBrush::Paste( bool bNoCharacterFormats, 
bool bNoParagraphForma
             mpDoc->AddUndo( mpDoc->GetSdrUndoFactory().CreateUndoAttrObject( 
*pObj, false, true ) );
     }
 
-    mpView->ApplyFormatPaintBrush( *mxItemSet, bNoCharacterFormats, 
bNoParagraphFormats );
+    mpView->ApplyFormatPaintBrush( *mxItemSet, mnDepth, bNoCharacterFormats, 
bNoParagraphFormats );
 
     if( pObj )
     {
diff --git a/sd/source/ui/inc/fuformatpaintbrush.hxx 
b/sd/source/ui/inc/fuformatpaintbrush.hxx
index 5c819372d7a2..0ec15e0fffac 100644
--- a/sd/source/ui/inc/fuformatpaintbrush.hxx
+++ b/sd/source/ui/inc/fuformatpaintbrush.hxx
@@ -52,6 +52,7 @@ private:
     void implcancel();
 
     std::shared_ptr<SfxItemSet> mxItemSet;
+    sal_Int16 mnDepth;
     bool   mbPermanent;
     bool   mbOldIsQuickTextEditMode;
 };
diff --git a/svx/source/svdraw/selectioncontroller.cxx 
b/svx/source/svdraw/selectioncontroller.cxx
index 43112953fad7..1fcac6b87ea0 100644
--- a/svx/source/svdraw/selectioncontroller.cxx
+++ b/svx/source/svdraw/selectioncontroller.cxx
@@ -95,7 +95,9 @@ bool SelectionController::PasteObjModel( const SdrModel& 
/*rModel*/ )
     return false;
 }
 
-bool SelectionController::ApplyFormatPaintBrush( SfxItemSet& /*rFormatSet*/, 
bool /*bNoCharacterFormats*/, bool /*bNoParagraphFormats*/ )
+bool SelectionController::ApplyFormatPaintBrush(SfxItemSet& /*rFormatSet*/, 
sal_Int16 /*nDepth*/,
+                                                bool /*bNoCharacterFormats*/,
+                                                bool /*bNoParagraphFormats*/)
 {
     return false;
 }
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index f2ea7c9ddeeb..dbcc73a63cf1 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -2797,11 +2797,12 @@ static const WhichRangesContainer& 
GetFormatRangeImpl(bool bTextOnly)
     return bTextOnly ? gTextOnly : gFull;
 }
 
-void SdrObjEditView::TakeFormatPaintBrush(std::shared_ptr<SfxItemSet>& 
rFormatSet)
+sal_Int32 SdrObjEditView::TakeFormatPaintBrush(std::shared_ptr<SfxItemSet>& 
rFormatSet)
 {
+    sal_Int32 nDepth = -2;
     const SdrMarkList& rMarkList = GetMarkedObjectList();
     if (rMarkList.GetMarkCount() <= 0)
-        return;
+        return nDepth;
 
     OutlinerView* pOLV = GetTextEditOutlinerView();
 
@@ -2810,6 +2811,7 @@ void 
SdrObjEditView::TakeFormatPaintBrush(std::shared_ptr<SfxItemSet>& rFormatSe
     if (pOLV)
     {
         rFormatSet->Put(pOLV->GetAttribs());
+        nDepth = pOLV->GetDepth();
     }
     else
     {
@@ -2828,6 +2830,7 @@ void 
SdrObjEditView::TakeFormatPaintBrush(std::shared_ptr<SfxItemSet>& rFormatSe
             mxSelectionController->GetAttributes(*rFormatSet, false);
         }
     }
+    return nDepth;
 }
 
 static SfxItemSet CreatePaintSet(const WhichRangesContainer& pRanges, 
SfxItemPool& rPool,
@@ -2863,8 +2866,8 @@ static SfxItemSet CreatePaintSet(const 
WhichRangesContainer& pRanges, SfxItemPoo
 }
 
 void SdrObjEditView::ApplyFormatPaintBrushToText(SfxItemSet const& rFormatSet, 
SdrTextObj& rTextObj,
-                                                 SdrText* pText, bool 
bNoCharacterFormats,
-                                                 bool bNoParagraphFormats)
+                                                 SdrText* pText, sal_Int16 
nDepth,
+                                                 bool bNoCharacterFormats, 
bool bNoParagraphFormats)
 {
     OutlinerParaObject* pParaObj = pText ? pText->GetOutlinerParaObject() : 
nullptr;
     if (!pParaObj)
@@ -2887,6 +2890,9 @@ void 
SdrObjEditView::ApplyFormatPaintBrushToText(SfxItemSet const& rFormatSet, S
         aSet.Put(CreatePaintSet(GetFormatRangeImpl(true), *aSet.GetPool(), 
rFormatSet, aSet,
                                 bNoCharacterFormats, bNoParagraphFormats));
         rOutliner.SetParaAttribs(nPara, aSet);
+        Paragraph* pParagraph = rOutliner.GetParagraph(nPara);
+        if (nDepth > -2)
+            rOutliner.SetDepth(pParagraph, nDepth);
     }
 
     std::optional<OutlinerParaObject> pTemp = rOutliner.CreateParaObject(0, 
nParaCount);
@@ -2909,11 +2915,11 @@ void SdrObjEditView::DisposeUndoManager()
     mpOldTextEditUndoManager = nullptr;
 }
 
-void SdrObjEditView::ApplyFormatPaintBrush(SfxItemSet& rFormatSet, bool 
bNoCharacterFormats,
-                                           bool bNoParagraphFormats)
+void SdrObjEditView::ApplyFormatPaintBrush(SfxItemSet& rFormatSet, sal_Int16 
nDepth,
+                                           bool bNoCharacterFormats, bool 
bNoParagraphFormats)
 {
     if (mxSelectionController.is()
-        && mxSelectionController->ApplyFormatPaintBrush(rFormatSet, 
bNoCharacterFormats,
+        && mxSelectionController->ApplyFormatPaintBrush(rFormatSet, nDepth, 
bNoCharacterFormats,
                                                         bNoParagraphFormats))
     {
         return;
@@ -2960,8 +2966,8 @@ void SdrObjEditView::ApplyFormatPaintBrush(SfxItemSet& 
rFormatSet, bool bNoChara
             while (--nText >= 0)
             {
                 SdrText* pText = pTextObj->getText(nText);
-                ApplyFormatPaintBrushToText(rFormatSet, *pTextObj, pText, 
bNoCharacterFormats,
-                                            bNoParagraphFormats);
+                ApplyFormatPaintBrushToText(rFormatSet, *pTextObj, pText, 
nDepth,
+                                            bNoCharacterFormats, 
bNoParagraphFormats);
             }
         }
     }
@@ -2983,6 +2989,11 @@ void SdrObjEditView::ApplyFormatPaintBrush(SfxItemSet& 
rFormatSet, bool bNoChara
                                                 rFormatSet, aSet, 
bNoCharacterFormats,
                                                 bNoParagraphFormats));
             pOLV->SetAttribs(aPaintSet);
+            if (!bNoParagraphFormats && nDepth > -2)
+            {
+                for (sal_Int32 nPara = aSel.nStartPara; nPara <= 
aSel.nEndPara; ++nPara)
+                    pOLV->SetDepth(nPara, nDepth);
+            }
         }
     }
 
diff --git a/svx/source/table/tablecontroller.cxx 
b/svx/source/table/tablecontroller.cxx
index 78363db198a4..874fd1cfee81 100644
--- a/svx/source/table/tablecontroller.cxx
+++ b/svx/source/table/tablecontroller.cxx
@@ -2922,7 +2922,8 @@ bool SvxTableController::PasteObject( SdrTableObj const * 
pPasteTableObj )
     return true;
 }
 
-bool SvxTableController::ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool 
bNoCharacterFormats, bool bNoParagraphFormats )
+bool SvxTableController::ApplyFormatPaintBrush(SfxItemSet& rFormatSet, 
sal_Int16 nDepth,
+                                               bool bNoCharacterFormats, bool 
bNoParagraphFormats)
 {
     if(!mbCellSelectionMode)
     {
@@ -2953,7 +2954,7 @@ bool SvxTableController::ApplyFormatPaintBrush( 
SfxItemSet& rFormatSet, bool bNo
                 if (bUndo)
                     xCell->AddUndo();
                 SdrText* pText = xCell.get();
-                SdrObjEditView::ApplyFormatPaintBrushToText( rFormatSet, 
rTableObj, pText, bNoCharacterFormats, bNoParagraphFormats );
+                SdrObjEditView::ApplyFormatPaintBrushToText( rFormatSet, 
rTableObj, pText, nDepth, bNoCharacterFormats, bNoParagraphFormats );
             }
         }
     }

Reply via email to