LCOV - code coverage report
Current view: top level - libreoffice/sfx2/source/view - frame.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 204 451 45.2 %
Date: 2012-12-27 Functions: 42 91 46.2 %
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 <com/sun/star/embed/EmbedStates.hpp>
      21             : #include <com/sun/star/uno/Reference.h>
      22             : #include <com/sun/star/awt/XWindow.hpp>
      23             : #include <com/sun/star/util/XURLTransformer.hpp>
      24             : #include <com/sun/star/util/XCloseable.hpp>
      25             : #include <com/sun/star/util/CloseVetoException.hpp>
      26             : #include <com/sun/star/lang/XComponent.hpp>
      27             : #include <com/sun/star/lang/DisposedException.hpp>
      28             : #include <com/sun/star/container/XChild.hpp>
      29             : 
      30             : #include <vcl/menu.hxx>
      31             : #include <svl/intitem.hxx>
      32             : #include <vcl/splitwin.hxx>
      33             : #include <svl/eitem.hxx>
      34             : #include <svl/stritem.hxx>
      35             : #include <toolkit/helper/vclunohelper.hxx>
      36             : #include <com/sun/star/awt/PosSize.hpp>
      37             : #include <comphelper/processfactory.hxx>
      38             : #include <vcl/msgbox.hxx>
      39             : 
      40             : // due to pTopFrames
      41             : #include "appdata.hxx"
      42             : #include <sfx2/app.hxx>
      43             : #include <sfx2/event.hxx>
      44             : #include <sfx2/unoctitm.hxx>
      45             : #include <sfx2/frame.hxx>
      46             : #include "arrdecl.hxx"
      47             : #include <sfx2/objsh.hxx>
      48             : #include <sfx2/dispatch.hxx>
      49             : #include <sfx2/docfile.hxx>
      50             : #include <sfx2/docfilt.hxx>
      51             : #include <sfx2/frmdescr.hxx>
      52             : #include "openflag.hxx"
      53             : #include <sfx2/viewsh.hxx>
      54             : #include <sfx2/viewfrm.hxx>
      55             : #include <sfx2/request.hxx>
      56             : #include <sfx2/fcontnr.hxx>
      57             : #include "impframe.hxx"
      58             : #include <sfx2/appuno.hxx>
      59             : #include "workwin.hxx"
      60             : #include <sfx2/sfxuno.hxx>
      61             : #include <sfx2/msgpool.hxx>
      62             : #include "objshimp.hxx"
      63             : #include <sfx2/ipclient.hxx>
      64             : 
      65             : #ifdef DBG_UTIL
      66             : #include <sfx2/frmhtmlw.hxx>
      67             : #endif
      68             : 
      69             : using namespace com::sun::star;
      70             : 
      71             : static SfxFrameArr_Impl* pFramesArr_Impl=0;
      72             : 
      73             : using namespace ::com::sun::star::uno;
      74             : using namespace ::com::sun::star::util;
      75             : using namespace ::com::sun::star::frame;
      76             : using namespace ::com::sun::star::container;
      77             : 
      78           0 : TYPEINIT1(SfxFrame, SfxListener);
      79           3 : TYPEINIT1_AUTOFACTORY(SfxFrameItem, SfxPoolItem);
      80       22530 : TYPEINIT1(SfxUsrAnyItem, SfxPoolItem);
      81          38 : TYPEINIT1_AUTOFACTORY(SfxUnoFrameItem, SfxPoolItem);
      82             : 
      83         303 : SvCompatWeakHdl* SfxFrame::GetHdl()
      84             : {
      85         303 :     return pImp->GetHdl();
      86             : }
      87             : 
      88             : //--------------------------------------------------------------------
      89         240 : void SfxFrame::Construct_Impl()
      90             : {
      91         240 :     pImp = new SfxFrame_Impl( this );
      92         240 :     if ( !pFramesArr_Impl )
      93           9 :         pFramesArr_Impl = new SfxFrameArr_Impl;
      94         240 :     pFramesArr_Impl->push_back( this );
      95         240 : }
      96             : 
      97             : //--------------------------------------------------------------------
      98             : 
      99         126 : SfxFrame::~SfxFrame()
     100             : {
     101          63 :     RemoveTopFrame_Impl( this );
     102          63 :     DELETEZ( pWindow );
     103             : 
     104          63 :     SfxFrameArr_Impl::iterator it = std::find( pFramesArr_Impl->begin(), pFramesArr_Impl->end(), this );
     105          63 :     if ( it != pFramesArr_Impl->end() )
     106          63 :         pFramesArr_Impl->erase( it );
     107             : 
     108          63 :     if ( pParentFrame )
     109             :     {
     110           0 :         pParentFrame->RemoveChildFrame_Impl( this );
     111           0 :         pParentFrame = 0;
     112             :     }
     113             : 
     114          63 :     delete pImp->pDescr;
     115             : 
     116          63 :     if ( pChildArr )
     117             :     {
     118             :         DBG_ASSERT( pChildArr->empty(), "Children are not removed!" );
     119           0 :         delete pChildArr;
     120             :     }
     121             : 
     122          63 :     delete pImp;
     123         126 : }
     124             : 
     125          63 : sal_Bool SfxFrame::DoClose()
     126             : {
     127             :     // Actually, one more PrepareClose is still needed!
     128          63 :     sal_Bool bRet = sal_False;
     129          63 :     if ( !pImp->bClosing )
     130             :     {
     131          63 :         pImp->bClosing = sal_True;
     132          63 :         CancelTransfers();
     133             : 
     134             :         // now close frame; it will be deleted if this call is successful, so don't use any members after that!
     135          63 :         bRet = sal_True;
     136             :         try
     137             :         {
     138          63 :             Reference< XCloseable > xCloseable  ( pImp->xFrame, UNO_QUERY );
     139          63 :             if ( (!GetCurrentDocument() || !GetCurrentDocument()->Get_Impl()->bDisposing ) && xCloseable.is())
     140          63 :                 xCloseable->close(sal_True);
     141           0 :             else if ( pImp->xFrame.is() )
     142             :             {
     143           0 :                 Reference < XFrame > xFrame = pImp->xFrame;
     144           0 :                 xFrame->setComponent( Reference < com::sun::star::awt::XWindow >(), Reference < XController >() );
     145           0 :                 xFrame->dispose();
     146             :             }
     147             :             else
     148           0 :                 bRet = DoClose_Impl();
     149             :         }
     150           0 :         catch( ::com::sun::star::util::CloseVetoException& )
     151             :         {
     152           0 :             pImp->bClosing = sal_False;
     153           0 :             bRet = sal_False;
     154             :         }
     155           0 :         catch( ::com::sun::star::lang::DisposedException& )
     156             :         {
     157             :         }
     158             :     }
     159             : 
     160          63 :     return bRet;
     161             : }
     162             : 
     163          63 : sal_Bool SfxFrame::DoClose_Impl()
     164             : {
     165          63 :     sal_Bool bRet = sal_True;
     166          63 :     SfxBindings* pBindings = NULL;
     167          63 :     if ( pImp->pCurrentViewFrame )
     168          63 :         pBindings = &pImp->pCurrentViewFrame->GetBindings();
     169             : 
     170             :     // For internal tasks Controllers and Tools must be cleared
     171          63 :     if ( pImp->pWorkWin )
     172          63 :         pImp->pWorkWin->DeleteControllers_Impl();
     173             : 
     174          63 :     if ( pImp->pCurrentViewFrame )
     175          63 :         bRet = pImp->pCurrentViewFrame->Close();
     176             : 
     177          63 :     if ( pImp->bOwnsBindings )
     178          63 :         DELETEZ( pBindings );
     179             : 
     180          63 :     bRet = Close();
     181             :     DBG_ASSERT( bRet, "Impossible state: frame closes, but controller refuses!");
     182          63 :     return bRet;
     183             : }
     184             : 
     185           0 : sal_Bool SfxFrame::DocIsModified_Impl()
     186             : {
     187           0 :     if ( pImp->pCurrentViewFrame && pImp->pCurrentViewFrame->GetObjectShell() &&
     188           0 :             pImp->pCurrentViewFrame->GetObjectShell()->IsModified() )
     189           0 :         return sal_True;
     190           0 :     for( sal_uInt16 nPos = GetChildFrameCount(); nPos--; )
     191           0 :         if( (*pChildArr)[ nPos ]->DocIsModified_Impl() )
     192           0 :             return sal_True;
     193           0 :     return sal_False;
     194             : }
     195             : 
     196           0 : sal_uInt16 SfxFrame::PrepareClose_Impl( sal_Bool bUI, sal_Bool bForBrowsing )
     197             : {
     198           0 :     sal_uInt16 nRet = RET_OK;
     199             : 
     200             :     // prevent recursive calls
     201           0 :     if( !pImp->bPrepClosing )
     202             :     {
     203           0 :         pImp->bPrepClosing = sal_True;
     204             : 
     205           0 :         SfxObjectShell* pCur = GetCurrentDocument() ;
     206           0 :         if( pCur )
     207             :         {
     208             :             // SFX components have a known behaviour
     209             :             // First check if this frame is the only view to its current document
     210           0 :             int bOther = sal_False;
     211           0 :             for ( const SfxViewFrame *pFrame = SfxViewFrame::GetFirst( pCur );
     212             :                     !bOther && pFrame; pFrame = SfxViewFrame::GetNext( *pFrame, pCur ) )
     213             :             {
     214           0 :                 bOther = ( &pFrame->GetFrame() != this );
     215             :             }
     216             : 
     217           0 :             SFX_APP()->NotifyEvent( SfxViewEventHint(SFX_EVENT_PREPARECLOSEVIEW, GlobalEventConfig::GetEventName( STR_EVENT_PREPARECLOSEVIEW ), pCur, GetController() ) );
     218             : 
     219           0 :             if ( bOther )
     220             :                 // if there are other views only the current view of this frame must be asked
     221           0 :                 nRet = GetCurrentViewFrame()->GetViewShell()->PrepareClose( bUI, bForBrowsing );
     222             :             else
     223             :                 // otherwise ask the document
     224           0 :                 nRet = pCur->PrepareClose( bUI, bForBrowsing );
     225             :         }
     226             : 
     227           0 :         if ( nRet == RET_OK )
     228             :         {
     229             :             // if this frame has child frames, ask them too
     230           0 :             for( sal_uInt16 nPos = GetChildFrameCount(); nRet == RET_OK && nPos--; )
     231           0 :                 nRet = (*pChildArr)[ nPos ]->PrepareClose_Impl( bUI, bForBrowsing );
     232             :         }
     233             : 
     234           0 :         pImp->bPrepClosing = sal_False;
     235             :     }
     236             : 
     237           0 :     if ( nRet == RET_OK && pImp->pWorkWin )
     238             :         // if closing was accepted by the component the UI subframes must be asked also
     239           0 :         nRet = pImp->pWorkWin->PrepareClose_Impl();
     240             : 
     241           0 :     return nRet;
     242             : }
     243             : 
     244             : //--------------------------------------------------------------------
     245             : 
     246           0 : SfxFrame* SfxFrame::GetChildFrame( sal_uInt16 nPos ) const
     247             : {
     248           0 :     if ( pChildArr && pChildArr->size() > nPos )
     249             :     {
     250             :         DBG_ASSERT( nPos < pChildArr->size(), "Wrong Index!");
     251           0 :         return (*pChildArr)[nPos];
     252             :     }
     253             : 
     254           0 :     return 0L;
     255             : }
     256             : 
     257           0 : void SfxFrame::RemoveChildFrame_Impl( SfxFrame* pFrame )
     258             : {
     259             :     DBG_ASSERT( pChildArr, "Unknown Frame!");
     260           0 :     SfxFrameArr_Impl::iterator it = std::find( pChildArr->begin(), pChildArr->end(), pFrame );
     261           0 :     if ( it != pChildArr->end() )
     262           0 :         pChildArr->erase( it );
     263           0 : };
     264             : 
     265        2128 : SfxFrame& SfxFrame::GetTopFrame() const
     266             : {
     267        2128 :     const SfxFrame* pParent = this;
     268        4256 :     while ( pParent->pParentFrame )
     269           0 :         pParent = pParent->pParentFrame;
     270        2128 :     return *const_cast< SfxFrame* >( pParent );
     271             : }
     272             : 
     273        6497 : sal_Bool SfxFrame::IsClosing_Impl() const
     274             : {
     275        6497 :     return pImp->bClosing;
     276             : }
     277             : 
     278          63 : void SfxFrame::SetIsClosing_Impl()
     279             : {
     280          63 :     pImp->bClosing = sal_True;
     281          63 : }
     282             : 
     283          63 : sal_uInt16 SfxFrame::GetChildFrameCount() const
     284             : {
     285          63 :     return pChildArr ? pChildArr->size() : 0;
     286             : }
     287             : 
     288          63 : void SfxFrame::CancelTransfers( sal_Bool /*bCancelLoadEnv*/ )
     289             : {
     290          63 :     if( !pImp->bInCancelTransfers )
     291             :     {
     292          63 :         pImp->bInCancelTransfers = sal_True;
     293          63 :         SfxObjectShell* pObj = GetCurrentDocument();
     294          63 :         if( pObj ) //&& !( pObj->Get_Impl()->nLoadedFlags & SFX_LOADED_ALL ))
     295             :         {
     296             :             SfxViewFrame* pFrm;
     297         126 :             for( pFrm = SfxViewFrame::GetFirst( pObj );
     298          63 :                  pFrm && &pFrm->GetFrame() == this;
     299             :                  pFrm = SfxViewFrame::GetNext( *pFrm, pObj ) ) ;
     300             :             // No more Frame in Document -> Cancel
     301          63 :             if( !pFrm )
     302             :             {
     303          63 :                 pObj->CancelTransfers();
     304          63 :                 GetCurrentDocument()->Broadcast( SfxSimpleHint(SFX_HINT_TITLECHANGED) );
     305             :             }
     306             :         }
     307             : 
     308             :         // First stop multiload Frames
     309          63 :         sal_uInt16 nCount = GetChildFrameCount();
     310          63 :         for( sal_uInt16 n = 0; n<nCount; n++ )
     311           0 :             GetChildFrame( n )->CancelTransfers();
     312             : 
     313             :         //  Check if StarOne-Loader should be canceled
     314          63 :         SfxFrameWeak wFrame( this );
     315          63 :         if (wFrame.Is())
     316          63 :             pImp->bInCancelTransfers = sal_False;
     317             :     }
     318          63 : }
     319             : 
     320        7572 : SfxViewFrame* SfxFrame::GetCurrentViewFrame() const
     321             : {
     322        7572 :     return pImp->pCurrentViewFrame;
     323             : }
     324             : 
     325           0 : SfxDispatcher* SfxFrame::GetDispatcher_Impl() const
     326             : {
     327           0 :     if ( pImp->pCurrentViewFrame )
     328           0 :         return pImp->pCurrentViewFrame->GetDispatcher();
     329           0 :     return GetParentFrame()->GetDispatcher_Impl();
     330             : }
     331             : 
     332         492 : SfxObjectShell* SfxFrame::GetCurrentDocument() const
     333             : {
     334             :     return pImp->pCurrentViewFrame ?
     335         252 :             pImp->pCurrentViewFrame->GetObjectShell() :
     336         744 :             NULL;
     337             : }
     338             : 
     339         303 : void SfxFrame::SetCurrentViewFrame_Impl( SfxViewFrame *pFrame )
     340             : {
     341         303 :     pImp->pCurrentViewFrame = pFrame;
     342         303 : }
     343             : 
     344         303 : sal_uInt32 SfxFrame::GetFrameType() const
     345             : {
     346         303 :     return pImp->nType;
     347             : }
     348             : 
     349         240 : void SfxFrame::SetFrameType_Impl( sal_uInt32 n )
     350             : {
     351         240 :     pImp->nType = n;
     352         240 : }
     353             : 
     354           0 : void SfxFrame::GetViewData_Impl()
     355             : {
     356             :     // Update all modifiable data between load and unload, the
     357             :     // fixed data is only processed once (after PrepareForDoc_Impl in
     358             :     // updateDescriptor) to save time.
     359             : 
     360           0 :     SfxViewFrame* pViewFrame = GetCurrentViewFrame();
     361           0 :     if( pViewFrame && pViewFrame->GetViewShell() )
     362             :     {
     363           0 :         const SfxMedium *pMed = GetCurrentDocument()->GetMedium();
     364           0 :         sal_Bool bReadOnly = pMed->GetOpenMode() == SFX_STREAM_READONLY;
     365           0 :         GetDescriptor()->SetReadOnly( bReadOnly );
     366             : 
     367           0 :         SfxItemSet *pSet = GetDescriptor()->GetArgs();
     368           0 :         sal_Bool bGetViewData = sal_False;
     369           0 :         if ( GetController().is() && pSet->GetItemState( SID_VIEW_DATA ) != SFX_ITEM_SET )
     370             :         {
     371           0 :             ::com::sun::star::uno::Any aData = GetController()->getViewData();
     372           0 :             pSet->Put( SfxUsrAnyItem( SID_VIEW_DATA, aData ) );
     373           0 :             bGetViewData = sal_True;
     374             :         }
     375             : 
     376           0 :         if ( pViewFrame->GetCurViewId() )
     377           0 :             pSet->Put( SfxUInt16Item( SID_VIEW_ID, pViewFrame->GetCurViewId() ) );
     378           0 :         if ( pChildArr )
     379             :         {
     380             :             // For Framesets also the data from the ChildViews hace to be processed
     381           0 :             sal_uInt16 nCount = pChildArr->size();
     382           0 :             for ( sal_uInt16 n=nCount; n>0; n--)
     383             :             {
     384           0 :                 SfxFrame* pFrame = (*pChildArr)[n-1];
     385           0 :                 if ( bGetViewData )
     386           0 :                     pFrame->GetDescriptor()->GetArgs()->ClearItem( SID_VIEW_DATA );
     387           0 :                 pFrame->GetViewData_Impl();
     388             :             }
     389             :         }
     390             :     }
     391           0 : }
     392             : 
     393         240 : void SfxFrame::UpdateDescriptor( SfxObjectShell *pDoc )
     394             : {
     395             :     // For PrepareForDoc_Impl frames, the descriptor of the updated
     396             :     // and new itemset to be initialized. All data fir restoring the view
     397             :     // are thus saved. If the document be replaced, GetViewData_Impl (so)
     398             :     // the latest information hinzugef by "added. All together then the
     399             :     // browser-history saved in. When you activate such frame pick entry
     400             :     // is complete itemsets and the descriptor in the OpenDoc sent;.
     401             :     // Here only the fixed properties identified "other adjustable, the
     402             :     // retrieved by GetViewData (saves time).
     403             : 
     404             :     DBG_ASSERT( pDoc, "NULL-Document inserted ?!" );
     405             : 
     406         240 :     GetParentFrame();
     407         240 :     const SfxMedium *pMed = pDoc->GetMedium();
     408         240 :     GetDescriptor()->SetActualURL( String(pMed->GetOrigURL()) );
     409             : 
     410         240 :     SFX_ITEMSET_ARG( pMed->GetItemSet(), pItem, SfxBoolItem, SID_EDITDOC, sal_False );
     411         240 :     sal_Bool bEditable = ( !pItem || pItem->GetValue() );
     412             : 
     413         240 :     GetDescriptor()->SetEditable( bEditable );
     414             : 
     415             :     // Mark FileOpen parameter
     416         240 :     SfxItemSet* pItemSet = pMed->GetItemSet();
     417         240 :     String aMedName( pMed->GetName() );
     418             : 
     419         240 :     const SfxFilter* pFilter = pMed->GetOrigFilter();
     420         240 :     String aFilter;
     421         240 :     if ( pFilter )
     422         236 :         aFilter = pFilter->GetFilterName();
     423             : 
     424         240 :     SFX_ITEMSET_ARG( pItemSet, pRefererItem, SfxStringItem, SID_REFERER, sal_False);
     425         240 :     SFX_ITEMSET_ARG( pItemSet, pOptionsItem, SfxStringItem, SID_FILE_FILTEROPTIONS, sal_False);
     426         240 :     SFX_ITEMSET_ARG( pItemSet, pTitle1Item, SfxStringItem, SID_DOCINFO_TITLE, sal_False);
     427             : 
     428         240 :     SfxItemSet *pSet = GetDescriptor()->GetArgs();
     429             : 
     430             :     // Delete all old Items
     431         240 :     pSet->ClearItem();
     432             : 
     433         240 :     if ( pRefererItem )
     434           4 :         pSet->Put( *pRefererItem );
     435             :     else
     436         236 :         pSet->Put( SfxStringItem( SID_REFERER, String() ) );
     437             : 
     438         240 :     if ( pOptionsItem )
     439           0 :         pSet->Put( *pOptionsItem );
     440             : 
     441         240 :     if ( pTitle1Item )
     442           0 :         pSet->Put( *pTitle1Item );
     443             : 
     444         240 :     pSet->Put( SfxStringItem( SID_FILTER_NAME, aFilter ));
     445         240 : }
     446             : 
     447             : //-------------------------------------------------------------------------
     448             : 
     449         720 : SfxFrameDescriptor* SfxFrame::GetDescriptor() const
     450             : {
     451             :     // Create a FrameDescriptor On Demand; if there is no TopLevel-Frame
     452             :     // will result in an error, as no valid link is created.
     453             : 
     454         720 :     if ( !pImp->pDescr )
     455             :     {
     456             :         DBG_ASSERT( !GetParentFrame(), "No TopLevel-Frame, but no Descriptor!" );
     457         240 :         pImp->pDescr = new SfxFrameDescriptor;
     458         240 :         if ( GetCurrentDocument() )
     459           0 :             pImp->pDescr->SetURL( GetCurrentDocument()->GetMedium()->GetOrigURL() );
     460             :     }
     461         720 :     return pImp->pDescr;
     462             : }
     463             : 
     464             : //-------------------------------------------------------------------------
     465             : 
     466           0 : void SfxFrame::GetTargetList( TargetList& rList ) const
     467             : {
     468           0 :     if ( !GetParentFrame() )
     469             :     {
     470             :         // An empty string for 'No Target'
     471           0 :         rList.push_back( new String() );
     472           0 :         rList.push_back( new String( DEFINE_CONST_UNICODE( "_top" ) ) );
     473           0 :         rList.push_back( new String( DEFINE_CONST_UNICODE( "_parent" ) ) );
     474           0 :         rList.push_back( new String( DEFINE_CONST_UNICODE( "_blank" ) ) );
     475           0 :         rList.push_back( new String( DEFINE_CONST_UNICODE( "_self" ) ) );
     476             :     }
     477             : 
     478           0 :     SfxViewFrame* pView = GetCurrentViewFrame();
     479           0 :     if( pView && pView->GetViewShell() && pChildArr )
     480             :     {
     481           0 :         sal_uInt16 nCount = pChildArr->size();
     482           0 :         for ( sal_uInt16 n=0; n<nCount; n++)
     483             :         {
     484           0 :             SfxFrame* pFrame = (*pChildArr)[n];
     485           0 :             pFrame->GetTargetList( rList );
     486             :         }
     487             :     }
     488           0 : }
     489             : 
     490             : //-------------------------------------------------------------------------
     491             : 
     492           0 : sal_Bool SfxFrame::IsParent( SfxFrame *pFrame ) const
     493             : {
     494           0 :     SfxFrame *pParent = pParentFrame;
     495           0 :     while ( pParent )
     496             :     {
     497           0 :         if ( pParent == pFrame )
     498           0 :             return sal_True;
     499           0 :         pParent = pParent->pParentFrame;
     500             :     }
     501             : 
     502           0 :     return sal_False;
     503             : }
     504             : 
     505         240 : void SfxFrame::InsertTopFrame_Impl( SfxFrame* pFrame )
     506             : {
     507         240 :     SfxFrameArr_Impl& rArr = *SFX_APP()->Get_Impl()->pTopFrames;
     508         240 :     rArr.push_back( pFrame );
     509         240 : }
     510             : 
     511          63 : void SfxFrame::RemoveTopFrame_Impl( SfxFrame* pFrame )
     512             : {
     513          63 :     SfxFrameArr_Impl& rArr = *SFX_APP()->Get_Impl()->pTopFrames;
     514          63 :     SfxFrameArr_Impl::iterator it = std::find( rArr.begin(), rArr.end(), pFrame );
     515          63 :     if ( it != rArr.end() )
     516          63 :         rArr.erase( it );
     517          63 : }
     518             : 
     519           0 : SfxFrameItem::SfxFrameItem( sal_uInt16 nWhichId, SfxViewFrame *p )
     520           0 :     : SfxPoolItem( nWhichId ), pFrame( p ? &p->GetFrame() : NULL )
     521             : {
     522           0 :     wFrame = pFrame;
     523           0 : }
     524             : 
     525           0 : SfxFrameItem::SfxFrameItem( sal_uInt16 nWhichId, SfxFrame *p ):
     526             :     SfxPoolItem( nWhichId ),
     527           0 :     pFrame( p ), wFrame( p )
     528             : {
     529           0 : }
     530             : 
     531           0 : SfxFrameItem::SfxFrameItem( SfxFrame *p ):
     532             :     SfxPoolItem( 0 ),
     533           0 :     pFrame( p ), wFrame( p )
     534             : {
     535           0 : }
     536             : 
     537           0 : int SfxFrameItem::operator==( const SfxPoolItem &rItem ) const
     538             : {
     539             :      return ((SfxFrameItem&)rItem).pFrame == pFrame &&
     540           0 :          ((SfxFrameItem&)rItem).wFrame == wFrame;
     541             : }
     542             : 
     543             : //--------------------------------------------------------------------
     544             : 
     545           0 : String SfxFrameItem::GetValueText() const
     546             : {
     547           0 :     return String();
     548             : }
     549             : 
     550           0 : SfxPoolItem* SfxFrameItem::Clone( SfxItemPool *) const
     551             : {
     552           0 :     SfxFrameItem* pNew = new SfxFrameItem( wFrame);
     553           0 :     pNew->SetFramePtr_Impl( pFrame );
     554           0 :     return pNew;
     555             : }
     556             : 
     557           0 : bool SfxFrameItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 ) const
     558             : {
     559           0 :     if ( wFrame )
     560             :     {
     561           0 :         rVal <<= wFrame->GetFrameInterface();
     562           0 :         return sal_True;
     563             :     }
     564             : 
     565           0 :     return sal_False;
     566             : }
     567             : 
     568           0 : bool SfxFrameItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 )
     569             : {
     570           0 :     Reference < XFrame > xFrame;
     571           0 :     if ( (rVal >>= xFrame) && xFrame.is() )
     572             :     {
     573           0 :         SfxFrame* pFr = SfxFrame::GetFirst();
     574           0 :         while ( pFr )
     575             :         {
     576           0 :             if ( pFr->GetFrameInterface() == xFrame )
     577             :             {
     578           0 :                 wFrame = pFrame = pFr;
     579           0 :                 return sal_True;
     580             :             }
     581             : 
     582           0 :             pFr = SfxFrame::GetNext( *pFr );
     583             :         }
     584           0 :         return sal_True;
     585             :     }
     586             : 
     587           0 :     return sal_False;
     588             : }
     589             : 
     590             : 
     591        6056 : SfxUsrAnyItem::SfxUsrAnyItem( sal_uInt16 nWhichId, const ::com::sun::star::uno::Any& rAny )
     592        6056 :     : SfxPoolItem( nWhichId )
     593             : {
     594        6056 :     aValue = rAny;
     595        6056 : }
     596             : 
     597           0 : int SfxUsrAnyItem::operator==( const SfxPoolItem& /*rItem*/ ) const
     598             : {
     599           0 :     return sal_False;
     600             : }
     601             : 
     602        3411 : SfxPoolItem* SfxUsrAnyItem::Clone( SfxItemPool *) const
     603             : {
     604        3411 :     return new SfxUsrAnyItem( Which(), aValue );
     605             : }
     606             : 
     607           0 : bool SfxUsrAnyItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
     608             : {
     609           0 :     rVal = aValue;
     610           0 :     return sal_True;
     611             : }
     612             : 
     613           0 : bool SfxUsrAnyItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
     614             : {
     615           0 :     aValue = rVal;
     616           0 :     return sal_True;
     617             : }
     618             : 
     619           0 : SfxUnoFrameItem::SfxUnoFrameItem()
     620             :     : SfxPoolItem()
     621           0 :     , m_xFrame()
     622             : {
     623           0 : }
     624             : 
     625           0 : SfxUnoFrameItem::SfxUnoFrameItem( sal_uInt16 nWhichId, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrame )
     626             :     : SfxPoolItem( nWhichId )
     627           0 :     , m_xFrame( i_rFrame )
     628             : {
     629           0 : }
     630             : 
     631           0 : int SfxUnoFrameItem::operator==( const SfxPoolItem& i_rItem ) const
     632             : {
     633           0 :     return i_rItem.ISA( SfxUnoFrameItem ) && static_cast< const SfxUnoFrameItem& >( i_rItem ).m_xFrame == m_xFrame;
     634             : }
     635             : 
     636           0 : SfxPoolItem* SfxUnoFrameItem::Clone( SfxItemPool* ) const
     637             : {
     638           0 :     return new SfxUnoFrameItem( Which(), m_xFrame );
     639             : }
     640             : 
     641           0 : bool SfxUnoFrameItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
     642             : {
     643           0 :     rVal <<= m_xFrame;
     644           0 :     return sal_True;
     645             : }
     646             : 
     647           0 : bool SfxUnoFrameItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
     648             : {
     649           0 :     return ( rVal >>= m_xFrame );
     650             : }
     651             : 
     652           0 : SfxFrameIterator::SfxFrameIterator( const SfxFrame& rFrame, sal_Bool bRecur )
     653             :     : pFrame( &rFrame )
     654           0 :     , bRecursive( bRecur )
     655           0 : {}
     656             : 
     657           0 : SfxFrame* SfxFrameIterator::FirstFrame()
     658             : {
     659             :     // GetFirst starts the iteration at the first child frame
     660           0 :     return pFrame->GetChildFrame( 0 );
     661             : }
     662             : 
     663           0 : SfxFrame* SfxFrameIterator::NextFrame( SfxFrame& rPrev )
     664             : {
     665             :     // If recursion is requested testing is done first on Children.
     666           0 :     SfxFrame *pRet = NULL;
     667           0 :     if ( bRecursive )
     668           0 :         pRet = rPrev.GetChildFrame( 0 );
     669           0 :     if ( !pRet )
     670             :     {
     671             :         // In other case continue with the siblings of rPrev
     672           0 :         pRet = NextSibling_Impl( rPrev );
     673             :     }
     674             : 
     675           0 :     return pRet;
     676             : }
     677             : 
     678             : 
     679           0 : SfxFrame* SfxFrameIterator::NextSibling_Impl( SfxFrame& rPrev )
     680             : {
     681           0 :     SfxFrame *pRet = NULL;
     682           0 :     if ( &rPrev != pFrame )
     683             :     {
     684           0 :         SfxFrameArr_Impl& rArr = *rPrev.pParentFrame->pChildArr;
     685           0 :         SfxFrameArr_Impl::iterator it = std::find( rArr.begin(), rArr.end(), &rPrev );
     686           0 :         if ( it != rArr.end() && (++it) != rArr.end() )
     687           0 :             pRet = *it;
     688             : 
     689           0 :         if ( !pRet && rPrev.pParentFrame->pParentFrame )
     690           0 :             pRet = NextSibling_Impl( *rPrev.pParentFrame );
     691             :     }
     692             : 
     693           0 :     return pRet;
     694             : }
     695             : 
     696         378 : sal_Bool SfxFrame::HasComponent() const
     697             : {
     698         378 :     return sal_False;
     699             : }
     700             : 
     701         944 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > SfxFrame::GetController() const
     702             : {
     703         944 :     if ( pImp->pCurrentViewFrame && pImp->pCurrentViewFrame->GetViewShell() )
     704         944 :         return pImp->pCurrentViewFrame->GetViewShell()->GetController();
     705             :     else
     706           0 :         return ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > ();
     707             : }
     708             : 
     709        5792 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >  SfxFrame::GetFrameInterface() const
     710             : {
     711        5792 :     return pImp->xFrame;
     712             : }
     713             : 
     714         303 : void SfxFrame::SetFrameInterface_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame )
     715             : {
     716         303 :     pImp->xFrame = rFrame;
     717         303 :     com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorder > xRecorder;
     718         303 :     if ( !rFrame.is() && GetCurrentViewFrame() )
     719          63 :         GetCurrentViewFrame()->GetBindings().SetRecorder_Impl( xRecorder );
     720         303 : }
     721             : 
     722           0 : void SfxFrame::Appear()
     723             : {
     724           0 :     if ( GetCurrentViewFrame() )
     725             :     {
     726           0 :         GetCurrentViewFrame()->Show();
     727           0 :         GetWindow().Show();
     728           0 :         pImp->xFrame->getContainerWindow()->setVisible( sal_True );
     729           0 :         if ( pParentFrame )
     730           0 :             pParentFrame->Appear();
     731           0 :         Reference < ::com::sun::star::awt::XTopWindow > xTopWindow( pImp->xFrame->getContainerWindow(), UNO_QUERY );
     732           0 :         if ( xTopWindow.is() )
     733           0 :             xTopWindow->toFront();
     734             :     }
     735           0 : }
     736             : 
     737           0 : void SfxFrame::AppearWithUpdate()
     738             : {
     739           0 :     Appear();
     740           0 :     if ( GetCurrentViewFrame() )
     741           0 :         GetCurrentViewFrame()->GetDispatcher()->Update_Impl( sal_True );
     742           0 : }
     743             : 
     744         240 : void SfxFrame::SetOwnsBindings_Impl( sal_Bool bSet )
     745             : {
     746         240 :     pImp->bOwnsBindings = bSet;
     747         240 : }
     748             : 
     749         831 : sal_Bool SfxFrame::OwnsBindings_Impl() const
     750             : {
     751         831 :     return pImp->bOwnsBindings;
     752             : }
     753             : 
     754        1530 : void SfxFrame::SetToolSpaceBorderPixel_Impl( const SvBorder& rBorder )
     755             : {
     756        1530 :     pImp->aBorder = rBorder;
     757        1530 :     SfxViewFrame *pF = GetCurrentViewFrame();
     758        1530 :     if ( pF )
     759             :     {
     760        1530 :         Point aPos ( rBorder.Left(), rBorder.Top() );
     761        1530 :         Size aSize( GetWindow().GetOutputSizePixel() );
     762        1530 :         long nDeltaX = rBorder.Left() + rBorder.Right();
     763        1530 :         if ( aSize.Width() > nDeltaX )
     764        1436 :             aSize.Width() -= nDeltaX;
     765             :         else
     766          94 :             aSize.Width() = 0;
     767             : 
     768        1530 :         long nDeltaY = rBorder.Top() + rBorder.Bottom();
     769        1530 :         if ( aSize.Height() > nDeltaY )
     770        1436 :             aSize.Height() -= nDeltaY;
     771             :         else
     772          94 :             aSize.Height() = 0;
     773             : 
     774        1530 :         if ( GetParentFrame() )
     775             :         {
     776           0 :             sal_Bool bHasTools = rBorder.Left() != rBorder.Right() || rBorder.Top() != rBorder.Bottom();
     777           0 :             pF->GetWindow().SetBorderStyle( bHasTools ? WINDOW_BORDER_NORMAL : WINDOW_BORDER_NOBORDER );
     778             :         }
     779             : 
     780        1530 :         pF->GetWindow().SetPosSizePixel( aPos, aSize );
     781             :     }
     782        1530 : }
     783             : 
     784        2168 : Rectangle SfxFrame::GetTopOuterRectPixel_Impl() const
     785             : {
     786        2168 :     Size aSize( GetWindow().GetOutputSizePixel() );
     787        2168 :     Point aPoint;
     788        2168 :     return ( Rectangle ( aPoint, aSize ) );
     789             : }
     790             : 
     791        7237 : SfxWorkWindow* SfxFrame::GetWorkWindow_Impl() const
     792             : {
     793        7237 :     if ( pImp->pWorkWin )
     794        7237 :         return pImp->pWorkWin;
     795           0 :     else if ( pParentFrame )
     796           0 :         return pParentFrame->GetWorkWindow_Impl();
     797             :     else
     798           0 :         return NULL;
     799             : }
     800             : 
     801         240 : void SfxFrame::CreateWorkWindow_Impl()
     802             : {
     803         240 :     SfxFrame* pFrame = this;
     804             : 
     805         240 :     if ( IsInPlace() )
     806             :     {
     807             :         // this makes sence only for inplace activated objects
     808             :         try
     809             :         {
     810           0 :             Reference < XChild > xChild( GetCurrentDocument()->GetModel(), UNO_QUERY );
     811           0 :             if ( xChild.is() )
     812             :             {
     813           0 :                 Reference < XModel > xParent( xChild->getParent(), UNO_QUERY );
     814           0 :                 if ( xParent.is() )
     815             :                 {
     816           0 :                     Reference< XController > xParentCtrler = xParent->getCurrentController();
     817           0 :                     if ( xParentCtrler.is() )
     818             :                     {
     819           0 :                         Reference < XFrame > xFrame( xParentCtrler->getFrame() );
     820           0 :                         SfxFrame* pFr = SfxFrame::GetFirst();
     821           0 :                         while ( pFr )
     822             :                         {
     823           0 :                             if ( pFr->GetFrameInterface() == xFrame )
     824             :                             {
     825           0 :                                 pFrame = pFr;
     826           0 :                                 break;
     827             :                             }
     828             : 
     829           0 :                             pFr = SfxFrame::GetNext( *pFr );
     830           0 :                         }
     831           0 :                     }
     832           0 :                 }
     833           0 :             }
     834             :         }
     835           0 :         catch(Exception&)
     836             :         {
     837             :             OSL_FAIL("SfxFrame::CreateWorkWindow_Impl: Exception cachted. Please try to submit a repoducable bug !");
     838             :         }
     839             :     }
     840             : 
     841         240 :     pImp->pWorkWin = new SfxFrameWorkWin_Impl( &pFrame->GetWindow(), this, pFrame );
     842         240 : }
     843             : 
     844         142 : void SfxFrame::GrabFocusOnComponent_Impl()
     845             : {
     846         142 :     if ( pImp->bReleasingComponent )
     847             :     {
     848           0 :         GetWindow().GrabFocus();
     849         142 :         return;
     850             :     }
     851             : 
     852         142 :     Window* pFocusWindow = &GetWindow();
     853         142 :     if ( GetCurrentViewFrame() && GetCurrentViewFrame()->GetViewShell() && GetCurrentViewFrame()->GetViewShell()->GetWindow() )
     854         142 :         pFocusWindow = GetCurrentViewFrame()->GetViewShell()->GetWindow();
     855             : 
     856         142 :     if( !pFocusWindow->HasChildPathFocus() )
     857         142 :         pFocusWindow->GrabFocus();
     858             : }
     859             : 
     860          63 : void SfxFrame::ReleasingComponent_Impl( sal_Bool bSet )
     861             : {
     862          63 :     pImp->bReleasingComponent = bSet;
     863          63 : }
     864             : 
     865        4985 : sal_Bool SfxFrame::IsInPlace() const
     866             : {
     867        4985 :     return pImp->bInPlace;
     868             : }
     869             : 
     870           0 : void SfxFrame::SetInPlace_Impl( sal_Bool bSet )
     871             : {
     872           0 :     pImp->bInPlace = bSet;
     873           0 : }
     874             : 
     875         705 : void SfxFrame::Resize()
     876             : {
     877         705 :     if ( IsClosing_Impl() )
     878         705 :         return;
     879             : 
     880         705 :     if ( OwnsBindings_Impl() )
     881             :     {
     882         563 :         if ( IsInPlace() )
     883             :         {
     884           0 :             SetToolSpaceBorderPixel_Impl( SvBorder() );
     885             :         }
     886             :         else
     887             :         {
     888             :             // check for IPClient that contains UIactive object or object that is currently UI activating
     889         563 :             SfxWorkWindow *pWork = GetWorkWindow_Impl();
     890         563 :             SfxInPlaceClient* pClient = GetCurrentViewFrame()->GetViewShell() ? GetCurrentViewFrame()->GetViewShell()->GetUIActiveIPClient_Impl() : 0;
     891         563 :             if ( pClient )
     892             :             {
     893           0 :                 uno::Reference < lang::XUnoTunnel > xObj( pClient->GetObject()->getComponent(), uno::UNO_QUERY );
     894           0 :                 uno::Sequence < sal_Int8 > aSeq( SvGlobalName( SFX_GLOBAL_CLASSID ).GetByteSequence() );
     895           0 :                 sal_Int64 nHandle = (xObj.is()? xObj->getSomething( aSeq ): 0);
     896           0 :                 if ( nHandle )
     897             :                 {
     898           0 :                     SfxObjectShell* pDoc = reinterpret_cast< SfxObjectShell* >( sal::static_int_cast< sal_IntPtr >( nHandle ));
     899           0 :                     pWork = SfxViewFrame::GetFirst( pDoc )->GetFrame().GetWorkWindow_Impl();
     900           0 :                 }
     901             :             }
     902             : 
     903         563 :             if ( pWork )
     904             :             {
     905         563 :                 pWork->ArrangeChildren_Impl();
     906         563 :                 pWork->ShowChildren_Impl();
     907             :             }
     908             : 
     909             :             // problem in presence of UIActive object: when the window is resized, but the toolspace border
     910             :             // remains the same, setting the toolspace border at the ContainerEnvironment doesn't force a
     911             :             // resize on the IPEnvironment; without that no resize is called for the SfxViewFrame. So always
     912             :             // set the window size of the SfxViewFrame explicit.
     913         563 :             SetToolSpaceBorderPixel_Impl( pImp->aBorder );
     914             :         }
     915             :     }
     916         142 :     else if ( pImp->pCurrentViewFrame )
     917             :     {
     918           0 :         pImp->pCurrentViewFrame->GetWindow().SetSizePixel( GetWindow().GetOutputSizePixel() );
     919             :     }
     920             : 
     921             : }
     922             : 
     923           0 : SfxFrame* SfxFrame::GetFirst()
     924             : {
     925           0 :     if ( !pFramesArr_Impl )
     926           0 :         return 0;
     927           0 :     return pFramesArr_Impl->empty() ? 0 : pFramesArr_Impl->front();
     928             : }
     929             : 
     930           0 : SfxFrame* SfxFrame::GetNext( SfxFrame& rFrame )
     931             : {
     932           0 :     SfxFrameArr_Impl::iterator it = std::find( pFramesArr_Impl->begin(), pFramesArr_Impl->end(), &rFrame );
     933           0 :     if ( it != pFramesArr_Impl->end() && (++it) != pFramesArr_Impl->end() )
     934           0 :         return *it;
     935             :     else
     936           0 :         return NULL;
     937             : }
     938             : 
     939           0 : const SfxPoolItem* SfxFrame::OpenDocumentSynchron( SfxItemSet& i_rSet, const Reference< XFrame >& i_rTargetFrame )
     940             : {
     941           0 :     i_rSet.Put( SfxUnoFrameItem( SID_FILLFRAME, i_rTargetFrame ) );
     942           0 :     i_rSet.ClearItem( SID_TARGETNAME );
     943           0 :     return SFX_APP()->GetDispatcher_Impl()->Execute( SID_OPENDOC, SFX_CALLMODE_SYNCHRON, i_rSet );
     944             : }
     945             : 
     946             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10