diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-08-08 21:08:37 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-08-08 22:32:12 +0200 |
commit | 2c1ae17421af0fc0e398b66bc2a07f27977a5bf0 (patch) | |
tree | 3280843e618053ff16d8e8be9a4baf40cd42bb88 /vcl/source/control | |
parent | 12dd1ce1dddc4ebad6be94ddec167cc7f6c45fe3 (diff) |
no need to allocate ControlLayoutData separately
Change-Id: I239befdaa05beea5200c81f23d0af861c9fc3baa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120177
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/source/control')
-rw-r--r-- | vcl/source/control/button.cxx | 7 | ||||
-rw-r--r-- | vcl/source/control/combobox.cxx | 3 | ||||
-rw-r--r-- | vcl/source/control/ctrl.cxx | 41 | ||||
-rw-r--r-- | vcl/source/control/edit.cxx | 3 | ||||
-rw-r--r-- | vcl/source/control/fixed.cxx | 11 | ||||
-rw-r--r-- | vcl/source/control/imp_listbox.cxx | 9 | ||||
-rw-r--r-- | vcl/source/control/listbox.cxx | 3 | ||||
-rw-r--r-- | vcl/source/control/spinfld.cxx | 3 | ||||
-rw-r--r-- | vcl/source/control/tabctrl.cxx | 11 |
9 files changed, 41 insertions, 50 deletions
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index 68b368b56c0e..e8c1b9854862 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -27,7 +27,6 @@ #include <vcl/event.hxx> #include <vcl/svapp.hxx> #include <vcl/settings.hxx> -#include <vcl/toolkit/controllayout.hxx> #include <vcl/toolkit/dialog.hxx> #include <vcl/toolkit/fixed.hxx> #include <vcl/toolkit/button.hxx> @@ -1340,7 +1339,7 @@ void PushButton::KeyUp( const KeyEvent& rKEvt ) void PushButton::FillLayoutData() const { - mpLayoutData.reset( new vcl::ControlLayoutData ); + mxLayoutData.emplace(); const_cast<PushButton*>(this)->Invalidate(); } @@ -2435,7 +2434,7 @@ void RadioButton::KeyUp( const KeyEvent& rKEvt ) void RadioButton::FillLayoutData() const { - mpLayoutData.reset( new vcl::ControlLayoutData ); + mxLayoutData.emplace(); const_cast<RadioButton*>(this)->Invalidate(); } @@ -3249,7 +3248,7 @@ void CheckBox::KeyUp( const KeyEvent& rKEvt ) void CheckBox::FillLayoutData() const { - mpLayoutData.reset( new vcl::ControlLayoutData ); + mxLayoutData.emplace(); const_cast<CheckBox*>(this)->Invalidate(); } diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx index 85b418a14f86..5fc86dd6d4f9 100644 --- a/vcl/source/control/combobox.cxx +++ b/vcl/source/control/combobox.cxx @@ -22,7 +22,6 @@ #include <set> #include <comphelper/string.hxx> -#include <vcl/toolkit/controllayout.hxx> #include <vcl/toolkit/lstbox.hxx> #include <vcl/builder.hxx> #include <vcl/commandevent.hxx> @@ -607,7 +606,7 @@ bool ComboBox::IsDropDownBox() const { return m_pImpl->m_pFloatWin != nullptr; } void ComboBox::FillLayoutData() const { - mpLayoutData.reset( new vcl::ControlLayoutData ); + mxLayoutData.emplace(); AppendLayoutData( *m_pImpl->m_pSubEdit ); m_pImpl->m_pSubEdit->SetLayoutDataParent( this ); ImplListBoxWindow* rMainWindow = GetMainWindow(); diff --git a/vcl/source/control/ctrl.cxx b/vcl/source/control/ctrl.cxx index 28af923cb168..cf221b2b02c7 100644 --- a/vcl/source/control/ctrl.cxx +++ b/vcl/source/control/ctrl.cxx @@ -23,7 +23,6 @@ #include <vcl/decoview.hxx> #include <vcl/settings.hxx> #include <vcl/uitest/logger.hxx> -#include <vcl/toolkit/controllayout.hxx> #include <sal/log.hxx> #include <textlayout.hxx> @@ -57,7 +56,7 @@ Control::~Control() void Control::dispose() { - mpLayoutData.reset(); + mxLayoutData.reset(); mpReferenceDevice.clear(); Window::dispose(); } @@ -83,13 +82,13 @@ void Control::FillLayoutData() const void Control::CreateLayoutData() const { - SAL_WARN_IF( mpLayoutData, "vcl", "Control::CreateLayoutData: should be called with non-existent layout data only!" ); - mpLayoutData.reset( new vcl::ControlLayoutData ); + SAL_WARN_IF( mxLayoutData, "vcl", "Control::CreateLayoutData: should be called with non-existent layout data only!" ); + mxLayoutData.emplace(); } bool Control::HasLayoutData() const { - return mpLayoutData != nullptr; + return bool(mxLayoutData); } void Control::SetText( const OUString& rStr ) @@ -111,7 +110,7 @@ tools::Rectangle Control::GetCharacterBounds( tools::Long nIndex ) const { if( !HasLayoutData() ) FillLayoutData(); - return mpLayoutData ? mpLayoutData->GetCharacterBounds( nIndex ) : tools::Rectangle(); + return mxLayoutData ? mxLayoutData->GetCharacterBounds( nIndex ) : tools::Rectangle(); } tools::Long ControlLayoutData::GetIndexForPoint( const Point& rPoint ) const @@ -135,7 +134,7 @@ tools::Long Control::GetIndexForPoint( const Point& rPoint ) const { if( ! HasLayoutData() ) FillLayoutData(); - return mpLayoutData ? mpLayoutData->GetIndexForPoint( rPoint ) : -1; + return mxLayoutData ? mxLayoutData->GetIndexForPoint( rPoint ) : -1; } tools::Long ControlLayoutData::GetLineCount() const @@ -173,7 +172,7 @@ Pair Control::GetLineStartEnd( tools::Long nLine ) const { if( !HasLayoutData() ) FillLayoutData(); - return mpLayoutData ? mpLayoutData->GetLineStartEnd( nLine ) : Pair( -1, -1 ); + return mxLayoutData ? mxLayoutData->GetLineStartEnd( nLine ) : Pair( -1, -1 ); } tools::Long ControlLayoutData::ToRelativeLineIndex( tools::Long nIndex ) const @@ -212,14 +211,14 @@ tools::Long Control::ToRelativeLineIndex( tools::Long nIndex ) const { if( !HasLayoutData() ) FillLayoutData(); - return mpLayoutData ? mpLayoutData->ToRelativeLineIndex( nIndex ) : -1; + return mxLayoutData ? mxLayoutData->ToRelativeLineIndex( nIndex ) : -1; } OUString Control::GetDisplayText() const { if( !HasLayoutData() ) FillLayoutData(); - return mpLayoutData ? mpLayoutData->m_aDisplayText : GetText(); + return mxLayoutData ? mxLayoutData->m_aDisplayText : GetText(); } bool Control::EventNotify( NotifyEvent& rNEvt ) @@ -270,23 +269,23 @@ void Control::AppendLayoutData( const Control& rSubControl ) const { if( !rSubControl.HasLayoutData() ) rSubControl.FillLayoutData(); - if( !rSubControl.HasLayoutData() || rSubControl.mpLayoutData->m_aDisplayText.isEmpty() ) + if( !rSubControl.HasLayoutData() || rSubControl.mxLayoutData->m_aDisplayText.isEmpty() ) return; - tools::Long nCurrentIndex = mpLayoutData->m_aDisplayText.getLength(); - mpLayoutData->m_aDisplayText += rSubControl.mpLayoutData->m_aDisplayText; - int nLines = rSubControl.mpLayoutData->m_aLineIndices.size(); + tools::Long nCurrentIndex = mxLayoutData->m_aDisplayText.getLength(); + mxLayoutData->m_aDisplayText += rSubControl.mxLayoutData->m_aDisplayText; + int nLines = rSubControl.mxLayoutData->m_aLineIndices.size(); int n; - mpLayoutData->m_aLineIndices.push_back( nCurrentIndex ); + mxLayoutData->m_aLineIndices.push_back( nCurrentIndex ); for( n = 1; n < nLines; n++ ) - mpLayoutData->m_aLineIndices.push_back( rSubControl.mpLayoutData->m_aLineIndices[n] + nCurrentIndex ); - int nRectangles = rSubControl.mpLayoutData->m_aUnicodeBoundRects.size(); + mxLayoutData->m_aLineIndices.push_back( rSubControl.mxLayoutData->m_aLineIndices[n] + nCurrentIndex ); + int nRectangles = rSubControl.mxLayoutData->m_aUnicodeBoundRects.size(); tools::Rectangle aRel = rSubControl.GetWindowExtentsRelative(this); for( n = 0; n < nRectangles; n++ ) { - tools::Rectangle aRect = rSubControl.mpLayoutData->m_aUnicodeBoundRects[n]; + tools::Rectangle aRect = rSubControl.mxLayoutData->m_aUnicodeBoundRects[n]; aRect.Move( aRel.Left(), aRel.Top() ); - mpLayoutData->m_aUnicodeBoundRects.push_back( aRect ); + mxLayoutData->m_aUnicodeBoundRects.push_back( aRect ); } } @@ -320,12 +319,12 @@ bool Control::ImplCallEventListenersAndHandler( VclEventId nEvent, std::function void Control::SetLayoutDataParent( const Control* pParent ) const { if( HasLayoutData() ) - mpLayoutData->m_pParent = pParent; + mxLayoutData->m_pParent = pParent; } void Control::ImplClearLayoutData() const { - mpLayoutData.reset(); + mxLayoutData.reset(); } void Control::ImplDrawFrame( OutputDevice* pDev, tools::Rectangle& rRect ) diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx index 4b6adef6bce7..c2329c45dc78 100644 --- a/vcl/source/control/edit.cxx +++ b/vcl/source/control/edit.cxx @@ -21,7 +21,6 @@ #include <vcl/event.hxx> #include <vcl/cursor.hxx> #include <vcl/menu.hxx> -#include <vcl/toolkit/controllayout.hxx> #include <vcl/toolkit/edit.hxx> #include <vcl/weld.hxx> #include <vcl/specialchars.hxx> @@ -1716,7 +1715,7 @@ void Edit::KeyInput( const KeyEvent& rKEvt ) void Edit::FillLayoutData() const { - mpLayoutData.reset( new vcl::ControlLayoutData ); + mxLayoutData.emplace(); const_cast<Edit*>(this)->Invalidate(); } diff --git a/vcl/source/control/fixed.cxx b/vcl/source/control/fixed.cxx index 467ac69d350a..b40e82048aae 100644 --- a/vcl/source/control/fixed.cxx +++ b/vcl/source/control/fixed.cxx @@ -19,7 +19,6 @@ #include <vcl/decoview.hxx> #include <vcl/event.hxx> -#include <vcl/toolkit/controllayout.hxx> #include <vcl/toolkit/fixed.hxx> #include <vcl/settings.hxx> @@ -153,12 +152,12 @@ void FixedText::ImplDraw(OutputDevice* pDev, DrawFlags nDrawFlags, nTextStyle |= DrawTextFlags::Mono; if( bFillLayout ) - mpLayoutData->m_aDisplayText.clear(); + mxLayoutData->m_aDisplayText.clear(); const tools::Rectangle aRect(aPos, rSize); DrawControlText(*pDev, aRect, aText, nTextStyle, - bFillLayout ? &mpLayoutData->m_aUnicodeBoundRects : nullptr, - bFillLayout ? &mpLayoutData->m_aDisplayText : nullptr); + bFillLayout ? &mxLayoutData->m_aUnicodeBoundRects : nullptr, + bFillLayout ? &mxLayoutData->m_aDisplayText : nullptr); } void FixedText::ApplySettings(vcl::RenderContext& rRenderContext) @@ -348,7 +347,7 @@ Size FixedText::GetOptimalSize() const void FixedText::FillLayoutData() const { - mpLayoutData.reset( new vcl::ControlLayoutData ); + mxLayoutData.emplace(); ImplDraw(const_cast<FixedText*>(this)->GetOutDev(), DrawFlags::NONE, Point(), GetOutputSizePixel(), true); //const_cast<FixedText*>(this)->Invalidate(); } @@ -553,7 +552,7 @@ FixedLine::FixedLine( vcl::Window* pParent, WinBits nStyle ) : void FixedLine::FillLayoutData() const { - mpLayoutData.reset( new vcl::ControlLayoutData ); + mxLayoutData.emplace(); const_cast<FixedLine*>(this)->Invalidate(); } diff --git a/vcl/source/control/imp_listbox.cxx b/vcl/source/control/imp_listbox.cxx index f3b06bf75543..a607aa84a45f 100644 --- a/vcl/source/control/imp_listbox.cxx +++ b/vcl/source/control/imp_listbox.cxx @@ -23,7 +23,6 @@ #include <vcl/settings.hxx> #include <vcl/event.hxx> #include <vcl/scrbar.hxx> -#include <vcl/toolkit/controllayout.hxx> #include <vcl/toolkit/lstbox.hxx> #include <vcl/i18nhelp.hxx> #include <vcl/naturalsort.hxx> @@ -1746,7 +1745,7 @@ void ImplListBoxWindow::DrawEntry(vcl::RenderContext& rRenderContext, sal_Int32 void ImplListBoxWindow::FillLayoutData() const { - mpLayoutData.reset( new vcl::ControlLayoutData ); + mxLayoutData.emplace(); const_cast<ImplListBoxWindow*>(this)->Invalidate(tools::Rectangle(Point(0, 0), GetOutDev()->GetOutputSize())); } @@ -2497,7 +2496,7 @@ void ImplWin::MouseButtonDown( const MouseEvent& ) void ImplWin::FillLayoutData() const { - mpLayoutData.reset( new vcl::ControlLayoutData ); + mxLayoutData.emplace(); ImplWin* pThis = const_cast<ImplWin*>(this); pThis->ImplDraw(*pThis->GetOutDev(), true); } @@ -2715,8 +2714,8 @@ void ImplWin::DrawEntry(vcl::RenderContext& rRenderContext, bool bLayout) aTextRect.AdjustLeft(maImage.GetSizePixel().Width() + IMG_TXT_DISTANCE ); } - std::vector< tools::Rectangle >* pVector = bLayout ? &mpLayoutData->m_aUnicodeBoundRects : nullptr; - OUString* pDisplayText = bLayout ? &mpLayoutData->m_aDisplayText : nullptr; + std::vector< tools::Rectangle >* pVector = bLayout ? &mxLayoutData->m_aUnicodeBoundRects : nullptr; + OUString* pDisplayText = bLayout ? &mxLayoutData->m_aDisplayText : nullptr; rRenderContext.DrawText( aTextRect, maString, nTextStyle, pVector, pDisplayText ); } diff --git a/vcl/source/control/listbox.cxx b/vcl/source/control/listbox.cxx index 58987498ab81..ee53bf4e9858 100644 --- a/vcl/source/control/listbox.cxx +++ b/vcl/source/control/listbox.cxx @@ -20,7 +20,6 @@ #include <vcl/builder.hxx> #include <vcl/commandevent.hxx> #include <vcl/event.hxx> -#include <vcl/toolkit/controllayout.hxx> #include <vcl/toolkit/lstbox.hxx> #include <vcl/settings.hxx> #include <vcl/uitest/uiobject.hxx> @@ -627,7 +626,7 @@ void ListBox::Resize() void ListBox::FillLayoutData() const { - mpLayoutData.reset( new vcl::ControlLayoutData ); + mxLayoutData.emplace(); const ImplListBoxWindow* rMainWin = mpImplLB->GetMainWindow(); if( mpFloatWin ) { diff --git a/vcl/source/control/spinfld.cxx b/vcl/source/control/spinfld.cxx index af8ecbc94edf..9cd3b545d841 100644 --- a/vcl/source/control/spinfld.cxx +++ b/vcl/source/control/spinfld.cxx @@ -20,7 +20,6 @@ #include <vcl/commandevent.hxx> #include <vcl/event.hxx> #include <vcl/decoview.hxx> -#include <vcl/toolkit/controllayout.hxx> #include <vcl/toolkit/spinfld.hxx> #include <vcl/settings.hxx> #include <vcl/uitest/uiobject.hxx> @@ -571,7 +570,7 @@ void SpinField::FillLayoutData() const { if (mbSpin) { - mpLayoutData.reset( new vcl::ControlLayoutData ); + mxLayoutData.emplace(); AppendLayoutData(*GetSubEdit()); GetSubEdit()->SetLayoutDataParent(this); } diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index 09c1281d63db..2a5a46b52f70 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -28,7 +28,6 @@ #include <vcl/toolkit/button.hxx> #include <vcl/tabpage.hxx> #include <vcl/tabctrl.hxx> -#include <vcl/toolkit/controllayout.hxx> #include <vcl/layout.hxx> #include <vcl/toolkit/lstbox.hxx> #include <vcl/settings.hxx> @@ -2021,9 +2020,9 @@ tools::Rectangle TabControl::GetCharacterBounds( sal_uInt16 nPageId, tools::Long std::unordered_map< int, int >::const_iterator it = mpTabCtrlData->maLayoutPageIdToLine.find( static_cast<int>(nPageId) ); if( it != mpTabCtrlData->maLayoutPageIdToLine.end() ) { - Pair aPair = mpLayoutData->GetLineStartEnd( it->second ); + Pair aPair = mxLayoutData->GetLineStartEnd( it->second ); if( (aPair.B() - aPair.A()) >= nIndex ) - aRet = mpLayoutData->GetCharacterBounds( aPair.A() + nIndex ); + aRet = mxLayoutData->GetCharacterBounds( aPair.A() + nIndex ); } } @@ -2039,15 +2038,15 @@ tools::Long TabControl::GetIndexForPoint( const Point& rPoint, sal_uInt16& rPage if( HasLayoutData() ) { - int nIndex = mpLayoutData->GetIndexForPoint( rPoint ); + int nIndex = mxLayoutData->GetIndexForPoint( rPoint ); if( nIndex != -1 ) { // what line (->pageid) is this index in ? - int nLines = mpLayoutData->GetLineCount(); + int nLines = mxLayoutData->GetLineCount(); int nLine = -1; while( ++nLine < nLines ) { - Pair aPair = mpLayoutData->GetLineStartEnd( nLine ); + Pair aPair = mxLayoutData->GetLineStartEnd( nLine ); if( aPair.A() <= nIndex && aPair.B() >= nIndex ) { nRet = nIndex - aPair.A(); |