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

Generated by: LCOV version 1.10