LCOV - code coverage report
Current view: top level - sfx2/source/view - viewsh.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 434 820 52.9 %
Date: 2014-11-03 Functions: 73 108 67.6 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <config_features.h>
      21             : 
      22             : #include <svl/stritem.hxx>
      23             : #include <svl/eitem.hxx>
      24             : #include <svl/whiter.hxx>
      25             : #include <vcl/layout.hxx>
      26             : #include <vcl/msgbox.hxx>
      27             : #include <vcl/toolbox.hxx>
      28             : #include <svl/intitem.hxx>
      29             : #include <svtools/sfxecode.hxx>
      30             : #include <svtools/ehdl.hxx>
      31             : #include <com/sun/star/frame/XLayoutManager.hpp>
      32             : #include <com/sun/star/frame/ModuleManager.hpp>
      33             : #include <com/sun/star/beans/XPropertySet.hpp>
      34             : #include <com/sun/star/embed/EmbedStates.hpp>
      35             : #include <com/sun/star/embed/EmbedMisc.hpp>
      36             : #include <com/sun/star/container/XContainerQuery.hpp>
      37             : #include <com/sun/star/frame/XStorable.hpp>
      38             : #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
      39             : #include <com/sun/star/frame/theUICommandDescription.hpp>
      40             : #include <cppuhelper/implbase1.hxx>
      41             : 
      42             : #include <osl/file.hxx>
      43             : #include <osl/mutex.hxx>
      44             : #include <tools/urlobj.hxx>
      45             : #include <unotools/tempfile.hxx>
      46             : #include <unotools/pathoptions.hxx>
      47             : #include <svtools/miscopt.hxx>
      48             : #include <svtools/soerr.hxx>
      49             : #include <svtools/embedhlp.hxx>
      50             : 
      51             : #include <basic/basmgr.hxx>
      52             : #include <basic/sbuno.hxx>
      53             : #include <framework/actiontriggerhelper.hxx>
      54             : #include <comphelper/processfactory.hxx>
      55             : #include <comphelper/sequenceashashmap.hxx>
      56             : #include <toolkit/helper/vclunohelper.hxx>
      57             : #include <vcl/settings.hxx>
      58             : 
      59             : #include <sfx2/app.hxx>
      60             : #include "view.hrc"
      61             : #include <sfx2/viewsh.hxx>
      62             : #include "viewimp.hxx"
      63             : #include <sfx2/sfxresid.hxx>
      64             : #include <sfx2/request.hxx>
      65             : #include <sfx2/templdlg.hxx>
      66             : #include <sfx2/printer.hxx>
      67             : #include <sfx2/docfile.hxx>
      68             : #include <sfx2/dispatch.hxx>
      69             : #include "arrdecl.hxx"
      70             : #include <sfx2/docfac.hxx>
      71             : #include "sfxlocal.hrc"
      72             : #include <sfx2/sfxbasecontroller.hxx>
      73             : #include <sfx2/mailmodelapi.hxx>
      74             : #include "bluthsndapi.hxx"
      75             : #include <sfx2/viewfrm.hxx>
      76             : #include <sfx2/event.hxx>
      77             : #include <sfx2/fcontnr.hxx>
      78             : #include <sfx2/ipclient.hxx>
      79             : #include "workwin.hxx"
      80             : #include <sfx2/objface.hxx>
      81             : #include <sfx2/docfilt.hxx>
      82             : #include "openuriexternally.hxx"
      83             : 
      84             : using namespace ::com::sun::star;
      85             : using namespace ::com::sun::star::uno;
      86             : using namespace ::com::sun::star::frame;
      87             : using namespace ::com::sun::star::beans;
      88             : using namespace ::com::sun::star::util;
      89             : using namespace ::cppu;
      90             : 
      91             : #define SfxViewShell
      92             : #include "sfxslots.hxx"
      93             : 
      94             : 
      95             : 
      96             : class SfxClipboardChangeListener : public ::cppu::WeakImplHelper1<
      97             :     datatransfer::clipboard::XClipboardListener >
      98             : {
      99             : public:
     100             :     SfxClipboardChangeListener( SfxViewShell* pView, const uno::Reference< datatransfer::clipboard::XClipboardNotifier >& xClpbrdNtfr );
     101             :     virtual ~SfxClipboardChangeListener();
     102             : 
     103             :     // XEventListener
     104             :     virtual void SAL_CALL disposing( const lang::EventObject& rEventObject )
     105             :         throw ( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     106             : 
     107             :     // XClipboardListener
     108             :     virtual void SAL_CALL changedContents( const datatransfer::clipboard::ClipboardEvent& rEventObject )
     109             :         throw ( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     110             : 
     111       10772 :     void DisconnectViewShell() { m_pViewShell = NULL; }
     112             :     void ChangedContents();
     113             : 
     114             :     enum AsyncExecuteCmd
     115             :     {
     116             :         ASYNCEXECUTE_CMD_DISPOSING,
     117             :         ASYNCEXECUTE_CMD_CHANGEDCONTENTS
     118             :     };
     119             : 
     120        5210 :     struct AsyncExecuteInfo
     121             :     {
     122        5566 :         AsyncExecuteInfo( AsyncExecuteCmd eCmd, uno::Reference< datatransfer::clipboard::XClipboardListener > xThis, SfxClipboardChangeListener* pListener ) :
     123        5566 :             m_eCmd( eCmd ), m_xThis( xThis ), m_pListener( pListener ) {}
     124             : 
     125             :         AsyncExecuteCmd m_eCmd;
     126             :         uno::Reference< datatransfer::clipboard::XClipboardListener > m_xThis;
     127             :         SfxClipboardChangeListener* m_pListener;
     128             :     };
     129             : 
     130             : private:
     131             :     SfxViewShell* m_pViewShell;
     132             :     uno::Reference< datatransfer::clipboard::XClipboardNotifier > m_xClpbrdNtfr;
     133             :     uno::Reference< lang::XComponent > m_xCtrl;
     134             : 
     135             :     DECL_STATIC_LINK( SfxClipboardChangeListener, AsyncExecuteHdl_Impl, AsyncExecuteInfo* );
     136             : };
     137             : 
     138        5566 : SfxClipboardChangeListener::SfxClipboardChangeListener( SfxViewShell* pView, const uno::Reference< datatransfer::clipboard::XClipboardNotifier >& xClpbrdNtfr )
     139        5566 :   : m_pViewShell( 0 ), m_xClpbrdNtfr( xClpbrdNtfr )
     140             : {
     141        5566 :     m_xCtrl = uno::Reference < lang::XComponent >( pView->GetController(), uno::UNO_QUERY );
     142        5566 :     if ( m_xCtrl.is() )
     143             :     {
     144        5566 :         m_xCtrl->addEventListener( uno::Reference < lang::XEventListener > ( static_cast < lang::XEventListener* >( this ) ) );
     145        5566 :         m_pViewShell = pView;
     146             :     }
     147        5566 :     if ( m_xClpbrdNtfr.is() )
     148             :     {
     149        1646 :         m_xClpbrdNtfr->addClipboardListener( uno::Reference< datatransfer::clipboard::XClipboardListener >(
     150        1646 :             static_cast< datatransfer::clipboard::XClipboardListener* >( this )));
     151             :     }
     152        5566 : }
     153             : 
     154       10416 : SfxClipboardChangeListener::~SfxClipboardChangeListener()
     155             : {
     156       10416 : }
     157             : 
     158           2 : void SfxClipboardChangeListener::ChangedContents()
     159             : {
     160           2 :     const SolarMutexGuard aGuard;
     161           2 :     if( m_pViewShell )
     162             :     {
     163           0 :         SfxBindings& rBind = m_pViewShell->GetViewFrame()->GetBindings();
     164           0 :         rBind.Invalidate( SID_PASTE );
     165           0 :         rBind.Invalidate( SID_PASTE_SPECIAL );
     166           0 :         rBind.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
     167           2 :     }
     168           2 : }
     169             : 
     170       10420 : IMPL_STATIC_LINK_NOINSTANCE( SfxClipboardChangeListener, AsyncExecuteHdl_Impl, AsyncExecuteInfo*, pAsyncExecuteInfo )
     171             : {
     172        5210 :     if ( pAsyncExecuteInfo )
     173             :     {
     174        5210 :         uno::Reference< datatransfer::clipboard::XClipboardListener > xThis( pAsyncExecuteInfo->m_xThis );
     175        5210 :         if ( pAsyncExecuteInfo->m_pListener )
     176             :         {
     177        5210 :             if ( pAsyncExecuteInfo->m_eCmd == ASYNCEXECUTE_CMD_DISPOSING )
     178        5208 :                 pAsyncExecuteInfo->m_pListener->DisconnectViewShell();
     179           2 :             else if ( pAsyncExecuteInfo->m_eCmd == ASYNCEXECUTE_CMD_CHANGEDCONTENTS )
     180           2 :                 pAsyncExecuteInfo->m_pListener->ChangedContents();
     181        5210 :         }
     182             :     }
     183        5210 :     delete pAsyncExecuteInfo;
     184             : 
     185        5210 :     return 0;
     186             : }
     187             : 
     188        5564 : void SAL_CALL SfxClipboardChangeListener::disposing( const lang::EventObject& /*rEventObject*/ )
     189             :     throw ( uno::RuntimeException, std::exception )
     190             : {
     191             :     // Either clipboard or ViewShell is going to be destroyed -> no interest in listening anymore
     192        5564 :     uno::Reference< lang::XComponent > xCtrl( m_xCtrl );
     193       11128 :     uno::Reference< datatransfer::clipboard::XClipboardNotifier > xNotify( m_xClpbrdNtfr );
     194             : 
     195       11128 :     uno::Reference< datatransfer::clipboard::XClipboardListener > xThis( static_cast< datatransfer::clipboard::XClipboardListener* >( this ));
     196        5564 :     if ( xCtrl.is() )
     197        5564 :         xCtrl->removeEventListener( uno::Reference < lang::XEventListener > ( static_cast < lang::XEventListener* >( this )));
     198        5564 :     if ( xNotify.is() )
     199        1644 :         xNotify->removeClipboardListener( xThis );
     200             : 
     201             :     // Make asynchronous call to avoid locking SolarMutex which is the
     202             :     // root for many deadlocks, especially in conjunction with the "Windows"
     203             :     // based single thread apartment clipboard code!
     204        5564 :     AsyncExecuteInfo* pInfo = new AsyncExecuteInfo( ASYNCEXECUTE_CMD_DISPOSING, xThis, this );
     205       11128 :     Application::PostUserEvent( STATIC_LINK( 0, SfxClipboardChangeListener, AsyncExecuteHdl_Impl ), pInfo );
     206        5564 : }
     207             : 
     208           2 : void SAL_CALL SfxClipboardChangeListener::changedContents( const datatransfer::clipboard::ClipboardEvent& )
     209             :     throw ( RuntimeException, std::exception )
     210             : {
     211             :     // Make asynchronous call to avoid locking SolarMutex which is the
     212             :     // root for many deadlocks, especially in conjunction with the "Windows"
     213             :     // based single thread apartment clipboard code!
     214           2 :     uno::Reference< datatransfer::clipboard::XClipboardListener > xThis( static_cast< datatransfer::clipboard::XClipboardListener* >( this ));
     215           2 :     AsyncExecuteInfo* pInfo = new AsyncExecuteInfo( ASYNCEXECUTE_CMD_CHANGEDCONTENTS, xThis, this );
     216           2 :     Application::PostUserEvent( STATIC_LINK( 0, SfxClipboardChangeListener, AsyncExecuteHdl_Impl ), pInfo );
     217           2 : }
     218             : 
     219             : 
     220             : 
     221        1562 : static OUString RetrieveLabelFromCommand(
     222             :     const OUString& rCommandURL,
     223             :     const css::uno::Reference< css::frame::XFrame >& rFrame )
     224             : {
     225        1562 :     static css::uno::WeakReference< frame::XModuleManager2 > s_xModuleManager;
     226        1562 :     static css::uno::WeakReference< container::XNameAccess > s_xNameAccess;
     227             : 
     228        1562 :     OUString aLabel;
     229        3124 :     css::uno::Reference< css::frame::XModuleManager2 > xModuleManager( s_xModuleManager );
     230        3124 :     css::uno::Reference< css::container::XNameAccess > xNameAccess( s_xNameAccess );
     231        3124 :     css::uno::Reference< css::uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
     232             : 
     233             :     try
     234             :     {
     235        1562 :         if ( !xModuleManager.is() )
     236             :         {
     237          54 :             xModuleManager = css::frame::ModuleManager::create(xContext);
     238          54 :             s_xModuleManager = xModuleManager;
     239             :         }
     240             : 
     241        1562 :         OUString aModuleIdentifier = xModuleManager->identify( rFrame );
     242             : 
     243        1562 :         if ( !xNameAccess.is() )
     244             :         {
     245         108 :             xNameAccess = css::uno::Reference< css::container::XNameAccess >(
     246             :                 css::frame::theUICommandDescription::get(xContext),
     247          54 :                     css::uno::UNO_QUERY_THROW );
     248          54 :             s_xNameAccess = xNameAccess;
     249             :         }
     250             : 
     251        3124 :         css::uno::Any a = xNameAccess->getByName( aModuleIdentifier );
     252        3124 :         css::uno::Reference< css::container::XNameAccess > xUICommands;
     253        1562 :         a >>= xUICommands;
     254             : 
     255        3124 :         OUString aStr;
     256        3124 :         css::uno::Sequence< css::beans::PropertyValue > aPropSeq;
     257             : 
     258        1562 :         a = xUICommands->getByName( rCommandURL );
     259        1562 :         if ( a >>= aPropSeq )
     260             :         {
     261        1562 :             for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ )
     262             :             {
     263        1562 :                 if ( aPropSeq[i].Name == "Label" )
     264             :                 {
     265        1562 :                     aPropSeq[i].Value >>= aStr;
     266        1562 :                     break;
     267             :                 }
     268             :             }
     269        1562 :             aLabel = aStr;
     270        1562 :         }
     271             :     }
     272           0 :     catch (const css::uno::Exception&)
     273             :     {
     274             :     }
     275             : 
     276        3124 :     return aLabel;
     277             : }
     278             : 
     279             : 
     280        5524 : SfxViewShell_Impl::SfxViewShell_Impl(sal_uInt16 const nFlags)
     281             : : aInterceptorContainer( aMutex )
     282             : ,   m_bControllerSet(false)
     283             : ,   m_nPrinterLocks(0)
     284        5524 : ,   m_bCanPrint(SFX_VIEW_CAN_PRINT == (nFlags & SFX_VIEW_CAN_PRINT))
     285             : ,   m_bHasPrintOptions(
     286        5524 :         SFX_VIEW_HAS_PRINTOPTIONS == (nFlags & SFX_VIEW_HAS_PRINTOPTIONS))
     287             : ,   m_bPlugInsActive(true)
     288        5524 : ,   m_bIsShowView(SFX_VIEW_NO_SHOW != (nFlags & SFX_VIEW_NO_SHOW))
     289             : ,   m_bGotOwnership(false)
     290             : ,   m_bGotFrameOwnership(false)
     291             : ,   m_nFamily(0xFFFF)   // undefined, default set by TemplateDialog
     292       22096 : ,   m_pController(0)
     293        5524 : {}
     294             : 
     295        5698 : SFX_IMPL_INTERFACE(SfxViewShell,SfxShell,SfxResId(0))
     296             : 
     297         303 : void SfxViewShell::InitInterface_Impl()
     298             : {
     299         303 : }
     300             : 
     301      100114 : TYPEINIT2(SfxViewShell,SfxShell,SfxListener);
     302             : 
     303             : /** search for a filter name dependent on type and module
     304             :  */
     305           0 : static OUString impl_retrieveFilterNameFromTypeAndModule(
     306             :     const css::uno::Reference< css::container::XContainerQuery >& rContainerQuery,
     307             :     const OUString& rType,
     308             :     const OUString& rModuleIdentifier,
     309             :     const sal_Int32 nFlags )
     310             : {
     311             :     // Retrieve filter from type
     312           0 :     css::uno::Sequence< css::beans::NamedValue > aQuery( 2 );
     313           0 :     aQuery[0].Name  = "Type";
     314           0 :     aQuery[0].Value = css::uno::makeAny( rType );
     315           0 :     aQuery[1].Name  = "DocumentService";
     316           0 :     aQuery[1].Value = css::uno::makeAny( rModuleIdentifier );
     317             : 
     318             :     css::uno::Reference< css::container::XEnumeration > xEnumeration =
     319           0 :         rContainerQuery->createSubSetEnumerationByProperties( aQuery );
     320             : 
     321           0 :     OUString aFoundFilterName;
     322           0 :     while ( xEnumeration->hasMoreElements() )
     323             :     {
     324           0 :         ::comphelper::SequenceAsHashMap aFilterPropsHM( xEnumeration->nextElement() );
     325             :         OUString aFilterName = aFilterPropsHM.getUnpackedValueOrDefault(
     326             :             OUString("Name"),
     327           0 :             OUString() );
     328             : 
     329             :         sal_Int32 nFilterFlags = aFilterPropsHM.getUnpackedValueOrDefault(
     330             :             OUString("Flags"),
     331           0 :             sal_Int32( 0 ) );
     332             : 
     333           0 :         if ( nFilterFlags & nFlags )
     334             :         {
     335           0 :             aFoundFilterName = aFilterName;
     336           0 :             break;
     337             :         }
     338           0 :     }
     339             : 
     340           0 :     return aFoundFilterName;
     341             : }
     342             : 
     343             : 
     344             : /** search for an internal typename, which map to the current app module
     345             :     and map also to a "family" of file formats as e.g. PDF/MS Doc/OOo Doc.
     346             :  */
     347             : enum ETypeFamily
     348             : {
     349             :     E_MS_DOC,
     350             :     E_OOO_DOC
     351             : };
     352             : 
     353           0 : OUString impl_searchFormatTypeForApp(const css::uno::Reference< css::frame::XFrame >& xFrame     ,
     354             :                                                   ETypeFamily                                eTypeFamily)
     355             : {
     356             :     try
     357             :     {
     358           0 :         css::uno::Reference< css::uno::XComponentContext >  xContext      (::comphelper::getProcessComponentContext());
     359           0 :         css::uno::Reference< css::frame::XModuleManager2 >  xModuleManager(css::frame::ModuleManager::create(xContext));
     360             : 
     361           0 :         OUString sModule = xModuleManager->identify(xFrame);
     362           0 :         OUString sType   ;
     363             : 
     364           0 :         switch(eTypeFamily)
     365             :         {
     366             :             case E_MS_DOC:
     367             :             {
     368           0 :                 if ( sModule == "com.sun.star.text.TextDocument" )
     369           0 :                     sType = "writer_MS_Word_97";
     370             :                 else
     371           0 :                 if ( sModule == "com.sun.star.sheet.SpreadsheetDocument" )
     372           0 :                     sType = "calc_MS_Excel_97";
     373             :                 else
     374           0 :                 if ( sModule == "com.sun.star.drawing.DrawingDocument" )
     375           0 :                     sType = "impress_MS_PowerPoint_97";
     376             :                 else
     377           0 :                 if ( sModule == "com.sun.star.presentation.PresentationDocument" )
     378           0 :                     sType = "impress_MS_PowerPoint_97";
     379             :             }
     380           0 :             break;
     381             : 
     382             :             case E_OOO_DOC:
     383             :             {
     384           0 :                 if ( sModule == "com.sun.star.text.TextDocument" )
     385           0 :                     sType = "writer8";
     386             :                 else
     387           0 :                 if ( sModule == "com.sun.star.sheet.SpreadsheetDocument" )
     388           0 :                     sType = "calc8";
     389             :                 else
     390           0 :                 if ( sModule == "com.sun.star.drawing.DrawingDocument" )
     391           0 :                     sType = "draw8";
     392             :                 else
     393           0 :                 if ( sModule == "com.sun.star.presentation.PresentationDocument" )
     394           0 :                     sType = "impress8";
     395             :             }
     396           0 :             break;
     397             :         }
     398             : 
     399           0 :         return sType;
     400             :     }
     401           0 :     catch (const css::uno::RuntimeException&)
     402             :     {
     403           0 :         throw;
     404             :     }
     405           0 :     catch (const css::uno::Exception&)
     406             :     {
     407             :     }
     408             : 
     409           0 :     return OUString();
     410             : }
     411             : 
     412             : 
     413             : 
     414          20 : void SfxViewShell::IPClientGone_Impl( SfxInPlaceClient *pIPClient )
     415             : {
     416          20 :     SfxInPlaceClientList* pClientList = GetIPClientList_Impl(true);
     417             : 
     418          20 :     for( SfxInPlaceClientList::iterator it = pClientList->begin(); it != pClientList->end(); ++it )
     419             :     {
     420          20 :         if ( *it == pIPClient )
     421             :         {
     422          20 :             pClientList->erase( it );
     423          20 :             break;
     424             :         }
     425             :     }
     426          20 : }
     427             : 
     428             : 
     429             : 
     430             : 
     431             : 
     432           0 : void SfxViewShell::ExecMisc_Impl( SfxRequest &rReq )
     433             : {
     434           0 :     const sal_uInt16 nId = rReq.GetSlot();
     435           0 :     switch( nId )
     436             :     {
     437             :         case SID_STYLE_FAMILY :
     438             :         {
     439           0 :             SFX_REQUEST_ARG(rReq, pItem, SfxUInt16Item, nId, false);
     440           0 :             if (pItem)
     441             :             {
     442           0 :                 pImp->m_nFamily = pItem->GetValue();
     443             :             }
     444           0 :             break;
     445             :         }
     446             :         case SID_ACTIVATE_STYLE_APPLY:
     447             :         {
     448             :             uno::Reference< frame::XFrame > xFrame(
     449           0 :                 GetViewFrame()->GetFrame().GetFrameInterface(),
     450           0 :                 uno::UNO_QUERY);
     451             : 
     452           0 :             Reference< beans::XPropertySet > xPropSet( xFrame, UNO_QUERY );
     453           0 :             Reference< frame::XLayoutManager > xLayoutManager;
     454           0 :             if ( xPropSet.is() )
     455             :             {
     456             :                 try
     457             :                 {
     458           0 :                     Any aValue = xPropSet->getPropertyValue("LayoutManager");
     459           0 :                     aValue >>= xLayoutManager;
     460           0 :                     if ( xLayoutManager.is() )
     461             :                     {
     462           0 :                         OUString aTextResString( "private:resource/toolbar/textobjectbar" );
     463           0 :                         uno::Reference< ui::XUIElement > xElement = xLayoutManager->getElement( aTextResString );
     464           0 :                         if(!xElement.is())
     465             :                         {
     466           0 :                             OUString aFrameResString( "private:resource/toolbar/frameobjectbar" );
     467           0 :                             xElement = xLayoutManager->getElement( aFrameResString );
     468             :                         }
     469           0 :                         if(!xElement.is())
     470             :                         {
     471           0 :                             OUString aOleResString( "private:resource/toolbar/oleobjectbar" );
     472           0 :                             xElement = xLayoutManager->getElement( aOleResString );
     473             :                         }
     474           0 :                         if(xElement.is())
     475             :                         {
     476           0 :                             uno::Reference< awt::XWindow > xWin( xElement->getRealInterface(), uno::UNO_QUERY_THROW );
     477           0 :                             vcl::Window* pWin = VCLUnoHelper::GetWindow( xWin );
     478           0 :                             ToolBox* pTextToolbox = dynamic_cast< ToolBox* >( pWin );
     479           0 :                             if( pTextToolbox )
     480             :                             {
     481           0 :                                 sal_uInt16 nItemCount = pTextToolbox->GetItemCount();
     482           0 :                                 for( sal_uInt16 nItem = 0; nItem < nItemCount; ++nItem )
     483             :                                 {
     484           0 :                                     sal_uInt16 nItemId = pTextToolbox->GetItemId( nItem );
     485           0 :                                     const OUString& rCommand = pTextToolbox->GetItemCommand( nItemId );
     486           0 :                                     if (rCommand == ".uno:StyleApply")
     487             :                                     {
     488           0 :                                         vcl::Window* pItemWin = pTextToolbox->GetItemWindow( nItemId );
     489           0 :                                         if( pItemWin )
     490           0 :                                             pItemWin->GrabFocus();
     491           0 :                                         break;
     492             :                                     }
     493           0 :                                 }
     494           0 :                             }
     495           0 :                         }
     496           0 :                     }
     497             :                 }
     498           0 :                 catch (const Exception&)
     499             :                 {
     500             :                 }
     501             :             }
     502           0 :             rReq.Done();
     503             :         }
     504           0 :         break;
     505             :         // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     506             : 
     507             :         case SID_MAIL_SENDDOCASMS:
     508             :         case SID_MAIL_SENDDOCASOOO:
     509             :         case SID_MAIL_SENDDOCASPDF:
     510             :         case SID_MAIL_SENDDOC:
     511             :         case SID_MAIL_SENDDOCASFORMAT:
     512             :         {
     513           0 :             SfxObjectShell* pDoc = GetObjectShell();
     514           0 :             if ( pDoc && pDoc->QueryHiddenInformation(
     515           0 :                              WhenSaving, &GetViewFrame()->GetWindow() ) != RET_YES )
     516           0 :                 break;
     517             : 
     518             : 
     519           0 :             SfxMailModel  aModel;
     520           0 :             OUString aDocType;
     521             : 
     522           0 :             SFX_REQUEST_ARG(rReq, pMailSubject, SfxStringItem, SID_MAIL_SUBJECT, false );
     523           0 :             if ( pMailSubject )
     524           0 :                 aModel.SetSubject( pMailSubject->GetValue() );
     525             : 
     526           0 :             SFX_REQUEST_ARG(rReq, pMailRecipient, SfxStringItem, SID_MAIL_RECIPIENT, false );
     527           0 :             if ( pMailRecipient )
     528             :             {
     529           0 :                 OUString aRecipient( pMailRecipient->GetValue() );
     530           0 :                 OUString aMailToStr("mailto:");
     531             : 
     532           0 :                 if ( aRecipient.startsWith( aMailToStr ) )
     533           0 :                     aRecipient = aRecipient.copy( aMailToStr.getLength() );
     534           0 :                 aModel.AddAddress( aRecipient, SfxMailModel::ROLE_TO );
     535             :             }
     536           0 :             SFX_REQUEST_ARG(rReq, pMailDocType, SfxStringItem, SID_TYPE_NAME, false );
     537           0 :             if ( pMailDocType )
     538           0 :                 aDocType = pMailDocType->GetValue();
     539             : 
     540           0 :             uno::Reference < frame::XFrame > xFrame( pFrame->GetFrame().GetFrameInterface() );
     541           0 :             SfxMailModel::SendMailResult eResult = SfxMailModel::SEND_MAIL_ERROR;
     542             : 
     543           0 :             if ( nId == SID_MAIL_SENDDOC )
     544           0 :                 eResult = aModel.SaveAndSend( xFrame, OUString() );
     545           0 :             else if ( nId == SID_MAIL_SENDDOCASPDF )
     546           0 :                 eResult = aModel.SaveAndSend( xFrame, OUString( "pdf_Portable_Document_Format" ));
     547           0 :             else if ( nId == SID_MAIL_SENDDOCASMS )
     548             :             {
     549           0 :                 aDocType = impl_searchFormatTypeForApp(xFrame, E_MS_DOC);
     550           0 :                 if (!aDocType.isEmpty())
     551           0 :                     eResult = aModel.SaveAndSend( xFrame, aDocType );
     552             :             }
     553           0 :             else if ( nId == SID_MAIL_SENDDOCASOOO )
     554             :             {
     555           0 :                 aDocType = impl_searchFormatTypeForApp(xFrame, E_OOO_DOC);
     556           0 :                 if (!aDocType.isEmpty())
     557           0 :                     eResult = aModel.SaveAndSend( xFrame, aDocType );
     558             :             }
     559             : 
     560           0 :             if ( eResult == SfxMailModel::SEND_MAIL_ERROR )
     561             :             {
     562           0 :                 MessageDialog aBox( SfxGetpApp()->GetTopWindow(), SfxResId( STR_ERROR_SEND_MAIL ), VCL_MESSAGE_INFO);
     563           0 :                 aBox.Execute();
     564           0 :                 rReq.Ignore();
     565             :             }
     566             :             else
     567           0 :                 rReq.Done();
     568             :         }
     569           0 :         break;
     570             : 
     571             :         case SID_BLUETOOTH_SENDDOC:
     572             :         {
     573           0 :             SfxBluetoothModel aModel;
     574           0 :             SfxObjectShell* pDoc = GetObjectShell();
     575           0 :             if ( pDoc && pDoc->QueryHiddenInformation(
     576           0 :                             WhenSaving, &GetViewFrame()->GetWindow() ) != RET_YES )
     577           0 :                 break;
     578           0 :             uno::Reference < frame::XFrame > xFrame( pFrame->GetFrame().GetFrameInterface() );
     579           0 :             SfxMailModel::SendMailResult eResult = aModel.SaveAndSend( xFrame, OUString() );
     580           0 :             if( eResult == SfxMailModel::SEND_MAIL_ERROR )
     581             :             {
     582           0 :                     MessageDialog aBox( SfxGetpApp()->GetTopWindow(), SfxResId( STR_ERROR_SEND_MAIL ), VCL_MESSAGE_INFO);
     583           0 :                     aBox.Execute();
     584           0 :                     rReq.Ignore();
     585             :             }
     586             :             else
     587           0 :                 rReq.Done();
     588             :         }
     589           0 :         break;
     590             : 
     591             :         // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     592             :         case SID_WEBHTML:
     593             :         {
     594             :             static const char HTML_DOCUMENT_TYPE[] = "generic_HTML";
     595             :             static const char HTML_GRAPHIC_TYPE[]  = "graphic_HTML";
     596           0 :             const sal_Int32   FILTERFLAG_EXPORT    = 0x00000002;
     597             : 
     598           0 :             css::uno::Reference< lang::XMultiServiceFactory > xSMGR(::comphelper::getProcessServiceFactory(), css::uno::UNO_QUERY_THROW);
     599           0 :             css::uno::Reference< uno::XComponentContext >     xContext(::comphelper::getProcessComponentContext(), css::uno::UNO_QUERY_THROW);
     600           0 :             css::uno::Reference< css::frame::XFrame >         xFrame( pFrame->GetFrame().GetFrameInterface() );
     601           0 :             css::uno::Reference< css::frame::XModel >         xModel;
     602             : 
     603           0 :             css::uno::Reference< css::frame::XModuleManager2 > xModuleManager( css::frame::ModuleManager::create(xContext) );
     604             : 
     605           0 :             OUString aModule;
     606             :             try
     607             :             {
     608           0 :                 aModule = xModuleManager->identify( xFrame );
     609             :             }
     610           0 :             catch (const css::uno::RuntimeException&)
     611             :             {
     612           0 :                 throw;
     613             :             }
     614           0 :             catch (const css::uno::Exception&)
     615             :             {
     616             :             }
     617             : 
     618           0 :             if ( xFrame.is() )
     619             :             {
     620           0 :                 css::uno::Reference< css::frame::XController > xController = xFrame->getController();
     621           0 :                 if ( xController.is() )
     622           0 :                     xModel = xController->getModel();
     623             :             }
     624             : 
     625             :             // We need at least a valid module name and model reference
     626           0 :             css::uno::Reference< css::frame::XStorable > xStorable( xModel, css::uno::UNO_QUERY );
     627           0 :             if ( xModel.is() && xStorable.is() )
     628             :             {
     629           0 :                 OUString aFilterName;
     630           0 :                 OUString aTypeName( HTML_DOCUMENT_TYPE );
     631           0 :                 OUString aFileName;
     632           0 :                 OUString aExtension( "htm" );
     633             : 
     634           0 :                 OUString aLocation = xStorable->getLocation();
     635           0 :                 INetURLObject aFileObj( aLocation );
     636             : 
     637           0 :                 bool bPrivateProtocol = ( aFileObj.GetProtocol() == INET_PROT_PRIV_SOFFICE );
     638           0 :                 bool bHasLocation = !aLocation.isEmpty() && !bPrivateProtocol;
     639             : 
     640             :                 css::uno::Reference< css::container::XContainerQuery > xContainerQuery(
     641           0 :                     xSMGR->createInstance( OUString(
     642           0 :                         "com.sun.star.document.FilterFactory" )),
     643           0 :                         css::uno::UNO_QUERY_THROW );
     644             : 
     645             :                 // Retrieve filter from type
     646           0 :                 sal_Int32 nFilterFlags = FILTERFLAG_EXPORT;
     647           0 :                 aFilterName = impl_retrieveFilterNameFromTypeAndModule( xContainerQuery, aTypeName, aModule, nFilterFlags );
     648           0 :                 if ( aFilterName.isEmpty() )
     649             :                 {
     650             :                     // Draw/Impress uses a different type. 2nd chance try to use alternative type name
     651           0 :                     aFilterName = impl_retrieveFilterNameFromTypeAndModule(
     652           0 :                         xContainerQuery, OUString( HTML_GRAPHIC_TYPE ), aModule, nFilterFlags );
     653             :                 }
     654             : 
     655             :                 // No filter found => error
     656             :                 // No type and no location => error
     657           0 :                 if ( aFilterName.isEmpty() ||  aTypeName.isEmpty())
     658             :                 {
     659           0 :                     rReq.Done(false);
     660           0 :                     return;
     661             :                 }
     662             : 
     663             :                 // Use provided save file name. If empty determine file name
     664           0 :                 if ( !bHasLocation )
     665             :                 {
     666             :                     // Create a default file name with the correct extension
     667           0 :                     const OUString aPreviewFileName( "webpreview" );
     668           0 :                     aFileName = aPreviewFileName;
     669             :                 }
     670             :                 else
     671             :                 {
     672             :                     // Determine file name from model
     673           0 :                     INetURLObject aFObj( xStorable->getLocation() );
     674           0 :                     aFileName = aFObj.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::NO_DECODE );
     675             :                 }
     676             : 
     677             :                 OSL_ASSERT( !aFilterName.isEmpty() );
     678             :                 OSL_ASSERT( !aFileName.isEmpty() );
     679             : 
     680             :                 // Creates a temporary directory to store our predefined file into it.
     681           0 :                 ::utl::TempFile aTempDir( NULL, true );
     682             : 
     683           0 :                 INetURLObject aFilePathObj( aTempDir.GetURL() );
     684           0 :                 aFilePathObj.insertName( aFileName );
     685           0 :                 aFilePathObj.setExtension( aExtension );
     686             : 
     687           0 :                 OUString aFileURL = aFilePathObj.GetMainURL( INetURLObject::NO_DECODE );
     688             : 
     689           0 :                 css::uno::Sequence< css::beans::PropertyValue > aArgs( 1 );
     690           0 :                 aArgs[0].Name  = "FilterName";
     691           0 :                 aArgs[0].Value = css::uno::makeAny( aFilterName );
     692             : 
     693             :                 // Store document in the html format
     694             :                 try
     695             :                 {
     696           0 :                     xStorable->storeToURL( aFileURL, aArgs );
     697             :                 }
     698           0 :                 catch (const io::IOException&)
     699             :                 {
     700           0 :                     rReq.Done(false);
     701           0 :                     return;
     702             :                 }
     703             : 
     704           0 :                 rReq.Done(sfx2::openUriExternally(aFileURL, true));
     705           0 :                 break;
     706             :             }
     707             :             else
     708             :             {
     709           0 :                 rReq.Done(false);
     710           0 :                 return;
     711           0 :             }
     712             :         }
     713             : 
     714             :         // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     715             :         case SID_PLUGINS_ACTIVE:
     716             :         {
     717           0 :             SFX_REQUEST_ARG(rReq, pShowItem, SfxBoolItem, nId, false);
     718             :             bool const bActive = (pShowItem)
     719             :                 ? pShowItem->GetValue()
     720           0 :                 : !pImp->m_bPlugInsActive;
     721             :             // ggf. recorden
     722           0 :             if ( !rReq.IsAPI() )
     723           0 :                 rReq.AppendItem( SfxBoolItem( nId, bActive ) );
     724             : 
     725             :             // Jetzt schon DONE aufrufen, da die Argumente evtl. einen Pool
     726             :             // benutzen, der demn"achst weg ist
     727           0 :             rReq.Done(true);
     728             : 
     729             :             // ausfuehren
     730           0 :             if (!pShowItem || (bActive != pImp->m_bPlugInsActive))
     731             :             {
     732           0 :                 SfxFrame* pTopFrame = &GetFrame()->GetTopFrame();
     733           0 :                 if ( pTopFrame != &GetFrame()->GetFrame() )
     734             :                 {
     735             :                     // FramesetDocument
     736           0 :                     SfxViewShell *pShell = pTopFrame->GetCurrentViewFrame()->GetViewShell();
     737           0 :                     if ( pShell->GetInterface()->GetSlot( nId ) )
     738           0 :                         pShell->ExecuteSlot( rReq );
     739           0 :                     break;
     740             :                 }
     741             : 
     742           0 :                 SfxFrameIterator aIter( *pTopFrame );
     743           0 :                 while ( pTopFrame )
     744             :                 {
     745           0 :                     if ( pTopFrame->GetCurrentViewFrame() )
     746             :                     {
     747           0 :                         SfxViewShell *pView = pTopFrame->GetCurrentViewFrame()->GetViewShell();
     748           0 :                         if ( pView )
     749             :                         {
     750           0 :                             pView->pImp->m_bPlugInsActive = bActive;
     751           0 :                             Rectangle aVisArea = GetObjectShell()->GetVisArea();
     752           0 :                             VisAreaChanged(aVisArea);
     753             : 
     754             :                             // the plugins might need change in their state
     755           0 :                             SfxInPlaceClientList *pClients = pView->GetIPClientList_Impl(false);
     756           0 :                             if ( pClients )
     757             :                             {
     758           0 :                                 for ( size_t n = 0; n < pClients->size(); n++)
     759             :                                 {
     760           0 :                                     SfxInPlaceClient* pIPClient = pClients->at( n );
     761           0 :                                     if ( pIPClient )
     762           0 :                                         pView->CheckIPClient_Impl( pIPClient, aVisArea );
     763             :                                 }
     764             :                             }
     765             :                         }
     766             :                     }
     767             : 
     768           0 :                     if ( !pTopFrame->GetParentFrame() )
     769           0 :                         pTopFrame = aIter.FirstFrame();
     770             :                     else
     771           0 :                         pTopFrame = aIter.NextFrame( *pTopFrame );
     772             :                 }
     773             :             }
     774             : 
     775           0 :             break;
     776             :         }
     777             :     }
     778             : }
     779             : 
     780             : 
     781             : 
     782       12850 : void SfxViewShell::GetState_Impl( SfxItemSet &rSet )
     783             : {
     784             : 
     785       12850 :     SfxWhichIter aIter( rSet );
     786       26204 :     for ( sal_uInt16 nSID = aIter.FirstWhich(); nSID; nSID = aIter.NextWhich() )
     787             :     {
     788       13354 :         switch ( nSID )
     789             :         {
     790             : #if HAVE_FEATURE_MACOSX_SANDBOX
     791             :             case SID_BLUETOOTH_SENDDOC:
     792             :             case SID_MAIL_SENDDOC:
     793             :             case SID_MAIL_SENDDOCASFORMAT:
     794             :             case SID_MAIL_SENDDOCASMS:
     795             :             case SID_MAIL_SENDDOCASOOO:
     796             :             case SID_MAIL_SENDDOCASPDF:
     797             :                 rSet.DisableItem(nSID);
     798             :                 break;
     799             : #endif
     800             :             // Printer functions
     801             :             case SID_PRINTDOC:
     802             :             case SID_PRINTDOCDIRECT:
     803             :             case SID_SETUPPRINTER:
     804             :             case SID_PRINTER_NAME:
     805             :             {
     806        3122 :                 bool bEnabled = pImp->m_bCanPrint && !pImp->m_nPrinterLocks;
     807        3122 :                 bEnabled = bEnabled  && !Application::GetSettings().GetMiscSettings().GetDisablePrinting();
     808        3122 :                 if ( bEnabled )
     809             :                 {
     810        3122 :                     SfxPrinter *pPrinter = GetPrinter(false);
     811             : 
     812        3122 :                     if ( SID_PRINTDOCDIRECT == nSID )
     813             :                     {
     814        1562 :                         OUString aPrinterName;
     815        1562 :                         if ( pPrinter != NULL )
     816          90 :                             aPrinterName = pPrinter->GetName();
     817             :                         else
     818        1472 :                             aPrinterName = Printer::GetDefaultPrinterName();
     819        1562 :                         if ( !aPrinterName.isEmpty() )
     820             :                         {
     821        1562 :                             uno::Reference < frame::XFrame > xFrame( pFrame->GetFrame().GetFrameInterface() );
     822             : 
     823        3124 :                             OUStringBuffer aBuffer( 60 );
     824             :                             aBuffer.append( RetrieveLabelFromCommand(
     825             :                                 OUString( ".uno:PrintDefault" ),
     826        1562 :                                 xFrame ));
     827        1562 :                             aBuffer.append( " (" );
     828        1562 :                             aBuffer.append( aPrinterName );
     829        1562 :                             aBuffer.append(')');
     830             : 
     831        3124 :                             rSet.Put( SfxStringItem( SID_PRINTDOCDIRECT, aBuffer.makeStringAndClear() ) );
     832        1562 :                         }
     833             :                     }
     834        3122 :                     bEnabled = !pPrinter || !pPrinter->IsPrinting();
     835             :                 }
     836        3122 :                 break;
     837             :             }
     838             : 
     839             :             // PlugIns running
     840             :             case SID_PLUGINS_ACTIVE:
     841             :             {
     842          18 :                 rSet.Put( SfxBoolItem( SID_PLUGINS_ACTIVE, !pImp->m_bPlugInsActive) );
     843          18 :                 break;
     844             :             }
     845             :             case SID_STYLE_FAMILY :
     846             :             {
     847        8678 :                 rSet.Put( SfxUInt16Item( SID_STYLE_FAMILY, pImp->m_nFamily ) );
     848        8678 :                 break;
     849             :             }
     850             :         }
     851       12850 :     }
     852       12850 : }
     853             : 
     854             : 
     855             : 
     856           0 : void SfxViewShell::SetZoomFactor( const Fraction &rZoomX,
     857             :     const Fraction &rZoomY )
     858             : {
     859             :     DBG_ASSERT( GetWindow(), "no window" );
     860           0 :     MapMode aMap( GetWindow()->GetMapMode() );
     861           0 :     aMap.SetScaleX( rZoomX );
     862           0 :     aMap.SetScaleY( rZoomY );
     863           0 :     GetWindow()->SetMapMode( aMap );
     864           0 : }
     865             : 
     866             : 
     867           0 : ErrCode SfxViewShell::DoVerb(long /*nVerb*/)
     868             : 
     869             : /*  [Description]
     870             : 
     871             :     Virtual Method used to perform a Verb on a selected Object.
     872             :     Since this Object is just known by the derived classes, DoVerb
     873             :     must be overloaded.
     874             : */
     875             : 
     876             : {
     877           0 :     return ERRCODE_SO_NOVERBS;
     878             : }
     879             : 
     880             : 
     881             : 
     882           4 : void SfxViewShell::OutplaceActivated( bool bActive, SfxInPlaceClient* /*pClient*/ )
     883             : {
     884           4 :     if ( !bActive )
     885           2 :         GetFrame()->GetFrame().Appear();
     886           4 : }
     887             : 
     888             : 
     889             : 
     890           2 : void SfxViewShell::InplaceActivating( SfxInPlaceClient* /*pClient*/ )
     891             : {
     892             :     // TODO/LATER: painting of the bitmap can be stopped, it is required if CLIPCHILDREN problem #i25788# is not solved,
     893             :     // but may be the bug will not affect the real office vcl windows, then it is not required
     894           2 : }
     895             : 
     896             : 
     897             : 
     898           2 : void SfxViewShell::InplaceDeactivated( SfxInPlaceClient* /*pClient*/ )
     899             : {
     900             :     // TODO/LATER: paint the replacement image in normal way if the painting was stopped
     901           2 : }
     902             : 
     903             : 
     904             : 
     905           2 : void SfxViewShell::UIActivating( SfxInPlaceClient* /*pClient*/ )
     906             : {
     907           2 :     uno::Reference < frame::XFrame > xOwnFrame( pFrame->GetFrame().GetFrameInterface() );
     908           4 :     uno::Reference < frame::XFramesSupplier > xParentFrame( xOwnFrame->getCreator(), uno::UNO_QUERY );
     909           2 :     if ( xParentFrame.is() )
     910           2 :         xParentFrame->setActiveFrame( xOwnFrame );
     911             : 
     912           2 :     pFrame->GetBindings().HidePopups(true);
     913           4 :     pFrame->GetDispatcher()->Update_Impl( true );
     914           2 : }
     915             : 
     916             : 
     917             : 
     918           2 : void SfxViewShell::UIDeactivated( SfxInPlaceClient* /*pClient*/ )
     919             : {
     920           2 :     if ( !pFrame->GetFrame().IsClosing_Impl() || SfxViewFrame::Current() != pFrame )
     921           0 :         pFrame->GetDispatcher()->Update_Impl( true );
     922           2 :     pFrame->GetBindings().HidePopups(false);
     923             : 
     924           2 :     pFrame->GetBindings().InvalidateAll(true);
     925           2 : }
     926             : 
     927             : 
     928             : 
     929        1684 : SfxInPlaceClient* SfxViewShell::FindIPClient
     930             : (
     931             :     const uno::Reference < embed::XEmbeddedObject >& xObj,
     932             :     vcl::Window*             pObjParentWin
     933             : )   const
     934             : {
     935        1684 :     SfxInPlaceClientList *pClients = GetIPClientList_Impl(false);
     936        1684 :     if ( !pClients )
     937        1664 :         return 0;
     938             : 
     939          20 :     if( !pObjParentWin )
     940           0 :         pObjParentWin = GetWindow();
     941          24 :     for ( size_t n = 0; n < pClients->size(); n++)
     942             :     {
     943          22 :         SfxInPlaceClient *pIPClient = (SfxInPlaceClient*) pClients->at( n );
     944          22 :         if ( pIPClient->GetObject() == xObj && pIPClient->GetEditWin() == pObjParentWin )
     945          18 :             return pIPClient;
     946             :     }
     947             : 
     948           2 :     return 0;
     949             : }
     950             : 
     951             : 
     952             : 
     953       41582 : SfxInPlaceClient* SfxViewShell::GetIPClient() const
     954             : {
     955       41582 :     return GetUIActiveClient();
     956             : }
     957             : 
     958             : 
     959             : 
     960       20808 : SfxInPlaceClient* SfxViewShell::GetUIActiveIPClient_Impl() const
     961             : {
     962             :     // this method is needed as long as SFX still manages the border space for ChildWindows (see SfxFrame::Resize)
     963       20808 :     SfxInPlaceClientList *pClients = GetIPClientList_Impl(false);
     964       20808 :     if ( !pClients )
     965       20804 :         return 0;
     966             : 
     967           4 :     for ( size_t n = 0; n < pClients->size(); n++)
     968             :     {
     969           4 :         SfxInPlaceClient* pIPClient = pClients->at( n );
     970           4 :         if ( pIPClient->IsUIActive() )
     971           4 :             return pIPClient;
     972             :     }
     973             : 
     974           0 :     return NULL;
     975             : }
     976             : 
     977      331891 : SfxInPlaceClient* SfxViewShell::GetUIActiveClient() const
     978             : {
     979      331891 :     SfxInPlaceClientList *pClients = GetIPClientList_Impl(false);
     980      331891 :     if ( !pClients )
     981      331143 :         return 0;
     982             : 
     983        1438 :     for ( size_t n = 0; n < pClients->size(); n++)
     984             :     {
     985         830 :         SfxInPlaceClient* pIPClient = pClients->at( n );
     986         830 :         if ( pIPClient->IsObjectUIActive() )
     987         140 :             return pIPClient;
     988             :     }
     989             : 
     990         608 :     return NULL;
     991             : }
     992             : 
     993             : 
     994             : 
     995        5454 : void SfxViewShell::Activate( bool bMDI )
     996             : {
     997        5454 :     if ( bMDI )
     998             :     {
     999        5454 :         SfxObjectShell *pSh = GetViewFrame()->GetObjectShell();
    1000        5454 :         if ( pSh->GetModel().is() )
    1001        5454 :             pSh->GetModel()->setCurrentController( GetViewFrame()->GetFrame().GetController() );
    1002             : 
    1003        5454 :         SetCurrentDocument();
    1004             :     }
    1005        5454 : }
    1006             : 
    1007             : 
    1008             : 
    1009        5454 : void SfxViewShell::Deactivate(bool /*bMDI*/)
    1010             : {
    1011        5454 : }
    1012             : 
    1013             : 
    1014             : 
    1015           0 : void SfxViewShell::AdjustPosSizePixel
    1016             : (
    1017             :     const Point&    /*rToolOffset*/,// Upper left corner Tools in Frame-Window
    1018             :     const Size&     /*rSize*/       // All available sizes.
    1019             : )
    1020             : 
    1021             : {
    1022           0 : }
    1023             : 
    1024             : 
    1025             : 
    1026           0 : void SfxViewShell::Move()
    1027             : 
    1028             : /*  [Description]
    1029             : 
    1030             :     This virtual Method is called when the window displayed in the
    1031             :     SfxViewShell gets a StarView-Move() notification.
    1032             : 
    1033             :     This base implementation does not have to be called.     .
    1034             : 
    1035             :     [Note]
    1036             : 
    1037             :     This Method can be used to cancel a selection, in order to catch the
    1038             :     mouse movement which is due to moving a window.
    1039             : 
    1040             :     For now the notification does not work In-Place.
    1041             : */
    1042             : 
    1043             : {
    1044           0 : }
    1045             : 
    1046             : 
    1047             : 
    1048           0 : void SfxViewShell::OuterResizePixel
    1049             : (
    1050             :     const Point&    /*rToolOffset*/,// Upper left corner Tools in Frame-Window
    1051             :     const Size&     /*rSize*/       // All available sizes.
    1052             : )
    1053             : 
    1054             : /*  [Description]
    1055             : 
    1056             :     This Method has to be overloaded to be able to react to the size-change of
    1057             :     the View. Thus the View is defined as the Edit window and also the
    1058             :     attached Tools are defined (for example the ruler).
    1059             : 
    1060             :     The Edit window must not be changed either in size or position.
    1061             : 
    1062             :     The Vis-Area of SfxObjectShell, its scale and position can be changed
    1063             :     here. The mainuse is to change the size of the Vis-Area.
    1064             : 
    1065             :     If the Border is changed due to the new calculation then this has to be set
    1066             :     by <SfxViewShell::SetBorderPixel(const SvBorder&)>. The Positioning of Tools
    1067             :     is only allowed after the calling of 'SetBorderPixel'.
    1068             : 
    1069             :     [Example]
    1070             : 
    1071             :     void AppViewSh::OuterViewResizePixel( const Point &rOfs, const Size &rSz )
    1072             :     {
    1073             :         // Calculate Tool position and size externally, do not set!
    1074             :         // (due to the following Border calculation)
    1075             :         Point aHLinPos...; Size aHLinSz...;
    1076             :         ...
    1077             : 
    1078             :         // Calculate and Set a Border of Tools which matches rSize.
    1079             :         SvBorder aBorder...
    1080             :         SetBorderPixel( aBorder ); // Allow Positioning from here on.
    1081             : 
    1082             :         // Arrange Tools
    1083             :         pHLin->SetPosSizePixel( aHLinPos, aHLinSz );
    1084             :         ...
    1085             :     }
    1086             : 
    1087             :     [Cross-reference]
    1088             : 
    1089             :         <SfxViewShell::InnerResizePixel(const Point&,const Size& rSize)>
    1090             : */
    1091             : 
    1092             : {
    1093           0 :     SetBorderPixel( SvBorder() );
    1094           0 : }
    1095             : 
    1096             : 
    1097             : 
    1098           0 : void SfxViewShell::InnerResizePixel
    1099             : (
    1100             :     const Point&    /*rToolOffset*/,// Upper left corner Tools in Frame-Window
    1101             :     const Size&     /*rSize*/       // All available sizes.
    1102             : )
    1103             : 
    1104             : /*  [Description]
    1105             : 
    1106             :     This Method has to be overloaded to be able to react to the size-change of
    1107             :     the Edit window.
    1108             : 
    1109             :     The Edit window must not be changed either in size or position.
    1110             :     Neither the Vis-Area of SfxObjectShell nor its scale or position are
    1111             :     allowed to be changed
    1112             : 
    1113             :     If the Border is changed due to the new calculation then is has to be set
    1114             :     by <SfxViewShell::SetBorderPixel(const SvBorder&)>.
    1115             :     The Positioning of Tools is only allowed after the calling of
    1116             :     'SetBorderPixel'.
    1117             : 
    1118             : 
    1119             :     [Note]
    1120             : 
    1121             :     void AppViewSh::InnerViewResizePixel( const Point &rOfs, const Size &rSz )
    1122             :     {
    1123             :         // Calculate Tool position and size internally, do not set!
    1124             :         // (due to the following Border calculation)
    1125             :         Point aHLinPos...; Size aHLinSz...;
    1126             :         ...
    1127             : 
    1128             :         // Calculate and Set a Border of Tools which matches rSize.
    1129             :         SvBorder aBorder...
    1130             :         SetBorderPixel( aBorder ); // Allow Positioning from here on.
    1131             : 
    1132             :         // Arrange Tools
    1133             :         pHLin->SetPosSizePixel( aHLinPos, aHLinSz );
    1134             :         ...
    1135             :     }
    1136             : 
    1137             :     [Cross-reference]
    1138             : 
    1139             :         <SfxViewShell::OuterResizePixel(const Point&,const Size& rSize)>
    1140             : */
    1141             : 
    1142             : {
    1143           0 :     SetBorderPixel( SvBorder() );
    1144           0 : }
    1145             : 
    1146             : 
    1147             : 
    1148       14878 : void SfxViewShell::InvalidateBorder()
    1149             : {
    1150             :     DBG_ASSERT( GetViewFrame(), "SfxViewShell without SfxViewFrame" );
    1151             : 
    1152       14878 :     GetViewFrame()->InvalidateBorderImpl( this );
    1153       14878 :     if (pImp->m_pController.is())
    1154             :     {
    1155       14878 :         pImp->m_pController->BorderWidthsChanged_Impl();
    1156             :     }
    1157       14878 : }
    1158             : 
    1159             : 
    1160             : 
    1161       25937 : void SfxViewShell::SetBorderPixel( const SvBorder &rBorder )
    1162             : {
    1163             :     DBG_ASSERT( GetViewFrame(), "SfxViewShell without SfxViewFrame" );
    1164             : 
    1165       25937 :     GetViewFrame()->SetBorderPixelImpl( this, rBorder );
    1166             : 
    1167             :     // notify related controller that border size is changed
    1168       25937 :     if (pImp->m_pController.is())
    1169             :     {
    1170       25391 :         pImp->m_pController->BorderWidthsChanged_Impl();
    1171             :     }
    1172       25937 : }
    1173             : 
    1174             : 
    1175             : 
    1176         973 : const SvBorder& SfxViewShell::GetBorderPixel() const
    1177             : {
    1178             :     DBG_ASSERT( GetViewFrame(), "SfxViewShell without SfxViewFrame" );
    1179             : 
    1180         973 :     return GetViewFrame()->GetBorderPixelImpl( this );
    1181             : }
    1182             : 
    1183             : 
    1184             : 
    1185       11713 : void SfxViewShell::SetWindow
    1186             : (
    1187             :     vcl::Window*     pViewPort   // For example Null pointer in the Destructor.
    1188             : )
    1189             : 
    1190             : /*  [Description]
    1191             : 
    1192             :     With this method the SfxViewShell is set in the data window. This is
    1193             :     needed for the in-place container and for restoring the proper focus.
    1194             : 
    1195             :     Even in-place-active the conversion of the ViewPort Windows is forbidden.
    1196             : */
    1197             : 
    1198             : {
    1199       11713 :     if( pWindow == pViewPort )
    1200       12402 :         return;
    1201             : 
    1202             :     // Disconnect existing IP-Clients if possible
    1203       11024 :     DisconnectAllClients();
    1204             : 
    1205             :     //TODO: should we have a "ReconnectAllClients" method?
    1206       11024 :     DiscardClients_Impl();
    1207             : 
    1208             :     // Switch View-Port
    1209       11024 :     bool bHadFocus = pWindow && pWindow->HasChildPathFocus( true );
    1210       11024 :     pWindow = pViewPort;
    1211             : 
    1212       11024 :     if( pWindow )
    1213             :     {
    1214             :         // Disable automatic GUI mirroring (right-to-left) for document windows
    1215        5544 :         pWindow->EnableRTL( false );
    1216             :     }
    1217             : 
    1218       11024 :     if ( bHadFocus && pWindow )
    1219          20 :         pWindow->GrabFocus();
    1220             :     //TODO/CLEANUP
    1221             :     //Do we still need this Method?!
    1222             :     //SfxGetpApp()->GrabFocus( pWindow );
    1223             : }
    1224             : 
    1225             : 
    1226             : 
    1227        5524 : SfxViewShell::SfxViewShell
    1228             : (
    1229             :     SfxViewFrame*   pViewFrame,     /*  <SfxViewFrame>, which will be
    1230             :                                         displayed in this View */
    1231             :     sal_uInt16          nFlags          /*  See <SfxViewShell-Flags> */
    1232             : )
    1233             : 
    1234             : :   SfxShell(this)
    1235        5524 : ,   pImp( new SfxViewShell_Impl(nFlags) )
    1236             : ,   pIPClientList( 0 )
    1237             : ,   pFrame(pViewFrame)
    1238             : ,   pSubShell(0)
    1239             : ,   pWindow(0)
    1240       11048 : ,   bNoNewWindow( 0 != (nFlags & SFX_VIEW_NO_NEWWINDOW) )
    1241             : {
    1242             : 
    1243        5524 :     if ( pViewFrame->GetParentViewFrame() )
    1244             :     {
    1245           0 :         pImp->m_bPlugInsActive = pViewFrame->GetParentViewFrame()
    1246           0 :             ->GetViewShell()->pImp->m_bPlugInsActive;
    1247             :     }
    1248        5524 :     SetMargin( pViewFrame->GetMargin_Impl() );
    1249             : 
    1250        5524 :     SetPool( &pViewFrame->GetObjectShell()->GetPool() );
    1251        5524 :     StartListening(*pViewFrame->GetObjectShell());
    1252             : 
    1253             :     // Insert into list
    1254        5524 :     SfxViewShellArr_Impl &rViewArr = SfxGetpApp()->GetViewShells_Impl();
    1255        5524 :     rViewArr.push_back(this);
    1256        5524 : }
    1257             : 
    1258             : 
    1259             : 
    1260       11044 : SfxViewShell::~SfxViewShell()
    1261             : {
    1262             : 
    1263             :     // Remove from list
    1264        5522 :     const SfxViewShell *pThis = this;
    1265        5522 :     SfxViewShellArr_Impl &rViewArr = SfxGetpApp()->GetViewShells_Impl();
    1266        5522 :     SfxViewShellArr_Impl::iterator it = std::find( rViewArr.begin(), rViewArr.end(), pThis );
    1267        5522 :     rViewArr.erase( it );
    1268             : 
    1269        5522 :     if ( pImp->xClipboardListener.is() )
    1270             :     {
    1271        5522 :         pImp->xClipboardListener->DisconnectViewShell();
    1272        5522 :         pImp->xClipboardListener = NULL;
    1273             :     }
    1274             : 
    1275        5522 :     if (pImp->m_pController.is())
    1276             :     {
    1277        5522 :         pImp->m_pController->ReleaseShell_Impl();
    1278        5522 :         pImp->m_pController.clear();
    1279             :     }
    1280             : 
    1281        5522 :     DELETEZ( pImp );
    1282        5522 :     DELETEZ( pIPClientList );
    1283        5522 : }
    1284             : 
    1285        5524 : void SfxViewShell::Initialize()
    1286             : {
    1287             :     // overloaded by the application.
    1288        5524 : }
    1289             : 
    1290       10798 : bool SfxViewShell::PrepareClose
    1291             : (
    1292             :     bool bUI     // TRUE: Allow Dialog and so on, FALSE: silent-mode
    1293             : )
    1294             : {
    1295       10798 :     SfxPrinter *pPrinter = GetPrinter();
    1296       10798 :     if ( pPrinter && pPrinter->IsPrinting() )
    1297             :     {
    1298           0 :         if ( bUI )
    1299             :         {
    1300           0 :             MessageDialog aInfoBox( &GetViewFrame()->GetWindow(), SfxResId( STR_CANT_CLOSE ), VCL_MESSAGE_INFO );
    1301           0 :             aInfoBox.Execute();
    1302             :         }
    1303             : 
    1304           0 :         return false;
    1305             :     }
    1306             : 
    1307       10798 :     if( GetViewFrame()->IsInModalMode() )
    1308           0 :         return false;
    1309             : 
    1310       10798 :     if( bUI && GetViewFrame()->GetDispatcher()->IsLocked() )
    1311           0 :         return false;
    1312             : 
    1313       10798 :     return true;
    1314             : }
    1315             : 
    1316             : 
    1317             : 
    1318      122522 : SfxViewShell* SfxViewShell::Current()
    1319             : {
    1320      122522 :     SfxViewFrame *pCurrent = SfxViewFrame::Current();
    1321      122522 :     return pCurrent ? pCurrent->GetViewShell() : NULL;
    1322             : }
    1323             : 
    1324             : 
    1325             : 
    1326        5572 : SfxViewShell* SfxViewShell::Get( const Reference< XController>& i_rController )
    1327             : {
    1328        5572 :     if ( !i_rController.is() )
    1329        5508 :         return NULL;
    1330             : 
    1331         160 :     for (   SfxViewShell* pViewShell = SfxViewShell::GetFirst( NULL, false );
    1332             :             pViewShell;
    1333             :             pViewShell = SfxViewShell::GetNext( *pViewShell, NULL, false )
    1334             :         )
    1335             :     {
    1336         160 :         if ( pViewShell->GetController() == i_rController )
    1337          64 :             return pViewShell;
    1338             :     }
    1339           0 :     return NULL;
    1340             : }
    1341             : 
    1342             : 
    1343             : 
    1344         212 : SdrView* SfxViewShell::GetDrawView() const
    1345             : 
    1346             : /*  [Description]
    1347             : 
    1348             :     This virtual Method has to be overloded by the sub classes, to be able
    1349             :     make the Property-Editor available.
    1350             : 
    1351             :     The default implementation does always return zero.
    1352             : */
    1353             : 
    1354             : {
    1355         212 :     return 0;
    1356             : }
    1357             : 
    1358             : 
    1359             : 
    1360           0 : OUString SfxViewShell::GetSelectionText
    1361             : (
    1362             :     bool /*bCompleteWords*/ /*  FALSE (default)
    1363             :                                 Only the actual selected text is returned.
    1364             : 
    1365             :                                 TRUE
    1366             :                                 The selected text is expanded so that only
    1367             :                                 whole words are returned. As word separators
    1368             :                                 these are used: white spaces and punctuation
    1369             :                                 ".,;" and single and double quotes.
    1370             :                             */
    1371             : )
    1372             : 
    1373             : /*  [Description]
    1374             : 
    1375             :     This Method can be overloaded by the programmers to return a text that
    1376             :     is included in the current selection. This is for example used when
    1377             :     sending emails.
    1378             : 
    1379             :     When called with "CompleteWords == TRUE", it is for example sufficent
    1380             :     with having the Cursor positioned somewhere within an URL in-order
    1381             :     to have the entire URL returned.
    1382             : */
    1383             : 
    1384             : {
    1385           0 :     return OUString();
    1386             : }
    1387             : 
    1388             : 
    1389             : 
    1390           0 : bool SfxViewShell::HasSelection( bool ) const
    1391             : 
    1392             : /*  [Description]
    1393             : 
    1394             :     With this virtual Method can a for example a Dialog be queried, to
    1395             :     check if something is selected in the current view. If the Parameter
    1396             :     is <BOOL> TRUE then it is checked whether some text is selected.
    1397             : */
    1398             : 
    1399             : {
    1400           0 :     return false;
    1401             : }
    1402             : 
    1403        2358 : void SfxViewShell::AddSubShell( SfxShell& rShell )
    1404             : {
    1405        2358 :     pImp->aArr.push_back(&rShell);
    1406        2358 :     SfxDispatcher *pDisp = pFrame->GetDispatcher();
    1407        2358 :     if ( pDisp->IsActive(*this) )
    1408             :     {
    1409         418 :         pDisp->Push(rShell);
    1410         418 :         pDisp->Flush();
    1411             :     }
    1412        2358 : }
    1413             : 
    1414        2214 : void SfxViewShell::RemoveSubShell( SfxShell* pShell )
    1415             : {
    1416        2214 :     SfxDispatcher *pDisp = pFrame->GetDispatcher();
    1417        2214 :     if ( !pShell )
    1418             :     {
    1419         988 :         size_t nCount = pImp->aArr.size();
    1420         988 :         if ( pDisp->IsActive(*this) )
    1421             :         {
    1422         268 :             for(size_t n = nCount; n > 0; --n)
    1423          38 :                 pDisp->Pop(*pImp->aArr[n - 1]);
    1424         230 :             pDisp->Flush();
    1425             :         }
    1426         988 :         pImp->aArr.clear();
    1427             :     }
    1428             :     else
    1429             :     {
    1430        1226 :         SfxShellArr_Impl::iterator i = std::find(pImp->aArr.begin(), pImp->aArr.end(), pShell);
    1431        1226 :         if(i != pImp->aArr.end())
    1432             :         {
    1433        1226 :             pImp->aArr.erase(i);
    1434        1226 :             if(pDisp->IsActive(*this))
    1435             :             {
    1436        1014 :                 pDisp->RemoveShell_Impl(*pShell);
    1437        1014 :                 pDisp->Flush();
    1438             :             }
    1439             :         }
    1440             :     }
    1441        2214 : }
    1442             : 
    1443       13706 : SfxShell* SfxViewShell::GetSubShell( sal_uInt16 nNo )
    1444             : {
    1445       13706 :     sal_uInt16 nCount = pImp->aArr.size();
    1446       13706 :     if(nNo < nCount)
    1447       10936 :         return pImp->aArr[nCount - nNo - 1];
    1448        2770 :     return NULL;
    1449             : }
    1450             : 
    1451       11046 : void SfxViewShell::PushSubShells_Impl( bool bPush )
    1452             : {
    1453       11046 :     SfxDispatcher *pDisp = pFrame->GetDispatcher();
    1454       11046 :     if ( bPush )
    1455             :     {
    1456        7252 :         for(SfxShellArr_Impl::const_iterator i = pImp->aArr.begin(); i != pImp->aArr.end(); ++i)
    1457        1728 :             pDisp->Push(**i);
    1458             :     }
    1459        5522 :     else if(!pImp->aArr.empty())
    1460             :     {
    1461         546 :         SfxShell& rPopUntil = *pImp->aArr[0];
    1462         546 :         if ( pDisp->GetShellLevel( rPopUntil ) != USHRT_MAX )
    1463         546 :             pDisp->Pop( rPopUntil, SFX_SHELL_POP_UNTIL );
    1464             :     }
    1465             : 
    1466       11046 :     pDisp->Flush();
    1467       11046 : }
    1468             : 
    1469             : 
    1470             : 
    1471           0 : void SfxViewShell::WriteUserData( OUString&, bool )
    1472             : {
    1473           0 : }
    1474             : 
    1475             : 
    1476             : 
    1477           0 : void SfxViewShell::ReadUserData(const OUString&, bool )
    1478             : {
    1479           0 : }
    1480             : 
    1481           0 : void SfxViewShell::ReadUserDataSequence ( const uno::Sequence < beans::PropertyValue >&, bool )
    1482             : {
    1483           0 : }
    1484             : 
    1485          34 : void SfxViewShell::WriteUserDataSequence ( uno::Sequence < beans::PropertyValue >&, bool )
    1486             : {
    1487          34 : }
    1488             : 
    1489             : 
    1490             : 
    1491             : // returns the first shell of spec. type viewing the specified doc.
    1492             : 
    1493        1677 : SfxViewShell* SfxViewShell::GetFirst
    1494             : (
    1495             :     const TypeId* pType,
    1496             :     bool          bOnlyVisible
    1497             : )
    1498             : {
    1499             :     // search for a SfxViewShell of the specified type
    1500        1677 :     SfxViewShellArr_Impl &rShells = SfxGetpApp()->GetViewShells_Impl();
    1501        1677 :     SfxViewFrameArr_Impl &rFrames = SfxGetpApp()->GetViewFrames_Impl();
    1502        2102 :     for ( sal_uInt16 nPos = 0; nPos < rShells.size(); ++nPos )
    1503             :     {
    1504        1692 :         SfxViewShell *pShell = rShells[nPos];
    1505        1692 :         if ( pShell )
    1506             :         {
    1507             :             // sometimes dangling SfxViewShells exist that point to a dead SfxViewFrame
    1508             :             // these ViewShells shouldn't be accessible anymore
    1509             :             // a destroyed ViewFrame is not in the ViewFrame array anymore, so checking this array helps
    1510        1727 :             for ( sal_uInt16 n=0; n<rFrames.size(); ++n )
    1511             :             {
    1512        1727 :                 SfxViewFrame *pFrame = rFrames[n];
    1513        1727 :                 if ( pFrame == pShell->GetViewFrame() )
    1514             :                 {
    1515             :                     // only ViewShells with a valid ViewFrame will be returned
    1516        1692 :                     if ( ( !bOnlyVisible || pFrame->IsVisible() ) && ( !pType || pShell->IsA(*pType) ) )
    1517        1267 :                         return pShell;
    1518         425 :                     break;
    1519             :                 }
    1520             :             }
    1521             :         }
    1522             :     }
    1523             : 
    1524         410 :     return 0;
    1525             : }
    1526             : 
    1527             : 
    1528             : // returns the next shell of spec. type viewing the specified doc.
    1529             : 
    1530        1059 : SfxViewShell* SfxViewShell::GetNext
    1531             : (
    1532             :     const SfxViewShell& rPrev,
    1533             :     const TypeId*       pType,
    1534             :     bool                bOnlyVisible
    1535             : )
    1536             : {
    1537        1059 :     SfxViewShellArr_Impl &rShells = SfxGetpApp()->GetViewShells_Impl();
    1538        1059 :     SfxViewFrameArr_Impl &rFrames = SfxGetpApp()->GetViewFrames_Impl();
    1539             :     sal_uInt16 nPos;
    1540        1277 :     for ( nPos = 0; nPos < rShells.size(); ++nPos )
    1541        1277 :         if ( rShells[nPos] == &rPrev )
    1542        1059 :             break;
    1543             : 
    1544        1105 :     for ( ++nPos; nPos < rShells.size(); ++nPos )
    1545             :     {
    1546         204 :         SfxViewShell *pShell = rShells[nPos];
    1547         204 :         if ( pShell )
    1548             :         {
    1549             :             // sometimes dangling SfxViewShells exist that point to a dead SfxViewFrame
    1550             :             // these ViewShells shouldn't be accessible anymore
    1551             :             // a destroyed ViewFrame is not in the ViewFrame array anymore, so checking this array helps
    1552         538 :             for ( sal_uInt16 n=0; n<rFrames.size(); ++n )
    1553             :             {
    1554         538 :                 SfxViewFrame *pFrame = rFrames[n];
    1555         538 :                 if ( pFrame == pShell->GetViewFrame() )
    1556             :                 {
    1557             :                     // only ViewShells with a valid ViewFrame will be returned
    1558         204 :                     if ( ( !bOnlyVisible || pFrame->IsVisible() ) && ( !pType || pShell->IsA(*pType) ) )
    1559         158 :                         return pShell;
    1560          46 :                     break;
    1561             :                 }
    1562             :             }
    1563             :         }
    1564             :     }
    1565             : 
    1566         901 :     return 0;
    1567             : }
    1568             : 
    1569             : 
    1570             : 
    1571      292071 : void SfxViewShell::Notify( SfxBroadcaster& rBC,
    1572             :                             const SfxHint& rHint )
    1573             : {
    1574      292071 :     const SfxEventHint* pEventHint = dynamic_cast<const SfxEventHint*>(&rHint);
    1575      292071 :     if ( pEventHint )
    1576             :     {
    1577       39908 :         switch ( pEventHint->GetEventId() )
    1578             :         {
    1579             :             case SFX_EVENT_LOADFINISHED:
    1580             :             {
    1581          24 :                 if ( GetController().is() )
    1582             :                 {
    1583             :                     // avoid access to dangling ViewShells
    1584          24 :                     SfxViewFrameArr_Impl &rFrames = SfxGetpApp()->GetViewFrames_Impl();
    1585          46 :                     for ( sal_uInt16 n=0; n<rFrames.size(); ++n )
    1586             :                     {
    1587          24 :                         SfxViewFrame *frame = rFrames[n];
    1588          24 :                         if ( frame == GetViewFrame() && &rBC == GetObjectShell() )
    1589             :                         {
    1590           2 :                             SfxItemSet* pSet = GetObjectShell()->GetMedium()->GetItemSet();
    1591           2 :                             SFX_ITEMSET_ARG( pSet, pItem, SfxUnoAnyItem, SID_VIEW_DATA, false );
    1592           2 :                             if ( pItem )
    1593             :                             {
    1594           0 :                                 pImp->m_pController->restoreViewData( pItem->GetValue() );
    1595           0 :                                 pSet->ClearItem( SID_VIEW_DATA );
    1596             :                             }
    1597             : 
    1598           2 :                             break;
    1599             :                         }
    1600             :                     }
    1601             :                 }
    1602             : 
    1603          24 :                 break;
    1604             :             }
    1605             :         }
    1606             :     }
    1607      292071 : }
    1608             : 
    1609             : 
    1610             : 
    1611           0 : bool SfxViewShell::ExecKey_Impl(const KeyEvent& aKey)
    1612             : {
    1613           0 :     if (!pImp->m_pAccExec.get())
    1614             :     {
    1615             :         pImp->m_pAccExec.reset(
    1616           0 :             ::svt::AcceleratorExecute::createAcceleratorHelper() );
    1617           0 :         pImp->m_pAccExec->init(::comphelper::getProcessComponentContext(),
    1618           0 :             pFrame->GetFrame().GetFrameInterface());
    1619             :     }
    1620             : 
    1621           0 :     return pImp->m_pAccExec->execute(aKey.GetKeyCode());
    1622             : }
    1623             : 
    1624             : 
    1625             : 
    1626           0 : bool SfxViewShell::KeyInput( const KeyEvent &rKeyEvent )
    1627             : 
    1628             : /*  [Description]
    1629             : 
    1630             :     This Method executes the KeyEvent 'rKeyEvent' of the Keys (Accelerator)
    1631             :     configured either direct or indirect (for example by the Application)
    1632             :     in the SfxViewShell.
    1633             : 
    1634             :     [Return value]
    1635             : 
    1636             :     bool                    TRUE
    1637             :                             The Key (Accelerator) is configured and the
    1638             :                             the associated Handler was called
    1639             : 
    1640             :                             FALSE
    1641             :                             The Key (Accelerator) is not configured and
    1642             :                             subsequently no Handler was called
    1643             : 
    1644             :     [Cross-reference]
    1645             : 
    1646             :     <SfxApplication::KeyInput(const KeyEvent&)>
    1647             : */
    1648             : {
    1649           0 :     return ExecKey_Impl(rKeyEvent);
    1650             : }
    1651             : 
    1652           0 : bool SfxViewShell::GlobalKeyInput_Impl( const KeyEvent &rKeyEvent )
    1653             : {
    1654           0 :     return ExecKey_Impl(rKeyEvent);
    1655             : }
    1656             : 
    1657             : 
    1658             : 
    1659           8 : void SfxViewShell::ShowCursor( bool /*bOn*/ )
    1660             : 
    1661             : /*  [Description]
    1662             : 
    1663             :     This Method has to be overloaded by the subclasses so that SFx from
    1664             :     the Cursor can be switched on and off. This happes for example with
    1665             :     with the running <SfxProgress>.
    1666             : */
    1667             : 
    1668             : {
    1669           8 : }
    1670             : 
    1671             : 
    1672             : 
    1673         605 : void SfxViewShell::GotFocus() const
    1674             : 
    1675             : /*  [Description]
    1676             : 
    1677             :     This Method has to be called by the programmer, when the
    1678             :     Edit window has received the focus. This gives for example the SFx
    1679             :     the power to turn on the accelerator.
    1680             : 
    1681             :     [Note]
    1682             : 
    1683             :     <StarView> does sadly enough not provide the possibillity to attach
    1684             :     such "side-way" events.
    1685             : */
    1686             : 
    1687             : {
    1688         605 : }
    1689             : 
    1690             : 
    1691           2 : void SfxViewShell::ResetAllClients_Impl( SfxInPlaceClient *pIP )
    1692             : {
    1693             : 
    1694           2 :     SfxInPlaceClientList *pClients = GetIPClientList_Impl(false);
    1695           2 :     if ( !pClients )
    1696           2 :         return;
    1697             : 
    1698           4 :     for ( size_t n = 0; n < pClients->size(); n++ )
    1699             :     {
    1700           2 :         SfxInPlaceClient* pIPClient = pClients->at( n );
    1701           2 :         if( pIPClient != pIP )
    1702           0 :             pIPClient->ResetObject();
    1703             :     }
    1704             : }
    1705             : 
    1706             : 
    1707             : 
    1708       17926 : void SfxViewShell::DisconnectAllClients()
    1709             : {
    1710       17926 :     SfxInPlaceClientList *pClients = GetIPClientList_Impl(false);
    1711       17926 :     if ( !pClients )
    1712       35816 :         return;
    1713             : 
    1714          72 :     for ( size_t n = 0; n < pClients->size(); )
    1715             :         // clients will remove themselves from the list
    1716           0 :         delete pClients->at( n );
    1717             : }
    1718             : 
    1719             : 
    1720             : 
    1721           0 : void SfxViewShell::QueryObjAreaPixel( Rectangle& ) const
    1722             : {
    1723           0 : }
    1724             : 
    1725             : 
    1726             : 
    1727       26378 : void SfxViewShell::VisAreaChanged(const Rectangle& /*rVisArea*/)
    1728             : {
    1729       26378 :     SfxInPlaceClientList *pClients = GetIPClientList_Impl(false);
    1730       26378 :     if ( !pClients )
    1731       52744 :         return;
    1732             : 
    1733          26 :     for ( size_t n = 0; n < pClients->size(); n++)
    1734             :     {
    1735          14 :         SfxInPlaceClient* pIPClient = pClients->at( n );
    1736          14 :         if ( pIPClient->IsObjectInPlaceActive() )
    1737             :             // client is active, notify client that the VisArea might have changed
    1738           4 :             pIPClient->VisAreaChanged();
    1739             :     }
    1740             : }
    1741             : 
    1742             : 
    1743           6 : void SfxViewShell::CheckIPClient_Impl( SfxInPlaceClient *pIPClient, const Rectangle& rVisArea )
    1744             : {
    1745           6 :     if ( GetObjectShell()->IsInClose() )
    1746           6 :         return;
    1747             : 
    1748             :     bool bAlwaysActive =
    1749           6 :         ( ( pIPClient->GetObjectMiscStatus() & embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY ) != 0 );
    1750             :     bool bActiveWhenVisible =
    1751          18 :         ( (( pIPClient->GetObjectMiscStatus() & embed::EmbedMisc::MS_EMBED_ACTIVATEWHENVISIBLE ) != 0 ) ||
    1752          18 :          svt::EmbeddedObjectRef::IsGLChart(pIPClient->GetObject()));
    1753             : 
    1754             :     // this method is called when either a client is created or the "Edit/Plugins" checkbox is checked
    1755           6 :     if ( !pIPClient->IsObjectInPlaceActive() && pImp->m_bPlugInsActive )
    1756             :     {
    1757             :         // object in client is currently not active
    1758             :         // check if the object wants to be activated always or when it becomes at least partially visible
    1759             :         // TODO/LATER: maybe we should use the scaled area instead of the ObjArea?!
    1760           6 :         if ( bAlwaysActive || (bActiveWhenVisible && rVisArea.IsOver(pIPClient->GetObjArea())) )
    1761             :         {
    1762             :             try
    1763             :             {
    1764           0 :                 pIPClient->GetObject()->changeState( embed::EmbedStates::INPLACE_ACTIVE );
    1765             :             }
    1766           0 :             catch (const uno::Exception&)
    1767             :             {
    1768             :             }
    1769             :         }
    1770             :     }
    1771           0 :     else if (!pImp->m_bPlugInsActive)
    1772             :     {
    1773             :         // object in client is currently active and "Edit/Plugins" checkbox is selected
    1774             :         // check if the object wants to be activated always or when it becomes at least partially visible
    1775             :         // in this case selecting of the "Edit/Plugin" checkbox should let such objects deactivate
    1776           0 :         if ( bAlwaysActive || bActiveWhenVisible )
    1777           0 :             pIPClient->GetObject()->changeState( embed::EmbedStates::RUNNING );
    1778             :     }
    1779             : }
    1780             : 
    1781             : 
    1782       22052 : void SfxViewShell::DiscardClients_Impl()
    1783             : 
    1784             : /*  [Description]
    1785             : 
    1786             :     The purpose of this Method is to prevent the saving of Objects when closing
    1787             :     the Document, if the user has chosen to close without saving.
    1788             : */
    1789             : 
    1790             : {
    1791       22052 :     SfxInPlaceClientList *pClients = GetIPClientList_Impl(false);
    1792       22052 :     if ( !pClients )
    1793       44050 :         return;
    1794             : 
    1795         128 :     for ( size_t n = 0; n < pClients->size(); )
    1796          20 :         delete pClients->at( n );
    1797             : }
    1798             : 
    1799             : 
    1800             : 
    1801      981235 : SfxObjectShell* SfxViewShell::GetObjectShell()
    1802             : {
    1803      981235 :     return pFrame ? pFrame->GetObjectShell() : NULL;
    1804             : }
    1805             : 
    1806             : 
    1807             : 
    1808       18383 : Reference< XModel > SfxViewShell::GetCurrentDocument() const
    1809             : {
    1810       18383 :     Reference< XModel > xDocument;
    1811             : 
    1812       18383 :     const SfxObjectShell* pDocShell( const_cast< SfxViewShell* >( this )->GetObjectShell() );
    1813             :     OSL_ENSURE( pDocShell, "SfxViewFrame::GetCurrentDocument: no DocShell!?" );
    1814       18383 :     if ( pDocShell )
    1815       18383 :         xDocument = pDocShell->GetModel();
    1816       18383 :     return xDocument;
    1817             : }
    1818             : 
    1819             : 
    1820             : 
    1821       18383 : void SfxViewShell::SetCurrentDocument() const
    1822             : {
    1823       18383 :     uno::Reference< frame::XModel > xDocument( GetCurrentDocument() );
    1824       18383 :     if ( xDocument.is() )
    1825       18383 :         SfxObjectShell::SetCurrentComponent( xDocument );
    1826       18383 : }
    1827             : 
    1828             : 
    1829             : 
    1830        4706 : const Size& SfxViewShell::GetMargin() const
    1831             : {
    1832        4706 :     return pImp->aMargin;
    1833             : }
    1834             : 
    1835             : 
    1836             : 
    1837        5524 : void SfxViewShell::SetMargin( const Size& rSize )
    1838             : {
    1839             :     // the default margin was verified using www.apple.com !!
    1840        5524 :     Size aMargin = rSize;
    1841        5524 :     if ( aMargin.Width() == -1 )
    1842        5524 :         aMargin.Width() = DEFAULT_MARGIN_WIDTH;
    1843        5524 :     if ( aMargin.Height() == -1 )
    1844        5524 :         aMargin.Height() = DEFAULT_MARGIN_HEIGHT;
    1845             : 
    1846        5524 :     if ( aMargin != pImp->aMargin )
    1847             :     {
    1848        5524 :         pImp->aMargin = aMargin;
    1849        5524 :         MarginChanged();
    1850             :     }
    1851        5524 : }
    1852             : 
    1853             : 
    1854             : 
    1855        5524 : void SfxViewShell::MarginChanged()
    1856             : {
    1857        5524 : }
    1858             : 
    1859             : 
    1860             : 
    1861        5524 : bool SfxViewShell::IsShowView_Impl() const
    1862             : {
    1863        5524 :     return pImp->m_bIsShowView;
    1864             : }
    1865             : 
    1866             : 
    1867             : 
    1868           0 : SfxFrame* SfxViewShell::GetSmartSelf( SfxFrame* pSelf, SfxMedium& /*rMedium*/ )
    1869             : {
    1870           0 :     return pSelf;
    1871             : }
    1872             : 
    1873             : 
    1874             : 
    1875           0 : void SfxViewShell::JumpToMark( const OUString& rMark )
    1876             : {
    1877           0 :     SfxStringItem aMarkItem( SID_JUMPTOMARK, rMark );
    1878             :     GetViewFrame()->GetDispatcher()->Execute(
    1879             :         SID_JUMPTOMARK,
    1880             :         SfxCallMode::SYNCHRON|SfxCallMode::RECORD,
    1881           0 :         &aMarkItem, 0L );
    1882           0 : }
    1883             : 
    1884             : 
    1885             : 
    1886      420781 : SfxInPlaceClientList* SfxViewShell::GetIPClientList_Impl( bool bCreate ) const
    1887             : {
    1888      420781 :     if ( !pIPClientList && bCreate )
    1889          18 :         ( (SfxViewShell*) this )->pIPClientList = new SfxInPlaceClientList;
    1890      420781 :     return pIPClientList;
    1891             : }
    1892             : 
    1893        5566 : void SfxViewShell::SetController( SfxBaseController* pController )
    1894             : {
    1895        5566 :     pImp->m_pController = pController;
    1896        5566 :     pImp->m_bControllerSet = true;
    1897             : 
    1898             :     // there should be no old listener, but if there is one, it should be disconnected
    1899        5566 :     if (  pImp->xClipboardListener.is() )
    1900          42 :         pImp->xClipboardListener->DisconnectViewShell();
    1901             : 
    1902        5566 :     pImp->xClipboardListener = new SfxClipboardChangeListener( this, GetClipboardNotifier() );
    1903        5566 : }
    1904             : 
    1905       48862 : Reference < XController > SfxViewShell::GetController()
    1906             : {
    1907       48862 :     return pImp->m_pController.get();
    1908             : }
    1909             : 
    1910        5524 : SfxBaseController* SfxViewShell::GetBaseController_Impl() const
    1911             : {
    1912        5524 :     return pImp->m_pController.get();
    1913             : }
    1914             : 
    1915           0 : void SfxViewShell::AddContextMenuInterceptor_Impl( const uno::Reference< ui::XContextMenuInterceptor >& xInterceptor )
    1916             : {
    1917           0 :     pImp->aInterceptorContainer.addInterface( xInterceptor );
    1918           0 : }
    1919             : 
    1920           0 : void SfxViewShell::RemoveContextMenuInterceptor_Impl( const uno::Reference< ui::XContextMenuInterceptor >& xInterceptor )
    1921             : {
    1922           0 :     pImp->aInterceptorContainer.removeInterface( xInterceptor );
    1923           0 : }
    1924             : 
    1925           0 : void Change( Menu* pMenu, SfxViewShell* pView )
    1926             : {
    1927           0 :     SfxDispatcher *pDisp = pView->GetViewFrame()->GetDispatcher();
    1928           0 :     sal_uInt16 nCount = pMenu->GetItemCount();
    1929           0 :     for ( sal_uInt16 nPos=0; nPos<nCount; ++nPos )
    1930             :     {
    1931           0 :         sal_uInt16 nId = pMenu->GetItemId(nPos);
    1932           0 :         OUString aCmd = pMenu->GetItemCommand(nId);
    1933           0 :         PopupMenu* pPopup = pMenu->GetPopupMenu(nId);
    1934           0 :         if ( pPopup )
    1935             :         {
    1936           0 :             Change( pPopup, pView );
    1937             :         }
    1938           0 :         else if ( nId < 5000 )
    1939             :         {
    1940           0 :             if ( aCmd.startsWith(".uno:") )
    1941             :             {
    1942           0 :                 for (sal_uInt16 nIdx=0;;)
    1943             :                 {
    1944           0 :                     SfxShell *pShell=pDisp->GetShell(nIdx++);
    1945           0 :                     if (pShell == NULL)
    1946           0 :                         break;
    1947           0 :                     const SfxInterface *pIFace = pShell->GetInterface();
    1948           0 :                     const SfxSlot* pSlot = pIFace->GetSlot( aCmd );
    1949           0 :                     if ( pSlot )
    1950             :                     {
    1951           0 :                         pMenu->InsertItem( pSlot->GetSlotId(), pMenu->GetItemText( nId ),
    1952           0 :                             pMenu->GetItemBits( nId ), OString(), nPos );
    1953           0 :                         pMenu->SetItemCommand( pSlot->GetSlotId(), aCmd );
    1954           0 :                         pMenu->RemoveItem( nPos+1 );
    1955           0 :                         break;
    1956             :                     }
    1957           0 :                 }
    1958             :             }
    1959             :         }
    1960           0 :     }
    1961           0 : }
    1962             : 
    1963             : 
    1964           0 : bool SfxViewShell::TryContextMenuInterception( Menu& rIn, const OUString& rMenuIdentifier, Menu*& rpOut, ui::ContextMenuExecuteEvent aEvent )
    1965             : {
    1966           0 :     rpOut = NULL;
    1967           0 :     bool bModified = false;
    1968             : 
    1969             :     // create container from menu
    1970           0 :     aEvent.ActionTriggerContainer = ::framework::ActionTriggerHelper::CreateActionTriggerContainerFromMenu(
    1971           0 :         &rIn, &rMenuIdentifier );
    1972             : 
    1973             :     // get selection from controller
    1974           0 :     aEvent.Selection = uno::Reference < view::XSelectionSupplier > ( GetController(), uno::UNO_QUERY );
    1975             : 
    1976             :     // call interceptors
    1977           0 :     ::cppu::OInterfaceIteratorHelper aIt( pImp->aInterceptorContainer );
    1978           0 :     while( aIt.hasMoreElements() )
    1979             :     {
    1980             :         try
    1981             :         {
    1982             :             ui::ContextMenuInterceptorAction eAction =
    1983           0 :                 static_cast<ui::XContextMenuInterceptor*>(aIt.next())->notifyContextMenuExecute( aEvent );
    1984           0 :             switch ( eAction )
    1985             :             {
    1986             :                 case ui::ContextMenuInterceptorAction_CANCELLED :
    1987             :                     // interceptor does not want execution
    1988           0 :                     return false;
    1989             :                 case ui::ContextMenuInterceptorAction_EXECUTE_MODIFIED :
    1990             :                     // interceptor wants his modified menu to be executed
    1991           0 :                     bModified = true;
    1992           0 :                     break;
    1993             :                 case ui::ContextMenuInterceptorAction_CONTINUE_MODIFIED :
    1994             :                     // interceptor has modified menu, but allows for calling other interceptors
    1995           0 :                     bModified = true;
    1996           0 :                     continue;
    1997             :                 case ui::ContextMenuInterceptorAction_IGNORED :
    1998             :                     // interceptor is indifferent
    1999           0 :                     continue;
    2000             :                 default:
    2001             :                     OSL_FAIL("Wrong return value of ContextMenuInterceptor!");
    2002           0 :                     continue;
    2003             :             }
    2004             :         }
    2005           0 :         catch (...)
    2006             :         {
    2007           0 :             aIt.remove();
    2008             :         }
    2009             : 
    2010           0 :         break;
    2011             :     }
    2012             : 
    2013           0 :     if ( bModified )
    2014             :     {
    2015             :         // container was modified, create a new window out of it
    2016           0 :         rpOut = new PopupMenu;
    2017           0 :         ::framework::ActionTriggerHelper::CreateMenuFromActionTriggerContainer( rpOut, aEvent.ActionTriggerContainer );
    2018             : 
    2019           0 :         Change( rpOut, this );
    2020             :     }
    2021             : 
    2022           0 :     return true;
    2023             : }
    2024             : 
    2025           0 : void SfxViewShell::TakeOwnership_Impl()
    2026             : {
    2027             :     // currently there is only one reason to take Ownership: a hidden frame is printed
    2028             :     // so the ViewShell will check this on EndPrint (->prnmon.cxx)
    2029           0 :     pImp->m_bGotOwnership = true;
    2030           0 : }
    2031             : 
    2032           0 : void SfxViewShell::TakeFrameOwnership_Impl()
    2033             : {
    2034             :     // currently there is only one reason to take Ownership: a hidden frame is printed
    2035             :     // so the ViewShell will check this on EndPrint (->prnmon.cxx)
    2036           0 :     pImp->m_bGotFrameOwnership = true;
    2037           0 : }
    2038             : 
    2039           0 : bool SfxViewShell::HandleNotifyEvent_Impl( NotifyEvent& rEvent )
    2040             : {
    2041           0 :     if (pImp->m_pController.is())
    2042           0 :         return pImp->m_pController->HandleEvent_Impl( rEvent );
    2043           0 :     return false;
    2044             : }
    2045             : 
    2046           0 : bool SfxViewShell::HasKeyListeners_Impl()
    2047             : {
    2048           0 :     return (pImp->m_pController.is())
    2049           0 :         && pImp->m_pController->HasKeyListeners_Impl();
    2050             : }
    2051             : 
    2052           0 : bool SfxViewShell::HasMouseClickListeners_Impl()
    2053             : {
    2054           0 :     return (pImp->m_pController.is())
    2055           0 :         && pImp->m_pController->HasMouseClickListeners_Impl();
    2056             : }
    2057             : 
    2058           0 : bool SfxViewShell::Escape()
    2059             : {
    2060           0 :     return GetViewFrame()->GetBindings().Execute( SID_TERMINATE_INPLACEACTIVATION );
    2061             : }
    2062             : 
    2063           0 : Reference< view::XRenderable > SfxViewShell::GetRenderable()
    2064             : {
    2065           0 :     Reference< view::XRenderable >xRender;
    2066           0 :     SfxObjectShell* pObj = GetObjectShell();
    2067           0 :     if( pObj )
    2068             :     {
    2069           0 :         Reference< frame::XModel > xModel( pObj->GetModel() );
    2070           0 :         if( xModel.is() )
    2071           0 :             xRender = Reference< view::XRenderable >( xModel, UNO_QUERY );
    2072             :     }
    2073           0 :     return xRender;
    2074             : }
    2075             : 
    2076        5566 : uno::Reference< datatransfer::clipboard::XClipboardNotifier > SfxViewShell::GetClipboardNotifier()
    2077             : {
    2078        5566 :     uno::Reference< datatransfer::clipboard::XClipboardNotifier > xClipboardNotifier;
    2079        5566 :     if ( GetViewFrame() )
    2080       11132 :         xClipboardNotifier = uno::Reference< datatransfer::clipboard::XClipboardNotifier >(
    2081       11132 :             GetViewFrame()->GetWindow().GetClipboard(), uno::UNO_QUERY );
    2082             : 
    2083        5566 :     return xClipboardNotifier;
    2084             : }
    2085             : 
    2086        1428 : void SfxViewShell::AddRemoveClipboardListener( const uno::Reference < datatransfer::clipboard::XClipboardListener >& rClp, bool bAdd )
    2087             : {
    2088             :     try
    2089             :     {
    2090        1428 :         if ( GetViewFrame() )
    2091             :         {
    2092        1428 :             uno::Reference< datatransfer::clipboard::XClipboard > xClipboard( GetViewFrame()->GetWindow().GetClipboard() );
    2093        1428 :             if( xClipboard.is() )
    2094             :             {
    2095        1428 :                 uno::Reference< datatransfer::clipboard::XClipboardNotifier > xClpbrdNtfr( xClipboard, uno::UNO_QUERY );
    2096        1428 :                 if( xClpbrdNtfr.is() )
    2097             :                 {
    2098        1428 :                     if( bAdd )
    2099         714 :                         xClpbrdNtfr->addClipboardListener( rClp );
    2100             :                     else
    2101         714 :                         xClpbrdNtfr->removeClipboardListener( rClp );
    2102        1428 :                 }
    2103        1428 :             }
    2104             :         }
    2105             :     }
    2106           0 :     catch (const uno::Exception&)
    2107             :     {
    2108             :     }
    2109        2379 : }
    2110             : 
    2111             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10