diff --git a/framework/source/uielement/popuptoolbarcontroller.cxx b/framework/source/uielement/popuptoolbarcontroller.cxx index efe2eb82f12c..36ad65f19cc2 100644 --- a/framework/source/uielement/popuptoolbarcontroller.cxx +++ b/framework/source/uielement/popuptoolbarcontroller.cxx @@ -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 );