accessibility/source/standard/vclxaccessibletabpage.cxx | 24 ++-- include/vcl/tabctrl.hxx | 12 -- vcl/source/control/tabctrl.cxx | 85 ---------------- 3 files changed, 12 insertions(+), 109 deletions(-)
New commits: commit 160ea29f0003812ab1d4e1f6689c608c879ef509 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Jun 28 14:55:32 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Jun 29 08:36:11 2023 +0200 maLayoutLineToPageId and maLayoutPageIdToLine are dead. I removed the code in ImplDrawItem that added data to them, because ImplDrawItem was only ever called with bLayout with false, and removing the bLayout param removed that code. That removal happened in: commit f0f973da8560e16cba85d2c9465c3a8c4c0ebbb3 Author: Noel Grandin <n...@peralex.com> Date: Wed Mar 16 08:49:35 2016 +0200 loplugin:constantparams in vcl/ And that happened because.... I noticed that ImplPaint was only ever called with bLayout==false, which meant I removed that param and passed bLayout==false to ImplDrawItem, in: commit 911ae0aeca443fb4b5e400ae0f939567b580e443 Author: Noel Grandin <n...@peralex.com> Date: Fri Feb 26 09:36:26 2016 +0200 loplugin:unuseddefaultparams in /include/vcl which was because the last call to ImplPaint with bLayout == true was removed in: commit a6b9d9a19fb8c5c9f166682f52941aee25b89c94 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> Date: Wed May 6 13:00:13 2015 +0900 refactor "TabControl" to use RenderContext Change-Id: Id234257201726de95e2c10bfacb30670123ca8a4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153713 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/accessibility/source/standard/vclxaccessibletabpage.cxx b/accessibility/source/standard/vclxaccessibletabpage.cxx index 0dae45ca840c..89b0d6c29b2a 100644 --- a/accessibility/source/standard/vclxaccessibletabpage.cxx +++ b/accessibility/source/standard/vclxaccessibletabpage.cxx @@ -586,7 +586,7 @@ awt::Rectangle VCLXAccessibleTabPage::getCharacterBounds( sal_Int32 nIndex ) if ( m_pTabControl ) { tools::Rectangle aPageRect = m_pTabControl->GetTabBounds( m_nPageId ); - tools::Rectangle aCharRect = m_pTabControl->GetCharacterBounds( m_nPageId, nIndex ); + tools::Rectangle aCharRect; // m_pTabControl->GetCharacterBounds( m_nPageId, nIndex ); aCharRect.Move( -aPageRect.Left(), -aPageRect.Top() ); aBounds = AWTRectangle( aCharRect ); } @@ -595,21 +595,21 @@ awt::Rectangle VCLXAccessibleTabPage::getCharacterBounds( sal_Int32 nIndex ) } -sal_Int32 VCLXAccessibleTabPage::getIndexAtPoint( const awt::Point& aPoint ) +sal_Int32 VCLXAccessibleTabPage::getIndexAtPoint( const awt::Point& /*aPoint*/ ) { OExternalLockGuard aGuard( this ); sal_Int32 nIndex = -1; - if ( m_pTabControl ) - { - sal_uInt16 nPageId = 0; - tools::Rectangle aPageRect = m_pTabControl->GetTabBounds( m_nPageId ); - Point aPnt( VCLPoint( aPoint ) ); - aPnt += aPageRect.TopLeft(); - sal_Int32 nI = m_pTabControl->GetIndexForPoint( aPnt, nPageId ); - if ( nI != -1 && m_nPageId == nPageId ) - nIndex = nI; - } +// if ( m_pTabControl ) +// { +// sal_uInt16 nPageId = 0; +// tools::Rectangle aPageRect = m_pTabControl->GetTabBounds( m_nPageId ); +// Point aPnt( VCLPoint( aPoint ) ); +// aPnt += aPageRect.TopLeft(); +// sal_Int32 nI = m_pTabControl->GetIndexForPoint( aPnt, nPageId ); +// if ( nI != -1 && m_nPageId == nPageId ) +// nIndex = nI; +// } return nIndex; } diff --git a/include/vcl/tabctrl.hxx b/include/vcl/tabctrl.hxx index 3da709d77807..f7db263d2eac 100644 --- a/include/vcl/tabctrl.hxx +++ b/include/vcl/tabctrl.hxx @@ -69,7 +69,6 @@ protected: SAL_DLLPRIVATE void ImplDrawItem(vcl::RenderContext& rRenderContext, ImplTabItem const * pItem, const tools::Rectangle& rCurRect, bool bFirstInGroup, bool bLastInGroup); - SAL_DLLPRIVATE void ImplFreeLayoutData(); SAL_DLLPRIVATE bool ImplHandleKeyEvent( const KeyEvent& rKeyEvent ); DECL_DLLPRIVATE_LINK( ImplListBoxSelectHdl, ListBox&, void ); @@ -78,7 +77,6 @@ protected: using Window::ImplInit; SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle ); - virtual void FillLayoutData() const override; virtual const vcl::Font& GetCanonicalFont( const StyleSettings& _rStyle ) const override; virtual const Color& GetCanonicalTextColor( const StyleSettings& _rStyle ) const override; virtual bool ImplPlaceTabs( tools::Long nWidth ); @@ -154,16 +152,6 @@ public: void SetActivatePageHdl( const Link<TabControl*,void>& rLink ) { maActivateHdl = rLink; } void SetDeactivatePageHdl( const Link<TabControl*, bool>& rLink ) { maDeactivateHdl = rLink; } - // returns (control relative) bounding rectangle for the - // character at index nIndex relative to the text of page nPageId - using Control::GetCharacterBounds; - tools::Rectangle GetCharacterBounds( sal_uInt16 nPageId, tools::Long nIndex ) const; - - // returns the index relative to the text of page nPageId (also returned) - // at position rPoint (control relative) - using Control::GetIndexForPoint; - tools::Long GetIndexForPoint( const Point& rPoint, sal_uInt16& rPageId ) const; - // returns the rectangle of the tab for page nPageId tools::Rectangle GetTabBounds( sal_uInt16 nPageId ) const; diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index f59431401137..a2461c5a0f80 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -90,8 +90,6 @@ ImplTabItem::ImplTabItem(sal_uInt16 nId) struct ImplTabCtrlData { - std::unordered_map< int, int > maLayoutPageIdToLine; - std::unordered_map< int, int > maLayoutLineToPageId; std::vector< ImplTabItem > maItemList; VclPtr<ListBox> mpListBox; }; @@ -187,16 +185,6 @@ void TabControl::ImplInitSettings( bool bBackground ) } } -void TabControl::ImplFreeLayoutData() -{ - if( HasLayoutData() ) - { - ImplClearLayoutData(); - mpTabCtrlData->maLayoutPageIdToLine.clear(); - mpTabCtrlData->maLayoutLineToPageId.clear(); - } -} - TabControl::TabControl( vcl::Window* pParent, WinBits nStyle ) : Control( WindowType::TABCONTROL ) { @@ -215,8 +203,6 @@ void TabControl::dispose() if (pParent && pParent->IsDialog()) GetParent()->RemoveChildEventListener( LINK( this, TabControl, ImplWindowEventListener ) ); - ImplFreeLayoutData(); - // delete TabCtrl data if (mpTabCtrlData) mpTabCtrlData->mpListBox.disposeAndClear(); @@ -633,8 +619,6 @@ tools::Rectangle TabControl::ImplGetTabRect(const ImplTabItem* pItem, tools::Lon void TabControl::ImplChangeTabPage( sal_uInt16 nId, sal_uInt16 nOldId ) { - ImplFreeLayoutData(); - ImplTabItem* pOldItem = ImplGetItem( nOldId ); ImplTabItem* pItem = ImplGetItem( nId ); TabPage* pOldPage = pOldItem ? pOldItem->mpTabPage.get() : nullptr; @@ -1276,8 +1260,6 @@ void TabControl::Paint( vcl::RenderContext& rRenderContext, const tools::Rectang void TabControl::setAllocation(const Size &rAllocation) { - ImplFreeLayoutData(); - if ( !IsReallyShown() ) return; @@ -1645,8 +1627,6 @@ bool TabControl::DeactivatePage() void TabControl::SetTabPageSizePixel( const Size& rSize ) { - ImplFreeLayoutData(); - Size aNewSize( rSize ); aNewSize.AdjustWidth(TAB_OFFSET*2 ); tools::Rectangle aRect = ImplGetTabRect( TAB_PAGERECT, @@ -1698,7 +1678,6 @@ void TabControl::InsertPage( sal_uInt16 nPageId, const OUString& rText, if ( IsUpdateMode() ) Invalidate(); - ImplFreeLayoutData(); if( mpTabCtrlData->mpListBox ) // reposition/resize listbox Resize(); @@ -1746,8 +1725,6 @@ void TabControl::RemovePage( sal_uInt16 nPageId ) if ( IsUpdateMode() ) Invalidate(); - ImplFreeLayoutData(); - CallEventListeners( VclEventId::TabpageRemoved, reinterpret_cast<void*>(nPageId) ); } @@ -1886,8 +1863,6 @@ void TabControl::SelectTabPage( sal_uInt16 nPageId ) if ( !nPageId || (nPageId == mnCurPageId) ) return; - ImplFreeLayoutData(); - CallEventListeners( VclEventId::TabpageDeactivate, reinterpret_cast<void*>(mnCurPageId) ); if ( DeactivatePage() ) { @@ -1956,7 +1931,6 @@ void TabControl::SetPageText( sal_uInt16 nPageId, const OUString& rText ) } if ( IsUpdateMode() ) Invalidate(); - ImplFreeLayoutData(); CallEventListeners( VclEventId::TabpagePageTextChanged, reinterpret_cast<void*>(nPageId) ); } @@ -2048,65 +2022,6 @@ void TabControl::SetPageImage( sal_uInt16 i_nPageId, const Image& i_rImage ) } } -tools::Rectangle TabControl::GetCharacterBounds( sal_uInt16 nPageId, tools::Long nIndex ) const -{ - tools::Rectangle aRet; - - if( !HasLayoutData() || mpTabCtrlData->maLayoutPageIdToLine.empty() ) - FillLayoutData(); - - if( HasLayoutData() ) - { - std::unordered_map< int, int >::const_iterator it = mpTabCtrlData->maLayoutPageIdToLine.find( static_cast<int>(nPageId) ); - if( it != mpTabCtrlData->maLayoutPageIdToLine.end() ) - { - Pair aPair = mxLayoutData->GetLineStartEnd( it->second ); - if( (aPair.B() - aPair.A()) >= nIndex ) - aRet = mxLayoutData->GetCharacterBounds( aPair.A() + nIndex ); - } - } - - return aRet; -} - -tools::Long TabControl::GetIndexForPoint( const Point& rPoint, sal_uInt16& rPageId ) const -{ - tools::Long nRet = -1; - - if( !HasLayoutData() || mpTabCtrlData->maLayoutPageIdToLine.empty() ) - FillLayoutData(); - - if( HasLayoutData() ) - { - int nIndex = mxLayoutData->GetIndexForPoint( rPoint ); - if( nIndex != -1 ) - { - // what line (->pageid) is this index in ? - int nLines = mxLayoutData->GetLineCount(); - int nLine = -1; - while( ++nLine < nLines ) - { - Pair aPair = mxLayoutData->GetLineStartEnd( nLine ); - if( aPair.A() <= nIndex && aPair.B() >= nIndex ) - { - nRet = nIndex - aPair.A(); - rPageId = static_cast<sal_uInt16>(mpTabCtrlData->maLayoutLineToPageId[ nLine ]); - break; - } - } - } - } - - return nRet; -} - -void TabControl::FillLayoutData() const -{ - mpTabCtrlData->maLayoutLineToPageId.clear(); - mpTabCtrlData->maLayoutPageIdToLine.clear(); - const_cast<TabControl*>(this)->Invalidate(); -} - tools::Rectangle TabControl::GetTabBounds( sal_uInt16 nPageId ) const { tools::Rectangle aRet;