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 /vcl/source/window | |
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 'vcl/source/window')
-rw-r--r-- | vcl/source/window/NotebookBarAddonsMerger.cxx | 2 | ||||
-rw-r--r-- | vcl/source/window/builder.cxx | 4 | ||||
-rw-r--r-- | vcl/source/window/dlgctrl.cxx | 3 | ||||
-rw-r--r-- | vcl/source/window/floatwin.cxx | 2 | ||||
-rw-r--r-- | vcl/source/window/menubarwindow.cxx | 32 | ||||
-rw-r--r-- | vcl/source/window/toolbox.cxx | 54 | ||||
-rw-r--r-- | vcl/source/window/toolbox2.cxx | 132 |
7 files changed, 114 insertions, 115 deletions
diff --git a/vcl/source/window/NotebookBarAddonsMerger.cxx b/vcl/source/window/NotebookBarAddonsMerger.cxx index f7cdbb2c3227..274b455bdb8f 100644 --- a/vcl/source/window/NotebookBarAddonsMerger.cxx +++ b/vcl/source/window/NotebookBarAddonsMerger.cxx @@ -67,7 +67,7 @@ static void CreateNotebookBarToolBox(vcl::Window* pNotebookbarToolBox, const AddonNotebookBarItem& aAddonNotebookBarItem, const std::vector<Image>& aImageVec, const tools::ULong nIter) { - sal_uInt16 nItemId = 0; + ToolBoxItemId nItemId(0); ToolBox* pToolbox = dynamic_cast<ToolBox*>(pNotebookbarToolBox); if (!pToolbox) return; diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 4519ae6e2ead..77f882fc8656 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -2111,7 +2111,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString & { OUString aCommand(extractActionName(rMap)); - sal_uInt16 nItemId = 0; + ToolBoxItemId nItemId(0); ToolBoxItemBits nBits = ToolBoxItemBits::NONE; if (name == "GtkMenuToolButton") nBits |= ToolBoxItemBits::DROPDOWN; @@ -2127,7 +2127,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString & } else { - nItemId = pToolBox->GetItemCount() + 1; + nItemId = ToolBoxItemId(pToolBox->GetItemCount() + 1); //TODO: ImplToolItems::size_type -> sal_uInt16! pToolBox->InsertItem(nItemId, extractLabel(rMap), nBits); if (aCommand.isEmpty() && !m_bLegacy) diff --git a/vcl/source/window/dlgctrl.cxx b/vcl/source/window/dlgctrl.cxx index 42a4ce82a8a2..961ec49ae038 100644 --- a/vcl/source/window/dlgctrl.cxx +++ b/vcl/source/window/dlgctrl.cxx @@ -191,10 +191,9 @@ static bool lcl_ToolBoxTabStop( Window* pWindow ) { ToolBox* pToolBoxWindow = static_cast<ToolBox*>( pWindow ); - sal_uInt16 nId; for ( ToolBox::ImplToolItems::size_type nPos = 0; nPos < pToolBoxWindow->GetItemCount(); nPos++ ) { - nId = pToolBoxWindow->GetItemId( nPos ); + ToolBoxItemId nId = pToolBoxWindow->GetItemId( nPos ); if ( pToolBoxWindow->IsItemVisible( nId ) && pToolBoxWindow->IsItemEnabled( nId ) ) return true; } diff --git a/vcl/source/window/floatwin.cxx b/vcl/source/window/floatwin.cxx index 6a661ae6b7b2..ecc2163a9d61 100644 --- a/vcl/source/window/floatwin.cxx +++ b/vcl/source/window/floatwin.cxx @@ -834,7 +834,7 @@ void FloatingWindow::StartPopupMode( ToolBox* pBox, FloatWinPopupFlags nFlags ) mpImplData->mpBox = pBox; // get selected button - sal_uInt16 nItemId = pBox->GetDownItemId(); + ToolBoxItemId nItemId = pBox->GetDownItemId(); if ( nItemId ) pBox->ImplFloatControl( true, this ); diff --git a/vcl/source/window/menubarwindow.cxx b/vcl/source/window/menubarwindow.cxx index c29a827b2c38..b3c78549dd49 100644 --- a/vcl/source/window/menubarwindow.cxx +++ b/vcl/source/window/menubarwindow.cxx @@ -61,14 +61,14 @@ void DecoToolBox::calcMinSize() ScopedVclPtrInstance<ToolBox> aTbx( GetParent() ); if( GetItemCount() == 0 ) { - aTbx->InsertItem(IID_DOCUMENTCLOSE, Image(StockImage::Yes, SV_RESID_BITMAP_CLOSEDOC)); + aTbx->InsertItem(ToolBoxItemId(IID_DOCUMENTCLOSE), Image(StockImage::Yes, SV_RESID_BITMAP_CLOSEDOC)); } else { ImplToolItems::size_type nItems = GetItemCount(); for( ImplToolItems::size_type i = 0; i < nItems; i++ ) { - sal_uInt16 nId = GetItemId( i ); + ToolBoxItemId nId = GetItemId( i ); aTbx->InsertItem( nId, GetItemImage( nId ) ); } } @@ -106,7 +106,7 @@ void DecoToolBox::SetImages( tools::Long nMaxHeight, bool bForce ) maImage.GetSizePixel() ); aBmpExDst.CopyPixel( aDestRect, aSrcRect, &aBmpExSrc ); - SetItemImage( IID_DOCUMENTCLOSE, Image( aBmpExDst ) ); + SetItemImage( ToolBoxItemId(IID_DOCUMENTCLOSE), Image( aBmpExDst ) ); } @@ -132,10 +132,10 @@ MenuBarWindow::MenuBarWindow( vcl::Window* pParent ) : m_aCloseBtn->SetPaintTransparent(true); m_aCloseBtn->SetParentClipMode(ParentClipMode::NoClip); - m_aCloseBtn->InsertItem(IID_DOCUMENTCLOSE, m_aCloseBtn->maImage); + m_aCloseBtn->InsertItem(ToolBoxItemId(IID_DOCUMENTCLOSE), m_aCloseBtn->maImage); m_aCloseBtn->SetSelectHdl(LINK(this, MenuBarWindow, CloseHdl)); m_aCloseBtn->AddEventListener(LINK(this, MenuBarWindow, ToolboxEventHdl)); - m_aCloseBtn->SetQuickHelpText(IID_DOCUMENTCLOSE, VclResId(SV_HELPTEXT_CLOSEDOCUMENT)); + m_aCloseBtn->SetQuickHelpText(ToolBoxItemId(IID_DOCUMENTCLOSE), VclResId(SV_HELPTEXT_CLOSEDOCUMENT)); m_aFloatBtn->SetSymbol( SymbolType::FLOAT ); m_aFloatBtn->SetQuickHelpText(VclResId(SV_HELPTEXT_RESTORE)); @@ -176,7 +176,7 @@ void MenuBarWindow::SetMenu( MenuBar* pMen ) m_nHighlightedItem = ITEMPOS_INVALID; if (pMen) { - m_aCloseBtn->ShowItem(IID_DOCUMENTCLOSE, pMen->HasCloseButton()); + m_aCloseBtn->ShowItem(ToolBoxItemId(IID_DOCUMENTCLOSE), pMen->HasCloseButton()); m_aCloseBtn->Show(pMen->HasCloseButton() || !m_aAddButtons.empty()); m_aFloatBtn->Show(pMen->HasFloatButton()); m_aHideBtn->Show(pMen->HasHideButton()); @@ -200,7 +200,7 @@ void MenuBarWindow::SetHeight(tools::Long nHeight) void MenuBarWindow::ShowButtons( bool bClose, bool bFloat, bool bHide ) { - m_aCloseBtn->ShowItem(IID_DOCUMENTCLOSE, bClose); + m_aCloseBtn->ShowItem(ToolBoxItemId(IID_DOCUMENTCLOSE), bClose); m_aCloseBtn->Show(bClose || !m_aAddButtons.empty()); if (m_pMenu->mpSalMenu) m_pMenu->mpSalMenu->ShowCloseButton(bClose); @@ -219,7 +219,7 @@ IMPL_LINK_NOARG(MenuBarWindow, CloseHdl, ToolBox *, void) if( ! m_pMenu ) return; - if( m_aCloseBtn->GetCurItemId() == IID_DOCUMENTCLOSE ) + if( m_aCloseBtn->GetCurItemId() == ToolBoxItemId(IID_DOCUMENTCLOSE) ) { // #i106052# call close hdl asynchronously to ease handler implementation // this avoids still being in the handler while the DecoToolBox already @@ -228,12 +228,12 @@ IMPL_LINK_NOARG(MenuBarWindow, CloseHdl, ToolBox *, void) } else { - std::map<sal_uInt16,AddButtonEntry>::iterator it = m_aAddButtons.find(m_aCloseBtn->GetCurItemId()); + std::map<sal_uInt16,AddButtonEntry>::iterator it = m_aAddButtons.find(sal_uInt16(m_aCloseBtn->GetCurItemId())); if( it != m_aAddButtons.end() ) { MenuBar::MenuBarButtonCallbackArg aArg; aArg.nId = it->first; - aArg.bHighlight = (m_aCloseBtn->GetHighlightItemId() == it->first); + aArg.bHighlight = (sal_uInt16(m_aCloseBtn->GetHighlightItemId()) == it->first); it->second.m_aSelectLink.Call( aArg ); } } @@ -248,11 +248,11 @@ IMPL_LINK( MenuBarWindow, ToolboxEventHdl, VclWindowEvent&, rEvent, void ) aArg.nId = 0xffff; aArg.bHighlight = (rEvent.GetId() == VclEventId::ToolboxHighlight); if( rEvent.GetId() == VclEventId::ToolboxHighlight ) - aArg.nId = m_aCloseBtn->GetHighlightItemId(); + aArg.nId =sal_uInt16(m_aCloseBtn->GetHighlightItemId()); else if( rEvent.GetId() == VclEventId::ToolboxHighlightOff ) { auto nPos = static_cast<ToolBox::ImplToolItems::size_type>(reinterpret_cast<sal_IntPtr>(rEvent.GetData())); - aArg.nId = m_aCloseBtn->GetItemId(nPos); + aArg.nId = sal_uInt16(m_aCloseBtn->GetItemId(nPos)); } std::map< sal_uInt16, AddButtonEntry >::iterator it = m_aAddButtons.find( aArg.nId ); if( it != m_aAddButtons.end() ) @@ -1167,9 +1167,9 @@ sal_uInt16 MenuBarWindow::AddMenuBarButton( const Image& i_rImage, const Link<Me SAL_WARN_IF( nId >= 128, "vcl", "too many addbuttons in menubar" ); AddButtonEntry& rNewEntry = m_aAddButtons[nId]; rNewEntry.m_aSelectLink = i_rLink; - m_aCloseBtn->InsertItem(nId, i_rImage, ToolBoxItemBits::NONE, 0); + m_aCloseBtn->InsertItem(ToolBoxItemId(nId), i_rImage, ToolBoxItemBits::NONE, 0); m_aCloseBtn->calcMinSize(); - ShowButtons(m_aCloseBtn->IsItemVisible(IID_DOCUMENTCLOSE), m_aFloatBtn->IsVisible(), m_aHideBtn->IsVisible()); + ShowButtons(m_aCloseBtn->IsItemVisible(ToolBoxItemId(IID_DOCUMENTCLOSE)), m_aFloatBtn->IsVisible(), m_aHideBtn->IsVisible()); LayoutChanged(); if( m_pMenu->mpSalMenu ) @@ -1202,7 +1202,7 @@ tools::Rectangle MenuBarWindow::GetMenuBarButtonRectPixel( sal_uInt16 nId ) if( aRect.IsEmpty() ) { - aRect = m_aCloseBtn->GetItemRect(nId); + aRect = m_aCloseBtn->GetItemRect(ToolBoxItemId(nId)); Point aOffset = m_aCloseBtn->OutputToScreenPixel(Point()); aRect.Move( aOffset.X(), aOffset.Y() ); } @@ -1212,7 +1212,7 @@ tools::Rectangle MenuBarWindow::GetMenuBarButtonRectPixel( sal_uInt16 nId ) void MenuBarWindow::RemoveMenuBarButton( sal_uInt16 nId ) { - ToolBox::ImplToolItems::size_type nPos = m_aCloseBtn->GetItemPos(nId); + ToolBox::ImplToolItems::size_type nPos = m_aCloseBtn->GetItemPos(ToolBoxItemId(nId)); m_aCloseBtn->RemoveItem(nPos); m_aAddButtons.erase( nId ); m_aCloseBtn->calcMinSize(); diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx index 935a1882e4aa..14bf3883e146 100644 --- a/vcl/source/window/toolbox.cxx +++ b/vcl/source/window/toolbox.cxx @@ -1112,9 +1112,9 @@ void ToolBox::ImplInitToolBoxData() mnRightBorder = 0; mnBottomBorder = 0; mnLastResizeDY = 0; - mnHighItemId = 0; - mnCurItemId = 0; - mnDownItemId = 0; + mnHighItemId = ToolBoxItemId(0); + mnCurItemId = ToolBoxItemId(0); + mnDownItemId = ToolBoxItemId(0); mnCurPos = ITEM_NOTFOUND; mnLines = 1; mnCurLine = 1; @@ -1147,7 +1147,7 @@ void ToolBox::ImplInitToolBoxData() mnWinStyle = 0; meLayoutMode = ToolBoxLayoutMode::Normal; meTextPosition = ToolBoxTextPosition::Right; - mnLastFocusItemId = 0; + mnLastFocusItemId = ToolBoxItemId(0); mnActivateCount = 0; mnImagesRotationAngle = 0_deg10; @@ -1327,7 +1327,7 @@ void ToolBox::dispose() DockingWindow::dispose(); } -ImplToolItem* ToolBox::ImplGetItem( sal_uInt16 nItemId ) const +ImplToolItem* ToolBox::ImplGetItem( ToolBoxItemId nItemId ) const { if (!mpData) return nullptr; @@ -2350,10 +2350,10 @@ IMPL_LINK_NOARG(ToolBox, ImplDropdownLongClickHdl, Timer *, void) InvalidateItem(mnCurPos); mnCurPos = ITEM_NOTFOUND; - mnCurItemId = 0; - mnDownItemId = 0; + mnCurItemId = ToolBoxItemId(0); + mnDownItemId = ToolBoxItemId(0); mnMouseModifier = 0; - mnHighItemId = 0; + mnHighItemId = ToolBoxItemId(0); } } @@ -2846,10 +2846,10 @@ void ToolBox::ImplFloatControl( bool bStart, FloatingWindow* pFloatWindow ) if( !bWasKeyboardActivate ) { mnCurPos = ITEM_NOTFOUND; - mnCurItemId = 0; - mnHighItemId = 0; + mnCurItemId = ToolBoxItemId(0); + mnHighItemId = ToolBoxItemId(0); } - mnDownItemId = 0; + mnDownItemId = ToolBoxItemId(0); } } @@ -2895,7 +2895,7 @@ bool ToolBox::ImplHandleMouseMove( const MouseEvent& rMEvt, bool bRepeat ) if ( mnCurItemId ) { InvalidateItem(mnCurPos); - mnCurItemId = 0; + mnCurItemId = ToolBoxItemId(0); InvalidateItem(mnCurPos); Highlight(); } @@ -3010,8 +3010,8 @@ bool ToolBox::ImplHandleMouseButtonUp( const MouseEvent& rMEvt, bool bCancel ) } mnCurPos = ITEM_NOTFOUND; - mnCurItemId = 0; - mnDownItemId = 0; + mnCurItemId = ToolBoxItemId(0); + mnDownItemId = ToolBoxItemId(0); mnMouseModifier = 0; return true; } @@ -3160,7 +3160,7 @@ void ToolBox::MouseMove( const MouseEvent& rMEvt ) CallEventListeners( VclEventId::ToolboxHighlightOff, reinterpret_cast< void* >( nClearPos ) ); } ImplHideFocus(); - mnHighItemId = 0; + mnHighItemId = ToolBoxItemId(0); } if( bMenuButtonHit ) @@ -3272,10 +3272,10 @@ void ToolBox::MouseButtonDown( const MouseEvent& rMEvt ) InvalidateItem(mnCurPos); mnCurPos = ITEM_NOTFOUND; - mnCurItemId = 0; - mnDownItemId = 0; + mnCurItemId = ToolBoxItemId(0); + mnDownItemId = ToolBoxItemId(0); mnMouseModifier = 0; - mnHighItemId = 0; + mnHighItemId = ToolBoxItemId(0); } return; } @@ -3596,7 +3596,7 @@ namespace } } -const OUString& ToolBox::ImplGetHelpText( sal_uInt16 nItemId ) const +const OUString& ToolBox::ImplGetHelpText( ToolBoxItemId nItemId ) const { ImplToolItem* pItem = ImplGetItem( nItemId ); @@ -3619,7 +3619,7 @@ const OUString& ToolBox::ImplGetHelpText( sal_uInt16 nItemId ) const void ToolBox::RequestHelp( const HelpEvent& rHEvt ) { - sal_uInt16 nItemId; + ToolBoxItemId nItemId; Point aHelpPos; if( !rHEvt.KeyboardActivated() ) @@ -3708,7 +3708,7 @@ bool ToolBox::EventNotify( NotifyEvent& rNEvt ) if( rNEvt.GetWindow() == this ) { // the toolbar itself got the focus - if( mnLastFocusItemId != 0 || mpData->mbMenubuttonWasLastSelected ) + if( mnLastFocusItemId != ToolBoxItemId(0) || mpData->mbMenubuttonWasLastSelected ) { // restore last item if( mpData->mbMenubuttonWasLastSelected ) @@ -3720,7 +3720,7 @@ bool ToolBox::EventNotify( NotifyEvent& rNEvt ) else { ImplChangeHighlight( ImplGetItem( mnLastFocusItemId ) ); - mnLastFocusItemId = 0; + mnLastFocusItemId = ToolBoxItemId(0); } } else if( (GetGetFocusFlags() & (GetFocusFlags::Backward|GetFocusFlags::Tab) ) == (GetFocusFlags::Backward|GetFocusFlags::Tab)) @@ -3729,7 +3729,7 @@ bool ToolBox::EventNotify( NotifyEvent& rNEvt ) else ImplChangeHighlightUpDn( true ); - mnLastFocusItemId = 0; + mnLastFocusItemId = ToolBoxItemId(0); return true; } @@ -3756,7 +3756,7 @@ bool ToolBox::EventNotify( NotifyEvent& rNEvt ) // deselect ImplHideFocus(); mpData->mbMenubuttonWasLastSelected = false; - mnHighItemId = 0; + mnHighItemId = ToolBoxItemId(0); mnCurPos = ITEM_NOTFOUND; } @@ -4176,7 +4176,7 @@ void ToolBox::LoseFocus() } // performs the action associated with an item, ie simulates clicking the item -void ToolBox::TriggerItem( sal_uInt16 nItemId ) +void ToolBox::TriggerItem( ToolBoxItemId nItemId ) { mnHighItemId = nItemId; vcl::KeyCode aKeyCode( 0, 0 ); @@ -4576,7 +4576,7 @@ void ToolBox::ImplChangeHighlight( ImplToolItem const * pItem, bool bNoGrabFocus // #i89962# ImplDrawItem can cause Invalidate/Update // which will in turn ImplShowFocus again // set mnHighItemId to 0 already to prevent this hen/egg problem - mnHighItemId = 0; + mnHighItemId = ToolBoxItemId(0); InvalidateItem(nPos); CallEventListeners( VclEventId::ToolboxHighlightOff, reinterpret_cast< void* >( nPos ) ); } @@ -4625,7 +4625,7 @@ void ToolBox::ImplChangeHighlight( ImplToolItem const * pItem, bool bNoGrabFocus else { ImplHideFocus(); - mnHighItemId = 0; + mnHighItemId = ToolBoxItemId(0); mnCurPos = ITEM_NOTFOUND; } diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx index 3dd2b5979546..6acf30e92d65 100644 --- a/vcl/source/window/toolbox2.cxx +++ b/vcl/source/window/toolbox2.cxx @@ -80,7 +80,7 @@ ImplToolBoxPrivateData::~ImplToolBoxPrivateData() mpMenu.disposeAndClear(); } -void ImplToolItem::init(sal_uInt16 nItemId, ToolBoxItemBits nItemBits, +void ImplToolItem::init(ToolBoxItemId nItemId, ToolBoxItemBits nItemBits, bool bEmptyBtn) { mnId = nItemId; @@ -105,24 +105,24 @@ void ImplToolItem::init(sal_uInt16 nItemId, ToolBoxItemBits nItemBits, ImplToolItem::ImplToolItem() { - init(0, ToolBoxItemBits::NONE, true); + init(ToolBoxItemId(0), ToolBoxItemBits::NONE, true); } -ImplToolItem::ImplToolItem( sal_uInt16 nItemId, const Image& rImage, +ImplToolItem::ImplToolItem( ToolBoxItemId nItemId, const Image& rImage, ToolBoxItemBits nItemBits ) : maImage( rImage ) { init(nItemId, nItemBits, false); } -ImplToolItem::ImplToolItem( sal_uInt16 nItemId, const OUString& rText, +ImplToolItem::ImplToolItem( ToolBoxItemId nItemId, const OUString& rText, ToolBoxItemBits nItemBits ) : maText( rText ) { init(nItemId, nItemBits, false); } -ImplToolItem::ImplToolItem( sal_uInt16 nItemId, const Image& rImage, +ImplToolItem::ImplToolItem( ToolBoxItemId nItemId, const Image& rImage, const OUString& rText, ToolBoxItemBits nItemBits ) : maImage( rImage ), maText( rText ) @@ -377,7 +377,7 @@ void ToolBox::Select() static_cast<FloatingWindow*>(pWrapper->GetFloatingWindow())->EndPopupMode(); } -void ToolBox::InsertItem( sal_uInt16 nItemId, const Image& rImage, ToolBoxItemBits nBits, ImplToolItems::size_type nPos ) +void ToolBox::InsertItem( ToolBoxItemId nItemId, const Image& rImage, ToolBoxItemBits nBits, ImplToolItems::size_type nPos ) { SAL_WARN_IF( !nItemId, "vcl", "ToolBox::InsertItem(): ItemId == 0" ); SAL_WARN_IF( GetItemPos( nItemId ) != ITEM_NOTFOUND, "vcl", @@ -395,7 +395,7 @@ void ToolBox::InsertItem( sal_uInt16 nItemId, const Image& rImage, ToolBoxItemBi CallEventListeners( VclEventId::ToolboxItemAdded, reinterpret_cast< void* >(nNewPos ) ); } -void ToolBox::InsertItem( sal_uInt16 nItemId, const Image& rImage, const OUString& rText, ToolBoxItemBits nBits, +void ToolBox::InsertItem( ToolBoxItemId nItemId, const Image& rImage, const OUString& rText, ToolBoxItemBits nBits, ImplToolItems::size_type nPos ) { SAL_WARN_IF( !nItemId, "vcl", "ToolBox::InsertItem(): ItemId == 0" ); @@ -414,7 +414,7 @@ void ToolBox::InsertItem( sal_uInt16 nItemId, const Image& rImage, const OUStrin CallEventListeners( VclEventId::ToolboxItemAdded, reinterpret_cast< void* >( nNewPos ) ); } -void ToolBox::InsertItem( sal_uInt16 nItemId, const OUString& rText, ToolBoxItemBits nBits, ImplToolItems::size_type nPos ) +void ToolBox::InsertItem( ToolBoxItemId nItemId, const OUString& rText, ToolBoxItemBits nBits, ImplToolItems::size_type nPos ) { SAL_WARN_IF( !nItemId, "vcl", "ToolBox::InsertItem(): ItemId == 0" ); SAL_WARN_IF( GetItemPos( nItemId ) != ITEM_NOTFOUND, "vcl", @@ -441,7 +441,7 @@ void ToolBox::InsertItem(const OUString& rCommand, const css::uno::Reference<css OUString aTooltip(vcl::CommandInfoProvider::GetTooltipForCommand(rCommand, aProperties, rFrame)); Image aImage(CommandInfoProvider::GetImageForCommand(rCommand, rFrame, GetImageSize())); - sal_uInt16 nItemId = GetItemCount() + 1; + ToolBoxItemId nItemId(GetItemCount() + 1); //TODO: ImplToolItems::size_type -> sal_uInt16! InsertItem(nItemId, aImage, aLabel, nBits, nPos); SetItemCommand(nItemId, rCommand); @@ -453,7 +453,7 @@ void ToolBox::InsertItem(const OUString& rCommand, const css::uno::Reference<css pItem->maMinimalItemSize = rRequestedSize; } -void ToolBox::InsertWindow( sal_uInt16 nItemId, vcl::Window* pWindow, +void ToolBox::InsertWindow( ToolBoxItemId nItemId, vcl::Window* pWindow, ToolBoxItemBits nBits, ImplToolItems::size_type nPos ) { SAL_WARN_IF( !nItemId, "vcl", "ToolBox::InsertWindow(): ItemId == 0" ); @@ -545,9 +545,9 @@ void ToolBox::RemoveItem( ImplToolItems::size_type nPos ) // ensure not to delete in the Select-Handler if ( mpData->m_aItems[nPos].mnId == mnCurItemId ) - mnCurItemId = 0; + mnCurItemId = ToolBoxItemId(0); if ( mpData->m_aItems[nPos].mnId == mnHighItemId ) - mnHighItemId = 0; + mnHighItemId = ToolBoxItemId(0); ImplInvalidate( bMustCalc ); @@ -558,7 +558,7 @@ void ToolBox::RemoveItem( ImplToolItems::size_type nPos ) CallEventListeners( VclEventId::ToolboxItemRemoved, reinterpret_cast< void* >( nPos ) ); } -void ToolBox::CopyItem( const ToolBox& rToolBox, sal_uInt16 nItemId ) +void ToolBox::CopyItem( const ToolBox& rToolBox, ToolBoxItemId nItemId ) { SAL_WARN_IF( GetItemPos( nItemId ) != ITEM_NOTFOUND, "vcl", "ToolBox::CopyItem(): ItemId already exists" ); @@ -591,8 +591,8 @@ void ToolBox::Clear() mpData->ImplClearLayoutData(); // ensure not to delete in the Select-Handler - mnCurItemId = 0; - mnHighItemId = 0; + mnCurItemId = ToolBoxItemId(0); + mnHighItemId = ToolBoxItemId(0); ImplInvalidate( true, true ); @@ -714,7 +714,7 @@ ToolBoxItemType ToolBox::GetItemType( ImplToolItems::size_type nPos ) const return (nPos < mpData->m_aItems.size()) ? mpData->m_aItems[nPos].meType : ToolBoxItemType::DONTKNOW; } -ToolBox::ImplToolItems::size_type ToolBox::GetItemPos( sal_uInt16 nItemId ) const +ToolBox::ImplToolItems::size_type ToolBox::GetItemPos( ToolBoxItemId nItemId ) const { if (mpData) { @@ -738,12 +738,12 @@ ToolBox::ImplToolItems::size_type ToolBox::GetItemPos( const Point& rPos ) const return ITEM_NOTFOUND; } -sal_uInt16 ToolBox::GetItemId( ImplToolItems::size_type nPos ) const +ToolBoxItemId ToolBox::GetItemId( ImplToolItems::size_type nPos ) const { - return (nPos < mpData->m_aItems.size()) ? mpData->m_aItems[nPos].mnId : 0; + return (nPos < mpData->m_aItems.size()) ? mpData->m_aItems[nPos].mnId : ToolBoxItemId(0); } -sal_uInt16 ToolBox::GetItemId( const Point& rPos ) const +ToolBoxItemId ToolBox::GetItemId( const Point& rPos ) const { // find item that was clicked auto it = std::find_if(mpData->m_aItems.begin(), mpData->m_aItems.end(), @@ -752,10 +752,10 @@ sal_uInt16 ToolBox::GetItemId( const Point& rPos ) const if( (it != mpData->m_aItems.end()) && (it->meType == ToolBoxItemType::BUTTON) ) return it->mnId; - return 0; + return ToolBoxItemId(0); } -Size ToolBox::GetItemContentSize( sal_uInt16 nItemId ) +Size ToolBox::GetItemContentSize( ToolBoxItemId nItemId ) { if ( mbCalc || mbFormat ) ImplFormat(); @@ -767,17 +767,17 @@ Size ToolBox::GetItemContentSize( sal_uInt16 nItemId ) return Size(); } -sal_uInt16 ToolBox::GetItemId(const OUString &rCommand) const +ToolBoxItemId ToolBox::GetItemId(const OUString &rCommand) const { if (!mpData) - return 0; + return ToolBoxItemId(0); auto it = std::find_if(mpData->m_aItems.begin(), mpData->m_aItems.end(), [&rCommand](const ImplToolItem& rItem) { return rItem.maCommandStr == rCommand; }); if (it != mpData->m_aItems.end()) return it->mnId; - return 0; + return ToolBoxItemId(0); } Point ToolBox::ImplGetPopupPosition( const tools::Rectangle& rRect ) const @@ -830,7 +830,7 @@ Point ToolBox::ImplGetPopupPosition( const tools::Rectangle& rRect ) const return aPos; } -tools::Rectangle ToolBox::GetItemRect( sal_uInt16 nItemId ) +tools::Rectangle ToolBox::GetItemRect( ToolBoxItemId nItemId ) { if ( mbCalc || mbFormat ) ImplFormat(); @@ -869,7 +869,7 @@ bool ToolBox::ImplHasExternalMenubutton() return bRet; } -void ToolBox::SetItemBits( sal_uInt16 nItemId, ToolBoxItemBits nBits ) +void ToolBox::SetItemBits( ToolBoxItemId nItemId, ToolBoxItemBits nBits ) { ImplToolItems::size_type nPos = GetItemPos( nItemId ); @@ -886,7 +886,7 @@ void ToolBox::SetItemBits( sal_uInt16 nItemId, ToolBoxItemBits nBits ) } } -void ToolBox::SetItemWindowNonInteractive(sal_uInt16 nItemId, bool bNonInteractive) +void ToolBox::SetItemWindowNonInteractive(ToolBoxItemId nItemId, bool bNonInteractive) { ImplToolItems::size_type nPos = GetItemPos( nItemId ); @@ -896,7 +896,7 @@ void ToolBox::SetItemWindowNonInteractive(sal_uInt16 nItemId, bool bNonInteracti } } -ToolBoxItemBits ToolBox::GetItemBits( sal_uInt16 nItemId ) const +ToolBoxItemBits ToolBox::GetItemBits( ToolBoxItemId nItemId ) const { ImplToolItem* pItem = ImplGetItem( nItemId ); @@ -906,7 +906,7 @@ ToolBoxItemBits ToolBox::GetItemBits( sal_uInt16 nItemId ) const return ToolBoxItemBits::NONE; } -void ToolBox::SetItemExpand( sal_uInt16 nItemId, bool bExpand ) +void ToolBox::SetItemExpand( ToolBoxItemId nItemId, bool bExpand ) { ImplToolItem* pItem = ImplGetItem( nItemId ); if (!pItem) @@ -919,7 +919,7 @@ void ToolBox::SetItemExpand( sal_uInt16 nItemId, bool bExpand ) } } -void ToolBox::SetItemData( sal_uInt16 nItemId, void* pNewData ) +void ToolBox::SetItemData( ToolBoxItemId nItemId, void* pNewData ) { ImplToolItems::size_type nPos = GetItemPos( nItemId ); @@ -930,7 +930,7 @@ void ToolBox::SetItemData( sal_uInt16 nItemId, void* pNewData ) } } -void* ToolBox::GetItemData( sal_uInt16 nItemId ) const +void* ToolBox::GetItemData( ToolBoxItemId nItemId ) const { ImplToolItem* pItem = ImplGetItem( nItemId ); @@ -940,7 +940,7 @@ void* ToolBox::GetItemData( sal_uInt16 nItemId ) const return nullptr; } -void ToolBox::SetItemImage( sal_uInt16 nItemId, const Image& rImage ) +void ToolBox::SetItemImage( ToolBoxItemId nItemId, const Image& rImage ) { ImplToolItems::size_type nPos = GetItemPos( nItemId ); @@ -971,7 +971,7 @@ static Image ImplRotImage( const Image& rImage, Degree10 nAngle10 ) return Image( aRotBitmapEx ); } -void ToolBox::SetItemImageAngle( sal_uInt16 nItemId, Degree10 nAngle10 ) +void ToolBox::SetItemImageAngle( ToolBoxItemId nItemId, Degree10 nAngle10 ) { ImplToolItems::size_type nPos = GetItemPos( nItemId ); @@ -1009,7 +1009,7 @@ static Image ImplMirrorImage( const Image& rImage ) return Image( aMirrBitmapEx ); } -void ToolBox::SetItemImageMirrorMode( sal_uInt16 nItemId, bool bMirror ) +void ToolBox::SetItemImageMirrorMode( ToolBoxItemId nItemId, bool bMirror ) { ImplToolItems::size_type nPos = GetItemPos( nItemId ); @@ -1031,13 +1031,13 @@ void ToolBox::SetItemImageMirrorMode( sal_uInt16 nItemId, bool bMirror ) } } -Image ToolBox::GetItemImage(sal_uInt16 nItemId) const +Image ToolBox::GetItemImage(ToolBoxItemId nItemId) const { ImplToolItem* pItem = ImplGetItem(nItemId); return pItem ? pItem->maImage : Image(); } -void ToolBox::SetItemText( sal_uInt16 nItemId, const OUString& rText ) +void ToolBox::SetItemText( ToolBoxItemId nItemId, const OUString& rText ) { ImplToolItems::size_type nPos = GetItemPos( nItemId ); @@ -1067,7 +1067,7 @@ void ToolBox::SetItemText( sal_uInt16 nItemId, const OUString& rText ) CallEventListeners( VclEventId::ToolboxItemTextChanged, reinterpret_cast< void* >( nPos ) ); } -const OUString& ToolBox::GetItemText( sal_uInt16 nItemId ) const +const OUString& ToolBox::GetItemText( ToolBoxItemId nItemId ) const { ImplToolItem* pItem = ImplGetItem( nItemId ); @@ -1077,7 +1077,7 @@ const OUString& ToolBox::GetItemText( sal_uInt16 nItemId ) const return pItem->maText; } -void ToolBox::SetItemWindow( sal_uInt16 nItemId, vcl::Window* pNewWindow ) +void ToolBox::SetItemWindow( ToolBoxItemId nItemId, vcl::Window* pNewWindow ) { ImplToolItems::size_type nPos = GetItemPos( nItemId ); @@ -1092,7 +1092,7 @@ void ToolBox::SetItemWindow( sal_uInt16 nItemId, vcl::Window* pNewWindow ) } } -vcl::Window* ToolBox::GetItemWindow( sal_uInt16 nItemId ) const +vcl::Window* ToolBox::GetItemWindow( ToolBoxItemId nItemId ) const { ImplToolItem* pItem = ImplGetItem( nItemId ); @@ -1117,12 +1117,12 @@ void ToolBox::EndSelection() } mnCurPos = ITEM_NOTFOUND; - mnCurItemId = 0; - mnDownItemId = 0; + mnCurItemId = ToolBoxItemId(0); + mnDownItemId = ToolBoxItemId(0); mnMouseModifier = 0; } -void ToolBox::SetItemDown( sal_uInt16 nItemId, bool bDown ) +void ToolBox::SetItemDown( ToolBoxItemId nItemId, bool bDown ) { ImplToolItems::size_type nPos = GetItemPos( nItemId ); @@ -1157,12 +1157,12 @@ void ToolBox::SetItemDown( sal_uInt16 nItemId, bool bDown ) Deactivate(); } - mnCurItemId = 0; - mnDownItemId = 0; + mnCurItemId = ToolBoxItemId(0); + mnDownItemId = ToolBoxItemId(0); mnMouseModifier = 0; } -void ToolBox::SetItemState( sal_uInt16 nItemId, TriState eState ) +void ToolBox::SetItemState( ToolBoxItemId nItemId, TriState eState ) { ImplToolItems::size_type nPos = GetItemPos( nItemId ); @@ -1222,7 +1222,7 @@ void ToolBox::SetItemState( sal_uInt16 nItemId, TriState eState ) CallEventListeners( VclEventId::ToolboxItemUpdated, reinterpret_cast< void* >(nPos) ); } -TriState ToolBox::GetItemState( sal_uInt16 nItemId ) const +TriState ToolBox::GetItemState( ToolBoxItemId nItemId ) const { ImplToolItem* pItem = ImplGetItem( nItemId ); @@ -1232,7 +1232,7 @@ TriState ToolBox::GetItemState( sal_uInt16 nItemId ) const return TRISTATE_FALSE; } -void ToolBox::EnableItem( sal_uInt16 nItemId, bool bEnable ) +void ToolBox::EnableItem( ToolBoxItemId nItemId, bool bEnable ) { ImplToolItems::size_type nPos = GetItemPos( nItemId ); @@ -1260,7 +1260,7 @@ void ToolBox::EnableItem( sal_uInt16 nItemId, bool bEnable ) CallEventListeners( bEnable ? VclEventId::ToolboxItemEnabled : VclEventId::ToolboxItemDisabled, reinterpret_cast< void* >( nPos ) ); } -bool ToolBox::IsItemEnabled( sal_uInt16 nItemId ) const +bool ToolBox::IsItemEnabled( ToolBoxItemId nItemId ) const { ImplToolItem* pItem = ImplGetItem( nItemId ); @@ -1270,7 +1270,7 @@ bool ToolBox::IsItemEnabled( sal_uInt16 nItemId ) const return false; } -void ToolBox::ShowItem( sal_uInt16 nItemId, bool bVisible ) +void ToolBox::ShowItem( ToolBoxItemId nItemId, bool bVisible ) { ImplToolItems::size_type nPos = GetItemPos( nItemId ); mpData->ImplClearLayoutData(); @@ -1286,7 +1286,7 @@ void ToolBox::ShowItem( sal_uInt16 nItemId, bool bVisible ) } } -bool ToolBox::IsItemClipped( sal_uInt16 nItemId ) const +bool ToolBox::IsItemClipped( ToolBoxItemId nItemId ) const { ImplToolItem* pItem = ImplGetItem( nItemId ); @@ -1296,7 +1296,7 @@ bool ToolBox::IsItemClipped( sal_uInt16 nItemId ) const return false; } -bool ToolBox::IsItemVisible( sal_uInt16 nItemId ) const +bool ToolBox::IsItemVisible( ToolBoxItemId nItemId ) const { ImplToolItem* pItem = ImplGetItem( nItemId ); @@ -1306,7 +1306,7 @@ bool ToolBox::IsItemVisible( sal_uInt16 nItemId ) const return false; } -bool ToolBox::IsItemReallyVisible( sal_uInt16 nItemId ) const +bool ToolBox::IsItemReallyVisible( ToolBoxItemId nItemId ) const { // is the item on the visible area of the toolbox? bool bRet = false; @@ -1322,7 +1322,7 @@ bool ToolBox::IsItemReallyVisible( sal_uInt16 nItemId ) const return bRet; } -void ToolBox::SetItemCommand(sal_uInt16 nItemId, const OUString& rCommand) +void ToolBox::SetItemCommand(ToolBoxItemId nItemId, const OUString& rCommand) { ImplToolItem* pItem = ImplGetItem( nItemId ); @@ -1330,7 +1330,7 @@ void ToolBox::SetItemCommand(sal_uInt16 nItemId, const OUString& rCommand) pItem->maCommandStr = rCommand; } -OUString ToolBox::GetItemCommand( sal_uInt16 nItemId ) const +OUString ToolBox::GetItemCommand( ToolBoxItemId nItemId ) const { ImplToolItem* pItem = ImplGetItem( nItemId ); @@ -1340,7 +1340,7 @@ OUString ToolBox::GetItemCommand( sal_uInt16 nItemId ) const return OUString(); } -void ToolBox::SetQuickHelpText( sal_uInt16 nItemId, const OUString& rText ) +void ToolBox::SetQuickHelpText( ToolBoxItemId nItemId, const OUString& rText ) { ImplToolItem* pItem = ImplGetItem( nItemId ); @@ -1348,7 +1348,7 @@ void ToolBox::SetQuickHelpText( sal_uInt16 nItemId, const OUString& rText ) pItem->maQuickHelpText = rText; } -OUString ToolBox::GetQuickHelpText( sal_uInt16 nItemId ) const +OUString ToolBox::GetQuickHelpText( ToolBoxItemId nItemId ) const { ImplToolItem* pItem = ImplGetItem( nItemId ); @@ -1358,7 +1358,7 @@ OUString ToolBox::GetQuickHelpText( sal_uInt16 nItemId ) const return OUString(); } -void ToolBox::SetHelpText( sal_uInt16 nItemId, const OUString& rText ) +void ToolBox::SetHelpText( ToolBoxItemId nItemId, const OUString& rText ) { ImplToolItem* pItem = ImplGetItem( nItemId ); @@ -1366,12 +1366,12 @@ void ToolBox::SetHelpText( sal_uInt16 nItemId, const OUString& rText ) pItem->maHelpText = rText; } -const OUString& ToolBox::GetHelpText( sal_uInt16 nItemId ) const +const OUString& ToolBox::GetHelpText( ToolBoxItemId nItemId ) const { return ImplGetHelpText( nItemId ); } -void ToolBox::SetHelpId( sal_uInt16 nItemId, const OString& rHelpId ) +void ToolBox::SetHelpId( ToolBoxItemId nItemId, const OString& rHelpId ) { ImplToolItem* pItem = ImplGetItem( nItemId ); @@ -1411,7 +1411,7 @@ OUString ToolBox::GetDisplayText() const return mpData->m_pLayoutData ? mpData->m_pLayoutData->m_aDisplayText : OUString(); } -tools::Rectangle ToolBox::GetCharacterBounds( sal_uInt16 nItemID, tools::Long nIndex ) +tools::Rectangle ToolBox::GetCharacterBounds( ToolBoxItemId nItemID, tools::Long nIndex ) { tools::Long nItemIndex = -1; if( ! mpData->m_pLayoutData ) @@ -1430,10 +1430,10 @@ tools::Rectangle ToolBox::GetCharacterBounds( sal_uInt16 nItemID, tools::Long nI return (mpData->m_pLayoutData && nItemIndex != -1) ? mpData->m_pLayoutData->GetCharacterBounds( nItemIndex+nIndex ) : tools::Rectangle(); } -tools::Long ToolBox::GetIndexForPoint( const Point& rPoint, sal_uInt16& rItemID ) +tools::Long ToolBox::GetIndexForPoint( const Point& rPoint, ToolBoxItemId& rItemID ) { tools::Long nIndex = -1; - rItemID = 0; + rItemID = ToolBoxItemId(0); if( ! mpData->m_pLayoutData ) ImplFillLayoutData(); if( mpData->m_pLayoutData ) @@ -1545,7 +1545,7 @@ void ToolBox::UpdateCustomMenu() { if( rItem.IsClipped() ) { - sal_uInt16 id = rItem.mnId + TOOLBOX_MENUITEM_START; + sal_uInt16 id = sal_uInt16(rItem.mnId) + TOOLBOX_MENUITEM_START; MenuItemBits nMenuItemBits = ConvertBitsFromToolBoxToMenu(rItem.mnBits); pMenu->InsertItem( id, rItem.maText, rItem.maImage, nMenuItemBits); pMenu->SetItemCommand( id, rItem.maCommandStr ); @@ -1562,7 +1562,7 @@ void ToolBox::UpdateCustomMenu() { if( rItem.IsItemHidden() ) { - sal_uInt16 id = rItem.mnId + TOOLBOX_MENUITEM_START; + sal_uInt16 id = sal_uInt16(rItem.mnId) + TOOLBOX_MENUITEM_START; MenuItemBits nMenuItemBits = ConvertBitsFromToolBoxToMenu(rItem.mnBits); pMenu->InsertItem( id, rItem.maText, rItem.maImage, nMenuItemBits ); pMenu->SetItemCommand( id, rItem.maCommandStr ); @@ -1578,7 +1578,7 @@ IMPL_LINK( ToolBox, ImplCustomMenuListener, VclMenuEvent&, rEvent, void ) { sal_uInt16 id = GetMenu()->GetItemId( rEvent.GetItemPos() ); if( id >= TOOLBOX_MENUITEM_START ) - TriggerItem( id - TOOLBOX_MENUITEM_START ); + TriggerItem( ToolBoxItemId(id - TOOLBOX_MENUITEM_START) ); } } @@ -1743,7 +1743,7 @@ void ToolBox::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) if (type == ToolBoxItemType::BUTTON) { auto childNode = rJsonWriter.startStruct(); - int nId = GetItemId(i); + ToolBoxItemId nId = GetItemId(i); if (!IsItemVisible(nId)) continue; rJsonWriter.put("type", "toolitem"); |