LCOV - code coverage report
Current view: top level - sfx2/source/dialog - dockwin.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 240 842 28.5 %
Date: 2015-06-13 12:38:46 Functions: 31 65 47.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include <svl/eitem.hxx>
      22             : #include <vcl/decoview.hxx>
      23             : 
      24             : #include <vcl/svapp.hxx>
      25             : #include <vcl/timer.hxx>
      26             : #include <vcl/idle.hxx>
      27             : #include <rtl/instance.hxx>
      28             : #include <toolkit/helper/vclunohelper.hxx>
      29             : #include <comphelper/processfactory.hxx>
      30             : 
      31             : #include <sfx2/dockwin.hxx>
      32             : #include <sfx2/bindings.hxx>
      33             : #include <sfx2/viewfrm.hxx>
      34             : #include <sfx2/dispatch.hxx>
      35             : #include "workwin.hxx"
      36             : #include "splitwin.hxx"
      37             : #include <sfx2/viewsh.hxx>
      38             : #include <sfx2/sfxhelp.hxx>
      39             : #include <sfx2/objsh.hxx>
      40             : #include <sfx2/msgpool.hxx>
      41             : 
      42             : #include <com/sun/star/frame/XController.hpp>
      43             : #include <com/sun/star/lang/XUnoTunnel.hpp>
      44             : #include <com/sun/star/lang/XSingleComponentFactory.hpp>
      45             : #include <com/sun/star/awt/XWindow.hpp>
      46             : #include <com/sun/star/uno/XComponentContext.hpp>
      47             : #include <com/sun/star/frame/ModuleManager.hpp>
      48             : #include <com/sun/star/container/XNameAccess.hpp>
      49             : #include <com/sun/star/ui/theWindowStateConfiguration.hpp>
      50             : #include <com/sun/star/ui/theWindowContentFactoryManager.hpp>
      51             : 
      52             : #define MAX_TOGGLEAREA_WIDTH        20
      53             : #define MAX_TOGGLEAREA_HEIGHT       20
      54             : 
      55             : using namespace ::com::sun::star;
      56             : 
      57             : // If you want to change the number you also have to:
      58             : // - Add new slot ids to sfxsids.hrc
      59             : // - Add new slots to frmslots.sdi
      60             : // - Add new slot definitions to sfx.sdi
      61             : static const int NUM_OF_DOCKINGWINDOWS = 10;
      62             : 
      63             : class SfxTitleDockingWindow : public SfxDockingWindow
      64             : {
      65             :     VclPtr<vcl::Window>   m_pWrappedWindow;
      66             : 
      67             : public:
      68             :                         SfxTitleDockingWindow(
      69             :                             SfxBindings* pBindings ,
      70             :                             SfxChildWindow* pChildWin ,
      71             :                             vcl::Window* pParent ,
      72             :                             WinBits nBits);
      73             :     virtual             ~SfxTitleDockingWindow();
      74             :     virtual void        dispose() SAL_OVERRIDE;
      75             : 
      76           0 :     vcl::Window*        GetWrappedWindow() const { return m_pWrappedWindow; }
      77             :     void                SetWrappedWindow(vcl::Window* const pWindow);
      78             : 
      79             :     virtual void        StateChanged( StateChangedType nType ) SAL_OVERRIDE;
      80             :     virtual bool        Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
      81             :     virtual void        Resize() SAL_OVERRIDE;
      82             :     virtual void        Resizing( Size& rSize ) SAL_OVERRIDE;
      83             :     virtual bool        Close() SAL_OVERRIDE;
      84             : };
      85             : 
      86             : namespace
      87             : {
      88           0 :     struct WindowState
      89             :     {
      90             :         OUString sTitle;
      91             :     };
      92             : }
      93             : 
      94           0 : static bool lcl_getWindowState( const uno::Reference< container::XNameAccess >& xWindowStateMgr, const OUString& rResourceURL, WindowState& rWindowState )
      95             : {
      96           0 :     bool bResult = false;
      97             : 
      98             :     try
      99             :     {
     100           0 :         uno::Any a;
     101           0 :         uno::Sequence< beans::PropertyValue > aWindowState;
     102           0 :         a = xWindowStateMgr->getByName( rResourceURL );
     103           0 :         if ( a >>= aWindowState )
     104             :         {
     105           0 :             for ( sal_Int32 n = 0; n < aWindowState.getLength(); n++ )
     106             :             {
     107           0 :                 if ( aWindowState[n].Name == "UIName" )
     108             :                 {
     109           0 :                     aWindowState[n].Value >>= rWindowState.sTitle;
     110             :                 }
     111             :             }
     112             :         }
     113             : 
     114           0 :         bResult = true;
     115             :     }
     116           0 :     catch ( container::NoSuchElementException& )
     117             :     {
     118           0 :         bResult = false;
     119             :     }
     120             : 
     121           0 :     return bResult;
     122             : }
     123             : 
     124           0 : SfxDockingWrapper::SfxDockingWrapper( vcl::Window* pParentWnd ,
     125             :                                       sal_uInt16 nId ,
     126             :                                       SfxBindings* pBindings ,
     127             :                                       SfxChildWinInfo* pInfo )
     128           0 :                     : SfxChildWindow( pParentWnd , nId )
     129             : {
     130           0 :     uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
     131           0 :     const OUString aDockWindowResourceURL( "private:resource/dockingwindow/" );
     132             : 
     133             :     VclPtr<SfxTitleDockingWindow> pTitleDockWindow = VclPtr<SfxTitleDockingWindow>::Create( pBindings, this, pParentWnd,
     134           0 :         WB_STDDOCKWIN | WB_CLIPCHILDREN | WB_SIZEABLE | WB_3DLOOK | WB_ROLLABLE);
     135           0 :     pWindow = pTitleDockWindow;
     136           0 :     eChildAlignment = SfxChildAlignment::NOALIGNMENT;
     137             : 
     138             :     // Use factory manager to retrieve XWindow factory. That can be used to instantiate
     139             :     // the real window factory.
     140           0 :     uno::Reference< lang::XSingleComponentFactory > xFactoryMgr = ui::theWindowContentFactoryManager::get(xContext);
     141             : 
     142           0 :     SfxDispatcher* pDispatcher = pBindings->GetDispatcher();
     143           0 :     uno::Reference< frame::XFrame > xFrame( pDispatcher->GetFrame()->GetFrame().GetFrameInterface(), uno::UNO_QUERY );
     144           0 :     uno::Sequence< uno::Any > aArgs(2);
     145           0 :     beans::PropertyValue      aPropValue;
     146           0 :     aPropValue.Name  = "Frame";
     147           0 :     aPropValue.Value = uno::makeAny( xFrame );
     148           0 :     aArgs[0] <<= aPropValue;
     149           0 :     aPropValue.Name  = "ResourceURL";
     150             : 
     151             :     // create a resource URL from the nId provided by the sfx2
     152           0 :     OUString aResourceURL( aDockWindowResourceURL );
     153           0 :     aResourceURL += OUString::number(nId);
     154           0 :     aPropValue.Value = uno::makeAny( aResourceURL );
     155           0 :     aArgs[1] <<= aPropValue;
     156             : 
     157           0 :     uno::Reference< awt::XWindow > xWindow;
     158             :     try
     159             :     {
     160           0 :         xWindow = uno::Reference< awt::XWindow>(
     161           0 :             xFactoryMgr->createInstanceWithArgumentsAndContext( aArgs, xContext ),
     162           0 :             uno::UNO_QUERY );
     163             : 
     164           0 :         static uno::WeakReference< frame::XModuleManager2 >  m_xModuleManager;
     165             : 
     166           0 :         uno::Reference< frame::XModuleManager2 > xModuleManager( m_xModuleManager );
     167           0 :         if ( !xModuleManager.is() )
     168             :         {
     169           0 :             xModuleManager = frame::ModuleManager::create(xContext);
     170           0 :             m_xModuleManager = xModuleManager;
     171             :         }
     172             : 
     173           0 :         static uno::WeakReference< container::XNameAccess > m_xWindowStateConfiguration;
     174             : 
     175           0 :         uno::Reference< container::XNameAccess > xWindowStateConfiguration( m_xWindowStateConfiguration );
     176           0 :         if ( !xWindowStateConfiguration.is() )
     177             :         {
     178           0 :             xWindowStateConfiguration = ui::theWindowStateConfiguration::get( xContext );
     179           0 :             m_xWindowStateConfiguration = xWindowStateConfiguration;
     180             :         }
     181             : 
     182           0 :         OUString sModuleIdentifier = xModuleManager->identify( xFrame );
     183             : 
     184             :         uno::Reference< container::XNameAccess > xModuleWindowState(
     185           0 :                                                     xWindowStateConfiguration->getByName( sModuleIdentifier ),
     186           0 :                                                     uno::UNO_QUERY );
     187           0 :         if ( xModuleWindowState.is() )
     188             :         {
     189           0 :             WindowState aDockWinState;
     190           0 :             if ( lcl_getWindowState( xModuleWindowState, aResourceURL, aDockWinState ))
     191           0 :                 pTitleDockWindow->SetText( aDockWinState.sTitle );
     192           0 :         }
     193             :     }
     194           0 :     catch ( beans::UnknownPropertyException& )
     195             :     {
     196             :     }
     197           0 :     catch ( uno::RuntimeException& )
     198             :     {
     199             :     }
     200           0 :     catch ( uno::Exception& )
     201             :     {
     202             :     }
     203             : 
     204           0 :     vcl::Window* pContentWindow = VCLUnoHelper::GetWindow(xWindow);
     205           0 :     if ( pContentWindow )
     206           0 :         pContentWindow->SetStyle( pContentWindow->GetStyle() | WB_DIALOGCONTROL | WB_CHILDDLGCTRL );
     207           0 :     pTitleDockWindow->SetWrappedWindow(pContentWindow);
     208             : 
     209           0 :     pWindow->SetOutputSizePixel( Size( 270, 240 ) );
     210             : 
     211           0 :     static_cast<SfxDockingWindow*>( pWindow.get() )->Initialize( pInfo );
     212           0 :     SetHideNotDelete( true );
     213           0 : }
     214             : 
     215           0 : SfxChildWindow* SfxDockingWrapper::CreateImpl(vcl::Window *pParent, sal_uInt16 nId,
     216             :                                               SfxBindings *pBindings, SfxChildWinInfo* pInfo)
     217             : {
     218           0 :     SfxChildWindow *pWin = new SfxDockingWrapper(pParent, nId, pBindings, pInfo);
     219           0 :     return pWin;
     220             : }
     221             : 
     222         208 : void SfxDockingWrapper::RegisterChildWindow (bool bVis, SfxModule *pMod, SfxChildWindowFlags nFlags)
     223             : {
     224             :     // pre-register a couple of docking windows
     225        2288 :     for (int i=0; i < NUM_OF_DOCKINGWINDOWS; i++ )
     226             :     {
     227        2080 :         sal_uInt16 nID = sal_uInt16(SID_DOCKWIN_START+i);
     228        2080 :         SfxChildWinFactory *pFact = new SfxChildWinFactory( SfxDockingWrapper::CreateImpl, nID, 0xffff );
     229        2080 :         pFact->aInfo.nFlags |= nFlags;
     230        2080 :         pFact->aInfo.bVisible = bVis;
     231        2080 :         SfxChildWindow::RegisterChildWindow(pMod, pFact);
     232             :     }
     233         208 : }
     234             : 
     235           0 : SfxChildWinInfo  SfxDockingWrapper::GetInfo() const
     236             : {
     237           0 :     SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();
     238           0 :     static_cast<SfxDockingWindow*>(GetWindow())->FillInfo( aInfo );
     239           0 :     return aInfo;
     240             : };
     241             : 
     242           0 : SfxTitleDockingWindow::SfxTitleDockingWindow(SfxBindings* pBind, SfxChildWindow* pChildWin,
     243             :                                              vcl::Window* pParent, WinBits nBits)
     244             :     : SfxDockingWindow(pBind, pChildWin, pParent, nBits)
     245           0 :     , m_pWrappedWindow(nullptr)
     246             : {
     247           0 : }
     248             : 
     249           0 : SfxTitleDockingWindow::~SfxTitleDockingWindow()
     250             : {
     251           0 :     disposeOnce();
     252           0 : }
     253             : 
     254           0 : void SfxTitleDockingWindow::dispose()
     255             : {
     256           0 :     m_pWrappedWindow.disposeAndClear();
     257           0 :     SfxDockingWindow::dispose();
     258           0 : }
     259             : 
     260           0 : void SfxTitleDockingWindow::SetWrappedWindow( vcl::Window* const pWindow )
     261             : {
     262           0 :     m_pWrappedWindow = pWindow;
     263           0 :     if (m_pWrappedWindow)
     264             :     {
     265           0 :         m_pWrappedWindow->SetParent(this);
     266           0 :         m_pWrappedWindow->SetSizePixel( GetOutputSizePixel() );
     267           0 :         m_pWrappedWindow->Show();
     268             :     }
     269           0 : }
     270             : 
     271           0 : bool SfxTitleDockingWindow::Notify( NotifyEvent& rNEvt )
     272             : {
     273           0 :     return SfxDockingWindow::Notify( rNEvt );
     274             : }
     275             : 
     276           0 : void SfxTitleDockingWindow::StateChanged( StateChangedType nType )
     277             : {
     278           0 :     if ( nType == StateChangedType::InitShow )
     279             :     {
     280           0 :         vcl::Window* pWindow = GetWrappedWindow();
     281           0 :         if ( pWindow )
     282             :         {
     283           0 :             pWindow->SetSizePixel( GetOutputSizePixel() );
     284           0 :             pWindow->Show();
     285             :         }
     286             :     }
     287             : 
     288           0 :     SfxDockingWindow::StateChanged(nType);
     289           0 : }
     290             : 
     291           0 : void SfxTitleDockingWindow::Resize()
     292             : {
     293           0 :     SfxDockingWindow::Resize();
     294           0 :     if (m_pWrappedWindow)
     295           0 :         m_pWrappedWindow->SetSizePixel( GetOutputSizePixel() );
     296           0 : }
     297             : 
     298           0 : void SfxTitleDockingWindow::Resizing( Size &rSize )
     299             : {
     300           0 :     SfxDockingWindow::Resizing( rSize );
     301           0 :     if (m_pWrappedWindow)
     302           0 :         m_pWrappedWindow->SetSizePixel( GetOutputSizePixel() );
     303           0 : }
     304             : 
     305           0 : bool SfxTitleDockingWindow::Close()
     306             : {
     307           0 :     return SfxDockingWindow::Close();
     308             : }
     309             : 
     310             : namespace
     311             : {
     312             :     struct ChildrenRegisteredMap : public rtl::Static< bool, ChildrenRegisteredMap > {};
     313             : }
     314             : 
     315           0 : static bool lcl_checkDockingWindowID( sal_uInt16 nID )
     316             : {
     317           0 :     if (nID < SID_DOCKWIN_START || nID >= sal_uInt16(SID_DOCKWIN_START+NUM_OF_DOCKINGWINDOWS))
     318           0 :         return false;
     319             :     else
     320           0 :         return true;
     321             : }
     322             : 
     323           0 : static SfxWorkWindow* lcl_getWorkWindowFromXFrame( const uno::Reference< frame::XFrame >& rFrame )
     324             : {
     325             :     // We need to find the corresponding SfxFrame of our XFrame
     326           0 :     SfxFrame* pFrame  = SfxFrame::GetFirst();
     327           0 :     SfxFrame* pXFrame = 0;
     328           0 :     while ( pFrame )
     329             :     {
     330           0 :         uno::Reference< frame::XFrame > xViewShellFrame( pFrame->GetFrameInterface() );
     331           0 :         if ( xViewShellFrame == rFrame )
     332             :         {
     333           0 :             pXFrame = pFrame;
     334           0 :             break;
     335             :         }
     336             :         else
     337           0 :             pFrame = SfxFrame::GetNext( *pFrame );
     338           0 :     }
     339             : 
     340             :     // If we have a SfxFrame we can retrieve the work window (Sfx layout manager for docking windows)
     341           0 :     if ( pXFrame )
     342           0 :         return pXFrame->GetWorkWindow_Impl();
     343             :     else
     344           0 :         return NULL;
     345             : }
     346             : 
     347             : /** Factory function used by the framework layout manager to "create" a docking window with a special name.
     348             :     The string rDockingWindowName MUST BE a valid ID! The ID is pre-defined by a certain slot range located
     349             :     in sfxsids.hrc (currently SID_DOCKWIN_START = 9800).
     350             : */
     351           0 : void SAL_CALL SfxDockingWindowFactory( const uno::Reference< frame::XFrame >& rFrame, const OUString& rDockingWindowName )
     352             : {
     353           0 :     SolarMutexGuard aGuard;
     354           0 :     sal_uInt16 nID = sal_uInt16(rDockingWindowName.toInt32());
     355             : 
     356             :     // Check the range of the provided ID otherwise nothing will happen
     357           0 :     if ( lcl_checkDockingWindowID( nID ))
     358             :     {
     359           0 :         SfxWorkWindow* pWorkWindow = lcl_getWorkWindowFromXFrame( rFrame );
     360           0 :         if ( pWorkWindow )
     361             :         {
     362           0 :             SfxChildWindow* pChildWindow = pWorkWindow->GetChildWindow_Impl(nID);
     363           0 :             if ( !pChildWindow )
     364             :             {
     365             :                 // Register window at the workwindow child window list
     366           0 :                 pWorkWindow->SetChildWindow_Impl( nID, true, false );
     367             :             }
     368             :         }
     369           0 :     }
     370           0 : }
     371             : 
     372             : /** Function used by the framework layout manager to determine the visibility state of a docking window with
     373             :     a special name. The string rDockingWindowName MUST BE a valid ID! The ID is pre-defined by a certain slot
     374             :     range located in sfxsids.hrc (currently SID_DOCKWIN_START = 9800).
     375             : */
     376           0 : bool SAL_CALL IsDockingWindowVisible( const uno::Reference< frame::XFrame >& rFrame, const OUString& rDockingWindowName )
     377             : {
     378           0 :     SolarMutexGuard aGuard;
     379             : 
     380           0 :     sal_uInt16 nID = sal_uInt16(rDockingWindowName.toInt32());
     381             : 
     382             :     // Check the range of the provided ID otherwise nothing will happen
     383           0 :     if ( lcl_checkDockingWindowID( nID ))
     384             :     {
     385           0 :         SfxWorkWindow* pWorkWindow = lcl_getWorkWindowFromXFrame( rFrame );
     386           0 :         if ( pWorkWindow )
     387             :         {
     388           0 :             SfxChildWindow* pChildWindow = pWorkWindow->GetChildWindow_Impl(nID);
     389           0 :             if ( pChildWindow )
     390           0 :                 return true;
     391             :         }
     392             :     }
     393             : 
     394           0 :     return false;
     395             : }
     396             : 
     397        6532 : class SfxDockingWindow_Impl
     398             : {
     399             : friend class SfxDockingWindow;
     400             : 
     401             :     SfxChildAlignment   eLastAlignment;
     402             :     SfxChildAlignment   eDockAlignment;
     403             :     bool                bConstructed;
     404             :     Size                aMinSize;
     405             :     VclPtr<SfxSplitWindow>  pSplitWin;
     406             :     bool                bSplitable;
     407             :     Idle                aMoveIdle;
     408             : 
     409             :     // The following members are only valid in the time from startDocking to
     410             :     // EndDocking:
     411             :     bool                bEndDocked;
     412             :     Size                aSplitSize;
     413             :     long                nHorizontalSize;
     414             :     long                nVerticalSize;
     415             :     sal_uInt16              nLine;
     416             :     sal_uInt16              nPos;
     417             :     sal_uInt16              nDockLine;
     418             :     sal_uInt16              nDockPos;
     419             :     bool                bNewLine;
     420             :     bool                bDockingPrevented;
     421             :     OString aWinState;
     422             : 
     423        6660 :     SfxChildAlignment   GetLastAlignment() const
     424        6660 :                         { return eLastAlignment; }
     425        9681 :     void                SetLastAlignment(SfxChildAlignment eAlign)
     426        9681 :                         { eLastAlignment = eAlign; }
     427        5253 :     SfxChildAlignment   GetDockAlignment() const
     428        5253 :                         { return eDockAlignment; }
     429        3264 :     void                SetDockAlignment(SfxChildAlignment eAlign)
     430        3264 :                         { eDockAlignment = eAlign; }
     431             : };
     432             : 
     433             : /*  [Description]
     434             : 
     435             :     This virtual method of the class FloatingWindow keeps track of changes in
     436             :     FloatingSize. If this method is overridden by a derived class,
     437             :     then the SfxFloatingWindow: Resize() must also be called.
     438             : */
     439        8666 : void SfxDockingWindow::Resize()
     440             : {
     441        8666 :     DockingWindow::Resize();
     442        8666 :     Invalidate();
     443        8666 :     if ( pImp && pImp->bConstructed && pMgr )
     444             :     {
     445        5253 :         if ( IsFloatingMode() )
     446             :         {
     447             :             // start timer for saving window status information
     448           0 :             pImp->aMoveIdle.Start();
     449             :         }
     450             :         else
     451             :         {
     452        5253 :             Size aSize( GetSizePixel() );
     453        5253 :             switch ( pImp->GetDockAlignment() )
     454             :             {
     455             :                 case SfxChildAlignment::LEFT:
     456             :                 case SfxChildAlignment::FIRSTLEFT:
     457             :                 case SfxChildAlignment::LASTLEFT:
     458             :                 case SfxChildAlignment::RIGHT:
     459             :                 case SfxChildAlignment::FIRSTRIGHT:
     460             :                 case SfxChildAlignment::LASTRIGHT:
     461        5253 :                     pImp->nHorizontalSize = aSize.Width();
     462        5253 :                     pImp->aSplitSize = aSize;
     463        5253 :                     break;
     464             :                 case SfxChildAlignment::TOP:
     465             :                 case SfxChildAlignment::LOWESTTOP:
     466             :                 case SfxChildAlignment::HIGHESTTOP:
     467             :                 case SfxChildAlignment::BOTTOM:
     468             :                 case SfxChildAlignment::HIGHESTBOTTOM:
     469             :                 case SfxChildAlignment::LOWESTBOTTOM:
     470           0 :                     pImp->nVerticalSize = aSize.Height();
     471           0 :                     pImp->aSplitSize = aSize;
     472           0 :                     break;
     473             :                 default:
     474           0 :                     break;
     475             :             }
     476             :         }
     477             :     }
     478        8666 : }
     479             : 
     480             : /*  [Description]
     481             : 
     482             :     This virtual method of the class DockingWindow makes it possible to
     483             :     intervene in the switching of the floating mode.
     484             :     If this method is overridden by a derived class,
     485             :     then the SfxDockingWindow::PrepareToggleFloatingMode() must be called
     486             :     afterwards, if not FALSE is returned.
     487             : */
     488           0 : bool SfxDockingWindow::PrepareToggleFloatingMode()
     489             : {
     490           0 :     if (!pImp || !pImp->bConstructed)
     491           0 :         return true;
     492             : 
     493           0 :     if ( (Application::IsInModalMode() && IsFloatingMode()) || !pMgr )
     494           0 :         return false;
     495             : 
     496           0 :     if ( pImp->bDockingPrevented )
     497           0 :         return false;
     498             : 
     499           0 :     if (!IsFloatingMode())
     500             :     {
     501             :         // Test, if FloatingMode is permitted.
     502           0 :         if ( CheckAlignment(GetAlignment(),SfxChildAlignment::NOALIGNMENT) != SfxChildAlignment::NOALIGNMENT )
     503           0 :             return false;
     504             : 
     505           0 :         if ( pImp->pSplitWin )
     506             :         {
     507             :             // The DockingWindow is inside a SplitWindow and will be teared of.
     508           0 :             pImp->pSplitWin->RemoveWindow(this/*, sal_False*/);
     509           0 :             pImp->pSplitWin = 0;
     510             :         }
     511             :     }
     512           0 :     else if ( pMgr )
     513             :     {
     514           0 :         pImp->aWinState = GetFloatingWindow()->GetWindowState();
     515             : 
     516             :         // Test if it is allowed to dock,
     517           0 :         if (CheckAlignment(GetAlignment(),pImp->GetLastAlignment()) == SfxChildAlignment::NOALIGNMENT)
     518           0 :             return false;
     519             : 
     520             :         // Test, if the Workwindow allows for docking at the moment.
     521           0 :         SfxWorkWindow *pWorkWin = pBindings->GetWorkWindow_Impl();
     522           0 :         if ( !pWorkWin->IsDockingAllowed() || !pWorkWin->IsInternalDockingAllowed() )
     523           0 :             return false;
     524             :     }
     525             : 
     526           0 :     return true;
     527             : }
     528             : 
     529             : /*  [Description]
     530             : 
     531             :     This virtual method of the DockingWindow class sets the internal data of
     532             :     the SfxDockingWindow and ensures the correct alignment on the parent window.
     533             :     Through PrepareToggleFloatMode and Initialize it is ensured that
     534             :     pImp-> GetLastAlignment() always delivers an allowed alignment. If this
     535             :     method is overridden by a derived class, then first the
     536             :     SfxDockingWindow::ToggleFloatingMode() must be called.
     537             : */
     538           0 : void SfxDockingWindow::ToggleFloatingMode()
     539             : {
     540           0 :     if ( !pImp || !pImp->bConstructed || !pMgr )
     541           0 :         return;                                 // No Handler call
     542             : 
     543             :     // Remember old alignment and then switch.
     544             :     // SV has already switched, but the alignment SfxDockingWindow is still
     545             :     // the old one. What I was before?
     546           0 :     SfxChildAlignment eLastAlign = GetAlignment();
     547             : 
     548           0 :     SfxWorkWindow *pWorkWin = pBindings->GetWorkWindow_Impl();
     549           0 :     SfxChildIdentifier eIdent = SfxChildIdentifier::DOCKINGWINDOW;
     550           0 :     if ( pImp->bSplitable )
     551           0 :         eIdent = SfxChildIdentifier::SPLITWINDOW;
     552             : 
     553           0 :     if (IsFloatingMode())
     554             :     {
     555           0 :         SetAlignment(SfxChildAlignment::NOALIGNMENT);
     556           0 :         if ( !pImp->aWinState.isEmpty() )
     557           0 :             GetFloatingWindow()->SetWindowState( pImp->aWinState );
     558             :         else
     559           0 :             GetFloatingWindow()->SetOutputSizePixel( GetFloatingSize() );
     560             :     }
     561             :     else
     562             :     {
     563           0 :         if (pImp->GetDockAlignment() == eLastAlign)
     564             :         {
     565             :             // If ToggleFloatingMode was called, but the DockAlignment still
     566             :             // is unchanged, then this means that it must have been a toggling
     567             :             // through DClick, so use last alignment
     568           0 :             SetAlignment (pImp->GetLastAlignment());
     569           0 :             if ( !pImp->bSplitable )
     570           0 :                 SetSizePixel( CalcDockingSize(GetAlignment()) );
     571             :         }
     572             :         else
     573             :         {
     574             : 
     575             :             // Toggling was triggered by dragging
     576           0 :             pImp->nLine = pImp->nDockLine;
     577           0 :             pImp->nPos = pImp->nDockPos;
     578           0 :             SetAlignment (pImp->GetDockAlignment());
     579             :         }
     580             : 
     581           0 :         if ( pImp->bSplitable )
     582             :         {
     583             :             // The DockingWindow is now in a SplitWindow
     584           0 :             pImp->pSplitWin = pWorkWin->GetSplitWindow_Impl(GetAlignment());
     585             : 
     586             :             // The LastAlignment is still the last docked
     587           0 :             SfxSplitWindow *pSplit = pWorkWin->GetSplitWindow_Impl(pImp->GetLastAlignment());
     588             : 
     589             :             DBG_ASSERT( pSplit, "LastAlignment is not correct!" );
     590           0 :             if ( pSplit && pSplit != pImp->pSplitWin )
     591           0 :                 pSplit->ReleaseWindow_Impl(this);
     592           0 :             if ( pImp->GetDockAlignment() == eLastAlign )
     593           0 :                 pImp->pSplitWin->InsertWindow( this, pImp->aSplitSize );
     594             :             else
     595           0 :                 pImp->pSplitWin->InsertWindow( this, pImp->aSplitSize, pImp->nLine, pImp->nPos, pImp->bNewLine );
     596           0 :             if ( !pImp->pSplitWin->IsFadeIn() )
     597           0 :                 pImp->pSplitWin->FadeIn();
     598             :         }
     599             :     }
     600             : 
     601             :     // Keep the old alignment for the next toggle; set it only now due to the
     602             :     // unregister SplitWindow!
     603           0 :     pImp->SetLastAlignment(eLastAlign);
     604             : 
     605             :     // Reset DockAlignment, if EndDocking is still called
     606           0 :     pImp->SetDockAlignment(GetAlignment());
     607             : 
     608             :     // Dock or undock SfxChildWindow correctly.
     609           0 :     pWorkWin->ConfigChild_Impl( eIdent, SfxDockingConfig::TOGGLEFLOATMODE, pMgr->GetType() );
     610             : }
     611             : 
     612             : /*  [Description]
     613             : 
     614             :     This virtual method of the DockingWindow class takes the inner and outer
     615             :     docking rectangle from the parent window. If this method is overridden by
     616             :     a derived class, then SfxDockingWindow:StartDocking() has to be called at
     617             :     the end.
     618             : */
     619           0 : void SfxDockingWindow::StartDocking()
     620             : {
     621           0 :     if ( !pImp || !pImp->bConstructed || !pMgr )
     622           0 :         return;
     623           0 :     SfxChildIdentifier eIdent = SfxChildIdentifier::DOCKINGWINDOW;
     624           0 :     if ( pImp->bSplitable )
     625           0 :         eIdent = SfxChildIdentifier::SPLITWINDOW;
     626           0 :     SfxWorkWindow *pWorkWin = pBindings->GetWorkWindow_Impl();
     627           0 :     pWorkWin->ConfigChild_Impl( eIdent, SfxDockingConfig::SETDOCKINGRECTS, pMgr->GetType() );
     628           0 :     pImp->SetDockAlignment(GetAlignment());
     629             : 
     630           0 :     if ( pImp->pSplitWin )
     631             :     {
     632             :         // Get the current docking data
     633           0 :         pImp->pSplitWin->GetWindowPos(this, pImp->nLine, pImp->nPos);
     634           0 :         pImp->nDockLine = pImp->nLine;
     635           0 :         pImp->nDockPos = pImp->nPos;
     636           0 :         pImp->bNewLine = false;
     637             :     }
     638             : }
     639             : 
     640             : /*  [Description]
     641             : 
     642             :     This virtual method of the DockingWindow class calculates the current
     643             :     tracking rectangle. For this purpose the method CalcAlignment(RPOs, rRect)
     644             :     is used, the behavior can be influenced by the derived classes (see below).
     645             :     This method should if possible not be overwritten.
     646             : */
     647           0 : bool SfxDockingWindow::Docking( const Point& rPos, Rectangle& rRect )
     648             : {
     649           0 :     if ( Application::IsInModalMode() )
     650           0 :         return true;
     651             : 
     652           0 :     if ( !pImp || !pImp->bConstructed || !pMgr )
     653             :     {
     654           0 :         rRect.SetSize( Size() );
     655           0 :         return IsFloatingMode();
     656             :     }
     657             : 
     658           0 :     SfxWorkWindow *pWorkWin = pBindings->GetWorkWindow_Impl();
     659           0 :     if ( pImp->bDockingPrevented || !pWorkWin->IsInternalDockingAllowed() )
     660           0 :         return false;
     661             : 
     662           0 :     bool bFloatMode = false;
     663             : 
     664           0 :     if ( GetOuterRect().IsInside( rPos ) && !IsDockingPrevented() )
     665             :     {
     666             :         // Mouse within OuterRect: calculate Alignment and Rectangle
     667           0 :         SfxChildAlignment eAlign = CalcAlignment(rPos, rRect);
     668           0 :         if (eAlign == SfxChildAlignment::NOALIGNMENT)
     669           0 :             bFloatMode = true;
     670           0 :         pImp->SetDockAlignment(eAlign);
     671             :     }
     672             :     else
     673             :     {
     674             :         // Mouse is not within OuterRect: must be FloatingWindow
     675             :         // Is this allowed?
     676           0 :         if (CheckAlignment(pImp->GetDockAlignment(),SfxChildAlignment::NOALIGNMENT) != SfxChildAlignment::NOALIGNMENT)
     677           0 :             return false;
     678           0 :         bFloatMode = true;
     679           0 :         if ( SfxChildAlignment::NOALIGNMENT != pImp->GetDockAlignment() )
     680             :         {
     681             :             // Due to a bug the rRect may only be changed when the
     682             :             // alignment is changed!
     683           0 :             pImp->SetDockAlignment(SfxChildAlignment::NOALIGNMENT);
     684           0 :             rRect.SetSize(CalcDockingSize(SfxChildAlignment::NOALIGNMENT));
     685             :         }
     686             :     }
     687             : 
     688           0 :     if ( !pImp->bSplitable )
     689             :     {
     690             :         // For individually docked window the position is set through the
     691             :         // alignment and the docking rectangle.
     692           0 :         Size aSize = rRect.GetSize();
     693           0 :         Point aPos;
     694             : 
     695           0 :         switch ( pImp->GetDockAlignment() )
     696             :         {
     697             :             case SfxChildAlignment::LEFT:
     698             :             case SfxChildAlignment::FIRSTLEFT:
     699             :             case SfxChildAlignment::LASTLEFT:
     700           0 :                 aPos = aInnerRect.TopLeft();
     701           0 :                 if ( pImp->GetDockAlignment() == GetAlignment() )
     702           0 :                     aPos.X() -= aSize.Width();
     703           0 :                 break;
     704             : 
     705             :             case SfxChildAlignment::TOP:
     706             :             case SfxChildAlignment::LOWESTTOP:
     707             :             case SfxChildAlignment::HIGHESTTOP:
     708           0 :                 aPos = Point(aOuterRect.Left(), aInnerRect.Top());
     709           0 :                 if ( pImp->GetDockAlignment() == GetAlignment() )
     710           0 :                     aPos.Y() -= aSize.Height();
     711           0 :                 break;
     712             : 
     713             :             case SfxChildAlignment::RIGHT:
     714             :             case SfxChildAlignment::FIRSTRIGHT:
     715             :             case SfxChildAlignment::LASTRIGHT:
     716           0 :                 aPos = Point(aInnerRect.Right() - rRect.GetSize().Width(),
     717           0 :                             aInnerRect.Top());
     718           0 :                 if ( pImp->GetDockAlignment() == GetAlignment() )
     719           0 :                     aPos.X() += aSize.Width();
     720           0 :                 break;
     721             : 
     722             :             case SfxChildAlignment::BOTTOM:
     723             :             case SfxChildAlignment::HIGHESTBOTTOM:
     724             :             case SfxChildAlignment::LOWESTBOTTOM:
     725           0 :                 aPos = Point(aOuterRect.Left(),
     726           0 :                         aInnerRect.Bottom() - rRect.GetSize().Height());
     727           0 :                 if ( pImp->GetDockAlignment() == GetAlignment() )
     728           0 :                     aPos.Y() += aSize.Height();
     729           0 :                 break;
     730             :                      default:
     731           0 :                          break;
     732             :         }
     733             : 
     734           0 :         rRect.SetPos(aPos);
     735             :     }
     736             : 
     737           0 :     return bFloatMode;
     738             : }
     739             : 
     740             : /** Virtual method of the DockingWindow class ensures the correct alignment on
     741             :     the parent window. If this method is overridden by a derived class, then
     742             :     SfxDockingWindow::EndDocking() must be called first.
     743             : */
     744           0 : void SfxDockingWindow::EndDocking( const Rectangle& rRect, bool bFloatMode )
     745             : {
     746           0 :     if ( !pImp || !pImp->bConstructed || IsDockingCanceled() || !pMgr )
     747           0 :         return;
     748             : 
     749           0 :     SfxWorkWindow *pWorkWin = pBindings->GetWorkWindow_Impl();
     750           0 :     bool bReArrange = false;
     751           0 :     if ( pImp->bSplitable )
     752             :     {
     753             :         // If the alignment changes and the window is in a docked state in a
     754             :         // SplitWindow, then it must be re-registered. If it is docked again,
     755             :         // PrepareToggleFloatingMode() and ToggleFloatingMode() preform the
     756             :         // re-registered
     757           0 :         if ( !bFloatMode )
     758           0 :             bReArrange = true;
     759             :     }
     760             : 
     761           0 :     if ( bReArrange )
     762             :     {
     763           0 :         if ( GetAlignment() != pImp->GetDockAlignment() )
     764             :         {
     765             :             // before Show() is called must the reassignment have been made,
     766             :             // therefore the base class can not be called
     767           0 :             if ( IsFloatingMode() || !pImp->bSplitable )
     768           0 :                 Show( false, ShowFlags::NoFocusChange );
     769             : 
     770             :             // Set the size for toggling.
     771           0 :             pImp->aSplitSize = rRect.GetSize();
     772           0 :             if ( IsFloatingMode() )
     773             :             {
     774           0 :                 SetFloatingMode( bFloatMode );
     775           0 :                 if ( IsFloatingMode() || !pImp->bSplitable )
     776           0 :                     Show( true, ShowFlags::NoFocusChange );
     777             :             }
     778             :             else
     779             :             {
     780           0 :                 pImp->pSplitWin->RemoveWindow(this,false);
     781           0 :                 pImp->nLine = pImp->nDockLine;
     782           0 :                 pImp->nPos = pImp->nDockPos;
     783           0 :                 pImp->pSplitWin->ReleaseWindow_Impl(this);
     784           0 :                 pImp->pSplitWin = pWorkWin->GetSplitWindow_Impl(pImp->GetDockAlignment());
     785           0 :                 pImp->pSplitWin->InsertWindow( this, pImp->aSplitSize, pImp->nDockLine, pImp->nDockPos, pImp->bNewLine );
     786           0 :                 if ( !pImp->pSplitWin->IsFadeIn() )
     787           0 :                     pImp->pSplitWin->FadeIn();
     788             :             }
     789             :         }
     790           0 :         else if ( pImp->nLine != pImp->nDockLine || pImp->nPos != pImp->nDockPos || pImp->bNewLine )
     791             :         {
     792             :             // Moved within Splitwindows
     793           0 :             if ( pImp->nLine != pImp->nDockLine )
     794           0 :                 pImp->aSplitSize = rRect.GetSize();
     795           0 :             pImp->pSplitWin->MoveWindow( this, pImp->aSplitSize, pImp->nDockLine, pImp->nDockPos, pImp->bNewLine );
     796             :         }
     797             :     }
     798             :     else
     799             :     {
     800           0 :         pImp->bEndDocked = true;
     801           0 :         DockingWindow::EndDocking(rRect, bFloatMode);
     802           0 :         pImp->bEndDocked = false;
     803             :     }
     804             : 
     805           0 :     SetAlignment( IsFloatingMode() ? SfxChildAlignment::NOALIGNMENT : pImp->GetDockAlignment() );
     806             : }
     807             : 
     808             : /*  [Description]
     809             : 
     810             :     Virtual method of the DockingWindow class. Here, the interactive resize in
     811             :     FloatingMode can be influenced, for example by only allowing for discrete
     812             :     values for width and / or height. The base implementation prevents that the
     813             :     output size is smaller than one set with SetMinOutputSizePixel().
     814             : */
     815           0 : void SfxDockingWindow::Resizing( Size& /*rSize*/ )
     816             : {
     817             : 
     818           0 : }
     819             : 
     820             : /*  [Description]
     821             : 
     822             :     Constructor for the SfxDockingWindow class. A SfxChildWindow will be
     823             :     required because the docking is implemented in Sfx through SfxChildWindows.
     824             : */
     825        3251 : SfxDockingWindow::SfxDockingWindow( SfxBindings *pBindinx, SfxChildWindow *pCW,
     826             :     vcl::Window* pParent, WinBits nWinBits) :
     827             :     DockingWindow (pParent, nWinBits),
     828             :     pBindings(pBindinx),
     829             :     pMgr(pCW),
     830        3251 :     pImp(NULL)
     831             : {
     832        3251 :     if ( !GetHelpId().isEmpty() )
     833             :     {
     834           0 :         SetUniqueId( GetHelpId() );
     835           0 :         SetHelpId("");
     836             :     }
     837             :     else
     838             :     {
     839        3251 :         SfxViewFrame* pViewFrame = pBindings->GetDispatcher()->GetFrame();
     840        3251 :         SfxSlotPool* pSlotPool = pViewFrame->GetObjectShell()->GetModule()->GetSlotPool();
     841        3251 :         const SfxSlot* pSlot = pCW ? pSlotPool->GetSlot( pCW->GetType() ) : NULL;
     842        3251 :         if ( pSlot )
     843             :         {
     844        3247 :             OString aCmd("SFXDOCKINGWINDOW_");
     845        3247 :             aCmd += pSlot->GetUnoName();
     846        3247 :             SetUniqueId( aCmd );
     847             :         }
     848             :     }
     849             : 
     850        3251 :     pImp = new SfxDockingWindow_Impl;
     851        3251 :     pImp->bConstructed = false;
     852        3251 :     pImp->pSplitWin = 0;
     853        3251 :     pImp->bEndDocked = false;
     854        3251 :     pImp->bDockingPrevented = false;
     855             : 
     856        3251 :     pImp->bSplitable = true;
     857             : 
     858             :     // Initially set to default, the alignment is set in the subclass
     859        3251 :     pImp->nLine = pImp->nDockLine = 0;
     860        3251 :     pImp->nPos  = pImp->nDockPos = 0;
     861        3251 :     pImp->bNewLine = false;
     862        3251 :     pImp->SetLastAlignment(SfxChildAlignment::NOALIGNMENT);
     863        3251 :     pImp->aMoveIdle.SetPriority(SchedulerPriority::RESIZE);
     864        3251 :     pImp->aMoveIdle.SetIdleHdl(LINK(this,SfxDockingWindow,TimerHdl));
     865        3251 : }
     866             : 
     867             : /** Constructor for the SfxDockingWindow class. A SfxChildWindow will be
     868             :     required because the docking is implemented in Sfx through SfxChildWindows.
     869             : */
     870           0 : SfxDockingWindow::SfxDockingWindow( SfxBindings *pBindinx, SfxChildWindow *pCW,
     871             :     vcl::Window* pParent, const ResId& rResId) :
     872             :     DockingWindow(pParent, rResId),
     873             :     pBindings(pBindinx),
     874             :     pMgr(pCW),
     875           0 :     pImp(NULL)
     876             : {
     877           0 :     if ( !GetHelpId().isEmpty() )
     878             :     {
     879           0 :         SetUniqueId( GetHelpId() );
     880           0 :         SetHelpId("");
     881             :     }
     882             :     else
     883             :     {
     884           0 :         SfxViewFrame* pViewFrame = pBindings->GetDispatcher()->GetFrame();
     885           0 :         SfxSlotPool* pSlotPool = pViewFrame->GetObjectShell()->GetModule()->GetSlotPool();
     886           0 :         const SfxSlot* pSlot = pCW ? pSlotPool->GetSlot( pCW->GetType() ) : NULL;
     887           0 :         if ( pSlot )
     888             :         {
     889           0 :             OString aCmd("SFXDOCKINGWINDOW_");
     890           0 :             aCmd += pSlot->GetUnoName();
     891           0 :             SetUniqueId( aCmd );
     892             :         }
     893             :     }
     894             : 
     895           0 :     pImp = new SfxDockingWindow_Impl;
     896           0 :     pImp->bConstructed = false;
     897           0 :     pImp->pSplitWin = 0;
     898           0 :     pImp->bEndDocked = false;
     899           0 :     pImp->bDockingPrevented = false;
     900             : 
     901           0 :     pImp->bSplitable = true;
     902             : 
     903             :     // Initially set to default, the alignment is set in the subclass
     904           0 :     pImp->nLine = pImp->nDockLine = 0;
     905           0 :     pImp->nPos  = pImp->nDockPos = 0;
     906           0 :     pImp->bNewLine = false;
     907           0 :     pImp->SetLastAlignment(SfxChildAlignment::NOALIGNMENT);
     908           0 :     pImp->aMoveIdle.SetPriority(SchedulerPriority::RESIZE);
     909           0 :     pImp->aMoveIdle.SetIdleHdl(LINK(this,SfxDockingWindow,TimerHdl));
     910           0 : }
     911             : 
     912             : /** Constructor for the SfxDockingWindow class. A SfxChildWindow will be
     913             :     required because the docking is implemented in Sfx through SfxChildWindows.
     914             : */
     915          17 : SfxDockingWindow::SfxDockingWindow( SfxBindings *pBindinx, SfxChildWindow *pCW,
     916             :     vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription)
     917             :     : DockingWindow(pParent, rID, rUIXMLDescription)
     918             :     , pBindings(pBindinx)
     919             :     , pMgr(pCW)
     920          17 :     , pImp(NULL)
     921             : {
     922          17 :     if ( !GetHelpId().isEmpty() )
     923             :     {
     924          17 :         SetUniqueId( GetHelpId() );
     925          17 :         SetHelpId("");
     926             :     }
     927             :     else
     928             :     {
     929           0 :         SfxViewFrame* pViewFrame = pBindings->GetDispatcher()->GetFrame();
     930           0 :         SfxSlotPool* pSlotPool = pViewFrame->GetObjectShell()->GetModule()->GetSlotPool();
     931           0 :         const SfxSlot* pSlot = pCW ? pSlotPool->GetSlot( pCW->GetType() ) : NULL;
     932           0 :         if ( pSlot )
     933             :         {
     934           0 :             OString aCmd("SFXDOCKINGWINDOW_");
     935           0 :             aCmd += pSlot->GetUnoName();
     936           0 :             SetUniqueId( aCmd );
     937             :         }
     938             :     }
     939             : 
     940          17 :     pImp = new SfxDockingWindow_Impl;
     941          17 :     pImp->bConstructed = false;
     942          17 :     pImp->pSplitWin = 0;
     943          17 :     pImp->bEndDocked = false;
     944          17 :     pImp->bDockingPrevented = false;
     945             : 
     946          17 :     pImp->bSplitable = true;
     947             : 
     948             :     // Initially set to default, the alignment is set in the subclass
     949          17 :     pImp->nLine = pImp->nDockLine = 0;
     950          17 :     pImp->nPos  = pImp->nDockPos = 0;
     951          17 :     pImp->bNewLine = false;
     952          17 :     pImp->SetLastAlignment(SfxChildAlignment::NOALIGNMENT);
     953          17 :     pImp->aMoveIdle.SetPriority(SchedulerPriority::RESIZE);
     954          17 :     pImp->aMoveIdle.SetIdleHdl(LINK(this,SfxDockingWindow,TimerHdl));
     955          17 : }
     956             : 
     957             : /** Initialization of the SfxDockingDialog class via a SfxChildWinInfo.
     958             :     The initialization is done only in a 2nd step after the constructor, this
     959             :     constructor should be called from the derived class or from the
     960             :     SfxChildWindows.
     961             : */
     962        3264 : void SfxDockingWindow::Initialize(SfxChildWinInfo *pInfo)
     963             : {
     964        3264 :     if ( !pMgr )
     965             :     {
     966           0 :         pImp->SetDockAlignment( SfxChildAlignment::NOALIGNMENT );
     967           0 :         pImp->bConstructed = true;
     968        3264 :         return;
     969             :     }
     970             : 
     971        3264 :     if (pInfo && (pInfo->nFlags & SfxChildWindowFlags::FORCEDOCK))
     972           1 :         pImp->bDockingPrevented = true;
     973             : 
     974        3264 :     pImp->aSplitSize = GetOutputSizePixel();
     975        3264 :     if ( !GetFloatingSize().Width() )
     976             :     {
     977        3263 :         Size aMinSize( GetMinOutputSizePixel() );
     978        3263 :         SetFloatingSize( pImp->aSplitSize );
     979        3263 :         if ( pImp->aSplitSize.Width() < aMinSize.Width() )
     980           0 :             pImp->aSplitSize.Width() = aMinSize.Width();
     981        3263 :         if ( pImp->aSplitSize.Height() < aMinSize.Height() )
     982           0 :             pImp->aSplitSize.Height() = aMinSize.Height();
     983             :     }
     984             : 
     985        3264 :     bool bVertHorzRead( false );
     986        3264 :     if (pInfo && !pInfo->aExtraString.isEmpty())
     987             :     {
     988             :         // get information about alignment, split size and position in SplitWindow
     989        3149 :         OUString aStr;
     990        3149 :         sal_Int32 nPos = pInfo->aExtraString.indexOf("AL:");
     991        3149 :         if ( nPos != -1 )
     992             :         {
     993             :             // alignment information
     994        3149 :             sal_Int32 n1 = pInfo->aExtraString.indexOf('(', nPos);
     995        3149 :             if ( n1 != -1 )
     996             :             {
     997        3149 :                 sal_Int32 n2 = pInfo->aExtraString.indexOf(')', n1);
     998        3149 :                 if ( n2 != -1 )
     999             :                 {
    1000             :                     // extract alignment information from extrastring
    1001        3149 :                     aStr = pInfo->aExtraString.copy(nPos, n2 - nPos + 1);
    1002        3149 :                     pInfo->aExtraString = pInfo->aExtraString.replaceAt(nPos, n2 - nPos + 1, "");
    1003        3149 :                     aStr = aStr.replaceAt(nPos, n1-nPos+1, "");
    1004             :                 }
    1005             :             }
    1006             :         }
    1007             : 
    1008        3149 :         if ( !aStr.isEmpty() )
    1009             :         {
    1010             :             // accept window state only if alignment is also set
    1011        3149 :             pImp->aWinState = pInfo->aWinState;
    1012             : 
    1013             :             // check for valid alignment
    1014        3149 :             SfxChildAlignment eLocalAlignment = (SfxChildAlignment) (sal_uInt16) aStr.toInt32();
    1015        3149 :             if ( pImp->bDockingPrevented )
    1016             :                 // docking prevented, ignore old configuration and take alignment from default
    1017           0 :                 aStr.clear();
    1018             :             else
    1019        3149 :                 SetAlignment( eLocalAlignment );
    1020             : 
    1021        3149 :             SfxChildAlignment eAlign = CheckAlignment(GetAlignment(),GetAlignment());
    1022        3149 :             if ( eAlign != GetAlignment() )
    1023             :             {
    1024             :                 OSL_FAIL("Invalid Alignment!");
    1025           0 :                 SetAlignment( eAlign );
    1026           0 :                 aStr.clear();
    1027             :             }
    1028             : 
    1029             :             // get last alignment (for toggeling)
    1030        3149 :             nPos = aStr.indexOf(',');
    1031        3149 :             if ( nPos != -1 )
    1032             :             {
    1033        3149 :                 aStr = aStr.copy(nPos+1);
    1034        3149 :                 pImp->SetLastAlignment( (SfxChildAlignment) (sal_uInt16) aStr.toInt32() );
    1035             :             }
    1036             : 
    1037        3149 :             nPos = aStr.indexOf(',');
    1038        3149 :             if ( nPos != -1 )
    1039             :             {
    1040             :                 // get split size and position in SplitWindow
    1041        3149 :                 Point aPos;
    1042        3149 :                 aStr = aStr.copy(nPos+1);
    1043        3149 :                 if ( GetPosSizeFromString( aStr, aPos, pImp->aSplitSize ) )
    1044             :                 {
    1045        3149 :                     pImp->nLine = pImp->nDockLine = (sal_uInt16) aPos.X();
    1046        3149 :                     pImp->nPos  = pImp->nDockPos  = (sal_uInt16) aPos.Y();
    1047        3149 :                     pImp->nVerticalSize = pImp->aSplitSize.Height();
    1048        3149 :                     pImp->nHorizontalSize = pImp->aSplitSize.Width();
    1049        3149 :                     if ( GetSplitSizeFromString( aStr, pImp->aSplitSize ))
    1050        3149 :                         bVertHorzRead = true;
    1051             :                 }
    1052             :             }
    1053             :         }
    1054             :         else {
    1055             :             OSL_FAIL( "Information is missing!" );
    1056        3149 :         }
    1057             :     }
    1058             : 
    1059        3264 :     if ( !bVertHorzRead )
    1060             :     {
    1061         115 :         pImp->nVerticalSize = pImp->aSplitSize.Height();
    1062         115 :         pImp->nHorizontalSize = pImp->aSplitSize.Width();
    1063             :     }
    1064             : 
    1065        3264 :     SfxWorkWindow *pWorkWin = pBindings->GetWorkWindow_Impl();
    1066        3264 :     if ( GetAlignment() != SfxChildAlignment::NOALIGNMENT )
    1067             :     {
    1068             :         // check if SfxWorkWindow is able to allow docking at its border
    1069        3264 :         if (
    1070        6528 :             !pWorkWin->IsDockingAllowed() ||
    1071        6528 :             !pWorkWin->IsInternalDockingAllowed() ||
    1072        3264 :             ( (GetFloatStyle() & WB_STANDALONE) && Application::IsInModalMode()) )
    1073             :         {
    1074           0 :             SetAlignment( SfxChildAlignment::NOALIGNMENT );
    1075             :         }
    1076             :     }
    1077             : 
    1078             :     // detect floating mode
    1079             :     // toggeling mode will not execute code in handlers, because pImp->bConstructed is not set yet
    1080        3264 :     bool bFloatMode = IsFloatingMode();
    1081        3264 :     if ( bFloatMode != ((GetAlignment() == SfxChildAlignment::NOALIGNMENT)) )
    1082             :     {
    1083           0 :         bFloatMode = !bFloatMode;
    1084           0 :         SetFloatingMode( bFloatMode );
    1085           0 :         if ( bFloatMode )
    1086             :         {
    1087           0 :             if ( !pImp->aWinState.isEmpty() )
    1088           0 :                 GetFloatingWindow()->SetWindowState( pImp->aWinState );
    1089             :             else
    1090           0 :                 GetFloatingWindow()->SetOutputSizePixel( GetFloatingSize() );
    1091             :         }
    1092             :     }
    1093             : 
    1094        3264 :     if ( IsFloatingMode() )
    1095             :     {
    1096             :         // validate last alignment
    1097           0 :         SfxChildAlignment eLastAlign = pImp->GetLastAlignment();
    1098           0 :         if ( eLastAlign == SfxChildAlignment::NOALIGNMENT)
    1099           0 :             eLastAlign = CheckAlignment(eLastAlign, SfxChildAlignment::LEFT);
    1100           0 :         if ( eLastAlign == SfxChildAlignment::NOALIGNMENT)
    1101           0 :             eLastAlign = CheckAlignment(eLastAlign, SfxChildAlignment::RIGHT);
    1102           0 :         if ( eLastAlign == SfxChildAlignment::NOALIGNMENT)
    1103           0 :             eLastAlign = CheckAlignment(eLastAlign, SfxChildAlignment::TOP);
    1104           0 :         if ( eLastAlign == SfxChildAlignment::NOALIGNMENT)
    1105           0 :             eLastAlign = CheckAlignment(eLastAlign, SfxChildAlignment::BOTTOM);
    1106           0 :         pImp->SetLastAlignment(eLastAlign);
    1107             :     }
    1108             :     else
    1109             :     {
    1110             :         // docked window must have NOALIGNMENT as last alignment
    1111        3264 :         pImp->SetLastAlignment(SfxChildAlignment::NOALIGNMENT);
    1112             : 
    1113        3264 :         if ( pImp->bSplitable )
    1114             :         {
    1115        3264 :             pImp->pSplitWin = pWorkWin->GetSplitWindow_Impl(GetAlignment());
    1116        3264 :             pImp->pSplitWin->InsertWindow(this, pImp->aSplitSize);
    1117             :         }
    1118             :         else
    1119             :         {
    1120             :             //?????? Currently not supported
    1121             :             // Window is docked individually; size is calculated.
    1122             :             // It must therefore be initialized with the DloatingSize if
    1123             :             // someone relies on it that a reasonable size is set
    1124           0 :             SetSizePixel(GetFloatingSize());
    1125           0 :             SetSizePixel(CalcDockingSize(GetAlignment()));
    1126             :         }
    1127             :     }
    1128             : 
    1129             :     // save alignment
    1130        3264 :     pImp->SetDockAlignment( GetAlignment() );
    1131             : }
    1132             : 
    1133        3236 : void SfxDockingWindow::Initialize_Impl()
    1134             : {
    1135        3236 :     if ( !pMgr )
    1136             :     {
    1137           0 :         pImp->bConstructed = true;
    1138        3236 :         return;
    1139             :     }
    1140             : 
    1141        3236 :     FloatingWindow* pFloatWin = GetFloatingWindow();
    1142        3236 :     bool bSet = false;
    1143        3236 :     if ( pFloatWin )
    1144             :     {
    1145           0 :         bSet = !pFloatWin->IsDefaultPos();
    1146             :     }
    1147             :     else
    1148             :     {
    1149        3236 :         Point aPos = GetFloatingPos();
    1150        3236 :         if ( aPos != Point() )
    1151           3 :             bSet = true;
    1152             :     }
    1153             : 
    1154        3236 :     if ( !bSet)
    1155             :     {
    1156        3233 :         SfxViewFrame *pFrame = pBindings->GetDispatcher_Impl()->GetFrame();
    1157        3233 :         vcl::Window* pEditWin = pFrame->GetViewShell()->GetWindow();
    1158        3233 :         Point aPos = pEditWin->OutputToScreenPixel( pEditWin->GetPosPixel() );
    1159        3233 :         aPos = GetParent()->ScreenToOutputPixel( aPos );
    1160        3233 :         SetFloatingPos( aPos );
    1161             :     }
    1162             : 
    1163        3236 :     if ( pFloatWin )
    1164             :     {
    1165             :         // initialize floating window
    1166           0 :         if ( pImp->aWinState.isEmpty() )
    1167             :             // window state never set before, get if from defaults
    1168           0 :             pImp->aWinState = pFloatWin->GetWindowState();
    1169             : 
    1170             :         // trick: use VCL method SetWindowState to adjust position and size
    1171           0 :         pFloatWin->SetWindowState( pImp->aWinState );
    1172           0 :         Size aSize(pFloatWin->GetSizePixel());
    1173             : 
    1174             :         // remember floating size for calculating alignment and tracking rectangle
    1175           0 :         SetFloatingSize(aSize);
    1176             : 
    1177             :     }
    1178             : 
    1179             :     // allow calling of docking handlers
    1180        3236 :     pImp->bConstructed = true;
    1181             : }
    1182             : 
    1183             : /** Fills a SfxChildWinInfo with specific data from SfxDockingWindow,
    1184             :     so that it can be written in the INI file. It is assumed that rinfo
    1185             :     receives all other possible relevant data in the ChildWindow class.
    1186             :     Insertions are marked with size and the ZoomIn flag.
    1187             :     If this method is overridden, the base implementation must be called first.
    1188             : */
    1189        6660 : void SfxDockingWindow::FillInfo(SfxChildWinInfo& rInfo) const
    1190             : {
    1191        6660 :     if (!pMgr || !pImp)
    1192        6660 :         return;
    1193             : 
    1194        6660 :     if (GetFloatingWindow() && pImp->bConstructed)
    1195           0 :         pImp->aWinState = GetFloatingWindow()->GetWindowState();
    1196             : 
    1197        6660 :     rInfo.aWinState = pImp->aWinState;
    1198        6660 :     rInfo.aExtraString = "AL:(";
    1199        6660 :     rInfo.aExtraString += OUString::number((sal_uInt16) GetAlignment());
    1200        6660 :     rInfo.aExtraString += ",";
    1201        6660 :     rInfo.aExtraString += OUString::number ((sal_uInt16) pImp->GetLastAlignment());
    1202        6660 :     if ( pImp->bSplitable )
    1203             :     {
    1204        6660 :         Point aPos(pImp->nLine, pImp->nPos);
    1205        6660 :         rInfo.aExtraString += ",";
    1206        6660 :         rInfo.aExtraString += OUString::number( aPos.X() );
    1207        6660 :         rInfo.aExtraString += "/";
    1208        6660 :         rInfo.aExtraString += OUString::number( aPos.Y() );
    1209        6660 :         rInfo.aExtraString += "/";
    1210        6660 :         rInfo.aExtraString += OUString::number( pImp->nHorizontalSize );
    1211        6660 :         rInfo.aExtraString += "/";
    1212        6660 :         rInfo.aExtraString += OUString::number( pImp->nVerticalSize );
    1213        6660 :         rInfo.aExtraString += ",";
    1214        6660 :         rInfo.aExtraString += OUString::number( pImp->aSplitSize.Width() );
    1215        6660 :         rInfo.aExtraString += ";";
    1216        6660 :         rInfo.aExtraString += OUString::number( pImp->aSplitSize.Height() );
    1217             :     }
    1218             : 
    1219        6660 :     rInfo.aExtraString += ")";
    1220             : }
    1221             : 
    1222        6494 : SfxDockingWindow::~SfxDockingWindow()
    1223             : {
    1224        3247 :     disposeOnce();
    1225        3247 : }
    1226             : 
    1227        3264 : void SfxDockingWindow::dispose()
    1228             : {
    1229        3264 :     ReleaseChildWindow_Impl();
    1230        3264 :     delete pImp; pImp = NULL;
    1231        3264 :     DockingWindow::dispose();
    1232        3264 : }
    1233             : 
    1234        3264 : void SfxDockingWindow::ReleaseChildWindow_Impl()
    1235             : {
    1236        3264 :     if ( pMgr && pMgr->GetFrame() == pBindings->GetActiveFrame() )
    1237          10 :         pBindings->SetActiveFrame( NULL );
    1238             : 
    1239        3264 :     if ( pMgr && pImp->pSplitWin && pImp->pSplitWin->IsItemValid( GetType() ) )
    1240        3252 :         pImp->pSplitWin->RemoveWindow(this);
    1241             : 
    1242        3264 :     pMgr=NULL;
    1243        3264 : }
    1244             : 
    1245             : /** This method calculates a resulting alignment for the given mouse position
    1246             :     and tracking rectangle. When changing the alignment it can also be that
    1247             :     the tracking rectangle is changed, so that an altered rectangle is
    1248             :     returned. The user of this class can influence behaviour of this method,
    1249             :     and thus the behavior of his DockinWindow class when docking where the
    1250             :     called virtual method:
    1251             : 
    1252             :     SfxDockingWindow :: CalcDockingSize (SfxChildAlignment eAlign)
    1253             : 
    1254             :     is overridden (see below).
    1255             : */
    1256           0 : SfxChildAlignment SfxDockingWindow::CalcAlignment(const Point& rPos, Rectangle& rRect)
    1257             : {
    1258             :     // calculate hypothetical sizes for different modes
    1259           0 :     Size aFloatingSize(CalcDockingSize(SfxChildAlignment::NOALIGNMENT));
    1260           0 :     Size aVerticalSize(CalcDockingSize(SfxChildAlignment::LEFT));
    1261           0 :     Size aHorizontalSize(CalcDockingSize(SfxChildAlignment::TOP));
    1262             : 
    1263             :     // check if docking is permitted
    1264           0 :     SfxWorkWindow *pWorkWin = pBindings->GetWorkWindow_Impl();
    1265           0 :     if ( !pWorkWin->IsDockingAllowed() )
    1266             :     {
    1267           0 :         rRect.SetSize( aFloatingSize );
    1268           0 :         return pImp->GetDockAlignment();
    1269             :     }
    1270             : 
    1271             :     // calculate borders to shrink inner area before checking for intersection with tracking rectangle
    1272             :     long nLRBorder, nTBBorder;
    1273           0 :     if ( pImp->bSplitable )
    1274             :     {
    1275             :         // take the smaller size of docked and floating mode
    1276           0 :         Size aSize = pImp->aSplitSize;
    1277           0 :         if ( GetFloatingSize().Height() < aSize.Height() )
    1278           0 :             aSize.Height() = GetFloatingSize().Height();
    1279           0 :         if ( GetFloatingSize().Width() < aSize.Width() )
    1280           0 :             aSize.Width() = GetFloatingSize().Width();
    1281             : 
    1282           0 :         nLRBorder = aSize.Width();
    1283           0 :         nTBBorder = aSize.Height();
    1284             :     }
    1285             :     else
    1286             :     {
    1287           0 :         nLRBorder = aVerticalSize.Width();
    1288           0 :         nTBBorder = aHorizontalSize.Height();
    1289             :     }
    1290             : 
    1291             :     // limit border to predefined constant values
    1292           0 :     if ( nLRBorder > MAX_TOGGLEAREA_WIDTH )
    1293           0 :         nLRBorder = MAX_TOGGLEAREA_WIDTH;
    1294           0 :     if ( nTBBorder > MAX_TOGGLEAREA_WIDTH )
    1295           0 :         nTBBorder = MAX_TOGGLEAREA_WIDTH;
    1296             : 
    1297             :     // shrink area for floating mode if possible
    1298           0 :     Rectangle aInRect = GetInnerRect();
    1299           0 :     if ( aInRect.GetWidth() > nLRBorder )
    1300           0 :         aInRect.Left()   += nLRBorder/2;
    1301           0 :     if ( aInRect.GetWidth() > nLRBorder )
    1302           0 :         aInRect.Right()  -= nLRBorder/2;
    1303           0 :     if ( aInRect.GetHeight() > nTBBorder )
    1304           0 :         aInRect.Top()    += nTBBorder/2;
    1305           0 :     if ( aInRect.GetHeight() > nTBBorder )
    1306           0 :         aInRect.Bottom() -= nTBBorder/2;
    1307             : 
    1308             :     // calculate alignment resulting from docking rectangle
    1309           0 :     bool bBecomesFloating = false;
    1310           0 :     SfxChildAlignment eDockAlign = pImp->GetDockAlignment();
    1311           0 :     Rectangle aDockingRect( rRect );
    1312           0 :     if ( !IsFloatingMode() )
    1313             :     {
    1314             :         // don't use tracking rectangle for alignment check, because it will be too large
    1315             :         // to get a floating mode as result - switch to floating size
    1316             :         // so the calculation only depends on the position of the rectangle, not the current
    1317             :         // docking state of the window
    1318           0 :         aDockingRect.SetSize( GetFloatingSize() );
    1319             : 
    1320             :         // in this mode docking is never done by keyboard, so it's OK to use the mouse position
    1321           0 :         aDockingRect.SetPos( pWorkWin->GetWindow()->OutputToScreenPixel( pWorkWin->GetWindow()->GetPointerPosPixel() ) );
    1322             :     }
    1323             : 
    1324           0 :     Point aPos = aDockingRect.TopLeft();
    1325           0 :     Rectangle aIntersect = GetOuterRect().GetIntersection( aDockingRect );
    1326           0 :     if ( aIntersect.IsEmpty() )
    1327             :         // docking rectangle completely outside docking area -> floating mode
    1328           0 :         bBecomesFloating = true;
    1329             :     else
    1330             :     {
    1331             :         // create a small test rect around the mouse position and use this one
    1332             :         // instead of the passed rRect to not dock too easily or by accident
    1333           0 :         Rectangle aSmallDockingRect;
    1334           0 :         aSmallDockingRect.SetSize( Size( MAX_TOGGLEAREA_WIDTH, MAX_TOGGLEAREA_HEIGHT ) );
    1335           0 :         Point aNewPos(rPos);
    1336           0 :         aNewPos.X() -= aSmallDockingRect.GetWidth()/2;
    1337           0 :         aNewPos.Y() -= aSmallDockingRect.GetHeight()/2;
    1338           0 :         aSmallDockingRect.SetPos(rPos);
    1339           0 :         Rectangle aIntersectRect = aInRect.GetIntersection( aSmallDockingRect );
    1340           0 :         if ( aIntersectRect == aSmallDockingRect )
    1341             :             // docking rectangle completely inside (shrunk) inner area -> floating mode
    1342           0 :             bBecomesFloating = true;
    1343             :     }
    1344             : 
    1345           0 :     if ( bBecomesFloating )
    1346             :     {
    1347           0 :         eDockAlign = CheckAlignment(pImp->GetDockAlignment(),SfxChildAlignment::NOALIGNMENT);
    1348             :     }
    1349             :     else
    1350             :     {
    1351             :         // docking rectangle is in the "sensible area"
    1352           0 :         Point aInPosTL( aPos.X()-aInRect.Left(), aPos.Y()-aInRect.Top() );
    1353           0 :         Point aInPosBR( aPos.X()-aInRect.Left() + aDockingRect.GetWidth(), aPos.Y()-aInRect.Top() + aDockingRect.GetHeight() );
    1354           0 :         Size  aInSize = aInRect.GetSize();
    1355           0 :         bool  bNoChange = false;
    1356             : 
    1357             :         // check if alignment is still unchanged
    1358           0 :         switch ( GetAlignment() )
    1359             :         {
    1360             :             case SfxChildAlignment::LEFT:
    1361             :             case SfxChildAlignment::FIRSTLEFT:
    1362             :             case SfxChildAlignment::LASTLEFT:
    1363           0 :                 if (aInPosTL.X() <= 0)
    1364             :                 {
    1365           0 :                     eDockAlign = GetAlignment();
    1366           0 :                     bNoChange = true;
    1367             :                 }
    1368           0 :                 break;
    1369             :             case SfxChildAlignment::TOP:
    1370             :             case SfxChildAlignment::LOWESTTOP:
    1371             :             case SfxChildAlignment::HIGHESTTOP:
    1372           0 :                 if ( aInPosTL.Y() <= 0)
    1373             :                 {
    1374           0 :                     eDockAlign = GetAlignment();
    1375           0 :                     bNoChange = true;
    1376             :                 }
    1377           0 :                 break;
    1378             :             case SfxChildAlignment::RIGHT:
    1379             :             case SfxChildAlignment::FIRSTRIGHT:
    1380             :             case SfxChildAlignment::LASTRIGHT:
    1381           0 :                 if ( aInPosBR.X() >= aInSize.Width())
    1382             :                 {
    1383           0 :                     eDockAlign = GetAlignment();
    1384           0 :                     bNoChange = true;
    1385             :                 }
    1386           0 :                 break;
    1387             :             case SfxChildAlignment::BOTTOM:
    1388             :             case SfxChildAlignment::LOWESTBOTTOM:
    1389             :             case SfxChildAlignment::HIGHESTBOTTOM:
    1390           0 :                 if ( aInPosBR.Y() >= aInSize.Height())
    1391             :                 {
    1392           0 :                     eDockAlign = GetAlignment();
    1393           0 :                     bNoChange = true;
    1394             :                 }
    1395           0 :                 break;
    1396             :             default:
    1397           0 :                 break;
    1398             :         }
    1399             : 
    1400           0 :         if ( !bNoChange )
    1401             :         {
    1402             :             // alignment will change, test alignment according to distance of the docking rectangles edges
    1403           0 :             bool bForbidden = true;
    1404           0 :             if ( aInPosTL.X() <= 0)
    1405             :             {
    1406           0 :                 eDockAlign = CheckAlignment(pImp->GetDockAlignment(),SfxChildAlignment::LEFT);
    1407           0 :                 bForbidden = ( eDockAlign != SfxChildAlignment::LEFT &&
    1408           0 :                                eDockAlign != SfxChildAlignment::FIRSTLEFT &&
    1409           0 :                                eDockAlign != SfxChildAlignment::LASTLEFT );
    1410             :             }
    1411             : 
    1412           0 :             if ( bForbidden && aInPosTL.Y() <= 0)
    1413             :             {
    1414           0 :                 eDockAlign = CheckAlignment(pImp->GetDockAlignment(),SfxChildAlignment::TOP);
    1415           0 :                 bForbidden = ( eDockAlign != SfxChildAlignment::TOP &&
    1416           0 :                                eDockAlign != SfxChildAlignment::HIGHESTTOP &&
    1417           0 :                                eDockAlign != SfxChildAlignment::LOWESTTOP );
    1418             :             }
    1419             : 
    1420           0 :             if ( bForbidden && aInPosBR.X() >= aInSize.Width())
    1421             :             {
    1422           0 :                 eDockAlign = CheckAlignment(pImp->GetDockAlignment(),SfxChildAlignment::RIGHT);
    1423           0 :                 bForbidden = ( eDockAlign != SfxChildAlignment::RIGHT &&
    1424           0 :                                eDockAlign != SfxChildAlignment::FIRSTRIGHT &&
    1425           0 :                                eDockAlign != SfxChildAlignment::LASTRIGHT );
    1426             :             }
    1427             : 
    1428           0 :             if ( bForbidden && aInPosBR.Y() >= aInSize.Height())
    1429             :             {
    1430           0 :                 eDockAlign = CheckAlignment(pImp->GetDockAlignment(),SfxChildAlignment::BOTTOM);
    1431           0 :                 bForbidden = ( eDockAlign != SfxChildAlignment::BOTTOM &&
    1432           0 :                                eDockAlign != SfxChildAlignment::HIGHESTBOTTOM &&
    1433           0 :                                eDockAlign != SfxChildAlignment::LOWESTBOTTOM );
    1434             :             }
    1435             : 
    1436             :             // the calculated alignment was rejected by the window -> take floating mode
    1437           0 :             if ( bForbidden )
    1438           0 :                 eDockAlign = CheckAlignment(pImp->GetDockAlignment(),SfxChildAlignment::NOALIGNMENT);
    1439             :         }
    1440             :     }
    1441             : 
    1442           0 :     if ( eDockAlign == SfxChildAlignment::NOALIGNMENT )
    1443             :     {
    1444             :         // In the FloatingMode the tracking rectangle will get the floating
    1445             :         // size. Due to a bug the rRect may only be changed when the
    1446             :         // alignment is changed!
    1447           0 :         if ( eDockAlign != pImp->GetDockAlignment() )
    1448           0 :             aDockingRect.SetSize( aFloatingSize );
    1449             :     }
    1450           0 :     else if ( pImp->bSplitable )
    1451             :     {
    1452             :         sal_uInt16 nLine, nPos;
    1453           0 :         SfxSplitWindow *pSplitWin = pWorkWin->GetSplitWindow_Impl(eDockAlign);
    1454           0 :         aPos = pSplitWin->ScreenToOutputPixel( aPos );
    1455           0 :         if ( pSplitWin->GetWindowPos( aPos, nLine, nPos ) )
    1456             :         {
    1457             :             // mouse over splitwindow, get line and position
    1458           0 :             pImp->nDockLine = nLine;
    1459           0 :             pImp->nDockPos = nPos;
    1460           0 :             pImp->bNewLine = false;
    1461             :         }
    1462             :         else
    1463             :         {
    1464             :             // mouse touches inner border -> create new line
    1465           0 :             if ( eDockAlign == GetAlignment() && pImp->pSplitWin &&
    1466           0 :                  pImp->nLine == pImp->pSplitWin->GetLineCount()-1 && pImp->pSplitWin->GetWindowCount(pImp->nLine) == 1 )
    1467             :             {
    1468             :                 // if this window is the only one in the last line, it can't be docked as new line in the same splitwindow
    1469           0 :                 pImp->nDockLine = pImp->nLine;
    1470           0 :                 pImp->nDockPos = pImp->nPos;
    1471           0 :                 pImp->bNewLine = false;
    1472             :             }
    1473             :             else
    1474             :             {
    1475             :                 // create new line
    1476           0 :                 pImp->nDockLine = pSplitWin->GetLineCount();
    1477           0 :                 pImp->nDockPos = 0;
    1478           0 :                 pImp->bNewLine = true;
    1479             :             }
    1480             :         }
    1481             : 
    1482           0 :         bool bChanged = pImp->nLine != pImp->nDockLine || pImp->nPos != pImp->nDockPos || eDockAlign != GetAlignment();
    1483           0 :         if ( !bChanged && !IsFloatingMode() )
    1484             :         {
    1485             :             // window only sightly moved, no change of any property
    1486           0 :             rRect.SetSize( pImp->aSplitSize );
    1487           0 :             rRect.SetPos( aDockingRect.TopLeft() );
    1488           0 :             return eDockAlign;
    1489             :         }
    1490             : 
    1491             :         // calculate new size and position
    1492           0 :         Size aSize;
    1493           0 :         Point aPoint = aDockingRect.TopLeft();
    1494           0 :         Size aInnerSize = GetInnerRect().GetSize();
    1495           0 :         if ( eDockAlign == SfxChildAlignment::LEFT || eDockAlign == SfxChildAlignment::RIGHT )
    1496             :         {
    1497           0 :             if ( pImp->bNewLine )
    1498             :             {
    1499             :                 // set height to height of free area
    1500           0 :                 aSize.Height() = aInnerSize.Height();
    1501           0 :                 aSize.Width() = pImp->nHorizontalSize;
    1502           0 :                 if ( eDockAlign == SfxChildAlignment::LEFT )
    1503             :                 {
    1504           0 :                     aPoint = aInnerRect.TopLeft();
    1505             :                 }
    1506             :                 else
    1507             :                 {
    1508           0 :                     aPoint = aInnerRect.TopRight();
    1509           0 :                     aPoint.X() -= aSize.Width();
    1510             :                 }
    1511             :             }
    1512             :             else
    1513             :             {
    1514             :                 // get width from splitwindow
    1515           0 :                 aSize.Width() = pSplitWin->GetLineSize(nLine);
    1516           0 :                 aSize.Height() = pImp->aSplitSize.Height();
    1517             :             }
    1518             :         }
    1519             :         else
    1520             :         {
    1521           0 :             if ( pImp->bNewLine )
    1522             :             {
    1523             :                 // set width to width of free area
    1524           0 :                 aSize.Width() = aInnerSize.Width();
    1525           0 :                 aSize.Height() = pImp->nVerticalSize;
    1526           0 :                 if ( eDockAlign == SfxChildAlignment::TOP )
    1527             :                 {
    1528           0 :                     aPoint = aInnerRect.TopLeft();
    1529             :                 }
    1530             :                 else
    1531             :                 {
    1532           0 :                     aPoint = aInnerRect.BottomLeft();
    1533           0 :                     aPoint.Y() -= aSize.Height();
    1534             :                 }
    1535             :             }
    1536             :             else
    1537             :             {
    1538             :                 // get height from splitwindow
    1539           0 :                 aSize.Height() = pSplitWin->GetLineSize(nLine);
    1540           0 :                 aSize.Width() = pImp->aSplitSize.Width();
    1541             :             }
    1542             :         }
    1543             : 
    1544           0 :         aDockingRect.SetSize( aSize );
    1545           0 :         aDockingRect.SetPos( aPoint );
    1546             :     }
    1547             :     else
    1548             :     {
    1549             :         // window can be docked, but outside our splitwindows
    1550             :         // tracking rectangle only needs to be modified if alignment was changed
    1551           0 :         if ( eDockAlign != pImp->GetDockAlignment() )
    1552             :         {
    1553           0 :             switch ( eDockAlign )
    1554             :             {
    1555             :                 case SfxChildAlignment::LEFT:
    1556             :                 case SfxChildAlignment::RIGHT:
    1557             :                 case SfxChildAlignment::FIRSTLEFT:
    1558           0 :                     aDockingRect.SetPos( aInnerRect.TopLeft() );
    1559           0 :                     aDockingRect.SetSize( aVerticalSize );
    1560           0 :                     break;
    1561             :                 case SfxChildAlignment::LASTLEFT:
    1562             :                 case SfxChildAlignment::FIRSTRIGHT:
    1563             :                 case SfxChildAlignment::LASTRIGHT:
    1564             :                 {
    1565           0 :                     Point aPt( aInnerRect.TopRight() );
    1566           0 :                     aPt.X() -= aDockingRect.GetWidth();
    1567           0 :                     aDockingRect.SetPos( aPt );
    1568           0 :                     aDockingRect.SetSize( aVerticalSize );
    1569           0 :                     break;
    1570             :                 }
    1571             : 
    1572             :                 case SfxChildAlignment::TOP:
    1573             :                 case SfxChildAlignment::BOTTOM:
    1574             :                 case SfxChildAlignment::LOWESTTOP:
    1575           0 :                     aDockingRect.SetPos( aInnerRect.TopLeft() );
    1576           0 :                     aDockingRect.SetSize( aHorizontalSize );
    1577           0 :                     break;
    1578             :                 case SfxChildAlignment::HIGHESTTOP:
    1579             :                 case SfxChildAlignment::LOWESTBOTTOM:
    1580             :                 case SfxChildAlignment::HIGHESTBOTTOM:
    1581             :                 {
    1582           0 :                     Point aPt( aInnerRect.BottomLeft() );
    1583           0 :                     aPt.Y() -= aDockingRect.GetHeight();
    1584           0 :                     aDockingRect.SetPos( aPt );
    1585           0 :                     aDockingRect.SetSize( aHorizontalSize );
    1586           0 :                     break;
    1587             :                 }
    1588             :                         default:
    1589           0 :                             break;
    1590             :             }
    1591             :         }
    1592             :     }
    1593             : 
    1594           0 :     rRect = aDockingRect;
    1595           0 :     return eDockAlign;
    1596             : }
    1597             : 
    1598             : /** Virtual method of the SfxDockingWindow class. This method determines how
    1599             :     the size of the DockingWindows changes depending on the alignment. The base
    1600             :     implementation uses the floating mode, the size of the marked Floating
    1601             :     Size. For horizontal alignment, the width will be the width of the outer
    1602             :     DockingRectangle, with vertical alignment the height will be the height of
    1603             :     the inner DockingRectangle (resulting from the order in which the SFX child
    1604             :     windows are displayed). The other size is set to the current floating-size,
    1605             :     this could changed by a to intervening derived class. The docking size must
    1606             :     be the same for Left/Right and Top/Bottom.
    1607             : */
    1608           0 : Size SfxDockingWindow::CalcDockingSize(SfxChildAlignment eAlign)
    1609             : {
    1610             :     // Note: if the resizing is also possible in the docked state, then the
    1611             :     // Floating-size does also have to be adjusted?
    1612             : 
    1613           0 :     Size aSize = GetFloatingSize();
    1614           0 :     switch (eAlign)
    1615             :     {
    1616             :         case SfxChildAlignment::TOP:
    1617             :         case SfxChildAlignment::BOTTOM:
    1618             :         case SfxChildAlignment::LOWESTTOP:
    1619             :         case SfxChildAlignment::HIGHESTTOP:
    1620             :         case SfxChildAlignment::LOWESTBOTTOM:
    1621             :         case SfxChildAlignment::HIGHESTBOTTOM:
    1622           0 :             aSize.Width() = aOuterRect.Right() - aOuterRect.Left();
    1623           0 :             break;
    1624             :         case SfxChildAlignment::LEFT:
    1625             :         case SfxChildAlignment::RIGHT:
    1626             :         case SfxChildAlignment::FIRSTLEFT:
    1627             :         case SfxChildAlignment::LASTLEFT:
    1628             :         case SfxChildAlignment::FIRSTRIGHT:
    1629             :         case SfxChildAlignment::LASTRIGHT:
    1630           0 :             aSize.Height() = aInnerRect.Bottom() - aInnerRect.Top();
    1631           0 :             break;
    1632             :         case SfxChildAlignment::NOALIGNMENT:
    1633           0 :             break;
    1634             :               default:
    1635           0 :                   break;
    1636             :     }
    1637             : 
    1638           0 :     return aSize;
    1639             : }
    1640             : 
    1641             : /** Virtual method of the SfxDockingWindow class. Here a derived class can
    1642             :     disallow certain alignments. The base implementation does not
    1643             :     prohibit alignment.
    1644             : */
    1645          76 : SfxChildAlignment SfxDockingWindow::CheckAlignment(SfxChildAlignment,
    1646             :     SfxChildAlignment eAlign)
    1647             : {
    1648          76 :     return eAlign;
    1649             : }
    1650             : 
    1651             : /** The window is closed when the ChildWindow is destroyed by running the
    1652             :     ChildWindow-slots. If this is method is overridden by a derived class
    1653             :     method, then the SfxDockingDialogWindow: Close() must be called afterwards
    1654             :     if the Close() was not cancelled with "return sal_False".
    1655             : */
    1656           0 : bool SfxDockingWindow::Close()
    1657             : {
    1658             :     // Execute with Parameters, since Toggle is ignored by some ChildWindows.
    1659           0 :     if ( !pMgr )
    1660           0 :         return true;
    1661             : 
    1662           0 :     SfxBoolItem aValue( pMgr->GetType(), false);
    1663             :     pBindings->GetDispatcher_Impl()->Execute(
    1664           0 :         pMgr->GetType(), SfxCallMode::RECORD | SfxCallMode::ASYNCHRON, &aValue, 0L );
    1665           0 :     return true;
    1666             : }
    1667             : 
    1668             : /** Returns a boundary line to the docked edge and a frame when the Window is in
    1669             :     a docked state. In this way SVLOOK is considered.
    1670             : */
    1671         129 : void SfxDockingWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle& /*rRect*/)
    1672             : {
    1673         129 :     if (pImp->bSplitable || IsFloatingMode())
    1674         258 :         return;
    1675             : 
    1676           0 :     Rectangle aRect = Rectangle(Point(0, 0), rRenderContext.GetOutputSizePixel());
    1677           0 :     switch (GetAlignment())
    1678             :     {
    1679             :         case SfxChildAlignment::TOP:
    1680             :         {
    1681           0 :             rRenderContext.DrawLine(aRect.BottomLeft(), aRect.BottomRight());
    1682           0 :             aRect.Bottom()--;
    1683           0 :             break;
    1684             :         }
    1685             : 
    1686             :         case SfxChildAlignment::BOTTOM:
    1687             :         {
    1688           0 :             rRenderContext.DrawLine(aRect.TopLeft(), aRect.TopRight());
    1689           0 :             aRect.Top()++;
    1690           0 :             break;
    1691             :         }
    1692             : 
    1693             :         case SfxChildAlignment::LEFT:
    1694             :         {
    1695           0 :             rRenderContext.DrawLine(aRect.TopRight(), aRect.BottomRight());
    1696           0 :             aRect.Right()--;
    1697           0 :             break;
    1698             :         }
    1699             : 
    1700             :         case SfxChildAlignment::RIGHT:
    1701             :         {
    1702           0 :             rRenderContext.DrawLine(aRect.TopLeft(), aRect.BottomLeft());
    1703           0 :             aRect.Left()++;
    1704           0 :             break;
    1705             :         }
    1706             : 
    1707             :         default:
    1708           0 :             break;
    1709             :     }
    1710             : 
    1711           0 :     DecorationView aView(&rRenderContext);
    1712           0 :     aView.DrawFrame(aRect, DrawFrameStyle::Out);
    1713             : }
    1714             : 
    1715             : /** With this method, a minimal OutputSize be can set, that is queried in
    1716             :     the Resizing()-Handler.
    1717             : */
    1718          15 : void SfxDockingWindow::SetMinOutputSizePixel( const Size& rSize )
    1719             : {
    1720          15 :     pImp->aMinSize = rSize;
    1721          15 :     DockingWindow::SetMinOutputSizePixel( rSize );
    1722          15 : }
    1723             : 
    1724             : /** Set the minimum size which is returned.*/
    1725        3277 : Size SfxDockingWindow::GetMinOutputSizePixel() const
    1726             : {
    1727        3277 :     return pImp->aMinSize;
    1728             : }
    1729             : 
    1730       84833 : bool SfxDockingWindow::Notify( NotifyEvent& rEvt )
    1731             : {
    1732       84833 :     if ( !pImp )
    1733         102 :         return DockingWindow::Notify( rEvt );
    1734             : 
    1735       84731 :     if ( rEvt.GetType() == MouseNotifyEvent::GETFOCUS )
    1736             :     {
    1737          41 :         if (pMgr != NULL)
    1738          41 :             pBindings->SetActiveFrame( pMgr->GetFrame() );
    1739             : 
    1740          41 :         if ( pImp->pSplitWin )
    1741          41 :             pImp->pSplitWin->SetActiveWindow_Impl( this );
    1742           0 :         else if (pMgr != NULL)
    1743           0 :             pMgr->Activate_Impl();
    1744             : 
    1745             :         // In VCL Notify goes first to the window itself, also call the
    1746             :         // base class, otherwise the parent learns nothing
    1747             :         // if ( rEvt.GetWindow() == this )  PB: #i74693# not necessary any longer
    1748          41 :         DockingWindow::Notify( rEvt );
    1749          41 :         return true;
    1750             :     }
    1751       84690 :     else if( rEvt.GetType() == MouseNotifyEvent::KEYINPUT )
    1752             :     {
    1753             :         // First, allow KeyInput for Dialog functions
    1754           0 :         if ( !DockingWindow::Notify( rEvt ) && SfxViewShell::Current() )
    1755             :             // then also for valid global accelerators.
    1756           0 :             return SfxViewShell::Current()->GlobalKeyInput_Impl( *rEvt.GetKeyEvent() );
    1757           0 :         return true;
    1758             :     }
    1759       84690 :     else if ( rEvt.GetType() == MouseNotifyEvent::LOSEFOCUS && !HasChildPathFocus() )
    1760             :     {
    1761           4 :         pBindings->SetActiveFrame( NULL );
    1762           4 :         if (pMgr != NULL)
    1763           4 :             pMgr->Deactivate_Impl();
    1764             :     }
    1765             : 
    1766       84690 :     return DockingWindow::Notify( rEvt );
    1767             : }
    1768             : 
    1769             : 
    1770        3264 : SplitWindowItemFlags SfxDockingWindow::GetWinBits_Impl() const
    1771             : {
    1772        3264 :     return SplitWindowItemFlags::NONE;
    1773             : }
    1774             : 
    1775             : 
    1776             : 
    1777           0 : void SfxDockingWindow::SetItemSize_Impl( const Size& rSize )
    1778             : {
    1779           0 :     pImp->aSplitSize = rSize;
    1780             : 
    1781           0 :     SfxWorkWindow *pWorkWin = pBindings->GetWorkWindow_Impl();
    1782           0 :     SfxChildIdentifier eIdent = SfxChildIdentifier::DOCKINGWINDOW;
    1783           0 :     if ( pImp->bSplitable )
    1784           0 :         eIdent = SfxChildIdentifier::SPLITWINDOW;
    1785           0 :     pWorkWin->ConfigChild_Impl( eIdent, SfxDockingConfig::ALIGNDOCKINGWINDOW, pMgr->GetType() );
    1786           0 : }
    1787             : 
    1788           8 : void SfxDockingWindow::Disappear_Impl()
    1789             : {
    1790           8 :     if ( pImp->pSplitWin && pImp->pSplitWin->IsItemValid( GetType() ) )
    1791           8 :         pImp->pSplitWin->RemoveWindow(this);
    1792           8 : }
    1793             : 
    1794        3787 : void SfxDockingWindow::Reappear_Impl()
    1795             : {
    1796        3787 :     if ( pImp->pSplitWin && !pImp->pSplitWin->IsItemValid( GetType() ) )
    1797             :     {
    1798           0 :         pImp->pSplitWin->InsertWindow( this, pImp->aSplitSize );
    1799             :     }
    1800        3787 : }
    1801             : 
    1802          67 : bool SfxDockingWindow::IsAutoHide_Impl() const
    1803             : {
    1804          67 :     if ( pImp->pSplitWin )
    1805          67 :         return !pImp->pSplitWin->IsFadeIn();
    1806             :     else
    1807           0 :         return false;
    1808             : }
    1809             : 
    1810           0 : void SfxDockingWindow::AutoShow_Impl( bool bShow )
    1811             : {
    1812           0 :     if ( pImp->pSplitWin )
    1813             :     {
    1814           0 :         if ( bShow )
    1815           0 :             pImp->pSplitWin->FadeIn();
    1816             :         else
    1817           0 :             pImp->pSplitWin->FadeOut();
    1818             :     }
    1819           0 : }
    1820             : 
    1821       14350 : void SfxDockingWindow::StateChanged( StateChangedType nStateChange )
    1822             : {
    1823       14350 :     if ( nStateChange == StateChangedType::InitShow )
    1824        3236 :         Initialize_Impl();
    1825             : 
    1826       14350 :     DockingWindow::StateChanged( nStateChange );
    1827       14350 : }
    1828             : 
    1829        6514 : void SfxDockingWindow::Move()
    1830             : {
    1831        6514 :     if ( pImp )
    1832        6514 :         pImp->aMoveIdle.Start();
    1833        6514 : }
    1834             : 
    1835        2152 : IMPL_LINK_NOARG_TYPED(SfxDockingWindow, TimerHdl, Idle *, void)
    1836             : {
    1837        1076 :     pImp->aMoveIdle.Stop();
    1838        1076 :     if ( IsReallyVisible() && IsFloatingMode() )
    1839             :     {
    1840           0 :         if( !GetFloatingWindow()->IsRollUp() )
    1841           0 :             SetFloatingSize( GetOutputSizePixel() );
    1842           0 :         pImp->aWinState = GetFloatingWindow()->GetWindowState();
    1843           0 :         SfxChildIdentifier eIdent = SfxChildIdentifier::DOCKINGWINDOW;
    1844           0 :         if ( pImp->bSplitable )
    1845           0 :             eIdent = SfxChildIdentifier::SPLITWINDOW;
    1846           0 :         SfxWorkWindow *pWorkWin = pBindings->GetWorkWindow_Impl();
    1847           0 :         pWorkWin->ConfigChild_Impl( eIdent, SfxDockingConfig::ALIGNDOCKINGWINDOW, pMgr->GetType() );
    1848             :     }
    1849        1724 : }
    1850             : 
    1851             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11