include/vcl/window.hxx | 2 - vcl/inc/window.h | 3 + vcl/source/window/window.cxx | 75 ++++++++++++++++++++----------------------- 3 files changed, 38 insertions(+), 42 deletions(-)
New commits: commit b0ea829f686b0cb690e2c2828389263f36ee7c5d Author: Arnaud Versini <[email protected]> Date: Thu May 5 18:14:30 2016 +0200 vcl : Simplify vcl::Window initialisation and destruction Change-Id: Ie3a8435d0adff795645618deb2c3c3da813e54f3 Reviewed-on: https://gerrit.libreoffice.org/24681 Reviewed-by: Noel Grandin <[email protected]> Tested-by: Noel Grandin <[email protected]> diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx index 11dc971..50d15e8 100644 --- a/include/vcl/window.hxx +++ b/include/vcl/window.hxx @@ -629,8 +629,6 @@ protected: private: - SAL_DLLPRIVATE void ImplInitWindowData( WindowType nType ); - SAL_DLLPRIVATE void ImplSetFrameParent( const vcl::Window* pParent ); SAL_DLLPRIVATE void ImplInsertWindow( vcl::Window* pParent ); diff --git a/vcl/inc/window.h b/vcl/inc/window.h index 302e9d0..ccdd8bf 100644 --- a/vcl/inc/window.h +++ b/vcl/inc/window.h @@ -99,6 +99,9 @@ struct ImplWinData bool mbEnableNativeWidget; //< toggle native widget rendering ::std::list< VclPtr<vcl::Window> > maTopWindowChildren; + + ImplWinData(); + ~ImplWinData(); }; struct ImplFrameData diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index d1c1ffe..cd44a21 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -78,27 +78,28 @@ using namespace ::com::sun::star::lang; using namespace ::com::sun::star::datatransfer::clipboard; using namespace ::com::sun::star::datatransfer::dnd; - namespace vcl { -Window::Window( WindowType nType ) +Window::Window( WindowType nType ) : + mpWindowImpl(new WindowImpl( nType )) { - ImplInitWindowData( nType ); + meOutDevType = OUTDEV_WINDOW; + + // true: this outdev will be mirrored if RTL window layout (UI mirroring) is globally active + mbEnableRTL = AllSettings::GetLayoutRTL(); } -Window::Window( vcl::Window* pParent, WinBits nStyle ) +Window::Window( vcl::Window* pParent, WinBits nStyle ) : + Window(WINDOW_WINDOW) { - - ImplInitWindowData( WINDOW_WINDOW ); ImplInit( pParent, nStyle, nullptr ); } -Window::Window( vcl::Window* pParent, const ResId& rResId ) - : mpWindowImpl(nullptr) +Window::Window( vcl::Window* pParent, const ResId& rResId ) : + Window(WINDOW_WINDOW) { rResId.SetRT( RSC_WINDOW ); WinBits nStyle = ImplInitRes( rResId ); - ImplInitWindowData( WINDOW_WINDOW ); ImplInit( pParent, nStyle, nullptr ); ImplLoadRes( rResId ); @@ -526,17 +527,7 @@ void Window::dispose() } } - // cleanup Extra Window Data, TODO: add and use ImplWinData destructor - if ( mpWindowImpl->mpWinData ) - { - delete mpWindowImpl->mpWinData->mpExtOldText; - delete mpWindowImpl->mpWinData->mpExtOldAttrAry; - delete mpWindowImpl->mpWinData->mpCursorRect; - delete[] mpWindowImpl->mpWinData->mpCompositionCharRects; - delete mpWindowImpl->mpWinData->mpFocusRect; - delete mpWindowImpl->mpWinData->mpTrackRect; - delete mpWindowImpl->mpWinData; - } + delete mpWindowImpl->mpWinData; // remove BorderWindow or Frame window data mpWindowImpl->mpBorderWindow.disposeAndClear(); @@ -752,6 +743,30 @@ WindowImpl::~WindowImpl() delete mpControlFont; } +ImplWinData::ImplWinData() : + mpExtOldText(nullptr), + mpExtOldAttrAry(nullptr), + mpCursorRect(nullptr), + mnCursorExtWidth(), + mpCompositionCharRects(nullptr), + mpFocusRect(nullptr), + mpTrackRect(nullptr), + mnTrackFlags(0), + mnIsTopWindow((sal_uInt16) ~0) // not initialized yet, 0/1 will indicate TopWindow (see IsTopWindow()) +{ +} + +ImplWinData::~ImplWinData() +{ + delete mpExtOldText; + delete mpExtOldAttrAry; + delete mpCursorRect; + delete[] mpCompositionCharRects; + delete mpFocusRect; + delete mpTrackRect; +} + + namespace vcl { bool Window::AcquireGraphics() const @@ -1201,15 +1216,6 @@ void Window::ImplInitAppFontData( vcl::Window* pWindow ) pSVData->maGDIData.mnAppFontX += (pSVData->maGDIData.mnAppFontX*pSVData->maAppData.mnDialogScaleX)/100; } -void Window::ImplInitWindowData( WindowType nType ) -{ - mpWindowImpl = new WindowImpl( nType ); - - meOutDevType = OUTDEV_WINDOW; - - mbEnableRTL = AllSettings::GetLayoutRTL(); // true: this outdev will be mirrored if RTL window layout (UI mirroring) is globally active -} - ImplWinData* Window::ImplGetWinData() const { if ( !mpWindowImpl->mpWinData ) @@ -1217,17 +1223,6 @@ ImplWinData* Window::ImplGetWinData() const static const char* pNoNWF = getenv( "SAL_NO_NWF" ); const_cast<vcl::Window*>(this)->mpWindowImpl->mpWinData = new ImplWinData; - mpWindowImpl->mpWinData->mpExtOldText = nullptr; - mpWindowImpl->mpWinData->mpExtOldAttrAry = nullptr; - mpWindowImpl->mpWinData->mpCursorRect = nullptr; - mpWindowImpl->mpWinData->mnCursorExtWidth = 0; - mpWindowImpl->mpWinData->mpCompositionCharRects = nullptr; - mpWindowImpl->mpWinData->mnCompositionCharRects = 0; - mpWindowImpl->mpWinData->mpFocusRect = nullptr; - mpWindowImpl->mpWinData->mpTrackRect = nullptr; - mpWindowImpl->mpWinData->mnTrackFlags = 0; - mpWindowImpl->mpWinData->mnIsTopWindow = (sal_uInt16) ~0; // not initialized yet, 0/1 will indicate TopWindow (see IsTopWindow()) - mpWindowImpl->mpWinData->mbMouseOver = false; mpWindowImpl->mpWinData->mbEnableNativeWidget = !(pNoNWF && *pNoNWF); // true: try to draw this control with native theme API } _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
