LCOV - code coverage report
Current view: top level - libreoffice/sfx2/source/view - viewfrm.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 392 1494 26.2 %
Date: 2012-12-27 Functions: 57 107 53.3 %
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             : 
      21             : #include <stdio.h>
      22             : 
      23             : #include <sfx2/infobar.hxx>
      24             : #include <sfx2/viewfrm.hxx>
      25             : #include <com/sun/star/document/MacroExecMode.hpp>
      26             : #include <com/sun/star/frame/Desktop.hpp>
      27             : #include <com/sun/star/frame/DispatchRecorderSupplier.hpp>
      28             : #include <com/sun/star/frame/XLoadable.hpp>
      29             : #include <com/sun/star/frame/XLayoutManager.hpp>
      30             : #include <com/sun/star/frame/XComponentLoader.hpp>
      31             : 
      32             : #include <toolkit/unohlp.hxx>
      33             : #include <vcl/splitwin.hxx>
      34             : #include <unotools/moduleoptions.hxx>
      35             : #include <svl/intitem.hxx>
      36             : #include <svl/visitem.hxx>
      37             : #include <svl/stritem.hxx>
      38             : #include <svl/eitem.hxx>
      39             : #include <svl/slstitm.hxx>
      40             : #include <svl/whiter.hxx>
      41             : #include <svl/undo.hxx>
      42             : #include <vcl/msgbox.hxx>
      43             : #include <svtools/sfxecode.hxx>
      44             : #include <svtools/miscopt.hxx>
      45             : #include <svtools/ehdl.hxx>
      46             : #include <tools/diagnose_ex.h>
      47             : #include <com/sun/star/container/XIndexAccess.hpp>
      48             : #include <com/sun/star/frame/XFramesSupplier.hpp>
      49             : #include <com/sun/star/frame/FrameSearchFlag.hpp>
      50             : #include <com/sun/star/frame/XFrame.hpp>
      51             : #include <com/sun/star/frame/XFrames.hpp>
      52             : #include <com/sun/star/awt/XWindow.hpp>
      53             : #include <com/sun/star/frame/XController.hpp>
      54             : #include <com/sun/star/frame/XModel2.hpp>
      55             : #include <com/sun/star/util/URLTransformer.hpp>
      56             : #include <com/sun/star/util/XURLTransformer.hpp>
      57             : #include <com/sun/star/util/XCloseable.hpp>
      58             : #include <com/sun/star/frame/XDispatchRecorderSupplier.hpp>
      59             : #include <com/sun/star/document/UpdateDocMode.hpp>
      60             : #include <com/sun/star/beans/XPropertySet.hpp>
      61             : #include <com/sun/star/uri/UriReferenceFactory.hpp>
      62             : #include <com/sun/star/uri/XVndSunStarScriptUrl.hpp>
      63             : #include <com/sun/star/embed/XStorage.hpp>
      64             : #include <com/sun/star/embed/EmbedStates.hpp>
      65             : #include <com/sun/star/document/XViewDataSupplier.hpp>
      66             : #include <com/sun/star/container/XIndexContainer.hpp>
      67             : #include <rtl/ustrbuf.hxx>
      68             : 
      69             : #include <unotools/localfilehelper.hxx>
      70             : #include <unotools/ucbhelper.hxx>
      71             : #include <comphelper/processfactory.hxx>
      72             : #include <comphelper/componentcontext.hxx>
      73             : #include <comphelper/namedvaluecollection.hxx>
      74             : #include <comphelper/configurationhelper.hxx>
      75             : #include <comphelper/docpasswordrequest.hxx>
      76             : #include <comphelper/docpasswordhelper.hxx>
      77             : 
      78             : #include <com/sun/star/uno/Reference.h>
      79             : #include <com/sun/star/ucb/XContent.hpp>
      80             : 
      81             : #include <basic/basmgr.hxx>
      82             : #include <basic/sbmod.hxx>
      83             : #include <basic/sbmeth.hxx>
      84             : #include <basic/sbx.hxx>
      85             : #include <comphelper/storagehelper.hxx>
      86             : #include <svtools/asynclink.hxx>
      87             : #include <svl/sharecontrolfile.hxx>
      88             : #include <svtools/svtools.hrc>
      89             : #include <svtools/svtresid.hxx>
      90             : #include <framework/framelistanalyzer.hxx>
      91             : 
      92             : #include <boost/optional.hpp>
      93             : 
      94             : using namespace ::com::sun::star;
      95             : using namespace ::com::sun::star::uno;
      96             : using namespace ::com::sun::star::ucb;
      97             : using namespace ::com::sun::star::frame;
      98             : using namespace ::com::sun::star::lang;
      99             : using ::com::sun::star::awt::XWindow;
     100             : using ::com::sun::star::beans::PropertyValue;
     101             : using ::com::sun::star::document::XViewDataSupplier;
     102             : using ::com::sun::star::container::XIndexContainer;
     103             : 
     104             : // Due to ViewFrame::Current
     105             : #include "appdata.hxx"
     106             : #include <sfx2/taskpane.hxx>
     107             : #include <sfx2/app.hxx>
     108             : #include <sfx2/objface.hxx>
     109             : #include "openflag.hxx"
     110             : #include "objshimp.hxx"
     111             : #include <sfx2/viewsh.hxx>
     112             : #include <sfx2/objsh.hxx>
     113             : #include <sfx2/bindings.hxx>
     114             : #include <sfx2/dispatch.hxx>
     115             : #include "arrdecl.hxx"
     116             : #include "sfxtypes.hxx"
     117             : #include <sfx2/request.hxx>
     118             : #include <sfx2/docfac.hxx>
     119             : #include <sfx2/ipclient.hxx>
     120             : #include "sfx2/sfxresid.hxx"
     121             : #include "appbas.hxx"
     122             : #include <sfx2/objitem.hxx>
     123             : #include "sfx2/viewfac.hxx"
     124             : #include <sfx2/event.hxx>
     125             : #include "fltfnc.hxx"
     126             : #include <sfx2/docfile.hxx>
     127             : #include <sfx2/module.hxx>
     128             : #include <sfx2/msgpool.hxx>
     129             : #include "viewimp.hxx"
     130             : #include <sfx2/sfxbasecontroller.hxx>
     131             : #include <sfx2/sfx.hrc>
     132             : #include "view.hrc"
     133             : #include <sfx2/frmdescr.hxx>
     134             : #include <sfx2/sfxuno.hxx>
     135             : #include <sfx2/progress.hxx>
     136             : #include "workwin.hxx"
     137             : #include "helper.hxx"
     138             : #include "sfx2/minfitem.hxx"
     139             : #include "../appl/app.hrc"
     140             : #include "impviewframe.hxx"
     141             : 
     142             : //-------------------------------------------------------------------------
     143             : DBG_NAME(SfxViewFrame)
     144             : 
     145             : #define SfxViewFrame
     146             : #include "sfxslots.hxx"
     147             : #undef SfxViewFrame
     148             : 
     149             : //-------------------------------------------------------------------------
     150             : 
     151        1321 : SFX_IMPL_INTERFACE(SfxViewFrame,SfxShell,SfxResId(0))
     152             : {
     153          19 :     SFX_CHILDWINDOW_REGISTRATION( SID_BROWSER );
     154          19 :     SFX_CHILDWINDOW_REGISTRATION( SID_RECORDING_FLOATWINDOW );
     155             : 
     156          19 :     SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_FULLSCREEN | SFX_VISIBILITY_FULLSCREEN, SfxResId(RID_FULLSCREENTOOLBOX) );
     157          19 :     SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_APPLICATION | SFX_VISIBILITY_STANDARD, SfxResId(RID_ENVTOOLBOX) );
     158          19 : }
     159             : 
     160        8239 : TYPEINIT2(SfxViewFrame,SfxShell,SfxListener);
     161           0 : TYPEINIT1(SfxViewFrameItem, SfxPoolItem);
     162             : 
     163             : //-------------------------------------------------------------------------
     164             : namespace
     165             : {
     166           0 :     bool moduleHasToolPanels( SfxViewFrame_Impl& i_rViewFrameImpl )
     167             :     {
     168           0 :         if ( !i_rViewFrameImpl.aHasToolPanels )
     169             :         {
     170             :             i_rViewFrameImpl.aHasToolPanels.reset( ::sfx2::ModuleTaskPane::ModuleHasToolPanels(
     171           0 :                 i_rViewFrameImpl.rFrame.GetFrameInterface() ) );
     172             :         }
     173           0 :         return *i_rViewFrameImpl.aHasToolPanels;
     174             :     }
     175             : }
     176             : 
     177             : //-------------------------------------------------------------------------
     178           0 : static sal_Bool AskPasswordToModify_Impl( const uno::Reference< task::XInteractionHandler >& xHandler, const ::rtl::OUString& aPath, const SfxFilter* pFilter, sal_uInt32 nPasswordHash, const uno::Sequence< beans::PropertyValue > aInfo )
     179             : {
     180             :     // TODO/LATER: In future the info should replace the direct hash completely
     181           0 :     sal_Bool bResult = ( !nPasswordHash && !aInfo.getLength() );
     182             : 
     183             :     OSL_ENSURE( pFilter && ( pFilter->GetFilterFlags() & SFX_FILTER_PASSWORDTOMODIFY ), "PasswordToModify feature is active for a filter that does not support it!" );
     184             : 
     185           0 :     if ( pFilter && xHandler.is() )
     186             :     {
     187           0 :         sal_Bool bCancel = sal_False;
     188           0 :         sal_Bool bFirstTime = sal_True;
     189             : 
     190           0 :         while ( !bResult && !bCancel )
     191             :         {
     192           0 :             sal_Bool bMSType = !pFilter->IsOwnFormat();
     193             : 
     194             :             ::rtl::Reference< ::comphelper::DocPasswordRequest > pPasswordRequest(
     195             :                  new ::comphelper::DocPasswordRequest(
     196             :                  bMSType ? ::comphelper::DocPasswordRequestType_MS : ::comphelper::DocPasswordRequestType_STANDARD,
     197             :                  bFirstTime ? ::com::sun::star::task::PasswordRequestMode_PASSWORD_ENTER : ::com::sun::star::task::PasswordRequestMode_PASSWORD_REENTER,
     198             :                  aPath,
     199           0 :                  sal_True ) );
     200             : 
     201           0 :             uno::Reference< com::sun::star::task::XInteractionRequest > rRequest( pPasswordRequest.get() );
     202           0 :             xHandler->handle( rRequest );
     203             : 
     204           0 :             if ( pPasswordRequest->isPassword() )
     205             :             {
     206           0 :                 if ( aInfo.getLength() )
     207             :                 {
     208           0 :                     bResult = ::comphelper::DocPasswordHelper::IsModifyPasswordCorrect( pPasswordRequest->getPasswordToModify(), aInfo );
     209             :                 }
     210             :                 else
     211             :                 {
     212             :                     // the binary format
     213           0 :                     bResult = ( SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), ::rtl::OUString( "com.sun.star.text.TextDocument"  ).equals( pFilter->GetServiceName() ) ) == nPasswordHash );
     214             :                 }
     215             :             }
     216             :             else
     217           0 :                 bCancel = sal_True;
     218             : 
     219           0 :             bFirstTime = sal_False;
     220           0 :         }
     221             :     }
     222             : 
     223           0 :     return bResult;
     224             : }
     225             : 
     226             : //-------------------------------------------------------------------------
     227          63 : void SfxViewFrame::SetDowning_Impl()
     228             : {
     229          63 :     pImp->bIsDowning = sal_True;
     230          63 : }
     231             : 
     232             : //-------------------------------------------------------------------------
     233        1978 : sal_Bool SfxViewFrame::IsDowning_Impl() const
     234             : {
     235        1978 :     return pImp->bIsDowning;
     236             : }
     237             : 
     238             : 
     239             : //--------------------------------------------------------------------
     240           0 : class SfxViewNotificatedFrameList_Impl :
     241             :     public SfxListener, public SfxViewFrameArr_Impl
     242             : {
     243             : public:
     244             : 
     245             :     void InsertViewFrame( SfxViewFrame* pFrame )
     246             :     {
     247             :         StartListening( *pFrame );
     248             :         push_back( pFrame );
     249             :     }
     250             :     void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
     251             : };
     252             : 
     253             : //-------------------------------------------------------------------------
     254           0 : void SfxViewNotificatedFrameList_Impl::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
     255             : {
     256           0 :     if ( rHint.IsA(TYPE(SfxSimpleHint)) )
     257             :     {
     258           0 :         switch( ( (SfxSimpleHint&) rHint ).GetId() )
     259             :         {
     260             :             case SFX_HINT_DYING:
     261           0 :                 SfxViewFrame* pFrame = (SfxViewFrame*) &rBC;
     262           0 :                 if( pFrame )
     263             :                 {
     264           0 :                     iterator it = std::find( begin(), end(), pFrame );
     265           0 :                     if( it != end() )
     266           0 :                         erase( it );
     267             :                 }
     268             :                 break;
     269             :         }
     270             :     }
     271           0 : }
     272             : 
     273             : //-------------------------------------------------------------------------
     274             : 
     275           0 : long ReloadDecouple_Impl( void* pObj, void* pArg )
     276             : {
     277           0 :     ((SfxViewFrame*) pObj)->ExecReload_Impl( *(SfxRequest*)pArg );
     278           0 :     return 0;
     279             : }
     280             : 
     281           0 : void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
     282             : {
     283           0 :     SfxFrame *pParent = GetFrame().GetParentFrame();
     284           0 :     if ( rReq.GetSlot() == SID_RELOAD )
     285             :     {
     286             :         // When CTRL-Reload, reload the active Frame
     287           0 :         SfxViewFrame* pActFrame = this;
     288           0 :         while ( pActFrame )
     289           0 :             pActFrame = pActFrame->GetActiveChildFrame_Impl();
     290             : 
     291           0 :         if ( pActFrame )
     292             :         {
     293           0 :             sal_uInt16 nModifier = rReq.GetModifier();
     294           0 :             if ( nModifier & KEY_MOD1 )
     295             :             {
     296           0 :                 pActFrame->ExecReload_Impl( rReq );
     297           0 :                 return;
     298             :             }
     299             :         }
     300             : 
     301             :         // If only a reload of the graphics for one or more child frames
     302             :         // should be made
     303           0 :         SfxFrame& rFrame = GetFrame();
     304           0 :         if ( pParent == &rFrame && rFrame.GetChildFrameCount() )
     305             :         {
     306           0 :             sal_Bool bReloadAvailable = sal_False;
     307           0 :             SfxFrameIterator aIter( rFrame, sal_False );
     308           0 :             SfxFrame *pChild = aIter.FirstFrame();
     309           0 :             while ( pChild )
     310             :             {
     311           0 :                 SfxFrame *pNext = aIter.NextFrame( *pChild );
     312           0 :                 SfxObjectShell *pShell = pChild->GetCurrentDocument();
     313           0 :                 if( pShell && pShell->Get_Impl()->bReloadAvailable )
     314             :                 {
     315           0 :                     bReloadAvailable = sal_True;
     316           0 :                     pChild->GetCurrentViewFrame()->ExecuteSlot( rReq );
     317             :                 }
     318           0 :                 pChild = pNext;
     319             :             }
     320             : 
     321             :             // The top level frame itself has no graphics!
     322           0 :             if ( bReloadAvailable )
     323             :                 return;
     324             :         }
     325             :     }
     326             :     else
     327             :     {
     328             :         // When CTRL-Edit, edit the TopFrame.
     329           0 :         sal_uInt16 nModifier = rReq.GetModifier();
     330             : 
     331           0 :         if ( ( nModifier & KEY_MOD1 ) && pParent )
     332             :         {
     333           0 :             SfxViewFrame *pTop = GetTopViewFrame();
     334           0 :             pTop->ExecReload_Impl( rReq );
     335           0 :             return;
     336             :         }
     337             :     }
     338             : 
     339           0 :     SfxObjectShell* pSh = GetObjectShell();
     340           0 :     switch ( rReq.GetSlot() )
     341             :     {
     342             :         case SID_EDITDOC:
     343             :         {
     344           0 :             if ( GetFrame().HasComponent() )
     345             :                 break;
     346             : 
     347             :             // Due to Double occupancy in toolboxes (with or without Ctrl),
     348             :             // it is also possible that the slot is enabled, but Ctrl-click
     349             :             // despite this is not!
     350           0 :             if( !pSh || !pSh->HasName() || !(pSh->Get_Impl()->nLoadedFlags & SFX_LOADED_MAINDOCUMENT ))
     351             :                 break;
     352             : 
     353           0 :             SfxMedium* pMed = pSh->GetMedium();
     354             : 
     355           0 :             SFX_ITEMSET_ARG( pSh->GetMedium()->GetItemSet(), pItem, SfxBoolItem, SID_VIEWONLY, sal_False );
     356           0 :             if ( pItem && pItem->GetValue() )
     357             :             {
     358           0 :                 SfxApplication* pApp = SFX_APP();
     359           0 :                 SfxAllItemSet aSet( pApp->GetPool() );
     360           0 :                 aSet.Put( SfxStringItem( SID_FILE_NAME, pMed->GetURLObject().GetMainURL(INetURLObject::NO_DECODE) ) );
     361           0 :                 aSet.Put( SfxBoolItem( SID_TEMPLATE, sal_True ) );
     362           0 :                 aSet.Put( SfxStringItem( SID_TARGETNAME, rtl::OUString("_blank") ) );
     363           0 :                 SFX_ITEMSET_ARG( pMed->GetItemSet(), pReferer, SfxStringItem, SID_REFERER, sal_False );
     364           0 :                 if ( pReferer )
     365           0 :                     aSet.Put( *pReferer );
     366           0 :                 SFX_ITEMSET_ARG( pSh->GetMedium()->GetItemSet(), pVersionItem, SfxInt16Item, SID_VERSION, sal_False );
     367           0 :                 if ( pVersionItem )
     368           0 :                     aSet.Put( *pVersionItem );
     369             : 
     370           0 :                 if( pMed->GetFilter() )
     371             :                 {
     372           0 :                     aSet.Put( SfxStringItem( SID_FILTER_NAME, pMed->GetFilter()->GetFilterName() ) );
     373           0 :                     SFX_ITEMSET_ARG( pMed->GetItemSet(), pOptions, SfxStringItem, SID_FILE_FILTEROPTIONS, sal_False );
     374           0 :                     if ( pOptions )
     375           0 :                         aSet.Put( *pOptions );
     376             :                 }
     377             : 
     378           0 :                 GetDispatcher()->Execute( SID_OPENDOC, SFX_CALLMODE_ASYNCHRON, aSet );
     379           0 :                 return;
     380             :             }
     381             : 
     382             :             sal_uInt16 nOpenMode;
     383           0 :             sal_Bool bNeedsReload = sal_False;
     384           0 :             if ( !pSh->IsReadOnly() )
     385             :             {
     386             :                 // Save and reload Readonly
     387           0 :                 if( pSh->IsModified() )
     388             :                 {
     389           0 :                     if ( pSh->PrepareClose() )
     390             :                     {
     391             :                         // the storing could let the medium be changed
     392           0 :                         pMed = pSh->GetMedium();
     393           0 :                         bNeedsReload = sal_True;
     394             :                     }
     395             :                     else
     396             :                     {
     397           0 :                         rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), sal_False ) );
     398             :                         return;
     399             :                     }
     400             :                 }
     401           0 :                 nOpenMode = SFX_STREAM_READONLY;
     402           0 :                 pSh->SetReadOnlyUI(true);
     403             :             }
     404             :             else
     405             :             {
     406           0 :                 if ( pSh->IsReadOnlyMedium()
     407           0 :                   && ( pSh->GetModifyPasswordHash() || pSh->GetModifyPasswordInfo().getLength() )
     408           0 :                   && !pSh->IsModifyPasswordEntered() )
     409             :                 {
     410           0 :                     ::rtl::OUString aDocumentName = INetURLObject( pMed->GetOrigURL() ).GetMainURL( INetURLObject::DECODE_WITH_CHARSET );
     411           0 :                     if( !AskPasswordToModify_Impl( pMed->GetInteractionHandler(), aDocumentName, pMed->GetOrigFilter(), pSh->GetModifyPasswordHash(), pSh->GetModifyPasswordInfo() ) )
     412             :                     {
     413             :                         // this is a read-only document, if it has "Password to modify"
     414             :                         // the user should enter password before he can edit the document
     415           0 :                         rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), sal_False ) );
     416             :                         return;
     417             :                     }
     418             : 
     419           0 :                     pSh->SetModifyPasswordEntered();
     420             :                 }
     421             : 
     422           0 :                 nOpenMode = pSh->IsOriginallyReadOnlyMedium() ? SFX_STREAM_READONLY : SFX_STREAM_READWRITE;
     423             : 
     424             :                 // if only the view was in the readonly mode then there is no need to do the reload
     425           0 :                 if ( !pSh->IsReadOnlyMedium() )
     426             :                 {
     427             :                     // SetReadOnlyUI causes recomputation of window title, using
     428             :                     // open mode among other things, so call SetOpenMode before
     429             :                     // SetReadOnlyUI:
     430           0 :                     pMed->SetOpenMode( nOpenMode );
     431           0 :                     pSh->SetReadOnlyUI( sal_False );
     432             :                     return;
     433             :                 }
     434             : 
     435           0 :                 pSh->SetReadOnlyUI( sal_False );
     436             :             }
     437             : 
     438           0 :             if ( rReq.IsAPI() )
     439             :             {
     440             :                 // Control through API if r/w or r/o
     441           0 :                 SFX_REQUEST_ARG(rReq, pEditItem, SfxBoolItem, SID_EDITDOC, sal_False);
     442           0 :                 if ( pEditItem )
     443           0 :                     nOpenMode = pEditItem->GetValue() ? SFX_STREAM_READWRITE : SFX_STREAM_READONLY;
     444             :             }
     445             : 
     446             :             // doing
     447             : 
     448           0 :             rtl::OUString aTemp;
     449           0 :             utl::LocalFileHelper::ConvertPhysicalNameToURL( pMed->GetPhysicalName(), aTemp );
     450           0 :             INetURLObject aPhysObj( aTemp );
     451           0 :             SFX_ITEMSET_ARG( pSh->GetMedium()->GetItemSet(),
     452             :                              pVersionItem, SfxInt16Item, SID_VERSION, sal_False );
     453             : 
     454           0 :             INetURLObject aMedObj( pMed->GetName() );
     455             : 
     456             :             // the logic below is following, if the document seems not to need to be reloaded and the physical name is different
     457             :             // to the logical one, then on file system it can be checked that the copy is still newer than the original and no document reload is required
     458           0 :             if ( ( !bNeedsReload && ( (aMedObj.GetProtocol() == INET_PROT_FILE &&
     459           0 :                     aMedObj.getFSysPath(INetURLObject::FSYS_DETECT) != aPhysObj.getFSysPath(INetURLObject::FSYS_DETECT) &&
     460           0 :                     !::utl::UCBContentHelper::IsYounger( aMedObj.GetMainURL( INetURLObject::NO_DECODE ), aPhysObj.GetMainURL( INetURLObject::NO_DECODE ) ))
     461           0 :                   || pMed->IsRemote() ) )
     462             :                || pVersionItem )
     463             :             {
     464           0 :                 sal_Bool bOK = sal_False;
     465           0 :                 if ( !pVersionItem )
     466             :                 {
     467           0 :                     sal_Bool bHasStorage = pMed->HasStorage_Impl();
     468             :                     // switching edit mode could be possible without reload
     469           0 :                     if ( bHasStorage && pMed->GetStorage() == pSh->GetStorage() )
     470             :                     {
     471             :                         // TODO/LATER: faster creation of copy
     472           0 :                         if ( !pSh->ConnectTmpStorage_Impl( pMed->GetStorage(), pMed ) )
     473             :                             return;
     474             :                     }
     475             : 
     476           0 :                     pMed->CloseAndRelease();
     477           0 :                     pMed->GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, !( nOpenMode & STREAM_WRITE ) ) );
     478           0 :                     pMed->SetOpenMode( nOpenMode );
     479             : 
     480           0 :                     pMed->CompleteReOpen();
     481           0 :                     if ( nOpenMode & STREAM_WRITE )
     482           0 :                         pMed->LockOrigFileOnDemand( sal_False, sal_True );
     483             : 
     484             :                     // LockOrigFileOnDemand might set the readonly flag itself, it should be set back
     485           0 :                     pMed->GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, !( nOpenMode & STREAM_WRITE ) ) );
     486             : 
     487           0 :                     if ( !pMed->GetErrorCode() )
     488           0 :                         bOK = sal_True;
     489             :                 }
     490             : 
     491           0 :                 if( !bOK )
     492             :                 {
     493           0 :                     ErrCode nErr = pMed->GetErrorCode();
     494           0 :                     if ( pVersionItem )
     495           0 :                         nErr = ERRCODE_IO_ACCESSDENIED;
     496             :                     else
     497             :                     {
     498           0 :                         pMed->ResetError();
     499           0 :                         pMed->SetOpenMode( SFX_STREAM_READONLY );
     500           0 :                         pMed->ReOpen();
     501           0 :                         pSh->DoSaveCompleted( pMed );
     502             :                     }
     503             : 
     504             :                     // Readonly document can not be switched to edit mode?
     505           0 :                     rReq.Done( sal_False );
     506             : 
     507           0 :                     if ( nOpenMode == SFX_STREAM_READWRITE && !rReq.IsAPI() )
     508             :                     {
     509             :                         // ::com::sun::star::sdbcx::User offering to open it as a template
     510           0 :                         QueryBox aBox( &GetWindow(), SfxResId(MSG_QUERY_OPENASTEMPLATE) );
     511           0 :                         if ( RET_YES == aBox.Execute() )
     512             :                         {
     513           0 :                             SfxApplication* pApp = SFX_APP();
     514           0 :                             SfxAllItemSet aSet( pApp->GetPool() );
     515           0 :                             aSet.Put( SfxStringItem( SID_FILE_NAME, pMed->GetName() ) );
     516           0 :                             SFX_ITEMSET_ARG( pMed->GetItemSet(), pReferer, SfxStringItem, SID_REFERER, sal_False );
     517           0 :                             if ( pReferer )
     518           0 :                                 aSet.Put( *pReferer );
     519           0 :                             aSet.Put( SfxBoolItem( SID_TEMPLATE, sal_True ) );
     520           0 :                             if ( pVersionItem )
     521           0 :                                 aSet.Put( *pVersionItem );
     522             : 
     523           0 :                             if( pMed->GetFilter() )
     524             :                             {
     525           0 :                                 aSet.Put( SfxStringItem( SID_FILTER_NAME, pMed->GetFilter()->GetFilterName() ) );
     526           0 :                                 SFX_ITEMSET_ARG( pMed->GetItemSet(), pOptions,
     527             :                                                  SfxStringItem, SID_FILE_FILTEROPTIONS, sal_False );
     528           0 :                                 if ( pOptions )
     529           0 :                                     aSet.Put( *pOptions );
     530             :                             }
     531             : 
     532           0 :                             GetDispatcher()->Execute( SID_OPENDOC, SFX_CALLMODE_ASYNCHRON, aSet );
     533           0 :                             return;
     534             :                         }
     535             :                         else
     536           0 :                             nErr = 0;
     537             :                     }
     538             : 
     539           0 :                     ErrorHandler::HandleError( nErr );
     540             :                     rReq.SetReturnValue(
     541           0 :                         SfxBoolItem( rReq.GetSlot(), sal_False ) );
     542             :                     return;
     543             :                 }
     544             :                 else
     545             :                 {
     546           0 :                     pSh->DoSaveCompleted( pMed );
     547           0 :                     pSh->Broadcast( SfxSimpleHint(SFX_HINT_MODECHANGED) );
     548           0 :                     rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), sal_True ) );
     549           0 :                     rReq.Done( sal_True );
     550             :                     return;
     551             :                 }
     552             :             }
     553             : 
     554           0 :             rReq.AppendItem( SfxBoolItem( SID_FORCERELOAD, sal_True) );
     555           0 :             rReq.AppendItem( SfxBoolItem( SID_SILENT, sal_True ));
     556             :         }
     557             : 
     558             :         case SID_RELOAD:
     559             :         {
     560             :             // Due to Double occupancy in toolboxes (with or without Ctrl),
     561             :             // it is also possible that the slot is enabled, but Ctrl-click
     562             :             // despite this is not!
     563           0 :             if ( !pSh || !pSh->CanReload_Impl() )
     564             :                 break;
     565           0 :             SfxApplication* pApp = SFX_APP();
     566           0 :             SFX_REQUEST_ARG(rReq, pForceReloadItem, SfxBoolItem,
     567             :                             SID_FORCERELOAD, sal_False);
     568           0 :             if(  pForceReloadItem && !pForceReloadItem->GetValue() &&
     569           0 :                 !pSh->GetMedium()->IsExpired() )
     570             :                 return;
     571           0 :             if( pImp->bReloading || pSh->IsInModalMode() )
     572             :                 return;
     573             : 
     574             :             // AutoLoad is prohibited if possible
     575           0 :             SFX_REQUEST_ARG(rReq, pAutoLoadItem, SfxBoolItem, SID_AUTOLOAD, sal_False);
     576           0 :             if ( pAutoLoadItem && pAutoLoadItem->GetValue() &&
     577           0 :                  GetFrame().IsAutoLoadLocked_Impl() )
     578             :                 return;
     579             : 
     580           0 :             SfxObjectShellLock xOldObj( pSh );
     581           0 :             pImp->bReloading = sal_True;
     582           0 :             SFX_REQUEST_ARG(rReq, pURLItem, SfxStringItem,
     583             :                             SID_FILE_NAME, sal_False);
     584             :             // Open as editable?
     585           0 :             sal_Bool bForEdit = !pSh->IsReadOnly();
     586             : 
     587             :             // If possible ask the User
     588           0 :             sal_Bool bDo = ( GetViewShell()->PrepareClose() != sal_False );
     589           0 :             SFX_REQUEST_ARG(rReq, pSilentItem, SfxBoolItem, SID_SILENT, sal_False);
     590           0 :             if ( bDo && GetFrame().DocIsModified_Impl() &&
     591           0 :                  !rReq.IsAPI() && ( !pSilentItem || !pSilentItem->GetValue() ) )
     592             :             {
     593           0 :                 QueryBox aBox( &GetWindow(), SfxResId(MSG_QUERY_LASTVERSION) );
     594           0 :                 bDo = ( RET_YES == aBox.Execute() );
     595             :             }
     596             : 
     597           0 :             if ( bDo )
     598             :             {
     599           0 :                 SfxMedium *pMedium = xOldObj->GetMedium();
     600             : 
     601             :                 // Remove Frameset before the FramesetView may disappear
     602           0 :                 String aURL;
     603           0 :                 if (pURLItem)
     604           0 :                     aURL = pURLItem->GetValue();
     605             :                 else
     606           0 :                     aURL = pMedium->GetName();
     607             : 
     608             :                 sal_Bool bHandsOff =
     609           0 :                     ( pMedium->GetURLObject().GetProtocol() == INET_PROT_FILE && !xOldObj->IsDocShared() );
     610             : 
     611             :                 // Emty existing SfxMDIFrames for this Document
     612             :                 // in native format or R/O, open it now for editing?
     613           0 :                 SfxObjectShellLock xNewObj;
     614             : 
     615             :                 // collect the views of the document
     616             :                 // TODO: when UNO ViewFactories are available for SFX-based documents, the below code should
     617             :                 // be UNOized, too
     618             :                 typedef ::std::pair< Reference< XFrame >, sal_uInt16 >  ViewDescriptor;
     619           0 :                 ::std::list< ViewDescriptor > aViewFrames;
     620           0 :                 SfxViewFrame *pView = GetFirst( xOldObj );
     621           0 :                 while ( pView )
     622             :                 {
     623           0 :                     Reference< XFrame > xFrame( pView->GetFrame().GetFrameInterface() );
     624             :                     OSL_ENSURE( xFrame.is(), "SfxViewFrame::ExecReload_Impl: no XFrame?!" );
     625           0 :                     aViewFrames.push_back( ViewDescriptor( xFrame, pView->GetCurViewId() ) );
     626             : 
     627           0 :                     pView = GetNext( *pView, xOldObj );
     628           0 :                 }
     629             : 
     630           0 :                 DELETEZ( xOldObj->Get_Impl()->pReloadTimer );
     631             : 
     632           0 :                 SfxItemSet* pNewSet = 0;
     633           0 :                 const SfxFilter *pFilter = pMedium->GetFilter();
     634           0 :                 if( pURLItem )
     635             :                 {
     636           0 :                     pNewSet = new SfxAllItemSet( pApp->GetPool() );
     637           0 :                     pNewSet->Put( *pURLItem );
     638             : 
     639             :                     // Filter Detection
     640           0 :                     SfxMedium aMedium( pURLItem->GetValue(), SFX_STREAM_READWRITE );
     641           0 :                     SfxFilterMatcher().GuessFilter( aMedium, &pFilter );
     642           0 :                     if ( pFilter )
     643           0 :                         pNewSet->Put( SfxStringItem( SID_FILTER_NAME, pFilter->GetName() ) );
     644           0 :                     pNewSet->Put( *aMedium.GetItemSet() );
     645             :                 }
     646             :                 else
     647             :                 {
     648           0 :                     pNewSet = new SfxAllItemSet( *pMedium->GetItemSet() );
     649           0 :                     pNewSet->ClearItem( SID_VIEW_ID );
     650           0 :                     pNewSet->ClearItem( SID_STREAM );
     651           0 :                     pNewSet->ClearItem( SID_INPUTSTREAM );
     652           0 :                     pNewSet->Put( SfxStringItem( SID_FILTER_NAME, pMedium->GetFilter()->GetName() ) );
     653             : 
     654             :                     // let the current security settings be checked again
     655           0 :                     pNewSet->Put( SfxUInt16Item( SID_MACROEXECMODE, document::MacroExecMode::USE_CONFIG ) );
     656             : 
     657           0 :                     if ( pSh->IsOriginallyReadOnlyMedium() )
     658             :                         // edit mode is switched or reload of readonly document
     659           0 :                         pNewSet->Put( SfxBoolItem( SID_DOC_READONLY, true ) );
     660             :                     else
     661             :                         // Reload of file opened for writing
     662           0 :                         pNewSet->ClearItem( SID_DOC_READONLY );
     663             :                 }
     664             : 
     665             :                 // If a salvaged file is present, do not enclose the OrigURL
     666             :                 // again, since the Tempdate is invalid after reload.
     667           0 :                 SFX_ITEMSET_ARG( pNewSet, pSalvageItem, SfxStringItem, SID_DOC_SALVAGE, sal_False);
     668           0 :                 if( pSalvageItem )
     669             :                 {
     670           0 :                     aURL = pSalvageItem->GetValue();
     671           0 :                     pNewSet->ClearItem( SID_DOC_SALVAGE );
     672             :                 }
     673             : 
     674             :                 // TODO/LATER: Temporary solution, the SfxMedium must know the original URL as aLogicName
     675             :                 //             SfxMedium::Transfer_Impl() will be forbidden then.
     676           0 :                 if ( xOldObj->IsDocShared() )
     677           0 :                     pNewSet->Put( SfxStringItem( SID_FILE_NAME, xOldObj->GetSharedFileURL() ) );
     678             : 
     679           0 :                 if ( pURLItem )
     680           0 :                     pNewSet->Put( SfxStringItem( SID_REFERER, pMedium->GetName() ) );
     681             :                 else
     682           0 :                     pNewSet->Put( SfxStringItem( SID_REFERER, String() ) );
     683             : 
     684           0 :                 xOldObj->CancelTransfers();
     685             : 
     686             : 
     687           0 :                 if ( pSilentItem && pSilentItem->GetValue() )
     688           0 :                     pNewSet->Put( SfxBoolItem( SID_SILENT, sal_True ) );
     689             : 
     690           0 :                 SFX_ITEMSET_ARG(pNewSet, pInteractionItem, SfxUnoAnyItem, SID_INTERACTIONHANDLER, sal_False);
     691           0 :                 SFX_ITEMSET_ARG(pNewSet, pMacroExecItem  , SfxUInt16Item, SID_MACROEXECMODE     , sal_False);
     692           0 :                 SFX_ITEMSET_ARG(pNewSet, pDocTemplateItem, SfxUInt16Item, SID_UPDATEDOCMODE     , sal_False);
     693             : 
     694           0 :                 if (!pInteractionItem)
     695             :                 {
     696           0 :                     Reference < ::com::sun::star::task::XInteractionHandler > xHdl( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString("com.sun.star.comp.uui.UUIInteractionHandler")), UNO_QUERY );
     697           0 :                     if (xHdl.is())
     698           0 :                         pNewSet->Put( SfxUnoAnyItem(SID_INTERACTIONHANDLER,::com::sun::star::uno::makeAny(xHdl)) );
     699             :                 }
     700             : 
     701           0 :                 if (!pMacroExecItem)
     702           0 :                     pNewSet->Put( SfxUInt16Item(SID_MACROEXECMODE,::com::sun::star::document::MacroExecMode::USE_CONFIG) );
     703           0 :                 if (!pDocTemplateItem)
     704           0 :                     pNewSet->Put( SfxUInt16Item(SID_UPDATEDOCMODE,::com::sun::star::document::UpdateDocMode::ACCORDING_TO_CONFIG) );
     705             : 
     706           0 :                 xOldObj->SetModified( sal_False );
     707             :                 // Do not chache the old Document! Is invalid when loading
     708             :                 // another document.
     709             : 
     710           0 :                 SFX_ITEMSET_ARG( pMedium->GetItemSet(), pSavedOptions, SfxStringItem, SID_FILE_FILTEROPTIONS, sal_False);
     711           0 :                 SFX_ITEMSET_ARG( pMedium->GetItemSet(), pSavedReferer, SfxStringItem, SID_REFERER, sal_False);
     712             : 
     713           0 :                 sal_Bool bHasStorage = pMedium->HasStorage_Impl();
     714           0 :                 if( bHandsOff )
     715             :                 {
     716           0 :                     if ( bHasStorage && pMedium->GetStorage() == xOldObj->GetStorage() )
     717             :                     {
     718             :                         // TODO/LATER: faster creation of copy
     719           0 :                         if ( !xOldObj->ConnectTmpStorage_Impl( pMedium->GetStorage(), pMedium ) )
     720             :                             return;
     721             :                     }
     722             : 
     723           0 :                     pMedium->CloseAndRelease();
     724             :                 }
     725             : 
     726           0 :                 xNewObj = SfxObjectShell::CreateObject( pFilter->GetServiceName(), SFX_CREATE_MODE_STANDARD );
     727             : 
     728           0 :                 if ( xOldObj->IsModifyPasswordEntered() )
     729           0 :                     xNewObj->SetModifyPasswordEntered();
     730             : 
     731           0 :                 uno::Sequence < beans::PropertyValue > aLoadArgs;
     732           0 :                 TransformItems( SID_OPENDOC, *pNewSet, aLoadArgs );
     733             :                 try
     734             :                 {
     735           0 :                     uno::Reference < frame::XLoadable > xLoad( xNewObj->GetModel(), uno::UNO_QUERY );
     736           0 :                     xLoad->load( aLoadArgs );
     737             :                 }
     738           0 :                 catch ( uno::Exception& )
     739             :                 {
     740           0 :                     xNewObj->DoClose();
     741           0 :                     xNewObj = 0;
     742             :                 }
     743             : 
     744           0 :                 DELETEZ( pNewSet );
     745             : 
     746           0 :                 if( !xNewObj.Is() )
     747             :                 {
     748           0 :                     if( bHandsOff )
     749             :                     {
     750             :                         // back to old medium
     751           0 :                         pMedium->ReOpen();
     752           0 :                         pMedium->LockOrigFileOnDemand( sal_False, sal_True );
     753             : 
     754           0 :                         xOldObj->DoSaveCompleted( pMedium );
     755             :                     }
     756             : 
     757             :                     // r/o-Doc couldn't be switched to writing mode
     758           0 :                     if ( bForEdit && SID_EDITDOC == rReq.GetSlot() )
     759             :                     {
     760             :                         // ask user for opening as template
     761           0 :                         QueryBox aBox( &GetWindow(), SfxResId(MSG_QUERY_OPENASTEMPLATE) );
     762           0 :                         if ( RET_YES == aBox.Execute() )
     763             :                         {
     764           0 :                             SfxAllItemSet aSet( pApp->GetPool() );
     765           0 :                             aSet.Put( SfxStringItem( SID_FILE_NAME, pMedium->GetName() ) );
     766           0 :                             aSet.Put( SfxStringItem( SID_TARGETNAME, rtl::OUString("_blank") ) );
     767           0 :                             if ( pSavedOptions )
     768           0 :                                 aSet.Put( *pSavedOptions );
     769           0 :                             if ( pSavedReferer )
     770           0 :                                 aSet.Put( *pSavedReferer );
     771           0 :                             aSet.Put( SfxBoolItem( SID_TEMPLATE, sal_True ) );
     772           0 :                             if( pFilter )
     773           0 :                                 aSet.Put( SfxStringItem( SID_FILTER_NAME, pFilter->GetFilterName() ) );
     774           0 :                             GetDispatcher()->Execute( SID_OPENDOC, SFX_CALLMODE_ASYNCHRON, aSet );
     775           0 :                         }
     776             :                     }
     777             :                 }
     778             :                 else
     779             :                 {
     780           0 :                     if ( xNewObj->GetModifyPasswordHash() && xNewObj->GetModifyPasswordHash() != xOldObj->GetModifyPasswordHash() )
     781             :                     {
     782           0 :                         xNewObj->SetModifyPasswordEntered( sal_False );
     783           0 :                         xNewObj->SetReadOnly();
     784             :                     }
     785           0 :                     else if ( rReq.GetSlot() == SID_EDITDOC )
     786             :                     {
     787           0 :                         xNewObj->SetReadOnlyUI( !bForEdit );
     788             :                     }
     789             : 
     790           0 :                     if ( xNewObj->IsDocShared() )
     791             :                     {
     792             :                         // the file is shared but the closing can change the sharing control file
     793           0 :                         xOldObj->DoNotCleanShareControlFile();
     794             :                     }
     795             : 
     796             :                     // the Reload and Silent items were only temporary, remove them
     797           0 :                     xNewObj->GetMedium()->GetItemSet()->ClearItem( SID_RELOAD );
     798           0 :                     xNewObj->GetMedium()->GetItemSet()->ClearItem( SID_SILENT );
     799           0 :                     TransformItems( SID_OPENDOC, *xNewObj->GetMedium()->GetItemSet(), aLoadArgs );
     800             : 
     801           0 :                     UpdateDocument_Impl();
     802             : 
     803             :                     try
     804             :                     {
     805           0 :                         while ( !aViewFrames.empty() )
     806             :                         {
     807           0 :                             LoadViewIntoFrame_Impl( *xNewObj, aViewFrames.front().first, aLoadArgs, aViewFrames.front().second, false );
     808           0 :                             aViewFrames.pop_front();
     809             :                         }
     810             :                     }
     811           0 :                     catch( const Exception& )
     812             :                     {
     813             :                         // close the remaining frames
     814             :                         // Don't catch exceptions herein, if this fails, then we're left in an indetermined state, and
     815             :                         // crashing is better than trying to proceed
     816           0 :                         while ( !aViewFrames.empty() )
     817             :                         {
     818           0 :                             Reference< util::XCloseable > xClose( aViewFrames.front().first, UNO_QUERY_THROW );
     819           0 :                             xClose->close( sal_True );
     820           0 :                             aViewFrames.pop_front();
     821           0 :                         }
     822             :                     }
     823             : 
     824             :                     // Propagate document closure.
     825           0 :                     SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_CLOSEDOC, GlobalEventConfig::GetEventName( STR_EVENT_CLOSEDOC ), xOldObj ) );
     826             :                 }
     827             : 
     828             :                 // Record as done
     829           0 :                 rReq.Done( sal_True );
     830           0 :                 rReq.SetReturnValue(SfxBoolItem(rReq.GetSlot(), sal_True));
     831           0 :                 return;
     832             :             }
     833             :             else
     834             :             {
     835             :                 // Record as not done
     836           0 :                 rReq.Done();
     837           0 :                 rReq.SetReturnValue(SfxBoolItem(rReq.GetSlot(), sal_False));
     838           0 :                 pImp->bReloading = sal_False;
     839             :                 return;
     840           0 :             }
     841             :         }
     842             :     }
     843             : }
     844             : 
     845             : //-------------------------------------------------------------------------
     846           0 : void SfxViewFrame::StateReload_Impl( SfxItemSet& rSet )
     847             : {
     848           0 :     SfxObjectShell* pSh = GetObjectShell();
     849           0 :     if ( !pSh )
     850             :         // I'm just on reload and am yielding myself ...
     851           0 :         return;
     852             : 
     853           0 :     GetFrame().GetParentFrame();
     854           0 :     SfxWhichIter aIter( rSet );
     855           0 :     for ( sal_uInt16 nWhich = aIter.FirstWhich(); nWhich; nWhich = aIter.NextWhich() )
     856             :     {
     857           0 :         if ( GetFrame().HasComponent() )
     858             :         {
     859             :             // If the component is not self-dispatched, then
     860             :             // it makes no sense!
     861           0 :             rSet.DisableItem( nWhich );
     862           0 :             continue;
     863             :         }
     864             : 
     865           0 :         switch ( nWhich )
     866             :         {
     867             :             case SID_EDITDOC:
     868             :             {
     869           0 :                 if ( !pSh || !pSh->HasName() || !( pSh->Get_Impl()->nLoadedFlags &  SFX_LOADED_MAINDOCUMENT )
     870           0 :                   || pSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
     871           0 :                     rSet.DisableItem( SID_EDITDOC );
     872             :                 else
     873             :                 {
     874           0 :                     SFX_ITEMSET_ARG( pSh->GetMedium()->GetItemSet(), pItem, SfxBoolItem, SID_EDITDOC, sal_False );
     875           0 :                     if ( pItem && !pItem->GetValue() )
     876           0 :                         rSet.DisableItem( SID_EDITDOC );
     877             :                     else
     878           0 :                         rSet.Put( SfxBoolItem( nWhich, !pSh->IsReadOnly() ) );
     879             :                 }
     880           0 :                 break;
     881             :             }
     882             : 
     883             :             case SID_RELOAD:
     884             :             {
     885           0 :                 SfxFrame* pFrame = &GetTopFrame();
     886             : 
     887           0 :                 if ( !pSh || !pSh->CanReload_Impl() || pSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
     888           0 :                     rSet.DisableItem(nWhich);
     889             :                 else
     890             :                 {
     891             :                     // If any ChildFrame is reloadable, the slot is enabled,
     892             :                     // so you can perfom CTRL-Reload
     893           0 :                     sal_Bool bReloadAvailable = sal_False;
     894           0 :                     SfxFrameIterator aFrameIter( *pFrame, sal_True );
     895           0 :                     for( SfxFrame* pNextFrame = aFrameIter.FirstFrame();
     896             :                             pFrame;
     897             :                             pNextFrame = pNextFrame ?
     898             :                                 aFrameIter.NextFrame( *pNextFrame ) : 0 )
     899             :                     {
     900           0 :                         SfxObjectShell *pShell = pFrame->GetCurrentDocument();
     901           0 :                         if( pShell && pShell->Get_Impl()->bReloadAvailable )
     902             :                         {
     903           0 :                             bReloadAvailable = sal_True;
     904           0 :                             break;
     905             :                         }
     906           0 :                         pFrame = pNextFrame;
     907             :                     }
     908             : 
     909           0 :                     rSet.Put( SfxBoolItem( nWhich, bReloadAvailable));
     910             :                 }
     911             : 
     912           0 :                 break;
     913             :             }
     914             :         }
     915           0 :     }
     916             : }
     917             : 
     918             : 
     919             : //--------------------------------------------------------------------
     920           0 : void SfxViewFrame::ExecHistory_Impl( SfxRequest &rReq )
     921             : {
     922             :     // Is there an Undo-Manager on the top Shell?
     923           0 :     SfxShell *pSh = GetDispatcher()->GetShell(0);
     924           0 :     ::svl::IUndoManager* pShUndoMgr = pSh->GetUndoManager();
     925           0 :     sal_Bool bOK = sal_False;
     926           0 :     if ( pShUndoMgr )
     927             :     {
     928           0 :         switch ( rReq.GetSlot() )
     929             :         {
     930             :             case SID_CLEARHISTORY:
     931           0 :                 pShUndoMgr->Clear();
     932           0 :                 bOK = sal_True;
     933           0 :                 break;
     934             : 
     935             :             case SID_UNDO:
     936           0 :                 pShUndoMgr->Undo();
     937           0 :                 GetBindings().InvalidateAll(sal_False);
     938           0 :                 bOK = sal_True;
     939           0 :                 break;
     940             : 
     941             :             case SID_REDO:
     942           0 :                 pShUndoMgr->Redo();
     943           0 :                 GetBindings().InvalidateAll(sal_False);
     944           0 :                 bOK = sal_True;
     945           0 :                 break;
     946             : 
     947             :             case SID_REPEAT:
     948           0 :                 if ( pSh->GetRepeatTarget() )
     949           0 :                     pShUndoMgr->Repeat( *pSh->GetRepeatTarget() );
     950           0 :                 bOK = sal_True;
     951           0 :                 break;
     952             :         }
     953             :     }
     954           0 :     else if ( GetViewShell() )
     955             :     {
     956             :         // The SW has its own undo in the View
     957           0 :         const SfxPoolItem *pRet = GetViewShell()->ExecuteSlot( rReq );
     958           0 :         if ( pRet )
     959           0 :             bOK = ((SfxBoolItem*)pRet)->GetValue();
     960             :     }
     961             : 
     962           0 :     rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bOK ) );
     963           0 :     rReq.Done();
     964           0 : }
     965             : 
     966             : //--------------------------------------------------------------------
     967           0 : void SfxViewFrame::StateHistory_Impl( SfxItemSet &rSet )
     968             : {
     969             :     // Search for Undo-Manager
     970           0 :     SfxShell *pSh = GetDispatcher()->GetShell(0);
     971           0 :     if ( !pSh )
     972             :         // I'm just on reload and am yielding myself ...
     973           0 :         return;
     974             : 
     975           0 :     ::svl::IUndoManager *pShUndoMgr = pSh->GetUndoManager();
     976           0 :     if ( !pShUndoMgr )
     977             :     {
     978             :         // The SW has its own undo in the View
     979           0 :         SfxWhichIter aIter( rSet );
     980           0 :         SfxViewShell *pViewSh = GetViewShell();
     981           0 :         if( !pViewSh ) return;
     982           0 :         for ( sal_uInt16 nSID = aIter.FirstWhich(); nSID; nSID = aIter.NextWhich() )
     983           0 :             pViewSh->GetSlotState( nSID, 0, &rSet );
     984           0 :         return;
     985             :     }
     986             : 
     987           0 :     if ( pShUndoMgr->GetUndoActionCount() == 0 &&
     988           0 :          pShUndoMgr->GetRedoActionCount() == 0 &&
     989           0 :          pShUndoMgr->GetRepeatActionCount() == 0 )
     990           0 :         rSet.DisableItem( SID_CLEARHISTORY );
     991             : 
     992           0 :     if ( pShUndoMgr && pShUndoMgr->GetUndoActionCount() )
     993             :     {
     994           0 :         String aTmp(SvtResId(STR_UNDO).toString());
     995           0 :         aTmp+= pShUndoMgr->GetUndoActionComment(0);
     996           0 :         rSet.Put( SfxStringItem( SID_UNDO, aTmp ) );
     997             :     }
     998             :     else
     999           0 :         rSet.DisableItem( SID_UNDO );
    1000             : 
    1001           0 :     if ( pShUndoMgr && pShUndoMgr->GetRedoActionCount() )
    1002             :     {
    1003           0 :         String aTmp(SvtResId(STR_REDO).toString());
    1004           0 :         aTmp += pShUndoMgr->GetRedoActionComment(0);
    1005           0 :         rSet.Put( SfxStringItem( SID_REDO, aTmp ) );
    1006             :     }
    1007             :     else
    1008           0 :         rSet.DisableItem( SID_REDO );
    1009           0 :     SfxRepeatTarget *pTarget = pSh->GetRepeatTarget();
    1010           0 :     if ( pShUndoMgr && pTarget && pShUndoMgr->GetRepeatActionCount() &&
    1011           0 :          pShUndoMgr->CanRepeat(*pTarget) )
    1012             :     {
    1013           0 :         String aTmp(SvtResId(STR_REPEAT).toString());
    1014           0 :         aTmp += pShUndoMgr->GetRepeatActionComment(*pTarget);
    1015           0 :         rSet.Put( SfxStringItem( SID_REPEAT, aTmp ) );
    1016             :     }
    1017             :     else
    1018           0 :         rSet.DisableItem( SID_REPEAT );
    1019             : }
    1020             : 
    1021             : //--------------------------------------------------------------------
    1022          63 : void SfxViewFrame::PopShellAndSubShells_Impl( SfxViewShell& i_rViewShell )
    1023             : {
    1024          63 :     i_rViewShell.PopSubShells_Impl();
    1025          63 :     sal_uInt16 nLevel = pDispatcher->GetShellLevel( i_rViewShell );
    1026          63 :     if ( nLevel != USHRT_MAX )
    1027             :     {
    1028          63 :         if ( nLevel )
    1029             :         {
    1030             :             // more sub shells on the stack, which were not affected by PopSubShells_Impl
    1031          63 :             SfxShell *pSubShell = pDispatcher->GetShell( nLevel-1 );
    1032          63 :             if ( pSubShell == i_rViewShell.GetSubShell() )
    1033             :                 // "real" sub shells will be deleted elsewhere
    1034           0 :                 pDispatcher->Pop( *pSubShell, SFX_SHELL_POP_UNTIL );
    1035             :             else
    1036          63 :                 pDispatcher->Pop( *pSubShell, SFX_SHELL_POP_UNTIL | SFX_SHELL_POP_DELETE );
    1037             :         }
    1038          63 :         pDispatcher->Pop( i_rViewShell );
    1039          63 :         pDispatcher->Flush();
    1040             :     }
    1041             : 
    1042          63 : }
    1043             : 
    1044             : //--------------------------------------------------------------------
    1045          63 : void SfxViewFrame::ReleaseObjectShell_Impl()
    1046             : 
    1047             : /*  [Description]
    1048             : 
    1049             :     This method empties the SfxViewFrame, i.e. takes the <SfxObjectShell>
    1050             :     from the dispatcher and ends its <SfxListener> Relationship to this
    1051             :     SfxObjectShell (by which they may even destroy themselves).
    1052             : 
    1053             :     Thus, by invoking ReleaseObjectShell() and  SetObjectShell() the
    1054             :     SfxObjectShell can be replaced.
    1055             : 
    1056             :     Between RealeaseObjectShell() and SetObjectShell() can the control not
    1057             :     be handed over to the system.
    1058             : 
    1059             :     [Cross-reference]
    1060             : 
    1061             :     <SfxViewFrame::SetObjectShell(SfxObjectShell&)>
    1062             : */
    1063             : {
    1064             :     DBG_CHKTHIS(SfxViewFrame, 0);
    1065             :     DBG_ASSERT( xObjSh.Is(), "no SfxObjectShell to release!" );
    1066             : 
    1067          63 :     GetFrame().ReleasingComponent_Impl( sal_True );
    1068          63 :     if ( GetWindow().HasChildPathFocus( sal_True ) )
    1069             :     {
    1070             :         DBG_ASSERT( !GetActiveChildFrame_Impl(), "Wrong active child frame!" );
    1071          40 :         GetWindow().GrabFocus();
    1072             :     }
    1073             : 
    1074          63 :     SfxViewShell *pDyingViewSh = GetViewShell();
    1075          63 :     if ( pDyingViewSh )
    1076             :     {
    1077          63 :         PopShellAndSubShells_Impl( *pDyingViewSh );
    1078          63 :         pDyingViewSh->DisconnectAllClients();
    1079          63 :         SetViewShell_Impl(0);
    1080          63 :         delete pDyingViewSh;
    1081             :     }
    1082             : #ifdef DBG_UTIL
    1083             :     else
    1084             :         OSL_FAIL("No Shell");
    1085             : #endif
    1086             : 
    1087          63 :     if ( xObjSh.Is() )
    1088             :     {
    1089          63 :          pImp->aLastType = xObjSh->Type();
    1090          63 :         pDispatcher->Pop( *xObjSh );
    1091          63 :         SfxModule* pModule = xObjSh->GetModule();
    1092          63 :         if( pModule )
    1093          63 :             pDispatcher->RemoveShell_Impl( *pModule );
    1094          63 :         pDispatcher->Flush();
    1095          63 :         EndListening( *xObjSh );
    1096             : 
    1097          63 :         Notify( *xObjSh, SfxSimpleHint(SFX_HINT_TITLECHANGED) );
    1098          63 :         Notify( *xObjSh, SfxSimpleHint(SFX_HINT_DOCCHANGED) );
    1099             : 
    1100          63 :         if ( 1 == xObjSh->GetOwnerLockCount() && pImp->bObjLocked && xObjSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
    1101           0 :             xObjSh->DoClose();
    1102          63 :         SfxObjectShellRef xDyingObjSh = xObjSh;
    1103          63 :         xObjSh.Clear();
    1104          63 :         if( ( GetFrameType() & SFXFRAME_HASTITLE ) && pImp->nDocViewNo )
    1105          63 :             xDyingObjSh->GetNoSet_Impl().ReleaseIndex(pImp->nDocViewNo-1);
    1106          63 :         if ( pImp->bObjLocked )
    1107             :         {
    1108          63 :             xDyingObjSh->OwnerLock( sal_False );
    1109          63 :             pImp->bObjLocked = sal_False;
    1110          63 :         }
    1111             :     }
    1112             : 
    1113          63 :     GetDispatcher()->SetDisableFlags( 0 );
    1114          63 : }
    1115             : 
    1116             : //--------------------------------------------------------------------
    1117          63 : sal_Bool SfxViewFrame::Close()
    1118             : {
    1119             :     DBG_CHKTHIS(SfxViewFrame, 0);
    1120             : 
    1121             :     DBG_ASSERT( GetFrame().IsClosing_Impl() || !GetFrame().GetFrameInterface().is(), "ViewFrame closed too early!" );
    1122             : 
    1123             :     // If no saving have been made up until now, then embedded Objects should
    1124             :     // not be saved automatically anymore.
    1125          63 :     if ( GetViewShell() )
    1126          63 :         GetViewShell()->DiscardClients_Impl();
    1127          63 :     Broadcast( SfxSimpleHint( SFX_HINT_DYING ) );
    1128             : 
    1129          63 :     if (SfxViewFrame::Current() == this)
    1130          63 :         SfxViewFrame::SetViewFrame( NULL );
    1131             : 
    1132             :     // Since the Dispatcher is emptied, it can not be used in any reasnable
    1133             :     // manner, thus it is better to let the dispatcher be.
    1134          63 :     GetDispatcher()->Lock(sal_True);
    1135          63 :     delete this;
    1136             : 
    1137          63 :     return sal_True;
    1138             : }
    1139             : 
    1140             : //--------------------------------------------------------------------
    1141             : 
    1142         236 : void SfxViewFrame::DoActivate( sal_Bool bUI, SfxViewFrame* pOldFrame )
    1143             : {
    1144             :     DBG_CHKTHIS(SfxViewFrame, 0);
    1145         236 :     SFX_APP();
    1146             : 
    1147         236 :     pDispatcher->DoActivate_Impl( bUI, pOldFrame );
    1148             : 
    1149             :     // If this ViewFrame has got a parent and this is not a parent of the
    1150             :     // old ViewFrames, it gets a ParentActivate.
    1151         236 :     if ( bUI )
    1152             :     {
    1153         236 :         SfxViewFrame *pFrame = GetParentViewFrame();
    1154         472 :         while ( pFrame )
    1155             :         {
    1156           0 :             if ( !pOldFrame || !pOldFrame->GetFrame().IsParent( &pFrame->GetFrame() ) )
    1157           0 :                 pFrame->pDispatcher->DoParentActivate_Impl();
    1158           0 :             pFrame = pFrame->GetParentViewFrame();
    1159             :         }
    1160             :     }
    1161         236 : }
    1162             : 
    1163             : //--------------------------------------------------------------------
    1164         236 : void SfxViewFrame::DoDeactivate(sal_Bool bUI, SfxViewFrame* pNewFrame )
    1165             : {
    1166             :     DBG_CHKTHIS(SfxViewFrame, 0);
    1167         236 :     SFX_APP();
    1168         236 :     pDispatcher->DoDeactivate_Impl( bUI, pNewFrame );
    1169             : 
    1170             :     // If this ViewFrame has got a parent and this is not a parent of the
    1171             :     // new ViewFrames, it gets a ParentDeactivate.
    1172         236 :     if ( bUI )
    1173             :     {
    1174         236 :         SfxViewFrame *pFrame = GetParentViewFrame();
    1175         472 :         while ( pFrame )
    1176             :         {
    1177           0 :             if ( !pNewFrame || !pNewFrame->GetFrame().IsParent( &pFrame->GetFrame() ) )
    1178           0 :                 pFrame->pDispatcher->DoParentDeactivate_Impl();
    1179           0 :             pFrame = pFrame->GetParentViewFrame();
    1180             :         }
    1181             :     }
    1182         236 : }
    1183             : 
    1184             : //------------------------------------------------------------------------
    1185         708 : void SfxViewFrame::InvalidateBorderImpl( const SfxViewShell* pSh )
    1186             : {
    1187         708 :     if( pSh && !nAdjustPosPixelLock )
    1188             :     {
    1189         708 :         if ( GetViewShell() && GetWindow().IsVisible() )
    1190             :         {
    1191           0 :             if ( GetFrame().IsInPlace() )
    1192             :             {
    1193         708 :                 return;
    1194             :             }
    1195             : 
    1196           0 :             DoAdjustPosSizePixel( (SfxViewShell *) GetViewShell(), Point(),
    1197           0 :                                             GetWindow().GetOutputSizePixel() );
    1198             :         }
    1199             :     }
    1200             : }
    1201             : 
    1202             : //------------------------------------------------------------------------
    1203         619 : sal_Bool SfxViewFrame::SetBorderPixelImpl
    1204             : (
    1205             :     const SfxViewShell* pVSh,
    1206             :     const SvBorder&     rBorder
    1207             : )
    1208             : 
    1209             : {
    1210         619 :     pImp->aBorder = rBorder;
    1211             : 
    1212         619 :     if ( IsResizeInToOut_Impl() && !GetFrame().IsInPlace() )
    1213             :     {
    1214           0 :         Size aSize = pVSh->GetWindow()->GetOutputSizePixel();
    1215           0 :         if ( aSize.Width() && aSize.Height() )
    1216             :         {
    1217           0 :             aSize.Width() += rBorder.Left() + rBorder.Right();
    1218           0 :             aSize.Height() += rBorder.Top() + rBorder.Bottom();
    1219             : 
    1220           0 :             Size aOldSize = GetWindow().GetOutputSizePixel();
    1221           0 :             GetWindow().SetOutputSizePixel( aSize );
    1222           0 :             Window* pParent = &GetWindow();
    1223           0 :             while ( pParent->GetParent() )
    1224           0 :                 pParent = pParent->GetParent();
    1225           0 :             Size aOuterSize = pParent->GetOutputSizePixel();
    1226           0 :             aOuterSize.Width() += ( aSize.Width() - aOldSize.Width() );
    1227           0 :             aOuterSize.Height() += ( aSize.Height() - aOldSize.Height() );
    1228           0 :             pParent->SetOutputSizePixel( aOuterSize );
    1229             :         }
    1230             :     }
    1231             :     else
    1232             :     {
    1233         619 :         Point aPoint;
    1234         619 :         Rectangle aEditArea( aPoint, GetWindow().GetOutputSizePixel() );
    1235         619 :         aEditArea.Left() += rBorder.Left();
    1236         619 :         aEditArea.Right() -= rBorder.Right();
    1237         619 :         aEditArea.Top() += rBorder.Top();
    1238         619 :         aEditArea.Bottom() -= rBorder.Bottom();
    1239         619 :         pVSh->GetWindow()->SetPosSizePixel( aEditArea.TopLeft(), aEditArea.GetSize() );
    1240             :     }
    1241             : 
    1242         619 :     return sal_True;
    1243             : }
    1244             : 
    1245             : //------------------------------------------------------------------------
    1246         145 : const SvBorder& SfxViewFrame::GetBorderPixelImpl
    1247             : (
    1248             :     const SfxViewShell* /*pSh*/
    1249             : )   const
    1250             : 
    1251             : {
    1252         145 :     return pImp->aBorder;
    1253             : }
    1254             : 
    1255             : //--------------------------------------------------------------------
    1256        1978 : void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
    1257             : {
    1258             :     {DBG_CHKTHIS(SfxViewFrame, 0);}
    1259             : 
    1260        1978 :     if( IsDowning_Impl())
    1261        2104 :         return;
    1262             : 
    1263             :     // we know only SimpleHints
    1264        1852 :     if ( rHint.IsA(TYPE(SfxSimpleHint)) )
    1265             :     {
    1266         667 :         switch( ( (SfxSimpleHint&) rHint ).GetId() )
    1267             :         {
    1268             :             case SFX_HINT_MODECHANGED:
    1269             :             {
    1270           0 :                 UpdateTitle();
    1271             : 
    1272           0 :                 if ( !xObjSh.Is() )
    1273           0 :                     break;
    1274             : 
    1275             :                 // Switch r/o?
    1276           0 :                 SfxBindings& rBind = GetBindings();
    1277           0 :                 rBind.Invalidate( SID_RELOAD );
    1278           0 :                 SfxDispatcher *pDispat = GetDispatcher();
    1279           0 :                 sal_Bool bWasReadOnly = pDispat->GetReadOnly_Impl();
    1280           0 :                 sal_Bool bIsReadOnly = xObjSh->IsReadOnly();
    1281           0 :                 if ( !bWasReadOnly != !bIsReadOnly )
    1282             :                 {
    1283             :                     // Then also TITLE_CHANGED
    1284           0 :                     UpdateTitle();
    1285           0 :                     rBind.Invalidate( SID_FILE_NAME );
    1286           0 :                     rBind.Invalidate( SID_DOCINFO_TITLE );
    1287           0 :                     rBind.Invalidate( SID_EDITDOC );
    1288             : 
    1289           0 :                     pDispat->GetBindings()->InvalidateAll(sal_True);
    1290           0 :                     pDispat->SetReadOnly_Impl( bIsReadOnly );
    1291             : 
    1292             :                     // Only force and Dispatcher-Update, if it is done next
    1293             :                     // anyway, otherwise flickering or GPF is possibel since
    1294             :                     // the Writer for example prefers in Resize preform some
    1295             :                     // actions which has a SetReadOnlyUI in Dispatcher as a
    1296             :                     // result!
    1297             : 
    1298           0 :                     if ( pDispat->IsUpdated_Impl() )
    1299           0 :                         pDispat->Update_Impl(sal_True);
    1300             :                 }
    1301             : 
    1302           0 :                 Enable( !xObjSh->IsInModalMode() );
    1303           0 :                 break;
    1304             :             }
    1305             : 
    1306             :             case SFX_HINT_TITLECHANGED:
    1307             :             {
    1308         322 :                 UpdateTitle();
    1309         322 :                 SfxBindings& rBind = GetBindings();
    1310         322 :                 rBind.Invalidate( SID_FILE_NAME );
    1311         322 :                 rBind.Invalidate( SID_DOCINFO_TITLE );
    1312         322 :                 rBind.Invalidate( SID_EDITDOC );
    1313         322 :                 rBind.Invalidate( SID_RELOAD );
    1314         322 :                 break;
    1315             :             }
    1316             : 
    1317             :             case SFX_HINT_DEINITIALIZING:
    1318          63 :                 GetFrame().DoClose();
    1319          63 :                 break;
    1320             :             case SFX_HINT_DYING:
    1321             :                 // when the Object is being deleted, destroy the view too
    1322           0 :                 if ( xObjSh.Is() )
    1323           0 :                     ReleaseObjectShell_Impl();
    1324             :                 else
    1325           0 :                     GetFrame().DoClose();
    1326           0 :                 break;
    1327             : 
    1328             :         }
    1329             :     }
    1330        1185 :     else if ( rHint.IsA(TYPE(SfxEventHint)) )
    1331             :     {
    1332             :         // When the Document is loaded asynchronously, was the Dispatcher
    1333             :         // set as ReadOnly, to what must be returned when the document itself
    1334             :         // is not read only, and the loading is finished.
    1335        1185 :         switch ( ((SfxEventHint&)rHint).GetEventId() )
    1336             :         {
    1337             :             case SFX_EVENT_MODIFYCHANGED:
    1338             :             {
    1339          18 :                 SfxBindings& rBind = GetBindings();
    1340          18 :                 rBind.Invalidate( SID_DOC_MODIFIED );
    1341          18 :                 rBind.Invalidate( SID_SAVEDOC );
    1342          18 :                 rBind.Invalidate( SID_RELOAD );
    1343          18 :                 rBind.Invalidate( SID_EDITDOC );
    1344          18 :                 break;
    1345             :             }
    1346             : 
    1347             :             case SFX_EVENT_OPENDOC:
    1348             :             case SFX_EVENT_CREATEDOC:
    1349             :             {
    1350         124 :                 if ( !xObjSh.Is() )
    1351           0 :                     break;
    1352             : 
    1353         124 :                 SfxBindings& rBind = GetBindings();
    1354         124 :                 rBind.Invalidate( SID_RELOAD );
    1355         124 :                 rBind.Invalidate( SID_EDITDOC );
    1356         124 :                 if ( !xObjSh->IsReadOnly() )
    1357             :                 {
    1358             :                     // In contrast to above (TITLE_CHANGED) does the UI not
    1359             :                     // have to be updated because it was not obstructed
    1360             : 
    1361             :                     // #i21560# InvalidateAll() causes the assertion
    1362             :                     // 'SfxBindings::Invalidate while in update" when
    1363             :                     // the sfx slot SID_BASICIDE_APPEAR is executed
    1364             :                     // via API from another thread (Java).
    1365             :                     // According to MBA this call is not necessary anymore,
    1366             :                     // because each document has its own SfxBindings.
    1367             :                     //GetDispatcher()->GetBindings()->InvalidateAll(sal_True);
    1368             :                 }
    1369             : 
    1370         124 :                 break;
    1371             :             }
    1372             : 
    1373             :             case SFX_EVENT_TOGGLEFULLSCREENMODE:
    1374             :             {
    1375           0 :                 if ( GetFrame().OwnsBindings_Impl() )
    1376           0 :                     GetBindings().GetDispatcher_Impl()->Update_Impl( sal_True );
    1377           0 :                 break;
    1378             :             }
    1379             :         }
    1380             :     }
    1381             : }
    1382             : 
    1383             : //------------------------------------------------------------------------
    1384         240 : void SfxViewFrame::Construct_Impl( SfxObjectShell *pObjSh )
    1385             : {
    1386         240 :     pImp->bResizeInToOut = sal_True;
    1387         240 :     pImp->bDontOverwriteResizeInToOut = sal_False;
    1388         240 :     pImp->bObjLocked = sal_False;
    1389         240 :     pImp->pFocusWin = 0;
    1390         240 :     pImp->pActiveChild = NULL;
    1391         240 :     pImp->nCurViewId = 0;
    1392         240 :     pImp->bReloading = sal_False;
    1393         240 :     pImp->bIsDowning = sal_False;
    1394         240 :     pImp->bModal = sal_False;
    1395         240 :     pImp->bEnabled = sal_True;
    1396         240 :     pImp->nDocViewNo = 0;
    1397         240 :     pImp->aMargin = Size( -1, -1 );
    1398         240 :     pImp->pWindow = 0;
    1399             : 
    1400         240 :     SetPool( &SFX_APP()->GetPool() );
    1401         240 :     pDispatcher = new SfxDispatcher(this);
    1402         240 :     if ( !GetBindings().GetDispatcher() )
    1403         240 :         GetBindings().SetDispatcher( pDispatcher );
    1404             : 
    1405         240 :     xObjSh = pObjSh;
    1406         240 :     if ( xObjSh.Is() && xObjSh->IsPreview() )
    1407           0 :         SetQuietMode_Impl( sal_True );
    1408             : 
    1409         240 :     if ( pObjSh )
    1410             :     {
    1411         240 :         pDispatcher->Push( *SFX_APP() );
    1412         240 :         SfxModule* pModule = xObjSh->GetModule();
    1413         240 :         if( pModule )
    1414         240 :             pDispatcher->Push( *pModule );
    1415         240 :         pDispatcher->Push( *this );
    1416         240 :         pDispatcher->Push( *pObjSh );
    1417         240 :         pDispatcher->Flush();
    1418         240 :         StartListening( *pObjSh );
    1419         240 :         pObjSh->ViewAssigned();
    1420         240 :         Notify( *pObjSh, SfxSimpleHint(SFX_HINT_TITLECHANGED) );
    1421         240 :         Notify( *pObjSh, SfxSimpleHint(SFX_HINT_DOCCHANGED) );
    1422         240 :         pDispatcher->SetReadOnly_Impl( pObjSh->IsReadOnly() );
    1423             :     }
    1424             :     else
    1425             :     {
    1426           0 :         pDispatcher->Push( *SFX_APP() );
    1427           0 :         pDispatcher->Push( *this );
    1428           0 :         pDispatcher->Flush();
    1429             :     }
    1430             : 
    1431         240 :     SfxViewFrameArr_Impl &rViewArr = SFX_APP()->GetViewFrames_Impl();
    1432         240 :     rViewArr.push_back( this );
    1433         240 : }
    1434             : 
    1435         240 : SfxViewFrame::SfxViewFrame
    1436             : (
    1437             :     SfxFrame&           rFrame,
    1438             :     SfxObjectShell*     pObjShell
    1439             : )
    1440             : 
    1441             : /*  [Description]
    1442             : 
    1443             :     Constructor of SfxViewFrame for a <SfxObjectShell> from the Resource.
    1444             :     The 'nViewId' to the created <SfxViewShell> can be returned.
    1445             :     (default is the SfxViewShell-Subclass that was registered first).
    1446             : */
    1447             : 
    1448         240 :     : pImp( new SfxViewFrame_Impl( rFrame ) )
    1449             :     , pDispatcher(0)
    1450         240 :     , pBindings( new SfxBindings )
    1451         720 :     , nAdjustPosPixelLock( 0 )
    1452             : {
    1453             :     DBG_CTOR( SfxViewFrame, NULL );
    1454             : 
    1455         240 :     rFrame.SetCurrentViewFrame_Impl( this );
    1456         240 :     rFrame.SetFrameType_Impl( GetFrameType() | SFXFRAME_HASTITLE );
    1457         240 :     Construct_Impl( pObjShell );
    1458             : 
    1459         240 :     pImp->pWindow = new SfxFrameViewWindow_Impl( this, rFrame.GetWindow() );
    1460         240 :     pImp->pWindow->SetSizePixel( rFrame.GetWindow().GetOutputSizePixel() );
    1461         240 :     rFrame.SetOwnsBindings_Impl( sal_True );
    1462         240 :     rFrame.CreateWorkWindow_Impl();
    1463         240 : }
    1464             : 
    1465             : //------------------------------------------------------------------------
    1466         189 : SfxViewFrame::~SfxViewFrame()
    1467             : {
    1468             :     DBG_DTOR(SfxViewFrame, 0);
    1469             : 
    1470          63 :     SetDowning_Impl();
    1471             : 
    1472          63 :     if ( SfxViewFrame::Current() == this )
    1473           0 :         SfxViewFrame::SetViewFrame( NULL );
    1474             : 
    1475          63 :     ReleaseObjectShell_Impl();
    1476             : 
    1477          63 :     if ( GetFrame().OwnsBindings_Impl() )
    1478             :         // The Bindings delete the Frame!
    1479          63 :         KillDispatcher_Impl();
    1480             : 
    1481          63 :     delete pImp->pWindow;
    1482             : 
    1483          63 :     if ( GetFrame().GetCurrentViewFrame() == this )
    1484          63 :         GetFrame().SetCurrentViewFrame_Impl( NULL );
    1485             : 
    1486             :     // Unregister from the Frame List.
    1487          63 :     SfxApplication *pSfxApp = SFX_APP();
    1488          63 :     SfxViewFrameArr_Impl &rFrames = pSfxApp->GetViewFrames_Impl();
    1489          63 :     SfxViewFrameArr_Impl::iterator it = std::find( rFrames.begin(), rFrames.end(), this );
    1490          63 :     rFrames.erase( it );
    1491             : 
    1492             :     // Delete Member
    1493          63 :     KillDispatcher_Impl();
    1494             : 
    1495          63 :     delete pImp;
    1496         126 : }
    1497             : 
    1498             : //------------------------------------------------------------------------
    1499         126 : void SfxViewFrame::KillDispatcher_Impl()
    1500             : 
    1501             : // Remove and delete the Dispatcher.
    1502             : 
    1503             : {
    1504             :     DBG_CHKTHIS(SfxViewFrame, 0);
    1505             : 
    1506         126 :     SfxModule* pModule = xObjSh.Is() ? xObjSh->GetModule() : 0;
    1507         126 :     if ( xObjSh.Is() )
    1508           0 :         ReleaseObjectShell_Impl();
    1509         126 :     if ( pDispatcher )
    1510             :     {
    1511          63 :         if( pModule )
    1512           0 :             pDispatcher->Pop( *pModule, SFX_SHELL_POP_UNTIL );
    1513             :         else
    1514          63 :             pDispatcher->Pop( *this );
    1515          63 :         DELETEZ(pDispatcher);
    1516             :     }
    1517         126 : }
    1518             : 
    1519             : //------------------------------------------------------------------------
    1520       12948 : SfxViewFrame* SfxViewFrame::Current()
    1521             : {
    1522       12948 :     return SfxApplication::Get() ? SFX_APP()->Get_Impl()->pViewFrame : NULL;
    1523             : }
    1524             : 
    1525             : //--------------------------------------------------------------------
    1526             : // returns the first window of spec. type viewing the specified doc.
    1527       12922 : SfxViewFrame* SfxViewFrame::GetFirst
    1528             : (
    1529             :     const SfxObjectShell*   pDoc,
    1530             :     sal_Bool                    bOnlyIfVisible
    1531             : )
    1532             : {
    1533       12922 :     SfxApplication *pSfxApp = SFX_APP();
    1534       12922 :     SfxViewFrameArr_Impl &rFrames = pSfxApp->GetViewFrames_Impl();
    1535             : 
    1536             :     // search for a SfxDocument of the specified type
    1537      164288 :     for ( sal_uInt16 nPos = 0; nPos < rFrames.size(); ++nPos )
    1538             :     {
    1539      153800 :         SfxViewFrame *pFrame = rFrames[nPos];
    1540      156030 :         if  (   ( !pDoc || pDoc == pFrame->GetObjectShell() )
    1541        2230 :             &&  ( !bOnlyIfVisible || pFrame->IsVisible() )
    1542             :             )
    1543        2434 :             return pFrame;
    1544             :     }
    1545             : 
    1546       10488 :     return 0;
    1547             : }
    1548             : //--------------------------------------------------------------------
    1549             : 
    1550             : // returns thenext window of spec. type viewing the specified doc.
    1551        1085 : SfxViewFrame* SfxViewFrame::GetNext
    1552             : (
    1553             :     const SfxViewFrame&     rPrev,
    1554             :     const SfxObjectShell*   pDoc,
    1555             :     sal_Bool                    bOnlyIfVisible
    1556             : )
    1557             : {
    1558        1085 :     SfxApplication *pSfxApp = SFX_APP();
    1559        1085 :     SfxViewFrameArr_Impl &rFrames = pSfxApp->GetViewFrames_Impl();
    1560             : 
    1561             :     // refind the specified predecessor
    1562             :     sal_uInt16 nPos;
    1563       22418 :     for ( nPos = 0; nPos < rFrames.size(); ++nPos )
    1564       22418 :         if ( rFrames[nPos] == &rPrev )
    1565        1085 :             break;
    1566             : 
    1567             :     // search for a Frame of the specified type
    1568        2881 :     for ( ++nPos; nPos < rFrames.size(); ++nPos )
    1569             :     {
    1570        1796 :         SfxViewFrame *pFrame = rFrames[nPos];
    1571        1796 :         if  (   ( !pDoc || pDoc == pFrame->GetObjectShell() )
    1572           0 :             &&  ( !bOnlyIfVisible || pFrame->IsVisible() )
    1573             :             )
    1574           0 :             return pFrame;
    1575             :     }
    1576        1085 :     return 0;
    1577             : }
    1578             : 
    1579             : //--------------------------------------------------------------------
    1580         472 : SfxProgress* SfxViewFrame::GetProgress() const
    1581             : {
    1582         472 :     SfxObjectShell *pObjSh = GetObjectShell();
    1583         472 :     return pObjSh ? pObjSh->GetProgress() : 0;
    1584             : }
    1585             : 
    1586             : //--------------------------------------------------------------------
    1587         709 : void SfxViewFrame::DoAdjustPosSizePixel //! divide on Inner.../Outer...
    1588             : (
    1589             :     SfxViewShell*   pSh,
    1590             :     const Point&    rPos,
    1591             :     const Size&     rSize
    1592             : )
    1593             : {
    1594             :     DBG_CHKTHIS(SfxViewFrame, 0);
    1595             : 
    1596             :     // Components do not use this Method!
    1597         709 :     if( pSh && pSh->GetWindow() && !nAdjustPosPixelLock )
    1598             :     {
    1599         709 :         nAdjustPosPixelLock++;
    1600         709 :         if ( pImp->bResizeInToOut )
    1601           0 :             pSh->InnerResizePixel( rPos, rSize );
    1602             :         else
    1603         709 :             pSh->OuterResizePixel( rPos, rSize );
    1604         709 :         nAdjustPosPixelLock--;
    1605             :     }
    1606         709 : }
    1607             : 
    1608             : //========================================================================
    1609             : 
    1610           0 : int SfxViewFrameItem::operator==( const SfxPoolItem &rItem ) const
    1611             : {
    1612           0 :      return PTR_CAST(SfxViewFrameItem, &rItem)->pFrame== pFrame;
    1613             : }
    1614             : 
    1615             : //--------------------------------------------------------------------
    1616           0 : String SfxViewFrameItem::GetValueText() const
    1617             : {
    1618           0 :     return String();
    1619             : }
    1620             : 
    1621             : //--------------------------------------------------------------------
    1622           0 : SfxPoolItem* SfxViewFrameItem::Clone( SfxItemPool *) const
    1623             : {
    1624           0 :     return new SfxViewFrameItem( pFrame);
    1625             : }
    1626             : 
    1627             : //--------------------------------------------------------------------
    1628         303 : void SfxViewFrame::SetViewShell_Impl( SfxViewShell *pVSh )
    1629             : 
    1630             : /*  [Description]
    1631             : 
    1632             :     Internal Method to set the current <SfxViewShell> Instance,
    1633             :     that is active int this SfxViewFrame at the moment.
    1634             : */
    1635             : 
    1636             : {
    1637         303 :     SfxShell::SetViewShell_Impl( pVSh );
    1638             : 
    1639             :     // Hack: InPlaceMode
    1640         303 :     if ( pVSh )
    1641         240 :         pImp->bResizeInToOut = sal_False;
    1642         303 : }
    1643             : 
    1644             : //--------------------------------------------------------------------
    1645             : /*  [Description]
    1646             : 
    1647             :     The ParentViewFrame of the Containers ViewFrame in the internal InPlace
    1648             : */
    1649             : 
    1650             : //TODO/LATER: is it still necessary? is there a replacement for GetParentViewFrame_Impl?
    1651         687 : SfxViewFrame* SfxViewFrame::GetParentViewFrame_Impl() const
    1652             : {
    1653         687 :     return NULL;
    1654             : }
    1655             : 
    1656             : //--------------------------------------------------------------------
    1657           0 : void SfxViewFrame::ForceOuterResize_Impl(sal_Bool bOn)
    1658             : {
    1659           0 :     if ( !pImp->bDontOverwriteResizeInToOut )
    1660           0 :         pImp->bResizeInToOut = !bOn;
    1661           0 : }
    1662             : 
    1663             : //--------------------------------------------------------------------
    1664         619 : sal_Bool SfxViewFrame::IsResizeInToOut_Impl() const
    1665             : {
    1666         619 :     return pImp->bResizeInToOut;
    1667             : }
    1668             : 
    1669             : //--------------------------------------------------------------------
    1670         236 : void SfxViewFrame::GetDocNumber_Impl()
    1671             : {
    1672             :     DBG_ASSERT( GetObjectShell(), "No Document!" );
    1673         236 :     GetObjectShell()->SetNamedVisibility_Impl();
    1674         236 :     pImp->nDocViewNo = GetObjectShell()->GetNoSet_Impl().GetFreeIndex()+1;
    1675         236 : }
    1676             : 
    1677             : //--------------------------------------------------------------------
    1678             : 
    1679         350 : void SfxViewFrame::Enable( sal_Bool bEnable )
    1680             : {
    1681         350 :     if ( bEnable != pImp->bEnabled )
    1682             :     {
    1683         110 :         pImp->bEnabled = bEnable;
    1684             : 
    1685             :         // e.g. InPlace-Frames have a parent...
    1686         110 :         SfxViewFrame *pParent = GetParentViewFrame_Impl();
    1687         110 :         if ( pParent )
    1688             :         {
    1689           0 :             pParent->Enable( bEnable );
    1690             :         }
    1691             :         else
    1692             :         {
    1693         110 :             Window *pWindow = &GetFrame().GetTopFrame().GetWindow();
    1694         110 :             if ( !bEnable )
    1695          55 :                 pImp->bWindowWasEnabled = pWindow->IsInputEnabled();
    1696         110 :             if ( !bEnable || pImp->bWindowWasEnabled )
    1697         110 :                 pWindow->EnableInput( bEnable, sal_True );
    1698             :         }
    1699             : 
    1700             :         // cursor and focus
    1701         110 :         SfxViewShell* pViewSh = GetViewShell();
    1702         110 :         if ( bEnable )
    1703             :         {
    1704             :             // show cursor
    1705          55 :             if ( pViewSh )
    1706          55 :                 pViewSh->ShowCursor();
    1707             :         }
    1708             :         else
    1709             :         {
    1710             :             // hide cursor
    1711          55 :             if ( pViewSh )
    1712          55 :                 pViewSh->ShowCursor(sal_False);
    1713             :         }
    1714             :     }
    1715         350 : }
    1716             : 
    1717             : //--------------------------------------------------------------------
    1718         378 : void SfxViewFrame::Show()
    1719             : 
    1720             : /*  [Description]
    1721             : 
    1722             :     This method makes the Frame-Window visible and before transmitts the
    1723             :     window name. In addition, the document is held. In general one can never
    1724             :     show the window directly!
    1725             : */
    1726             : 
    1727             : {
    1728             :     // First lock the objectShell so that UpdateTitle() is valid:
    1729             :     // IsVisible() == sal_True (:#)
    1730         378 :     if ( xObjSh.Is() )
    1731             :     {
    1732         378 :         xObjSh->GetMedium()->GetItemSet()->ClearItem( SID_HIDDEN );
    1733         378 :         if ( !pImp->bObjLocked )
    1734         236 :             LockObjectShell_Impl( sal_True );
    1735             : 
    1736             :         // Adjust Doc-Shell titel nummer, get unique view-no
    1737         378 :         if ( 0 == pImp->nDocViewNo  )
    1738             :         {
    1739         236 :             GetDocNumber_Impl();
    1740         236 :             UpdateTitle();
    1741             :         }
    1742             :     }
    1743             :     else
    1744           0 :         UpdateTitle();
    1745             : 
    1746             :     // Display Frame-window, but only if the ViewFrame has no window of its
    1747             :     // own or if it does not contain a Component
    1748         378 :     if ( &GetWindow() == &GetFrame().GetWindow() || !GetFrame().HasComponent() )
    1749         378 :         GetWindow().Show();
    1750         378 :     GetFrame().GetWindow().Show();
    1751         378 : }
    1752             : 
    1753             : //--------------------------------------------------------------------
    1754        4561 : sal_Bool SfxViewFrame::IsVisible() const
    1755             : {
    1756        4561 :     return pImp->bObjLocked;
    1757             : }
    1758             : 
    1759             : //--------------------------------------------------------------------
    1760         236 : void SfxViewFrame::LockObjectShell_Impl( sal_Bool bLock )
    1761             : {
    1762             :     DBG_ASSERT( pImp->bObjLocked != bLock, "Wrong Locked status!" );
    1763             : 
    1764             :     DBG_ASSERT( GetObjectShell(), "No Document!" );
    1765         236 :     GetObjectShell()->OwnerLock(bLock);
    1766         236 :     pImp->bObjLocked = bLock;
    1767         236 : }
    1768             : 
    1769             : //--------------------------------------------------------------------
    1770         520 : void SfxViewFrame::MakeActive_Impl( sal_Bool bGrabFocus )
    1771             : {
    1772         520 :     if ( GetViewShell() && !GetFrame().IsClosing_Impl() )
    1773             :     {
    1774         520 :         if ( IsVisible() )
    1775             :         {
    1776         378 :             if ( GetViewShell() )
    1777             :             {
    1778         378 :                 sal_Bool bPreview = sal_False;
    1779         378 :                 if ( GetObjectShell()->IsPreview() )
    1780             :                 {
    1781           0 :                     bPreview = sal_True;
    1782             :                 }
    1783             :                 else
    1784             :                 {
    1785         378 :                     SfxViewFrame* pParent = GetParentViewFrame();
    1786         378 :                     if ( pParent )
    1787           0 :                         pParent->SetActiveChildFrame_Impl( this );
    1788             :                 }
    1789             : 
    1790         378 :                 SfxViewFrame* pCurrent = SfxViewFrame::Current();
    1791         378 :                 css::uno::Reference< css::frame::XFrame > xFrame = GetFrame().GetFrameInterface();
    1792         378 :                 if ( !bPreview )
    1793             :                 {
    1794         378 :                     SetViewFrame( this );
    1795         378 :                     GetBindings().SetActiveFrame( css::uno::Reference< css::frame::XFrame >() );
    1796         378 :                     uno::Reference< frame::XFramesSupplier > xSupp( xFrame, uno::UNO_QUERY );
    1797         378 :                     if ( xSupp.is() )
    1798         378 :                         xSupp->setActiveFrame( uno::Reference < frame::XFrame >() );
    1799             : 
    1800         378 :                     css::uno::Reference< css::awt::XWindow > xContainerWindow = xFrame->getContainerWindow();
    1801         378 :                     Window* pWindow = VCLUnoHelper::GetWindow(xContainerWindow);
    1802         378 :                     if (pWindow && pWindow->HasChildPathFocus() && bGrabFocus)
    1803             :                     {
    1804         142 :                         SfxInPlaceClient *pCli = GetViewShell()->GetUIActiveClient();
    1805         247 :                         if ( ( !pCli || !pCli->IsObjectUIActive() ) &&
    1806         105 :                             ( !pCurrent || pCurrent->GetParentViewFrame_Impl() != this ) )
    1807         142 :                                 GetFrame().GrabFocusOnComponent_Impl();
    1808         378 :                     }
    1809             :                 }
    1810             :                 else
    1811             :                 {
    1812           0 :                     GetBindings().SetDispatcher( GetDispatcher() );
    1813           0 :                     GetBindings().SetActiveFrame( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > () );
    1814           0 :                     GetDispatcher()->Update_Impl( sal_False );
    1815         378 :                 }
    1816             :             }
    1817             :         }
    1818             :     }
    1819         520 : }
    1820             : 
    1821             : //-------------------------------------------------------------------------
    1822             : 
    1823           0 : void SfxViewFrame::SetQuietMode_Impl( sal_Bool bOn )
    1824             : {
    1825           0 :     GetDispatcher()->SetQuietMode_Impl( bOn );
    1826           0 : }
    1827             : 
    1828             : //-------------------------------------------------------------------------
    1829             : 
    1830      233242 : SfxObjectShell* SfxViewFrame::GetObjectShell()
    1831             : {
    1832      233242 :     return xObjSh;
    1833             : }
    1834             : 
    1835         240 : const Size& SfxViewFrame::GetMargin_Impl() const
    1836             : {
    1837         240 :     return pImp->aMargin;
    1838             : }
    1839             : 
    1840           0 : void SfxViewFrame::SetActiveChildFrame_Impl( SfxViewFrame *pViewFrame )
    1841             : {
    1842           0 :     if ( pViewFrame != pImp->pActiveChild )
    1843             :     {
    1844           0 :         pImp->pActiveChild = pViewFrame;
    1845             : 
    1846           0 :         Reference< XFramesSupplier > xFrame( GetFrame().GetFrameInterface(), UNO_QUERY );
    1847           0 :         Reference< XFrame >  xActive;
    1848           0 :         if ( pViewFrame )
    1849           0 :             xActive = pViewFrame->GetFrame().GetFrameInterface();
    1850             : 
    1851           0 :         if ( xFrame.is() )      // xFrame can be NULL
    1852           0 :             xFrame->setActiveFrame( xActive );
    1853             :     }
    1854           0 : }
    1855             : 
    1856           0 : SfxViewFrame* SfxViewFrame::GetActiveChildFrame_Impl() const
    1857             : {
    1858           0 :     SfxViewFrame *pViewFrame = pImp->pActiveChild;
    1859           0 :     return pViewFrame;
    1860             : }
    1861             : 
    1862             : //--------------------------------------------------------------------
    1863           4 : SfxViewFrame* SfxViewFrame::LoadViewIntoFrame_Impl_NoThrow( const SfxObjectShell& i_rDoc, const Reference< XFrame >& i_rFrame,
    1864             :                                                    const sal_uInt16 i_nViewId, const bool i_bHidden )
    1865             : {
    1866           4 :     Reference< XFrame > xFrame( i_rFrame );
    1867           4 :     bool bOwnFrame = false;
    1868           4 :     SfxViewShell* pSuccessView = NULL;
    1869             :     try
    1870             :     {
    1871           4 :         if ( !xFrame.is() )
    1872             :         {
    1873           4 :             Reference < XDesktop2 > xDesktop = Desktop::create( ::comphelper::getProcessComponentContext() );
    1874             : 
    1875           4 :             if ( !i_bHidden )
    1876             :             {
    1877             :                 try
    1878             :                 {
    1879             :                     // if there is a backing component, use it
    1880           0 :                     Reference< XFramesSupplier > xTaskSupplier( xDesktop , css::uno::UNO_QUERY_THROW );
    1881           0 :                     ::framework::FrameListAnalyzer aAnalyzer( xTaskSupplier, Reference< XFrame >(), ::framework::FrameListAnalyzer::E_BACKINGCOMPONENT );
    1882             : 
    1883           0 :                     if ( aAnalyzer.m_xBackingComponent.is() )
    1884           0 :                         xFrame = aAnalyzer.m_xBackingComponent;
    1885             :                 }
    1886           0 :                 catch( uno::Exception& )
    1887             :                 {}
    1888             :             }
    1889             : 
    1890           4 :             if ( !xFrame.is() )
    1891           4 :                 xFrame.set( xDesktop->findFrame( DEFINE_CONST_UNICODE("_blank"), 0 ), UNO_SET_THROW );
    1892             : 
    1893           4 :             bOwnFrame = true;
    1894             :         }
    1895             : 
    1896             :         pSuccessView = LoadViewIntoFrame_Impl(
    1897             :             i_rDoc,
    1898             :             xFrame,
    1899             :             Sequence< PropertyValue >(),    // means "reuse existing model's args"
    1900             :             i_nViewId,
    1901             :             i_bHidden
    1902           4 :         );
    1903             : 
    1904           4 :         if ( bOwnFrame && !i_bHidden )
    1905             :         {
    1906             :             // ensure the frame/window is visible
    1907           0 :             Reference< XWindow > xContainerWindow( xFrame->getContainerWindow(), UNO_SET_THROW );
    1908           0 :             xContainerWindow->setVisible( sal_True );
    1909             :         }
    1910             :     }
    1911           0 :     catch( const Exception& )
    1912             :     {
    1913             :         DBG_UNHANDLED_EXCEPTION();
    1914             :     }
    1915             : 
    1916           4 :     if ( pSuccessView )
    1917           4 :         return pSuccessView->GetViewFrame();
    1918             : 
    1919           0 :     if ( bOwnFrame )
    1920             :     {
    1921             :         try
    1922             :         {
    1923           0 :             xFrame->dispose();
    1924             :         }
    1925           0 :         catch( const Exception& )
    1926             :         {
    1927             :             DBG_UNHANDLED_EXCEPTION();
    1928             :         }
    1929             :     }
    1930             : 
    1931           0 :     return NULL;
    1932             : }
    1933             : 
    1934             : //--------------------------------------------------------------------
    1935           4 : SfxViewShell* SfxViewFrame::LoadViewIntoFrame_Impl( const SfxObjectShell& i_rDoc, const Reference< XFrame >& i_rFrame,
    1936             :                                            const Sequence< PropertyValue >& i_rLoadArgs, const sal_uInt16 i_nViewId,
    1937             :                                            const bool i_bHidden )
    1938             : {
    1939           4 :     Reference< XModel > xDocument( i_rDoc.GetModel(), UNO_SET_THROW );
    1940             : 
    1941           4 :     ::comphelper::NamedValueCollection aTransformLoadArgs( i_rLoadArgs.getLength() ? i_rLoadArgs : xDocument->getArgs() );
    1942           4 :     aTransformLoadArgs.put( "Model", xDocument );
    1943           4 :     if ( i_nViewId )
    1944           0 :         aTransformLoadArgs.put( "ViewId", sal_Int16( i_nViewId ) );
    1945           4 :     if ( i_bHidden )
    1946           4 :         aTransformLoadArgs.put( "Hidden", i_bHidden );
    1947             :     else
    1948           0 :         aTransformLoadArgs.remove( "Hidden" );
    1949             : 
    1950           4 :     ::rtl::OUString sURL( "private:object"  );
    1951           4 :     if ( sURL.isEmpty() )
    1952           0 :         sURL = i_rDoc.GetFactory().GetFactoryURL();
    1953             : 
    1954           4 :     Reference< XComponentLoader > xLoader( i_rFrame, UNO_QUERY_THROW );
    1955           4 :     xLoader->loadComponentFromURL( sURL, ::rtl::OUString("_self"), 0,
    1956           4 :         aTransformLoadArgs.getPropertyValues() );
    1957             : 
    1958           4 :     SfxViewShell* pViewShell = SfxViewShell::Get( i_rFrame->getController() );
    1959           4 :     ENSURE_OR_THROW( pViewShell,
    1960             :         "SfxViewFrame::LoadViewIntoFrame_Impl: loading an SFX doc into a frame resulted in a non-SFX view - quite impossible" );
    1961           4 :     return pViewShell;
    1962             : }
    1963             : 
    1964             : //--------------------------------------------------------------------
    1965             : 
    1966           4 : SfxViewFrame* SfxViewFrame::LoadHiddenDocument( SfxObjectShell& i_rDoc, const sal_uInt16 i_nViewId )
    1967             : {
    1968           4 :     return LoadViewIntoFrame_Impl_NoThrow( i_rDoc, Reference< XFrame >(), i_nViewId, true );
    1969             : }
    1970             : 
    1971             : //--------------------------------------------------------------------
    1972             : 
    1973           0 : SfxViewFrame* SfxViewFrame::LoadDocument( SfxObjectShell& i_rDoc, const sal_uInt16 i_nViewId )
    1974             : {
    1975           0 :     return LoadViewIntoFrame_Impl_NoThrow( i_rDoc, Reference< XFrame >(), i_nViewId, false );
    1976             : }
    1977             : 
    1978             : //--------------------------------------------------------------------
    1979             : 
    1980           0 : SfxViewFrame* SfxViewFrame::LoadDocumentIntoFrame( SfxObjectShell& i_rDoc, const Reference< XFrame >& i_rTargetFrame, const sal_uInt16 i_nViewId )
    1981             : {
    1982           0 :     return LoadViewIntoFrame_Impl_NoThrow( i_rDoc, i_rTargetFrame, i_nViewId, false );
    1983             : }
    1984             : 
    1985             : //--------------------------------------------------------------------
    1986             : 
    1987           0 : SfxViewFrame* SfxViewFrame::LoadDocumentIntoFrame( SfxObjectShell& i_rDoc, const SfxFrameItem* i_pFrameItem, const sal_uInt16 i_nViewId )
    1988             : {
    1989           0 :     return LoadViewIntoFrame_Impl_NoThrow( i_rDoc, i_pFrameItem && i_pFrameItem->GetFrame() ? i_pFrameItem->GetFrame()->GetFrameInterface() : NULL, i_nViewId, false );
    1990             : }
    1991             : 
    1992             : //--------------------------------------------------------------------
    1993           0 : SfxViewFrame* SfxViewFrame::DisplayNewDocument( SfxObjectShell& i_rDoc, const SfxRequest& i_rCreateDocRequest, const sal_uInt16 i_nViewId )
    1994             : {
    1995           0 :     SFX_REQUEST_ARG( i_rCreateDocRequest, pFrameItem, SfxUnoFrameItem, SID_FILLFRAME, sal_False );
    1996           0 :     SFX_REQUEST_ARG( i_rCreateDocRequest, pHiddenItem, SfxBoolItem, SID_HIDDEN, sal_False );
    1997             : 
    1998             :     return LoadViewIntoFrame_Impl_NoThrow(
    1999             :         i_rDoc,
    2000           0 :         pFrameItem ? pFrameItem->GetFrame() : NULL,
    2001             :         i_nViewId,
    2002           0 :         pHiddenItem ? pHiddenItem->GetValue() : false
    2003           0 :     );
    2004             : }
    2005             : 
    2006             : //--------------------------------------------------------------------
    2007             : 
    2008         240 : SfxViewFrame* SfxViewFrame::Get( const Reference< XController>& i_rController, const SfxObjectShell* i_pDoc )
    2009             : {
    2010         240 :     if ( !i_rController.is() )
    2011           0 :         return NULL;
    2012             : 
    2013         240 :     const SfxObjectShell* pDoc = i_pDoc;
    2014         240 :     if ( !pDoc )
    2015             :     {
    2016           0 :         Reference< XModel > xDocument( i_rController->getModel() );
    2017           0 :         for (   pDoc = SfxObjectShell::GetFirst( 0, false );
    2018             :                 pDoc;
    2019             :                 pDoc = SfxObjectShell::GetNext( *pDoc, 0, false )
    2020             :             )
    2021             :         {
    2022           0 :             if ( pDoc->GetModel() == xDocument )
    2023           0 :                 break;
    2024           0 :         }
    2025             :     }
    2026             : 
    2027         240 :     SfxViewFrame* pViewFrame = NULL;
    2028         240 :     for (   pViewFrame = SfxViewFrame::GetFirst( pDoc, sal_False );
    2029             :             pViewFrame;
    2030             :             pViewFrame = SfxViewFrame::GetNext( *pViewFrame, pDoc, sal_False )
    2031             :         )
    2032             :     {
    2033         240 :         if ( pViewFrame->GetViewShell()->GetController() == i_rController )
    2034         240 :             break;
    2035             :     }
    2036             : 
    2037         240 :     return pViewFrame;
    2038             : }
    2039             : 
    2040             : //--------------------------------------------------------------------
    2041             : 
    2042           0 : void SfxViewFrame::SaveCurrentViewData_Impl( const sal_uInt16 i_nNewViewId )
    2043             : {
    2044           0 :     SfxViewShell* pCurrentShell = GetViewShell();
    2045           0 :     ENSURE_OR_RETURN_VOID( pCurrentShell != NULL, "SfxViewFrame::SaveCurrentViewData_Impl: no current view shell -> no current view data!" );
    2046             : 
    2047             :     // determine the logical (API) view name
    2048           0 :     const SfxObjectFactory& rDocFactory( pCurrentShell->GetObjectShell()->GetFactory() );
    2049           0 :     const sal_uInt16 nCurViewNo = rDocFactory.GetViewNo_Impl( GetCurViewId(), 0 );
    2050           0 :     const String sCurrentViewName = rDocFactory.GetViewFactory( nCurViewNo ).GetAPIViewName();
    2051           0 :     const sal_uInt16 nNewViewNo = rDocFactory.GetViewNo_Impl( i_nNewViewId, 0 );
    2052           0 :     const String sNewViewName = rDocFactory.GetViewFactory( nNewViewNo ).GetAPIViewName();
    2053           0 :     if ( ( sCurrentViewName.Len() == 0 ) || ( sNewViewName.Len() == 0 ) )
    2054             :     {
    2055             :         // can't say anything about the view, the respective application did not yet migrate its code to
    2056             :         // named view factories => bail out
    2057             :         OSL_FAIL( "SfxViewFrame::SaveCurrentViewData_Impl: views without API names? Shouldn't happen anymore?" );
    2058             :         return;
    2059             :     }
    2060             :     OSL_ENSURE( !sNewViewName.Equals( sCurrentViewName ), "SfxViewFrame::SaveCurrentViewData_Impl: suspicious: new and old view name are identical!" );
    2061             : 
    2062             :     // save the view data only when we're moving from a non-print-preview to the print-preview view
    2063           0 :     if ( !sNewViewName.EqualsAscii( "PrintPreview" ) )
    2064             :         return;
    2065             : 
    2066             :     // retrieve the view data from the view
    2067           0 :     Sequence< PropertyValue > aViewData;
    2068           0 :     pCurrentShell->WriteUserDataSequence( aViewData );
    2069             : 
    2070             :     try
    2071             :     {
    2072             :         // retrieve view data (for *all* views) from the model
    2073           0 :         const Reference< XController > xController( pCurrentShell->GetController(), UNO_SET_THROW );
    2074           0 :         const Reference< XViewDataSupplier > xViewDataSupplier( xController->getModel(), UNO_QUERY_THROW );
    2075           0 :         const Reference< XIndexContainer > xViewData( xViewDataSupplier->getViewData(), UNO_QUERY_THROW );
    2076             : 
    2077             :         // look up the one view data item which corresponds to our current view, and remove it
    2078           0 :         const sal_Int32 nCount = xViewData->getCount();
    2079           0 :         for ( sal_Int32 i=0; i<nCount; ++i )
    2080             :         {
    2081           0 :             const ::comphelper::NamedValueCollection aCurViewData( xViewData->getByIndex(i) );
    2082           0 :             ::rtl::OUString sViewId( aCurViewData.getOrDefault( "ViewId", ::rtl::OUString() ) );
    2083           0 :             if ( sViewId.isEmpty() )
    2084           0 :                 continue;
    2085             : 
    2086           0 :             const SfxViewFactory* pViewFactory = rDocFactory.GetViewFactoryByViewName( sViewId );
    2087           0 :             if ( pViewFactory == NULL )
    2088           0 :                 continue;
    2089             : 
    2090           0 :             if ( pViewFactory->GetOrdinal() == GetCurViewId() )
    2091             :             {
    2092           0 :                 xViewData->removeByIndex(i);
    2093             :                 break;
    2094             :             }
    2095           0 :         }
    2096             : 
    2097             :         // then replace it with the most recent view data we just obtained
    2098           0 :         xViewData->insertByIndex( 0, makeAny( aViewData ) );
    2099             :     }
    2100           0 :     catch( const Exception& )
    2101             :     {
    2102             :         DBG_UNHANDLED_EXCEPTION();
    2103           0 :     }
    2104             : }
    2105             : 
    2106             : //--------------------------------------------------------------------
    2107             : 
    2108           0 : sal_Bool SfxViewFrame::SwitchToViewShell_Impl
    2109             : (
    2110             :     sal_uInt16  nViewIdOrNo,    /*  > 0
    2111             :                                 Registration-Id of the View, to which the
    2112             :                                 the method should switch, for example the one
    2113             :                                 that will be created.
    2114             : 
    2115             :                                 == 0
    2116             :                                 First use the Default view. */
    2117             : 
    2118             :     sal_Bool    bIsIndex        /*  sal_True
    2119             :                                 'nViewIdOrNo' is no Registration-Id instead
    2120             :                                 an Index of <SfxViewFrame> in <SfxObjectShell>.
    2121             :                                 */
    2122             : )
    2123             : 
    2124             : /*  [Description]
    2125             : 
    2126             :     Internal Method for switching to another <SfxViewShell> subclass,
    2127             :     which should be created in this SfxMDIFrame. If no SfxViewShell exist
    2128             :     in this SfxMDIFrame, then one will first be created.
    2129             : 
    2130             : 
    2131             :     [Return Value]
    2132             : 
    2133             :     sal_Bool                        sal_True
    2134             :                                 requested SfxViewShell was created and a
    2135             :                                 possibly existing one deleted
    2136             : 
    2137             :                                 sal_False
    2138             :                                 SfxViewShell requested could not be created,
    2139             :                                 the existing SfxViewShell thus continue to exist
    2140             : */
    2141             : 
    2142             : {
    2143             :     try
    2144             :     {
    2145           0 :         ENSURE_OR_THROW( GetObjectShell() != NULL, "not possible without a document" );
    2146             : 
    2147             :         // if we already have a view shell, remove it
    2148           0 :         SfxViewShell* pOldSh = GetViewShell();
    2149             :         OSL_PRECOND( pOldSh, "SfxViewFrame::SwitchToViewShell_Impl: that's called *switch* (not for *initial-load*) for a reason" );
    2150           0 :         if ( pOldSh )
    2151             :         {
    2152             :             // ask whether it can be closed
    2153           0 :             if ( !pOldSh->PrepareClose( sal_True ) )
    2154           0 :                 return sal_False;
    2155             : 
    2156             :             // remove sub shells from Dispatcher before switching to new ViewShell
    2157           0 :             PopShellAndSubShells_Impl( *pOldSh );
    2158             :         }
    2159             : 
    2160           0 :         GetBindings().ENTERREGISTRATIONS();
    2161           0 :         LockAdjustPosSizePixel();
    2162             : 
    2163             :         // ID of the new view
    2164           0 :         SfxObjectFactory& rDocFact = GetObjectShell()->GetFactory();
    2165           0 :         const sal_uInt16 nViewId = ( bIsIndex || !nViewIdOrNo ) ? rDocFact.GetViewFactory( nViewIdOrNo ).GetOrdinal() : nViewIdOrNo;
    2166             : 
    2167             :         // save the view data of the old view, so it can be restored later on (when needed)
    2168           0 :         SaveCurrentViewData_Impl( nViewId );
    2169             : 
    2170             :         // create and load new ViewShell
    2171             :         SfxViewShell* pNewSh = LoadViewIntoFrame_Impl(
    2172           0 :             *GetObjectShell(),
    2173           0 :             GetFrame().GetFrameInterface(),
    2174             :             Sequence< PropertyValue >(),    // means "reuse existing model's args"
    2175             :             nViewId,
    2176             :             false
    2177           0 :         );
    2178             : 
    2179             :         // allow resize events to be processed
    2180           0 :         UnlockAdjustPosSizePixel();
    2181             : 
    2182           0 :         if ( GetWindow().IsReallyVisible() )
    2183           0 :             DoAdjustPosSizePixel( pNewSh, Point(), GetWindow().GetOutputSizePixel() );
    2184             : 
    2185           0 :         GetBindings().LEAVEREGISTRATIONS();
    2186           0 :         delete pOldSh;
    2187             :     }
    2188           0 :     catch ( const com::sun::star::uno::Exception& )
    2189             :     {
    2190             :         // the SfxCode is not able to cope with exceptions thrown while creating views
    2191             :         // the code will crash in the stack unwinding procedure, so we shouldn't let exceptions go through here
    2192             :         DBG_UNHANDLED_EXCEPTION();
    2193           0 :         return sal_False;
    2194             :     }
    2195             : 
    2196             :     DBG_ASSERT( SFX_APP()->GetViewFrames_Impl().size() == SFX_APP()->GetViewShells_Impl().size(), "Inconsistent view arrays!" );
    2197           0 :     return sal_True;
    2198             : }
    2199             : 
    2200             : //-------------------------------------------------------------------------
    2201         240 : void SfxViewFrame::SetCurViewId_Impl( const sal_uInt16 i_nID )
    2202             : {
    2203         240 :     pImp->nCurViewId = i_nID;
    2204         240 : }
    2205             : 
    2206             : //-------------------------------------------------------------------------
    2207         468 : sal_uInt16 SfxViewFrame::GetCurViewId() const
    2208             : {
    2209         468 :     return pImp->nCurViewId;
    2210             : }
    2211             : 
    2212             : //-------------------------------------------------------------------------
    2213           0 : void SfxViewFrame::ExecView_Impl
    2214             : (
    2215             :     SfxRequest& rReq        // The executable <SfxRequest>
    2216             : )
    2217             : 
    2218             : /*  [Description]
    2219             : 
    2220             :     Internal method to run the slot for the <SfxShell> Subclass in the
    2221             :     SfxViewFrame <SVIDL> described slots.
    2222             : */
    2223             : 
    2224             : {
    2225             :     DBG_CHKTHIS(SfxViewFrame, 0);
    2226             : 
    2227             :     // If the Shells are just being replaced...
    2228           0 :     if ( !GetObjectShell() || !GetViewShell() )
    2229           0 :         return;
    2230             : 
    2231           0 :     switch ( rReq.GetSlot() )
    2232             :     {
    2233             :         case SID_TERMINATE_INPLACEACTIVATION :
    2234             :         {
    2235           0 :             SfxInPlaceClient* pClient = GetViewShell()->GetUIActiveClient();
    2236           0 :             if ( pClient )
    2237           0 :                 pClient->DeactivateObject();
    2238           0 :             break;
    2239             :         }
    2240             : 
    2241             :         case SID_VIEWSHELL:
    2242             :         {
    2243           0 :             const SfxPoolItem *pItem = 0;
    2244           0 :             if  (   rReq.GetArgs()
    2245           0 :                 &&  SFX_ITEM_SET == rReq.GetArgs()->GetItemState( SID_VIEWSHELL, sal_False, &pItem )
    2246             :                 )
    2247             :             {
    2248           0 :                 const sal_uInt16 nViewId = static_cast< const SfxUInt16Item* >( pItem )->GetValue();
    2249           0 :                 sal_Bool bSuccess = SwitchToViewShell_Impl( nViewId );
    2250           0 :                 rReq.SetReturnValue( SfxBoolItem( 0, bSuccess ) );
    2251             :             }
    2252             :             break;
    2253             :         }
    2254             : 
    2255             :         case SID_VIEWSHELL0:
    2256             :         case SID_VIEWSHELL1:
    2257             :         case SID_VIEWSHELL2:
    2258             :         case SID_VIEWSHELL3:
    2259             :         case SID_VIEWSHELL4:
    2260             :         {
    2261           0 :             const sal_uInt16 nViewNo = rReq.GetSlot() - SID_VIEWSHELL0;
    2262           0 :             sal_Bool bSuccess = SwitchToViewShell_Impl( nViewNo, sal_True );
    2263           0 :             rReq.SetReturnValue( SfxBoolItem( 0, bSuccess ) );
    2264           0 :             break;
    2265             :         }
    2266             : 
    2267             :         case SID_NEWWINDOW:
    2268             :         {
    2269             :             // Hack. at the moment a virtual Function
    2270           0 :             if ( !GetViewShell()->NewWindowAllowed() )
    2271             :             {
    2272             :                 OSL_FAIL( "You should have disabled the 'Window/New Window' slot!" );
    2273             :                 return;
    2274             :             }
    2275             : 
    2276             :             // Get ViewData of FrameSets recursivly.
    2277           0 :             GetFrame().GetViewData_Impl();
    2278           0 :             SfxMedium* pMed = GetObjectShell()->GetMedium();
    2279             : 
    2280             :             // do not open the new window hidden
    2281           0 :             pMed->GetItemSet()->ClearItem( SID_HIDDEN );
    2282             : 
    2283             :             // the view ID (optional arg. TODO: this is currently not supported in the slot definition ...)
    2284           0 :             SFX_REQUEST_ARG( rReq, pViewIdItem, SfxUInt16Item, SID_VIEW_ID, sal_False );
    2285           0 :             const sal_uInt16 nViewId = pViewIdItem ? pViewIdItem->GetValue() : GetCurViewId();
    2286             : 
    2287           0 :             Reference < XFrame > xFrame;
    2288             :             // the frame (optional arg. TODO: this is currently not supported in the slot definition ...)
    2289           0 :             SFX_REQUEST_ARG( rReq, pFrameItem, SfxUnoFrameItem, SID_FILLFRAME, sal_False );
    2290           0 :             if ( pFrameItem )
    2291           0 :                 xFrame = pFrameItem->GetFrame();
    2292             : 
    2293           0 :             LoadViewIntoFrame_Impl_NoThrow( *GetObjectShell(), xFrame, nViewId, false );
    2294             : 
    2295           0 :             rReq.Done();
    2296           0 :             break;
    2297             :         }
    2298             : 
    2299             :         case SID_OBJECT:
    2300             :         {
    2301           0 :             SFX_REQUEST_ARG( rReq, pItem, SfxUInt16Item, SID_OBJECT, sal_False );
    2302             : 
    2303           0 :             SfxViewShell *pViewShell = GetViewShell();
    2304           0 :             if ( pViewShell && pItem )
    2305             :             {
    2306           0 :                 pViewShell->DoVerb( pItem->GetValue() );
    2307           0 :                 rReq.Done();
    2308           0 :                 break;;
    2309             :             }
    2310             :         }
    2311             :     }
    2312             : }
    2313             : 
    2314             : //-------------------------------------------------------------------------
    2315             : /* TODO as96863:
    2316             :         This method try to collect informations about the count of currently open documents.
    2317             :         But the algorithm is implemented very simple ...
    2318             :         E.g. hidden documents should be ignored here ... but they are counted.
    2319             :         TODO: export special helper "framework::FrameListAnalyzer" within the framework module
    2320             :         and use it here.
    2321             : */
    2322           0 : sal_Bool impl_maxOpenDocCountReached()
    2323             : {
    2324             :     try
    2325             :     {
    2326           0 :         css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
    2327             :         css::uno::Any aVal = ::comphelper::ConfigurationHelper::readDirectKey(
    2328             :                                 xContext,
    2329             :                                 ::rtl::OUString("org.openoffice.Office.Common/"),
    2330             :                                 ::rtl::OUString("Misc"),
    2331             :                                 ::rtl::OUString("MaxOpenDocuments"),
    2332           0 :                                 ::comphelper::ConfigurationHelper::E_READONLY);
    2333             : 
    2334             :         // NIL means: count of allowed documents = infinite !
    2335           0 :         if ( ! aVal.hasValue())
    2336           0 :             return sal_False;
    2337             : 
    2338           0 :         sal_Int32 nOpenDocs = 0;
    2339           0 :         sal_Int32 nMaxDocs  = 0;
    2340           0 :         aVal >>= nMaxDocs;
    2341             : 
    2342           0 :         css::uno::Reference< css::frame::XDesktop2 >  xDesktop = css::frame::Desktop::create(xContext);
    2343           0 :         css::uno::Reference< css::container::XIndexAccess > xCont   (xDesktop->getFrames()                 , css::uno::UNO_QUERY_THROW);
    2344             : 
    2345           0 :         sal_Int32 c = xCont->getCount();
    2346           0 :         sal_Int32 i = 0;
    2347             : 
    2348           0 :         for (i=0; i<c; ++i)
    2349             :         {
    2350             :             try
    2351             :             {
    2352           0 :                 css::uno::Reference< css::frame::XFrame > xFrame;
    2353           0 :                 xCont->getByIndex(i) >>= xFrame;
    2354           0 :                 if ( ! xFrame.is())
    2355           0 :                     continue;
    2356             : 
    2357             :                 // a) do not count the help window
    2358           0 :                 if ( xFrame->getName() == "OFFICE_HELP_TASK" )
    2359           0 :                     continue;
    2360             : 
    2361             :                 // b) count all other frames
    2362           0 :                 ++nOpenDocs;
    2363             :             }
    2364           0 :             catch(const css::uno::Exception&)
    2365             :                 // A IndexOutOfBoundException can happen in multithreaded
    2366             :                 // environments, where any other thread can change this
    2367             :                 // container !
    2368           0 :                 { continue; }
    2369             :         }
    2370             : 
    2371           0 :         return (nOpenDocs >= nMaxDocs);
    2372             :     }
    2373           0 :     catch(const css::uno::Exception&)
    2374             :         {}
    2375             : 
    2376             :     // Any internal error is no reason to stop opening documents !
    2377             :     // Limitation of opening documents is a special "nice to  have" feature.
    2378             :     // Otherwhise it can happen, that NO document will be opened ...
    2379           0 :     return sal_False;
    2380             : }
    2381             : 
    2382             : //-------------------------------------------------------------------------
    2383           0 : void SfxViewFrame::StateView_Impl
    2384             : (
    2385             :     SfxItemSet&     rSet            /*  empty <SfxItemSet> with <Which-Ranges>,
    2386             :                                         which describes the Slot Ids */
    2387             : )
    2388             : 
    2389             : /*  [Description]
    2390             : 
    2391             :     This internal methode returns in 'rSet' the Status for the  <SfxShell>
    2392             :     Subclass SfxViewFrame in the <SVIDL> described <Slots>.
    2393             : 
    2394             :     Thus exactly those Slots-IDs that are recognized as beeing invalid by Sfx
    2395             :     are included as Which-ranges in 'rSet'. If there exists a mapping for
    2396             :     single slot-IDs of the <SfxItemPool> set in the shell, then the respective
    2397             :     Which-IDs are used so that items can be replaced directly with a working
    2398             :     Core::sun::com::star::script::Engine of the Which-IDs if possible. .
    2399             : */
    2400             : 
    2401             : {
    2402             :     DBG_CHKTHIS(SfxViewFrame, 0);
    2403             : 
    2404           0 :     SfxObjectShell *pDocSh = GetObjectShell();
    2405             : 
    2406           0 :     if ( !pDocSh )
    2407             :         // I'm just on reload and am yielding myself ...
    2408           0 :         return;
    2409             : 
    2410           0 :     const sal_uInt16 *pRanges = rSet.GetRanges();
    2411             :     DBG_ASSERT(pRanges, "Set with no Range");
    2412           0 :     while ( *pRanges )
    2413             :     {
    2414           0 :         for ( sal_uInt16 nWhich = *pRanges++; nWhich <= *pRanges; ++nWhich )
    2415             :         {
    2416           0 :             switch(nWhich)
    2417             :             {
    2418             :                 case SID_VIEWSHELL:
    2419             :                 {
    2420           0 :                     rSet.Put( SfxUInt16Item( nWhich, pImp->nCurViewId ) );
    2421           0 :                     break;
    2422             :                 }
    2423             : 
    2424             :                 case SID_VIEWSHELL0:
    2425             :                 case SID_VIEWSHELL1:
    2426             :                 case SID_VIEWSHELL2:
    2427             :                 case SID_VIEWSHELL3:
    2428             :                 case SID_VIEWSHELL4:
    2429             :                 {
    2430           0 :                     sal_uInt16 nViewNo = nWhich - SID_VIEWSHELL0;
    2431           0 :                     if ( GetObjectShell()->GetFactory().GetViewFactoryCount() >
    2432           0 :                          nViewNo && !GetObjectShell()->IsInPlaceActive() )
    2433             :                     {
    2434             :                         SfxViewFactory &rViewFactory =
    2435           0 :                             GetObjectShell()->GetFactory().GetViewFactory(nViewNo);
    2436             :                         rSet.Put( SfxBoolItem(
    2437           0 :                             nWhich, pImp->nCurViewId == rViewFactory.GetOrdinal() ) );
    2438             :                     }
    2439             :                     else
    2440           0 :                         rSet.DisableItem( nWhich );
    2441           0 :                     break;
    2442             :                 }
    2443             : 
    2444             :                 case SID_NEWWINDOW:
    2445             :                 {
    2446           0 :                     if  (   !GetViewShell()->NewWindowAllowed()
    2447           0 :                         ||  impl_maxOpenDocCountReached()
    2448             :                         )
    2449           0 :                         rSet.DisableItem( nWhich );
    2450           0 :                     break;
    2451             :                 }
    2452             :             }
    2453             :         }
    2454             :     }
    2455             : }
    2456             : 
    2457             : //-------------------------------------------------------------------------
    2458           0 : void SfxViewFrame::ToTop()
    2459             : {
    2460           0 :     GetFrame().Appear();
    2461           0 : }
    2462             : 
    2463             : //-------------------------------------------------------------------------
    2464        1334 : SfxViewFrame* SfxViewFrame::GetParentViewFrame() const
    2465             : /*  [Description]
    2466             : 
    2467             :     The ParentViewFrame is the ViewFrame of the ParentFrames.
    2468             : */
    2469             : {
    2470        1334 :     SfxFrame *pFrame = GetFrame().GetParentFrame();
    2471        1334 :     return pFrame ? pFrame->GetCurrentViewFrame() : NULL;
    2472             : }
    2473             : 
    2474             : //-------------------------------------------------------------------------
    2475       23952 : SfxFrame& SfxViewFrame::GetFrame() const
    2476             : /*  [Description]
    2477             : 
    2478             :     GetFrame returns the Frame, in which the ViewFrame is located.
    2479             : */
    2480             : {
    2481       23952 :     return pImp->rFrame;
    2482             : }
    2483             : 
    2484             : //-------------------------------------------------------------------------
    2485        1424 : SfxViewFrame* SfxViewFrame::GetTopViewFrame() const
    2486             : {
    2487        1424 :     return GetFrame().GetTopFrame().GetCurrentViewFrame();
    2488             : }
    2489             : 
    2490        6615 : Window& SfxViewFrame::GetWindow() const
    2491             : {
    2492        6615 :     return pImp->pWindow ? *pImp->pWindow : GetFrame().GetWindow();
    2493             : }
    2494             : 
    2495           0 : sal_Bool SfxViewFrame::DoClose()
    2496             : {
    2497           0 :     return GetFrame().DoClose();
    2498             : }
    2499             : 
    2500           0 : String SfxViewFrame::GetActualPresentationURL_Impl() const
    2501             : {
    2502           0 :     if ( xObjSh.Is() )
    2503           0 :         return xObjSh->GetMedium()->GetName();
    2504           0 :     return String();
    2505             : }
    2506             : 
    2507           0 : void SfxViewFrame::SetModalMode( sal_Bool bModal )
    2508             : {
    2509           0 :     pImp->bModal = bModal;
    2510           0 :     if ( xObjSh.Is() )
    2511             :     {
    2512           0 :         for ( SfxViewFrame* pFrame = SfxViewFrame::GetFirst( xObjSh );
    2513           0 :               !bModal && pFrame; pFrame = SfxViewFrame::GetNext( *pFrame, xObjSh ) )
    2514           0 :             bModal = pFrame->pImp->bModal;
    2515           0 :         xObjSh->SetModalMode_Impl( bModal );
    2516             :     }
    2517           0 : }
    2518             : 
    2519         126 : sal_Bool SfxViewFrame::IsInModalMode() const
    2520             : {
    2521         126 :     return pImp->bModal || GetFrame().GetWindow().IsInModalMode();
    2522             : }
    2523             : 
    2524         945 : void SfxViewFrame::Resize( sal_Bool bForce )
    2525             : {
    2526         945 :     Size aSize = GetWindow().GetOutputSizePixel();
    2527         945 :     if ( bForce || aSize != pImp->aSize )
    2528             :     {
    2529         709 :         pImp->aSize = aSize;
    2530         709 :         SfxViewShell *pShell = GetViewShell();
    2531         709 :         if ( pShell )
    2532             :         {
    2533         709 :             if ( GetFrame().IsInPlace() )
    2534             :             {
    2535           0 :                 Point aPoint = GetWindow().GetPosPixel();
    2536           0 :                 DoAdjustPosSizePixel( pShell, aPoint, aSize );
    2537             :             }
    2538             :             else
    2539             :             {
    2540         709 :                 DoAdjustPosSizePixel( pShell, Point(), aSize );
    2541             :             }
    2542             :         }
    2543             :     }
    2544         945 : }
    2545             : 
    2546             : #define LINE_SEP 0x0A
    2547             : 
    2548           0 : void CutLines( ::rtl::OUString& rStr, sal_Int32 nStartLine, sal_Int32 nLines, sal_Bool bEraseTrailingEmptyLines )
    2549             : {
    2550           0 :     sal_Int32 nStartPos = 0;
    2551           0 :     sal_Int32 nLine = 0;
    2552           0 :     while ( nLine < nStartLine )
    2553             :     {
    2554           0 :         nStartPos = rStr.indexOf( LINE_SEP, nStartPos );
    2555           0 :         if( nStartPos == -1 )
    2556           0 :             break;
    2557           0 :         nStartPos++;    // not the \n.
    2558           0 :         nLine++;
    2559             :     }
    2560             : 
    2561             :     DBG_ASSERTWARNING( nStartPos != STRING_NOTFOUND, "CutLines: Start row not found!" );
    2562             : 
    2563           0 :     if ( nStartPos != -1 )
    2564             :     {
    2565           0 :         sal_Int32 nEndPos = nStartPos;
    2566           0 :         for ( sal_Int32 i = 0; i < nLines; i++ )
    2567           0 :             nEndPos = rStr.indexOf( LINE_SEP, nEndPos+1 );
    2568             : 
    2569           0 :         if ( nEndPos == -1 ) // Can happen at the last row.
    2570           0 :             nEndPos = rStr.getLength();
    2571             :         else
    2572           0 :             nEndPos++;
    2573             : 
    2574           0 :         ::rtl::OUString aEndStr = rStr.copy( nEndPos );
    2575           0 :         rStr = rStr.copy( 0, nStartPos );
    2576           0 :         rStr += aEndStr;
    2577             :     }
    2578           0 :     if ( bEraseTrailingEmptyLines )
    2579             :     {
    2580           0 :         sal_Int32 n = nStartPos;
    2581           0 :         sal_Int32 nLen = rStr.getLength();
    2582           0 :         while ( ( n < nLen ) && ( rStr.getStr()[ n ] == LINE_SEP ) )
    2583           0 :             n++;
    2584             : 
    2585           0 :         if ( n > nStartPos )
    2586             :         {
    2587           0 :             ::rtl::OUString aEndStr = rStr.copy( n );
    2588           0 :             rStr = rStr.copy( 0, nStartPos );
    2589           0 :             rStr += aEndStr;
    2590             :         }
    2591             :     }
    2592           0 : }
    2593             : 
    2594             : /*
    2595             :     add new recorded dispatch macro script into the application global basic
    2596             :     lib container. It generates a new unique id for it and insert the macro
    2597             :     by using this number as name for the modul
    2598             :  */
    2599           0 : void SfxViewFrame::AddDispatchMacroToBasic_Impl( const ::rtl::OUString& sMacro )
    2600             : {
    2601             : #ifdef DISABLE_SCRIPTING
    2602             :     (void) sMacro;
    2603             : #else
    2604           0 :     if ( sMacro.isEmpty() )
    2605             :         return;
    2606             : 
    2607           0 :     SfxApplication* pSfxApp = SFX_APP();
    2608           0 :     SfxRequest aReq( SID_BASICCHOOSER, SFX_CALLMODE_SYNCHRON, pSfxApp->GetPool() );
    2609           0 :     aReq.AppendItem( SfxBoolItem(SID_RECORDMACRO,sal_True) );
    2610           0 :     const SfxPoolItem* pRet = SFX_APP()->ExecuteSlot( aReq );
    2611           0 :     String aScriptURL;
    2612           0 :     if ( pRet )
    2613           0 :         aScriptURL = ((SfxStringItem*)pRet)->GetValue();
    2614           0 :     if ( aScriptURL.Len() )
    2615             :     {
    2616             :         // parse scriptURL
    2617           0 :         String aLibName;
    2618           0 :         String aModuleName;
    2619           0 :         String aMacroName;
    2620           0 :         String aLocation;
    2621           0 :         Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext();
    2622             :         Reference< com::sun::star::uri::XUriReferenceFactory > xFactory =
    2623           0 :             com::sun::star::uri::UriReferenceFactory::create( xContext );
    2624           0 :         Reference< com::sun::star::uri::XVndSunStarScriptUrl > xUrl( xFactory->parse( aScriptURL ), UNO_QUERY );
    2625           0 :         if ( xUrl.is() )
    2626             :         {
    2627             :             // get name
    2628           0 :             ::rtl::OUString aName = xUrl->getName();
    2629           0 :             sal_Unicode cTok = '.';
    2630           0 :             sal_Int32 nIndex = 0;
    2631           0 :             aLibName = aName.getToken( 0, cTok, nIndex );
    2632           0 :             if ( nIndex != -1 )
    2633           0 :                 aModuleName = aName.getToken( 0, cTok, nIndex );
    2634           0 :             if ( nIndex != -1 )
    2635           0 :                 aMacroName = aName.getToken( 0, cTok, nIndex );
    2636             : 
    2637             :             // get location
    2638           0 :             ::rtl::OUString aLocKey("location");
    2639           0 :             if ( xUrl->hasParameter( aLocKey ) )
    2640           0 :                 aLocation = xUrl->getParameter( aLocKey );
    2641             :         }
    2642             : 
    2643           0 :         BasicManager* pBasMgr = 0;
    2644           0 :         if ( aLocation.EqualsIgnoreCaseAscii( "application" ) )
    2645             :         {
    2646             :             // application basic
    2647           0 :             pBasMgr = pSfxApp->GetBasicManager();
    2648             :         }
    2649           0 :         else if ( aLocation.EqualsIgnoreCaseAscii( "document" ) )
    2650             :         {
    2651           0 :             pBasMgr = GetObjectShell()->GetBasicManager();
    2652             :         }
    2653             : 
    2654           0 :         ::rtl::OUString aOUSource;
    2655           0 :         if ( pBasMgr)
    2656             :         {
    2657           0 :             StarBASIC* pBasic = pBasMgr->GetLib( aLibName );
    2658           0 :             if ( pBasic )
    2659             :             {
    2660           0 :                 SbModule* pModule = pBasic->FindModule( aModuleName );
    2661           0 :                 if ( pModule )
    2662             :                 {
    2663           0 :                     SbMethod* pMethod = (SbMethod*)pModule->GetMethods()->Find( aMacroName, SbxCLASS_METHOD );
    2664           0 :                     aOUSource = pModule->GetSource32();
    2665             :                     sal_uInt16 nStart, nEnd;
    2666           0 :                     pMethod->GetLineRange( nStart, nEnd );
    2667           0 :                     sal_uIntPtr nlStart = nStart;
    2668           0 :                     sal_uIntPtr nlEnd = nEnd;
    2669           0 :                     CutLines( aOUSource, nlStart-1, nlEnd-nlStart+1, sal_True );
    2670             :                 }
    2671             :             }
    2672             :         }
    2673             : 
    2674             :         // open lib container and break operation if it couldn't be opened
    2675           0 :         com::sun::star::uno::Reference< com::sun::star::script::XLibraryContainer > xLibCont;
    2676           0 :         if ( aLocation.EqualsIgnoreCaseAscii( "application" ) )
    2677             :         {
    2678           0 :             xLibCont = SFX_APP()->GetBasicContainer();
    2679             :         }
    2680           0 :         else if ( aLocation.EqualsIgnoreCaseAscii( "document" ) )
    2681             :         {
    2682           0 :             xLibCont = GetObjectShell()->GetBasicContainer();
    2683             :         }
    2684             : 
    2685           0 :         if(!xLibCont.is())
    2686             :         {
    2687             :             SAL_WARN( "sfx2.view", "couldn't get access to the basic lib container. Adding of macro isn't possible." );
    2688             :             return;
    2689             :         }
    2690             : 
    2691             :         // get LibraryContainer
    2692           0 :         com::sun::star::uno::Any aTemp;
    2693             :         com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > xRoot(
    2694             :                 xLibCont,
    2695           0 :                 com::sun::star::uno::UNO_QUERY);
    2696             : 
    2697           0 :         ::rtl::OUString sLib( aLibName );
    2698           0 :         com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > xLib;
    2699           0 :         if(xRoot->hasByName(sLib))
    2700             :         {
    2701             :             // library must be loaded
    2702           0 :             aTemp = xRoot->getByName(sLib);
    2703           0 :             xLibCont->loadLibrary(sLib);
    2704           0 :             aTemp >>= xLib;
    2705             :         }
    2706             :         else
    2707             :         {
    2708             :             xLib = com::sun::star::uno::Reference< com::sun::star::container::XNameAccess >(
    2709           0 :                         xLibCont->createLibrary(sLib),
    2710           0 :                         com::sun::star::uno::UNO_QUERY);
    2711             :         }
    2712             : 
    2713             :         // pack the macro as direct usable "sub" routine
    2714           0 :         ::rtl::OUString sCode;
    2715           0 :         ::rtl::OUStringBuffer sRoutine(10000);
    2716           0 :         ::rtl::OUString sMacroName( aMacroName );
    2717           0 :         sal_Bool bReplace = sal_False;
    2718             : 
    2719             :         // get module
    2720           0 :         ::rtl::OUString sModule( aModuleName );
    2721           0 :         if(xLib->hasByName(sModule))
    2722             :         {
    2723           0 :             if ( !aOUSource.isEmpty() )
    2724             :             {
    2725           0 :                 sRoutine.append( aOUSource );
    2726             :             }
    2727             :             else
    2728             :             {
    2729           0 :                 aTemp = xLib->getByName(sModule);
    2730           0 :                 aTemp >>= sCode;
    2731           0 :                 sRoutine.append( sCode );
    2732             :             }
    2733             : 
    2734           0 :             bReplace = sal_True;
    2735             :         }
    2736             : 
    2737             :         // append new method
    2738           0 :         sRoutine.appendAscii(RTL_CONSTASCII_STRINGPARAM("\nsub "));
    2739           0 :         sRoutine.append(sMacroName);
    2740           0 :         sRoutine.appendAscii(RTL_CONSTASCII_STRINGPARAM("\n"));
    2741           0 :         sRoutine.append(sMacro);
    2742           0 :         sRoutine.appendAscii(RTL_CONSTASCII_STRINGPARAM("\nend sub\n"));
    2743             : 
    2744             :         // create the modul inside the library and insert the macro routine
    2745           0 :         aTemp <<= sRoutine.makeStringAndClear();
    2746           0 :         if ( bReplace )
    2747             :         {
    2748             :             com::sun::star::uno::Reference< com::sun::star::container::XNameContainer > xModulCont(
    2749             :                 xLib,
    2750           0 :                 com::sun::star::uno::UNO_QUERY);
    2751           0 :             xModulCont->replaceByName(sModule,aTemp);
    2752             :         }
    2753             :         else
    2754             :         {
    2755             :             com::sun::star::uno::Reference< com::sun::star::container::XNameContainer > xModulCont(
    2756             :                 xLib,
    2757           0 :                 com::sun::star::uno::UNO_QUERY);
    2758           0 :             xModulCont->insertByName(sModule,aTemp);
    2759             :         }
    2760             : 
    2761             :         // #i17355# update the Basic IDE
    2762           0 :         for ( SfxViewShell* pViewShell = SfxViewShell::GetFirst(); pViewShell; pViewShell = SfxViewShell::GetNext( *pViewShell ) )
    2763             :         {
    2764           0 :             if ( pViewShell->GetName().EqualsAscii( "BasicIDE" ) )
    2765             :             {
    2766           0 :                 SfxViewFrame* pViewFrame = pViewShell->GetViewFrame();
    2767           0 :                 SfxDispatcher* pDispat = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
    2768           0 :                 if ( pDispat )
    2769             :                 {
    2770           0 :                     SfxMacroInfoItem aInfoItem( SID_BASICIDE_ARG_MACROINFO, pBasMgr, aLibName, aModuleName, String(), String() );
    2771           0 :                     pDispat->Execute( SID_BASICIDE_UPDATEMODULESOURCE, SFX_CALLMODE_SYNCHRON, &aInfoItem, 0L );
    2772             :                 }
    2773             :             }
    2774           0 :         }
    2775             :     }
    2776             :     else
    2777             :     {
    2778             :         // add code for "session only" macro
    2779           0 :     }
    2780             : #endif
    2781             : }
    2782             : 
    2783           0 : void SfxViewFrame::MiscExec_Impl( SfxRequest& rReq )
    2784             : {
    2785           0 :     switch ( rReq.GetSlot() )
    2786             :     {
    2787             :         case SID_STOP_RECORDING :
    2788             :         case SID_RECORDMACRO :
    2789             :         {
    2790             :             // try to find any active recorder on this frame
    2791           0 :             ::rtl::OUString sProperty("DispatchRecorderSupplier");
    2792             :             com::sun::star::uno::Reference< com::sun::star::frame::XFrame > xFrame(
    2793           0 :                     GetFrame().GetFrameInterface(),
    2794           0 :                     com::sun::star::uno::UNO_QUERY);
    2795             : 
    2796           0 :             com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > xSet(xFrame,com::sun::star::uno::UNO_QUERY);
    2797           0 :             com::sun::star::uno::Any aProp = xSet->getPropertyValue(sProperty);
    2798           0 :             com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorderSupplier > xSupplier;
    2799           0 :             aProp >>= xSupplier;
    2800           0 :             com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorder > xRecorder;
    2801           0 :             if (xSupplier.is())
    2802           0 :                 xRecorder = xSupplier->getDispatchRecorder();
    2803             : 
    2804           0 :             sal_Bool bIsRecording = xRecorder.is();
    2805           0 :             SFX_REQUEST_ARG( rReq, pItem, SfxBoolItem, SID_RECORDMACRO, sal_False);
    2806           0 :             if ( pItem && pItem->GetValue() == bIsRecording )
    2807           0 :                 return;
    2808             : 
    2809           0 :             if ( xRecorder.is() )
    2810             :             {
    2811             :                 // disable active recording
    2812           0 :                 aProp <<= com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorderSupplier >();
    2813           0 :                 xSet->setPropertyValue(sProperty,aProp);
    2814             : 
    2815           0 :                 SFX_REQUEST_ARG( rReq, pRecordItem, SfxBoolItem, FN_PARAM_1, sal_False);
    2816           0 :                 if ( !pRecordItem || !pRecordItem->GetValue() )
    2817             :                     // insert script into basic library container of application
    2818           0 :                     AddDispatchMacroToBasic_Impl(xRecorder->getRecordedMacro());
    2819             : 
    2820           0 :                 xRecorder->endRecording();
    2821           0 :                 xRecorder = NULL;
    2822           0 :                 GetBindings().SetRecorder_Impl( xRecorder );
    2823             : 
    2824           0 :                 SetChildWindow( SID_RECORDING_FLOATWINDOW, sal_False );
    2825           0 :                 if ( rReq.GetSlot() != SID_RECORDMACRO )
    2826           0 :                     GetBindings().Invalidate( SID_RECORDMACRO );
    2827             :             }
    2828           0 :             else if ( rReq.GetSlot() == SID_RECORDMACRO )
    2829             :             {
    2830             :                 // enable recording
    2831             :                 com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xFactory(
    2832             :                         ::comphelper::getProcessServiceFactory(),
    2833           0 :                         com::sun::star::uno::UNO_QUERY);
    2834             :                 com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > xContext(
    2835           0 :                         ::comphelper::getProcessComponentContext());
    2836             : 
    2837             :                 xRecorder = com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorder >(
    2838           0 :                         xFactory->createInstance(rtl::OUString("com.sun.star.frame.DispatchRecorder")),
    2839           0 :                         com::sun::star::uno::UNO_QUERY);
    2840             : 
    2841           0 :                 xSupplier = com::sun::star::frame::DispatchRecorderSupplier::create( xContext );
    2842             : 
    2843           0 :                 xSupplier->setDispatchRecorder(xRecorder);
    2844           0 :                 xRecorder->startRecording(xFrame);
    2845           0 :                 aProp <<= xSupplier;
    2846           0 :                 xSet->setPropertyValue(sProperty,aProp);
    2847           0 :                 GetBindings().SetRecorder_Impl( xRecorder );
    2848           0 :                 SetChildWindow( SID_RECORDING_FLOATWINDOW, sal_True );
    2849             :             }
    2850             : 
    2851           0 :             rReq.Done();
    2852           0 :             break;
    2853             :         }
    2854             : 
    2855             :         case SID_TOGGLESTATUSBAR:
    2856             :         {
    2857             :             com::sun::star::uno::Reference< com::sun::star::frame::XFrame > xFrame(
    2858           0 :                     GetFrame().GetFrameInterface(),
    2859           0 :                     com::sun::star::uno::UNO_QUERY);
    2860             : 
    2861           0 :             Reference< com::sun::star::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY );
    2862           0 :             Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
    2863           0 :             if ( xPropSet.is() )
    2864             :             {
    2865             :                 try
    2866             :                 {
    2867           0 :                     Any aValue = xPropSet->getPropertyValue( rtl::OUString( "LayoutManager" ));
    2868           0 :                     aValue >>= xLayoutManager;
    2869             :                 }
    2870           0 :                 catch ( Exception& )
    2871             :                 {
    2872             :                 }
    2873             :             }
    2874             : 
    2875           0 :             if ( xLayoutManager.is() )
    2876             :             {
    2877           0 :                 rtl::OUString aStatusbarResString( "private:resource/statusbar/statusbar" );
    2878             :                 // Evaluate parameter.
    2879           0 :                 SFX_REQUEST_ARG(rReq, pShowItem, SfxBoolItem, rReq.GetSlot(), sal_False);
    2880           0 :                 sal_Bool bShow( sal_True );
    2881           0 :                 if ( !pShowItem )
    2882           0 :                     bShow = xLayoutManager->isElementVisible( aStatusbarResString );
    2883             :                 else
    2884           0 :                     bShow = pShowItem->GetValue();
    2885             : 
    2886           0 :                 if ( bShow )
    2887             :                 {
    2888           0 :                     xLayoutManager->createElement( aStatusbarResString );
    2889           0 :                     xLayoutManager->showElement( aStatusbarResString );
    2890             :                 }
    2891             :                 else
    2892           0 :                     xLayoutManager->hideElement( aStatusbarResString );
    2893             : 
    2894           0 :                 if ( !pShowItem )
    2895           0 :                     rReq.AppendItem( SfxBoolItem( SID_TOGGLESTATUSBAR, bShow ) );
    2896             :             }
    2897           0 :             rReq.Done();
    2898           0 :             break;
    2899             :         }
    2900             : 
    2901             :         // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    2902             :         case SID_WIN_FULLSCREEN:
    2903             :         {
    2904           0 :             SFX_REQUEST_ARG(rReq, pItem, SfxBoolItem, rReq.GetSlot(), sal_False);
    2905           0 :             SfxViewFrame *pTop = GetTopViewFrame();
    2906           0 :             if ( pTop )
    2907             :             {
    2908           0 :                 WorkWindow* pWork = (WorkWindow*) pTop->GetFrame().GetTopWindow_Impl();
    2909           0 :                 if ( pWork )
    2910             :                 {
    2911             :                     com::sun::star::uno::Reference< com::sun::star::frame::XFrame > xFrame(
    2912           0 :                             GetFrame().GetFrameInterface(),
    2913           0 :                             com::sun::star::uno::UNO_QUERY);
    2914             : 
    2915           0 :                     Reference< ::com::sun::star::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY );
    2916           0 :                     Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
    2917           0 :                     if ( xPropSet.is() )
    2918             :                     {
    2919             :                         try
    2920             :                         {
    2921           0 :                             Any aValue = xPropSet->getPropertyValue( rtl::OUString( "LayoutManager" ));
    2922           0 :                             aValue >>= xLayoutManager;
    2923             :                         }
    2924           0 :                         catch ( Exception& )
    2925             :                         {
    2926             :                         }
    2927             :                     }
    2928             : 
    2929           0 :                     sal_Bool bNewFullScreenMode = pItem ? pItem->GetValue() : !pWork->IsFullScreenMode();
    2930           0 :                     if ( bNewFullScreenMode != pWork->IsFullScreenMode() )
    2931             :                     {
    2932           0 :                         Reference< ::com::sun::star::beans::XPropertySet > xLMPropSet( xLayoutManager, UNO_QUERY );
    2933           0 :                         if ( xLMPropSet.is() )
    2934             :                         {
    2935             :                             try
    2936             :                             {
    2937           0 :                                 xLMPropSet->setPropertyValue(
    2938             :                                     ::rtl::OUString( "HideCurrentUI" ),
    2939           0 :                                     makeAny( bNewFullScreenMode ));
    2940             :                             }
    2941           0 :                             catch ( ::com::sun::star::beans::UnknownPropertyException& )
    2942             :                             {
    2943             :                             }
    2944             :                         }
    2945           0 :                         pWork->ShowFullScreenMode( bNewFullScreenMode );
    2946           0 :                         pWork->SetMenuBarMode( bNewFullScreenMode ? MENUBAR_MODE_HIDE : MENUBAR_MODE_NORMAL );
    2947           0 :                         GetFrame().GetWorkWindow_Impl()->SetFullScreen_Impl( bNewFullScreenMode );
    2948           0 :                         if ( !pItem )
    2949           0 :                             rReq.AppendItem( SfxBoolItem( SID_WIN_FULLSCREEN, bNewFullScreenMode ) );
    2950           0 :                         rReq.Done();
    2951             :                     }
    2952             :                     else
    2953           0 :                         rReq.Ignore();
    2954             :                 }
    2955             :             }
    2956             :             else
    2957           0 :                 rReq.Ignore();
    2958             : 
    2959           0 :             GetDispatcher()->Update_Impl( sal_True );
    2960           0 :             break;
    2961             :         }
    2962             :     }
    2963             : }
    2964             : 
    2965           0 : void SfxViewFrame::MiscState_Impl(SfxItemSet &rSet)
    2966             : {
    2967           0 :     const sal_uInt16 *pRanges = rSet.GetRanges();
    2968             :     DBG_ASSERT(pRanges && *pRanges, "Set without range");
    2969           0 :     while ( *pRanges )
    2970             :     {
    2971           0 :         for(sal_uInt16 nWhich = *pRanges++; nWhich <= *pRanges; ++nWhich)
    2972             :         {
    2973           0 :             switch(nWhich)
    2974             :             {
    2975             :                 case SID_CURRENT_URL:
    2976             :                 {
    2977             :                     // Get the ContainerFrame, when internal InPlace.
    2978           0 :                     SfxViewFrame *pFrame = this;
    2979           0 :                     if ( pFrame->GetParentViewFrame_Impl() )
    2980           0 :                         pFrame = pFrame->GetParentViewFrame_Impl();
    2981           0 :                     rSet.Put( SfxStringItem( nWhich, pFrame->GetActualPresentationURL_Impl() ) );
    2982           0 :                     break;
    2983             :                 }
    2984             : 
    2985             :                 case SID_RECORDMACRO :
    2986             :                 {
    2987           0 :                     SvtMiscOptions aMiscOptions;
    2988           0 :                     const char* pName = GetObjectShell()->GetFactory().GetShortName();
    2989           0 :                     if ( !aMiscOptions.IsMacroRecorderMode() ||
    2990           0 :                          ( strcmp(pName,"swriter") && strcmp(pName,"scalc") ) )
    2991             :                     {
    2992           0 :                         rSet.DisableItem( nWhich );
    2993           0 :                         rSet.Put(SfxVisibilityItem(nWhich, sal_False));
    2994             :                         break;
    2995             :                     }
    2996             : 
    2997           0 :                     ::rtl::OUString sProperty("DispatchRecorderSupplier");
    2998             :                     com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > xSet(
    2999           0 :                             GetFrame().GetFrameInterface(),
    3000           0 :                             com::sun::star::uno::UNO_QUERY);
    3001             : 
    3002           0 :                     com::sun::star::uno::Any aProp = xSet->getPropertyValue(sProperty);
    3003           0 :                     com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorderSupplier > xSupplier;
    3004           0 :                     if ( aProp >>= xSupplier )
    3005           0 :                         rSet.Put( SfxBoolItem( nWhich, xSupplier.is() ) );
    3006             :                     else
    3007           0 :                         rSet.DisableItem( nWhich );
    3008           0 :                     break;
    3009             :                 }
    3010             : 
    3011             :                 case SID_STOP_RECORDING :
    3012             :                 {
    3013           0 :                     SvtMiscOptions aMiscOptions;
    3014           0 :                     const char* pName = GetObjectShell()->GetFactory().GetShortName();
    3015           0 :                     if ( !aMiscOptions.IsMacroRecorderMode() ||
    3016           0 :                          ( strcmp(pName,"swriter") && strcmp(pName,"scalc") ) )
    3017             :                     {
    3018           0 :                         rSet.DisableItem( nWhich );
    3019             :                         break;
    3020             :                     }
    3021             : 
    3022           0 :                     ::rtl::OUString sProperty("DispatchRecorderSupplier");
    3023             :                     com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > xSet(
    3024           0 :                             GetFrame().GetFrameInterface(),
    3025           0 :                             com::sun::star::uno::UNO_QUERY);
    3026             : 
    3027           0 :                     com::sun::star::uno::Any aProp = xSet->getPropertyValue(sProperty);
    3028           0 :                     com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorderSupplier > xSupplier;
    3029           0 :                     if ( !(aProp >>= xSupplier) || !xSupplier.is() )
    3030           0 :                         rSet.DisableItem( nWhich );
    3031           0 :                     break;
    3032             :                 }
    3033             : 
    3034             :                 case SID_TOGGLESTATUSBAR:
    3035             :                 {
    3036           0 :                     com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
    3037             :                     com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > xSet(
    3038           0 :                             GetFrame().GetFrameInterface(),
    3039           0 :                             com::sun::star::uno::UNO_QUERY);
    3040           0 :                     com::sun::star::uno::Any aProp = xSet->getPropertyValue(
    3041           0 :                         rtl::OUString( "LayoutManager" ) );
    3042             : 
    3043           0 :                     if ( !( aProp >>= xLayoutManager ))
    3044           0 :                         rSet.Put( SfxBoolItem( nWhich, sal_False ));
    3045             :                     else
    3046             :                     {
    3047           0 :                         rtl::OUString aStatusbarResString( "private:resource/statusbar/statusbar" );
    3048           0 :                         sal_Bool bShow = xLayoutManager->isElementVisible( aStatusbarResString );
    3049           0 :                         rSet.Put( SfxBoolItem( nWhich, bShow ));
    3050             :                     }
    3051           0 :                     break;
    3052             :                 }
    3053             : 
    3054             :                 case SID_WIN_FULLSCREEN:
    3055             :                 {
    3056           0 :                     SfxViewFrame* pTop = GetTopViewFrame();
    3057           0 :                     if ( pTop )
    3058             :                     {
    3059           0 :                         WorkWindow* pWork = (WorkWindow*) pTop->GetFrame().GetTopWindow_Impl();
    3060           0 :                         if ( pWork )
    3061             :                         {
    3062           0 :                             rSet.Put( SfxBoolItem( nWhich, pWork->IsFullScreenMode() ) );
    3063           0 :                             break;
    3064             :                         }
    3065             :                     }
    3066             : 
    3067           0 :                     rSet.DisableItem( nWhich );
    3068           0 :                     break;
    3069             :                 }
    3070             : 
    3071             :                 case SID_FORMATMENUSTATE :
    3072             :                 {
    3073             :                     OSL_FAIL("Outdated slot!");
    3074           0 :                     rSet.DisableItem( nWhich );
    3075           0 :                     break;
    3076             :                 }
    3077             : 
    3078             :                 default:
    3079           0 :                     break;
    3080             :             }
    3081             :         }
    3082             : 
    3083           0 :         ++pRanges;
    3084             :     }
    3085           0 : }
    3086             : 
    3087           0 : void SfxViewFrame::ChildWindowExecute( SfxRequest &rReq )
    3088             : 
    3089             : /*  [Description]
    3090             : 
    3091             :     This method can be included in the Execute method for the on- and off-
    3092             :     switching of ChildWindows, to implement this and API-bindings.
    3093             : 
    3094             :     Simply include as 'ExecuteMethod' in the IDL.
    3095             : */
    3096             : 
    3097             : {
    3098             :     // Evaluate Parameter
    3099           0 :     sal_uInt16 nSID = rReq.GetSlot();
    3100             : 
    3101           0 :     SFX_REQUEST_ARG(rReq, pShowItem, SfxBoolItem, nSID, sal_False);
    3102           0 :     if ( nSID == SID_VIEW_DATA_SOURCE_BROWSER )
    3103             :     {
    3104           0 :         if (!SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SDATABASE))
    3105             :             return;
    3106           0 :         Reference < XFrame > xFrame = GetFrame().GetTopFrame().GetFrameInterface();
    3107           0 :         Reference < XFrame > xBeamer( xFrame->findFrame( DEFINE_CONST_UNICODE("_beamer"), FrameSearchFlag::CHILDREN ) );
    3108           0 :         sal_Bool bShow = sal_False;
    3109           0 :         sal_Bool bHasChild = xBeamer.is();
    3110           0 :         bShow = pShowItem ? pShowItem->GetValue() : !bHasChild;
    3111           0 :         if ( pShowItem )
    3112             :         {
    3113           0 :             if( bShow == bHasChild )
    3114             :                 return;
    3115             :         }
    3116             :         else
    3117           0 :             rReq.AppendItem( SfxBoolItem( nSID, bShow ) );
    3118             : 
    3119           0 :         if ( !bShow )
    3120             :         {
    3121           0 :             SetChildWindow( SID_BROWSER, sal_False );
    3122             :         }
    3123             :         else
    3124             :         {
    3125           0 :             ::com::sun::star::util::URL aTargetURL;
    3126           0 :             aTargetURL.Complete = ::rtl::OUString(".component:DB/DataSourceBrowser");
    3127             :             Reference < ::com::sun::star::util::XURLTransformer > xTrans(
    3128             :                     ::com::sun::star::util::URLTransformer::create(
    3129           0 :                          ::comphelper::getProcessComponentContext() ) );
    3130           0 :             xTrans->parseStrict( aTargetURL );
    3131             : 
    3132           0 :             Reference < XDispatchProvider > xProv( xFrame, UNO_QUERY );
    3133           0 :             Reference < ::com::sun::star::frame::XDispatch > xDisp;
    3134           0 :             if ( xProv.is() )
    3135           0 :                 xDisp = xProv->queryDispatch( aTargetURL, ::rtl::OUString("_beamer"), 31 );
    3136           0 :             if ( xDisp.is() )
    3137             :             {
    3138           0 :                 Sequence < ::com::sun::star::beans::PropertyValue > aArgs(1);
    3139           0 :                 ::com::sun::star::beans::PropertyValue* pArg = aArgs.getArray();
    3140           0 :                 pArg[0].Name = rtl::OUString("Referer");
    3141           0 :                 pArg[0].Value <<= ::rtl::OUString("private:user");
    3142           0 :                 xDisp->dispatch( aTargetURL, aArgs );
    3143           0 :             }
    3144             :         }
    3145             : 
    3146           0 :         rReq.Done();
    3147           0 :         return;
    3148             :     }
    3149             : 
    3150           0 :     sal_Bool bShow = sal_False;
    3151           0 :     sal_Bool bHasChild = HasChildWindow(nSID);
    3152           0 :     bShow = pShowItem ? pShowItem->GetValue() : !bHasChild;
    3153             : 
    3154             :     // Perform action.
    3155           0 :     if ( !pShowItem || bShow != bHasChild )
    3156           0 :         ToggleChildWindow( nSID );
    3157             : 
    3158           0 :     GetBindings().Invalidate( nSID );
    3159           0 :     GetDispatcher()->Update_Impl( sal_True );
    3160             : 
    3161             :     // Record if possible.
    3162           0 :     if ( nSID == SID_HYPERLINK_DIALOG || nSID == SID_SEARCH_DLG )
    3163             :     {
    3164           0 :         rReq.Ignore();
    3165             :     }
    3166             :     else
    3167             :     {
    3168           0 :         rReq.AppendItem( SfxBoolItem( nSID, bShow ) );
    3169           0 :         rReq.Done();
    3170             :     }
    3171             : }
    3172             : 
    3173             : //--------------------------------------------------------------------
    3174             : 
    3175           0 : void SfxViewFrame::ChildWindowState( SfxItemSet& rState )
    3176             : 
    3177             : /*  [Description]
    3178             : 
    3179             :     This method can be used in the state method for the on and off-state
    3180             :     of child-windows, in order to implement this.
    3181             : 
    3182             :     Just register the IDL as 'StateMethod'.
    3183             : */
    3184             : 
    3185             : {
    3186           0 :     SfxWhichIter aIter( rState );
    3187           0 :     for ( sal_uInt16 nSID = aIter.FirstWhich(); nSID; nSID = aIter.NextWhich() )
    3188             :     {
    3189           0 :         if ( nSID == SID_VIEW_DATA_SOURCE_BROWSER )
    3190             :         {
    3191           0 :             rState.Put( SfxBoolItem( nSID, HasChildWindow( SID_BROWSER ) ) );
    3192             :         }
    3193           0 :         else if ( nSID == SID_HYPERLINK_DIALOG )
    3194             :         {
    3195           0 :             const SfxPoolItem* pDummy = NULL;
    3196           0 :             SfxItemState eState = GetDispatcher()->QueryState( SID_HYPERLINK_SETLINK, pDummy );
    3197           0 :             if ( SFX_ITEM_DISABLED == eState )
    3198           0 :                 rState.DisableItem(nSID);
    3199             :             else
    3200             :             {
    3201           0 :                 if ( KnowsChildWindow(nSID) )
    3202           0 :                     rState.Put( SfxBoolItem( nSID, HasChildWindow(nSID)) );
    3203             :                 else
    3204           0 :                     rState.DisableItem(nSID);
    3205             :             }
    3206             :         }
    3207           0 :         else if ( nSID == SID_BROWSER )
    3208             :         {
    3209           0 :             Reference < XFrame > xFrame = GetFrame().GetTopFrame().GetFrameInterface()->
    3210           0 :                             findFrame( DEFINE_CONST_UNICODE("_beamer"), FrameSearchFlag::CHILDREN );
    3211           0 :             if ( !xFrame.is() )
    3212           0 :                 rState.DisableItem( nSID );
    3213           0 :             else if ( KnowsChildWindow(nSID) )
    3214           0 :                 rState.Put( SfxBoolItem( nSID, HasChildWindow(nSID) ) );
    3215             :         }
    3216           0 :         else if ( nSID == SID_TASKPANE )
    3217             :         {
    3218           0 :             if  ( !KnowsChildWindow( nSID ) )
    3219             :             {
    3220             :                 OSL_FAIL( "SID_TASKPANE state requested, but no task pane child window exists for this ID!" );
    3221           0 :                 rState.DisableItem( nSID );
    3222             :             }
    3223           0 :             else if ( !moduleHasToolPanels( *pImp ) )
    3224             :             {
    3225           0 :                 rState.Put( SfxVisibilityItem( nSID, sal_False ) );
    3226             :             }
    3227             :             else
    3228             :             {
    3229           0 :                 rState.Put( SfxBoolItem( nSID, HasChildWindow( nSID ) ) );
    3230             :             }
    3231             :         }
    3232           0 :         else if ( KnowsChildWindow(nSID) )
    3233           0 :             rState.Put( SfxBoolItem( nSID, HasChildWindow(nSID) ) );
    3234             :         else
    3235           0 :             rState.DisableItem(nSID);
    3236           0 :     }
    3237           0 : }
    3238             : 
    3239             : //--------------------------------------------------------------------
    3240        2097 : SfxWorkWindow* SfxViewFrame::GetWorkWindow_Impl( sal_uInt16 /*nId*/ )
    3241             : {
    3242        2097 :     SfxWorkWindow* pWork = 0;
    3243        2097 :     pWork = GetFrame().GetWorkWindow_Impl();
    3244        2097 :     return pWork;
    3245             : }
    3246             : 
    3247         126 : void SfxViewFrame::SetChildWindow(sal_uInt16 nId, sal_Bool bOn, sal_Bool bSetFocus )
    3248             : {
    3249         126 :     SfxWorkWindow* pWork = GetWorkWindow_Impl( nId );
    3250         126 :     if ( pWork )
    3251         126 :         pWork->SetChildWindow_Impl( nId, bOn, bSetFocus );
    3252         126 : }
    3253             : 
    3254             : //--------------------------------------------------------------------
    3255             : 
    3256           0 : void SfxViewFrame::ToggleChildWindow(sal_uInt16 nId)
    3257             : {
    3258           0 :     SfxWorkWindow* pWork = GetWorkWindow_Impl( nId );
    3259           0 :     if ( pWork )
    3260           0 :         pWork->ToggleChildWindow_Impl( nId, sal_True );
    3261           0 : }
    3262             : 
    3263             : //--------------------------------------------------------------------
    3264             : 
    3265           9 : sal_Bool SfxViewFrame::HasChildWindow( sal_uInt16 nId )
    3266             : {
    3267           9 :     SfxWorkWindow* pWork = GetWorkWindow_Impl( nId );
    3268           9 :     return pWork ? pWork->HasChildWindow_Impl(nId) : sal_False;
    3269             : }
    3270             : 
    3271             : //--------------------------------------------------------------------
    3272             : 
    3273           0 : sal_Bool SfxViewFrame::KnowsChildWindow( sal_uInt16 nId )
    3274             : {
    3275           0 :     SfxWorkWindow* pWork = GetWorkWindow_Impl( nId );
    3276           0 :     return pWork ? pWork->KnowsChildWindow_Impl(nId) : sal_False;
    3277             : }
    3278             : 
    3279             : //--------------------------------------------------------------------
    3280             : 
    3281           0 : void SfxViewFrame::ShowChildWindow( sal_uInt16 nId, sal_Bool bVisible )
    3282             : {
    3283           0 :     SfxWorkWindow* pWork = GetWorkWindow_Impl( nId );
    3284           0 :     if ( pWork )
    3285             :     {
    3286           0 :         GetDispatcher()->Update_Impl(sal_True);
    3287           0 :         pWork->ShowChildWindow_Impl(nId, bVisible, sal_True );
    3288             :     }
    3289           0 : }
    3290             : 
    3291             : //--------------------------------------------------------------------
    3292             : 
    3293        1962 : SfxChildWindow* SfxViewFrame::GetChildWindow(sal_uInt16 nId)
    3294             : {
    3295        1962 :     SfxWorkWindow* pWork = GetWorkWindow_Impl( nId );
    3296        1962 :     return pWork ? pWork->GetChildWindow_Impl(nId) : NULL;
    3297             : }
    3298             : 
    3299         240 : void SfxViewFrame::UpdateDocument_Impl()
    3300             : {
    3301         240 :     SfxObjectShell* pDoc = GetObjectShell();
    3302         240 :     if ( pDoc->IsLoadingFinished() )
    3303         240 :         pDoc->CheckSecurityOnLoading_Impl();
    3304             : 
    3305             :     // check if document depends on a template
    3306         240 :     pDoc->UpdateFromTemplate_Impl();
    3307         240 : }
    3308             : 
    3309         441 : void SfxViewFrame::SetViewFrame( SfxViewFrame* pFrame )
    3310             : {
    3311         441 :     SFX_APP()->SetViewFrame_Impl( pFrame );
    3312         441 : }
    3313             : 
    3314             : // ---------------------------------------------------------------------------------------------------------------------
    3315           0 : void SfxViewFrame::ActivateToolPanel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrame, const ::rtl::OUString& i_rPanelURL )
    3316             : {
    3317           0 :     SolarMutexGuard aGuard;
    3318             : 
    3319             :     // look up the SfxFrame for the given XFrame
    3320           0 :     SfxFrame* pFrame = NULL;
    3321           0 :     for ( pFrame = SfxFrame::GetFirst(); pFrame; pFrame = SfxFrame::GetNext( *pFrame ) )
    3322             :     {
    3323           0 :         if ( pFrame->GetFrameInterface() == i_rFrame )
    3324           0 :             break;
    3325             :     }
    3326           0 :     SfxViewFrame* pViewFrame = pFrame ? pFrame->GetCurrentViewFrame() : NULL;
    3327           0 :     ENSURE_OR_RETURN_VOID( pViewFrame != NULL, "SfxViewFrame::ActivateToolPanel: did not find an SfxFrame for the given XFrame!" );
    3328             : 
    3329           0 :     pViewFrame->ActivateToolPanel_Impl( i_rPanelURL );
    3330             : }
    3331             : 
    3332             : // ---------------------------------------------------------------------------------------------------------------------
    3333           0 : void SfxViewFrame::ActivateToolPanel_Impl( const ::rtl::OUString& i_rPanelURL )
    3334             : {
    3335             :     // ensure the task pane is visible
    3336           0 :     ENSURE_OR_RETURN_VOID( KnowsChildWindow( SID_TASKPANE ), "SfxViewFrame::ActivateToolPanel: this frame/module does not allow for a task pane!" );
    3337           0 :     if ( !HasChildWindow( SID_TASKPANE ) )
    3338           0 :         ToggleChildWindow( SID_TASKPANE );
    3339             : 
    3340           0 :     SfxChildWindow* pTaskPaneChildWindow = GetChildWindow( SID_TASKPANE );
    3341           0 :     ENSURE_OR_RETURN_VOID( pTaskPaneChildWindow, "SfxViewFrame::ActivateToolPanel_Impl: just switched it on, but it is not there!" );
    3342             : 
    3343           0 :     ::sfx2::ITaskPaneToolPanelAccess* pPanelAccess = dynamic_cast< ::sfx2::ITaskPaneToolPanelAccess* >( pTaskPaneChildWindow );
    3344           0 :     ENSURE_OR_RETURN_VOID( pPanelAccess, "SfxViewFrame::ActivateToolPanel_Impl: task pane child window does not implement a required interface!" );
    3345           0 :     pPanelAccess->ActivateToolPanel( i_rPanelURL );
    3346             : }
    3347             : 
    3348           0 : void SfxViewFrame::AppendInfoBar( const rtl::OUString& sId, const rtl::OUString& sMessage, std::vector< PushButton* > aButtons )
    3349             : {
    3350           0 :     const sal_uInt16 nId = SfxInfoBarContainerChild::GetChildWindowId();
    3351             : 
    3352             :     // Make sure the InfoBar container is visible
    3353           0 :     if ( !HasChildWindow( nId ) )
    3354           0 :         ToggleChildWindow( nId );
    3355           0 :     SfxChildWindow* pChild = GetChildWindow( nId );
    3356           0 :     if ( pChild )
    3357             :     {
    3358           0 :         SfxInfoBarContainerWindow* pInfoBars = ( SfxInfoBarContainerWindow* )pChild->GetWindow();
    3359           0 :         pInfoBars->appendInfoBar( sId, sMessage, aButtons );
    3360           0 :         ShowChildWindow( nId );
    3361             :     }
    3362           0 : }
    3363             : 
    3364           0 : void SfxViewFrame::RemoveInfoBar( const rtl::OUString& sId )
    3365             : {
    3366           0 :     const sal_uInt16 nId = SfxInfoBarContainerChild::GetChildWindowId();
    3367             : 
    3368             :     // Make sure the InfoBar container is visible
    3369           0 :     if ( !HasChildWindow( nId ) )
    3370           0 :         ToggleChildWindow( nId );
    3371           0 :     SfxChildWindow* pChild = GetChildWindow( nId );
    3372           0 :     if ( pChild )
    3373             :     {
    3374           0 :         SfxInfoBarContainerWindow* pInfoBars = ( SfxInfoBarContainerWindow* )pChild->GetWindow();
    3375           0 :         SfxInfoBarWindow* pInfoBar = pInfoBars->getInfoBar( sId );
    3376           0 :         pInfoBars->removeInfoBar( pInfoBar );
    3377           0 :         ShowChildWindow( nId );
    3378             :     }
    3379           0 : }
    3380             : 
    3381             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10