LCOV - code coverage report
Current view: top level - sfx2/source/appl - workwin.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 1301 0.0 %
Date: 2014-04-14 Functions: 0 76 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             : #include <config_features.h>
      21             : #include <comphelper/processfactory.hxx>
      22             : #include <stdio.h>
      23             : #include <boost/unordered_map.hpp>
      24             : 
      25             : #include <sfx2/docfile.hxx>
      26             : #include <sfx2/objsh.hxx>
      27             : #include <sfx2/app.hxx>
      28             : #include "workwin.hxx"
      29             : #include <sfx2/viewfrm.hxx>
      30             : #include "arrdecl.hxx"
      31             : #include <sfx2/module.hxx>
      32             : #include <sfx2/dispatch.hxx>
      33             : #include <sfx2/dockwin.hxx>
      34             : #include <sfx2/viewsh.hxx>
      35             : #include "splitwin.hxx"
      36             : #include <sfx2/msgpool.hxx>
      37             : #include <sfx2/sfxresid.hxx>
      38             : #include <sfx2/request.hxx>
      39             : #include <vcl/taskpanelist.hxx>
      40             : #include <vcl/toolbox.hxx>
      41             : #include <tools/rcid.h>
      42             : #include <tools/diagnose_ex.h>
      43             : #include <toolkit/helper/vclunohelper.hxx>
      44             : #include <svl/itempool.hxx>
      45             : #include <svl/itemiter.hxx>
      46             : #include <svl/whiter.hxx>
      47             : #include <svl/intitem.hxx>
      48             : #include <svl/eitem.hxx>
      49             : #include <unotools/moduleoptions.hxx>
      50             : #include <com/sun/star/ui/XUIElement.hpp>
      51             : #include <com/sun/star/frame/LayoutManagerEvents.hpp>
      52             : #include <com/sun/star/frame/ModuleManager.hpp>
      53             : #include <com/sun/star/frame/XLayoutManager.hpp>
      54             : #include <com/sun/star/frame/XLayoutManagerEventBroadcaster.hpp>
      55             : #include <com/sun/star/beans/XPropertySet.hpp>
      56             : #include <com/sun/star/awt/XWindow.hpp>
      57             : #include <com/sun/star/lang/DisposedException.hpp>
      58             : 
      59             : using namespace ::com::sun::star;
      60             : using namespace ::com::sun::star::uno;
      61             : 
      62             : struct ResIdToResName
      63             : {
      64             :     sal_uInt16      nId;
      65             :     const char* pName;
      66             : };
      67             : 
      68             : static const ResIdToResName pToolBarResToName[] =
      69             : {
      70             :     // OMG! hardcoded numbers that have nice (?) symbolic names
      71             :     // elsewhere.
      72             :     { 558,      "fullscreenbar"        }, // This 558 for instance equals RID_FULLSCREENTOOLBOX (in
      73             :                                           // value, and presumably also in semantics) from app.hrc in
      74             :                                           // this very same directory, so why RID_FULLSCREENTOOLBOX
      75             :                                           // can't be used I have no idea.
      76             : 
      77             :     { 560,      "standardbar",         }, // 560 is called RID_ENVTOOLBOX in app.hrc, still the same?
      78             : 
      79             :     { 18001,    "formsnavigationbar"   }, // Probably the rest are defined in .hrc files that are higher
      80             :                                           // up in the dependency chain and/or later in the build order,
      81             :                                           // and that is the (bad) reason why their symbolic names are
      82             :                                           // not available? Would it really be so owful to move the .hrc
      83             :                                           // files in question out from the modules where they now are?
      84             : 
      85             :     { 18002,    "formsfilterbar"       },
      86             :     { 18003,    "formtextobjectbar"    },
      87             :     { 18004,    "formcontrols"         },
      88             :     { 18005,    "moreformcontrols"     },
      89             :     { 18006,    "formdesign"           },
      90             :     { 20050,    "toolbar"              },      //math
      91             :     { 30001,    "objectbar"            },      //chart
      92             :     { 30513,    "toolbar"              },      //chart
      93             :     { 25005,    "textobjectbar"        },      //calc
      94             :     { 25053,    "drawobjectbar"        },
      95             :     { 25054,    "graphicobjectbar"     },
      96             :     { 25001,    "formatobjectbar"      },
      97             :     { 25006,    "previewbar"           },
      98             :     { 25035,    "toolbar"              },      //calc
      99             :     { 23015,    "bezierobjectbar"      },      //draw/impress
     100             :     { 23019,    "gluepointsobjectbar"  },
     101             :     { 23030,    "graphicobjectbar"     },
     102             :     { 23013,    "drawingobjectbar"     },      //impress
     103             :     { 23016,    "textobjectbar"        },      //impress
     104             :     { 23028,    "textobjectbar"        },      //draw
     105             :     { 23011,    "toolbar"              },      //impress
     106             :     { 23020,    "optionsbar"           },
     107             :     { 23021,    "commontaskbar"        },
     108             :     { 23025,    "toolbar"              },      //draw
     109             :     { 23026,    "optionsbar"           },
     110             :     { 23027,    "drawingobjectbar"     },      //draw
     111             :     { 23017,    "outlinetoolbar"       },      //impress
     112             :     { 23012,    "slideviewtoolbar"     },
     113             :     { 23014,    "slideviewobjectbar"   },
     114             :     { 23283,    "bezierobjectbar"      },      //writer
     115             :     { 23269,    "drawingobjectbar"     },
     116             :     { 23270,    "drawtextobjectbar"    },
     117             :     { 23267,    "frameobjectbar"       },
     118             :     { 23268,    "graphicobjectbar"     },
     119             :     { 23271,    "numobjectbar"         },
     120             :     { 23272,    "oleobjectbar"         },
     121             :     { 23266,    "tableobjectbar"       },
     122             :     { 23265,    "textobjectbar"        },
     123             :     { 20631,    "previewobjectbar"     },      //writer
     124             :     { 20402,    "toolbar"              },      //web
     125             :     { 20403,    "textobjectbar"        },
     126             :     { 23273,    "toolbar"              },      //writer
     127             :     { 20408,    "frameobjectbar"       },      //web
     128             :     { 20410,    "graphicobjectbar"     },
     129             :     { 20411,    "oleobjectbar"         },
     130             :     { 14850,    "macrobar"             },
     131             :     { 10987,    "fontworkobjectbar"    },      //global
     132             :     { 10986,    "extrusionobjectbar"   },
     133             :     { 23022,    "formsobjectbar"       },
     134             :     { 23310,    "viewerbar"            },      //writer (plugin)
     135             :     { 25000,    "viewerbar"            },      //calc   (plugin)
     136             :     { 23023,    "viewerbar"            },      //impress(plugin)
     137             :     { 23024,    "viewerbar"            },      //draw   (plugin)
     138             :     { 23031,    "mediaobjectbar"       },      //draw/impress
     139             :     { 25060,    "mediaobjectbar"       },      //calc
     140             :     { 23311,    "mediaobjectbar"       },      //writer
     141             :     { 23313,    "navigationobjectbar"  },      //writer
     142             :     { 0,        ""                     }
     143             : };
     144             : 
     145             : //SV_IMPL_OBJARR( SfxObjectBarArr_Impl, SfxObjectBar_Impl );
     146             : 
     147             : 
     148             : // Sort the Children according their alignment
     149             : // The order corresponds to the enum SfxChildAlignment (->CHILDWIN.HXX).
     150             : 
     151             : 
     152             : // Help to make changes to the alignment compatible!
     153             : 
     154             : 
     155           0 : LayoutManagerListener::LayoutManagerListener(
     156             :     SfxWorkWindow* pWrkWin ) :
     157             :     m_bHasFrame( false ),
     158             :     m_pWrkWin( pWrkWin ),
     159           0 :     m_aLayoutManagerPropName( "LayoutManager" )
     160             : {
     161           0 : }
     162             : 
     163           0 : LayoutManagerListener::~LayoutManagerListener()
     164             : {
     165           0 : }
     166             : 
     167           0 : void LayoutManagerListener::setFrame( const css::uno::Reference< css::frame::XFrame >& xFrame )
     168             : {
     169           0 :     SolarMutexGuard aGuard;
     170           0 :     if ( m_pWrkWin && !m_bHasFrame )
     171             :     {
     172           0 :         m_xFrame    = xFrame;
     173           0 :         m_bHasFrame = true;
     174             : 
     175           0 :         if ( xFrame.is() )
     176             :         {
     177           0 :             css::uno::Reference< css::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY );
     178           0 :             css::uno::Reference< css::frame::XLayoutManagerEventBroadcaster > xLayoutManager;
     179           0 :             if ( xPropSet.is() )
     180             :             {
     181             :                 try
     182             :                 {
     183           0 :                     Any aValue = xPropSet->getPropertyValue( m_aLayoutManagerPropName );
     184           0 :                     aValue >>= xLayoutManager;
     185             : 
     186           0 :                     if ( xLayoutManager.is() )
     187           0 :                         xLayoutManager->addLayoutManagerEventListener(
     188             :                             css::uno::Reference< css::frame::XLayoutManagerListener >(
     189           0 :                                 static_cast< OWeakObject* >( this ), css::uno::UNO_QUERY ));
     190             : 
     191           0 :                     xPropSet = css::uno::Reference< css::beans::XPropertySet >( xLayoutManager, UNO_QUERY );
     192           0 :                     if ( xPropSet.is() )
     193             :                     {
     194           0 :                         aValue = xPropSet->getPropertyValue(
     195           0 :                             OUString( "LockCount" ) );
     196           0 :                         aValue >>= m_pWrkWin->m_nLock;
     197           0 :                     }
     198             :                 }
     199           0 :                 catch ( css::lang::DisposedException& )
     200             :                 {
     201             :                 }
     202           0 :                 catch ( const css::uno::RuntimeException& )
     203             :                 {
     204           0 :                     throw;
     205             :                 }
     206           0 :                 catch ( css::uno::Exception& )
     207             :                 {
     208             :                 }
     209           0 :             }
     210             :         }
     211           0 :     }
     212           0 : }
     213             : 
     214             : 
     215             : //  XComponent
     216             : 
     217           0 : void SAL_CALL LayoutManagerListener::addEventListener(
     218             :     const css::uno::Reference< css::lang::XEventListener >& )
     219             : throw (::com::sun::star::uno::RuntimeException, std::exception)
     220             : {
     221             :     // do nothing, only internal class
     222           0 : }
     223             : 
     224           0 : void SAL_CALL LayoutManagerListener::removeEventListener(
     225             :     const css::uno::Reference< css::lang::XEventListener >& )
     226             : throw (::com::sun::star::uno::RuntimeException, std::exception)
     227             : {
     228             :     // do nothing, only internal class
     229           0 : }
     230             : 
     231           0 : void SAL_CALL LayoutManagerListener::dispose()
     232             : throw( css::uno::RuntimeException, std::exception )
     233             : {
     234           0 :     SolarMutexGuard aGuard;
     235             : 
     236             :     // reset member
     237           0 :     m_pWrkWin = 0;
     238             : 
     239           0 :     css::uno::Reference< css::frame::XFrame > xFrame( m_xFrame.get(), css::uno::UNO_QUERY );
     240           0 :     if ( xFrame.is() )
     241             :     {
     242           0 :         m_xFrame = css::uno::Reference< css::frame::XFrame >();
     243           0 :         m_bHasFrame = false;
     244             : 
     245           0 :         css::uno::Reference< css::beans::XPropertySet > xPropSet( xFrame, css::uno::UNO_QUERY );
     246           0 :         css::uno::Reference< css::frame::XLayoutManagerEventBroadcaster > xLayoutManager;
     247           0 :         if ( xPropSet.is() )
     248             :         {
     249             :             try
     250             :             {
     251           0 :                 css::uno::Any aValue = xPropSet->getPropertyValue( m_aLayoutManagerPropName );
     252           0 :                 aValue >>= xLayoutManager;
     253             : 
     254             :                 // remove as listener from layout manager
     255           0 :                 if ( xLayoutManager.is() )
     256           0 :                     xLayoutManager->removeLayoutManagerEventListener(
     257             :                         css::uno::Reference< css::frame::XLayoutManagerListener >(
     258           0 :                             static_cast< OWeakObject* >( this ), css::uno::UNO_QUERY ));
     259             :             }
     260           0 :             catch ( css::lang::DisposedException& )
     261             :             {
     262             :             }
     263           0 :             catch ( const css::uno::RuntimeException& )
     264             :             {
     265           0 :                 throw;
     266             :             }
     267           0 :             catch ( css::uno::Exception& )
     268             :             {
     269             :             }
     270           0 :         }
     271           0 :     }
     272           0 : }
     273             : 
     274             : 
     275             : //  XEventListener
     276             : 
     277           0 : void SAL_CALL LayoutManagerListener::disposing(
     278             :     const css::lang::EventObject& )
     279             : throw( css::uno::RuntimeException, std::exception )
     280             : {
     281           0 :     SolarMutexGuard aGuard;
     282           0 :     m_pWrkWin = 0;
     283           0 :     m_bHasFrame = false;
     284           0 :     m_xFrame = css::uno::Reference< css::frame::XFrame >();
     285           0 : }
     286             : 
     287             : 
     288             : // XLayoutManagerEventListener
     289             : 
     290           0 : void SAL_CALL LayoutManagerListener::layoutEvent(
     291             :     const css::lang::EventObject&,
     292             :     ::sal_Int16                   eLayoutEvent,
     293             :     const css::uno::Any&                        )
     294             : throw (css::uno::RuntimeException, std::exception)
     295             : {
     296           0 :     SolarMutexGuard aGuard;
     297           0 :     if ( m_pWrkWin )
     298             :     {
     299           0 :         if ( eLayoutEvent == css::frame::LayoutManagerEvents::VISIBLE )
     300             :         {
     301           0 :             m_pWrkWin->MakeVisible_Impl( true );
     302           0 :             m_pWrkWin->ShowChildren_Impl();
     303           0 :             m_pWrkWin->ArrangeChildren_Impl( sal_True );
     304             :         }
     305           0 :         else if ( eLayoutEvent == css::frame::LayoutManagerEvents::INVISIBLE )
     306             :         {
     307           0 :             m_pWrkWin->MakeVisible_Impl( false );
     308           0 :             m_pWrkWin->HideChildren_Impl();
     309           0 :             m_pWrkWin->ArrangeChildren_Impl( sal_True );
     310             :         }
     311           0 :         else if ( eLayoutEvent == css::frame::LayoutManagerEvents::LOCK )
     312             :         {
     313           0 :             m_pWrkWin->Lock_Impl( true );
     314             :         }
     315           0 :         else if ( eLayoutEvent == css::frame::LayoutManagerEvents::UNLOCK )
     316             :         {
     317           0 :             m_pWrkWin->Lock_Impl( false );
     318             :         }
     319           0 :     }
     320           0 : }
     321             : 
     322             : namespace
     323             : {
     324           0 :     class FilledToolBarResIdToResourceURLMap
     325             :     {
     326             :     private:
     327             :         typedef boost::unordered_map< sal_Int32, OUString > ToolBarResIdToResourceURLMap;
     328             :         ToolBarResIdToResourceURLMap m_aResIdToResourceURLMap;
     329             :     public:
     330           0 :         FilledToolBarResIdToResourceURLMap()
     331           0 :         {
     332           0 :             sal_Int32 nIndex( 0 );
     333           0 :             while ( pToolBarResToName[nIndex].nId != 0 )
     334             :             {
     335           0 :                 OUString aResourceURL( OUString::createFromAscii( pToolBarResToName[nIndex].pName ));
     336             :                 m_aResIdToResourceURLMap.insert( ToolBarResIdToResourceURLMap::value_type(
     337           0 :                                                     sal_Int32( pToolBarResToName[nIndex].nId ), aResourceURL ));
     338           0 :                 ++nIndex;
     339           0 :             }
     340           0 :         }
     341             : 
     342           0 :         OUString findURL(sal_uInt16 nResId) const
     343             :         {
     344           0 :             ToolBarResIdToResourceURLMap::const_iterator aIter = m_aResIdToResourceURLMap.find( nResId );
     345           0 :             if ( aIter != m_aResIdToResourceURLMap.end() )
     346           0 :                 return aIter->second;
     347           0 :             return OUString();
     348             :         }
     349             :     };
     350             : 
     351             :     class theFilledToolBarResIdToResourceURLMap
     352             :         : public rtl::Static<FilledToolBarResIdToResourceURLMap,
     353             :                              theFilledToolBarResIdToResourceURLMap>
     354             :     {
     355             :     };
     356             : }
     357             : 
     358           0 : static OUString GetResourceURLFromResId( sal_uInt16 nResId )
     359             : {
     360           0 :     return theFilledToolBarResIdToResourceURLMap::get().findURL(nResId);
     361             : }
     362             : 
     363           0 : bool IsAppWorkWinToolbox_Impl( sal_uInt16 nPos )
     364             : {
     365           0 :     switch ( nPos )
     366             :     {
     367             :         case SFX_OBJECTBAR_APPLICATION :
     368             :         case SFX_OBJECTBAR_MACRO:
     369             :         case SFX_OBJECTBAR_FULLSCREEN:
     370           0 :             return true;
     371             :         default:
     372           0 :             return false;
     373             :     }
     374             : }
     375             : 
     376           0 : sal_uInt16 TbxMatch( sal_uInt16 nPos )
     377             : {
     378           0 :     switch ( nPos )
     379             :     {
     380             :         case SFX_OBJECTBAR_APPLICATION :
     381           0 :             return 0;
     382             :         case SFX_OBJECTBAR_OPTIONS:
     383           0 :             return 1;
     384             :         case SFX_OBJECTBAR_MACRO:
     385           0 :             return 2;
     386             :         case SFX_OBJECTBAR_OBJECT:
     387           0 :             return 3;
     388             :         case SFX_OBJECTBAR_TOOLS:
     389           0 :             return 4;
     390             :         case SFX_OBJECTBAR_FULLSCREEN:
     391             :         case SFX_OBJECTBAR_COMMONTASK:
     392             :         case SFX_OBJECTBAR_RECORDING:
     393           0 :             return nPos+1;
     394             :         default:
     395           0 :             return nPos;
     396             :     }
     397             : }
     398             : 
     399           0 : sal_uInt16 ChildAlignValue(SfxChildAlignment eAlign)
     400             : {
     401           0 :     sal_uInt16 ret = 17;
     402             : 
     403           0 :     switch (eAlign)
     404             :     {
     405             :         case SFX_ALIGN_HIGHESTTOP:
     406           0 :             ret = 1;
     407           0 :             break;
     408             :         case SFX_ALIGN_LOWESTBOTTOM:
     409           0 :             ret = 2;
     410           0 :             break;
     411             :         case SFX_ALIGN_FIRSTLEFT:
     412           0 :             ret = 3;
     413           0 :             break;
     414             :         case SFX_ALIGN_LASTRIGHT:
     415           0 :             ret = 4;
     416           0 :             break;
     417             :         case SFX_ALIGN_LEFT:
     418           0 :             ret = 5;
     419           0 :             break;
     420             :         case SFX_ALIGN_RIGHT:
     421           0 :             ret = 6;
     422           0 :             break;
     423             :         case SFX_ALIGN_FIRSTRIGHT:
     424           0 :             ret = 7;
     425           0 :             break;
     426             :         case SFX_ALIGN_LASTLEFT:
     427           0 :             ret = 8;
     428           0 :             break;
     429             :         case SFX_ALIGN_TOP:
     430           0 :             ret = 9;
     431           0 :             break;
     432             :         case SFX_ALIGN_BOTTOM:
     433           0 :             ret = 10;
     434           0 :             break;
     435             :         case SFX_ALIGN_TOOLBOXTOP:
     436           0 :             ret = 11;
     437           0 :             break;
     438             :         case SFX_ALIGN_TOOLBOXBOTTOM:
     439           0 :             ret = 12;
     440           0 :             break;
     441             :         case SFX_ALIGN_LOWESTTOP:
     442           0 :             ret = 13;
     443           0 :             break;
     444             :         case SFX_ALIGN_HIGHESTBOTTOM:
     445           0 :             ret = 14;
     446           0 :             break;
     447             :         case SFX_ALIGN_TOOLBOXLEFT:
     448           0 :             ret = 15;
     449           0 :             break;
     450             :         case SFX_ALIGN_TOOLBOXRIGHT:
     451           0 :             ret = 16;
     452           0 :             break;
     453             :         case SFX_ALIGN_NOALIGNMENT:
     454           0 :             break;  // -Wall not handled...
     455             :     }
     456             : 
     457           0 :     return ret;
     458             : }
     459             : 
     460           0 : sal_uInt16 ChildTravelValue( SfxChildAlignment eAlign )
     461             : {
     462           0 :     sal_uInt16 ret = 17;
     463             : 
     464           0 :     switch (eAlign)
     465             :     {
     466             :         case SFX_ALIGN_FIRSTLEFT:
     467           0 :             ret = 1;
     468           0 :             break;
     469             :         case SFX_ALIGN_LEFT:
     470           0 :             ret = 2;
     471           0 :             break;
     472             :         case SFX_ALIGN_LASTLEFT:
     473           0 :             ret = 3;
     474           0 :             break;
     475             :         case SFX_ALIGN_TOOLBOXLEFT:
     476           0 :             ret = 4;
     477           0 :             break;
     478             :         case SFX_ALIGN_HIGHESTTOP:
     479           0 :             ret = 5;
     480           0 :             break;
     481             :         case SFX_ALIGN_TOP:
     482           0 :             ret = 6;
     483           0 :             break;
     484             :         case SFX_ALIGN_TOOLBOXTOP:
     485           0 :             ret = 7;
     486           0 :             break;
     487             :         case SFX_ALIGN_LOWESTTOP:
     488           0 :             ret = 8;
     489           0 :             break;
     490             :         case SFX_ALIGN_HIGHESTBOTTOM:
     491           0 :             ret = 9;
     492           0 :             break;
     493             :         case SFX_ALIGN_TOOLBOXBOTTOM:
     494           0 :             ret = 10;
     495           0 :             break;
     496             :         case SFX_ALIGN_BOTTOM:
     497           0 :             ret = 11;
     498           0 :             break;
     499             :         case SFX_ALIGN_LOWESTBOTTOM:
     500           0 :             ret = 12;
     501           0 :             break;
     502             :         case SFX_ALIGN_TOOLBOXRIGHT:
     503           0 :             ret = 13;
     504           0 :             break;
     505             :         case SFX_ALIGN_FIRSTRIGHT:
     506           0 :             ret = 14;
     507           0 :             break;
     508             :         case SFX_ALIGN_RIGHT:
     509           0 :             ret = 15;
     510           0 :             break;
     511             :         case SFX_ALIGN_LASTRIGHT:
     512           0 :             ret = 16;
     513           0 :             break;
     514             :         case SFX_ALIGN_NOALIGNMENT:
     515           0 :             break;  // -Wall not handled.
     516             :     }
     517             : 
     518           0 :     return ret;
     519             : }
     520             : 
     521           0 : void SfxWorkWindow::Sort_Impl()
     522             : {
     523           0 :     aSortedList.clear();
     524           0 :     for (sal_uInt16 i = 0; i < aChildren.size(); ++i)
     525             :     {
     526           0 :         SfxChild_Impl *pCli = aChildren[i];
     527           0 :         if (pCli)
     528             :         {
     529             :             sal_uInt16 k;
     530           0 :             for (k=0; k<aSortedList.size(); k++)
     531           0 :                 if (ChildAlignValue( aChildren[aSortedList[k]]->eAlign ) >
     532           0 :                     ChildAlignValue(pCli->eAlign))
     533           0 :                     break;
     534           0 :             aSortedList.insert( aSortedList.begin() + k, i );
     535             :         }
     536             :     }
     537             : 
     538           0 :     bSorted = true;
     539           0 : }
     540             : 
     541             : 
     542             : 
     543             : // constructor for workwin of a Frame
     544             : 
     545           0 : SfxFrameWorkWin_Impl::SfxFrameWorkWin_Impl( Window *pWin, SfxFrame *pFrm, SfxFrame* pMaster )
     546             :     : SfxWorkWindow(
     547             :         pWin,
     548           0 :         pFrm->GetCurrentViewFrame()->GetBindings(),
     549           0 :         pFrm->GetParentFrame() ? pFrm->GetParentFrame()->GetWorkWindow_Impl() : NULL )
     550             :     , pMasterFrame( pMaster )
     551           0 :     , pFrame( pFrm )
     552             : {
     553           0 :     pConfigShell = pFrm->GetCurrentViewFrame();
     554           0 :     if ( pConfigShell && pConfigShell->GetObjectShell() )
     555             :     {
     556           0 :         bShowStatusBar = ( !pConfigShell->GetObjectShell()->IsInPlaceActive() );
     557           0 :         bDockingAllowed = true;
     558           0 :         bInternalDockingAllowed = true;
     559             :     }
     560             : 
     561             :     // The required split windows (one for each side) can be created
     562           0 :     for ( sal_uInt16 n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
     563             :     {
     564             :         // The SplitWindows excludes direct ChildWindows of the WorkWindows
     565             :         // and receives the docked window.
     566             : 
     567             :         SfxChildAlignment eAlign =
     568             :                         ( n == SFX_SPLITWINDOWS_LEFT ? SFX_ALIGN_LEFT :
     569             :                             n == SFX_SPLITWINDOWS_RIGHT ? SFX_ALIGN_RIGHT :
     570             :                             n == SFX_SPLITWINDOWS_TOP ? SFX_ALIGN_TOP :
     571           0 :                                 SFX_ALIGN_BOTTOM );
     572           0 :         SfxSplitWindow *pSplitWin = new SfxSplitWindow(pWorkWin, eAlign, this, pParent==0 );
     573           0 :         pSplit[n] = pSplitWin;
     574             :     }
     575             : 
     576           0 :     nOrigMode = SFX_VISIBILITY_STANDARD;
     577           0 :     nUpdateMode = SFX_VISIBILITY_STANDARD;
     578           0 : }
     579             : 
     580             : 
     581             : // Constructor of the base class
     582             : 
     583           0 : SfxWorkWindow::SfxWorkWindow( Window *pWin, SfxBindings& rB, SfxWorkWindow* pParentWorkwin ) :
     584             :     pParent( pParentWorkwin ),
     585             :     pBindings(&rB),
     586             :     pWorkWin (pWin),
     587             :     pConfigShell( 0 ),
     588             :     pActiveChild( 0 ),
     589             :     nChildren( 0 ),
     590             :     nOrigMode( 0 ),
     591             :     bSorted( true ),
     592             :     bDockingAllowed(true),
     593             :     bInternalDockingAllowed(true),
     594             :     bAllChildrenVisible(true),
     595             : #if HAVE_FEATURE_DESKTOP
     596             :     bIsFullScreen( false ),
     597             :     bShowStatusBar( true ),
     598             : #else
     599             :     bIsFullScreen( sal_True ),
     600             :     bShowStatusBar( sal_False ),
     601             : #endif
     602             :     m_nLock( 0 ),
     603             :     m_aStatusBarResName( "private:resource/statusbar/statusbar" ),
     604             :     m_aLayoutManagerPropName( "LayoutManager" ),
     605             :     m_aTbxTypeName( "private:resource/toolbar/" ),
     606           0 :     m_aProgressBarResName( "private:resource/progressbar/progressbar" )
     607             : {
     608             :     DBG_ASSERT (pBindings, "No Bindings!");
     609             : 
     610           0 :     pBindings->SetWorkWindow_Impl( this );
     611             : 
     612             :     // For the ObjectBars a integral place in the Childlist is reserved,
     613             :     // so that they always come in a defined order.
     614           0 :     aChildren.insert( aChildren.begin(), SFX_OBJECTBAR_MAX, (SfxChild_Impl*)NULL );
     615             : 
     616             :     // create and initialize layout manager listener
     617           0 :     Reference< com::sun::star::frame::XFrame > xFrame = GetFrameInterface();
     618           0 :     LayoutManagerListener* pLayoutManagerListener = new LayoutManagerListener( this );
     619           0 :     m_xLayoutManagerListener = css::uno::Reference< css::lang::XComponent >(
     620             :                                     static_cast< cppu::OWeakObject* >( pLayoutManagerListener ),
     621           0 :                                         css::uno::UNO_QUERY );
     622           0 :     pLayoutManagerListener->setFrame( xFrame );
     623           0 : }
     624             : 
     625             : 
     626             : // Destructor
     627             : 
     628           0 : SfxWorkWindow::~SfxWorkWindow()
     629             : {
     630             : 
     631             :     // Delete SplitWindows
     632           0 :     for ( sal_uInt16 n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
     633             :     {
     634           0 :         SfxSplitWindow *p = pSplit[n];
     635           0 :         if (p->GetWindowCount())
     636           0 :             ReleaseChild_Impl(*p);
     637           0 :         delete p;
     638             :     }
     639             : 
     640             :     // Delete help structure for Child-Windows
     641             :     DBG_ASSERT( aChildren.empty(), "dangling children" );
     642             : 
     643           0 :     if ( m_xLayoutManagerListener.is() )
     644           0 :         m_xLayoutManagerListener->dispose();
     645           0 : }
     646             : 
     647           0 : void SfxWorkWindow::Lock_Impl( bool bLock )
     648             : {
     649           0 :     if ( bLock )
     650           0 :         m_nLock++;
     651             :     else
     652           0 :         --m_nLock;
     653           0 :     if ( m_nLock<0 )
     654             :     {
     655             :         OSL_FAIL("Lock count underflow!");
     656           0 :         m_nLock = 0;
     657             :     }
     658             : 
     659           0 :     if ( !m_nLock )
     660           0 :         ArrangeChildren_Impl();
     661           0 : }
     662             : 
     663             : 
     664             : // Helper method to release the child lists. Should the destructor not be
     665             : // called after this, instead work continues, then space for the object bars
     666             : // and split windows has to be reserved in the same way as in the constructor
     667             : // of SfxWorkWindow.
     668             : 
     669           0 : void SfxWorkWindow::DeleteControllers_Impl()
     670             : {
     671             : 
     672             :     // Lock SplitWindows (which means supressing the Resize-Reaction of the
     673             :     // DockingWindows)
     674             :     sal_uInt16 n;
     675           0 :     for ( n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
     676             :     {
     677           0 :         SfxSplitWindow *p = pSplit[n];
     678           0 :            if (p->GetWindowCount())
     679           0 :         p->Lock();
     680             :     }
     681             : 
     682             :     // Delete Child-Windows
     683           0 :     for ( n=0; n<aChildWins.size(); )
     684             :     {
     685           0 :         SfxChildWin_Impl* pCW = aChildWins[n];
     686           0 :         aChildWins.erase(aChildWins.begin());
     687           0 :         SfxChildWindow *pChild = pCW->pWin;
     688           0 :         if (pChild)
     689             :         {
     690           0 :             pChild->Hide();
     691             : 
     692             :             // If the child window is a direct child window and not in a
     693             :             // SplitWindow, cancel it at the workwindow.
     694             :             // After TH a cancellation on the SplitWindow is not necessary
     695             :             // since this window is also destroyed (see below).
     696           0 :             if (pCW->pCli)
     697           0 :                 ReleaseChild_Impl(*pChild->GetWindow());
     698           0 :             pCW->pWin = 0;
     699           0 :             pWorkWin->GetSystemWindow()->GetTaskPaneList()->RemoveWindow( pChild->GetWindow() );
     700           0 :             pChild->Destroy();
     701             :         }
     702             : 
     703           0 :         delete pCW;
     704             : 
     705             :         // ATTENTION: The array itself is cleared after this loop!!
     706             :         // Therefore we have to set every array entry to zero as it could be
     707             :         // accessed by calling pChild->Destroy().
     708             :         // Window::NotifyAllChildren() calls SfxWorkWindow::DataChanged_Impl for
     709             :         // 8-bit displays (WM_QUERYPALETTECHANGED message due to focus change)!!
     710             :     }
     711             : 
     712           0 :     Reference< com::sun::star::frame::XFrame > xFrame = GetFrameInterface();
     713           0 :     Reference< com::sun::star::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY );
     714           0 :     Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
     715           0 :     if ( xPropSet.is() )
     716             :     {
     717             :         try
     718             :         {
     719           0 :             Any aValue = xPropSet->getPropertyValue( m_aLayoutManagerPropName );
     720           0 :             aValue >>= xLayoutManager;
     721             :         }
     722           0 :         catch ( Exception& )
     723             :         {
     724             :         }
     725             :     }
     726             : 
     727           0 :     if ( xLayoutManager.is() )
     728             :     {
     729           0 :         xLayoutManager->reset();
     730             : 
     731             :         // Delete StatusBar
     732           0 :         ResetStatusBar_Impl();
     733             : 
     734             :         // Delete ObjectBars (this is done last, so that aChildren does not
     735             :         // receive dead Pointers)
     736           0 :         for ( sal_uInt16 i = 0; i < aObjBarList.size(); i++ )
     737             :         {
     738             :             // Not every position must be occupied
     739           0 :             sal_uInt16 nId = aObjBarList[i].nId;
     740           0 :             if ( nId )
     741           0 :                 aObjBarList[i].nId = 0;
     742             :         }
     743             :     }
     744             : 
     745             :     // ObjectBars are all released at once, since they occupy a
     746             :     // fixed contiguous area in the array pChild
     747           0 :     aChildren.clear();
     748           0 :     bSorted = false;
     749             : 
     750           0 :     nChildren = 0;
     751           0 : }
     752             : 
     753             : 
     754             : // Virtual method for placing the child window.
     755             : 
     756           0 : void SfxWorkWindow::ArrangeChildren_Impl( sal_Bool /*bForce*/)
     757             : {
     758           0 :     Arrange_Impl();
     759           0 : }
     760             : 
     761           0 : void SfxFrameWorkWin_Impl::ArrangeChildren_Impl( sal_Bool bForce )
     762             : {
     763           0 :     if ( pFrame->IsClosing_Impl() || ( m_nLock && !bForce ))
     764           0 :         return;
     765             : 
     766           0 :     SfxInPlaceClient *pClient = 0;
     767           0 :     SfxViewFrame *pF = pFrame->GetCurrentViewFrame();
     768           0 :     if ( pF && pF->GetViewShell() )
     769           0 :         pClient = pF->GetViewShell()->GetIPClient();
     770             : 
     771           0 :     if ( pClient )
     772           0 :         return;
     773             : 
     774           0 :     aClientArea = GetTopRect_Impl();
     775           0 :     if ( aClientArea.IsEmpty() )
     776           0 :         return;
     777             : 
     778           0 :     SvBorder aBorder;
     779           0 :     if ( nChildren )
     780             :     {
     781           0 :         if ( IsVisible_Impl() )
     782           0 :             aBorder = Arrange_Impl();
     783             :     }
     784             :     // If the current application document contains a IPClient, then the
     785             :     // object through SetTopToolFramePixel has to be assigned the available
     786             :     // space. The object will then point to its UITools and sets the app border
     787             :     // (-> SfxInPlaceEnv_Impl:: ArrangeChildren_Impl ()). Otherwise the
     788             :     // app border is set here directly to possibly overwrite the Border that
     789             :     // was set by an object from another document.  The object does not set
     790             :     // the SetAppBorder when it removes its UI tools so that no-dithering
     791             :     // ObjectBar arises.
     792             :     // (->SfxInPlaceEnv_Impl::ArrangeChildren_Impl())
     793             : 
     794           0 :     pMasterFrame->SetToolSpaceBorderPixel_Impl( aBorder );
     795             : 
     796           0 :     ArrangeAutoHideWindows( NULL );
     797             : }
     798             : 
     799             : 
     800             : 
     801           0 : SvBorder SfxWorkWindow::Arrange_Impl()
     802             : 
     803             : /*  [Description]
     804             : 
     805             :     This method organizes all visible child windows so that the docked window
     806             :     sorted in order from the outside to the inside are placed after one
     807             :     another. If a visible window does not fit anymore into the free
     808             :     ClientArea, it is set to "not visible".
     809             : */
     810             : {
     811             : 
     812           0 :     aClientArea = GetTopRect_Impl();
     813           0 :     aUpperClientArea = aClientArea;
     814             : 
     815           0 :     SvBorder aBorder;
     816           0 :     if ( !nChildren )
     817           0 :         return aBorder;
     818             : 
     819           0 :     if (!bSorted)
     820           0 :         Sort_Impl();
     821             : 
     822           0 :     Point aPos;
     823           0 :     Size aSize;
     824           0 :     Rectangle aTmp( aClientArea );
     825             : 
     826           0 :     for ( sal_uInt16 n=0; n<aSortedList.size(); ++n )
     827             :     {
     828           0 :         SfxChild_Impl* pCli = aChildren[aSortedList[n]];
     829           0 :         if ( !pCli->pWin )
     830           0 :             continue;
     831             : 
     832             :         // First, we assume that there is room for the window.
     833           0 :         pCli->nVisible |= CHILD_FITS_IN;
     834             : 
     835             :         // Skip invisiable windows
     836           0 :         if (pCli->nVisible != CHILD_VISIBLE)
     837           0 :             continue;
     838             : 
     839           0 :         if ( pCli->bResize )
     840           0 :             aSize = pCli->aSize;
     841             :         else
     842           0 :             aSize = pCli->pWin->GetSizePixel();
     843             : 
     844           0 :         SvBorder aTemp = aBorder;
     845           0 :         bool bAllowHiding = true;
     846           0 :         switch ( pCli->eAlign )
     847             :         {
     848             :             case SFX_ALIGN_HIGHESTTOP:
     849             :             case SFX_ALIGN_TOP:
     850             :             case SFX_ALIGN_TOOLBOXTOP:
     851             :             case SFX_ALIGN_LOWESTTOP:
     852           0 :                 aSize.Width() = aTmp.GetWidth();
     853           0 :                 if ( pCli->pWin->GetType() == WINDOW_SPLITWINDOW )
     854           0 :                     aSize = ((SplitWindow *)(pCli->pWin))->CalcLayoutSizePixel( aSize );
     855           0 :                 bAllowHiding = false;
     856           0 :                 aBorder.Top() += aSize.Height();
     857           0 :                 aPos = aTmp.TopLeft();
     858           0 :                 aTmp.Top() += aSize.Height();
     859           0 :                 if ( pCli->eAlign == SFX_ALIGN_HIGHESTTOP )
     860           0 :                     aUpperClientArea.Top() += aSize.Height();
     861           0 :                 break;
     862             : 
     863             :             case SFX_ALIGN_LOWESTBOTTOM:
     864             :             case SFX_ALIGN_BOTTOM:
     865             :             case SFX_ALIGN_TOOLBOXBOTTOM:
     866             :             case SFX_ALIGN_HIGHESTBOTTOM:
     867           0 :                 aSize.Width() = aTmp.GetWidth();
     868           0 :                 if ( pCli->pWin->GetType() == WINDOW_SPLITWINDOW )
     869           0 :                     aSize = ((SplitWindow *)(pCli->pWin))->CalcLayoutSizePixel( aSize );
     870           0 :                 aBorder.Bottom() += aSize.Height();
     871           0 :                 aPos = aTmp.BottomLeft();
     872           0 :                 aPos.Y() -= (aSize.Height()-1);
     873           0 :                 aTmp.Bottom() -= aSize.Height();
     874           0 :                 if ( pCli->eAlign == SFX_ALIGN_LOWESTBOTTOM )
     875           0 :                     aUpperClientArea.Bottom() -= aSize.Height();
     876           0 :                 break;
     877             : 
     878             :             case SFX_ALIGN_FIRSTLEFT:
     879             :             case SFX_ALIGN_LEFT:
     880             :             case SFX_ALIGN_LASTLEFT:
     881             :             case SFX_ALIGN_TOOLBOXLEFT:
     882           0 :                 aSize.Height() = aTmp.GetHeight();
     883           0 :                 if ( pCli->pWin->GetType() == WINDOW_SPLITWINDOW )
     884           0 :                     aSize = ((SplitWindow *)(pCli->pWin))->CalcLayoutSizePixel( aSize );
     885           0 :                 bAllowHiding = false;
     886           0 :                 aBorder.Left() += aSize.Width();
     887           0 :                 aPos = aTmp.TopLeft();
     888           0 :                 aTmp.Left() += aSize.Width();
     889           0 :                 if ( pCli->eAlign != SFX_ALIGN_TOOLBOXLEFT )
     890           0 :                     aUpperClientArea.Left() += aSize.Width();
     891           0 :                 break;
     892             : 
     893             :             case SFX_ALIGN_FIRSTRIGHT:
     894             :             case SFX_ALIGN_RIGHT:
     895             :             case SFX_ALIGN_LASTRIGHT:
     896             :             case SFX_ALIGN_TOOLBOXRIGHT:
     897           0 :                 aSize.Height() = aTmp.GetHeight();
     898           0 :                 if ( pCli->pWin->GetType() == WINDOW_SPLITWINDOW )
     899           0 :                     aSize = ((SplitWindow *)(pCli->pWin))->CalcLayoutSizePixel( aSize );
     900           0 :                 aBorder.Right() += aSize.Width();
     901           0 :                 aPos = aTmp.TopRight();
     902           0 :                 aPos.X() -= (aSize.Width()-1);
     903           0 :                 aTmp.Right() -= aSize.Width();
     904           0 :                 if ( pCli->eAlign != SFX_ALIGN_TOOLBOXRIGHT )
     905           0 :                     aUpperClientArea.Right() -= aSize.Width();
     906           0 :                 break;
     907             : 
     908             :             default:
     909           0 :                 pCli->aSize = pCli->pWin->GetSizePixel();
     910           0 :                 pCli->bResize = false;
     911           0 :                 continue;
     912             :         }
     913             : 
     914           0 :         pCli->pWin->SetPosSizePixel( aPos, aSize );
     915           0 :         pCli->bResize = false;
     916           0 :         pCli->aSize = aSize;
     917           0 :         if( bAllowHiding && !RequestTopToolSpacePixel_Impl( aBorder ) )
     918             :         {
     919           0 :             pCli->nVisible ^= CHILD_FITS_IN;
     920           0 :             aBorder = aTemp;
     921             :         }
     922             :     }
     923             : 
     924           0 :     if ( aClientArea.GetWidth() >= aBorder.Left() + aBorder.Right() )
     925             :     {
     926           0 :         aClientArea.Left() += aBorder.Left();
     927           0 :         aClientArea.Right() -= aBorder.Right();
     928             :     }
     929             :     else
     930             :     {
     931           0 :         aBorder.Left() = aClientArea.Left();
     932           0 :         aBorder.Right() = aClientArea.Right();
     933           0 :         aClientArea.Right() = aClientArea.Left() = aTmp.Left();
     934             :     }
     935             : 
     936           0 :     if ( aClientArea.GetHeight() >= aBorder.Top() + aBorder.Bottom() )
     937             :     {
     938           0 :         aClientArea.Top() += aBorder.Top();
     939           0 :         aClientArea.Bottom() -= aBorder.Bottom();
     940             :     }
     941             :     else
     942             :     {
     943           0 :         aBorder.Top() = aClientArea.Top();
     944           0 :         aBorder.Bottom() = aClientArea.Bottom();
     945           0 :         aClientArea.Top() = aClientArea.Bottom() = aTmp.Top();
     946             :     }
     947             : 
     948           0 :     return IsDockingAllowed() ? aBorder : SvBorder();
     949             : }
     950             : 
     951           0 : bool SfxWorkWindow::PrepareClose_Impl()
     952             : {
     953           0 :     for (sal_uInt16 n=0; n<aChildWins.size(); n++)
     954             :     {
     955           0 :         SfxChildWin_Impl *pCW  = aChildWins[n];
     956           0 :         SfxChildWindow *pChild = pCW->pWin;
     957           0 :         if ( pChild && !pChild->QueryClose() )
     958           0 :             return false;
     959             :     }
     960             : 
     961           0 :     return true;
     962             : }
     963             : 
     964             : 
     965             : 
     966           0 : SfxChild_Impl* SfxWorkWindow::RegisterChild_Impl( Window& rWindow,
     967             :                     SfxChildAlignment eAlign, bool bCanGetFocus )
     968             : {
     969             :     DBG_ASSERT( aChildren.size() < 255, "too many children" );
     970             :     DBG_ASSERT( SfxChildAlignValid(eAlign), "invalid align" );
     971             :     DBG_ASSERT( !FindChild_Impl(rWindow), "child registered more than once" );
     972             : 
     973             : 
     974           0 :     if ( rWindow.GetParent() != pWorkWin )
     975           0 :         rWindow.SetParent( pWorkWin );
     976             : 
     977           0 :     SfxChild_Impl *pChild = new SfxChild_Impl(rWindow, rWindow.GetSizePixel(),
     978           0 :                                     eAlign, rWindow.IsVisible());
     979           0 :     pChild->bCanGetFocus = bCanGetFocus;
     980             : 
     981           0 :     aChildren.push_back(pChild);
     982           0 :     bSorted = false;
     983           0 :     nChildren++;
     984           0 :     return aChildren.back();
     985             : }
     986             : 
     987             : 
     988             : 
     989           0 : void SfxWorkWindow::ReleaseChild_Impl( Window& rWindow )
     990             : {
     991             : 
     992           0 :     SfxChild_Impl *pChild = 0;
     993             :     sal_uInt16 nPos;
     994           0 :     for ( nPos = 0; nPos < aChildren.size(); ++nPos )
     995             :     {
     996           0 :         pChild = aChildren[nPos];
     997           0 :         if ( pChild && pChild->pWin == &rWindow )
     998           0 :             break;
     999             :     }
    1000             : 
    1001           0 :     if ( nPos < aChildren.size() )
    1002             :     {
    1003           0 :         bSorted = false;
    1004           0 :         nChildren--;
    1005           0 :         aChildren.erase(aChildren.begin() + nPos);
    1006           0 :         delete pChild;
    1007             :     }
    1008             :     else {
    1009             :         OSL_FAIL( "releasing unregistered child" );
    1010             :     }
    1011           0 : }
    1012             : 
    1013             : 
    1014             : 
    1015           0 : SfxChild_Impl* SfxWorkWindow::FindChild_Impl( const Window& rWindow ) const
    1016             : {
    1017             : 
    1018           0 :     SfxChild_Impl *pChild = 0;
    1019           0 :     sal_uInt16 nCount = aChildren.size();
    1020           0 :     for ( sal_uInt16 nPos = 0; nPos < nCount; ++nPos )
    1021             :     {
    1022           0 :         pChild = aChildren[nPos];
    1023           0 :         if ( pChild && pChild->pWin == &rWindow )
    1024           0 :             return pChild;
    1025             :     }
    1026             : 
    1027           0 :     return 0;
    1028             : }
    1029             : 
    1030             : 
    1031             : 
    1032           0 : void SfxWorkWindow::ShowChildren_Impl()
    1033             : {
    1034             : 
    1035           0 :     bool bInvisible = ( !IsVisible_Impl() || ( !pWorkWin->IsReallyVisible() && !pWorkWin->IsReallyShown() ));
    1036             : 
    1037           0 :     for ( sal_uInt16 nPos = 0; nPos < aChildren.size(); ++nPos )
    1038             :     {
    1039           0 :         SfxChildWin_Impl* pCW = 0;
    1040           0 :         SfxChild_Impl *pCli = aChildren[nPos];
    1041             : 
    1042           0 :         if ( pCli && pCli->pWin )
    1043             :         {
    1044             :             // We have to find the SfxChildWin_Impl to retrieve the
    1045             :             // SFX_CHILDWIN flags that can influence visibility.
    1046           0 :             for (sal_uInt16 n=0; n<aChildWins.size(); n++)
    1047             :             {
    1048           0 :                 SfxChildWin_Impl* pCWin = aChildWins[n];
    1049           0 :                 SfxChild_Impl*    pChild  = pCWin->pCli;
    1050           0 :                 if ( pChild == pCli )
    1051             :                 {
    1052           0 :                     pCW = pCWin;
    1053           0 :                     break;
    1054             :                 }
    1055             :             }
    1056             : 
    1057           0 :             bool bVisible( !bInvisible );
    1058           0 :             if ( pCW )
    1059             :             {
    1060             :                 // Check flag SFX_CHILDWIN_NEVERHIDE that forces us to show
    1061             :                 // the child window even in situations where no child window is
    1062             :                 // visible.
    1063           0 :                 sal_uInt16 nFlags = pCW->aInfo.nFlags;
    1064           0 :                 bVisible = !bInvisible || (( nFlags & SFX_CHILDWIN_NEVERHIDE ) != 0 );
    1065             :             }
    1066             : 
    1067           0 :             if ( CHILD_VISIBLE == (pCli->nVisible & CHILD_VISIBLE) && bVisible )
    1068             :             {
    1069           0 :                 sal_uInt16 nFlags = pCli->bSetFocus ? 0 : SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE;
    1070           0 :                 switch ( pCli->pWin->GetType() )
    1071             :                 {
    1072             :                     case RSC_DOCKINGWINDOW :
    1073           0 :                         ((DockingWindow*)pCli->pWin)->Show( true, nFlags );
    1074           0 :                         break;
    1075             :                     case RSC_SPLITWINDOW :
    1076           0 :                         ((SplitWindow*)pCli->pWin)->Show( true, nFlags );
    1077           0 :                         break;
    1078             :                     default:
    1079           0 :                         pCli->pWin->Show( true, nFlags );
    1080           0 :                         break;
    1081             :                 }
    1082             : 
    1083           0 :                 pCli->bSetFocus = false;
    1084             :             }
    1085             :             else
    1086             :             {
    1087           0 :                 switch ( pCli->pWin->GetType() )
    1088             :                 {
    1089             :                     case RSC_DOCKINGWINDOW :
    1090           0 :                         ((DockingWindow*)pCli->pWin)->Hide();
    1091           0 :                         break;
    1092             :                     default:
    1093           0 :                         pCli->pWin->Hide();
    1094           0 :                         break;
    1095             :                 }
    1096             :             }
    1097             :         }
    1098             :     }
    1099           0 : }
    1100             : 
    1101             : 
    1102             : 
    1103           0 : void SfxWorkWindow::HideChildren_Impl()
    1104             : {
    1105           0 :     for ( sal_uInt16 nPos = aChildren.size(); nPos > 0; --nPos )
    1106             :     {
    1107           0 :         SfxChild_Impl *pChild = aChildren[nPos-1];
    1108           0 :         if (pChild && pChild->pWin)
    1109             :         {
    1110           0 :             switch ( pChild->pWin->GetType() )
    1111             :             {
    1112             :                 case RSC_DOCKINGWINDOW :
    1113           0 :                     ((DockingWindow*)pChild->pWin)->Hide();
    1114           0 :                     break;
    1115             :                 default:
    1116           0 :                     pChild->pWin->Hide();
    1117           0 :                     break;
    1118             :             }
    1119             :         }
    1120             :     }
    1121           0 : }
    1122             : 
    1123             : 
    1124             : 
    1125           0 : void SfxWorkWindow::ResetObjectBars_Impl()
    1126             : {
    1127             :     sal_uInt16 n;
    1128           0 :     for ( n = 0; n < aObjBarList.size(); n++ )
    1129           0 :         aObjBarList[n].bDestroy = true;
    1130             : 
    1131           0 :     for ( n = 0; n < aChildWins.size(); ++n )
    1132           0 :         aChildWins[n]->nId = 0;
    1133           0 : }
    1134             : 
    1135             : 
    1136             : 
    1137           0 : void SfxWorkWindow::SetObjectBar_Impl( sal_uInt16 nPos, sal_uInt32 nResId,
    1138             :             SfxInterface* pIFace, const OUString *pName)
    1139             : {
    1140             :     DBG_ASSERT( (nPos & SFX_POSITION_MASK) < SFX_OBJECTBAR_MAX,
    1141             :                 "object bar position overflow" );
    1142             : 
    1143           0 :     sal_uInt16 nRealPos = nPos & SFX_POSITION_MASK;
    1144           0 :     if ( pParent && IsAppWorkWinToolbox_Impl( nRealPos ) )
    1145             :     {
    1146           0 :         pParent->SetObjectBar_Impl( nPos, nResId, pIFace, pName );
    1147           0 :         return;
    1148             :     }
    1149             : 
    1150           0 :     SfxObjectBar_Impl aObjBar;
    1151           0 :     aObjBar.pIFace = pIFace;
    1152           0 :     aObjBar.nId = sal::static_int_cast<sal_uInt16>(nResId);
    1153           0 :     aObjBar.nPos = nRealPos;
    1154           0 :     aObjBar.nMode = (nPos & SFX_VISIBILITY_MASK);
    1155           0 :     if (pName)
    1156           0 :         aObjBar.aName = *pName;
    1157             :     else
    1158           0 :         aObjBar.aName = "";
    1159             : 
    1160           0 :     for ( sal_uInt16 n=0; n<aObjBarList.size(); n++ )
    1161             :     {
    1162           0 :         if ( aObjBarList[n].nId == aObjBar.nId )
    1163             :         {
    1164           0 :             aObjBarList[n] = aObjBar;
    1165           0 :             return;
    1166             :         }
    1167             :     }
    1168             : 
    1169           0 :     aObjBarList.push_back( aObjBar );
    1170             : }
    1171             : 
    1172             : 
    1173             : 
    1174           0 : bool SfxWorkWindow::KnowsObjectBar_Impl( sal_uInt16 nPos ) const
    1175             : 
    1176             : /*  [Description]
    1177             : 
    1178             :     Determines if a object list is available at the position in question.
    1179             :     This is independent for the fact whether it is actually turned on or off.
    1180             : */
    1181             : 
    1182             : {
    1183           0 :     sal_uInt16 nRealPos = nPos & SFX_POSITION_MASK;
    1184           0 :     if ( pParent && IsAppWorkWinToolbox_Impl( nRealPos ) )
    1185           0 :         return pParent->KnowsObjectBar_Impl( nPos );
    1186             : 
    1187           0 :     for ( sal_uInt16 n=0; n<aObjBarList.size(); n++ )
    1188             :     {
    1189           0 :         if ( aObjBarList[n].nPos == nRealPos )
    1190           0 :             return true;
    1191             :     }
    1192             : 
    1193           0 :     return false;
    1194             : }
    1195             : 
    1196             : 
    1197             : 
    1198           0 : bool SfxWorkWindow::IsVisible_Impl( sal_uInt16 nMode ) const
    1199             : {
    1200           0 :     switch( nUpdateMode )
    1201             :     {
    1202             :         case SFX_VISIBILITY_STANDARD:
    1203           0 :             return true;
    1204             :         case SFX_VISIBILITY_UNVISIBLE:
    1205           0 :             return false;
    1206             :         case SFX_VISIBILITY_CLIENT:
    1207             :         case SFX_VISIBILITY_SERVER:
    1208           0 :             return !!(nMode & nUpdateMode);
    1209             :         default:
    1210           0 :             return !!(nMode & nOrigMode ) ||
    1211           0 :                 nOrigMode == SFX_VISIBILITY_STANDARD;
    1212             :     }
    1213             : }
    1214             : 
    1215           0 : void SfxFrameWorkWin_Impl::UpdateObjectBars_Impl()
    1216             : {
    1217           0 :     if ( pFrame->IsClosing_Impl() )
    1218           0 :         return;
    1219             : 
    1220           0 :     SfxWorkWindow *pWork = pParent;
    1221           0 :     while ( pWork )
    1222             :     {
    1223           0 :         pWork->SfxWorkWindow::UpdateObjectBars_Impl();
    1224           0 :         pWork = pWork->GetParent_Impl();
    1225             :     }
    1226             : 
    1227           0 :     SfxWorkWindow::UpdateObjectBars_Impl();
    1228             : 
    1229             :     {
    1230           0 :         pWork = pParent;
    1231           0 :         while ( pWork )
    1232             :         {
    1233           0 :             pWork->ArrangeChildren_Impl();
    1234           0 :             pWork = pWork->GetParent_Impl();
    1235             :         }
    1236             : 
    1237           0 :         ArrangeChildren_Impl( sal_False );
    1238             : 
    1239           0 :         pWork = pParent;
    1240           0 :         while ( pWork )
    1241             :         {
    1242           0 :             pWork->ShowChildren_Impl();
    1243           0 :             pWork = pWork->GetParent_Impl();
    1244             :         }
    1245             : 
    1246           0 :         ShowChildren_Impl();
    1247             :     }
    1248             : 
    1249           0 :     ShowChildren_Impl();
    1250             : }
    1251             : 
    1252           0 : Reference< ::com::sun::star::task::XStatusIndicator > SfxWorkWindow::GetStatusIndicator()
    1253             : {
    1254           0 :     Reference< com::sun::star::beans::XPropertySet > xPropSet( GetFrameInterface(), UNO_QUERY );
    1255           0 :     Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
    1256           0 :     Reference< com::sun::star::task::XStatusIndicator > xStatusIndicator;
    1257             : 
    1258           0 :     if ( xPropSet.is() )
    1259             :     {
    1260           0 :         Any aValue = xPropSet->getPropertyValue( m_aLayoutManagerPropName );
    1261           0 :         aValue >>= xLayoutManager;
    1262           0 :         if ( xLayoutManager.is() )
    1263             :         {
    1264           0 :             xLayoutManager->createElement( m_aProgressBarResName );
    1265           0 :             xLayoutManager->showElement( m_aProgressBarResName );
    1266             : 
    1267             :             Reference< ::com::sun::star::ui::XUIElement > xProgressBar =
    1268           0 :                 xLayoutManager->getElement( m_aProgressBarResName );
    1269           0 :             if ( xProgressBar.is() )
    1270             :             {
    1271           0 :                 xStatusIndicator = Reference< ::com::sun::star::task::XStatusIndicator >(
    1272           0 :                     xProgressBar->getRealInterface(), UNO_QUERY );
    1273           0 :             }
    1274           0 :         }
    1275             :     }
    1276             : 
    1277           0 :     return xStatusIndicator;
    1278             : }
    1279             : 
    1280             : 
    1281             : 
    1282           0 : bool SfxWorkWindow::IsPluginMode( SfxObjectShell* pObjShell )
    1283             : {
    1284           0 :     if ( pObjShell && pObjShell->GetMedium() )
    1285             :     {
    1286           0 :         SFX_ITEMSET_ARG( pObjShell->GetMedium()->GetItemSet(), pViewOnlyItem, SfxBoolItem, SID_VIEWONLY, false );
    1287           0 :         if ( pViewOnlyItem && pViewOnlyItem->GetValue() )
    1288           0 :             return true;
    1289             :     }
    1290             : 
    1291           0 :     return false;
    1292             : }
    1293             : 
    1294             : 
    1295             : 
    1296           0 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > SfxWorkWindow::GetFrameInterface()
    1297             : {
    1298           0 :     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame;
    1299             : 
    1300           0 :     SfxDispatcher* pDispatcher( GetBindings().GetDispatcher() );
    1301           0 :     if ( pDispatcher )
    1302             :     {
    1303           0 :         SfxViewFrame* pFrame = pDispatcher->GetFrame();
    1304           0 :         if ( pFrame )
    1305           0 :            xFrame = pFrame->GetFrame().GetFrameInterface();
    1306             :     }
    1307             : 
    1308           0 :     return xFrame;
    1309             : }
    1310             : 
    1311             : 
    1312             : 
    1313           0 : void SfxWorkWindow::UpdateObjectBars_Impl()
    1314             : {
    1315             :     // Lock SplitWindows (which means supressing the Resize-Reaction of the
    1316             :     // DockingWindows)
    1317             :     sal_uInt16 n;
    1318           0 :     for ( n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
    1319             :     {
    1320           0 :         SfxSplitWindow *p = pSplit[n];
    1321           0 :         if (p->GetWindowCount())
    1322           0 :             p->Lock();
    1323             :     }
    1324             : 
    1325             :     // you realize what is needed often (saves Code and execution time)
    1326           0 :     SFX_APP();
    1327             : 
    1328           0 :     Reference< com::sun::star::beans::XPropertySet > xPropSet( GetFrameInterface(), UNO_QUERY );
    1329           0 :     Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
    1330             : 
    1331           0 :     if ( xPropSet.is() )
    1332             :     {
    1333           0 :         Any aValue = xPropSet->getPropertyValue( m_aLayoutManagerPropName );
    1334           0 :         aValue >>= xLayoutManager;
    1335             :     }
    1336             : 
    1337           0 :     if ( !xLayoutManager.is() )
    1338           0 :         return;
    1339             : 
    1340           0 :     bool       bPluginMode( false );
    1341           0 :     SfxDispatcher* pDispatcher( GetBindings().GetDispatcher() );
    1342             : 
    1343           0 :     if ( pDispatcher )
    1344             :     {
    1345           0 :         SfxViewFrame* pFrame = pDispatcher->GetFrame();
    1346           0 :         if ( pFrame )
    1347           0 :            bPluginMode = IsPluginMode( pFrame->GetObjectShell() );
    1348             :     }
    1349             : 
    1350             :     // Iterate over all Toolboxes
    1351           0 :     xLayoutManager->lock();
    1352           0 :     for ( n = 0; n < aObjBarList.size(); ++n )
    1353             :     {
    1354           0 :         sal_uInt16      nId      = aObjBarList[n].nId;
    1355           0 :         bool    bDestroy = aObjBarList[n].bDestroy;
    1356             : 
    1357             :         // Determine the vaild mode for the ToolBox
    1358           0 :         sal_uInt16 nTbxMode = aObjBarList[n].nMode;
    1359             :         bool bFullScreenTbx = SFX_VISIBILITY_FULLSCREEN ==
    1360           0 :                                   ( nTbxMode & SFX_VISIBILITY_FULLSCREEN );
    1361           0 :         nTbxMode &= ~SFX_VISIBILITY_FULLSCREEN;
    1362           0 :         nTbxMode &= ~SFX_VISIBILITY_VIEWER;
    1363             : 
    1364             :         // Is a ToolBox required in this context ?
    1365           0 :         bool bModesMatching = ( nUpdateMode && ( nTbxMode & nUpdateMode) == nUpdateMode );
    1366           0 :         if ( bDestroy )
    1367             :         {
    1368           0 :             OUString aTbxId( m_aTbxTypeName );
    1369           0 :             aTbxId += GetResourceURLFromResId( aObjBarList[n].nId );
    1370           0 :             xLayoutManager->destroyElement( aTbxId );
    1371             :         }
    1372           0 :         else if ( nId != 0 && ( ( bModesMatching && !bIsFullScreen ) ||
    1373           0 :                                 ( bIsFullScreen && bFullScreenTbx ) ) )
    1374             :         {
    1375           0 :             OUString aTbxId( m_aTbxTypeName );
    1376           0 :             aTbxId += GetResourceURLFromResId( aObjBarList[n].nId );
    1377           0 :             if ( !IsDockingAllowed() && !xLayoutManager->isElementFloating( aTbxId ))
    1378           0 :                 xLayoutManager->destroyElement( aTbxId );
    1379             :             else
    1380             :             {
    1381           0 :                 xLayoutManager->requestElement( aTbxId );
    1382           0 :                 if ( bPluginMode )
    1383           0 :                     xLayoutManager->lockWindow( aTbxId );
    1384           0 :             }
    1385             :         }
    1386           0 :         else if ( nId != 0 )
    1387             :         {
    1388             :             // Delete the Toolbox at this Position if possible
    1389           0 :             OUString aTbxId( m_aTbxTypeName );
    1390           0 :             aTbxId += GetResourceURLFromResId( aObjBarList[n].nId );
    1391           0 :             xLayoutManager->destroyElement( aTbxId );
    1392             :         }
    1393             :     }
    1394             : 
    1395           0 :     UpdateStatusBar_Impl();
    1396             : 
    1397             :     // unlocking automatically forces Layout
    1398           0 :     xLayoutManager->unlock();
    1399             : 
    1400           0 :     UpdateChildWindows_Impl();
    1401             : 
    1402             :     // Unlock the SplitWindows again
    1403           0 :     for ( n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
    1404             :     {
    1405           0 :         SfxSplitWindow *p = pSplit[n];
    1406           0 :         if (p->GetWindowCount())
    1407           0 :             p->Lock(false);
    1408           0 :     }
    1409             : }
    1410             : 
    1411           0 : bool SfxWorkWindow::AllowChildWindowCreation_Impl( const SfxChildWin_Impl& i_rCW ) const
    1412             : {
    1413             :     // or checking the availability of child windows, we need access to the module
    1414           0 :     const SfxViewFrame* pViewFrame = pBindings->GetDispatcher_Impl()->GetFrame();
    1415           0 :     const SfxObjectShell* pShell = pViewFrame ? pViewFrame->GetObjectShell() : NULL;
    1416           0 :     const SfxModule* pModule = pShell ? pShell->GetModule() : NULL;
    1417           0 :     ENSURE_OR_RETURN( pModule, "SfxWorkWindow::UpdateChildWindows_Impl: did not find an SfxModule to ask for the child win availability!", true );
    1418           0 :     return pModule->IsChildWindowAvailable( i_rCW.nId, pViewFrame );
    1419             : }
    1420             : 
    1421           0 : void SfxWorkWindow::UpdateChildWindows_Impl()
    1422             : {
    1423             :     // any current or in the context available Childwindows
    1424           0 :     for ( sal_uInt16 n=0; n<aChildWins.size(); n++ )
    1425             :     {
    1426           0 :         SfxChildWin_Impl *pCW = aChildWins[n];
    1427           0 :         SfxChildWindow *pChildWin = pCW->pWin;
    1428           0 :         bool bCreate = false;
    1429           0 :         if ( pCW->nId && !pCW->bDisabled  && (pCW->aInfo.nFlags & SFX_CHILDWIN_ALWAYSAVAILABLE || IsVisible_Impl( pCW->nVisibility ) ) )
    1430             :         {
    1431             :             // In the context is an appropriate ChildWindow allowed;
    1432             :             // it is also turned on?
    1433           0 :             if ( pChildWin == NULL && pCW->bCreate )
    1434             :             {
    1435             :                 // Internal docking is only used for embedding into another
    1436             :                 // container. We force the floating state of all floatable
    1437             :                 // child windows.
    1438           0 :                 if ( !bInternalDockingAllowed )
    1439             :                 {
    1440             :                     // Special case for all non-floatable child windows. We have
    1441             :                     // to prevent the creation here!
    1442           0 :                     bCreate = !( pCW->aInfo.nFlags & SFX_CHILDWIN_FORCEDOCK );
    1443             :                 }
    1444           0 :                 else if ( !IsDockingAllowed() || bIsFullScreen ) // || !bInternalDocking )
    1445             :                 {
    1446             :                     // In Presentation mode or FullScreen only FloatingWindows
    1447             :                     SfxChildAlignment eAlign;
    1448           0 :                     if ( pCW->aInfo.GetExtraData_Impl( &eAlign ) )
    1449           0 :                         bCreate = ( eAlign == SFX_ALIGN_NOALIGNMENT );
    1450             :                 }
    1451             :                 else
    1452           0 :                     bCreate = true;
    1453             : 
    1454           0 :                 if ( bCreate )
    1455           0 :                     bCreate = AllowChildWindowCreation_Impl( *pCW );
    1456             : 
    1457             :                 // Currently, no window here, but it is enabled; windows
    1458             :                 // Create window and if possible theContext
    1459           0 :                 if ( bCreate )
    1460           0 :                     CreateChildWin_Impl( pCW, false );
    1461             : 
    1462           0 :                 if ( !bAllChildrenVisible )
    1463             :                 {
    1464           0 :                     if ( pCW->pCli )
    1465           0 :                         pCW->pCli->nVisible &= ~CHILD_ACTIVE;
    1466           0 :                 }
    1467             :             }
    1468           0 :             else if ( pChildWin )
    1469             :             {
    1470             :                 // Window already exists, it should also be visible?
    1471           0 :                 if ( ( !bIsFullScreen || pChildWin->GetAlignment() == SFX_ALIGN_NOALIGNMENT ) && bAllChildrenVisible )
    1472             :                 {
    1473             :                     // Update Mode is compatible; definitely enable it
    1474           0 :                     bCreate = AllowChildWindowCreation_Impl( *pCW );
    1475           0 :                     if ( bCreate )
    1476             :                     {
    1477           0 :                         if ( pCW->pCli )
    1478             :                         {
    1479             :                             // The window is a direct Child
    1480           0 :                             if ( bAllChildrenVisible && ( (IsDockingAllowed() && bInternalDockingAllowed) || pCW->pCli->eAlign == SFX_ALIGN_NOALIGNMENT ) )
    1481           0 :                                 pCW->pCli->nVisible |= CHILD_NOT_HIDDEN;
    1482             :                         }
    1483             :                         else
    1484             :                         {
    1485           0 :                             if ( pCW->bCreate && IsDockingAllowed() && bInternalDockingAllowed )
    1486             :                                 // The window ia within a SplitWindow
    1487           0 :                                 ((SfxDockingWindow*)pChildWin->GetWindow())->Reappear_Impl();
    1488             :                         }
    1489             : 
    1490           0 :                         if ( pCW->nInterfaceId != pChildWin->GetContextId() )
    1491           0 :                             pChildWin->CreateContext( pCW->nInterfaceId, GetBindings() );
    1492             :                     }
    1493             :                 }
    1494             :             }
    1495             :         }
    1496             : 
    1497           0 :         if ( pChildWin && !bCreate )
    1498             :         {
    1499           0 :             if ( !pChildWin->QueryClose() || pChildWin->IsHideNotDelete() || Application::IsUICaptured() )
    1500             :             {
    1501           0 :                 if ( pCW->pCli )
    1502             :                 {
    1503           0 :                     if ( pCW->pCli->nVisible & CHILD_NOT_HIDDEN )
    1504           0 :                         pCW->pCli->nVisible ^= CHILD_NOT_HIDDEN;
    1505             :                 }
    1506             :                 else
    1507           0 :                     ((SfxDockingWindow*)pChildWin->GetWindow())->Disappear_Impl();
    1508             :             }
    1509             :             else
    1510           0 :                 RemoveChildWin_Impl( pCW );
    1511             :         }
    1512             :     }
    1513           0 : }
    1514             : 
    1515           0 : void SfxWorkWindow::CreateChildWin_Impl( SfxChildWin_Impl *pCW, bool bSetFocus )
    1516             : {
    1517           0 :     pCW->aInfo.bVisible = true;
    1518             : 
    1519           0 :     SfxChildWindow *pChildWin = SfxChildWindow::CreateChildWindow( pCW->nId, pWorkWin, &GetBindings(), pCW->aInfo);
    1520           0 :     if (pChildWin)
    1521             :     {
    1522           0 :         if ( bSetFocus )
    1523           0 :             bSetFocus = pChildWin->WantsFocus();
    1524           0 :         pChildWin->SetWorkWindow_Impl( this );
    1525             : 
    1526             :         // At least the extra string is changed during the evaluation,
    1527             :         // also get it anewed
    1528           0 :         SfxChildWinInfo aInfo = pChildWin->GetInfo();
    1529           0 :         pCW->aInfo.aExtraString = aInfo.aExtraString;
    1530           0 :         pCW->aInfo.bVisible = aInfo.bVisible;
    1531           0 :         pCW->aInfo.nFlags |= aInfo.nFlags;
    1532             : 
    1533             :         // The creation was successful
    1534           0 :         GetBindings().Invalidate(pCW->nId);
    1535             : 
    1536           0 :         sal_uInt16 nPos = pChildWin->GetPosition();
    1537           0 :         if (nPos != CHILDWIN_NOPOS)
    1538             :         {
    1539             :             DBG_ASSERT(nPos < SFX_OBJECTBAR_MAX, "Illegal objectbar position!");
    1540           0 :             if ( aChildren[TbxMatch(nPos)] )// &&
    1541             :             {
    1542             :                 // ChildWindow replaces ObjectBar
    1543           0 :                 aChildren[TbxMatch(nPos)]->nVisible ^= CHILD_NOT_HIDDEN;
    1544             :             }
    1545             :         }
    1546             : 
    1547             :         // make childwin keyboard accessible
    1548           0 :         pWorkWin->GetSystemWindow()->GetTaskPaneList()->AddWindow( pChildWin->GetWindow() );
    1549             : 
    1550           0 :         pCW->pWin = pChildWin;
    1551             : 
    1552           0 :         if ( pChildWin->GetAlignment() == SFX_ALIGN_NOALIGNMENT || pChildWin->GetWindow()->GetParent() == pWorkWin)
    1553             :         {
    1554             :             // The window is not docked or docked outside of one split windows
    1555             :             // and must therefore be registered explicitly as a Child
    1556           0 :             pCW->pCli = RegisterChild_Impl(*(pChildWin->GetWindow()), pChildWin->GetAlignment(), pChildWin->CanGetFocus());
    1557           0 :             pCW->pCli->nVisible = CHILD_VISIBLE;
    1558           0 :             if ( pChildWin->GetAlignment() != SFX_ALIGN_NOALIGNMENT && bIsFullScreen )
    1559           0 :                 pCW->pCli->nVisible ^= CHILD_ACTIVE;
    1560           0 :             pCW->pCli->bSetFocus = bSetFocus;
    1561             :         }
    1562             :         else
    1563             :         {
    1564             :             // A docked window which parent is not a WorkingWindow, must lie
    1565             :             // in a SplitWindow and thus not be explicitly registered.
    1566             :             // This happens already in the initialization of SfxDockingWindows!
    1567             :         }
    1568             : 
    1569           0 :         if ( pCW->nInterfaceId != pChildWin->GetContextId() )
    1570           0 :             pChildWin->CreateContext( pCW->nInterfaceId, GetBindings() );
    1571             : 
    1572             :         // Save the information in the INI file
    1573           0 :         SaveStatus_Impl(pChildWin, pCW->aInfo);
    1574             :     }
    1575           0 : }
    1576             : 
    1577           0 : void SfxWorkWindow::RemoveChildWin_Impl( SfxChildWin_Impl *pCW )
    1578             : {
    1579           0 :     sal_uInt16 nId = pCW->nSaveId;
    1580           0 :     SfxChildWindow *pChildWin = pCW->pWin;
    1581             : 
    1582             :     // Save the information in the INI file
    1583           0 :     sal_uInt16 nFlags = pCW->aInfo.nFlags;
    1584           0 :     pCW->aInfo = pChildWin->GetInfo();
    1585           0 :     pCW->aInfo.nFlags |= nFlags;
    1586           0 :     SaveStatus_Impl(pChildWin, pCW->aInfo);
    1587             : 
    1588           0 :     pChildWin->Hide();
    1589             : 
    1590           0 :     if ( pCW->pCli )
    1591             :     {
    1592             :         // Child window is a direct child window and must therefore unregister
    1593             :         // itself from the  WorkWindow
    1594           0 :         pCW->pCli = 0;
    1595           0 :         ReleaseChild_Impl(*pChildWin->GetWindow());
    1596             :     }
    1597             :     else
    1598             :     {
    1599             :         // ChildWindow is within a SplitWindow and unregister itself in
    1600             :         // the destructor.
    1601             :     }
    1602             : 
    1603           0 :     pWorkWin->GetSystemWindow()->GetTaskPaneList()->RemoveWindow( pChildWin->GetWindow() );
    1604           0 :     pCW->pWin = 0;
    1605           0 :     pChildWin->Destroy();
    1606             : 
    1607           0 :     GetBindings().Invalidate( nId );
    1608           0 : }
    1609             : 
    1610           0 : void SfxWorkWindow::ResetStatusBar_Impl()
    1611             : {
    1612           0 :     aStatBar.nId = 0;
    1613           0 : }
    1614             : 
    1615             : 
    1616           0 : void SfxWorkWindow::SetStatusBar_Impl( sal_uInt32 nResId, SfxShell*, SfxBindings& )
    1617             : {
    1618           0 :     if ( nResId && bShowStatusBar && IsVisible_Impl() )
    1619           0 :         aStatBar.nId = sal::static_int_cast<sal_uInt16>(nResId);
    1620           0 : }
    1621             : 
    1622           0 : void SfxWorkWindow::UpdateStatusBar_Impl()
    1623             : {
    1624           0 :     Reference< ::com::sun::star::beans::XPropertySet > xPropSet( GetFrameInterface(), UNO_QUERY );
    1625           0 :     Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
    1626             : 
    1627           0 :     Any aValue = xPropSet->getPropertyValue( m_aLayoutManagerPropName );
    1628           0 :     aValue >>= xLayoutManager;
    1629             : 
    1630             :     // No status bar, if no ID is required or when in FullScreenView or
    1631             :     // if disabled
    1632           0 :     if ( aStatBar.nId && IsDockingAllowed() && bInternalDockingAllowed && bShowStatusBar &&
    1633           0 :          ( (aStatBar.bOn && !bIsFullScreen) || aStatBar.bTemp ) )
    1634             :     {
    1635             :         // Id has changed, thus create a suitable Statusbarmanager, this takes
    1636             :         // over the  current status bar;
    1637           0 :         if ( xLayoutManager.is() )
    1638           0 :             xLayoutManager->requestElement( m_aStatusBarResName );
    1639             :     }
    1640             :     else
    1641             :     {
    1642             :         // Destroy the current StatusBar
    1643             :         // The Manager only creates the Status bar, does not destroy it.
    1644           0 :         if ( xLayoutManager.is() )
    1645           0 :             xLayoutManager->destroyElement( m_aStatusBarResName );
    1646           0 :     }
    1647           0 : }
    1648             : 
    1649           0 : void SfxWorkWindow::MakeVisible_Impl( bool bVis )
    1650             : {
    1651           0 :     if ( bVis )
    1652           0 :         nOrigMode = SFX_VISIBILITY_STANDARD;
    1653             :     else
    1654           0 :         nOrigMode = SFX_VISIBILITY_UNVISIBLE;
    1655             : 
    1656           0 :     if ( nOrigMode != nUpdateMode)
    1657           0 :         nUpdateMode = nOrigMode;
    1658           0 : }
    1659             : 
    1660           0 : bool SfxWorkWindow::IsVisible_Impl()
    1661             : {
    1662           0 :     return nOrigMode != SFX_VISIBILITY_UNVISIBLE;
    1663             : }
    1664             : 
    1665             : 
    1666           0 : void SfxWorkWindow::HidePopups_Impl(bool bHide, bool bParent, sal_uInt16 nId )
    1667             : {
    1668           0 :     for ( sal_uInt16 n = 0; n < aChildWins.size(); ++n )
    1669             :     {
    1670           0 :         SfxChildWindow *pCW = aChildWins[n]->pWin;
    1671           0 :         if (pCW && pCW->GetAlignment() == SFX_ALIGN_NOALIGNMENT && pCW->GetType() != nId)
    1672             :         {
    1673           0 :             Window *pWin = pCW->GetWindow();
    1674           0 :             SfxChild_Impl *pChild = FindChild_Impl(*pWin);
    1675           0 :             if (bHide)
    1676             :             {
    1677           0 :                 pChild->nVisible &= ~CHILD_ACTIVE;
    1678           0 :                 pCW->Hide();
    1679             :             }
    1680             :             else
    1681             :             {
    1682           0 :                 pChild->nVisible |= CHILD_ACTIVE;
    1683           0 :                 if ( CHILD_VISIBLE == (pChild->nVisible & CHILD_VISIBLE) )
    1684           0 :                     pCW->Show( SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
    1685             :             }
    1686             :         }
    1687             :     }
    1688             : 
    1689           0 :     if ( bParent && pParent )
    1690           0 :         pParent->HidePopups_Impl( bHide, bParent, nId );
    1691           0 : }
    1692             : 
    1693             : 
    1694             : 
    1695           0 : void SfxWorkWindow::ConfigChild_Impl(SfxChildIdentifier eChild,
    1696             :             SfxDockingConfig eConfig, sal_uInt16 nId)
    1697             : {
    1698           0 :     SfxDockingWindow* pDockWin=0;
    1699           0 :     sal_uInt16 nPos = USHRT_MAX;
    1700           0 :     Window *pWin=0;
    1701           0 :     SfxChildWin_Impl *pCW = 0;
    1702             : 
    1703           0 :     if ( eChild == SFX_CHILDWIN_OBJECTBAR )
    1704           0 :         return;
    1705             : 
    1706             :     // configure direct childwindow
    1707           0 :     for (sal_uInt16 n=0; n<aChildWins.size(); n++)
    1708             :     {
    1709           0 :         pCW = aChildWins[n];
    1710           0 :         SfxChildWindow *pChild = pCW->pWin;
    1711           0 :         if ( pChild )
    1712             :         {
    1713           0 :             if ( pChild->GetType() == nId )
    1714             :             {
    1715           0 :                 if ( pChild->GetWindow()->GetType() == RSC_DOCKINGWINDOW )
    1716             :                     // it's a DockingWindow
    1717           0 :                     pDockWin = (SfxDockingWindow*) pChild->GetWindow();
    1718             :                 else
    1719             :                     // FloatingWindow or ModelessDialog
    1720           0 :                     pWin = pChild->GetWindow();
    1721           0 :                 break;
    1722             :             }
    1723             :         }
    1724             :     }
    1725             : 
    1726           0 :     if ( pDockWin )
    1727             :     {
    1728           0 :         if ( eChild == SFX_CHILDWIN_DOCKINGWINDOW || pDockWin->GetAlignment() == SFX_ALIGN_NOALIGNMENT )
    1729             :         {
    1730           0 :             if ( eChild == SFX_CHILDWIN_SPLITWINDOW && eConfig == SFX_TOGGLEFLOATMODE)
    1731             :             {
    1732             :                 // DockingWindow was dragged out of a SplitWindow
    1733           0 :                 pCW->pCli = RegisterChild_Impl(*pDockWin, pDockWin->GetAlignment(), pCW->pWin->CanGetFocus());
    1734           0 :                 pCW->pCli->nVisible = CHILD_VISIBLE;
    1735             :             }
    1736             : 
    1737           0 :             pWin = pDockWin;
    1738             :         }
    1739             :         else
    1740             :         {
    1741           0 :             SfxSplitWindow *pSplitWin = GetSplitWindow_Impl(pDockWin->GetAlignment());
    1742             : 
    1743             :             // configure DockingWindow inside a SplitWindow
    1744           0 :             if ( eConfig == SFX_TOGGLEFLOATMODE)
    1745             :             {
    1746             :                 // DockingWindow was dragged into a SplitWindow
    1747           0 :                 pCW->pCli = 0;
    1748           0 :                 ReleaseChild_Impl(*pDockWin);
    1749             :             }
    1750             : 
    1751           0 :             pWin = pSplitWin->GetSplitWindow();
    1752           0 :             if ( pSplitWin->GetWindowCount() == 1 )
    1753           0 :                 ((SplitWindow*)pWin)->Show( true, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
    1754             :         }
    1755             :     }
    1756             : 
    1757             :     DBG_ASSERT( pCW, "Unknown window!" );
    1758           0 :     if ( !pCW && pParent )
    1759             :     {
    1760           0 :         pParent->ConfigChild_Impl( eChild, eConfig, nId );
    1761           0 :         return;
    1762             :     }
    1763             : 
    1764           0 :     if ( !bSorted )
    1765             :         // windows may have been registered and released without an update until now
    1766           0 :         Sort_Impl();
    1767             : 
    1768           0 :     SfxChild_Impl *pChild = 0;
    1769             :     sal_uInt16 n;
    1770           0 :     for ( n=0; n<aSortedList.size(); ++n )
    1771             :     {
    1772           0 :         pChild = aChildren[aSortedList[n]];
    1773           0 :         if ( pChild )
    1774           0 :             if ( pChild->pWin == pWin )
    1775           0 :             break;
    1776             :     }
    1777             : 
    1778           0 :     if ( n < aSortedList.size() )
    1779             :         // sometimes called while toggeling float mode
    1780           0 :         nPos = aSortedList[n];
    1781             : 
    1782           0 :     switch ( eConfig )
    1783             :     {
    1784             :         case SFX_SETDOCKINGRECTS :
    1785             :         {
    1786           0 :             if ( nPos == USHRT_MAX )
    1787           0 :                 return;
    1788             : 
    1789           0 :             Rectangle aOuterRect( GetTopRect_Impl() );
    1790           0 :             aOuterRect.SetPos( pWorkWin->OutputToScreenPixel( aOuterRect.TopLeft() ));
    1791           0 :             Rectangle aInnerRect( aOuterRect );
    1792             : 
    1793             :             // The current affected window is included in the calculation of
    1794             :             // the inner rectangle!
    1795           0 :             for ( sal_uInt16 m=0; m<aSortedList.size(); ++m )
    1796             :             {
    1797           0 :                 sal_uInt16 i=aSortedList[m];
    1798           0 :                 SfxChild_Impl* pCli = aChildren[i];
    1799             : 
    1800           0 :                 if ( pCli && pCli->nVisible == CHILD_VISIBLE && pCli->pWin )
    1801             :                 {
    1802           0 :                     switch ( pCli->eAlign )
    1803             :                     {
    1804             :                         case SFX_ALIGN_TOP:
    1805             :                             // Objekt-Toolboxes come always last
    1806           0 :                                 aInnerRect.Top() += pCli->aSize.Height();
    1807           0 :                             break;
    1808             : 
    1809             :                         case SFX_ALIGN_HIGHESTTOP:
    1810             :                             // Always performed first
    1811           0 :                             aInnerRect.Top() += pCli->aSize.Height();
    1812           0 :                             break;
    1813             : 
    1814             :                         case SFX_ALIGN_LOWESTTOP:
    1815             :                             // Is only counted if it is the current window
    1816           0 :                             if ( i == nPos )
    1817           0 :                                 aInnerRect.Top() += pCli->aSize.Height();
    1818           0 :                             break;
    1819             : 
    1820             :                         case SFX_ALIGN_BOTTOM:
    1821             :                             // Objekt-Toolboxes come always last
    1822           0 :                                 aInnerRect.Bottom() -= pCli->aSize.Height();
    1823           0 :                             break;
    1824             : 
    1825             :                         case SFX_ALIGN_LOWESTBOTTOM:
    1826             :                             // Always performed first
    1827           0 :                             aInnerRect.Bottom() -= pCli->aSize.Height();
    1828           0 :                             break;
    1829             : 
    1830             :                         case SFX_ALIGN_HIGHESTBOTTOM:
    1831             :                             // Is only counted if it is the current window
    1832           0 :                             if ( i == nPos )
    1833           0 :                                 aInnerRect.Bottom() -= pCli->aSize.Height();
    1834           0 :                             break;
    1835             : 
    1836             :                         case SFX_ALIGN_LEFT:
    1837             :                             // Toolboxes come always last
    1838           0 :                                 aInnerRect.Left() += pCli->aSize.Width();
    1839           0 :                             break;
    1840             : 
    1841             :                         case SFX_ALIGN_FIRSTLEFT:
    1842             :                             // Always performed first
    1843           0 :                             aInnerRect.Left() += pCli->aSize.Width();
    1844           0 :                             break;
    1845             : 
    1846             :                         case SFX_ALIGN_LASTLEFT:
    1847             :                             // Is only counted if it is the current window
    1848           0 :                             if (i == nPos)
    1849           0 :                                 aInnerRect.Left() += pCli->aSize.Width();
    1850             : 
    1851             :                         case SFX_ALIGN_RIGHT:
    1852             :                             // Toolboxes come always last
    1853           0 :                                 aInnerRect.Right() -= pCli->aSize.Width();
    1854           0 :                             break;
    1855             : 
    1856             :                         case SFX_ALIGN_FIRSTRIGHT:
    1857             :                             // Is only counted if it is the current window
    1858           0 :                             if (i == nPos)
    1859           0 :                                 aInnerRect.Right() -= pCli->aSize.Width();
    1860           0 :                             break;
    1861             : 
    1862             :                         case SFX_ALIGN_LASTRIGHT:
    1863             :                             // Always performed first
    1864           0 :                             aInnerRect.Right() -= pCli->aSize.Width();
    1865           0 :                             break;
    1866             : 
    1867             :                         default:
    1868           0 :                             break;
    1869             :                     }
    1870             :                 }
    1871             :             }
    1872             : 
    1873           0 :             pDockWin->SetDockingRects(aOuterRect, aInnerRect);
    1874           0 :             break;
    1875             :         }
    1876             : 
    1877             :         case SFX_MOVEDOCKINGWINDOW :
    1878             :         case SFX_ALIGNDOCKINGWINDOW :
    1879             :         case SFX_TOGGLEFLOATMODE:
    1880             :         {
    1881           0 :             if ( nPos == USHRT_MAX && !pCW )
    1882           0 :                 return;
    1883             : 
    1884           0 :             SfxChildAlignment eAlign = SFX_ALIGN_NOALIGNMENT;
    1885           0 :             SfxChild_Impl *pCli = ( nPos != USHRT_MAX ) ? aChildren[nPos] : 0;
    1886           0 :             if ( pCli && pDockWin )
    1887             :             {
    1888           0 :                 eAlign = pDockWin->GetAlignment();
    1889           0 :                 if ( eChild == SFX_CHILDWIN_DOCKINGWINDOW || eAlign == SFX_ALIGN_NOALIGNMENT)
    1890             :                 {
    1891             :                     // configuration inside the SplitWindow, no change for the SplitWindows' configuration
    1892           0 :                     pCli->bResize = true;
    1893           0 :                     pCli->aSize = pDockWin->GetSizePixel();
    1894             :                 }
    1895             :             }
    1896             : 
    1897           0 :             if ( pCli )
    1898             :             {
    1899           0 :                 if( pCli->eAlign != eAlign )
    1900             :                 {
    1901           0 :                     bSorted = false;
    1902           0 :                     pCli->eAlign = eAlign;
    1903             :                 }
    1904             : 
    1905           0 :                 ArrangeChildren_Impl();
    1906           0 :                 ShowChildren_Impl();
    1907             :             }
    1908             : 
    1909           0 :             if ( pCW && pCW->pWin )
    1910             :             {
    1911             :                 // store changed configuration
    1912           0 :                 sal_uInt16 nFlags = pCW->aInfo.nFlags;
    1913           0 :                 pCW->aInfo = pCW->pWin->GetInfo();
    1914           0 :                 pCW->aInfo.nFlags |= nFlags;
    1915           0 :                 if ( eConfig != SFX_MOVEDOCKINGWINDOW )
    1916           0 :                     SaveStatus_Impl( pCW->pWin, pCW->aInfo);
    1917             :             }
    1918             : 
    1919           0 :             break;
    1920             :         }
    1921             :     }
    1922             : }
    1923             : 
    1924             : 
    1925             : 
    1926           0 : void SfxWorkWindow::SetChildWindowVisible_Impl( sal_uInt32 lId, bool bEnabled, sal_uInt16 nMode )
    1927             : {
    1928           0 :     sal_uInt16 nInter = (sal_uInt16) ( lId >> 16 );
    1929           0 :     sal_uInt16 nId = (sal_uInt16) ( lId & 0xFFFF );
    1930             : 
    1931           0 :     SfxChildWin_Impl *pCW=NULL;
    1932           0 :     SfxWorkWindow *pWork = pParent;
    1933             : 
    1934             :     // Get the top parent, child windows are always registered at the
    1935             :     // task of the WorkWindow for example the frame or on AppWorkWindow
    1936           0 :     while ( pWork && pWork->pParent )
    1937           0 :         pWork = pWork->pParent;
    1938             : 
    1939           0 :     if ( pWork )
    1940             :     {
    1941             :         // The Parent already known?
    1942           0 :         sal_uInt16 nCount = pWork->aChildWins.size();
    1943           0 :         for (sal_uInt16 n=0; n<nCount; n++)
    1944           0 :             if (pWork->aChildWins[n]->nSaveId == nId)
    1945             :             {
    1946           0 :                 pCW = pWork->aChildWins[n];
    1947           0 :                 break;
    1948             :             }
    1949             :     }
    1950             : 
    1951           0 :     if ( !pCW )
    1952             :     {
    1953             :         // If no Parent or the Parent us still unknown, then search here
    1954           0 :         sal_uInt16 nCount = aChildWins.size();
    1955           0 :         for (sal_uInt16 n=0; n<nCount; n++)
    1956           0 :             if (aChildWins[n]->nSaveId == nId)
    1957             :             {
    1958           0 :                 pCW = aChildWins[n];
    1959           0 :                 break;
    1960             :             }
    1961             :     }
    1962             : 
    1963           0 :     if ( !pCW )
    1964             :     {
    1965             :         // If new, then initialize, add this here depending on the flag or
    1966             :         // the Parent
    1967           0 :         pCW = new SfxChildWin_Impl( lId );
    1968           0 :         pCW->nId = nId;
    1969           0 :         InitializeChild_Impl( pCW );
    1970           0 :         if ( pWork && !( pCW->aInfo.nFlags & SFX_CHILDWIN_TASK ) )
    1971           0 :             pWork->aChildWins.push_back( pCW );
    1972             :         else
    1973           0 :             aChildWins.push_back( pCW );
    1974             :     }
    1975             : 
    1976           0 :     pCW->nId = nId;
    1977           0 :     if ( nInter )
    1978           0 :         pCW->nInterfaceId = nInter;
    1979           0 :     pCW->nVisibility = nMode;
    1980           0 :     pCW->bEnable = bEnabled;
    1981           0 :     pCW->nVisibility = nMode;
    1982           0 : }
    1983             : 
    1984             : 
    1985             : // The on/off status of a ChildWindow is switched
    1986             : 
    1987           0 : void SfxWorkWindow::ToggleChildWindow_Impl(sal_uInt16 nId, bool bSetFocus)
    1988             : {
    1989           0 :     sal_uInt16 nCount = aChildWins.size();
    1990             :     sal_uInt16 n;
    1991           0 :     for (n=0; n<nCount; n++)
    1992           0 :         if (aChildWins[n]->nId == nId)
    1993           0 :             break;
    1994             : 
    1995           0 :     if ( n<nCount )
    1996             :     {
    1997             :         // The Window is already known
    1998           0 :         SfxChildWin_Impl *pCW = aChildWins[n];
    1999           0 :         SfxChildWindow *pChild = pCW->pWin;
    2000             : 
    2001           0 :         bool bCreationAllowed( true );
    2002           0 :         if ( !bInternalDockingAllowed )
    2003             :         {
    2004             :             // Special case for all non-floatable child windows. We have
    2005             :             // to prevent the creation here!
    2006           0 :             bCreationAllowed = !( pCW->aInfo.nFlags & SFX_CHILDWIN_FORCEDOCK );
    2007             :         }
    2008             : 
    2009           0 :         if ( bCreationAllowed )
    2010             :         {
    2011           0 :             if ( pCW->bCreate )
    2012             :             {
    2013           0 :                 if ( pChild )
    2014             :                 {
    2015           0 :                     if ( pChild->QueryClose() )
    2016             :                     {
    2017           0 :                         pCW->bCreate = false;
    2018           0 :                         if ( pChild->IsHideAtToggle() )
    2019             :                         {
    2020           0 :                             ShowChildWindow_Impl( nId, false, bSetFocus );
    2021             :                         }
    2022             :                         else
    2023             :                         {
    2024             :                             // The Window should be switched off
    2025           0 :                             pChild->SetVisible_Impl( false );
    2026           0 :                             RemoveChildWin_Impl( pCW );
    2027             :                         }
    2028             :                     }
    2029             :                 }
    2030             :                 else
    2031             :                 {
    2032             :                     // no actual Window exists, yet => just remember the "switched off" state
    2033           0 :                     pCW->bCreate = false;
    2034             :                 }
    2035             :             }
    2036             :             else
    2037             :             {
    2038           0 :                 pCW->bCreate = AllowChildWindowCreation_Impl( *pCW );
    2039           0 :                 if ( pCW->bCreate )
    2040             :                 {
    2041           0 :                     if ( pChild )
    2042             :                     {
    2043           0 :                         ShowChildWindow_Impl( nId, true, bSetFocus );
    2044             :                     }
    2045             :                     else
    2046             :                     {
    2047             :                         // create actual Window
    2048           0 :                         CreateChildWin_Impl( pCW, bSetFocus );
    2049           0 :                         if ( !pCW->pWin )
    2050             :                             // no success
    2051           0 :                             pCW->bCreate = false;
    2052             :                     }
    2053             :                 }
    2054             :             }
    2055             :         }
    2056             : 
    2057           0 :         ArrangeChildren_Impl();
    2058           0 :         ShowChildren_Impl();
    2059             : 
    2060           0 :         if ( pCW->bCreate && bCreationAllowed )
    2061             :         {
    2062           0 :             if ( !pCW->pCli )
    2063             :             {
    2064             :                 SfxDockingWindow *pDock =
    2065           0 :                     (SfxDockingWindow*) pCW->pWin->GetWindow();
    2066           0 :                 if ( pDock->IsAutoHide_Impl() )
    2067           0 :                     pDock->AutoShow_Impl();
    2068             :             }
    2069             :         }
    2070             : 
    2071           0 :         return;
    2072             :     }
    2073           0 :     else if ( pParent )
    2074             :     {
    2075           0 :         pParent->ToggleChildWindow_Impl( nId, bSetFocus );
    2076           0 :         return;
    2077             :     }
    2078             : 
    2079             : #ifdef DBG_UTIL
    2080             :     nCount = aChildWins.size();
    2081             :     for (n=0; n<nCount; n++)
    2082             :         if (aChildWins[n]->nSaveId == nId)
    2083             :             break;
    2084             : 
    2085             :     if ( n < nCount )
    2086             :     {
    2087             :         OSL_FAIL("The ChildWindow is not in context!");
    2088             :     }
    2089             :     else
    2090             :     {
    2091             :         OSL_FAIL("The ChildWindow is not registered!");
    2092             :     }
    2093             : #endif
    2094             : }
    2095             : 
    2096             : 
    2097             : 
    2098           0 : bool SfxWorkWindow::HasChildWindow_Impl(sal_uInt16 nId)
    2099             : {
    2100           0 :     sal_uInt16 nCount = aChildWins.size();
    2101             :     sal_uInt16 n;
    2102           0 :     for (n=0; n<nCount; n++)
    2103           0 :         if (aChildWins[n]->nSaveId == nId)
    2104           0 :             break;
    2105             : 
    2106           0 :     if (n<nCount)
    2107             :     {
    2108           0 :         SfxChildWin_Impl *pCW = aChildWins[n];
    2109           0 :         SfxChildWindow *pChild = pCW->pWin;
    2110           0 :         return ( pChild && pCW->bCreate );
    2111             :     }
    2112             : 
    2113           0 :     if ( pParent )
    2114           0 :         return pParent->HasChildWindow_Impl( nId );
    2115             : 
    2116           0 :     return false;
    2117             : }
    2118             : 
    2119           0 : bool SfxWorkWindow::IsFloating( sal_uInt16 nId )
    2120             : {
    2121           0 :     SfxChildWin_Impl *pCW=NULL;
    2122           0 :     SfxWorkWindow *pWork = pParent;
    2123             : 
    2124             :     // Get the top parent, child windows are always registered at the
    2125             :     // task of the WorkWindow for example the frame or on AppWorkWindow
    2126           0 :     while ( pWork && pWork->pParent )
    2127           0 :         pWork = pWork->pParent;
    2128             : 
    2129           0 :     if ( pWork )
    2130             :     {
    2131             :         // The Parent already known?
    2132           0 :         sal_uInt16 nCount = pWork->aChildWins.size();
    2133           0 :         for (sal_uInt16 n=0; n<nCount; n++)
    2134           0 :             if (pWork->aChildWins[n]->nSaveId == nId)
    2135             :             {
    2136           0 :                 pCW = pWork->aChildWins[n];
    2137           0 :                 break;
    2138             :             }
    2139             :     }
    2140             : 
    2141           0 :     if ( !pCW )
    2142             :     {
    2143             :         // If no Parent or the Parent us still unknown, then search here
    2144           0 :         sal_uInt16 nCount = aChildWins.size();
    2145           0 :         for (sal_uInt16 n=0; n<nCount; n++)
    2146           0 :             if (aChildWins[n]->nSaveId == nId)
    2147             :             {
    2148           0 :                 pCW = aChildWins[n];
    2149           0 :                 break;
    2150             :             }
    2151             :     }
    2152             : 
    2153           0 :     if ( !pCW )
    2154             :     {
    2155             :         // If new, then initialize, add this here depending on the flag or
    2156             :         // the Parent
    2157           0 :         pCW = new SfxChildWin_Impl( nId );
    2158           0 :         pCW->bEnable = false;
    2159           0 :         pCW->nId = 0;
    2160           0 :         pCW->nVisibility = 0;
    2161           0 :         InitializeChild_Impl( pCW );
    2162           0 :         if ( pWork && !( pCW->aInfo.nFlags & SFX_CHILDWIN_TASK ) )
    2163           0 :             pWork->aChildWins.push_back( pCW );
    2164             :         else
    2165           0 :             aChildWins.push_back( pCW );
    2166             :     }
    2167             : 
    2168             :     SfxChildAlignment eAlign;
    2169           0 :     if ( pCW->aInfo.GetExtraData_Impl( &eAlign ) )
    2170           0 :         return( eAlign == SFX_ALIGN_NOALIGNMENT );
    2171             :     else
    2172           0 :         return true;
    2173             : }
    2174             : 
    2175             : 
    2176             : 
    2177           0 : bool SfxWorkWindow::KnowsChildWindow_Impl(sal_uInt16 nId)
    2178             : {
    2179           0 :     SfxChildWin_Impl *pCW=0;
    2180           0 :     sal_uInt16 nCount = aChildWins.size();
    2181             :     sal_uInt16 n;
    2182           0 :     for (n=0; n<nCount; n++)
    2183             :     {
    2184           0 :         pCW = aChildWins[n];
    2185           0 :         if ( pCW->nSaveId == nId)
    2186           0 :              break;
    2187             :     }
    2188             : 
    2189           0 :     if (n<nCount)
    2190             :     {
    2191           0 :         if ( !(pCW->aInfo.nFlags & SFX_CHILDWIN_ALWAYSAVAILABLE) && !IsVisible_Impl(  pCW->nVisibility ) )
    2192           0 :             return false;
    2193           0 :         return pCW->bEnable;
    2194             :     }
    2195           0 :     else if ( pParent )
    2196           0 :         return pParent->KnowsChildWindow_Impl( nId );
    2197             :     else
    2198           0 :         return false;
    2199             : }
    2200             : 
    2201             : 
    2202             : 
    2203           0 : void SfxWorkWindow::SetChildWindow_Impl(sal_uInt16 nId, bool bOn, bool bSetFocus)
    2204             : {
    2205           0 :     SfxChildWin_Impl *pCW=NULL;
    2206           0 :     SfxWorkWindow *pWork = pParent;
    2207             : 
    2208             :     // Get the top parent, child windows are always registered at the
    2209             :     // task of the WorkWindow for example the frame or on AppWorkWindow
    2210           0 :     while ( pWork && pWork->pParent )
    2211           0 :         pWork = pWork->pParent;
    2212             : 
    2213           0 :     if ( pWork )
    2214             :     {
    2215             :         // The Parent already known?
    2216           0 :         sal_uInt16 nCount = pWork->aChildWins.size();
    2217           0 :         for (sal_uInt16 n=0; n<nCount; n++)
    2218           0 :             if (pWork->aChildWins[n]->nSaveId == nId)
    2219             :             {
    2220           0 :                 pCW = pWork->aChildWins[n];
    2221           0 :                 break;
    2222             :             }
    2223             :     }
    2224             : 
    2225           0 :     if ( !pCW )
    2226             :     {
    2227             :         // If no Parent or the Parent us still unknown, then search here
    2228           0 :         sal_uInt16 nCount = aChildWins.size();
    2229           0 :         for (sal_uInt16 n=0; n<nCount; n++)
    2230           0 :             if (aChildWins[n]->nSaveId == nId)
    2231             :             {
    2232           0 :                 pCW = aChildWins[n];
    2233           0 :                 pWork = this;
    2234           0 :                 break;
    2235             :             }
    2236             :     }
    2237             : 
    2238           0 :     if ( !pCW )
    2239             :     {
    2240             :         // If new, then initialize, add this here depending on the flag or
    2241             :         // the Parent
    2242           0 :         pCW = new SfxChildWin_Impl( nId );
    2243           0 :         InitializeChild_Impl( pCW );
    2244           0 :         if ( !pWork || pCW->aInfo.nFlags & SFX_CHILDWIN_TASK )
    2245           0 :             pWork = this;
    2246           0 :         pWork->aChildWins.push_back( pCW );
    2247             :     }
    2248             : 
    2249           0 :     if ( pCW->bCreate != bOn )
    2250           0 :         pWork->ToggleChildWindow_Impl(nId,bSetFocus);
    2251           0 : }
    2252             : 
    2253             : 
    2254             : 
    2255           0 : void SfxWorkWindow::ShowChildWindow_Impl(sal_uInt16 nId, bool bVisible, bool bSetFocus)
    2256             : {
    2257           0 :     sal_uInt16 nCount = aChildWins.size();
    2258           0 :     SfxChildWin_Impl* pCW=0;
    2259             :     sal_uInt16 n;
    2260           0 :     for (n=0; n<nCount; n++)
    2261             :     {
    2262           0 :         pCW = aChildWins[n];
    2263           0 :         if (pCW->nId == nId)
    2264           0 :             break;
    2265             :     }
    2266             : 
    2267           0 :     if ( n<nCount )
    2268             :     {
    2269           0 :         SfxChildWindow *pChildWin = pCW->pWin;
    2270           0 :         if ( pChildWin )
    2271             :         {
    2272           0 :             if ( bVisible )
    2273             :             {
    2274           0 :                 if ( pCW->pCli )
    2275             :                 {
    2276           0 :                     pCW->pCli->bSetFocus = bSetFocus;
    2277           0 :                     pCW->pCli->nVisible = CHILD_VISIBLE;
    2278           0 :                     pChildWin->Show( bSetFocus && pChildWin->WantsFocus() ? 0 : SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
    2279             :                 }
    2280             :                 else
    2281           0 :                     ((SfxDockingWindow*)pChildWin->GetWindow())->Reappear_Impl();
    2282             : 
    2283             :             }
    2284             :             else
    2285             :             {
    2286           0 :                 if ( pCW->pCli )
    2287             :                 {
    2288           0 :                     pCW->pCli->nVisible = CHILD_VISIBLE ^ CHILD_NOT_HIDDEN;
    2289           0 :                     pCW->pWin->Hide();
    2290             :                 }
    2291             :                 else
    2292           0 :                     ((SfxDockingWindow*)pChildWin->GetWindow())->Disappear_Impl();
    2293             : 
    2294             :             }
    2295             : 
    2296           0 :             ArrangeChildren_Impl();
    2297           0 :             ShowChildren_Impl();
    2298             :         }
    2299           0 :         else if ( bVisible )
    2300             :         {
    2301           0 :             SetChildWindow_Impl( nId, true, bSetFocus );
    2302           0 :             pChildWin = pCW->pWin;
    2303             :         }
    2304             : 
    2305           0 :         if ( pChildWin )
    2306             :         {
    2307           0 :             pChildWin->SetVisible_Impl( bVisible );
    2308           0 :             sal_uInt16 nFlags = pCW->aInfo.nFlags;
    2309           0 :             pCW->aInfo = pChildWin->GetInfo();
    2310           0 :             pCW->aInfo.nFlags |= nFlags;
    2311           0 :             if ( !pCW->bCreate )
    2312           0 :                 SaveStatus_Impl( pChildWin, pCW->aInfo );
    2313             :         }
    2314             : 
    2315           0 :         return;
    2316             :     }
    2317             : 
    2318           0 :     if ( pParent )
    2319             :     {
    2320           0 :         pParent->ShowChildWindow_Impl( nId, bVisible, bSetFocus );
    2321           0 :         return;
    2322             :     }
    2323             : 
    2324             : #ifdef DBG_UTIL
    2325             :     nCount = aChildWins.size();
    2326             :     for (n=0; n<nCount; n++)
    2327             :         if (aChildWins[n]->nSaveId == nId)
    2328             :             break;
    2329             : 
    2330             :     if ( n<nCount )
    2331             :     {
    2332             :         OSL_FAIL("The ChildWindow is not in context!");
    2333             :     }
    2334             :     else
    2335             :     {
    2336             :         OSL_FAIL("The ChildWindow is not registered");
    2337             :     }
    2338             : #endif
    2339             : }
    2340             : 
    2341             : 
    2342             : 
    2343           0 : SfxChildWindow* SfxWorkWindow::GetChildWindow_Impl(sal_uInt16 nId)
    2344             : {
    2345           0 :     sal_uInt16 nCount = aChildWins.size();
    2346             :     sal_uInt16 n;
    2347           0 :     for (n=0; n<nCount; n++)
    2348           0 :         if (aChildWins[n]->nSaveId == nId)
    2349           0 :              break;
    2350             : 
    2351           0 :     if (n<nCount)
    2352           0 :         return aChildWins[n]->pWin;
    2353           0 :     else if ( pParent )
    2354           0 :         return pParent->GetChildWindow_Impl( nId );
    2355           0 :     return 0;
    2356             : }
    2357             : 
    2358             : 
    2359             : 
    2360           0 : void SfxWorkWindow::ResetChildWindows_Impl()
    2361             : {
    2362           0 :     for ( sal_uInt16 n = 0; n < aChildWins.size(); ++n )
    2363             :     {
    2364           0 :         aChildWins[n]->nId = 0;
    2365           0 :         aChildWins[n]->bEnable = false;
    2366             :     }
    2367           0 : }
    2368             : 
    2369             : 
    2370             : // Virtual method that returns the size of the area (client area) of the
    2371             : // parent windows, in which the ChildWindow can be fitted.
    2372             : 
    2373           0 : Rectangle SfxWorkWindow::GetTopRect_Impl()
    2374             : {
    2375           0 :     return Rectangle (Point(), pWorkWin->GetOutputSizePixel() );
    2376             : }
    2377             : 
    2378             : 
    2379             : // Virtual method that returns the size of the area (client area) of the
    2380             : // parent windows, in which the ChildWindow can be fitted.
    2381             : 
    2382           0 : Rectangle SfxFrameWorkWin_Impl::GetTopRect_Impl()
    2383             : {
    2384           0 :     return pMasterFrame->GetTopOuterRectPixel_Impl();
    2385             : }
    2386             : 
    2387             : 
    2388             : // Virtual method to find out if there is room for a ChildWindow in the
    2389             : // client area of the parent.
    2390             : 
    2391           0 : bool SfxWorkWindow::RequestTopToolSpacePixel_Impl( SvBorder aBorder )
    2392             : {
    2393           0 :     if ( !IsDockingAllowed() ||
    2394           0 :             aClientArea.GetWidth() < aBorder.Left() + aBorder.Right() ||
    2395           0 :             aClientArea.GetHeight() < aBorder.Top() + aBorder.Bottom() )
    2396           0 :         return false;
    2397             :     else
    2398           0 :         return true;;
    2399             : }
    2400             : 
    2401           0 : void SfxWorkWindow::SaveStatus_Impl(SfxChildWindow *pChild, const SfxChildWinInfo &rInfo)
    2402             : {
    2403             :     // The Status of the Presentation mode is not saved
    2404           0 :     if ( IsDockingAllowed() && bInternalDockingAllowed )
    2405           0 :         pChild->SaveStatus(rInfo);
    2406           0 : }
    2407             : 
    2408           0 : void SfxWorkWindow::InitializeChild_Impl(SfxChildWin_Impl *pCW)
    2409             : {
    2410           0 :     SfxDispatcher *pDisp = pBindings->GetDispatcher_Impl();
    2411           0 :     SfxViewFrame *pFrame = pDisp ? pDisp->GetFrame() :0;
    2412           0 :     SfxModule *pMod = pFrame ? SfxModule::GetActiveModule(pFrame) :0;
    2413             : 
    2414           0 :     OUString sModule;
    2415           0 :     if (pFrame)
    2416             :     {
    2417             :         try
    2418             :         {
    2419             :             using namespace ::com::sun::star;
    2420             :             uno::Reference< frame::XModuleManager2 > xModuleManager(
    2421           0 :                 frame::ModuleManager::create(::comphelper::getProcessComponentContext()));
    2422           0 :             sModule = xModuleManager->identify(pFrame->GetFrame().GetFrameInterface());
    2423           0 :             SvtModuleOptions::EFactory eFac = SvtModuleOptions::ClassifyFactoryByServiceName(sModule);
    2424           0 :             sModule = SvtModuleOptions::GetFactoryShortName(eFac);
    2425             :         }
    2426           0 :         catch (...)
    2427             :         {
    2428             :         }
    2429             :     }
    2430             : 
    2431           0 :     SfxChildWinFactory* pFact=0;
    2432           0 :     SfxApplication *pApp = SFX_APP();
    2433             :     {
    2434           0 :         SfxChildWinFactArr_Impl &rFactories = pApp->GetChildWinFactories_Impl();
    2435           0 :         for ( sal_uInt16 nFactory = 0; nFactory < rFactories.size(); ++nFactory )
    2436             :         {
    2437           0 :             pFact = rFactories[nFactory];
    2438           0 :             if ( pFact->nId == pCW->nSaveId )
    2439             :             {
    2440           0 :                 pCW->aInfo   = pFact->aInfo;
    2441           0 :                 pCW->aInfo.aModule = sModule;
    2442             :                 SfxChildWindow::InitializeChildWinFactory_Impl(
    2443           0 :                                             pCW->nSaveId, pCW->aInfo);
    2444           0 :                 pCW->bCreate = pCW->aInfo.bVisible;
    2445           0 :                 sal_uInt16 nFlags = pFact->aInfo.nFlags;
    2446           0 :                 if ( nFlags & SFX_CHILDWIN_TASK )
    2447           0 :                     pCW->aInfo.nFlags |= SFX_CHILDWIN_TASK;
    2448           0 :                 if ( nFlags & SFX_CHILDWIN_CANTGETFOCUS )
    2449           0 :                     pCW->aInfo.nFlags |= SFX_CHILDWIN_CANTGETFOCUS;
    2450           0 :                 if ( nFlags & SFX_CHILDWIN_FORCEDOCK )
    2451           0 :                     pCW->aInfo.nFlags |= SFX_CHILDWIN_FORCEDOCK;
    2452           0 :                 pFact->aInfo = pCW->aInfo;
    2453           0 :                 return;
    2454             :             }
    2455             :         }
    2456             :     }
    2457             : 
    2458           0 :     if ( pMod )
    2459             :     {
    2460           0 :         SfxChildWinFactArr_Impl *pFactories = pMod->GetChildWinFactories_Impl();
    2461           0 :         if ( pFactories )
    2462             :         {
    2463           0 :             SfxChildWinFactArr_Impl &rFactories = *pFactories;
    2464           0 :             for ( sal_uInt16 nFactory = 0; nFactory < rFactories.size(); ++nFactory )
    2465             :             {
    2466           0 :                 pFact = rFactories[nFactory];
    2467           0 :                 if ( pFact->nId == pCW->nSaveId )
    2468             :                 {
    2469           0 :                     pCW->aInfo   = pFact->aInfo;
    2470           0 :                     pCW->aInfo.aModule = sModule;
    2471             :                     SfxChildWindow::InitializeChildWinFactory_Impl(
    2472           0 :                                                 pCW->nSaveId, pCW->aInfo);
    2473           0 :                     pCW->bCreate = pCW->aInfo.bVisible;
    2474           0 :                     sal_uInt16 nFlags = pFact->aInfo.nFlags;
    2475           0 :                     if ( nFlags & SFX_CHILDWIN_TASK )
    2476           0 :                         pCW->aInfo.nFlags |= SFX_CHILDWIN_TASK;
    2477           0 :                     if ( nFlags & SFX_CHILDWIN_CANTGETFOCUS )
    2478           0 :                         pCW->aInfo.nFlags |= SFX_CHILDWIN_CANTGETFOCUS;
    2479           0 :                     if ( nFlags & SFX_CHILDWIN_FORCEDOCK )
    2480           0 :                         pCW->aInfo.nFlags |= SFX_CHILDWIN_FORCEDOCK;
    2481           0 :                     if ( nFlags & SFX_CHILDWIN_ALWAYSAVAILABLE )
    2482           0 :                         pCW->aInfo.nFlags |= SFX_CHILDWIN_ALWAYSAVAILABLE;
    2483           0 :                     pFact->aInfo = pCW->aInfo;
    2484           0 :                     return;
    2485             :                 }
    2486             :             }
    2487             :         }
    2488           0 :     }
    2489             : }
    2490             : 
    2491           0 : SfxSplitWindow* SfxWorkWindow::GetSplitWindow_Impl( SfxChildAlignment eAlign )
    2492             : {
    2493           0 :     switch ( eAlign )
    2494             :     {
    2495             :         case SFX_ALIGN_TOP:
    2496           0 :             return pSplit[2];
    2497             : 
    2498             :         case SFX_ALIGN_BOTTOM:
    2499           0 :             return pSplit[3];
    2500             : 
    2501             :         case SFX_ALIGN_LEFT:
    2502           0 :             return pSplit[0];
    2503             : 
    2504             :         case SFX_ALIGN_RIGHT:
    2505           0 :             return pSplit[1];
    2506             : 
    2507             :         default:
    2508           0 :             return 0;
    2509             :     }
    2510             : }
    2511             : 
    2512           0 : void SfxWorkWindow::MakeChildrenVisible_Impl( bool bVis )
    2513             : {
    2514           0 :     if ( pParent )
    2515           0 :         pParent->MakeChildrenVisible_Impl( bVis );
    2516             : 
    2517           0 :     bAllChildrenVisible = bVis;
    2518           0 :     if ( bVis )
    2519             :     {
    2520           0 :         if ( !bSorted )
    2521           0 :             Sort_Impl();
    2522           0 :         for ( sal_uInt16 n=0; n<aSortedList.size(); ++n )
    2523             :         {
    2524           0 :             SfxChild_Impl* pCli = aChildren[aSortedList[n]];
    2525           0 :             if ( (pCli->eAlign == SFX_ALIGN_NOALIGNMENT) || (IsDockingAllowed() && bInternalDockingAllowed) )
    2526           0 :                 pCli->nVisible |= CHILD_ACTIVE;
    2527             :         }
    2528             :     }
    2529             :     else
    2530             :     {
    2531           0 :         if ( !bSorted )
    2532           0 :             Sort_Impl();
    2533           0 :         for ( sal_uInt16 n=0; n<aSortedList.size(); ++n )
    2534             :         {
    2535           0 :             SfxChild_Impl* pCli = aChildren[aSortedList[n]];
    2536           0 :             pCli->nVisible &= ~CHILD_ACTIVE;
    2537             :         }
    2538             :     }
    2539           0 : }
    2540             : 
    2541           0 : bool SfxWorkWindow::IsAutoHideMode( const SfxSplitWindow *pSplitWin )
    2542             : {
    2543           0 :     for ( sal_uInt16 n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
    2544             :     {
    2545           0 :         if ( pSplit[n] != pSplitWin && pSplit[n]->IsAutoHide( true ) )
    2546           0 :             return true;
    2547             :     }
    2548           0 :     return false;
    2549             : }
    2550             : 
    2551             : 
    2552           0 : void SfxWorkWindow::EndAutoShow_Impl( Point aPos )
    2553             : {
    2554           0 :     if ( pParent )
    2555           0 :         pParent->EndAutoShow_Impl( aPos );
    2556             : 
    2557           0 :     for ( sal_uInt16 n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
    2558             :     {
    2559           0 :         SfxSplitWindow *p = pSplit[n];
    2560           0 :         if ( p && p->IsAutoHide() )
    2561             :         {
    2562           0 :             Point aLocalPos = p->ScreenToOutputPixel( aPos );
    2563           0 :         Point aEmptyPoint = Point();
    2564           0 :             Rectangle aRect( aEmptyPoint, p->GetSizePixel() );
    2565           0 :             if ( !aRect.IsInside( aLocalPos ) )
    2566           0 :                 p->FadeOut();
    2567             :         }
    2568             :     }
    2569           0 : }
    2570             : 
    2571           0 : void SfxWorkWindow::ArrangeAutoHideWindows( SfxSplitWindow *pActSplitWin )
    2572             : {
    2573           0 :     if ( m_nLock )
    2574           0 :         return;
    2575             : 
    2576           0 :     if ( pParent )
    2577           0 :         pParent->ArrangeAutoHideWindows( pActSplitWin );
    2578             : 
    2579           0 :     Rectangle aArea( aUpperClientArea );
    2580           0 :     for ( sal_uInt16 n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
    2581             :     {
    2582             :         // Either dummy window or window in the auto-show-mode are processed
    2583             :         // (not pinned, FadeIn).
    2584             :         // Only the abandoned window may be invisible, because perhaps its
    2585             :         // size is just beeing calculated before it is displayed.
    2586           0 :         SfxSplitWindow* pSplitWin = pSplit[n];
    2587           0 :         bool bDummyWindow = !pSplitWin->IsFadeIn();
    2588           0 :         Window *pDummy = pSplitWin->GetSplitWindow();
    2589           0 :         Window *pWin = bDummyWindow ? pDummy : pSplitWin;
    2590           0 :         if ( (pSplitWin->IsPinned() && !bDummyWindow) || (!pWin->IsVisible() && pActSplitWin != pSplitWin) )
    2591           0 :             continue;
    2592             : 
    2593             :         // Width and position of the dummy window as a starting point
    2594           0 :         Size aSize = pDummy->GetSizePixel();
    2595           0 :         Point aPos = pDummy->GetPosPixel();
    2596             : 
    2597           0 :         switch ( n )
    2598             :         {
    2599             :             case ( 0 ) :
    2600             :             {
    2601             :                 // Left SplitWindow
    2602             :                 // Get the width of the Window yourself, if no DummyWindow
    2603           0 :                 if ( !bDummyWindow )
    2604           0 :                     aSize.Width() = pSplitWin->GetSizePixel().Width();
    2605             : 
    2606             :                 // If a Window is visable to the left, then the free region
    2607             :                 // starts to the right from it, for example at the Client area
    2608           0 :                 long nLeft = aPos.X() + aSize.Width();
    2609           0 :                 if ( nLeft > aArea.Left() )
    2610           0 :                     aArea.Left() = nLeft;
    2611           0 :                 break;
    2612             :             }
    2613             :             case ( 1 ) :
    2614             :             {
    2615             :                 // Right SplitWindow
    2616             :                 // Position to correct the difference of the widths
    2617           0 :                 aPos.X() += aSize.Width();
    2618             : 
    2619             :                 // Get the width of the Window yourself, if no DummyWindow
    2620           0 :                 if ( !bDummyWindow )
    2621           0 :                     aSize.Width() = pSplitWin->GetSizePixel().Width();
    2622             : 
    2623           0 :                 aPos.X() -= aSize.Width();
    2624             : 
    2625             :                 // If already a window is opened at the left side, then the
    2626             :                 // right is not allowed to overlap this one.
    2627           0 :                 if ( aPos.X() < aArea.Left() )
    2628             :                 {
    2629           0 :                     aPos.X() = aArea.Left();
    2630           0 :                     aSize.Width() = aArea.GetWidth();
    2631             :                 }
    2632             : 
    2633             :                 // If a Window is visable to the right, then the free region
    2634             :                 // starts to the left from it, for example at the Client area
    2635           0 :                 long nRight = aPos.X();
    2636           0 :                 if ( nRight < aArea.Right() )
    2637           0 :                     aArea.Right() = nRight;
    2638           0 :                 break;
    2639             :             }
    2640             :             case ( 2 ) :
    2641             :             {
    2642             :                 // Top SplitWindow
    2643             :                 // Get the height of the Window yourself, if no DummyWindow
    2644           0 :                 if ( !bDummyWindow )
    2645           0 :                     aSize.Height() = pSplitWin->GetSizePixel().Height();
    2646             : 
    2647             : 
    2648             :                 // Adjust width with regard to if a Window is already open
    2649             :                 // to the left or right
    2650           0 :                 aPos.X() = aArea.Left();
    2651           0 :                 aSize.Width() = aArea.GetWidth();
    2652             : 
    2653             :                 // If a Window is visable at the top, then the free region
    2654             :                 // starts beneath it, for example at the Client area
    2655           0 :                 long nTop = aPos.Y() + aSize.Height();
    2656           0 :                 if ( nTop > aArea.Top() )
    2657           0 :                     aArea.Top() = nTop;
    2658           0 :                 break;
    2659             :             }
    2660             :             case ( 3 ) :
    2661             :             {
    2662             :                 // The bottom SplitWindow
    2663             :                 // Position to correct the difference of the heights
    2664           0 :                 aPos.Y() += aSize.Height();
    2665             : 
    2666             :                 // Get the height of the Window yourself, if no DummyWindow
    2667           0 :                 if ( !bDummyWindow )
    2668           0 :                     aSize.Height() = pSplitWin->GetSizePixel().Height();
    2669             : 
    2670           0 :                 aPos.Y() -= aSize.Height();
    2671             : 
    2672             :                 // Adjust width with regard to if a Window is already open
    2673             :                 // to the left or right.
    2674           0 :                 aPos.X() = aArea.Left();
    2675           0 :                 aSize.Width() = aArea.GetWidth();
    2676             : 
    2677             :                 // If already a window is opened at the top, then the
    2678             :                 // bottom one is not allowed to overlap this one.
    2679           0 :                 if ( aPos.Y() < aArea.Top() )
    2680             :                 {
    2681           0 :                     aPos.Y() = aArea.Top();
    2682           0 :                     aSize.Height() = aArea.GetHeight();
    2683             :                 }
    2684             : 
    2685           0 :                 break;
    2686             :             }
    2687             :         }
    2688             : 
    2689           0 :         if ( !bDummyWindow )
    2690             :             // the FadeIn-Window is a Floating window, which coordinates are
    2691             :             // set in Screen coordinates.
    2692           0 :             pSplitWin->SetPosSizePixel( pWorkWin->OutputToScreenPixel(aPos), aSize );
    2693             :         else
    2694             :             // the docked DummyWindow
    2695           0 :             pDummy->SetPosSizePixel( aPos, aSize );
    2696             :     }
    2697             : }
    2698             : 
    2699           0 : Rectangle SfxWorkWindow::GetFreeArea( bool bAutoHide ) const
    2700             : {
    2701           0 :     if ( bAutoHide )
    2702             :     {
    2703           0 :         Rectangle aArea( aClientArea );
    2704           0 :         for ( sal_uInt16 n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
    2705             :         {
    2706           0 :             if ( pSplit[n]->IsPinned() || !pSplit[n]->IsVisible() )
    2707           0 :                 continue;
    2708             : 
    2709           0 :             Size aSize = pSplit[n]->GetSizePixel();
    2710           0 :             switch ( n )
    2711             :             {
    2712             :                 case ( 0 ) :
    2713           0 :                     aArea.Left() += aSize.Width();
    2714           0 :                     break;
    2715             :                 case ( 1 ) :
    2716           0 :                     aArea.Right() -= aSize.Width();
    2717           0 :                     break;
    2718             :                 case ( 2 ) :
    2719           0 :                     aArea.Top() += aSize.Height();
    2720           0 :                     break;
    2721             :                 case ( 3 ) :
    2722           0 :                     aArea.Bottom() -= aSize.Height();
    2723           0 :                     break;
    2724             :             }
    2725             :         }
    2726             : 
    2727           0 :         return aArea;
    2728             :     }
    2729             :     else
    2730           0 :         return aClientArea;
    2731             : }
    2732             : 
    2733           0 : void SfxWorkWindow::SetActiveChild_Impl( Window *pChild )
    2734             : {
    2735           0 :     pActiveChild = pChild;
    2736           0 : }
    2737             : 
    2738           0 : bool SfxWorkWindow::ActivateNextChild_Impl( sal_Bool bForward )
    2739             : {
    2740             :     // Sort all children under list
    2741           0 :     std::vector<sal_uInt16> aList;
    2742           0 :     for ( sal_uInt16 i=SFX_OBJECTBAR_MAX; i<aChildren.size(); i++)
    2743             :     {
    2744           0 :         SfxChild_Impl *pCli = aChildren[i];
    2745           0 :         if ( pCli && pCli->bCanGetFocus && pCli->pWin )
    2746             :         {
    2747             :             sal_uInt16 k;
    2748           0 :             for (k=0; k<aList.size(); k++)
    2749           0 :                 if ( ChildTravelValue( aChildren[aList[k]]->eAlign) > ChildTravelValue(pCli->eAlign) )
    2750           0 :                     break;
    2751           0 :             aList.insert( aList.begin() + k, i );
    2752             :         }
    2753             :     }
    2754             : 
    2755           0 :     if ( aList.empty() )
    2756           0 :         return false;
    2757             : 
    2758           0 :     sal_uInt16 nTopValue  = ChildTravelValue( SFX_ALIGN_LOWESTTOP );
    2759           0 :     for ( sal_uInt16 i=0; i<aList.size(); i++ )
    2760             :     {
    2761           0 :         SfxChild_Impl* pCli = aChildren[aList[i]];
    2762           0 :         if ( pCli->pWin && ChildTravelValue( pCli->eAlign ) > nTopValue )
    2763           0 :             break;
    2764             :     }
    2765             : 
    2766           0 :     sal_uInt16 n = bForward ? 0 : aList.size()-1;
    2767           0 :     SfxChild_Impl *pAct=NULL;
    2768           0 :     if ( pActiveChild )
    2769             :     {
    2770             :         // Look for the active window
    2771           0 :         for ( n=0; n<aList.size(); n++ )
    2772             :         {
    2773           0 :             SfxChild_Impl* pCli = aChildren[aList[n]];
    2774           0 :             if ( pCli && pCli->pWin && ( pCli->pWin == pActiveChild || !pActiveChild ) )
    2775             :             {
    2776           0 :                 pAct = pCli;
    2777           0 :                 break;
    2778             :             }
    2779             :         }
    2780             :     }
    2781             : 
    2782             :     // dummy entries for the container window
    2783           0 :     aList.insert( aList.begin(), 0xFFFF );
    2784           0 :     aList.push_back( 0xFFFF );
    2785           0 :     n = n + 1;
    2786           0 :     if ( pAct )
    2787             :     {
    2788           0 :         for ( sal_uInt16 i=0; i<SFX_SPLITWINDOWS_MAX; i++ )
    2789             :         {
    2790             :             // Maybe the pNext is a Splitwindow
    2791           0 :             SfxSplitWindow *p = pSplit[i];
    2792           0 :             if ( pAct->pWin == p )
    2793             :             {
    2794           0 :                 if( p->ActivateNextChild_Impl( bForward ) )
    2795           0 :                     return true;
    2796           0 :                 break;
    2797             :             }
    2798             :         }
    2799             : 
    2800             :         // pAct is a direct ChildWindow
    2801             :         // continue with the successor or predecessor of the active window
    2802           0 :         if ( bForward )
    2803           0 :             n = n+1;
    2804             :         else
    2805           0 :             n = n-1;
    2806             : 
    2807           0 :         if ( n == 0 || n == aList.size()-1 )
    2808           0 :             return false;
    2809             :     }
    2810             : 
    2811             :     for( ;; )
    2812             :     {
    2813           0 :         SfxChild_Impl* pCli = aChildren[aList[n]];
    2814           0 :         if ( pCli->pWin )
    2815             :         {
    2816           0 :             SfxChild_Impl* pNext = pCli;
    2817           0 :             for ( sal_uInt16 i=0; n<SFX_SPLITWINDOWS_MAX; n++ )
    2818             :             {
    2819             :                 // Maybe the pNext is a Splitwindow
    2820           0 :                 SfxSplitWindow *p = pSplit[i];
    2821           0 :                 if ( pNext->pWin == p )
    2822             :                 {
    2823             :                     // Activate the first/last window
    2824           0 :                     p->SetActiveWindow_Impl( NULL );
    2825           0 :                     pNext = NULL;
    2826           0 :                     if( p->ActivateNextChild_Impl( bForward ) )
    2827           0 :                         return true;
    2828           0 :                     break;
    2829             :                 }
    2830             :             }
    2831             : 
    2832           0 :             if ( pNext )
    2833             :             {
    2834           0 :                 pNext->pWin->GrabFocus();
    2835           0 :                 pActiveChild = pNext->pWin;
    2836           0 :                 return true;
    2837             :             }
    2838             :         }
    2839             : 
    2840           0 :         if ( bForward )
    2841           0 :             n = n+1;
    2842             :         else
    2843           0 :             n = n-1;
    2844             : 
    2845           0 :         if ( n == 0 || n == aList.size()-1 )
    2846           0 :             break;
    2847           0 :     }
    2848             : 
    2849           0 :     return false;
    2850             : }
    2851             : 
    2852           0 : void SfxWorkWindow::DataChanged_Impl( const DataChangedEvent& )
    2853             : {
    2854             :     sal_uInt16 n;
    2855           0 :     sal_uInt16 nCount = aChildWins.size();
    2856           0 :     for (n=0; n<nCount; n++)
    2857             :     {
    2858           0 :         SfxChildWin_Impl*pCW = aChildWins[n];
    2859           0 :         if ( pCW && pCW->pWin )
    2860           0 :             pCW->pWin->GetWindow()->UpdateSettings( Application::GetSettings() );
    2861             :     }
    2862             : 
    2863           0 :     ArrangeChildren_Impl();
    2864           0 : }
    2865             : 
    2866             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10