summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorArnaud Versini <arnaud.versini@gmail.com>2016-05-05 18:14:30 +0200
committerNoel Grandin <noelgrandin@gmail.com>2016-05-10 06:46:39 +0000
commitb0ea829f686b0cb690e2c2828389263f36ee7c5d (patch)
tree995656125451e3a059677b4eb6d50c049e3c83b5 /vcl
parentc748debd8f1c6a8c0cd202013edebd74d608ada1 (diff)
vcl : Simplify vcl::Window initialisation and destruction
Change-Id: Ie3a8435d0adff795645618deb2c3c3da813e54f3 Reviewed-on: https://gerrit.libreoffice.org/24681 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/window.h3
-rw-r--r--vcl/source/window/window.cxx75
2 files changed, 38 insertions, 40 deletions
diff --git a/vcl/inc/window.h b/vcl/inc/window.h
index 302e9d03541b..ccdd8bf824b9 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 d1c1ffe0dc49..cd44a211f2b8 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
}