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

Generated by: LCOV version 1.10