diff options
author | Noel <noel.grandin@collabora.co.uk> | 2021-03-08 21:37:43 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-03-11 14:10:30 +0100 |
commit | 1692998399eecb79e7b59456cff805bcb77aece4 (patch) | |
tree | 8cc22c633e88f19c39f5736e87a0934f041729de /svtools | |
parent | 665a2b477dd4f412b42ffb58a183f7a702cd7645 (diff) |
use strong_int for item ids in vcl::ToolBox
(*) fix bug in SfxToolBoxControl::StateChanged where it was using the slot id
instead of the toolbox item id
(*) I left the logic in SbaTableQueryBrowser alone, but it looks suspicious,
casting slot ids to toolbox ids
Change-Id: Ied229164c27fb4456b0515c6fdcbd1682766a1a9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112186
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/uno/popupwindowcontroller.cxx | 2 | ||||
-rw-r--r-- | svtools/source/uno/toolboxcontroller.cxx | 20 |
2 files changed, 13 insertions, 9 deletions
diff --git a/svtools/source/uno/popupwindowcontroller.cxx b/svtools/source/uno/popupwindowcontroller.cxx index fe7eac4ff847..17b432c445e5 100644 --- a/svtools/source/uno/popupwindowcontroller.cxx +++ b/svtools/source/uno/popupwindowcontroller.cxx @@ -197,7 +197,7 @@ void SAL_CALL PopupWindowController::statusChanged( const frame::FeatureStateEve } ToolBox* pToolBox = nullptr; - sal_uInt16 nItemId = 0; + ToolBoxItemId nItemId; if ( getToolboxId( nItemId, &pToolBox ) ) { pToolBox->CheckItem( nItemId, bValue ); diff --git a/svtools/source/uno/toolboxcontroller.cxx b/svtools/source/uno/toolboxcontroller.cxx index f6d8e84d83d5..949c7c1cfb68 100644 --- a/svtools/source/uno/toolboxcontroller.cxx +++ b/svtools/source/uno/toolboxcontroller.cxx @@ -197,7 +197,11 @@ void SAL_CALL ToolboxController::initialize( const Sequence< Any >& aArguments ) else if ( aPropValue.Name == "ModuleIdentifier" ) aPropValue.Value >>= m_sModuleName; else if ( aPropValue.Name == "Identifier" ) - aPropValue.Value >>= m_nToolBoxId; + { + sal_uInt16 nTmp; + if (aPropValue.Value >>= nTmp) + m_nToolBoxId = ToolBoxItemId(nTmp); + } else if ( aPropValue.Name == "IsSidebar" ) aPropValue.Value >>= m_bSidebar; } @@ -732,26 +736,26 @@ IMPL_STATIC_LINK( ToolboxController, ExecuteHdl_Impl, void*, p, void ) void ToolboxController::enable( bool bEnable ) { ToolBox* pToolBox = nullptr; - sal_uInt16 nItemId = 0; + ToolBoxItemId nItemId; if( getToolboxId( nItemId, &pToolBox ) ) { pToolBox->EnableItem( nItemId, bEnable ); } } -bool ToolboxController::getToolboxId( sal_uInt16& rItemId, ToolBox** ppToolBox ) +bool ToolboxController::getToolboxId( ToolBoxItemId& rItemId, ToolBox** ppToolBox ) { - if( (m_nToolBoxId != SAL_MAX_UINT16) && (ppToolBox == nullptr) ) - return m_nToolBoxId; + if( (m_nToolBoxId != ToolBoxItemId(SAL_MAX_UINT16)) && (ppToolBox == nullptr) ) + return false; ToolBox* pToolBox = static_cast< ToolBox* >( VCLUnoHelper::GetWindow( getParent() ) ); - if( (m_nToolBoxId == SAL_MAX_UINT16) && pToolBox ) + if( (m_nToolBoxId == ToolBoxItemId(SAL_MAX_UINT16)) && pToolBox ) { const ToolBox::ImplToolItems::size_type nCount = pToolBox->GetItemCount(); for ( ToolBox::ImplToolItems::size_type nPos = 0; nPos < nCount; ++nPos ) { - const sal_uInt16 nItemId = pToolBox->GetItemId( nPos ); + const ToolBoxItemId nItemId = pToolBox->GetItemId( nPos ); if ( pToolBox->GetItemCommand( nItemId ) == m_aCommandURL ) { m_nToolBoxId = nItemId; @@ -765,7 +769,7 @@ bool ToolboxController::getToolboxId( sal_uInt16& rItemId, ToolBox** ppToolBox ) rItemId = m_nToolBoxId; - return (rItemId != SAL_MAX_UINT16) && (( ppToolBox == nullptr) || (*ppToolBox != nullptr) ); + return (rItemId != ToolBoxItemId(SAL_MAX_UINT16)) && (( ppToolBox == nullptr) || (*ppToolBox != nullptr) ); } //end |