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

Generated by: LCOV version 1.11