LCOV - code coverage report
Current view: top level - sfx2/source/appl - childwin.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 236 371 63.6 %
Date: 2012-08-25 Functions: 33 46 71.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 201 526 38.2 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      11                 :            :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12                 :            :  *   contributor license agreements. See the NOTICE file distributed
      13                 :            :  *   with this work for additional information regarding copyright
      14                 :            :  *   ownership. The ASF licenses this file to you under the Apache
      15                 :            :  *   License, Version 2.0 (the "License"); you may not use this file
      16                 :            :  *   except in compliance with the License. You may obtain a copy of
      17                 :            :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18                 :            :  */
      19                 :            : 
      20                 :            : 
      21                 :            : #include <vcl/toolbox.hxx>
      22                 :            : #include <tools/rcid.h>
      23                 :            : #include <unotools/viewoptions.hxx>
      24                 :            : #include <com/sun/star/frame/XController.hpp>
      25                 :            : #include <com/sun/star/frame/XFrame.hpp>
      26                 :            : #include <com/sun/star/util/XCloseable.hpp>
      27                 :            : #include <comphelper/string.hxx>
      28                 :            : #include <cppuhelper/implbase1.hxx>
      29                 :            : 
      30                 :            : #include <sfx2/childwin.hxx>
      31                 :            : #include <sfx2/app.hxx>
      32                 :            : #include "arrdecl.hxx"
      33                 :            : #include <sfx2/bindings.hxx>
      34                 :            : #include <sfx2/module.hxx>
      35                 :            : #include <sfx2/dockwin.hxx>
      36                 :            : #include <sfx2/dispatch.hxx>
      37                 :            : #include "workwin.hxx"
      38                 :            : 
      39                 :            : static const sal_uInt16 nVersion = 2;
      40                 :            : 
      41                 :            : DBG_NAME(SfxChildWindow)
      42                 :            : 
      43                 :       1146 : struct SfxChildWindow_Impl
      44                 :            : {
      45                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >             xFrame;
      46                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >      xListener;
      47                 :            :     SfxChildWinFactory* pFact;
      48                 :            :     sal_Bool                bHideNotDelete;
      49                 :            :     sal_Bool                bVisible;
      50                 :            :     sal_Bool                bHideAtToggle;
      51                 :            :     sal_Bool                bWantsFocus;
      52                 :            :     SfxModule*          pContextModule;
      53                 :            :     SfxWorkWindow*      pWorkWin;
      54                 :            : };
      55                 :            : 
      56                 :            : // -----------------------------------------------------------------------
      57                 :            : 
      58         [ -  + ]:          4 : class DisposeListener : public ::cppu::WeakImplHelper1< ::com::sun::star::lang::XEventListener >
      59                 :            : {
      60                 :            :     public:
      61                 :          2 :         DisposeListener( SfxChildWindow*      pOwner ,
      62                 :            :                          SfxChildWindow_Impl* pData  )
      63                 :            :             :   m_pOwner( pOwner )
      64                 :          2 :             ,   m_pData ( pData  )
      65                 :          2 :         {}
      66                 :            : 
      67                 :          2 :         virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& aSource ) throw (::com::sun::star::uno::RuntimeException)
      68                 :            :         {
      69         [ +  - ]:          2 :             ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > xSelfHold( this );
      70                 :            : 
      71         [ +  - ]:          2 :             ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xComp( aSource.Source, ::com::sun::star::uno::UNO_QUERY );
      72         [ +  - ]:          2 :             if( xComp.is() )
      73 [ +  - ][ +  - ]:          2 :                 xComp->removeEventListener( this );
                 [ +  - ]
      74                 :            : 
      75 [ +  - ][ +  - ]:          2 :             if( m_pOwner && m_pData )
      76                 :            :             {
      77         [ +  - ]:          2 :                 m_pData->xListener = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >();
      78                 :            : 
      79         [ -  + ]:          2 :                 if ( m_pData->pWorkWin )
      80                 :            :                 {
      81                 :            :                     // m_pOwner and m_pData will be killed
      82         [ #  # ]:          0 :                     m_pData->xFrame    = ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >();
      83         [ #  # ]:          0 :                     m_pData->pWorkWin->GetBindings().Execute( m_pOwner->GetType() );
      84                 :            :                 }
      85                 :            :                 else
      86                 :            :                 {
      87 [ +  - ][ +  - ]:          2 :                     delete m_pOwner;
      88                 :            :                 }
      89                 :            : 
      90                 :          2 :                 m_pOwner = NULL;
      91                 :          2 :                 m_pData  = NULL;
      92                 :          2 :             }
      93                 :          2 :         }
      94                 :            : 
      95                 :            :     private:
      96                 :            :         SfxChildWindow*      m_pOwner;
      97                 :            :         SfxChildWindow_Impl* m_pData ;
      98                 :            : };
      99                 :            : 
     100                 :            : // -----------------------------------------------------------------------
     101                 :            : 
     102                 :        274 : sal_Bool GetPosSizeFromString( const String& rStr, Point& rPos, Size& rSize )
     103                 :            : {
     104 [ +  - ][ +  - ]:        274 :     if ( comphelper::string::getTokenCount(rStr, '/') != 4 )
                 [ -  + ]
     105                 :          0 :         return sal_False;
     106                 :            : 
     107                 :        274 :     xub_StrLen nIdx = 0;
     108 [ +  - ][ +  - ]:        274 :     rPos.X() = rStr.GetToken(0, '/', nIdx).ToInt32();
                 [ +  - ]
     109 [ +  - ][ +  - ]:        274 :     rPos.Y() = rStr.GetToken(0, '/', nIdx).ToInt32();
                 [ +  - ]
     110 [ +  - ][ +  - ]:        274 :     rSize.Width() = rStr.GetToken(0, '/', nIdx).ToInt32();
                 [ +  - ]
     111 [ +  - ][ +  - ]:        274 :     rSize.Height() = rStr.GetToken(0, '/', nIdx).ToInt32();
                 [ +  - ]
     112                 :            : 
     113                 :            :     // negative sizes are invalid
     114 [ +  - ][ -  + ]:        274 :     if ( rSize.Width() < 0 || rSize.Height() < 0 )
                 [ -  + ]
     115                 :          0 :         return sal_False;
     116                 :            : 
     117                 :        274 :     return sal_True;
     118                 :            : }
     119                 :            : 
     120                 :        274 : sal_Bool GetSplitSizeFromString( const String& rStr, Size& rSize )
     121                 :            : {
     122                 :        274 :     xub_StrLen nIndex = rStr.Search( ',' );
     123         [ +  - ]:        274 :     if ( nIndex != STRING_NOTFOUND )
     124                 :            :     {
     125         [ +  - ]:        274 :         String aStr = rStr.Copy( nIndex+1 );
     126                 :            : 
     127 [ +  - ][ +  - ]:        274 :         sal_Int32 nCount = comphelper::string::getTokenCount(aStr, ';');
     128         [ -  + ]:        274 :         if ( nCount != 2 )
     129                 :          0 :             return sal_False;
     130                 :            : 
     131 [ +  - ][ +  - ]:        274 :         rSize.Width() = aStr.GetToken(0, ';' ).ToInt32();
                 [ +  - ]
     132 [ +  - ][ +  - ]:        274 :         rSize.Height() = aStr.GetToken(1, ';' ).ToInt32();
                 [ +  - ]
     133                 :            : 
     134                 :            :         // negative sizes are invalid
     135 [ +  - ][ -  + ]:        274 :         if ( rSize.Width() < 0 || rSize.Height() < 0 )
                 [ -  + ]
     136                 :          0 :             return sal_False;
     137                 :            : 
     138         [ +  - ]:        274 :         return sal_True;
     139                 :            :     }
     140                 :            : 
     141                 :        274 :     return sal_False;
     142                 :            : }
     143                 :            : 
     144                 :            : //=========================================================================
     145                 :        575 : SfxChildWindow::SfxChildWindow(Window *pParentWindow, sal_uInt16 nId)
     146                 :            :     : pParent(pParentWindow)
     147                 :            :     , nType(nId)
     148                 :            :     , eChildAlignment(SFX_ALIGN_NOALIGNMENT)
     149                 :        575 :     , pWindow(0L)
     150                 :            : {
     151         [ +  - ]:        575 :     pImp = new SfxChildWindow_Impl;
     152                 :        575 :     pImp->pFact = 0L;
     153                 :        575 :     pImp->bHideNotDelete = sal_False;
     154                 :        575 :     pImp->bHideAtToggle = sal_False;
     155                 :        575 :     pImp->bWantsFocus = sal_True;
     156                 :        575 :     pImp->bVisible = sal_True;
     157                 :        575 :     pImp->pContextModule = NULL;
     158                 :        575 :     pImp->pWorkWin = NULL;
     159                 :            : 
     160                 :        575 :     pContext = 0L;
     161                 :            :     DBG_CTOR(SfxChildWindow,0);
     162                 :        575 : }
     163                 :            : 
     164                 :        571 : void SfxChildWindow::Destroy()
     165                 :            : {
     166         [ +  + ]:        571 :     if ( GetFrame().is() )
     167                 :            :     {
     168                 :          2 :         pImp->pWorkWin = NULL;
     169                 :            :         try
     170                 :            :         {
     171 [ +  - ][ +  - ]:          2 :             ::com::sun::star::uno::Reference < ::com::sun::star::util::XCloseable > xClose( GetFrame(), ::com::sun::star::uno::UNO_QUERY );
     172         [ +  - ]:          2 :             if ( xClose.is() )
     173 [ +  - ][ +  - ]:          2 :                 xClose->close( sal_True );
     174                 :            :             else
     175 [ #  # ][ #  # ]:          2 :                 GetFrame()->dispose();
         [ #  # ][ #  # ]
     176                 :            :         }
     177                 :          0 :         catch (const com::sun::star::uno::Exception&)
     178                 :            :         {
     179                 :            :         }
     180                 :            :     }
     181                 :            :     else
     182         [ +  - ]:        569 :         delete this;
     183                 :        571 : }
     184                 :            : 
     185                 :            : //-------------------------------------------------------------------------
     186                 :        571 : SfxChildWindow::~SfxChildWindow()
     187                 :            : {
     188                 :            :     DBG_DTOR(SfxChildWindow,0);
     189         [ -  + ]:        571 :     delete pContext;
     190         [ +  - ]:        571 :     delete pWindow;
     191         [ +  - ]:        571 :     delete pImp;
     192         [ -  + ]:        571 : }
     193                 :            : 
     194                 :            : //-------------------------------------------------------------------------
     195                 :        575 : SfxChildWindow* SfxChildWindow::CreateChildWindow( sal_uInt16 nId,
     196                 :            :         Window *pParent, SfxBindings* pBindings, SfxChildWinInfo& rInfo)
     197                 :            : {
     198                 :        575 :     SfxChildWindow *pChild=0;
     199                 :        575 :     SfxChildWinFactory* pFact=0;
     200                 :        575 :     sal_uInt16 nOldMode = Application::GetSystemWindowMode();
     201                 :            : 
     202                 :            :     // First search for ChildWindow in SDT; "Overloading has to be realized
     203                 :            :     // by using ChildWindowContext
     204                 :        575 :     SfxApplication *pApp = SFX_APP();
     205                 :            :     {
     206                 :        575 :         SfxChildWinFactArr_Impl &rFactories = pApp->GetChildWinFactories_Impl();
     207         [ +  + ]:       9260 :         for ( sal_uInt16 nFactory = 0; nFactory < rFactories.size(); ++nFactory )
     208                 :            :         {
     209                 :       8875 :             pFact = rFactories[nFactory];
     210         [ +  + ]:       8875 :             if ( pFact->nId == nId )
     211                 :            :             {
     212                 :        190 :                 SfxChildWinInfo& rFactInfo = pFact->aInfo;
     213         [ +  - ]:        190 :                 if ( rInfo.bVisible )
     214                 :            :                 {
     215         [ +  - ]:        190 :                     if ( pBindings )
     216         [ +  - ]:        190 :                         pBindings->ENTERREGISTRATIONS();
     217         [ +  - ]:        190 :                     SfxChildWinInfo aInfo = rFactInfo;
     218         [ +  - ]:        190 :                     Application::SetSystemWindowMode( SYSTEMWINDOW_MODE_NOAUTOMODE );
     219         [ +  - ]:        190 :                     pChild = pFact->pCtor( pParent, nId, pBindings, &aInfo );
     220         [ +  - ]:        190 :                     Application::SetSystemWindowMode( nOldMode );
     221         [ +  - ]:        190 :                     if ( pBindings )
     222 [ +  - ][ +  - ]:        190 :                         pBindings->LEAVEREGISTRATIONS();
     223                 :            :                 }
     224                 :            : 
     225                 :        190 :                 break;
     226                 :            :             }
     227                 :            :         }
     228                 :            :     }
     229                 :            : 
     230                 :        575 :     SfxDispatcher *pDisp = pBindings->GetDispatcher_Impl();
     231         [ +  - ]:        575 :     SfxModule *pMod = pDisp ? SfxModule::GetActiveModule( pDisp->GetFrame() ) :0;
     232 [ +  + ][ +  - ]:        575 :     if ( !pChild &&  pMod )
     233                 :            :     {
     234                 :        385 :         SfxChildWinFactArr_Impl *pFactories = pMod->GetChildWinFactories_Impl();
     235         [ +  - ]:        385 :         if ( pFactories )
     236                 :            :         {
     237                 :        385 :             SfxChildWinFactArr_Impl &rFactories = *pFactories;
     238         [ +  - ]:       3183 :             for ( sal_uInt16 nFactory = 0; nFactory < rFactories.size(); ++nFactory )
     239                 :            :             {
     240                 :       2798 :                 pFact = rFactories[nFactory];
     241         [ +  + ]:       2798 :                 if ( pFact->nId == nId )
     242                 :            :                 {
     243                 :        385 :                     SfxChildWinInfo& rFactInfo = pFact->aInfo;
     244         [ +  - ]:        385 :                     if ( rInfo.bVisible )
     245                 :            :                     {
     246         [ +  - ]:        385 :                         if ( pBindings )
     247         [ +  - ]:        385 :                             pBindings->ENTERREGISTRATIONS();
     248         [ +  - ]:        385 :                         SfxChildWinInfo aInfo = rFactInfo;
     249         [ +  - ]:        385 :                         Application::SetSystemWindowMode( SYSTEMWINDOW_MODE_NOAUTOMODE );
     250         [ +  - ]:        385 :                         pChild = pFact->pCtor( pParent, nId, pBindings, &aInfo );
     251         [ +  - ]:        385 :                         Application::SetSystemWindowMode( nOldMode );
     252         [ +  - ]:        385 :                         if ( pBindings )
     253 [ +  - ][ +  - ]:        385 :                             pBindings->LEAVEREGISTRATIONS();
     254                 :            :                     }
     255                 :            : 
     256                 :        385 :                     break;
     257                 :            :                 }
     258                 :            :             }
     259                 :            :         }
     260                 :            :     }
     261                 :            : 
     262         [ +  - ]:        575 :     if ( pChild )
     263                 :        575 :         pChild->SetFactory_Impl( pFact );
     264                 :            : 
     265                 :            :     DBG_ASSERT(pFact && (pChild || !rInfo.bVisible), "ChildWindow-Typ not registered!");
     266                 :            : 
     267 [ +  - ][ -  + ]:        575 :     if ( pChild && !pChild->pWindow )
     268                 :            :     {
     269         [ #  # ]:          0 :         DELETEZ(pChild);
     270                 :            :         DBG_WARNING("ChildWindow has no Window!");
     271                 :            :     }
     272                 :            : 
     273                 :        575 :     return pChild;
     274                 :            : }
     275                 :            : 
     276                 :            : //-------------------------------------------------------------------------
     277                 :        767 : void SfxChildWindow::SaveStatus(const SfxChildWinInfo& rInfo)
     278                 :            : {
     279                 :        767 :     sal_uInt16 nID = GetType();
     280                 :            : 
     281                 :        767 :     rtl::OUStringBuffer aWinData;
     282 [ +  - ][ +  - ]:        767 :     aWinData.append('V').append(static_cast<sal_Int32>(nVersion)).
     283 [ +  - ][ +  - ]:       1534 :         append(',').append(rInfo.bVisible ? 'V' : 'H').append(',').
         [ +  - ][ +  + ]
     284         [ +  - ]:        767 :         append(static_cast<sal_Int32>(rInfo.nFlags));
     285         [ +  + ]:        767 :     if ( rInfo.aExtraString.Len() )
     286                 :            :     {
     287         [ +  - ]:        468 :         aWinData.append(',');
     288 [ +  - ][ +  - ]:        468 :         aWinData.append(rInfo.aExtraString);
     289                 :            :     }
     290                 :            : 
     291 [ +  - ][ +  - ]:        767 :     SvtViewOptions aWinOpt( E_WINDOW, String::CreateFromInt32( nID ) );
         [ +  - ][ +  - ]
     292 [ +  - ][ +  - ]:        767 :     aWinOpt.SetWindowState(rtl::OStringToOUString(rInfo.aWinState, RTL_TEXTENCODING_UTF8));
     293                 :            : 
     294         [ +  - ]:        767 :     ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq(1);
     295         [ +  - ]:        767 :     aSeq[0].Name = ::rtl::OUString("Data");
     296 [ +  - ][ +  - ]:        767 :     aSeq[0].Value <<= aWinData.makeStringAndClear();
                 [ +  - ]
     297         [ +  - ]:        767 :     aWinOpt.SetUserData( aSeq );
     298                 :            : 
     299                 :            :     // ... but save status at runtime!
     300 [ +  - ][ +  - ]:        767 :     pImp->pFact->aInfo = rInfo;
                 [ +  - ]
     301                 :        767 : }
     302                 :            : 
     303                 :            : //-------------------------------------------------------------------------
     304                 :        274 : void SfxChildWindow::SetAlignment(SfxChildAlignment eAlign)
     305                 :            : {
     306                 :            :     DBG_CHKTHIS(SfxChildWindow,0);
     307                 :            : 
     308                 :        274 :     eChildAlignment = eAlign;
     309                 :        274 : }
     310                 :            : 
     311                 :            : //-------------------------------------------------------------------------
     312                 :        767 : SfxChildWinInfo SfxChildWindow::GetInfo() const
     313                 :            : {
     314                 :            :     DBG_CHKTHIS(SfxChildWindow,0);
     315                 :            : 
     316                 :        767 :     SfxChildWinInfo aInfo;
     317         [ +  - ]:        767 :     aInfo.aPos  = pWindow->GetPosPixel();
     318         [ +  - ]:        767 :     aInfo.aSize = pWindow->GetSizePixel();
     319 [ +  - ][ +  + ]:        767 :     if ( pWindow->IsSystemWindow() )
     320                 :            :     {
     321                 :         54 :         sal_uIntPtr nMask = WINDOWSTATE_MASK_POS | WINDOWSTATE_MASK_STATE;
     322 [ +  - ][ -  + ]:         54 :         if ( pWindow->GetStyle() & WB_SIZEABLE )
     323                 :          0 :             nMask |= ( WINDOWSTATE_MASK_WIDTH | WINDOWSTATE_MASK_HEIGHT );
     324         [ +  - ]:         54 :         aInfo.aWinState = ((SystemWindow*)pWindow)->GetWindowState( nMask );
     325                 :            :     }
     326 [ +  - ][ +  + ]:        713 :     else if ( pWindow->GetType() == RSC_DOCKINGWINDOW )
     327                 :            :     {
     328         [ -  + ]:        468 :         if (((DockingWindow*)pWindow)->GetFloatingWindow() )
     329         [ #  # ]:          0 :             aInfo.aWinState = ((DockingWindow*)pWindow)->GetFloatingWindow()->GetWindowState();
     330                 :            :         else
     331                 :            :         {
     332         [ +  - ]:        468 :             SfxChildWinInfo aTmpInfo;
     333         [ +  - ]:        468 :             ((SfxDockingWindow*)pWindow)->FillInfo( aTmpInfo );
     334 [ +  - ][ +  - ]:        468 :             aInfo.aExtraString = aTmpInfo.aExtraString;
     335                 :            :         }
     336                 :            :     }
     337                 :            : 
     338                 :        767 :     aInfo.bVisible = pImp->bVisible;
     339                 :        767 :     aInfo.nFlags = 0;
     340                 :        767 :     return aInfo;
     341                 :            : }
     342                 :            : 
     343                 :            : //-------------------------------------------------------------------------
     344                 :        575 : sal_uInt16 SfxChildWindow::GetPosition()
     345                 :            : {
     346                 :        575 :     return pImp->pFact->nPos;
     347                 :            : }
     348                 :            : 
     349                 :            : //-------------------------------------------------------------------------
     350                 :      53855 : void SfxChildWindow::InitializeChildWinFactory_Impl( sal_uInt16 nId, SfxChildWinInfo& rInfo )
     351                 :            : {
     352                 :            :     // load configuration
     353 [ +  - ][ +  - ]:      53855 :     SvtViewOptions aWinOpt( E_WINDOW, String::CreateFromInt32( nId ) );
         [ +  - ][ +  - ]
     354                 :            : 
     355 [ +  - ][ +  + ]:      53855 :     if ( aWinOpt.Exists() )
     356         [ +  - ]:       2050 :         rInfo.bVisible  = aWinOpt.IsVisible(); // set state from configuration. Can be overwritten by UserData, see below
     357                 :            : 
     358         [ +  - ]:      53855 :     ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt.GetUserData();
     359                 :            : 
     360                 :      53855 :     ::rtl::OUString aTmp;
     361         [ +  + ]:      53855 :     if ( aSeq.getLength() )
     362         [ +  - ]:        515 :         aSeq[0].Value >>= aTmp;
     363                 :            : 
     364         [ +  - ]:      53855 :     String aWinData( aTmp );
     365 [ +  - ][ +  - ]:      53855 :     rInfo.aWinState = rtl::OUStringToOString(aWinOpt.GetWindowState(), RTL_TEXTENCODING_UTF8);
     366                 :            : 
     367                 :            : 
     368         [ +  + ]:      53855 :     if ( aWinData.Len() )
     369                 :            :     {
     370                 :            :         // Search for version ID
     371         [ -  + ]:        515 :         if ( aWinData.GetChar((sal_uInt16)0) != 0x0056 ) // 'V' = 56h
     372                 :            :             // A version ID, so do not use
     373                 :            :             return;
     374                 :            : 
     375                 :            :         // Delete 'V'
     376         [ +  - ]:        515 :         aWinData.Erase(0,1);
     377                 :            : 
     378                 :            :         // Read version
     379                 :        515 :         char cToken = ',';
     380         [ +  - ]:        515 :         sal_uInt16 nPos = aWinData.Search( cToken );
     381 [ +  - ][ +  - ]:        515 :         sal_uInt16 nActVersion = (sal_uInt16)aWinData.Copy( 0, nPos + 1 ).ToInt32();
                 [ +  - ]
     382         [ -  + ]:        515 :         if ( nActVersion != nVersion )
     383                 :            :             return;
     384                 :            : 
     385         [ +  - ]:        515 :         aWinData.Erase(0,nPos+1);
     386                 :            : 
     387                 :            :         // Load Visibility: is coded as a char
     388                 :        515 :         rInfo.bVisible = (aWinData.GetChar(0) == 0x0056); // 'V' = 56h
     389         [ +  - ]:        515 :         aWinData.Erase(0,1);
     390         [ +  - ]:        515 :         nPos = aWinData.Search( cToken );
     391         [ +  - ]:        515 :         if (nPos != STRING_NOTFOUND)
     392                 :            :         {
     393         [ +  - ]:        515 :             sal_uInt16 nNextPos = aWinData.Search( cToken, 2 );
     394         [ +  + ]:        515 :             if ( nNextPos != STRING_NOTFOUND )
     395                 :            :             {
     396                 :            :                 // there is extra information
     397 [ +  - ][ +  - ]:        294 :                 rInfo.nFlags = (sal_uInt16)aWinData.Copy( nPos+1, nNextPos - nPos - 1 ).ToInt32();
                 [ +  - ]
     398         [ +  - ]:        294 :                 aWinData.Erase( nPos, nNextPos-nPos+1 );
     399         [ +  - ]:        294 :                 rInfo.aExtraString = aWinData;
     400                 :            :             }
     401                 :            :             else
     402 [ +  - ][ +  - ]:      53855 :                 rInfo.nFlags = (sal_uInt16)aWinData.Copy( nPos+1 ).ToInt32();
                 [ +  - ]
     403                 :            :         }
     404 [ +  - ][ -  + ]:      53855 :     }
         [ -  + ][ +  - ]
         [ -  + ][ +  - ]
                 [ +  - ]
     405                 :            : }
     406                 :            : 
     407                 :          0 : void SfxChildWindow::CreateContext( sal_uInt16 nContextId, SfxBindings& rBindings )
     408                 :            : {
     409                 :          0 :     SfxChildWindowContext *pCon = NULL;
     410                 :          0 :     SfxChildWinFactory* pFact=0;
     411                 :          0 :     SfxApplication *pApp = SFX_APP();
     412                 :          0 :     SfxDispatcher *pDisp = rBindings.GetDispatcher_Impl();
     413         [ #  # ]:          0 :     SfxModule *pMod = pDisp ? SfxModule::GetActiveModule( pDisp->GetFrame() ) :0;
     414         [ #  # ]:          0 :     if ( pMod )
     415                 :            :     {
     416                 :          0 :         SfxChildWinFactArr_Impl *pFactories = pMod->GetChildWinFactories_Impl();
     417         [ #  # ]:          0 :         if ( pFactories )
     418                 :            :         {
     419                 :          0 :             SfxChildWinFactArr_Impl &rFactories = *pFactories;
     420         [ #  # ]:          0 :             for ( sal_uInt16 nFactory = 0; nFactory < rFactories.size(); ++nFactory )
     421                 :            :             {
     422                 :          0 :                 pFact = rFactories[nFactory];
     423         [ #  # ]:          0 :                 if ( pFact->nId == GetType() )
     424                 :            :                 {
     425                 :            :                     DBG_ASSERT( pFact->pArr, "No context registered!" );
     426         [ #  # ]:          0 :                     if ( !pFact->pArr )
     427                 :          0 :                         break;
     428                 :            : 
     429         [ #  # ]:          0 :                     for ( sal_uInt16 n=0; n<pFact->pArr->size(); ++n )
     430                 :            :                     {
     431                 :          0 :                         SfxChildWinContextFactory *pConFact = &(*pFact->pArr)[n];
     432                 :          0 :                         rBindings.ENTERREGISTRATIONS();
     433         [ #  # ]:          0 :                         if ( pConFact->nContextId == nContextId )
     434                 :            :                         {
     435         [ #  # ]:          0 :                             SfxChildWinInfo aInfo = pFact->aInfo;
     436         [ #  # ]:          0 :                             pCon = pConFact->pCtor( GetWindow(), &rBindings, &aInfo );
     437                 :          0 :                             pCon->nContextId = pConFact->nContextId;
     438         [ #  # ]:          0 :                             pImp->pContextModule = pMod;
     439                 :            :                         }
     440                 :          0 :                         rBindings.LEAVEREGISTRATIONS();
     441                 :            :                     }
     442                 :          0 :                     break;
     443                 :            :                 }
     444                 :            :             }
     445                 :            :         }
     446                 :            :     }
     447                 :            : 
     448         [ #  # ]:          0 :     if ( !pCon )
     449                 :            :     {
     450                 :          0 :         SfxChildWinFactArr_Impl &rFactories = pApp->GetChildWinFactories_Impl();
     451         [ #  # ]:          0 :         for ( sal_uInt16 nFactory = 0; nFactory < rFactories.size(); ++nFactory )
     452                 :            :         {
     453                 :          0 :             pFact = rFactories[nFactory];
     454         [ #  # ]:          0 :             if ( pFact->nId == GetType() )
     455                 :            :             {
     456                 :            :                 DBG_ASSERT( pFact->pArr, "No context registered!" );
     457         [ #  # ]:          0 :                 if ( !pFact->pArr )
     458                 :          0 :                     break;
     459                 :            : 
     460         [ #  # ]:          0 :                 for ( sal_uInt16 n=0; n<pFact->pArr->size(); ++n )
     461                 :            :                 {
     462                 :          0 :                     SfxChildWinContextFactory *pConFact = &(*pFact->pArr)[n];
     463                 :          0 :                     rBindings.ENTERREGISTRATIONS();
     464         [ #  # ]:          0 :                     if ( pConFact->nContextId == nContextId )
     465                 :            :                     {
     466         [ #  # ]:          0 :                         SfxChildWinInfo aInfo = pFact->aInfo;
     467         [ #  # ]:          0 :                         pCon = pConFact->pCtor( GetWindow(), &rBindings, &aInfo );
     468                 :          0 :                         pCon->nContextId = pConFact->nContextId;
     469         [ #  # ]:          0 :                         pImp->pContextModule = NULL;
     470                 :            :                     }
     471                 :          0 :                     rBindings.LEAVEREGISTRATIONS();
     472                 :            :                 }
     473                 :          0 :                 break;
     474                 :            :             }
     475                 :            :         }
     476                 :            :     }
     477                 :            : 
     478         [ #  # ]:          0 :     if ( !pCon )
     479                 :            :     {
     480                 :            :         OSL_FAIL( "No suitable context found! ");
     481                 :          0 :         return;
     482                 :            :     }
     483                 :            : 
     484         [ #  # ]:          0 :     if ( pContext )
     485         [ #  # ]:          0 :         delete( pContext );
     486                 :          0 :     pContext = pCon;
     487         [ #  # ]:          0 :     pContext->GetWindow()->SetSizePixel( pWindow->GetOutputSizePixel() );
     488                 :          0 :     pContext->GetWindow()->Show();
     489                 :            : }
     490                 :            : 
     491                 :          0 : SfxChildWindowContext::SfxChildWindowContext( sal_uInt16 nId )
     492                 :            :     : pWindow( NULL )
     493                 :          0 :     , nContextId( nId )
     494                 :            : {
     495                 :          0 : }
     496                 :            : 
     497                 :          0 : SfxChildWindowContext::~SfxChildWindowContext()
     498                 :            : {
     499         [ #  # ]:          0 :     delete pWindow;
     500         [ #  # ]:          0 : }
     501                 :            : 
     502                 :          0 : FloatingWindow* SfxChildWindowContext::GetFloatingWindow() const
     503                 :            : {
     504                 :          0 :     Window *pParent = pWindow->GetParent();
     505 [ #  # ][ #  # ]:          0 :     if ( pParent->GetType() == RSC_DOCKINGWINDOW || pParent->GetType() == RSC_TOOLBOX )
                 [ #  # ]
     506                 :            :     {
     507                 :          0 :         return ((DockingWindow*)pParent)->GetFloatingWindow();
     508                 :            :     }
     509         [ #  # ]:          0 :     else if ( pParent->GetType() == RSC_FLOATINGWINDOW )
     510                 :            :     {
     511                 :          0 :         return (FloatingWindow*) pParent;
     512                 :            :     }
     513                 :            :     else
     514                 :            :     {
     515                 :            :         OSL_FAIL("No FloatingWindow-Context!");
     516                 :          0 :         return NULL;
     517                 :            :     }
     518                 :            : }
     519                 :            : 
     520                 :          0 : void SfxChildWindowContext::Resizing( Size& )
     521                 :            : {
     522                 :          0 : }
     523                 :            : 
     524                 :          0 : sal_Bool SfxChildWindowContext::Close()
     525                 :            : {
     526                 :          0 :     return sal_True;
     527                 :            : }
     528                 :            : 
     529                 :        575 : void SfxChildWindow::SetFactory_Impl( SfxChildWinFactory *pF )
     530                 :            : {
     531                 :        575 :     pImp->pFact = pF;
     532                 :        575 : }
     533                 :            : 
     534                 :        158 : void SfxChildWindow::SetHideNotDelete( sal_Bool bOn )
     535                 :            : {
     536                 :        158 :     pImp->bHideNotDelete = bOn;
     537                 :        158 : }
     538                 :            : 
     539                 :         16 : sal_Bool SfxChildWindow::IsHideNotDelete() const
     540                 :            : {
     541                 :         16 :     return pImp->bHideNotDelete;
     542                 :            : }
     543                 :            : 
     544                 :        156 : sal_Bool SfxChildWindow::IsHideAtToggle() const
     545                 :            : {
     546                 :        156 :     return pImp->bHideAtToggle;
     547                 :            : }
     548                 :            : 
     549                 :          0 : void SfxChildWindow::SetWantsFocus( sal_Bool bSet )
     550                 :            : {
     551                 :          0 :     pImp->bWantsFocus = bSet;
     552                 :          0 : }
     553                 :            : 
     554                 :        158 : sal_Bool SfxChildWindow::WantsFocus() const
     555                 :            : {
     556                 :        158 :     return pImp->bWantsFocus;
     557                 :            : }
     558                 :            : 
     559                 :          0 : sal_Bool SfxChildWinInfo::GetExtraData_Impl
     560                 :            : (
     561                 :            :     SfxChildAlignment   *pAlign,
     562                 :            :     SfxChildAlignment   *pLastAlign,
     563                 :            :     Size                *pSize,
     564                 :            :     sal_uInt16          *pLine,
     565                 :            :     sal_uInt16          *pPos
     566                 :            : )   const
     567                 :            : {
     568                 :            :     // invalid?
     569         [ #  # ]:          0 :     if ( !aExtraString.Len() )
     570                 :          0 :         return sal_False;
     571         [ #  # ]:          0 :     String aStr;
     572         [ #  # ]:          0 :     sal_uInt16 nPos = aExtraString.SearchAscii("AL:");
     573         [ #  # ]:          0 :     if ( nPos == STRING_NOTFOUND )
     574                 :          0 :         return sal_False;
     575                 :            : 
     576                 :            :     // Try to read the alignment string "ALIGN :(...)", but if
     577                 :            :     // it is not present, then use an older version
     578         [ #  # ]:          0 :     if ( nPos != STRING_NOTFOUND )
     579                 :            :     {
     580         [ #  # ]:          0 :         sal_uInt16 n1 = aExtraString.Search('(', nPos);
     581         [ #  # ]:          0 :         if ( n1 != STRING_NOTFOUND )
     582                 :            :         {
     583         [ #  # ]:          0 :             sal_uInt16 n2 = aExtraString.Search(')', n1);
     584         [ #  # ]:          0 :             if ( n2 != STRING_NOTFOUND )
     585                 :            :             {
     586                 :            :                 // Cut out Alignment string
     587 [ #  # ][ #  # ]:          0 :                 aStr = aExtraString.Copy(nPos, n2 - nPos + 1);
                 [ #  # ]
     588         [ #  # ]:          0 :                 aStr.Erase(nPos, n1-nPos+1);
     589                 :            :             }
     590                 :            :         }
     591                 :            :     }
     592                 :            : 
     593                 :            :     // First extract the Alignment
     594         [ #  # ]:          0 :     if ( !aStr.Len() )
     595                 :          0 :         return sal_False;
     596         [ #  # ]:          0 :     if ( pAlign )
     597         [ #  # ]:          0 :         *pAlign = (SfxChildAlignment) (sal_uInt16) aStr.ToInt32();
     598                 :            : 
     599                 :            :     // then the LastAlignment
     600         [ #  # ]:          0 :     nPos = aStr.Search(',');
     601         [ #  # ]:          0 :     if ( nPos == STRING_NOTFOUND )
     602                 :          0 :         return sal_False;
     603         [ #  # ]:          0 :     aStr.Erase(0, nPos+1);
     604         [ #  # ]:          0 :     if ( pLastAlign )
     605         [ #  # ]:          0 :         *pLastAlign = (SfxChildAlignment) (sal_uInt16) aStr.ToInt32();
     606                 :            : 
     607                 :            :     // Then the splitting information
     608         [ #  # ]:          0 :     nPos = aStr.Search(',');
     609         [ #  # ]:          0 :     if ( nPos == STRING_NOTFOUND )
     610                 :            :         // No docking in a Splitwindow
     611                 :          0 :         return sal_True;
     612         [ #  # ]:          0 :     aStr.Erase(0, nPos+1);
     613                 :          0 :     Point aChildPos;
     614                 :          0 :     Size aChildSize;
     615 [ #  # ][ #  # ]:          0 :     if ( GetPosSizeFromString( aStr, aChildPos, aChildSize ) )
     616                 :            :     {
     617         [ #  # ]:          0 :         if ( pSize )
     618                 :          0 :             *pSize = aChildSize;
     619         [ #  # ]:          0 :         if ( pLine )
     620                 :          0 :             *pLine = (sal_uInt16) aChildPos.X();
     621         [ #  # ]:          0 :         if ( pPos )
     622                 :          0 :             *pPos = (sal_uInt16) aChildPos.Y();
     623                 :          0 :         return sal_True;
     624                 :            :     }
     625         [ #  # ]:          0 :     return sal_False;
     626                 :            : }
     627                 :            : 
     628                 :          0 : sal_Bool SfxChildWindow::IsVisible() const
     629                 :            : {
     630                 :          0 :     return pImp->bVisible;
     631                 :            : }
     632                 :            : 
     633                 :        156 : void SfxChildWindow::SetVisible_Impl( sal_Bool bVis )
     634                 :            : {
     635                 :        156 :     pImp->bVisible = bVis;
     636                 :        156 : }
     637                 :            : 
     638                 :        571 : void SfxChildWindow::Hide()
     639                 :            : {
     640      [ +  +  + ]:        571 :     switch ( pWindow->GetType() )
     641                 :            :     {
     642                 :            :         case RSC_DOCKINGWINDOW :
     643                 :        312 :             ((DockingWindow*)pWindow)->Hide();
     644                 :        312 :             break;
     645                 :            :         case RSC_TOOLBOX :
     646                 :        225 :             ((ToolBox*)pWindow)->Hide();
     647                 :        225 :             break;
     648                 :            :         default:
     649                 :         34 :             pWindow->Hide();
     650                 :         34 :             break;
     651                 :            :     }
     652                 :        571 : }
     653                 :            : 
     654                 :         34 : void SfxChildWindow::Show( sal_uInt16 nFlags )
     655                 :            : {
     656      [ -  -  + ]:         34 :     switch ( pWindow->GetType() )
     657                 :            :     {
     658                 :            :         case RSC_DOCKINGWINDOW :
     659                 :          0 :             ((DockingWindow*)pWindow)->Show( sal_True, nFlags );
     660                 :          0 :             break;
     661                 :            :         case RSC_TOOLBOX :
     662                 :          0 :             ((ToolBox*)pWindow)->Show( sal_True, nFlags );
     663                 :          0 :             break;
     664                 :            :         default:
     665                 :         34 :             pWindow->Show( sal_True, nFlags );
     666                 :         34 :             break;
     667                 :            :     }
     668                 :         34 : }
     669                 :            : 
     670                 :          0 : Window* SfxChildWindow::GetContextWindow( SfxModule *pModule ) const
     671                 :            : {
     672 [ #  # ][ #  # ]:          0 :     return pModule == pImp->pContextModule && pContext ? pContext->GetWindow(): 0;
     673                 :            : }
     674                 :            : 
     675                 :        575 : void SfxChildWindow::SetWorkWindow_Impl( SfxWorkWindow* pWin )
     676                 :            : {
     677                 :        575 :     pImp->pWorkWin = pWin;
     678 [ +  - ][ -  + ]:        575 :     if ( pWin && pWindow->HasChildPathFocus() )
                 [ -  + ]
     679                 :          0 :         pImp->pWorkWin->SetActiveChild_Impl( pWindow );
     680                 :        575 : }
     681                 :            : 
     682                 :          0 : void SfxChildWindow::Activate_Impl()
     683                 :            : {
     684         [ #  # ]:          0 :     if(pImp->pWorkWin!=NULL)
     685                 :          0 :         pImp->pWorkWin->SetActiveChild_Impl( pWindow );
     686                 :          0 : }
     687                 :            : 
     688                 :          2 : void SfxChildWindow::Deactivate_Impl()
     689                 :            : {
     690                 :          2 : }
     691                 :            : 
     692                 :        172 : sal_Bool SfxChildWindow::QueryClose()
     693                 :            : {
     694                 :        172 :     sal_Bool bAllow = sal_True;
     695                 :            : 
     696         [ -  + ]:        172 :     if ( pImp->xFrame.is() )
     697                 :            :     {
     698 [ #  # ][ #  # ]:          0 :         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >  xCtrl = pImp->xFrame->getController();
     699         [ #  # ]:          0 :         if ( xCtrl.is() )
     700 [ #  # ][ #  # ]:          0 :             bAllow = xCtrl->suspend( sal_True );
     701                 :            :     }
     702                 :            : 
     703         [ +  - ]:        172 :     if ( bAllow )
     704                 :        172 :         bAllow = !GetWindow()->IsInModalMode();
     705                 :            : 
     706                 :        172 :     return bAllow;
     707                 :            : }
     708                 :            : 
     709                 :       1030 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >  SfxChildWindow::GetFrame()
     710                 :            : {
     711                 :       1030 :     return pImp->xFrame;
     712                 :            : }
     713                 :            : 
     714                 :          2 : void SfxChildWindow::SetFrame( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > & rFrame )
     715                 :            : {
     716                 :            :     // Do nothing if nothing will be changed ...
     717         [ +  - ]:          2 :     if( pImp->xFrame != rFrame )
     718                 :            :     {
     719                 :            :         // ... but stop listening on old frame, if connection exist!
     720         [ -  + ]:          2 :         if( pImp->xFrame.is() )
     721                 :          0 :             pImp->xFrame->removeEventListener( pImp->xListener );
     722                 :            : 
     723                 :            :         // If new frame isnt NULL -> we must guarantee valid listener for disposing events.
     724                 :            :         // Use already existing or create new one.
     725         [ +  - ]:          2 :         if( rFrame.is() )
     726         [ +  - ]:          2 :             if( !pImp->xListener.is() )
     727 [ +  - ][ +  - ]:          2 :                 pImp->xListener = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >( new DisposeListener( this, pImp ) );
                 [ +  - ]
     728                 :            : 
     729                 :            :         // Set new frame in data container
     730                 :            :         // and build new listener connection, if neccessary.
     731                 :          2 :         pImp->xFrame = rFrame;
     732         [ +  - ]:          2 :         if( pImp->xFrame.is() )
     733                 :          2 :             pImp->xFrame->addEventListener( pImp->xListener );
     734                 :            :     }
     735                 :          2 : }
     736                 :            : 
     737                 :        263 : sal_Bool SfxChildWindow::CanGetFocus() const
     738                 :            : {
     739                 :        263 :     return !(pImp->pFact->aInfo.nFlags & SFX_CHILDWIN_CANTGETFOCUS);
     740                 :            : }
     741                 :            : 
     742                 :        174 : void SfxChildWindowContext::RegisterChildWindowContext(SfxModule* pMod, sal_uInt16 nId, SfxChildWinContextFactory* pFact)
     743                 :            : {
     744                 :        174 :     SFX_APP()->RegisterChildWindowContext_Impl( pMod, nId, pFact );
     745                 :        174 : }
     746                 :            : 
     747                 :       7055 : void SfxChildWindow::RegisterChildWindow(SfxModule* pMod, SfxChildWinFactory* pFact)
     748                 :            : {
     749                 :       7055 :     SFX_APP()->RegisterChildWindow_Impl( pMod, pFact );
     750                 :       7055 : }
     751                 :            : 
     752                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10