editeng/source/outliner/outlvw.cxx |   39 ++++++++++++++++++++++++++++++++
 include/editeng/outliner.hxx       |    1 
 sd/source/ui/func/futext.cxx       |    1 
 sd/source/ui/view/drtxtob.cxx      |   44 +++++++++++++++++++++++++++++++++++++
 sd/source/ui/view/drtxtob1.cxx     |    3 ++
 sd/source/ui/view/drviews2.cxx     |    3 ++
 sd/source/ui/view/drviewsf.cxx     |   11 +++++++--
 svx/source/svdraw/svdedxv.cxx      |   11 +++++----
 8 files changed, 107 insertions(+), 6 deletions(-)

New commits:
commit 1757f5bf108cdee51eecd67a40fde187281fa7c6
Author:     Oliver Specht <oliver.spe...@cib.de>
AuthorDate: Tue Jan 14 14:20:33 2025 +0100
Commit:     Adolfo Jayme Barrientos <fit...@ubuntu.com>
CommitDate: Fri Jan 24 06:52:50 2025 +0100

    tdf#105083 Support status of numbering and bullet list
    
    Shows the status of bullet/numbering in the current text selection
    in the toolbar buttons ToggleUnorder/OrderedList.
    
    Change-Id: I458896293c502da8142ad9cb43b5ea62a9f3b558
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180238
    Tested-by: Jenkins
    Reviewed-by: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de>
    Tested-by: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de>
    (cherry picked from commit 5337205fdc3917760008dac77f1d0f5c4d55fef7)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180549
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>

diff --git a/editeng/source/outliner/outlvw.cxx 
b/editeng/source/outliner/outlvw.cxx
index 62fa083b0321..80b15c89b225 100644
--- a/editeng/source/outliner/outlvw.cxx
+++ b/editeng/source/outliner/outlvw.cxx
@@ -926,6 +926,45 @@ void OutlinerView::ToggleBullets()
     pOwner->UndoActionEnd();
 }
 
+bool OutlinerView::IsBulletOrNumbering(bool& bBullets, bool& bNumbering)
+{
+    //TODO: returns true if the same list is active in the selection,
+    // sets bBullets/bNumbering if the related list type is found
+    bool bBulletFound = false;
+    bool bNumberingFound = false;
+
+    ESelection aSel( pEditView->GetSelection() );
+    aSel.Adjust();
+    for (sal_Int32 nPara = aSel.start.nPara; nPara <= aSel.end.nPara; nPara++)
+    {
+        Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
+        DBG_ASSERT(pPara, "OutlinerView::IsBulletOrNumbering(), illegal 
selection?");
+
+        if( pPara )
+        {
+            if (pOwner->GetDepth(nPara) < 0)
+                return false;
+            const SvxNumberFormat* pFmt = pOwner ->GetNumberFormat(nPara);
+            if (pFmt)
+            {
+                sal_Int16 nNumType = pFmt->GetNumberingType();
+                if (nNumType != SVX_NUM_BITMAP && nNumType != 
SVX_NUM_CHAR_SPECIAL)
+                    bNumberingFound = true;
+                else
+                    bBulletFound = true;
+            }
+        }
+    }
+    if (bNumberingFound)
+    {
+        if (bBulletFound)
+            return false;
+        bNumbering = true;
+    }
+    else
+        bBullets = true;
+    return true;
+}
 
 void OutlinerView::ToggleBulletsNumbering(
     const bool bToggle,
diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx
index b18690050037..6dc9a02a3d97 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -317,6 +317,7 @@ public:
         or disables bullets/numbering for the selected paragraphs if the 
bullets/numbering of the first paragraph is on
     */
     void ToggleBullets();
+    bool IsBulletOrNumbering(bool& bBullets, bool& bNumbering);
 
     void ToggleBulletsNumbering(
         const bool bToggle,
diff --git a/sd/source/ui/func/futext.cxx b/sd/source/ui/func/futext.cxx
index 799dc51c42aa..59f7558e7aa8 100644
--- a/sd/source/ui/func/futext.cxx
+++ b/sd/source/ui/func/futext.cxx
@@ -126,6 +126,7 @@ const sal_uInt16 SidArray[] = {
     SID_PARASPACE_INCREASE,           //   11145
     SID_PARASPACE_DECREASE,           //   11146
     FN_NUM_BULLET_ON,                 //   20138
+    FN_NUM_NUMBERING_ON,              //   20144
                             0 };
 
 
diff --git a/sd/source/ui/view/drtxtob.cxx b/sd/source/ui/view/drtxtob.cxx
index 3e800881960b..92c0d8a62b52 100644
--- a/sd/source/ui/view/drtxtob.cxx
+++ b/sd/source/ui/view/drtxtob.cxx
@@ -53,6 +53,7 @@
 #include <sfx2/objface.hxx>
 
 #include <drawdoc.hxx>
+#include <drawview.hxx>
 #include <DrawDocShell.hxx>
 #include <DrawViewShell.hxx>
 #include <OutlineViewShell.hxx>
@@ -444,6 +445,49 @@ void TextObjectBar::GetAttrStateImpl(ViewShell* 
mpViewShell, ::sd::View* mpView,
             }
             break;
 
+            case FN_NUM_BULLET_ON:
+            case FN_NUM_NUMBERING_ON:
+            {
+                bool bEnable = false;
+                const DrawViewShell* pDrawViewShell = dynamic_cast< 
DrawViewShell* >(mpViewShell);
+                if (pDrawViewShell)
+                {
+                    SdrView* pDrawView = pDrawViewShell->GetDrawView();
+                    //TODO: is pDrawView always available?
+                    const SdrMarkList& rMarkList = 
pDrawView->GetMarkedObjectList();
+                    const size_t nMarkCount = rMarkList.GetMarkCount();
+                    for (size_t nIndex = 0; nIndex < nMarkCount; ++nIndex)
+                    {
+                        SdrTextObj* pTextObj = 
DynCastSdrTextObj(rMarkList.GetMark(nIndex)->GetMarkedSdrObj());
+                        if (pTextObj && pTextObj->GetObjInventor() == 
SdrInventor::Default)
+                        {
+                            if (pTextObj->GetObjIdentifier() != 
SdrObjKind::OLE2)
+                            {
+                                bEnable = true;
+                                break;
+                            }
+                        }
+                    }
+                    if (bEnable)
+                    {
+                        bool bIsBullet = false;
+                        bool bIsNumbering = false;
+                        OutlinerView* pOlView = 
pDrawView->GetTextEditOutlinerView();
+                        if (pOlView)
+                        {
+                            pOlView->IsBulletOrNumbering(bIsBullet, 
bIsNumbering);
+                        }
+                        rSet.Put(SfxBoolItem(FN_NUM_BULLET_ON, bIsBullet));
+                        rSet.Put(SfxBoolItem(FN_NUM_NUMBERING_ON, 
bIsNumbering));
+                    }
+                    else
+                    {
+                        rSet.DisableItem(FN_NUM_BULLET_ON);
+                        rSet.DisableItem(FN_NUM_NUMBERING_ON);
+                    }
+                }
+            }
+            break;
             default:
             break;
         }
diff --git a/sd/source/ui/view/drtxtob1.cxx b/sd/source/ui/view/drtxtob1.cxx
index 9058f7ad30a0..c4763de8dd3f 100644
--- a/sd/source/ui/view/drtxtob1.cxx
+++ b/sd/source/ui/view/drtxtob1.cxx
@@ -476,6 +476,9 @@ void TextObjectBar::ExecuteImpl(ViewShell* mpViewShell, 
::sd::View* mpView, SfxR
                         }
                     }
                 }
+                SfxBindings& rBindings = 
mpViewShell->GetViewFrame()->GetBindings();
+                rBindings.Invalidate( FN_NUM_BULLET_ON );
+                rBindings.Invalidate( FN_NUM_NUMBERING_ON );
             }
             break;
         }
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index ce9359fbebc3..fc011865e7fa 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -1521,6 +1521,9 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
         {
             SetCurrentFunction( FuBulletAndPosition::Create( this, 
GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
             Cancel();
+            SfxBindings& rBindings = GetViewFrame()->GetBindings();
+            rBindings.Invalidate( FN_NUM_BULLET_ON );
+            rBindings.Invalidate( FN_NUM_NUMBERING_ON );
         }
         break;
 
diff --git a/sd/source/ui/view/drviewsf.cxx b/sd/source/ui/view/drviewsf.cxx
index 8444d9129b57..d864a3c1ecd0 100644
--- a/sd/source/ui/view/drviewsf.cxx
+++ b/sd/source/ui/view/drviewsf.cxx
@@ -704,8 +704,15 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet )
                 }
                 if (bEnable)
                 {
-                    rSet.Put(SfxBoolItem(FN_NUM_BULLET_ON, false));
-                    rSet.Put(SfxBoolItem(FN_NUM_NUMBERING_ON, false));
+                    bool bIsBullet = false;
+                    bool bIsNumbering = false;
+                    OutlinerView* pOlView = 
mpDrawView->GetTextEditOutlinerView();
+                    if (pOlView)
+                    {
+                        pOlView->IsBulletOrNumbering(bIsBullet, bIsNumbering);
+                    }
+                    rSet.Put(SfxBoolItem(FN_NUM_BULLET_ON, bIsBullet));
+                    rSet.Put(SfxBoolItem(FN_NUM_NUMBERING_ON, bIsNumbering));
                 }
                 else
                 {
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index 374c38baf00e..cd7cb89b2e05 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -2830,10 +2830,13 @@ sal_uInt16 SdrObjEditView::GetSelectionLevel() const
     for (sal_Int32 nPara = nStartPara; nPara <= nEndPara; nPara++)
     {
         sal_Int16 nDepth = mpTextEditOutliner->GetDepth(nPara);
-        assert(nDepth >= 0 && nDepth <= 15);
-        sal_uInt16 nParaDepth = 1 << static_cast<sal_uInt16>(nDepth);
-        if (!(nLevel & nParaDepth))
-            nLevel += nParaDepth;
+        assert(nDepth <= 15);
+        if (nDepth >= 0)
+        {
+            sal_uInt16 nParaDepth = 1 << static_cast<sal_uInt16>(nDepth);
+            if (!(nLevel & nParaDepth))
+                nLevel += nParaDepth;
+        }
     }
     //reduce one level for Outliner Object
     //if( nLevel > 0 && GetTextEditObject()->GetObjIdentifier() == 
OBJ_OUTLINETEXT )

Reply via email to