vcl:fixes towards unit test happiness

Change-Id: Ic0a3075c7616f604b93228dff149931cf25a5ed8
diff --git a/include/vcl/vclptr.hxx b/include/vcl/vclptr.hxx
index c32dbcc..37da714 100644
--- a/include/vcl/vclptr.hxx
+++ b/include/vcl/vclptr.hxx
@@ -136,6 +136,12 @@ public:
        m_rInnerRef.set(pBody);
    }

    inline VclPtr<reference_type>& SAL_CALL operator= (reference_type * pBody)
    {
        m_rInnerRef.set(pBody);
        return *this;
    }

    inline SAL_CALL operator reference_type * () const
    {
        return m_rInnerRef.get();
@@ -151,8 +157,9 @@ public:
        // hold it alive for the lifetime of this method
        ::rtl::Reference<reference_type> aTmp(m_rInnerRef);
        m_rInnerRef.clear(); // we should use some 'swap' method ideally ;-)
        if (aTmp.get())
        if (aTmp.get()) {
            aTmp->dispose();
        }
    }

}; // class VclPtr
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index 904e481..09589f5 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -420,7 +420,8 @@ private:
    // OutputDevice
    ::OutputDevice* mpOutputDevice;

    mutable int mnRefCnt;        // reference count
    mutable int mnRefCnt;         // reference count
    bool        mbInDtor = false; // true: We're still in Window-Dtor

#ifdef DBG_UTIL
    friend const char* ::ImplDbgCheckWindow( const void* pObj );
diff --git a/sfx2/source/dialog/dockwin.cxx b/sfx2/source/dialog/dockwin.cxx
index 06fe979..c3e0e3d 100644
--- a/sfx2/source/dialog/dockwin.cxx
+++ b/sfx2/source/dialog/dockwin.cxx
@@ -1280,7 +1280,7 @@ SfxDockingWindow::~SfxDockingWindow()
void SfxDockingWindow::dispose()
{
    ReleaseChildWindow_Impl();
    delete pImp;
    delete pImp; pImp = NULL;
    DockingWindow::dispose();
}

diff --git a/starmath/qa/cppunit/test_starmath.cxx b/starmath/qa/cppunit/test_starmath.cxx
index 054af67..d19c297 100644
--- a/starmath/qa/cppunit/test_starmath.cxx
+++ b/starmath/qa/cppunit/test_starmath.cxx
@@ -60,8 +60,8 @@ private:

    SfxBindings m_aBindings;
    SfxDispatcher *m_pDispatcher;
    SmCmdBoxWindow *m_pSmCmdBoxWindow;
    SmEditWindow *m_pEditWindow;
    VclPtr<SmCmdBoxWindow> m_pSmCmdBoxWindow;
    VclPtr<SmEditWindow> m_pEditWindow;
    SmDocShellRef m_xDocShRef;
    SmViewShell *m_pViewShell;
};
@@ -94,8 +94,8 @@ void Test::setUp()

void Test::tearDown()
{
    delete m_pEditWindow;
    delete m_pSmCmdBoxWindow;
    m_pEditWindow.disposeAndClear();
    m_pSmCmdBoxWindow.disposeAndClear();
    delete m_pDispatcher;
    m_xDocShRef->DoClose();
    m_xDocShRef.Clear();
diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx
index 90fe7a0..3a496f0 100644
--- a/starmath/source/edit.cxx
+++ b/starmath/source/edit.cxx
@@ -99,7 +99,7 @@ SmEditWindow::SmEditWindow( SmCmdBoxWindow &rMyCmdBoxWin ) :
    SetMapMode(MAP_PIXEL);

    // Even RTL languages don't use RTL for math
    rCmdBox.GetEditWindow().EnableRTL( false );
    EnableRTL( false );

    ApplyColorConfigValues( SM_MOD()->GetColorConfig() );

@@ -149,10 +149,14 @@ void SmEditWindow::dispose()
            pEditEngine->RemoveView( pEditView );
        }
        delete pEditView;
        pEditView = NULL;
    }
    delete pHScrollBar;
    pHScrollBar = NULL;
    delete pVScrollBar;
    pVScrollBar = NULL;
    delete pScrollBox;
    pScrollBox = NULL;
    vcl::Window::dispose();
}

diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx
index 3b04e76f..8d2cf2d 100644
--- a/vcl/inc/svdata.hxx
+++ b/vcl/inc/svdata.hxx
@@ -307,7 +307,7 @@ struct ImplSVData
    SalData*                mpSalData;
    SalInstance*            mpDefInst;                      // Default SalInstance
    Application*            mpApp;                          // pApp
    WorkWindow*             mpDefaultWin;                   // Default-Window
    VclPtr<WorkWindow>      mpDefaultWin;                   // Default-Window
    bool                    mbDeInit;                       // Is VCL deinitializing
    sal_uLong               mnThreadCount;                  // is VCL MultiThread enabled
    ImplConfigData*         mpFirstConfigData;              // pointer to the first config block
diff --git a/vcl/inc/window.h b/vcl/inc/window.h
index 78d3321..4eb3c6b 100644
--- a/vcl/inc/window.h
+++ b/vcl/inc/window.h
@@ -35,6 +35,7 @@
#include <vcl/timer.hxx>
#include <vcl/idle.hxx>
#include <vcl/vclevent.hxx>
#include <vcl/vclptr.hxx>
#include <vector>

struct SalPaintEvent;
@@ -214,7 +215,7 @@ public:
    SalObject*          mpSysObj;
    vcl::Window*        mpFrameWindow;
    vcl::Window*        mpOverlapWindow;
    vcl::Window*        mpBorderWindow;
    VclPtr<vcl::Window> mpBorderWindow;
    vcl::Window*        mpClientWindow;
    vcl::Window*        mpParent;
    vcl::Window*        mpRealParent;
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index a80d576..fce2961 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -423,11 +423,7 @@ void DeInitVCL()
        delete pSVData->maCtrlData.mpDisclosureMinus;
        pSVData->maCtrlData.mpDisclosureMinus = NULL;
    }
    if ( pSVData->mpDefaultWin )
    {
        delete pSVData->mpDefaultWin;
        pSVData->mpDefaultWin = NULL;
    }
    pSVData->mpDefaultWin.disposeAndClear();

    DBGGUI_DEINIT_SOLARMUTEXCHECK();

diff --git a/vcl/source/control/ctrl.cxx b/vcl/source/control/ctrl.cxx
index 155952d..137ca04 100644
--- a/vcl/source/control/ctrl.cxx
+++ b/vcl/source/control/ctrl.cxx
@@ -344,7 +344,11 @@ void Control::SetLayoutDataParent( const Control* pParent ) const

void Control::ImplClearLayoutData() const
{
    delete mpControlData->mpLayoutData, mpControlData->mpLayoutData = NULL;
    if (mpControlData)
    {
        delete mpControlData->mpLayoutData;
        mpControlData->mpLayoutData = NULL;
    }
}

void Control::ImplDrawFrame( OutputDevice* pDev, Rectangle& rRect )
diff --git a/vcl/source/control/scrbar.cxx b/vcl/source/control/scrbar.cxx
index b1411d7..ddefa9a 100644
--- a/vcl/source/control/scrbar.cxx
+++ b/vcl/source/control/scrbar.cxx
@@ -130,7 +130,7 @@ ScrollBar::~ScrollBar()

void ScrollBar::dispose()
{
    delete mpData;
    delete mpData; mpData = NULL;
    Control::dispose();
}

diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 7efe07e..3efccec 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -1768,7 +1768,7 @@ vcl::Window *VclBuilder::makeObject(vcl::Window *pParent, const OString &name, c
            ", created " << pWindow << " child of " <<
            pParent << "(" << pWindow->mpWindowImpl->mpParent << "/" <<
            pWindow->mpWindowImpl->mpRealParent << "/" <<
            pWindow->mpWindowImpl->mpBorderWindow << ") with helpid " <<
            pWindow->mpWindowImpl->mpBorderWindow.get() << ") with helpid " <<
            pWindow->GetHelpId().getStr());
        m_aChildren.push_back(WinAndId(id, pWindow, bVertical));
    }
diff --git a/vcl/source/window/floatwin.cxx b/vcl/source/window/floatwin.cxx
index 06596b3..ffafa47 100644
--- a/vcl/source/window/floatwin.cxx
+++ b/vcl/source/window/floatwin.cxx
@@ -605,8 +605,8 @@ void FloatingWindow::SetTitleType( sal_uInt16 nTitle )
            nTitleStyle = BORDERWINDOW_TITLE_POPUP;
        else // nTitle == FLOATWIN_TITLE_NONE
            nTitleStyle = BORDERWINDOW_TITLE_NONE;
        static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetTitleType( nTitleStyle, aOutSize );
        static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
        static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetTitleType( nTitleStyle, aOutSize );
        static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
    }
}

diff --git a/vcl/source/window/settings.cxx b/vcl/source/window/settings.cxx
index 77ddce2..a35e658 100644
--- a/vcl/source/window/settings.cxx
+++ b/vcl/source/window/settings.cxx
@@ -51,8 +51,8 @@ void Window::SetSettings( const AllSettings& rSettings, bool bChild )
    {
        mpWindowImpl->mpBorderWindow->SetSettings( rSettings, false );
        if ( (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) &&
             static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->mpMenuBarWindow )
            static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->mpMenuBarWindow->SetSettings( rSettings, true );
             static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->mpMenuBarWindow )
            static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->mpMenuBarWindow->SetSettings( rSettings, true );
    }

    AllSettings aOldSettings(*mxSettings);
@@ -86,8 +86,8 @@ void Window::UpdateSettings( const AllSettings& rSettings, bool bChild )
    {
        mpWindowImpl->mpBorderWindow->UpdateSettings( rSettings, false );
        if ( (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) &&
             static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->mpMenuBarWindow )
            static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->mpMenuBarWindow->UpdateSettings( rSettings, true );
             static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->mpMenuBarWindow )
            static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->mpMenuBarWindow->UpdateSettings( rSettings, true );
    }

    AllSettings aOldSettings(*mxSettings);
diff --git a/vcl/source/window/splitwin.cxx b/vcl/source/window/splitwin.cxx
index 9f63ae3..2b701e9 100644
--- a/vcl/source/window/splitwin.cxx
+++ b/vcl/source/window/splitwin.cxx
@@ -1353,7 +1353,8 @@ SplitWindow::~SplitWindow()
void SplitWindow::dispose()
{
    // delete Sets
    ImplDeleteSet( mpMainSet );
    if (mpMainSet)
        ImplDeleteSet( mpMainSet );
    mpMainSet = NULL; //NULL for base-class callbacks during dtoring
    DockingWindow::dispose();
}
diff --git a/vcl/source/window/syswin.cxx b/vcl/source/window/syswin.cxx
index 63bbd76..02f2417 100644
--- a/vcl/source/window/syswin.cxx
+++ b/vcl/source/window/syswin.cxx
@@ -314,7 +314,7 @@ void SystemWindow::ShowTitleButton( sal_uInt16 nButton, bool bVisible )
        {
            mbDockBtn = bVisible;
            if ( mpWindowImpl->mpBorderWindow )
                static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetDockButton( bVisible );
                static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetDockButton( bVisible );
        }
    }
    else if ( nButton == TITLE_BUTTON_HIDE )
@@ -323,13 +323,13 @@ void SystemWindow::ShowTitleButton( sal_uInt16 nButton, bool bVisible )
        {
            mbHideBtn = bVisible;
            if ( mpWindowImpl->mpBorderWindow )
                static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetHideButton( bVisible );
                static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetHideButton( bVisible );
        }
    }
    else if ( nButton == TITLE_BUTTON_MENU )
    {
        if ( mpWindowImpl->mpBorderWindow )
            static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetMenuButton( bVisible );
            static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetMenuButton( bVisible );
    }
    else
        return;
@@ -349,7 +349,7 @@ void SystemWindow::SetPin( bool bPin )
    {
        mbPinned = bPin;
        if ( mpWindowImpl->mpBorderWindow )
            static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetPin( bPin );
            static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetPin( bPin );
    }
}

@@ -364,7 +364,7 @@ void SystemWindow::RollUp()
            aSize.Width() = GetOutputSizePixel().Width();
        mbRollUp = true;
        if ( mpWindowImpl->mpBorderWindow )
            static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetRollUp( true, aSize );
            static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetRollUp( true, aSize );
        else
            SetOutputSizePixel( aSize );
        mbRollFunc = false;
@@ -377,7 +377,7 @@ void SystemWindow::RollDown()
    {
        mbRollUp = false;
        if ( mpWindowImpl->mpBorderWindow )
            static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetRollUp( false, maOrgSize );
            static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetRollUp( false, maOrgSize );
        else
            SetOutputSizePixel( maOrgSize );
    }
@@ -388,7 +388,7 @@ void SystemWindow::SetMinOutputSizePixel( const Size& rSize )
    maMinOutSize = rSize;
    if ( mpWindowImpl->mpBorderWindow )
    {
        static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetMinOutputSize( rSize.Width(), rSize.Height() );
        static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetMinOutputSize( rSize.Width(), rSize.Height() );
        if ( mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame )
            mpWindowImpl->mpBorderWindow->mpWindowImpl->mpFrame->SetMinClientSize( rSize.Width(), rSize.Height() );
    }
@@ -407,7 +407,7 @@ void SystemWindow::SetMaxOutputSizePixel( const Size& rSize )
    mpImplData->maMaxOutSize = aSize;
    if ( mpWindowImpl->mpBorderWindow )
    {
        static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetMaxOutputSize( aSize.Width(), aSize.Height() );
        static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetMaxOutputSize( aSize.Width(), aSize.Height() );
        if ( mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame )
            mpWindowImpl->mpBorderWindow->mpWindowImpl->mpFrame->SetMaxClientSize( aSize.Width(), aSize.Height() );
    }
@@ -913,11 +913,11 @@ void SystemWindow::SetMenuBar(MenuBar* pMenuBar, const css::uno::Reference<css::
            if ( pMenuBar )
            {
                DBG_ASSERT( !pMenuBar->pWindow, "SystemWindow::SetMenuBar() - MenuBars can only set in one SystemWindow at time" );
                static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetMenuBarWindow( pNewWindow = MenuBar::ImplCreate( mpWindowImpl->mpBorderWindow, pOldWindow, pMenuBar, rFrame));
                static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetMenuBarWindow( pNewWindow = MenuBar::ImplCreate( mpWindowImpl->mpBorderWindow, pOldWindow, pMenuBar, rFrame));
                CallEventListeners( VCLEVENT_WINDOW_MENUBARADDED, (void*) pMenuBar );
            }
            else
                static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetMenuBarWindow( NULL );
                static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetMenuBarWindow( NULL );
            ImplToBottomChild();
            if ( pOldMenuBar )
            {
@@ -960,9 +960,9 @@ void SystemWindow::SetMenuBarMode( sal_uInt16 nMode )
        if ( mpWindowImpl->mpBorderWindow && (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) )
        {
            if ( nMode == MENUBAR_MODE_HIDE )
                static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetMenuBarMode( true );
                static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetMenuBarMode( true );
            else
                static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetMenuBarMode( false );
                static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetMenuBarMode( false );
        }
    }
}
diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx
index f0da66c..f95c020 100644
--- a/vcl/source/window/toolbox.cxx
+++ b/vcl/source/window/toolbox.cxx
@@ -1576,7 +1576,7 @@ ToolBox::~ToolBox()
void ToolBox::dispose()
{
    // custom menu event still running?
    if( mpData->mnEventId )
    if( mpData && mpData->mnEventId )
        Application::RemoveUserEvent( mpData->mnEventId );

    // #103005# make sure our activate/deactivate balance is right
@@ -1587,9 +1587,12 @@ void ToolBox::dispose()
    // still connected
    if ( mpFloatWin )
        mpFloatWin->EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL );
    mpFloatWin = NULL;

    // delete private data
    delete mpData;
    if (mpData)
        delete mpData;
    mpData = NULL;

    // remove the lists when there are no more toolbox references to
    // the lists
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 60443ff..9aa378f 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -136,10 +136,7 @@ void Window::dispose()
    if (!mpWindowImpl)
        return;

    // TODO: turn this assert on once we have switched to using VclPtr everywhere
    //assert( !mpWindowImpl->mbInDispose && "vcl::Window - already in dispose()" );
    if (mpWindowImpl->mbInDispose)
        return;
    assert( !mpWindowImpl->mbInDispose && "vcl::Window - already in dispose()" );
    mpWindowImpl->mbInDispose = true;

    // remove Key and Mouse events issued by Application::PostKey/MouseEvent
@@ -549,9 +546,8 @@ void Window::dispose()
        delete mpWindowImpl->mpOverlapData;

    // remove BorderWindow or Frame window data
    if ( mpWindowImpl->mpBorderWindow )
        delete mpWindowImpl->mpBorderWindow;
    else if ( mpWindowImpl->mbFrame )
    mpWindowImpl->mpBorderWindow.disposeAndClear();
    if ( mpWindowImpl->mbFrame )
    {
        if ( pSVData->maWinData.mpFirstFrame == this )
            pSVData->maWinData.mpFirstFrame = mpWindowImpl->mpFrameData->mpNextFrame;
@@ -575,9 +571,10 @@ void Window::dispose()

Window::~Window()
{
    DBG_ASSERT( !mbInDtor, "~Window - already in DTOR!" );
    mbInDtor = true;
    vcl::LazyDeletor<vcl::Window>::Undelete( this );
    dispose ();
    DBG_ASSERT( !mpWindowImpl->mbInDtor, "~Window - already in DTOR!" );
    dispose();
}

} /* namespace vcl */
@@ -716,7 +713,6 @@ WindowImpl::WindowImpl( WindowType nType )
    mbCompoundControlHasFocus           = false;                     // true: Composite Control has focus somewhere
    mbPaintDisabled                     = false;                     // true: Paint should not be executed
    mbAllResize                         = false;                     // true: Also sent ResizeEvents with 0,0
    mbInDtor                            = false;                     // true: We're still in Window-Dtor
    mbInDispose                         = false;                     // true: We're still in Window::dispose()
    mbExtTextInput                      = false;                     // true: ExtTextInput-Mode is active
    mbInFocusHdl                        = false;                     // true: Within GetFocus-Handler
@@ -1201,6 +1197,7 @@ void Window::ImplInitWindowData( WindowType nType )
    mpOutputDevice = (OutputDevice*)this;

    mnRefCnt = 0;
    mbInDtor = false;                     // true: We're still in Window-Dtor

    mpWindowImpl = new WindowImpl( nType );

@@ -2108,7 +2105,7 @@ void Window::SetBorderStyle( WindowBorderStyle nBorderStyle )
        else
        {
            if ( mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW )
                static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetBorderStyle( nBorderStyle );
                static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetBorderStyle( nBorderStyle );
            else
                mpWindowImpl->mpBorderWindow->SetBorderStyle( nBorderStyle );
        }
@@ -2121,7 +2118,7 @@ WindowBorderStyle Window::GetBorderStyle() const
    if ( mpWindowImpl->mpBorderWindow )
    {
        if ( mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW )
            return static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->GetBorderStyle();
            return static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->GetBorderStyle();
        else
            return mpWindowImpl->mpBorderWindow->GetBorderStyle();
    }
@@ -2135,7 +2132,7 @@ long Window::CalcTitleWidth() const
    if ( mpWindowImpl->mpBorderWindow )
    {
        if ( mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW )
            return static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->CalcTitleWidth();
            return static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->CalcTitleWidth();
        else
            return mpWindowImpl->mpBorderWindow->CalcTitleWidth();
    }
@@ -2539,8 +2536,8 @@ void Window::Enable( bool bEnable, bool bChild )
    {
        mpWindowImpl->mpBorderWindow->Enable( bEnable, false );
        if ( (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) &&
             static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->mpMenuBarWindow )
            static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->mpMenuBarWindow->Enable( bEnable, true );
             static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->mpMenuBarWindow )
            static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->mpMenuBarWindow->Enable( bEnable, true );
    }

    // #i56102# restore app focus win in case the
@@ -2601,8 +2598,8 @@ void Window::EnableInput( bool bEnable, bool bChild )
    {
        mpWindowImpl->mpBorderWindow->EnableInput( bEnable, false );
        if ( (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) &&
             static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->mpMenuBarWindow )
            static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->mpMenuBarWindow->EnableInput( bEnable, true );
             static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->mpMenuBarWindow )
            static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->mpMenuBarWindow->EnableInput( bEnable, true );
    }

    if ( (! bEnable && mpWindowImpl->meAlwaysInputMode != AlwaysInputEnabled) ||