diff options
-rw-r--r-- | svx/source/tbxctrls/bulletsnumbering.cxx | 5 | ||||
-rw-r--r-- | sw/sdi/_textsh.sdi | 1 | ||||
-rw-r--r-- | sw/source/uibase/shells/textsh1.cxx | 12 | ||||
-rw-r--r-- | sw/source/uibase/shells/txtnum.cxx | 33 |
4 files changed, 47 insertions, 4 deletions
diff --git a/svx/source/tbxctrls/bulletsnumbering.cxx b/svx/source/tbxctrls/bulletsnumbering.cxx index 8bf8327612ba..413cbc183025 100644 --- a/svx/source/tbxctrls/bulletsnumbering.cxx +++ b/svx/source/tbxctrls/bulletsnumbering.cxx @@ -215,10 +215,7 @@ void SAL_CALL NumberingToolBoxControl::initialize( const css::uno::Sequence< css ToolBox* pToolBox = nullptr; ToolBoxItemId nId; if (getToolboxId(nId, &pToolBox)) - { - ToolBoxItemBits nBits = ( mePageType == NumberingPageType::OUTLINE ) ? ToolBoxItemBits::DROPDOWNONLY : ToolBoxItemBits::DROPDOWN; - pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | nBits ); - } + pToolBox->SetItemBits(nId, pToolBox->GetItemBits(nId) | ToolBoxItemBits::DROPDOWN); } OUString SAL_CALL NumberingToolBoxControl::getImplementationName() diff --git a/sw/sdi/_textsh.sdi b/sw/sdi/_textsh.sdi index 4537c6e96428..71ccb441c6de 100644 --- a/sw/sdi/_textsh.sdi +++ b/sw/sdi/_textsh.sdi @@ -883,6 +883,7 @@ interface BaseText FN_SVX_SET_OUTLINE [ ExecMethod = ExecSetNumber; + StateMethod = GetState; DisableFlags="SfxDisableFlags::SwOnProtectedCursor"; ] SID_OUTLINE_BULLET // status(final|play) diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index adf0496e513a..f86621c78a56 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -2291,6 +2291,18 @@ void SwTextShell::GetState( SfxItemSet &rSet ) !rSh.GetNumRuleAtCurrentSelection())); break; + case FN_SVX_SET_OUTLINE: + { + NBOTypeMgrBase* pOutline = NBOutlineTypeMgrFact::CreateInstance(NBOType::Outline); + auto pCurRule = const_cast<SwNumRule*>(rSh.GetNumRuleAtCurrCursorPos()); + if (pOutline && pCurRule) + { + SvxNumRule aSvxRule = pCurRule->MakeSvxNumRule(); + const sal_uInt16 nIndex = pOutline->GetNBOIndexForNumRule(aSvxRule, 0); + rSet.Put(SfxBoolItem(FN_SVX_SET_OUTLINE, nIndex < USHRT_MAX)); + } + break; + } case FN_BUL_NUM_RULE_INDEX: case FN_NUM_NUM_RULE_INDEX: case FN_OUTLINE_RULE_INDEX: diff --git a/sw/source/uibase/shells/txtnum.cxx b/sw/source/uibase/shells/txtnum.cxx index 34a95d13ee8e..3410d962ff79 100644 --- a/sw/source/uibase/shells/txtnum.cxx +++ b/sw/source/uibase/shells/txtnum.cxx @@ -17,6 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <comphelper/dispatchcommand.hxx> +#include <comphelper/propertysequence.hxx> #include <sfx2/request.hxx> #include <svl/eitem.hxx> #include <svl/stritem.hxx> @@ -310,6 +312,37 @@ void SwTextShell::ExecSetNumber(SfxRequest const &rReq) GetShell().SetCurNumRule( aNewNumRule, bCreateNewList ); } } + else if (nSlot == FN_SVX_SET_OUTLINE) + { + // FN_SVX_SET_NUMBER and FN_SVX_SET_BULLET are only dropdown actions, + // but FN_SVX_SET_OUTLINE is different. It is also the button action, + // which is what is being handled here.. + + // Only toggle off if the current selection is a valid outline choice, + // otherwise do nothing if other bullets/numbering are part of the selection. + const SwNumRule* pNumRule = GetShell().GetNumRuleAtCurrentSelection(); + if (pNumRule) + { + SvxNumRule aSvxRule = pNumRule->MakeSvxNumRule(); + + svx::sidebar::NBOTypeMgrBase* pOutline + = svx::sidebar::NBOutlineTypeMgrFact::CreateInstance( + svx::sidebar::NBOType::Outline); + if (pOutline) + { + const sal_uInt16 nIndex = pOutline->GetNBOIndexForNumRule(aSvxRule, 0); + if (nIndex < USHRT_MAX) + comphelper::dispatchCommand(".uno:RemoveBullets", {}); + } + } + else if (!GetShell().GetNumRuleAtCurrCursorPos()) + { + // No numbering yet. Just use the first locale-defined choice. + auto aArgs(comphelper::InitPropertySequence( + { { "SetOutline", uno::Any(sal_uInt16(1)) } })); + comphelper::dispatchCommand(".uno:SetOutline", aArgs); + } + } } break; |