summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2023-01-04 22:13:17 -0500
committerJustin Luth <jluth@mail.com>2023-01-06 00:34:31 +0000
commita9b666b6b839735919923d8911f7e1efe0eb87b0 (patch)
tree7b80a5b8048497809dde28b951a7545eadaf039b
parentc0eb37dfd00311518926bd602ccc8776f89b397c (diff)
tdf#56258 svx SetOutline: convert to toggle
The "Outline Format" toolbar button is normally hidden. It didn't check state like the bullet and toggle numbering do. This patch adds that - so it lights up when the text contains a numbering list that matches a valid outline choice. I also added a toggle aspect to the button. Toggling ON is not great. It works fine if there is no numbering yet, but if you are in an outline and toggle off, it won't toggle back on to the same list - it starts a new one. I don't think there is much that can be done about that, since the removal delete the level information too, and outlines are all about multiple levels of numbering. The proper response to an errant toggle off is (multiple) undo(s), not toggle back on. (In the ideal world, it would popup the dropdown choices). Toggling ON does nothing when there are already bullets or numbering. The proper response is to use the dropdown if the desire is to change to an outline format. Toggling OFF is only possible when we are on a valid outline. This is extremely important because otherwise it isn't clear how to remove Outline Numbering's mix of bullets and numbers. (When the selection contains one list with both bullet and number levels, the number and bullet buttons do nothing.) Although not perfect, this is not a bad user experience, so I'm going to push the full patch to gerrit. There is one known obscure case that troubles all methods. If the selection spans multiple list definitions and ends on an un-numbered paragraph, then the toggle-on will happen. It is possible to just not do any toggling and ALWAYS show the dropdown action, but that isn't very consistent with the other related buttons. Change-Id: I6d927604e49711f1da8549be9f3dbf8b8133a06b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145061 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com>
-rw-r--r--svx/source/tbxctrls/bulletsnumbering.cxx5
-rw-r--r--sw/sdi/_textsh.sdi1
-rw-r--r--sw/source/uibase/shells/textsh1.cxx12
-rw-r--r--sw/source/uibase/shells/txtnum.cxx33
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;