summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2015-07-21 10:58:39 +0300
committerMaxim Monastirsky <momonasmon@gmail.com>2015-07-21 17:36:09 +0300
commit74cc3fbc17235f5c0010c363342a9a9adaf85c4e (patch)
tree102212f766aa8a0abd5691b15e37e48462360ae7 /framework
parent3c7a7b538e8ca8b310ae9778ae9ace5ae937a4f1 (diff)
tdf#36796 Status updates for custom shapes buttons
We're dealing here with 2 bugs: 1. Single shape buttons (like rectangle, ellipse etc.) don't get the pressed state when active. The cause is that all commands of the same kind (Basic Shapes, Symbol Shapes etc.) are handled as one internally, allowing only one type of status updates. It used to transport the current active shape, but it was changed to a boolean value in the fix for i#41753, and since then used for the pressed state of the group buttons. 2. The pressed state of a group button shows always, even when a user activates a shape from a place other than the drop-down of that button. But in this case the image of the group button doesn't update with the current shape, thus confusing the user on what is currently active. The cause here is that we use (since i#41753) the XSubToolbarController interface to update the last selected function (instead of the old-style status based update), and ToolBarManager notifies a controller about a new selection only if it was made from a particular toolbar that the controller claimed to use in the getSubToolbarName method. Since 7352a7c17875e5adcc4226c45f4a03e11c44ff49 there is a similar regression for other group buttons in sd (like lines, 3D Objects and other), with the same cause. This is also fixed now. Change-Id: Ida074a001ff78bf5bd5bcb8151516daa6e27cbce
Diffstat (limited to 'framework')
-rw-r--r--framework/source/uielement/subtoolbarcontroller.cxx53
1 files changed, 33 insertions, 20 deletions
diff --git a/framework/source/uielement/subtoolbarcontroller.cxx b/framework/source/uielement/subtoolbarcontroller.cxx
index 63a0984cafd0..3a06a104ec2e 100644
--- a/framework/source/uielement/subtoolbarcontroller.cxx
+++ b/framework/source/uielement/subtoolbarcontroller.cxx
@@ -102,6 +102,8 @@ SubToolBarController::SubToolBarController( const css::uno::Sequence< css::uno::
break;
}
}
+ if ( !m_aLastCommand.isEmpty() )
+ addStatusListener( m_aLastCommand );
}
SubToolBarController::~SubToolBarController()
@@ -131,32 +133,41 @@ void SubToolBarController::statusChanged( const css::frame::FeatureStateEvent& E
sal_uInt16 nId = 0;
if ( getToolboxId( nId, &pToolBox ) )
{
- pToolBox->EnableItem( nId, Event.IsEnabled );
ToolBoxItemBits nItemBits = pToolBox->GetItemBits( nId );
nItemBits &= ~ToolBoxItemBits::CHECKABLE;
TriState eTri = TRISTATE_FALSE;
- bool bValue;
- css::frame::status::ItemStatus aItemState;
- css::frame::status::Visibility aItemVisibility;
-
- if ( Event.State >>= bValue )
- {
- // Boolean, treat it as checked/unchecked
- pToolBox->SetItemBits( nId, nItemBits );
- pToolBox->CheckItem( nId, bValue );
- if ( bValue )
- eTri = TRISTATE_TRUE;
- nItemBits |= ToolBoxItemBits::CHECKABLE;
- }
- else if ( Event.State >>= aItemState )
+ if ( Event.FeatureURL.Complete == m_aCommandURL )
{
- eTri = TRISTATE_INDET;
- nItemBits |= ToolBoxItemBits::CHECKABLE;
+ pToolBox->EnableItem( nId, Event.IsEnabled );
+
+ OUString aStrValue;
+ css::frame::status::Visibility aItemVisibility;
+ if ( Event.State >>= aStrValue )
+ {
+ // Enum command, such as the current custom shape,
+ // toggle checked state.
+ if ( m_aLastCommand == OUString( m_aCommandURL + "." + aStrValue ) )
+ {
+ eTri = TRISTATE_TRUE;
+ nItemBits |= ToolBoxItemBits::CHECKABLE;
+ }
+ }
+ else if ( Event.State >>= aItemVisibility )
+ {
+ pToolBox->ShowItem( nId, aItemVisibility.bVisible );
+ }
}
- else if ( Event.State >>= aItemVisibility )
+ else
{
- pToolBox->ShowItem( nId, aItemVisibility.bVisible );
+ bool bValue;
+ if ( Event.State >>= bValue )
+ {
+ // Boolean, treat it as checked/unchecked
+ if ( bValue )
+ eTri = TRISTATE_TRUE;
+ nItemBits |= ToolBoxItemBits::CHECKABLE;
+ }
}
pToolBox->SetItemState( nId, eTri );
@@ -261,9 +272,11 @@ OUString SubToolBarController::getSubToolbarName()
void SubToolBarController::functionSelected( const OUString& rCommand )
throw ( css::uno::RuntimeException, std::exception )
{
- if ( !m_aLastCommand.isEmpty() )
+ if ( !m_aLastCommand.isEmpty() && m_aLastCommand != rCommand )
{
+ removeStatusListener( m_aLastCommand );
m_aLastCommand = rCommand;
+ addStatusListener( m_aLastCommand );
updateImage();
}
}