LCOV - code coverage report
Current view: top level - libreoffice/sfx2/source/dialog - basedlgs.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 339 0.3 %
Date: 2012-12-27 Functions: 2 56 3.6 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10