LCOV - code coverage report
Current view: top level - sfx2/source/dialog - basedlgs.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 59 326 18.1 %
Date: 2012-08-25 Functions: 14 51 27.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 37 564 6.6 %

           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                 :            : #include <stdlib.h>
      21                 :            : #include <vcl/fixed.hxx>
      22                 :            : #include <vcl/help.hxx>
      23                 :            : #include <vcl/msgbox.hxx>
      24                 :            : #include <svl/eitem.hxx>
      25                 :            : #include <unotools/viewoptions.hxx>
      26                 :            : #include <svtools/fixedhyper.hxx>
      27                 :            : #include <svtools/controldims.hrc>
      28                 :            : 
      29                 :            : #include <sfx2/basedlgs.hxx>
      30                 :            : #include <sfx2/viewfrm.hxx>
      31                 :            : #include <sfx2/tabdlg.hxx>
      32                 :            : #include <sfx2/app.hxx>
      33                 :            : #include <sfx2/bindings.hxx>
      34                 :            : #include <sfx2/dispatch.hxx>
      35                 :            : #include <sfx2/childwin.hxx>
      36                 :            : #include <sfx2/viewsh.hxx>
      37                 :            : #include "sfx2/sfxhelp.hxx"
      38                 :            : #include "workwin.hxx"
      39                 :            : #include "sfx2/sfxresid.hxx"
      40                 :            : #include "dialog.hrc"
      41                 :            : 
      42                 :            : using namespace ::com::sun::star::uno;
      43                 :            : using namespace ::rtl;
      44                 :            : 
      45                 :            : #define USERITEM_NAME OUString("UserItem")
      46                 :            : 
      47 [ #  # ][ #  # ]:          0 : class SfxModelessDialog_Impl : public SfxListener
                 [ #  # ]
      48                 :            : {
      49                 :            : public:
      50                 :            :     rtl::OString aWinState;
      51                 :            :     SfxChildWindow* pMgr;
      52                 :            :     sal_Bool            bConstructed;
      53                 :            :     void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
      54                 :            : 
      55                 :            :     Timer           aMoveTimer;
      56                 :            : };
      57                 :            : 
      58                 :          0 : void SfxModelessDialog_Impl::Notify( SfxBroadcaster&, const SfxHint& rHint )
      59                 :            : {
      60         [ #  # ]:          0 :     if ( rHint.IsA(TYPE(SfxSimpleHint)) )
      61                 :            :     {
      62         [ #  # ]:          0 :         switch( ( (SfxSimpleHint&) rHint ).GetId() )
      63                 :            :         {
      64                 :            :             case SFX_HINT_DYING:
      65                 :          0 :                 pMgr->Destroy();
      66                 :          0 :                 break;
      67                 :            :         }
      68                 :            :     }
      69                 :          0 : }
      70                 :            : 
      71 [ +  - ][ -  + ]:        102 : class SfxFloatingWindow_Impl : public SfxListener
                 [ +  - ]
      72                 :            : {
      73                 :            : public:
      74                 :            :     rtl::OString aWinState;
      75                 :            :     SfxChildWindow* pMgr;
      76                 :            :     sal_Bool            bConstructed;
      77                 :            :     Timer           aMoveTimer;
      78                 :            : 
      79                 :            :     void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
      80                 :            : };
      81                 :            : 
      82                 :         28 : void SfxFloatingWindow_Impl::Notify( SfxBroadcaster&, const SfxHint& rHint )
      83                 :            : {
      84         [ +  - ]:         28 :     if ( rHint.IsA(TYPE(SfxSimpleHint)) )
      85                 :            :     {
      86         [ -  + ]:         28 :         switch( ( (SfxSimpleHint&) rHint ).GetId() )
      87                 :            :         {
      88                 :            :             case SFX_HINT_DYING:
      89                 :          0 :                 pMgr->Destroy();
      90                 :         28 :                 break;
      91                 :            :         }
      92                 :            :     }
      93                 :         28 : }
      94                 :            : 
      95                 :            : // class SfxModalDefParentHelper -----------------------------------------
      96                 :            : 
      97                 :          0 : SfxModalDefParentHelper::SfxModalDefParentHelper( Window *pWindow)
      98                 :            : {
      99                 :          0 :     pOld = Application::GetDefDialogParent();
     100                 :          0 :     Application::SetDefDialogParent( pWindow );
     101                 :          0 : }
     102                 :            : 
     103                 :            : // -----------------------------------------------------------------------
     104                 :            : 
     105                 :          0 : SfxModalDefParentHelper::~SfxModalDefParentHelper()
     106                 :            : {
     107                 :          0 :     Application::SetDefDialogParent( pOld );
     108                 :          0 : }
     109                 :            : 
     110                 :            : // -----------------------------------------------------------------------
     111                 :            : 
     112                 :          0 : void SfxModalDialog::SetDialogData_Impl()
     113                 :            : {
     114                 :            :     // save settings (position and user data)
     115 [ #  # ][ #  # ]:          0 :     SvtViewOptions aDlgOpt( E_DIALOG, String::CreateFromInt32( nUniqId ) );
         [ #  # ][ #  # ]
     116                 :            :     aDlgOpt.SetWindowState(OStringToOUString(
     117 [ #  # ][ #  # ]:          0 :         GetWindowState(WINDOWSTATE_MASK_POS), RTL_TEXTENCODING_ASCII_US));
                 [ #  # ]
     118         [ #  # ]:          0 :     if ( aExtraData.Len() )
     119 [ #  # ][ #  # ]:          0 :         aDlgOpt.SetUserItem( USERITEM_NAME, makeAny( OUString( aExtraData ) ) );
         [ #  # ][ #  # ]
     120                 :          0 : }
     121                 :            : 
     122                 :            : // -----------------------------------------------------------------------
     123                 :            : 
     124                 :          0 : void SfxModalDialog::GetDialogData_Impl()
     125                 :            : 
     126                 :            : /*  [Description]
     127                 :            : 
     128                 :            :     Helper function, reads the dialogue position from the ini file and
     129                 :            :     puts them on the transfered window.
     130                 :            : */
     131                 :            : 
     132                 :            : {
     133 [ #  # ][ #  # ]:          0 :     SvtViewOptions aDlgOpt( E_DIALOG, String::CreateFromInt32( nUniqId ) );
         [ #  # ][ #  # ]
     134 [ #  # ][ #  # ]:          0 :     if ( aDlgOpt.Exists() )
     135                 :            :     {
     136                 :            :         // load settings
     137 [ #  # ][ #  # ]:          0 :         SetWindowState( rtl::OUStringToOString( aDlgOpt.GetWindowState().getStr(), RTL_TEXTENCODING_ASCII_US ) );
                 [ #  # ]
     138         [ #  # ]:          0 :         Any aUserItem = aDlgOpt.GetUserItem( USERITEM_NAME );
     139                 :          0 :         OUString aTemp;
     140         [ #  # ]:          0 :         if ( aUserItem >>= aTemp )
     141 [ #  # ][ #  # ]:          0 :             aExtraData = String( aTemp );
                 [ #  # ]
     142         [ #  # ]:          0 :     }
     143                 :          0 : }
     144                 :            : 
     145                 :            : // -----------------------------------------------------------------------
     146                 :            : 
     147                 :          0 : void SfxModalDialog::init()
     148                 :            : {
     149                 :          0 :     GetDialogData_Impl();
     150                 :          0 : }
     151                 :            : 
     152                 :            : // -----------------------------------------------------------------------
     153                 :            : 
     154                 :          0 : SfxModalDialog::SfxModalDialog(Window* pParent, const ResId &rResId )
     155                 :            : 
     156                 :            : /*  [Description]
     157                 :            : 
     158                 :            :     Constructor of the general base class for modal Dialoge;
     159                 :            :     ResId is used as ID in ini-file. The saved position from there is set.
     160                 :            : */
     161                 :            : 
     162                 :            : :   ModalDialog(pParent, rResId),
     163                 :          0 :     nUniqId(rResId.GetId()),
     164                 :            :     pInputSet(0),
     165         [ #  # ]:          0 :     pOutputSet(0)
     166                 :            : {
     167         [ #  # ]:          0 :     init();
     168                 :          0 : }
     169                 :            : 
     170                 :            : // -----------------------------------------------------------------------
     171                 :            : 
     172                 :          0 : SfxModalDialog::SfxModalDialog(Window* pParent,
     173                 :            :                                sal_uInt32 nUniqueId,
     174                 :            :                                WinBits nWinStyle) :
     175                 :            : /*  [Description]
     176                 :            : 
     177                 :            :     Constructor of the general base class for modal Dialoge;
     178                 :            :     The ID for the ini-file wird explicilty handed over.
     179                 :            :     The saved position from there is set.
     180                 :            : */
     181                 :            : 
     182                 :            :     ModalDialog(pParent, nWinStyle),
     183                 :            :     nUniqId(nUniqueId),
     184                 :            :     pInputSet(0),
     185         [ #  # ]:          0 :     pOutputSet(0)
     186                 :            : {
     187         [ #  # ]:          0 :     init();
     188                 :          0 : }
     189                 :            : 
     190                 :            : // -----------------------------------------------------------------------
     191                 :            : 
     192         [ #  # ]:          0 : SfxModalDialog::~SfxModalDialog()
     193                 :            : 
     194                 :            : /*  [Description]
     195                 :            : 
     196                 :            :     Destructor; writes the Dialog position in the ini-file.
     197                 :            : */
     198                 :            : 
     199                 :            : {
     200         [ #  # ]:          0 :     SetDialogData_Impl();
     201 [ #  # ][ #  # ]:          0 :     delete pOutputSet;
     202         [ #  # ]:          0 : }
     203                 :            : 
     204                 :          0 : void SfxModalDialog::CreateOutputItemSet( SfxItemPool& rPool )
     205                 :            : {
     206                 :            :     DBG_ASSERT( !pOutputSet, "Double creation of OutputSet!" );
     207         [ #  # ]:          0 :     if (!pOutputSet)
     208         [ #  # ]:          0 :         pOutputSet = new SfxAllItemSet( rPool );
     209                 :          0 : }
     210                 :            : 
     211                 :            : // -----------------------------------------------------------------------
     212                 :            : 
     213                 :          0 : void SfxModalDialog::CreateOutputItemSet( const SfxItemSet& rSet )
     214                 :            : {
     215                 :            :     DBG_ASSERT( !pOutputSet, "Double creation of OutputSet!" );
     216         [ #  # ]:          0 :     if (!pOutputSet)
     217                 :            :     {
     218         [ #  # ]:          0 :         pOutputSet = new SfxItemSet( rSet );
     219                 :          0 :         pOutputSet->ClearItem();
     220                 :            :     }
     221                 :          0 : }
     222                 :            : 
     223                 :            : //-------------------------------------------------------------------------
     224                 :          0 : void SfxModelessDialog::StateChanged( StateChangedType nStateChange )
     225                 :            : {
     226         [ #  # ]:          0 :     if ( nStateChange == STATE_CHANGE_INITSHOW )
     227                 :            :     {
     228         [ #  # ]:          0 :         if ( !pImp->aWinState.isEmpty() )
     229                 :            :         {
     230                 :          0 :             SetWindowState( pImp->aWinState );
     231                 :            :         }
     232                 :            :         else
     233                 :            :         {
     234         [ #  # ]:          0 :             Point aPos = GetPosPixel();
     235         [ #  # ]:          0 :             if ( !aPos.X() )
     236                 :            :             {
     237         [ #  # ]:          0 :                 aSize = GetSizePixel();
     238                 :            : 
     239         [ #  # ]:          0 :                 Size aParentSize = GetParent()->GetOutputSizePixel();
     240         [ #  # ]:          0 :                 Size aDlgSize = GetSizePixel();
     241                 :          0 :                 aPos.X() += ( aParentSize.Width() - aDlgSize.Width() ) / 2;
     242                 :          0 :                 aPos.Y() += ( aParentSize.Height() - aDlgSize.Height() ) / 2;
     243                 :            : 
     244                 :          0 :                 Point aPoint;
     245         [ #  # ]:          0 :                 Rectangle aRect = GetDesktopRectPixel();
     246                 :          0 :                 aPoint.X() = aRect.Right() - aDlgSize.Width();
     247                 :          0 :                 aPoint.Y() = aRect.Bottom() - aDlgSize.Height();
     248                 :            : 
     249         [ #  # ]:          0 :                 aPoint = OutputToScreenPixel( aPoint );
     250                 :            : 
     251         [ #  # ]:          0 :                 if ( aPos.X() > aPoint.X() )
     252                 :          0 :                     aPos.X() = aPoint.X() ;
     253         [ #  # ]:          0 :                 if ( aPos.Y() > aPoint.Y() )
     254                 :          0 :                     aPos.Y() = aPoint.Y();
     255                 :            : 
     256         [ #  # ]:          0 :                 if ( aPos.X() < 0 ) aPos.X() = 0;
     257         [ #  # ]:          0 :                 if ( aPos.Y() < 0 ) aPos.Y() = 0;
     258                 :            : 
     259         [ #  # ]:          0 :                 SetPosPixel( aPos );
     260                 :            :             }
     261                 :            :         }
     262                 :            : 
     263                 :          0 :         pImp->bConstructed = sal_True;
     264                 :            :     }
     265                 :            : 
     266                 :          0 :     ModelessDialog::StateChanged( nStateChange );
     267                 :          0 : }
     268                 :            : 
     269                 :          0 : void SfxModelessDialog::Initialize(SfxChildWinInfo *pInfo)
     270                 :            : 
     271                 :            : /*  [Description]
     272                 :            : 
     273                 :            :     Initialization of the class SfxModelessDialog via a SfxChildWinInfo.
     274                 :            :     The initialization is done only in a 2nd step after the constructor, this
     275                 :            :     constructor should be called from the derived class or from the
     276                 :            :     SfxChildWindows.
     277                 :            : */
     278                 :            : 
     279                 :            : {
     280                 :          0 :     pImp->aWinState = pInfo->aWinState;
     281                 :          0 : }
     282                 :            : 
     283                 :          0 : void SfxModelessDialog::Resize()
     284                 :            : 
     285                 :            : /*  [Description]
     286                 :            : 
     287                 :            :     This virtual method of the class FloatingWindow keeps track if a change
     288                 :            :     in size has been made. When this method is overridden by a derived class,
     289                 :            :     then the SfxFloatingWindow: Resize() must also be called.
     290                 :            : */
     291                 :            : 
     292                 :            : {
     293                 :          0 :     ModelessDialog::Resize();
     294 [ #  # ][ #  # ]:          0 :     if ( pImp->bConstructed && pImp->pMgr )
     295                 :            :     {
     296                 :            :         // start timer for saving window status information
     297                 :          0 :         pImp->aMoveTimer.Start();
     298                 :            :     }
     299                 :          0 : }
     300                 :            : 
     301                 :          0 : void SfxModelessDialog::Move()
     302                 :            : {
     303                 :          0 :     ModelessDialog::Move();
     304 [ #  # ][ #  # ]:          0 :     if ( pImp->bConstructed && pImp->pMgr && IsReallyVisible() )
         [ #  # ][ #  # ]
     305                 :            :     {
     306                 :            :         // start timer for saving window status information
     307                 :          0 :         pImp->aMoveTimer.Start();
     308                 :            :     }
     309                 :          0 : }
     310                 :            : 
     311                 :            : /*
     312                 :            :     Implements a timer event that is triggered by a move or resize of the window
     313                 :            :     This will save config information to Views.xcu with a small delay
     314                 :            : */
     315                 :          0 : IMPL_LINK_NOARG(SfxModelessDialog, TimerHdl)
     316                 :            : {
     317                 :          0 :     pImp->aMoveTimer.Stop();
     318 [ #  # ][ #  # ]:          0 :     if ( pImp->bConstructed && pImp->pMgr )
     319                 :            :     {
     320         [ #  # ]:          0 :         if ( !IsRollUp() )
     321                 :          0 :             aSize = GetSizePixel();
     322                 :          0 :         sal_uIntPtr nMask = WINDOWSTATE_MASK_POS | WINDOWSTATE_MASK_STATE;
     323         [ #  # ]:          0 :         if ( GetStyle() & WB_SIZEABLE )
     324                 :          0 :             nMask |= ( WINDOWSTATE_MASK_WIDTH | WINDOWSTATE_MASK_HEIGHT );
     325                 :          0 :         pImp->aWinState = GetWindowState( nMask );
     326                 :          0 :         GetBindings().GetWorkWindow_Impl()->ConfigChild_Impl( SFX_CHILDWIN_DOCKINGWINDOW, SFX_ALIGNDOCKINGWINDOW, pImp->pMgr->GetType() );
     327                 :            :     }
     328                 :          0 :     return 0;
     329                 :            : }
     330                 :            : 
     331                 :            : // -----------------------------------------------------------------------
     332                 :            : 
     333                 :          0 : SfxModelessDialog::SfxModelessDialog( SfxBindings *pBindinx,
     334                 :            :                         SfxChildWindow *pCW, Window *pParent,
     335                 :            :                         const ResId& rResId ) :
     336                 :            :     ModelessDialog(pParent, rResId),
     337                 :            :     pBindings(pBindinx),
     338 [ #  # ][ #  # ]:          0 :     pImp( new SfxModelessDialog_Impl )
     339                 :            : {
     340                 :          0 :     pImp->pMgr = pCW;
     341                 :          0 :     pImp->bConstructed = sal_False;
     342 [ #  # ][ #  # ]:          0 :     SetUniqueId( GetHelpId() );
     343         [ #  # ]:          0 :     SetHelpId("");
     344         [ #  # ]:          0 :     if ( pBindinx )
     345         [ #  # ]:          0 :         pImp->StartListening( *pBindinx );
     346         [ #  # ]:          0 :     pImp->aMoveTimer.SetTimeout(50);
     347         [ #  # ]:          0 :     pImp->aMoveTimer.SetTimeoutHdl(LINK(this,SfxModelessDialog,TimerHdl));
     348                 :          0 : }
     349                 :            : 
     350                 :            : // -----------------------------------------------------------------------
     351                 :            : 
     352                 :          0 : long SfxModelessDialog::Notify( NotifyEvent& rEvt )
     353                 :            : 
     354                 :            : /*  [Description]
     355                 :            : 
     356                 :            :     If a ModelessDialog is enabled its ViewFrame wil be activated.
     357                 :            :     This is necessary by PluginInFrames.
     358                 :            : */
     359                 :            : 
     360                 :            : {
     361         [ #  # ]:          0 :     if ( rEvt.GetType() == EVENT_GETFOCUS )
     362                 :            :     {
     363 [ #  # ][ #  # ]:          0 :         pBindings->SetActiveFrame( pImp->pMgr->GetFrame() );
     364         [ #  # ]:          0 :         pImp->pMgr->Activate_Impl();
     365                 :          0 :         Window* pWindow = rEvt.GetWindow();
     366                 :          0 :         rtl::OString sHelpId;
     367 [ #  # ][ #  # ]:          0 :         while ( sHelpId.isEmpty() && pWindow )
                 [ #  # ]
     368                 :            :         {
     369         [ #  # ]:          0 :             sHelpId = pWindow->GetHelpId();
     370         [ #  # ]:          0 :             pWindow = pWindow->GetParent();
     371                 :            :         }
     372                 :            : 
     373         [ #  # ]:          0 :         if ( !sHelpId.isEmpty() )
     374 [ #  # ][ #  # ]:          0 :             SfxHelp::OpenHelpAgent( &pBindings->GetDispatcher_Impl()->GetFrame()->GetFrame(), sHelpId );
                 [ #  # ]
     375                 :            :     }
     376 [ #  # ][ #  # ]:          0 :     else if ( rEvt.GetType() == EVENT_LOSEFOCUS && !HasChildPathFocus() )
                 [ #  # ]
     377                 :            :     {
     378         [ #  # ]:          0 :         pBindings->SetActiveFrame( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > () );
     379                 :          0 :         pImp->pMgr->Deactivate_Impl();
     380                 :            :     }
     381         [ #  # ]:          0 :     else if( rEvt.GetType() == EVENT_KEYINPUT )
     382                 :            :     {
     383                 :            :         // First, allow KeyInput for Dialog functions ( TAB etc. )
     384 [ #  # ][ #  # ]:          0 :         if ( !ModelessDialog::Notify( rEvt ) && SfxViewShell::Current() )
                 [ #  # ]
     385                 :            :             // then also for valid global accelerators.
     386                 :          0 :             return SfxViewShell::Current()->GlobalKeyInput_Impl( *rEvt.GetKeyEvent() );
     387                 :          0 :         return sal_True;
     388                 :            :     }
     389                 :            : 
     390                 :          0 :     return ModelessDialog::Notify( rEvt );
     391                 :            : }
     392                 :            : 
     393                 :            : // -----------------------------------------------------------------------
     394                 :            : 
     395                 :          0 : SfxModelessDialog::~SfxModelessDialog()
     396                 :            : 
     397                 :            : /*  [Description]
     398                 :            : 
     399                 :            :     Destructor
     400                 :            : */
     401                 :            : 
     402                 :            : {
     403 [ #  # ][ #  # ]:          0 :     if ( pImp->pMgr->GetFrame().is() && pImp->pMgr->GetFrame() == pBindings->GetActiveFrame() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
          #  #  #  #  #  
                      # ]
     404 [ #  # ][ #  # ]:          0 :         pBindings->SetActiveFrame( NULL );
     405 [ #  # ][ #  # ]:          0 :     delete pImp;
     406         [ #  # ]:          0 : }
     407                 :            : 
     408                 :            : //-------------------------------------------------------------------------
     409                 :            : 
     410                 :          0 : sal_Bool SfxModelessDialog::Close()
     411                 :            : 
     412                 :            : /*  [Description]
     413                 :            : 
     414                 :            :     The window is closed when the ChildWindow is destroyed by running the
     415                 :            :     ChildWindow-slots. If this is method is overridden by a derived class
     416                 :            :     method, then the SfxModelessDialogWindow: Close() must be called afterwards
     417                 :            :     if the Close() was not cancelled with "return sal_False".
     418                 :            : */
     419                 :            : 
     420                 :            : {
     421                 :            :     // Execute with Parameters, since Toggle is ignored by some ChildWindows.
     422         [ #  # ]:          0 :     SfxBoolItem aValue( pImp->pMgr->GetType(), sal_False);
     423                 :            :     pBindings->GetDispatcher_Impl()->Execute(
     424                 :          0 :         pImp->pMgr->GetType(),
     425         [ #  # ]:          0 :         SFX_CALLMODE_RECORD|SFX_CALLMODE_SYNCHRON, &aValue, 0L );
     426         [ #  # ]:          0 :     return sal_True;
     427                 :            : }
     428                 :            : 
     429                 :            : //-------------------------------------------------------------------------
     430                 :            : 
     431                 :          0 : void SfxModelessDialog::FillInfo(SfxChildWinInfo& rInfo) const
     432                 :            : 
     433                 :            : /*  [Description]
     434                 :            : 
     435                 :            :     Fills a SfxChildWinInfo with specific data from SfxModelessDialog,
     436                 :            :     so that it can be written in the INI file. It is assumed that rinfo
     437                 :            :     receives all other possible relevant data in the ChildWindow class.
     438                 :            :     ModelessDialogs have no specific information, so that the base
     439                 :            :     implementation does nothing and therefore must not be called.
     440                 :            : */
     441                 :            : 
     442                 :            : {
     443                 :          0 :     rInfo.aSize  = aSize;
     444         [ #  # ]:          0 :     if ( IsRollUp() )
     445                 :          0 :         rInfo.nFlags |= SFX_CHILDWIN_ZOOMIN;
     446                 :          0 : }
     447                 :            : 
     448                 :            : // -----------------------------------------------------------------------
     449                 :            : 
     450                 :        374 : long SfxFloatingWindow::Notify( NotifyEvent& rEvt )
     451                 :            : 
     452                 :            : /*  [Description]
     453                 :            : 
     454                 :            :     If a ModelessDialog is enabled, its ViewFrame will be activated.
     455                 :            :     This necessary for the PluginInFrames.
     456                 :            : */
     457                 :            : 
     458                 :            : {
     459         [ -  + ]:        374 :     if ( rEvt.GetType() == EVENT_GETFOCUS )
     460                 :            :     {
     461 [ #  # ][ #  # ]:          0 :         pBindings->SetActiveFrame( pImp->pMgr->GetFrame() );
     462         [ #  # ]:          0 :         pImp->pMgr->Activate_Impl();
     463                 :          0 :         Window* pWindow = rEvt.GetWindow();
     464                 :          0 :         rtl::OString sHelpId;
     465 [ #  # ][ #  # ]:          0 :         while ( sHelpId.isEmpty() && pWindow )
                 [ #  # ]
     466                 :            :         {
     467         [ #  # ]:          0 :             sHelpId = pWindow->GetHelpId();
     468         [ #  # ]:          0 :             pWindow = pWindow->GetParent();
     469                 :            :         }
     470                 :            : 
     471         [ #  # ]:          0 :         if ( !sHelpId.isEmpty() )
     472 [ #  # ][ #  # ]:          0 :             SfxHelp::OpenHelpAgent( &pBindings->GetDispatcher_Impl()->GetFrame()->GetFrame(), sHelpId );
                 [ #  # ]
     473                 :            :     }
     474         [ -  + ]:        374 :     else if ( rEvt.GetType() == EVENT_LOSEFOCUS )
     475                 :            :     {
     476         [ #  # ]:          0 :         if ( !HasChildPathFocus() )
     477                 :            :         {
     478         [ #  # ]:          0 :             pBindings->SetActiveFrame( NULL );
     479                 :          0 :             pImp->pMgr->Deactivate_Impl();
     480                 :            :         }
     481                 :            :     }
     482         [ -  + ]:        374 :     else if( rEvt.GetType() == EVENT_KEYINPUT )
     483                 :            :     {
     484                 :            :         // First, allow KeyInput for Dialog functions
     485 [ #  # ][ #  # ]:          0 :         if ( !FloatingWindow::Notify( rEvt ) && SfxViewShell::Current() )
                 [ #  # ]
     486                 :            :             // then also for valid global accelerators.
     487                 :          0 :             return SfxViewShell::Current()->GlobalKeyInput_Impl( *rEvt.GetKeyEvent() );
     488                 :          0 :         return sal_True;
     489                 :            :     }
     490                 :            : 
     491                 :        374 :     return FloatingWindow::Notify( rEvt );
     492                 :            : }
     493                 :            : 
     494                 :            : // -----------------------------------------------------------------------
     495                 :            : 
     496                 :          0 : SfxFloatingWindow::SfxFloatingWindow( SfxBindings *pBindinx,
     497                 :            :                         SfxChildWindow *pCW,
     498                 :            :                         Window* pParent, WinBits nWinBits) :
     499                 :            :     FloatingWindow (pParent, nWinBits),
     500                 :            :     pBindings(pBindinx),
     501 [ #  # ][ #  # ]:          0 :     pImp( new SfxFloatingWindow_Impl )
     502                 :            : {
     503                 :          0 :     pImp->pMgr = pCW;
     504                 :          0 :     pImp->bConstructed = sal_False;
     505 [ #  # ][ #  # ]:          0 :     SetUniqueId( GetHelpId() );
     506         [ #  # ]:          0 :     SetHelpId("");
     507         [ #  # ]:          0 :     if ( pBindinx )
     508         [ #  # ]:          0 :         pImp->StartListening( *pBindinx );
     509         [ #  # ]:          0 :     pImp->aMoveTimer.SetTimeout(50);
     510         [ #  # ]:          0 :     pImp->aMoveTimer.SetTimeoutHdl(LINK(this,SfxFloatingWindow,TimerHdl));
     511                 :          0 : }
     512                 :            : 
     513                 :            : // -----------------------------------------------------------------------
     514                 :            : 
     515                 :         34 : SfxFloatingWindow::SfxFloatingWindow( SfxBindings *pBindinx,
     516                 :            :                         SfxChildWindow *pCW,
     517                 :            :                         Window* pParent,
     518                 :            :                         const ResId& rResId) :
     519                 :            :     FloatingWindow(pParent, rResId),
     520                 :            :     pBindings(pBindinx),
     521 [ +  - ][ +  - ]:         34 :     pImp( new SfxFloatingWindow_Impl )
     522                 :            : {
     523                 :         34 :     pImp->pMgr = pCW;
     524                 :         34 :     pImp->bConstructed = sal_False;
     525 [ +  - ][ +  - ]:         34 :     SetUniqueId( GetHelpId() );
     526         [ +  - ]:         34 :     SetHelpId("");
     527         [ +  - ]:         34 :     if ( pBindinx )
     528         [ +  - ]:         34 :         pImp->StartListening( *pBindinx );
     529         [ +  - ]:         34 :     pImp->aMoveTimer.SetTimeout(50);
     530         [ +  - ]:         34 :     pImp->aMoveTimer.SetTimeoutHdl(LINK(this,SfxFloatingWindow,TimerHdl));
     531                 :         34 : }
     532                 :            : 
     533                 :            : //-------------------------------------------------------------------------
     534                 :            : 
     535                 :          0 : sal_Bool SfxFloatingWindow::Close()
     536                 :            : 
     537                 :            : /*  [Description]
     538                 :            : 
     539                 :            :     The window is closed when the ChildWindow is destroyed by running the
     540                 :            :     ChildWindow-slots. If this is method is overridden by a derived class
     541                 :            :     method, then the SfxModelessDialogWindow: Close) must be called afterwards
     542                 :            :     if the Close() was not cancelled with "return sal_False".
     543                 :            : */
     544                 :            : 
     545                 :            : {
     546                 :            :     // Execute with Parameters, since Toggle is ignored by some ChildWindows.
     547         [ #  # ]:          0 :     SfxBoolItem aValue( pImp->pMgr->GetType(), sal_False);
     548                 :            :     pBindings->GetDispatcher_Impl()->Execute(
     549                 :          0 :             pImp->pMgr->GetType(),
     550         [ #  # ]:          0 :             SFX_CALLMODE_RECORD|SFX_CALLMODE_SYNCHRON, &aValue, 0L );
     551         [ #  # ]:          0 :     return sal_True;
     552                 :            : }
     553                 :            : 
     554                 :            : // -----------------------------------------------------------------------
     555                 :            : 
     556                 :         34 : SfxFloatingWindow::~SfxFloatingWindow()
     557                 :            : 
     558                 :            : /*  [Description]
     559                 :            : 
     560                 :            :     Destructor
     561                 :            : */
     562                 :            : 
     563                 :            : {
     564 [ +  - ][ +  - ]:         34 :     if ( pImp->pMgr->GetFrame() == pBindings->GetActiveFrame() )
         [ +  - ][ -  + ]
     565 [ #  # ][ #  # ]:          0 :         pBindings->SetActiveFrame( NULL );
     566 [ +  - ][ +  - ]:         34 :     delete pImp;
     567         [ -  + ]:         34 : }
     568                 :            : 
     569                 :            : //-------------------------------------------------------------------------
     570                 :            : 
     571                 :        170 : void SfxFloatingWindow::Resize()
     572                 :            : 
     573                 :            : /*  [Description]
     574                 :            : 
     575                 :            :     This virtual method of the class FloatingWindow keeps track if a change
     576                 :            :     in size has been made. When this method is overridden by a derived class,
     577                 :            :     then the SfxFloatingWindow: Resize() must also be called.
     578                 :            : */
     579                 :            : 
     580                 :            : {
     581                 :        170 :     FloatingWindow::Resize();
     582 [ +  - ][ +  + ]:        170 :     if ( pImp->bConstructed && pImp->pMgr )
     583                 :            :     {
     584                 :            :         // start timer for saving window status information
     585                 :         68 :         pImp->aMoveTimer.Start();
     586                 :            :     }
     587                 :        170 : }
     588                 :            : 
     589                 :         34 : void SfxFloatingWindow::Move()
     590                 :            : {
     591                 :         34 :     FloatingWindow::Move();
     592 [ #  # ][ -  + ]:         34 :     if ( pImp->bConstructed && pImp->pMgr )
     593                 :            :     {
     594                 :            :         // start timer for saving window status information
     595                 :          0 :         pImp->aMoveTimer.Start();
     596                 :            :     }
     597                 :         34 : }
     598                 :            : 
     599                 :            : /*
     600                 :            :     Implements a timer event that is triggered by a move or resize of the window
     601                 :            :     This will save config information to Views.xcu with a small delay
     602                 :            : */
     603                 :         20 : IMPL_LINK_NOARG(SfxFloatingWindow, TimerHdl)
     604                 :            : {
     605                 :         20 :     pImp->aMoveTimer.Stop();
     606 [ +  - ][ +  - ]:         20 :     if ( pImp->bConstructed && pImp->pMgr )
     607                 :            :     {
     608         [ +  - ]:         20 :         if ( !IsRollUp() )
     609                 :         20 :             aSize = GetSizePixel();
     610                 :         20 :         sal_uIntPtr nMask = WINDOWSTATE_MASK_POS | WINDOWSTATE_MASK_STATE;
     611         [ -  + ]:         20 :         if ( GetStyle() & WB_SIZEABLE )
     612                 :          0 :             nMask |= ( WINDOWSTATE_MASK_WIDTH | WINDOWSTATE_MASK_HEIGHT );
     613                 :         20 :         pImp->aWinState = GetWindowState( nMask );
     614                 :         20 :         GetBindings().GetWorkWindow_Impl()->ConfigChild_Impl( SFX_CHILDWIN_DOCKINGWINDOW, SFX_ALIGNDOCKINGWINDOW, pImp->pMgr->GetType() );
     615                 :            :     }
     616                 :         20 :     return 0;
     617                 :            : }
     618                 :            : 
     619                 :            : //-------------------------------------------------------------------------
     620                 :        204 : void SfxFloatingWindow::StateChanged( StateChangedType nStateChange )
     621                 :            : {
     622         [ +  + ]:        204 :     if ( nStateChange == STATE_CHANGE_INITSHOW )
     623                 :            :     {
     624                 :            :         // FloatingWindows are not centered by default
     625         [ +  + ]:         68 :         if ( !pImp->aWinState.isEmpty() )
     626                 :         60 :             SetWindowState( pImp->aWinState );
     627                 :         68 :         pImp->bConstructed = sal_True;
     628                 :            :     }
     629                 :            : 
     630                 :        204 :     FloatingWindow::StateChanged( nStateChange );
     631                 :        204 : }
     632                 :            : 
     633                 :            : 
     634                 :         34 : void SfxFloatingWindow::Initialize(SfxChildWinInfo *pInfo)
     635                 :            : 
     636                 :            : /*  [Description]
     637                 :            : 
     638                 :            :     Initialization of a class SfxFloatingWindow through a SfxChildWinInfo.
     639                 :            :     The initialization is done only in a 2nd step after the constructor and
     640                 :            :     should be called by the constructor of the derived class or from the
     641                 :            :     SfxChildWindows.
     642                 :            : */
     643                 :            : {
     644                 :         34 :     pImp->aWinState = pInfo->aWinState;
     645                 :         34 : }
     646                 :            : 
     647                 :            : //-------------------------------------------------------------------------
     648                 :            : 
     649                 :         54 : void SfxFloatingWindow::FillInfo(SfxChildWinInfo& rInfo) const
     650                 :            : 
     651                 :            : /*  [Description]
     652                 :            : 
     653                 :            :     Fills a SfxChildWinInfo with specific data from SfxFloatingWindow,
     654                 :            :     so that it can be written in the INI file. It is assumed that rinfo
     655                 :            :     receives all other possible relevant data in the ChildWindow class.
     656                 :            :     Insertions are marked with size and the ZoomIn flag.
     657                 :            :     If this method is overridden, the base implementation must be called first.
     658                 :            : */
     659                 :            : 
     660                 :            : {
     661                 :         54 :     rInfo.aSize  = aSize;
     662         [ -  + ]:         54 :     if ( IsRollUp() )
     663                 :          0 :         rInfo.nFlags |= SFX_CHILDWIN_ZOOMIN;
     664                 :         54 : }
     665                 :            : 
     666                 :            : // SfxSingleTabDialog ----------------------------------------------------
     667                 :            : 
     668                 :          0 : IMPL_LINK_NOARG(SfxSingleTabDialog, OKHdl_Impl)
     669                 :            : 
     670                 :            : /*  [Description]
     671                 :            : 
     672                 :            :     Ok_Handler; FillItemSet() is called for setting of Page.
     673                 :            : */
     674                 :            : 
     675                 :            : {
     676         [ #  # ]:          0 :     if ( !GetInputItemSet() )
     677                 :            :     {
     678                 :            :         // TabPage without ItemSet
     679                 :          0 :         EndDialog( RET_OK );
     680                 :          0 :         return 1;
     681                 :            :     }
     682                 :            : 
     683         [ #  # ]:          0 :     if ( !GetOutputItemSet() )
     684                 :            :     {
     685                 :          0 :         CreateOutputItemSet( *GetInputItemSet() );
     686                 :            :     }
     687                 :          0 :     sal_Bool bModified = sal_False;
     688                 :            : 
     689         [ #  # ]:          0 :     if ( pImpl->m_pSfxPage->HasExchangeSupport() )
     690                 :            :     {
     691                 :          0 :         int nRet = pImpl->m_pSfxPage->DeactivatePage( GetOutputSetImpl() );
     692         [ #  # ]:          0 :         if ( nRet != SfxTabPage::LEAVE_PAGE )
     693                 :          0 :             return 0;
     694                 :            :         else
     695                 :          0 :             bModified = ( GetOutputItemSet()->Count() > 0 );
     696                 :            :     }
     697                 :            :     else
     698                 :          0 :         bModified = pImpl->m_pSfxPage->FillItemSet( *GetOutputSetImpl() );
     699                 :            : 
     700         [ #  # ]:          0 :     if ( bModified )
     701                 :            :     {
     702                 :            :         // Save user data in IniManager.
     703         [ #  # ]:          0 :         pImpl->m_pSfxPage->FillUserData();
     704         [ #  # ]:          0 :         String sData( pImpl->m_pSfxPage->GetUserData() );
     705 [ #  # ][ #  # ]:          0 :         SvtViewOptions aPageOpt( E_TABPAGE, String::CreateFromInt32( GetUniqId() ) );
         [ #  # ][ #  # ]
     706 [ #  # ][ #  # ]:          0 :         aPageOpt.SetUserItem( USERITEM_NAME, makeAny( OUString( sData ) ) );
                 [ #  # ]
     707 [ #  # ][ #  # ]:          0 :         EndDialog( RET_OK );
                 [ #  # ]
     708                 :            :     }
     709                 :            :     else
     710                 :          0 :         EndDialog( RET_CANCEL );
     711                 :          0 :     return 0;
     712                 :            : }
     713                 :            : 
     714                 :            : // -----------------------------------------------------------------------
     715                 :            : 
     716                 :          0 : SfxSingleTabDialog::SfxSingleTabDialog
     717                 :            : (
     718                 :            :     Window *pParent,
     719                 :            :     const SfxItemSet& rSet,
     720                 :            :     sal_uInt16 nUniqueId
     721                 :            : ) :
     722                 :            : 
     723                 :            : /*  [Description]
     724                 :            : 
     725                 :            :     Constructor of the general base class for SingleTab-Dialoge;
     726                 :            :     ID for the ini-file is handed over.
     727                 :            : */
     728                 :            : 
     729                 :            :     SfxModalDialog( pParent, nUniqueId, WinBits( WB_STDMODAL | WB_3DLOOK ) ),
     730                 :            : 
     731                 :            :     pOKBtn          ( 0 ),
     732                 :            :     pCancelBtn      ( 0 ),
     733                 :            :     pHelpBtn        ( 0 ),
     734 [ #  # ][ #  # ]:          0 :     pImpl           ( new SingleTabDlgImpl )
     735                 :            : {
     736                 :            :     DBG_WARNING( "please use the constructor with ViewFrame" );
     737                 :          0 :     SetInputSet( &rSet );
     738                 :          0 : }
     739                 :            : 
     740                 :            : // -----------------------------------------------------------------------
     741                 :            : 
     742                 :          0 : SfxSingleTabDialog::SfxSingleTabDialog
     743                 :            : (
     744                 :            :     Window* pParent,
     745                 :            :     sal_uInt16 nUniqueId,
     746                 :            :     const SfxItemSet* pInSet
     747                 :            : )
     748                 :            : 
     749                 :            : /*  [Description]
     750                 :            : 
     751                 :            :     Constructor of the general base class for SingleTab-Dialoge;
     752                 :            :     ID for the ini-file is handed over.
     753                 :            :     Deprecated.
     754                 :            :  */
     755                 :            : 
     756                 :            : :   SfxModalDialog( pParent, nUniqueId, WinBits( WB_STDMODAL | WB_3DLOOK ) ),
     757                 :            : 
     758                 :            :     pOKBtn          ( 0 ),
     759                 :            :     pCancelBtn      ( 0 ),
     760                 :            :     pHelpBtn        ( 0 ),
     761 [ #  # ][ #  # ]:          0 :     pImpl           ( new SingleTabDlgImpl )
     762                 :            : {
     763                 :            :     DBG_WARNING( "please use the constructor with ViewFrame" );
     764                 :          0 :     SetInputSet( pInSet );
     765                 :          0 : }
     766                 :            : 
     767                 :            : // -----------------------------------------------------------------------
     768                 :            : 
     769                 :          0 : SfxSingleTabDialog::~SfxSingleTabDialog()
     770                 :            : {
     771 [ #  # ][ #  # ]:          0 :     delete pOKBtn;
     772 [ #  # ][ #  # ]:          0 :     delete pCancelBtn;
     773 [ #  # ][ #  # ]:          0 :     delete pHelpBtn;
     774 [ #  # ][ #  # ]:          0 :     delete pImpl->m_pTabPage;
     775 [ #  # ][ #  # ]:          0 :     delete pImpl->m_pSfxPage;
     776 [ #  # ][ #  # ]:          0 :     delete pImpl->m_pLine;
     777 [ #  # ][ #  # ]:          0 :     delete pImpl;
     778         [ #  # ]:          0 : }
     779                 :            : 
     780                 :            : // -----------------------------------------------------------------------
     781                 :            : 
     782                 :          0 : void SfxSingleTabDialog::SetTabPage( SfxTabPage* pTabPage,
     783                 :            :                                      GetTabPageRanges pRangesFunc )
     784                 :            : /*  [Description]
     785                 :            : 
     786                 :            :     Insert a (new) TabPage; an existing page is deleted.
     787                 :            :     The passed on page is initialized with the initially given Itemset
     788                 :            :     through calling Reset().
     789                 :            : */
     790                 :            : 
     791                 :            : {
     792         [ #  # ]:          0 :     if ( !pOKBtn )
     793                 :            :     {
     794         [ #  # ]:          0 :         pOKBtn = new OKButton( this, WB_DEFBUTTON );
     795                 :          0 :         pOKBtn->SetClickHdl( LINK( this, SfxSingleTabDialog, OKHdl_Impl ) );
     796                 :            :     }
     797         [ #  # ]:          0 :     if ( !pCancelBtn )
     798         [ #  # ]:          0 :         pCancelBtn = new CancelButton( this );
     799         [ #  # ]:          0 :     if ( !pHelpBtn )
     800         [ #  # ]:          0 :         pHelpBtn = new HelpButton( this );
     801                 :            : 
     802         [ #  # ]:          0 :     if ( pImpl->m_pTabPage )
     803         [ #  # ]:          0 :         delete pImpl->m_pTabPage;
     804         [ #  # ]:          0 :     if ( pImpl->m_pSfxPage )
     805         [ #  # ]:          0 :         delete pImpl->m_pSfxPage;
     806                 :          0 :     pImpl->m_pSfxPage = pTabPage;
     807                 :          0 :     fnGetRanges = pRangesFunc;
     808                 :            : 
     809         [ #  # ]:          0 :     if ( pImpl->m_pSfxPage )
     810                 :            :     {
     811                 :            :         // First obtain the user data, only then Reset()
     812 [ #  # ][ #  # ]:          0 :         SvtViewOptions aPageOpt( E_TABPAGE, String::CreateFromInt32( GetUniqId() ) );
         [ #  # ][ #  # ]
     813         [ #  # ]:          0 :         String sUserData;
     814         [ #  # ]:          0 :         Any aUserItem = aPageOpt.GetUserItem( USERITEM_NAME );
     815                 :          0 :         OUString aTemp;
     816         [ #  # ]:          0 :         if ( aUserItem >>= aTemp )
     817 [ #  # ][ #  # ]:          0 :             sUserData = String( aTemp );
                 [ #  # ]
     818         [ #  # ]:          0 :         pImpl->m_pSfxPage->SetUserData( sUserData );
     819         [ #  # ]:          0 :         pImpl->m_pSfxPage->Reset( *GetInputItemSet() );
     820         [ #  # ]:          0 :         pImpl->m_pSfxPage->Show();
     821                 :            : 
     822                 :            :         // Adjust size and position
     823         [ #  # ]:          0 :         pImpl->m_pSfxPage->SetPosPixel( Point() );
     824         [ #  # ]:          0 :         Size aOutSz( pImpl->m_pSfxPage->GetSizePixel() );
     825 [ #  # ][ #  # ]:          0 :         Size aBtnSiz = LogicToPixel( Size( 50, 14 ), MAP_APPFONT );
                 [ #  # ]
     826 [ #  # ][ #  # ]:          0 :         Point aPnt( aOutSz.Width(), LogicToPixel( Point( 0, 6 ), MAP_APPFONT ).Y() );
                 [ #  # ]
     827 [ #  # ][ #  # ]:          0 :         aOutSz.Width() += aBtnSiz.Width() + LogicToPixel( Size( 6, 0 ), MAP_APPFONT ).Width();
                 [ #  # ]
     828         [ #  # ]:          0 :         SetOutputSizePixel( aOutSz );
     829         [ #  # ]:          0 :         pOKBtn->SetPosSizePixel( aPnt, aBtnSiz );
     830         [ #  # ]:          0 :         pOKBtn->Show();
     831 [ #  # ][ #  # ]:          0 :         aPnt.Y() = LogicToPixel( Point( 0, 23 ), MAP_APPFONT ).Y();
                 [ #  # ]
     832         [ #  # ]:          0 :         pCancelBtn->SetPosSizePixel( aPnt, aBtnSiz );
     833         [ #  # ]:          0 :         pCancelBtn->Show();
     834 [ #  # ][ #  # ]:          0 :         aPnt.Y() = LogicToPixel( Point( 0, 43 ), MAP_APPFONT ).Y();
                 [ #  # ]
     835         [ #  # ]:          0 :         pHelpBtn->SetPosSizePixel( aPnt, aBtnSiz );
     836                 :            : 
     837 [ #  # ][ #  # ]:          0 :         if ( Help::IsContextHelpEnabled() )
     838         [ #  # ]:          0 :             pHelpBtn->Show();
     839                 :            : 
     840                 :            :         // Set TabPage text in the Dialog
     841 [ #  # ][ #  # ]:          0 :         SetText( pImpl->m_pSfxPage->GetText() );
                 [ #  # ]
     842                 :            : 
     843                 :            :         // Dialog recieves the HelpId of TabPage
     844 [ #  # ][ #  # ]:          0 :         SetHelpId( pImpl->m_pSfxPage->GetHelpId() );
     845 [ #  # ][ #  # ]:          0 :         SetUniqueId( pImpl->m_pSfxPage->GetUniqueId() );
         [ #  # ][ #  # ]
     846                 :            :     }
     847                 :          0 : }
     848                 :            : 
     849                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10