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

Generated by: LCOV version 1.10