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

Generated by: LCOV version 1.10