tdf#139696 Use getToolboxId to set item id

This code depends on ToolboxController::m_nToolBoxId being already set, which
is the case for toolbars, as passed by ToolBarManager::CreateControllers via
the "Identifier" property, but not for the notebookbar, as can be seen in
sfx2::sidebar::ControllerFactory::CreateToolBarController.

Avoid this problem by using getToolboxId, like in most other toolbar controls.

Change-Id: I5dfb1bda0886ce3542274a422f8c9111e7fdcf7e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109722
Tested-by: Jenkins
Tested-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
This commit is contained in:
Maxim Monastirsky 2021-01-20 17:38:29 +02:00
parent 2c96bd26ec
commit da2b2c9b3d

View File

@ -149,12 +149,13 @@ void SAL_CALL PopupMenuToolbarController::initialize(
}
SolarMutexGuard aSolarLock;
VclPtr< ToolBox > pToolBox = static_cast< ToolBox* >( VCLUnoHelper::GetWindow( getParent() ).get() );
if ( pToolBox )
ToolBox* pToolBox = nullptr;
sal_uInt16 nItemId = 0;
if ( getToolboxId( nItemId, &pToolBox ) )
{
ToolBoxItemBits nCurStyle( pToolBox->GetItemBits( m_nToolBoxId ) );
ToolBoxItemBits nCurStyle( pToolBox->GetItemBits( nItemId ) );
ToolBoxItemBits nSetStyle( getDropDownStyle() );
pToolBox->SetItemBits( m_nToolBoxId,
pToolBox->SetItemBits( nItemId,
m_bHasController ?
nCurStyle | nSetStyle :
nCurStyle & ~nSetStyle );