LCOV - code coverage report
Current view: top level - libreoffice/sfx2/source/view - sfxbasecontroller.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 288 687 41.9 %
Date: 2012-12-27 Functions: 35 73 47.9 %
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 <time.h>
      21             : #include <sfx2/sfxbasecontroller.hxx>
      22             : 
      23             : #include <com/sun/star/awt/KeyEvent.hpp>
      24             : #include <com/sun/star/awt/KeyModifier.hpp>
      25             : #include <com/sun/star/awt/MouseEvent.hpp>
      26             : #include <com/sun/star/awt/MouseButton.hpp>
      27             : #include <com/sun/star/util/XCloseable.hpp>
      28             : #include <com/sun/star/util/XCloseBroadcaster.hpp>
      29             : #include <com/sun/star/util/XCloseListener.hpp>
      30             : #include <com/sun/star/util/CloseVetoException.hpp>
      31             : #include <com/sun/star/document/XCmisDocument.hpp>
      32             : #include <com/sun/star/document/XViewDataSupplier.hpp>
      33             : #include <cppuhelper/implbase1.hxx>
      34             : #include <cppuhelper/implbase2.hxx>
      35             : #include <com/sun/star/frame/FrameActionEvent.hpp>
      36             : #include <com/sun/star/frame/FrameAction.hpp>
      37             : #include <com/sun/star/frame/CommandGroup.hpp>
      38             : #include <com/sun/star/frame/XFrame.hpp>
      39             : #include <com/sun/star/frame/XBorderResizeListener.hpp>
      40             : #include <com/sun/star/lang/DisposedException.hpp>
      41             : #include <com/sun/star/lang/EventObject.hpp>
      42             : #include <com/sun/star/lang/XEventListener.hpp>
      43             : #include <com/sun/star/lang/XComponent.hpp>
      44             : #include <com/sun/star/container/XIndexAccess.hpp>
      45             : #include <cppuhelper/interfacecontainer.hxx>
      46             : #include <cppuhelper/typeprovider.hxx>
      47             : #include <basic/sbstar.hxx>
      48             : #include <uno/mapping.hxx>
      49             : #include <sfx2/viewsh.hxx>
      50             : #include <sfx2/docfac.hxx>
      51             : #include <sfx2/viewfrm.hxx>
      52             : #include <sfx2/objsh.hxx>
      53             : #include <sfx2/app.hxx>
      54             : #include <sfx2/msgpool.hxx>
      55             : #include <sfx2/dispatch.hxx>
      56             : #include <sfx2/userinputinterception.hxx>
      57             : 
      58             : #include <viewimp.hxx>
      59             : #include <sfx2/unoctitm.hxx>
      60             : #include <sfx2/childwin.hxx>
      61             : #include <sfx2/sfxsids.hrc>
      62             : #include <sfx2/sfx.hrc>
      63             : #include <sfx2/sfxresid.hxx>
      64             : #include <workwin.hxx>
      65             : #include <sfx2/objface.hxx>
      66             : #include <sfx2/infobar.hxx>
      67             : 
      68             : #include <osl/mutex.hxx>
      69             : #include <tools/diagnose_ex.h>
      70             : #include <comphelper/sequence.hxx>
      71             : #include <rtl/ustrbuf.hxx>
      72             : #include <toolkit/helper/convert.hxx>
      73             : #include <framework/titlehelper.hxx>
      74             : #include <comphelper/processfactory.hxx>
      75             : #include <vcl/msgbox.hxx>
      76             : 
      77             : #include <boost/unordered_map.hpp>
      78             : 
      79             : #include <sfx2/event.hxx>
      80             : #include "sfx2/viewfac.hxx"
      81             : 
      82             : #define OMULTITYPEINTERFACECONTAINERHELPER      ::cppu::OMultiTypeInterfaceContainerHelper
      83             : #define OINTERFACECONTAINERHELPER               ::cppu::OInterfaceContainerHelper
      84             : #define XCLOSELISTENER                          ::com::sun::star::util::XCloseListener
      85             : #define FRAMEACTIONEVENT                        ::com::sun::star::frame::FrameActionEvent
      86             : #define EVENTOBJECT                             ::com::sun::star::lang::EventObject
      87             : #define OTYPECOLLECTION                         ::cppu::OTypeCollection
      88             : #define OIMPLEMENTATIONID                       ::cppu::OImplementationId
      89             : #define XCOMPONENT                              ::com::sun::star::lang::XComponent
      90             : #define XINTERFACE                              ::com::sun::star::uno::XInterface
      91             : #define XKEYHANDLER                             ::com::sun::star::awt::XKeyHandler
      92             : 
      93             : #define TIMEOUT_START_RESCHEDULE    10L /* 10th s */
      94             : 
      95             : using namespace ::com::sun::star;
      96             : using ::com::sun::star::uno::Reference;
      97             : using ::com::sun::star::uno::RuntimeException;
      98             : using ::com::sun::star::uno::UNO_QUERY_THROW;
      99             : using ::com::sun::star::uno::UNO_SET_THROW;
     100             : using ::com::sun::star::lang::DisposedException;
     101             : using ::com::sun::star::awt::XWindow;
     102             : using ::com::sun::star::frame::XController;
     103             : using ::com::sun::star::frame::XDispatchProvider;
     104             : using ::com::sun::star::document::XViewDataSupplier;
     105             : using ::com::sun::star::container::XIndexAccess;
     106             : using ::com::sun::star::beans::PropertyValue;
     107             : using ::com::sun::star::uno::Sequence;
     108             : using ::com::sun::star::uno::UNO_QUERY;
     109             : using ::com::sun::star::uno::Exception;
     110             : using ::com::sun::star::frame::XFrame;
     111             : using ::com::sun::star::frame::XFrameActionListener;
     112             : using ::com::sun::star::util::XCloseListener;
     113             : using ::com::sun::star::task::XStatusIndicator;
     114             : using ::com::sun::star::frame::XTitle;
     115             : 
     116             : struct GroupIDToCommandGroup
     117             : {
     118             :     sal_Int16   nGroupID;
     119             :     sal_Int16   nCommandGroup;
     120             : };
     121             : 
     122             : // Please update when a new command group is added
     123             : const sal_Int16 MAX_COMMANDGROUP = com::sun::star::frame::CommandGroup::CONTROLS;
     124             : 
     125             : static sal_Bool                 bGroupIDMapInitialized = sal_False;
     126             : static GroupIDToCommandGroup    GroupIDCommandGroupMap[] =
     127             : {
     128             :     { GID_INTERN        ,   com::sun::star::frame::CommandGroup::INTERNAL       },
     129             :     { GID_APPLICATION   ,   com::sun::star::frame::CommandGroup::APPLICATION    },
     130             :     { GID_DOCUMENT      ,   com::sun::star::frame::CommandGroup::DOCUMENT       },
     131             :     { GID_VIEW          ,   com::sun::star::frame::CommandGroup::VIEW           },
     132             :     { GID_EDIT          ,   com::sun::star::frame::CommandGroup::EDIT           },
     133             :     { GID_MACRO         ,   com::sun::star::frame::CommandGroup::MACRO          },
     134             :     { GID_OPTIONS       ,   com::sun::star::frame::CommandGroup::OPTIONS        },
     135             :     { GID_MATH          ,   com::sun::star::frame::CommandGroup::MATH           },
     136             :     { GID_NAVIGATOR     ,   com::sun::star::frame::CommandGroup::NAVIGATOR      },
     137             :     { GID_INSERT        ,   com::sun::star::frame::CommandGroup::INSERT         },
     138             :     { GID_FORMAT        ,   com::sun::star::frame::CommandGroup::FORMAT         },
     139             :     { GID_TEMPLATE      ,   com::sun::star::frame::CommandGroup::TEMPLATE       },
     140             :     { GID_TEXT          ,   com::sun::star::frame::CommandGroup::TEXT           },
     141             :     { GID_FRAME         ,   com::sun::star::frame::CommandGroup::FRAME          },
     142             :     { GID_GRAPHIC       ,   com::sun::star::frame::CommandGroup::GRAPHIC        },
     143             :     { GID_TABLE         ,   com::sun::star::frame::CommandGroup::TABLE          },
     144             :     { GID_ENUMERATION   ,   com::sun::star::frame::CommandGroup::ENUMERATION    },
     145             :     { GID_DATA          ,   com::sun::star::frame::CommandGroup::DATA           },
     146             :     { GID_SPECIAL       ,   com::sun::star::frame::CommandGroup::SPECIAL        },
     147             :     { GID_IMAGE         ,   com::sun::star::frame::CommandGroup::IMAGE          },
     148             :     { GID_CHART         ,   com::sun::star::frame::CommandGroup::CHART          },
     149             :     { GID_EXPLORER      ,   com::sun::star::frame::CommandGroup::EXPLORER       },
     150             :     { GID_CONNECTOR     ,   com::sun::star::frame::CommandGroup::CONNECTOR      },
     151             :     { GID_MODIFY        ,   com::sun::star::frame::CommandGroup::MODIFY         },
     152             :     { GID_DRAWING       ,   com::sun::star::frame::CommandGroup::DRAWING        },
     153             :     { GID_CONTROLS      ,   com::sun::star::frame::CommandGroup::CONTROLS       },
     154             :     { 0                 ,   0                                                   }
     155             : };
     156             : 
     157             : typedef boost::unordered_map< sal_Int16, sal_Int16 > GroupHashMap;
     158             : 
     159             : 
     160           0 : sal_Int16 MapGroupIDToCommandGroup( sal_Int16 nGroupID )
     161             : {
     162           0 :     static GroupHashMap mHashMap;
     163             : 
     164           0 :     if ( !bGroupIDMapInitialized )
     165             :     {
     166           0 :         sal_Int32 i = 0;
     167           0 :         while ( GroupIDCommandGroupMap[i].nGroupID != 0 )
     168             :         {
     169             :             mHashMap.insert( GroupHashMap::value_type(
     170             :                 GroupIDCommandGroupMap[i].nGroupID,
     171           0 :                 GroupIDCommandGroupMap[i].nCommandGroup ));
     172           0 :             ++i;
     173             :         }
     174           0 :         bGroupIDMapInitialized = sal_True;
     175             :     }
     176             : 
     177           0 :     GroupHashMap::const_iterator pIter = mHashMap.find( nGroupID );
     178           0 :     if ( pIter != mHashMap.end() )
     179           0 :         return pIter->second;
     180             :     else
     181           0 :         return com::sun::star::frame::CommandGroup::INTERNAL;
     182             : }
     183             : 
     184          66 : sal_uInt32 Get10ThSec()
     185             : {
     186          66 :     sal_uInt32 n10Ticks = 10 * (sal_uInt32)clock();
     187          66 :     return n10Ticks / CLOCKS_PER_SEC;
     188             : }
     189             : 
     190             : sal_Int32 m_nInReschedule = 0;  /// static counter for rescheduling
     191             : 
     192           0 : void reschedule()
     193             : {
     194           0 :     if ( m_nInReschedule == 0 )
     195             :     {
     196           0 :         ++m_nInReschedule;
     197           0 :         Application::Reschedule();
     198           0 :         --m_nInReschedule;
     199             :     }
     200           0 : }
     201             : 
     202           0 : class SfxStatusIndicator : public ::cppu::WeakImplHelper2< ::com::sun::star::task::XStatusIndicator, ::com::sun::star::lang::XEventListener >
     203             : {
     204             : friend class SfxBaseController;
     205             :     ::com::sun::star::uno::Reference < XController > xOwner;
     206             :     ::com::sun::star::uno::Reference < ::com::sun::star::task::XStatusIndicator > xProgress;
     207             :     SfxWorkWindow*          pWorkWindow;
     208             :     sal_Int32               _nRange;
     209             :     sal_Int32               _nValue;
     210             :     long                    _nStartTime;
     211             : public:
     212           0 :                             SfxStatusIndicator(SfxBaseController* pController, SfxWorkWindow* pWork)
     213             :                                 : xOwner( pController )
     214           0 :                                 , pWorkWindow( pWork )
     215             :                             {
     216           0 :                                 ++m_refCount;
     217             :                                 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xComponent(
     218           0 :                                     (static_cast< ::cppu::OWeakObject* >(pController)), ::com::sun::star::uno::UNO_QUERY );
     219           0 :                                 if (xComponent.is())
     220           0 :                                     xComponent->addEventListener(this);
     221           0 :                                 --m_refCount;
     222           0 :                             }
     223             : 
     224             :     virtual void SAL_CALL   start(const ::rtl::OUString& aText, sal_Int32 nRange) throw(::com::sun::star::uno::RuntimeException);
     225             :     virtual void SAL_CALL   end(void) throw(::com::sun::star::uno::RuntimeException);
     226             :     virtual void SAL_CALL   setText(const ::rtl::OUString& aText) throw(::com::sun::star::uno::RuntimeException);
     227             :     virtual void SAL_CALL   setValue(sal_Int32 nValue) throw(::com::sun::star::uno::RuntimeException);
     228             :     virtual void SAL_CALL   reset() throw(::com::sun::star::uno::RuntimeException);
     229             : 
     230             :     virtual void SAL_CALL   disposing( const com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
     231             : };
     232             : 
     233           0 : void SAL_CALL SfxStatusIndicator::start(const ::rtl::OUString& aText, sal_Int32 nRange) throw(::com::sun::star::uno::RuntimeException)
     234             : {
     235           0 :     SolarMutexGuard aGuard;
     236           0 :     if ( xOwner.is() )
     237             :     {
     238           0 :         _nRange = nRange;
     239           0 :         _nValue = 0;
     240             : 
     241           0 :         if ( !xProgress.is() )
     242           0 :             xProgress = pWorkWindow->GetStatusIndicator();
     243             : 
     244           0 :         if ( xProgress.is() )
     245           0 :             xProgress->start( aText, nRange );
     246             : 
     247           0 :         _nStartTime = Get10ThSec();
     248           0 :         reschedule();
     249           0 :     }
     250           0 : }
     251             : 
     252           0 : void SAL_CALL SfxStatusIndicator::end(void) throw(::com::sun::star::uno::RuntimeException)
     253             : {
     254           0 :     SolarMutexGuard aGuard;
     255           0 :     if ( xOwner.is() )
     256             :     {
     257           0 :         if ( !xProgress.is() )
     258           0 :             xProgress = pWorkWindow->GetStatusIndicator();
     259             : 
     260           0 :         if ( xProgress.is() )
     261           0 :             xProgress->end();
     262             : 
     263           0 :         reschedule();
     264           0 :     }
     265           0 : }
     266             : 
     267           0 : void SAL_CALL SfxStatusIndicator::setText(const ::rtl::OUString& aText) throw(::com::sun::star::uno::RuntimeException)
     268             : {
     269           0 :     SolarMutexGuard aGuard;
     270           0 :     if ( xOwner.is() )
     271             :     {
     272           0 :         if ( !xProgress.is() )
     273           0 :             xProgress = pWorkWindow->GetStatusIndicator();
     274             : 
     275           0 :         if ( xProgress.is() )
     276           0 :             xProgress->setText( aText );
     277             : 
     278           0 :         reschedule();
     279           0 :     }
     280           0 : }
     281             : 
     282           0 : void SAL_CALL SfxStatusIndicator::setValue( sal_Int32 nValue ) throw(::com::sun::star::uno::RuntimeException)
     283             : {
     284           0 :     SolarMutexGuard aGuard;
     285           0 :     if ( xOwner.is() )
     286             :     {
     287           0 :         _nValue = nValue;
     288             : 
     289           0 :         if ( !xProgress.is() )
     290           0 :             xProgress = pWorkWindow->GetStatusIndicator();
     291             : 
     292           0 :         if ( xProgress.is() )
     293           0 :             xProgress->setValue( nValue );
     294             : 
     295           0 :         sal_Bool bReschedule = (( Get10ThSec() - _nStartTime ) > TIMEOUT_START_RESCHEDULE );
     296           0 :         if ( bReschedule )
     297           0 :             reschedule();
     298           0 :     }
     299           0 : }
     300             : 
     301           0 : void SAL_CALL SfxStatusIndicator::reset() throw(::com::sun::star::uno::RuntimeException)
     302             : {
     303           0 :     SolarMutexGuard aGuard;
     304           0 :     if ( xOwner.is() )
     305             :     {
     306           0 :         if ( !xProgress.is() )
     307           0 :             xProgress = pWorkWindow->GetStatusIndicator();
     308             : 
     309           0 :         if ( xProgress.is() )
     310           0 :             xProgress->reset();
     311             : 
     312           0 :         reschedule();
     313           0 :     }
     314           0 : }
     315             : 
     316           0 : void SAL_CALL SfxStatusIndicator::disposing( const com::sun::star::lang::EventObject& /*Source*/ ) throw(::com::sun::star::uno::RuntimeException)
     317             : {
     318           0 :     SolarMutexGuard aGuard;
     319           0 :     xOwner = 0;
     320           0 :     xProgress.clear();
     321           0 : }
     322             : 
     323             : //________________________________________________________________________________________________________
     324             : //  declaration IMPL_SfxBaseController_ListenerHelper
     325             : //________________________________________________________________________________________________________
     326             : 
     327             : class IMPL_SfxBaseController_ListenerHelper : public ::cppu::WeakImplHelper1< ::com::sun::star::frame::XFrameActionListener >
     328             : {
     329             : public:
     330             :     IMPL_SfxBaseController_ListenerHelper(  SfxBaseController*  pController ) ;
     331             :     virtual ~IMPL_SfxBaseController_ListenerHelper() ;
     332             :     virtual void SAL_CALL frameAction( const FRAMEACTIONEVENT& aEvent ) throw (RUNTIMEEXCEPTION) ;
     333             :     virtual void SAL_CALL disposing( const EVENTOBJECT& aEvent ) throw (RUNTIMEEXCEPTION) ;
     334             : 
     335             : private:
     336             : 
     337             :     SfxBaseController*      m_pController   ;
     338             : 
     339             : } ; // class IMPL_SfxBaseController_ListenerContainer
     340             : 
     341             : class IMPL_SfxBaseController_CloseListenerHelper : public ::cppu::WeakImplHelper1< ::com::sun::star::util::XCloseListener >
     342             : {
     343             : public:
     344             :     IMPL_SfxBaseController_CloseListenerHelper( SfxBaseController*  pController ) ;
     345             :     virtual ~IMPL_SfxBaseController_CloseListenerHelper() ;
     346             :     virtual void SAL_CALL queryClosing( const EVENTOBJECT& aEvent, sal_Bool bDeliverOwnership )
     347             :         throw (RUNTIMEEXCEPTION, com::sun::star::util::CloseVetoException) ;
     348             :     virtual void SAL_CALL notifyClosing( const EVENTOBJECT& aEvent ) throw (RUNTIMEEXCEPTION) ;
     349             :     virtual void SAL_CALL disposing( const EVENTOBJECT& aEvent ) throw (RUNTIMEEXCEPTION) ;
     350             : 
     351             : private:
     352             : 
     353             :     SfxBaseController*      m_pController;
     354             : 
     355             : } ; // class IMPL_SfxBaseController_ListenerContainer
     356             : 
     357         240 : IMPL_SfxBaseController_CloseListenerHelper::IMPL_SfxBaseController_CloseListenerHelper( SfxBaseController*  pController )
     358         240 :         : m_pController ( pController   )
     359             : {
     360         240 : }
     361             : 
     362         106 : IMPL_SfxBaseController_CloseListenerHelper::~IMPL_SfxBaseController_CloseListenerHelper()
     363             : {
     364         106 : }
     365             : 
     366           0 : void SAL_CALL IMPL_SfxBaseController_CloseListenerHelper::disposing( const EVENTOBJECT& /*aEvent*/ ) throw( ::com::sun::star::uno::RuntimeException )
     367             : {
     368           0 : }
     369             : 
     370         126 : void SAL_CALL IMPL_SfxBaseController_CloseListenerHelper::queryClosing( const EVENTOBJECT& aEvent, sal_Bool bDeliverOwnership )
     371             :     throw (RUNTIMEEXCEPTION, com::sun::star::util::CloseVetoException)
     372             : {
     373         126 :     SolarMutexGuard aGuard;
     374         126 :     SfxViewShell* pShell = m_pController->GetViewShell_Impl();
     375         126 :     if  ( m_pController !=  NULL &&  pShell )
     376             :     {
     377         126 :         sal_Bool bCanClose = (sal_Bool) pShell->PrepareClose( sal_False );
     378         126 :         if ( !bCanClose )
     379             :         {
     380           0 :             if ( bDeliverOwnership && ( !pShell->GetWindow() || !pShell->GetWindow()->IsReallyVisible() ) )
     381             :             {
     382             :                 // ignore OwnerShip in case of visible frame (will be closed by user)
     383           0 :                 uno::Reference < frame::XModel > xModel( aEvent.Source, uno::UNO_QUERY );
     384           0 :                 if ( xModel.is() )
     385           0 :                     pShell->TakeOwnerShip_Impl();
     386             :                 else
     387           0 :                     pShell->TakeFrameOwnerShip_Impl();
     388             :             }
     389             : 
     390           0 :             throw com::sun::star::util::CloseVetoException(::rtl::OUString("Controller disagree ..."),static_cast< ::cppu::OWeakObject*>(this));
     391             :         }
     392         126 :     }
     393         126 : }
     394             : 
     395          63 : void SAL_CALL IMPL_SfxBaseController_CloseListenerHelper::notifyClosing( const EVENTOBJECT& /*aEvent*/ ) throw (RUNTIMEEXCEPTION)
     396             : {
     397          63 : }
     398             : 
     399             : //________________________________________________________________________________________________________
     400             : //  declaration IMPL_SfxBaseController_DataContainer
     401             : //________________________________________________________________________________________________________
     402             : 
     403          53 : struct IMPL_SfxBaseController_DataContainer
     404             : {
     405             :     Reference< XFrame >                     m_xFrame                ;
     406             :     Reference< XFrameActionListener >       m_xListener             ;
     407             :     Reference< XCloseListener >             m_xCloseListener        ;
     408             :     ::sfx2::UserInputInterception           m_aUserInputInterception;
     409             :     OMULTITYPEINTERFACECONTAINERHELPER      m_aListenerContainer    ;
     410             :     OINTERFACECONTAINERHELPER               m_aInterceptorContainer ;
     411             :     Reference< XStatusIndicator >           m_xIndicator            ;
     412             :     SfxViewShell*                           m_pViewShell            ;
     413             :     SfxBaseController*                      m_pController           ;
     414             :     sal_Bool                                m_bDisposing            ;
     415             :     sal_Bool                                m_bSuspendState         ;
     416             :     Reference< XTitle >                     m_xTitleHelper          ;
     417             :     Sequence< PropertyValue >               m_aCreationArgs         ;
     418             : 
     419         240 :     IMPL_SfxBaseController_DataContainer(   MUTEX&              aMutex      ,
     420             :                                             SfxViewShell*       pViewShell  ,
     421             :                                             SfxBaseController*  pController )
     422         240 :             :   m_xListener                     ( new IMPL_SfxBaseController_ListenerHelper( pController ) )
     423         240 :             ,   m_xCloseListener                ( new IMPL_SfxBaseController_CloseListenerHelper( pController ) )
     424             :             ,   m_aUserInputInterception        ( *pController, aMutex                                  )
     425             :             ,   m_aListenerContainer            ( aMutex                                                )
     426             :             ,   m_aInterceptorContainer         ( aMutex                                                )
     427             :             ,   m_pViewShell            ( pViewShell                                            )
     428             :             ,   m_pController           ( pController                                           )
     429             :             ,   m_bDisposing            ( sal_False                                             )
     430         720 :             ,   m_bSuspendState                 ( sal_False                                              )
     431             :     {
     432         240 :     }
     433             : 
     434             : } ; // struct IMPL_SfxBaseController_DataContainer
     435             : 
     436             : //________________________________________________________________________________________________________
     437             : //  IMPL_SfxBaseController_ListenerHelper constructor
     438             : //________________________________________________________________________________________________________
     439             : 
     440         240 : IMPL_SfxBaseController_ListenerHelper::IMPL_SfxBaseController_ListenerHelper(   SfxBaseController*  pController )
     441         240 :         : m_pController ( pController   )
     442             : {
     443         240 : }
     444             : 
     445             : //________________________________________________________________________________________________________
     446             : //  IMPL_SfxBaseController_ListenerHelper destructor
     447             : //________________________________________________________________________________________________________
     448             : 
     449         106 : IMPL_SfxBaseController_ListenerHelper::~IMPL_SfxBaseController_ListenerHelper()
     450             : {
     451         106 : }
     452             : 
     453         267 : void SAL_CALL IMPL_SfxBaseController_ListenerHelper::frameAction( const FRAMEACTIONEVENT& aEvent ) throw( RUNTIMEEXCEPTION )
     454             : {
     455         267 :     SolarMutexGuard aGuard;
     456        1602 :     if  (
     457             :             ( m_pController !=  NULL ) &&
     458         801 :             ( aEvent.Frame  ==  m_pController->getFrame() ) &&
     459         534 :             ( m_pController->GetViewShell_Impl() && m_pController->GetViewShell_Impl()->GetWindow() !=  NULL                                                    )
     460             :         )
     461             :     {
     462         267 :         if ( aEvent.Action == ::com::sun::star::frame::FrameAction_FRAME_UI_ACTIVATED )
     463             :         {
     464           0 :             if ( !m_pController->GetViewShell_Impl()->GetUIActiveIPClient_Impl() )
     465           0 :                 m_pController->GetViewShell_Impl()->GetViewFrame()->MakeActive_Impl( sal_False );
     466             :         }
     467         267 :         else if ( aEvent.Action == ::com::sun::star::frame::FrameAction_CONTEXT_CHANGED )
     468             :         {
     469           0 :             m_pController->GetViewShell_Impl()->GetViewFrame()->GetBindings().ContextChanged_Impl();
     470             :         }
     471         267 :     }
     472         267 : }
     473             : 
     474             : //________________________________________________________________________________________________________
     475             : //  IMPL_SfxBaseController_ListenerHelper -> XEventListener
     476             : //________________________________________________________________________________________________________
     477             : 
     478          63 : void SAL_CALL IMPL_SfxBaseController_ListenerHelper::disposing( const EVENTOBJECT& /*aEvent*/ ) throw( ::com::sun::star::uno::RuntimeException )
     479             : {
     480          63 :     SolarMutexGuard aGuard;
     481          63 :     if ( m_pController && m_pController->getFrame().is() )
     482           0 :         m_pController->getFrame()->removeFrameActionListener( this ) ;
     483          63 : }
     484             : 
     485             : //________________________________________________________________________________________________________
     486             : //  SfxBaseController -> constructor
     487             : //________________________________________________________________________________________________________
     488             : DBG_NAME(sfx2_SfxBaseController)
     489         240 : SfxBaseController::SfxBaseController( SfxViewShell* pViewShell )
     490         240 :     :   m_pData ( new IMPL_SfxBaseController_DataContainer( m_aMutex, pViewShell, this ))
     491             : {
     492             :     DBG_CTOR(sfx2_SfxBaseController,NULL);
     493         240 :     m_pData->m_pViewShell->SetController( this );
     494         240 : }
     495             : 
     496             : //________________________________________________________________________________________________________
     497             : //  SfxBaseController -> destructor
     498             : //________________________________________________________________________________________________________
     499             : 
     500         106 : SfxBaseController::~SfxBaseController()
     501             : {
     502             :     DBG_DTOR(sfx2_SfxBaseController,NULL);
     503          53 :     delete m_pData;
     504          53 : }
     505             : 
     506             : //________________________________________________________________________________________________________
     507             : //  SfxBaseController -> XController2
     508             : //________________________________________________________________________________________________________
     509             : 
     510         240 : Reference< XWindow > SAL_CALL SfxBaseController::getComponentWindow() throw (RuntimeException)
     511             : {
     512         240 :     SolarMutexGuard aGuard;
     513         240 :     if ( !m_pData->m_pViewShell )
     514           0 :         throw DisposedException();
     515             : 
     516         240 :     return Reference< XWindow >( GetViewFrame_Impl().GetFrame().GetWindow().GetComponentInterface(), UNO_QUERY_THROW );
     517             : }
     518             : 
     519           0 : ::rtl::OUString SAL_CALL SfxBaseController::getViewControllerName() throw (RuntimeException)
     520             : {
     521           0 :     SolarMutexGuard aGuard;
     522           0 :     if ( !m_pData->m_pViewShell || !m_pData->m_pViewShell->GetObjectShell() )
     523           0 :         throw DisposedException();
     524             : 
     525           0 :     const SfxObjectFactory& rDocFac( m_pData->m_pViewShell->GetObjectShell()->GetFactory() );
     526           0 :     sal_uInt16 nViewNo = rDocFac.GetViewNo_Impl( GetViewFrame_Impl().GetCurViewId(), rDocFac.GetViewFactoryCount() );
     527             :     OSL_ENSURE( nViewNo < rDocFac.GetViewFactoryCount(), "SfxBaseController::getViewControllerName: view ID not found in view factories!" );
     528             : 
     529           0 :     ::rtl::OUString sViewName;
     530           0 :     if ( nViewNo < rDocFac.GetViewFactoryCount() )
     531           0 :         sViewName = rDocFac.GetViewFactory( nViewNo ).GetAPIViewName();
     532             : 
     533           0 :     return sViewName;
     534             : }
     535             : 
     536         240 : Sequence< PropertyValue > SAL_CALL SfxBaseController::getCreationArguments() throw (RuntimeException)
     537             : {
     538         240 :     SolarMutexGuard aGuard;
     539         240 :     if ( !m_pData->m_pViewShell || !m_pData->m_pViewShell->GetObjectShell() )
     540           0 :         throw DisposedException();
     541             : 
     542         240 :     return m_pData->m_aCreationArgs;
     543             : }
     544             : 
     545         240 : void SfxBaseController::SetCreationArguments_Impl( const Sequence< PropertyValue >& i_rCreationArgs )
     546             : {
     547             :     OSL_ENSURE( m_pData->m_aCreationArgs.getLength() == 0, "SfxBaseController::SetCreationArguments_Impl: not intended to be called twice!" );
     548         240 :     m_pData->m_aCreationArgs = i_rCreationArgs;
     549         240 : }
     550             : 
     551         240 : SfxViewFrame& SfxBaseController::GetViewFrame_Impl() const
     552             : {
     553         240 :     ENSURE_OR_THROW( m_pData->m_pViewShell, "not to be called without a view shell" );
     554         240 :     SfxViewFrame* pActFrame = m_pData->m_pViewShell->GetFrame();
     555         240 :     ENSURE_OR_THROW( pActFrame, "a view shell without a view frame is pretty pathological" );
     556         240 :     return *pActFrame;
     557             : }
     558             : 
     559             : //________________________________________________________________________________________________________
     560             : //  SfxBaseController -> XController2 -> XController
     561             : //________________________________________________________________________________________________________
     562             : 
     563         303 : void SAL_CALL SfxBaseController::attachFrame( const REFERENCE< XFRAME >& xFrame ) throw( ::com::sun::star::uno::RuntimeException )
     564             : {
     565         303 :     REFERENCE< XFRAME > xTemp( getFrame() ) ;
     566             : 
     567         303 :     SolarMutexGuard aGuard;
     568         303 :     if ( xTemp.is() )
     569             :     {
     570          63 :         xTemp->removeFrameActionListener( m_pData->m_xListener ) ;
     571          63 :         REFERENCE < ::com::sun::star::util::XCloseBroadcaster > xCloseable( xTemp, com::sun::star::uno::UNO_QUERY );
     572          63 :         if ( xCloseable.is() )
     573          63 :             xCloseable->removeCloseListener( m_pData->m_xCloseListener );
     574             :     }
     575             : 
     576         303 :     m_pData->m_xFrame = xFrame;
     577             : 
     578         303 :     if ( xFrame.is() )
     579             :     {
     580         240 :         xFrame->addFrameActionListener( m_pData->m_xListener ) ;
     581         240 :         REFERENCE < ::com::sun::star::util::XCloseBroadcaster > xCloseable( xFrame, com::sun::star::uno::UNO_QUERY );
     582         240 :         if ( xCloseable.is() )
     583         240 :             xCloseable->addCloseListener( m_pData->m_xCloseListener );
     584             : 
     585         240 :         if ( m_pData->m_pViewShell )
     586             :         {
     587         240 :             ConnectSfxFrame_Impl( E_CONNECT );
     588         240 :             ShowInfoBars( );
     589             : 
     590             :             // attaching the frame to the controller is the last step in the creation of a new view, so notify this
     591         240 :             SfxViewEventHint aHint( SFX_EVENT_VIEWCREATED, GlobalEventConfig::GetEventName( STR_EVENT_VIEWCREATED ), m_pData->m_pViewShell->GetObjectShell(), uno::Reference< frame::XController2 >( this ) );
     592         240 :             SFX_APP()->NotifyEvent( aHint );
     593         240 :         }
     594         303 :     }
     595         303 : }
     596             : 
     597             : //________________________________________________________________________________________________________
     598             : //  SfxBaseController -> XController
     599             : //________________________________________________________________________________________________________
     600             : 
     601         240 : sal_Bool SAL_CALL SfxBaseController::attachModel( const REFERENCE< XMODEL >& xModel ) throw( ::com::sun::star::uno::RuntimeException )
     602             : {
     603         240 :     if ( m_pData->m_pViewShell && xModel.is() && xModel != m_pData->m_pViewShell->GetObjectShell()->GetModel() )
     604             :     {
     605             :         // don't allow to reattach a model!
     606             :         OSL_FAIL("Can't reattach model!");
     607           0 :         return sal_False;
     608             :     }
     609             : 
     610         240 :     REFERENCE < ::com::sun::star::util::XCloseBroadcaster > xCloseable( xModel, com::sun::star::uno::UNO_QUERY );
     611         240 :     if ( xCloseable.is() )
     612         240 :         xCloseable->addCloseListener( m_pData->m_xCloseListener );
     613         240 :     return sal_True;
     614             : }
     615             : 
     616             : //________________________________________________________________________________________________________
     617             : //  SfxBaseController -> XController
     618             : //________________________________________________________________________________________________________
     619             : 
     620           0 : sal_Bool SAL_CALL SfxBaseController::suspend( sal_Bool bSuspend ) throw( ::com::sun::star::uno::RuntimeException )
     621             : {
     622           0 :     SolarMutexGuard aGuard;
     623             : 
     624             :     // ignore dublicate calls, which doesnt change anything real
     625           0 :     if (bSuspend == m_pData->m_bSuspendState)
     626           0 :        return sal_True;
     627             : 
     628           0 :     if ( bSuspend == sal_True )
     629             :     {
     630           0 :         if ( !m_pData->m_pViewShell )
     631             :         {
     632           0 :             m_pData->m_bSuspendState = sal_True;
     633           0 :             return sal_True;
     634             :         }
     635             : 
     636           0 :         if ( !m_pData->m_pViewShell->PrepareClose() )
     637           0 :             return sal_False;
     638             : 
     639           0 :         if ( getFrame().is() )
     640           0 :             getFrame()->removeFrameActionListener( m_pData->m_xListener ) ;
     641           0 :         SfxViewFrame* pActFrame = m_pData->m_pViewShell->GetFrame() ;
     642             : 
     643             :         // More Views on the same document?
     644           0 :         SfxObjectShell* pDocShell   =   m_pData->m_pViewShell->GetObjectShell() ;
     645           0 :         sal_Bool        bOther      =   sal_False                               ;
     646             : 
     647           0 :         for ( const SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell ); !bOther && pFrame; pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell ) )
     648           0 :             bOther = (pFrame != pActFrame);
     649             : 
     650           0 :         sal_Bool bRet = bOther || pDocShell->PrepareClose();
     651           0 :         if ( bRet )
     652             :         {
     653           0 :             ConnectSfxFrame_Impl( E_DISCONNECT );
     654           0 :             m_pData->m_bSuspendState = sal_True;
     655             :         }
     656             : 
     657           0 :         return bRet;
     658             :     }
     659             :     else
     660             :     {
     661           0 :         if ( getFrame().is() )
     662           0 :             getFrame()->addFrameActionListener( m_pData->m_xListener ) ;
     663             : 
     664           0 :         if ( m_pData->m_pViewShell )
     665             :         {
     666           0 :             ConnectSfxFrame_Impl( E_RECONNECT );
     667             :         }
     668             : 
     669           0 :         m_pData->m_bSuspendState = sal_False;
     670           0 :         return sal_True ;
     671           0 :     }
     672             : }
     673             : 
     674             : //________________________________________________________________________________________________________
     675             : //  SfxBaseController -> XController
     676             : //________________________________________________________________________________________________________
     677             : 
     678           0 : ANY SfxBaseController::getViewData() throw( ::com::sun::star::uno::RuntimeException )
     679             : {
     680           0 :     ANY         aAny;
     681           0 :     String      sData1;
     682           0 :     SolarMutexGuard aGuard;
     683           0 :     if ( m_pData->m_pViewShell )
     684             :     {
     685           0 :         m_pData->m_pViewShell->WriteUserData( sData1 ) ;
     686           0 :         ::rtl::OUString    sData( sData1 );
     687           0 :         aAny <<= sData ;
     688             :     }
     689             : 
     690           0 :     return aAny ;
     691             : }
     692             : 
     693             : //________________________________________________________________________________________________________
     694             : //  SfxBaseController -> XController
     695             : //________________________________________________________________________________________________________
     696             : 
     697           0 : void SAL_CALL SfxBaseController::restoreViewData( const ANY& aValue ) throw( ::com::sun::star::uno::RuntimeException )
     698             : {
     699           0 :     SolarMutexGuard aGuard;
     700           0 :     if ( m_pData->m_pViewShell )
     701             :     {
     702           0 :         ::rtl::OUString sData;
     703           0 :         aValue >>= sData ;
     704           0 :         m_pData->m_pViewShell->ReadUserData( sData ) ;
     705           0 :     }
     706           0 : }
     707             : 
     708             : //________________________________________________________________________________________________________
     709             : //  SfxBaseController -> XController
     710             : //________________________________________________________________________________________________________
     711             : 
     712         814 : REFERENCE< XFRAME > SAL_CALL SfxBaseController::getFrame() throw( ::com::sun::star::uno::RuntimeException )
     713             : {
     714         814 :     SolarMutexGuard aGuard;
     715         814 :     return m_pData->m_xFrame;
     716             : }
     717             : 
     718             : //________________________________________________________________________________________________________
     719             : //  SfxBaseController -> XController
     720             : //________________________________________________________________________________________________________
     721             : 
     722       39273 : REFERENCE< XMODEL > SAL_CALL SfxBaseController::getModel() throw( ::com::sun::star::uno::RuntimeException )
     723             : {
     724       39273 :     SolarMutexGuard aGuard;
     725       39273 :     return m_pData->m_pViewShell ? m_pData->m_pViewShell->GetObjectShell()->GetModel() : REFERENCE < XMODEL > () ;
     726             : }
     727             : 
     728             : //________________________________________________________________________________________________________
     729             : //  SfxBaseController -> XDispatchProvider
     730             : //________________________________________________________________________________________________________
     731             : 
     732        3995 : REFERENCE< XDISPATCH > SAL_CALL SfxBaseController::queryDispatch(   const   UNOURL&             aURL            ,
     733             :                                                                     const   ::rtl::OUString&            sTargetFrameName,
     734             :                                                                             sal_Int32           eSearchFlags    ) throw( RUNTIMEEXCEPTION )
     735             : {
     736        3995 :     SolarMutexGuard aGuard;
     737        3995 :     REFERENCE< XDISPATCH >  xDisp;
     738        3995 :     if ( m_pData->m_pViewShell )
     739             :     {
     740        3995 :         SfxViewFrame*           pAct    = m_pData->m_pViewShell->GetViewFrame() ;
     741        3995 :         if ( !m_pData->m_bDisposing )
     742             :         {
     743        3995 :             if ( sTargetFrameName == "_beamer" )
     744             :             {
     745           0 :                 SfxViewFrame *pFrame = m_pData->m_pViewShell->GetViewFrame();
     746           0 :                 if ( eSearchFlags & ( ::com::sun::star::frame::FrameSearchFlag::CREATE ))
     747           0 :                     pFrame->SetChildWindow( SID_BROWSER, sal_True );
     748           0 :                 SfxChildWindow* pChildWin = pFrame->GetChildWindow( SID_BROWSER );
     749           0 :                 REFERENCE < XFRAME > xFrame;
     750           0 :                 if ( pChildWin )
     751           0 :                     xFrame = ( pChildWin->GetFrame() );
     752           0 :                 if ( xFrame.is() )
     753           0 :                     xFrame->setName( sTargetFrameName );
     754             : 
     755           0 :                 Reference< XDispatchProvider > xProv( xFrame, ::com::sun::star::uno::UNO_QUERY );
     756           0 :                 if ( xProv.is() )
     757           0 :                     return xProv->queryDispatch( aURL, sTargetFrameName, ::com::sun::star::frame::FrameSearchFlag::SELF );
     758             :             }
     759             : 
     760        3995 :             if ( aURL.Protocol == ".uno:" )
     761             :             {
     762        1635 :                 rtl::OUString aMasterCommand = SfxOfficeDispatch::GetMasterUnoCommand( aURL );
     763        1635 :                 sal_Bool      bMasterCommand( !aMasterCommand.isEmpty() );
     764             : 
     765        1635 :                 pAct = m_pData->m_pViewShell->GetViewFrame() ;
     766        1635 :                 SfxSlotPool& rSlotPool = SfxSlotPool::GetSlotPool( pAct );
     767             : 
     768        1635 :                 const SfxSlot* pSlot( 0 );
     769        1635 :                 if ( bMasterCommand )
     770           0 :                     pSlot = rSlotPool.GetUnoSlot( aMasterCommand );
     771             :                 else
     772        1635 :                     pSlot = rSlotPool.GetUnoSlot( aURL.Path );
     773        1635 :                 if ( pSlot && ( !pAct->GetFrame().IsInPlace() || !pSlot->IsMode( SFX_SLOT_CONTAINER ) ) )
     774        1635 :                     return pAct->GetBindings().GetDispatch( pSlot, aURL, bMasterCommand );
     775             :                 else
     776             :                 {
     777             :                     // try to find parent SfxViewFrame
     778           0 :                     uno::Reference< frame::XFrame > xParentFrame;
     779           0 :                     uno::Reference< frame::XFrame > xOwnFrame = pAct->GetFrame().GetFrameInterface();
     780           0 :                     if ( xOwnFrame.is() )
     781           0 :                         xParentFrame = uno::Reference< frame::XFrame >( xOwnFrame->getCreator(), uno::UNO_QUERY );
     782             : 
     783           0 :                     if ( xParentFrame.is() )
     784             :                     {
     785             :                         // TODO/LATER: in future probably SfxViewFrame hirarchy should be the same as XFrame hirarchy
     786             :                         // SfxViewFrame* pParentFrame = pAct->GetParentViewFrame();
     787             : 
     788             :                         // search the related SfxViewFrame
     789           0 :                         SfxViewFrame* pParentFrame = NULL;
     790           0 :                         for ( SfxViewFrame* pFrame = SfxViewFrame::GetFirst();
     791             :                                 pFrame;
     792             :                                 pFrame = SfxViewFrame::GetNext( *pFrame ) )
     793             :                         {
     794           0 :                             if ( pFrame->GetFrame().GetFrameInterface() == xParentFrame )
     795             :                             {
     796           0 :                                 pParentFrame = pFrame;
     797           0 :                                 break;
     798             :                             }
     799             :                         }
     800             : 
     801           0 :                         if ( pParentFrame )
     802             :                         {
     803           0 :                             SfxSlotPool& rFrameSlotPool = SfxSlotPool::GetSlotPool( pParentFrame );
     804           0 :                             const SfxSlot* pSlot2( 0 );
     805           0 :                             if ( bMasterCommand )
     806           0 :                                 pSlot2 = rFrameSlotPool.GetUnoSlot( aMasterCommand );
     807             :                             else
     808           0 :                                 pSlot2 = rFrameSlotPool.GetUnoSlot( aURL.Path );
     809             : 
     810           0 :                             if ( pSlot2 )
     811           0 :                                 return pParentFrame->GetBindings().GetDispatch( pSlot2, aURL, bMasterCommand );
     812             :                         }
     813           0 :                     }
     814        1635 :                 }
     815             :             }
     816        2360 :             else if ( aURL.Protocol == "slot:" )
     817             :             {
     818           0 :                 sal_uInt16 nId = (sal_uInt16) aURL.Path.toInt32();
     819             : 
     820           0 :                 pAct = m_pData->m_pViewShell->GetViewFrame() ;
     821           0 :                 if (nId >= SID_VERB_START && nId <= SID_VERB_END)
     822             :                 {
     823           0 :                     const SfxSlot* pSlot = m_pData->m_pViewShell->GetVerbSlot_Impl(nId);
     824           0 :                     if ( pSlot )
     825           0 :                         return pAct->GetBindings().GetDispatch( pSlot, aURL, sal_False );
     826             :                 }
     827             : 
     828           0 :                 SfxSlotPool& rSlotPool = SfxSlotPool::GetSlotPool( pAct );
     829           0 :                 const SfxSlot* pSlot = rSlotPool.GetSlot( nId );
     830           0 :                 if ( pSlot && ( !pAct->GetFrame().IsInPlace() || !pSlot->IsMode( SFX_SLOT_CONTAINER ) ) )
     831           0 :                     return pAct->GetBindings().GetDispatch( pSlot, aURL, sal_False );
     832             :                 else
     833             :                 {
     834             :                     // try to find parent SfxViewFrame
     835           0 :                     uno::Reference< frame::XFrame > xParentFrame;
     836           0 :                     uno::Reference< frame::XFrame > xOwnFrame = pAct->GetFrame().GetFrameInterface();
     837           0 :                     if ( xOwnFrame.is() )
     838           0 :                         xParentFrame = uno::Reference< frame::XFrame >( xOwnFrame->getCreator(), uno::UNO_QUERY );
     839             : 
     840           0 :                     if ( xParentFrame.is() )
     841             :                     {
     842             :                         // TODO/LATER: in future probably SfxViewFrame hirarchy should be the same as XFrame hirarchy
     843             :                         // SfxViewFrame* pParentFrame = pAct->GetParentViewFrame();
     844             : 
     845             :                         // search the related SfxViewFrame
     846           0 :                         SfxViewFrame* pParentFrame = NULL;
     847           0 :                         for ( SfxViewFrame* pFrame = SfxViewFrame::GetFirst();
     848             :                                 pFrame;
     849             :                                 pFrame = SfxViewFrame::GetNext( *pFrame ) )
     850             :                         {
     851           0 :                             if ( pFrame->GetFrame().GetFrameInterface() == xParentFrame )
     852             :                             {
     853           0 :                                 pParentFrame = pFrame;
     854           0 :                                 break;
     855             :                             }
     856             :                         }
     857             : 
     858           0 :                         if ( pParentFrame )
     859             :                         {
     860           0 :                             SfxSlotPool& rSlotPool2 = SfxSlotPool::GetSlotPool( pParentFrame );
     861           0 :                             const SfxSlot* pSlot2 = rSlotPool2.GetUnoSlot( aURL.Path );
     862           0 :                             if ( pSlot2 )
     863           0 :                                 return pParentFrame->GetBindings().GetDispatch( pSlot2, aURL, sal_False );
     864             :                         }
     865           0 :                     }
     866             :                 }
     867             :             }
     868        2360 :             else if( sTargetFrameName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("_self")) || sTargetFrameName.isEmpty() )
     869             :             {
     870             :                 // check for already loaded URL ... but with additional jumpmark!
     871        2360 :                 REFERENCE< XMODEL > xModel = getModel();
     872        2360 :                 if( xModel.is() && !aURL.Mark.isEmpty() )
     873             :                 {
     874           0 :                     SfxSlotPool& rSlotPool = SfxSlotPool::GetSlotPool( pAct );
     875           0 :                     const SfxSlot* pSlot = rSlotPool.GetSlot( SID_JUMPTOMARK );
     876           0 :                     if( !aURL.Main.isEmpty() && aURL.Main == xModel->getURL() && pSlot )
     877           0 :                         return REFERENCE< XDISPATCH >( new SfxOfficeDispatch( pAct->GetBindings(), pAct->GetDispatcher(), pSlot, aURL) );
     878        2360 :                 }
     879             :             }
     880             :         }
     881             :     }
     882             : 
     883        2360 :     return xDisp;
     884             : }
     885             : 
     886             : //________________________________________________________________________________________________________
     887             : //  SfxBaseController -> XDispatchProvider
     888             : //________________________________________________________________________________________________________
     889             : 
     890           0 : uno::Sequence< REFERENCE< XDISPATCH > > SAL_CALL SfxBaseController::queryDispatches( const uno::Sequence< DISPATCHDESCRIPTOR >& seqDescripts ) throw( ::com::sun::star::uno::RuntimeException )
     891             : {
     892             :     // Create return list - which must have same size then the given descriptor
     893             :     // It's not allowed to pack it!
     894           0 :     sal_Int32 nCount = seqDescripts.getLength();
     895           0 :     uno::Sequence< REFERENCE< XDISPATCH > > lDispatcher( nCount );
     896             : 
     897           0 :     for( sal_Int32 i=0; i<nCount; ++i )
     898             :     {
     899           0 :         lDispatcher[i] = queryDispatch( seqDescripts[i].FeatureURL  ,
     900           0 :                                         seqDescripts[i].FrameName   ,
     901           0 :                                         seqDescripts[i].SearchFlags );
     902             :     }
     903             : 
     904           0 :     return lDispatcher;
     905             : }
     906             : 
     907             : //________________________________________________________________________________________________________
     908             : //  SfxBaseController -> XControllerBorder
     909             : //________________________________________________________________________________________________________
     910             : 
     911           0 : frame::BorderWidths SAL_CALL SfxBaseController::getBorder()
     912             :     throw ( uno::RuntimeException )
     913             : {
     914           0 :     frame::BorderWidths aResult;
     915             : 
     916           0 :     SolarMutexGuard aGuard;
     917           0 :     if ( m_pData->m_pViewShell )
     918             :     {
     919           0 :         SvBorder aBorder = m_pData->m_pViewShell->GetBorderPixel();
     920           0 :         aResult.Left = aBorder.Left();
     921           0 :         aResult.Top = aBorder.Top();
     922           0 :         aResult.Right = aBorder.Right();
     923           0 :         aResult.Bottom = aBorder.Bottom();
     924             :     }
     925             : 
     926           0 :     return aResult;
     927             : }
     928             : 
     929           0 : void SAL_CALL SfxBaseController::addBorderResizeListener( const uno::Reference< frame::XBorderResizeListener >& xListener )
     930             :     throw ( uno::RuntimeException )
     931             : {
     932           0 :     m_pData->m_aListenerContainer.addInterface( ::getCppuType((const uno::Reference< frame::XBorderResizeListener >*)0),
     933           0 :                                                 xListener );
     934           0 : }
     935             : 
     936           0 : void SAL_CALL SfxBaseController::removeBorderResizeListener( const uno::Reference< frame::XBorderResizeListener >& xListener )
     937             :     throw ( uno::RuntimeException )
     938             : {
     939           0 :     m_pData->m_aListenerContainer.removeInterface( ::getCppuType((const uno::Reference< frame::XBorderResizeListener >*)0),
     940           0 :                                                 xListener );
     941           0 : }
     942             : 
     943           0 : awt::Rectangle SAL_CALL SfxBaseController::queryBorderedArea( const awt::Rectangle& aPreliminaryRectangle )
     944             :     throw ( uno::RuntimeException )
     945             : {
     946           0 :     SolarMutexGuard aGuard;
     947           0 :     if ( m_pData->m_pViewShell )
     948             :     {
     949           0 :         Rectangle aTmpRect = VCLRectangle( aPreliminaryRectangle );
     950           0 :         m_pData->m_pViewShell->QueryObjAreaPixel( aTmpRect );
     951           0 :         return AWTRectangle( aTmpRect );
     952             :     }
     953             : 
     954           0 :     return aPreliminaryRectangle;
     955             : }
     956             : 
     957        1327 : void SfxBaseController::BorderWidthsChanged_Impl()
     958             : {
     959             :        ::cppu::OInterfaceContainerHelper* pContainer = m_pData->m_aListenerContainer.getContainer(
     960        1327 :                         ::getCppuType( ( const uno::Reference< frame::XBorderResizeListener >*) NULL ) );
     961        1327 :     if ( pContainer )
     962             :     {
     963           0 :         frame::BorderWidths aBWidths = getBorder();
     964           0 :         uno::Reference< uno::XInterface > xThis( static_cast< ::cppu::OWeakObject* >(this), uno::UNO_QUERY );
     965             : 
     966           0 :         ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
     967           0 :         while (pIterator.hasMoreElements())
     968             :         {
     969             :             try
     970             :             {
     971           0 :                 ((frame::XBorderResizeListener*)pIterator.next())->borderWidthsChanged( xThis, aBWidths );
     972             :             }
     973           0 :             catch (const uno::RuntimeException&)
     974             :             {
     975           0 :                 pIterator.remove();
     976             :             }
     977           0 :         }
     978             :     }
     979        1327 : }
     980             : 
     981             : //________________________________________________________________________________________________________
     982             : //  SfxBaseController -> XComponent
     983             : //________________________________________________________________________________________________________
     984             : 
     985          63 : void SAL_CALL SfxBaseController::dispose() throw( ::com::sun::star::uno::RuntimeException )
     986             : {
     987          63 :     SolarMutexGuard aGuard;
     988          63 :     Reference< XController > xTmp( this );
     989          63 :     m_pData->m_bDisposing = sal_True ;
     990             : 
     991          63 :     EVENTOBJECT aEventObject;
     992          63 :     aEventObject.Source = *this ;
     993          63 :     m_pData->m_aListenerContainer.disposeAndClear( aEventObject ) ;
     994             : 
     995          63 :     if ( m_pData->m_pController && m_pData->m_pController->getFrame().is() )
     996          63 :         m_pData->m_pController->getFrame()->removeFrameActionListener( m_pData->m_xListener ) ;
     997             : 
     998          63 :     if ( m_pData->m_pViewShell )
     999             :     {
    1000          63 :         SfxViewFrame* pFrame = m_pData->m_pViewShell->GetViewFrame() ;
    1001          63 :         if ( pFrame && pFrame->GetViewShell() == m_pData->m_pViewShell )
    1002          63 :             pFrame->GetFrame().SetIsClosing_Impl();
    1003          63 :         m_pData->m_pViewShell->DiscardClients_Impl();
    1004          63 :         m_pData->m_pViewShell->pImp->m_bControllerSet = false;
    1005             : 
    1006          63 :         if ( pFrame )
    1007             :         {
    1008          63 :             EVENTOBJECT aObject;
    1009          63 :             aObject.Source = *this ;
    1010             : 
    1011          63 :             SfxObjectShell* pDoc = pFrame->GetObjectShell() ;
    1012          63 :             SfxViewFrame *pView = SfxViewFrame::GetFirst(pDoc);
    1013         189 :             while( pView )
    1014             :             {
    1015             :                 // if there is another ViewFrame or currently the ViewShell in my ViewFrame is switched (PagePreview)
    1016          63 :                 if ( pView != pFrame || pView->GetViewShell() != m_pData->m_pViewShell )
    1017           0 :                     break;
    1018          63 :                 pView = SfxViewFrame::GetNext( *pView, pDoc );
    1019             :             }
    1020             : 
    1021          63 :             SFX_APP()->NotifyEvent( SfxViewEventHint(SFX_EVENT_CLOSEVIEW, GlobalEventConfig::GetEventName( STR_EVENT_CLOSEVIEW ), pDoc, uno::Reference< frame::XController2 >( this ) ) );
    1022          63 :             if ( !pView )
    1023          63 :                 SFX_APP()->NotifyEvent( SfxEventHint(SFX_EVENT_CLOSEDOC, GlobalEventConfig::GetEventName( STR_EVENT_CLOSEDOC ), pDoc) );
    1024             : 
    1025          63 :             REFERENCE< XMODEL > xModel = pDoc->GetModel();
    1026          63 :             REFERENCE < ::com::sun::star::util::XCloseable > xCloseable( xModel, com::sun::star::uno::UNO_QUERY );
    1027          63 :             if ( xModel.is() )
    1028             :             {
    1029          63 :                 xModel->disconnectController( this );
    1030          63 :                 if ( xCloseable.is() )
    1031          63 :                     xCloseable->removeCloseListener( m_pData->m_xCloseListener );
    1032             :             }
    1033             : 
    1034          63 :             REFERENCE < XFRAME > aXFrame;
    1035          63 :             attachFrame( aXFrame );
    1036             : 
    1037          63 :             m_pData->m_xListener->disposing( aObject );
    1038          63 :             SfxViewShell *pShell = m_pData->m_pViewShell;
    1039          63 :             m_pData->m_pViewShell = NULL;
    1040          63 :             if ( pFrame->GetViewShell() == pShell )
    1041             :             {
    1042             :                 // Enter registrations only allowed if we are the owner!
    1043          63 :                 if ( pFrame->GetFrame().OwnsBindings_Impl() )
    1044          63 :                     pFrame->GetBindings().ENTERREGISTRATIONS();
    1045          63 :                 pFrame->GetFrame().SetFrameInterface_Impl(  aXFrame );
    1046          63 :                 pFrame->GetFrame().DoClose_Impl();
    1047          63 :             }
    1048             :         }
    1049          63 :     }
    1050          63 : }
    1051             : 
    1052             : //________________________________________________________________________________________________________
    1053             : //  SfxBaseController -> XComponent
    1054             : //________________________________________________________________________________________________________
    1055             : 
    1056         244 : void SAL_CALL SfxBaseController::addEventListener( const REFERENCE< XEVENTLISTENER >& aListener ) throw( ::com::sun::star::uno::RuntimeException )
    1057             : {
    1058         244 :     m_pData->m_aListenerContainer.addInterface( ::getCppuType((const REFERENCE< XEVENTLISTENER >*)0), aListener );
    1059         244 : }
    1060             : 
    1061             : //________________________________________________________________________________________________________
    1062             : //  SfxBaseController -> XComponent
    1063             : //________________________________________________________________________________________________________
    1064             : 
    1065          63 : void SAL_CALL SfxBaseController::removeEventListener( const REFERENCE< XEVENTLISTENER >& aListener ) throw( ::com::sun::star::uno::RuntimeException )
    1066             : {
    1067          63 :     m_pData->m_aListenerContainer.removeInterface( ::getCppuType((const REFERENCE< XEVENTLISTENER >*)0), aListener );
    1068          63 : }
    1069             : 
    1070          63 : void SfxBaseController::ReleaseShell_Impl()
    1071             : {
    1072          63 :     SolarMutexGuard aGuard;
    1073          63 :     if ( m_pData->m_pViewShell )
    1074             :     {
    1075           0 :         SfxObjectShell* pDoc = m_pData->m_pViewShell->GetObjectShell() ;
    1076           0 :         REFERENCE< XMODEL > xModel = pDoc->GetModel();
    1077           0 :         REFERENCE < ::com::sun::star::util::XCloseable > xCloseable( xModel, com::sun::star::uno::UNO_QUERY );
    1078           0 :         if ( xModel.is() )
    1079             :         {
    1080           0 :             xModel->disconnectController( this );
    1081           0 :             if ( xCloseable.is() )
    1082           0 :                 xCloseable->removeCloseListener( m_pData->m_xCloseListener );
    1083             :         }
    1084           0 :         m_pData->m_pViewShell = 0;
    1085             : 
    1086           0 :         REFERENCE < XFRAME > aXFrame;
    1087           0 :         attachFrame( aXFrame );
    1088          63 :     }
    1089          63 : }
    1090             : 
    1091         660 : SfxViewShell* SfxBaseController::GetViewShell_Impl() const
    1092             : {
    1093         660 :     return m_pData->m_pViewShell;
    1094             : }
    1095             : 
    1096           0 : ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator > SAL_CALL SfxBaseController::getStatusIndicator(  ) throw (::com::sun::star::uno::RuntimeException)
    1097             : {
    1098           0 :     SolarMutexGuard aGuard;
    1099           0 :     if ( m_pData->m_pViewShell && !m_pData->m_xIndicator.is() )
    1100           0 :         m_pData->m_xIndicator = new SfxStatusIndicator( this, m_pData->m_pViewShell->GetViewFrame()->GetFrame().GetWorkWindow_Impl() );
    1101           0 :     return m_pData->m_xIndicator;
    1102             : }
    1103             : 
    1104           0 : void SAL_CALL SfxBaseController::registerContextMenuInterceptor( const REFERENCE< XCONTEXTMENUINTERCEPTOR >& xInterceptor ) throw( RUNTIMEEXCEPTION )
    1105             : 
    1106             : {
    1107           0 :     m_pData->m_aInterceptorContainer.addInterface( xInterceptor );
    1108             : 
    1109           0 :     SolarMutexGuard aGuard;
    1110           0 :     if ( m_pData->m_pViewShell )
    1111           0 :         m_pData->m_pViewShell->AddContextMenuInterceptor_Impl( xInterceptor );
    1112           0 : }
    1113             : 
    1114           0 : void SAL_CALL SfxBaseController::releaseContextMenuInterceptor( const REFERENCE< XCONTEXTMENUINTERCEPTOR >& xInterceptor ) throw( RUNTIMEEXCEPTION )
    1115             : 
    1116             : {
    1117           0 :     m_pData->m_aInterceptorContainer.removeInterface( xInterceptor );
    1118             : 
    1119           0 :     SolarMutexGuard aGuard;
    1120           0 :     if ( m_pData->m_pViewShell )
    1121           0 :         m_pData->m_pViewShell->RemoveContextMenuInterceptor_Impl( xInterceptor );
    1122           0 : }
    1123             : 
    1124           0 : void SAL_CALL SfxBaseController::addKeyHandler( const ::com::sun::star::uno::Reference< XKEYHANDLER >& xHandler ) throw (::com::sun::star::uno::RuntimeException)
    1125             : {
    1126           0 :     SolarMutexGuard aGuard;
    1127           0 :     m_pData->m_aUserInputInterception.addKeyHandler( xHandler );
    1128           0 : }
    1129             : 
    1130           0 : void SAL_CALL SfxBaseController::removeKeyHandler( const ::com::sun::star::uno::Reference< XKEYHANDLER >& xHandler ) throw (::com::sun::star::uno::RuntimeException)
    1131             : {
    1132           0 :     SolarMutexGuard aGuard;
    1133           0 :     m_pData->m_aUserInputInterception.removeKeyHandler( xHandler );
    1134           0 : }
    1135             : 
    1136           0 : void SAL_CALL SfxBaseController::addMouseClickHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseClickHandler >& xHandler ) throw (::com::sun::star::uno::RuntimeException)
    1137             : {
    1138           0 :     SolarMutexGuard aGuard;
    1139           0 :     m_pData->m_aUserInputInterception.addMouseClickHandler( xHandler );
    1140           0 : }
    1141             : 
    1142           0 : void SAL_CALL SfxBaseController::removeMouseClickHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseClickHandler >& xHandler ) throw (::com::sun::star::uno::RuntimeException)
    1143             : {
    1144           0 :     SolarMutexGuard aGuard;
    1145           0 :     m_pData->m_aUserInputInterception.removeMouseClickHandler( xHandler );
    1146           0 : }
    1147             : 
    1148           0 : ::com::sun::star::uno::Sequence< sal_Int16 > SAL_CALL SfxBaseController::getSupportedCommandGroups()
    1149             : throw (::com::sun::star::uno::RuntimeException)
    1150             : {
    1151           0 :     SolarMutexGuard aGuard;
    1152             : 
    1153           0 :     std::list< sal_Int16 > aGroupList;
    1154           0 :     SfxViewFrame* pViewFrame( m_pData->m_pViewShell->GetFrame() );
    1155           0 :     SfxSlotPool*  pPool = &SfxSlotPool::GetSlotPool( pViewFrame );
    1156             : 
    1157           0 :     SfxSlotPool* pSlotPool = pPool ? pPool : &SFX_SLOTPOOL();
    1158           0 :     const sal_uIntPtr nMode( SFX_SLOT_TOOLBOXCONFIG|SFX_SLOT_ACCELCONFIG|SFX_SLOT_MENUCONFIG );
    1159             : 
    1160             :     // Select Group ( Group 0 is internal )
    1161           0 :     for ( sal_uInt16 i=0; i<pSlotPool->GetGroupCount(); i++ )
    1162             :     {
    1163           0 :         String aName = pSlotPool->SeekGroup( i );
    1164           0 :         const SfxSlot* pSfxSlot = pSlotPool->FirstSlot();
    1165           0 :         while ( pSfxSlot )
    1166             :         {
    1167           0 :             if ( pSfxSlot->GetMode() & nMode )
    1168             :             {
    1169           0 :                 sal_Int16 nCommandGroup = MapGroupIDToCommandGroup( pSfxSlot->GetGroupId() );
    1170           0 :                 aGroupList.push_back( nCommandGroup );
    1171             :                 break;
    1172             :             }
    1173           0 :             pSfxSlot = pSlotPool->NextSlot();
    1174             :         }
    1175           0 :     }
    1176             : 
    1177             :     ::com::sun::star::uno::Sequence< sal_Int16 > aSeq =
    1178           0 :         comphelper::containerToSequence< sal_Int16 >( aGroupList );
    1179           0 :     return aSeq;
    1180             : }
    1181             : 
    1182           0 : ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchInformation > SAL_CALL SfxBaseController::getConfigurableDispatchInformation( sal_Int16 nCmdGroup )
    1183             : throw (::com::sun::star::uno::RuntimeException)
    1184             : {
    1185           0 :     std::list< ::com::sun::star::frame::DispatchInformation > aCmdList;
    1186             : 
    1187           0 :     SolarMutexGuard aGuard;
    1188           0 :     if ( m_pData->m_pViewShell )
    1189             :     {
    1190           0 :         const sal_uIntPtr nMode( SFX_SLOT_TOOLBOXCONFIG|SFX_SLOT_ACCELCONFIG|SFX_SLOT_MENUCONFIG );
    1191             : 
    1192           0 :         SfxViewFrame* pViewFrame( m_pData->m_pViewShell->GetFrame() );
    1193           0 :         SfxSlotPool*  pPool( &SfxSlotPool::GetSlotPool( pViewFrame ));
    1194           0 :         rtl::OUString aCmdPrefix( ".uno:" );
    1195             : 
    1196           0 :         SfxSlotPool* pSlotPool = pPool ? pPool : &SFX_SLOTPOOL();
    1197           0 :         for ( sal_uInt16 i=0; i<pSlotPool->GetGroupCount(); i++ )
    1198             :         {
    1199           0 :             String aName = pSlotPool->SeekGroup( i );
    1200           0 :             const SfxSlot* pSfxSlot = pSlotPool->FirstSlot();
    1201           0 :             if ( pSfxSlot )
    1202             :             {
    1203           0 :                 sal_Int16 nCommandGroup = MapGroupIDToCommandGroup( pSfxSlot->GetGroupId() );
    1204           0 :                 if ( nCommandGroup == nCmdGroup )
    1205             :                 {
    1206           0 :                     while ( pSfxSlot )
    1207             :                     {
    1208           0 :                         if ( pSfxSlot->GetMode() & nMode )
    1209             :                         {
    1210           0 :                             ::com::sun::star::frame::DispatchInformation aCmdInfo;
    1211           0 :                             ::rtl::OUStringBuffer aBuf( aCmdPrefix );
    1212           0 :                             aBuf.appendAscii( pSfxSlot->GetUnoName() );
    1213           0 :                             aCmdInfo.Command = aBuf.makeStringAndClear();
    1214           0 :                             aCmdInfo.GroupId = nCommandGroup;
    1215           0 :                             aCmdList.push_back( aCmdInfo );
    1216             :                         }
    1217           0 :                         pSfxSlot = pSlotPool->NextSlot();
    1218             :                     }
    1219             :                 }
    1220             :             }
    1221           0 :         }
    1222             :     }
    1223             : 
    1224             :     ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchInformation > aSeq =
    1225           0 :         comphelper::containerToSequence< ::com::sun::star::frame::DispatchInformation, std::list< ::com::sun::star::frame::DispatchInformation > >( aCmdList );
    1226             : 
    1227           0 :     return aSeq;
    1228             : }
    1229             : 
    1230           0 : sal_Bool SfxBaseController::HandleEvent_Impl( NotifyEvent& rEvent )
    1231             : {
    1232           0 :     return m_pData->m_aUserInputInterception.handleNotifyEvent( rEvent );
    1233             : }
    1234             : 
    1235           0 : sal_Bool SfxBaseController::HasKeyListeners_Impl()
    1236             : {
    1237           0 :     return m_pData->m_aUserInputInterception.hasKeyHandlers();
    1238             : }
    1239             : 
    1240           0 : sal_Bool SfxBaseController::HasMouseClickListeners_Impl()
    1241             : {
    1242           0 :     return m_pData->m_aUserInputInterception.hasMouseClickListeners();
    1243             : }
    1244             : 
    1245         240 : void SfxBaseController::ConnectSfxFrame_Impl( const ConnectSfxFrame i_eConnect )
    1246             : {
    1247         240 :     ENSURE_OR_THROW( m_pData->m_pViewShell, "not to be called without a view shell" );
    1248         240 :     SfxViewFrame* pViewFrame = m_pData->m_pViewShell->GetFrame();
    1249         240 :     ENSURE_OR_THROW( pViewFrame, "a view shell without a view frame is pretty pathological" );
    1250             : 
    1251         240 :     const bool bConnect = ( i_eConnect != E_DISCONNECT );
    1252             : 
    1253             :     // disable window and dispatcher
    1254         240 :     pViewFrame->Enable( bConnect );
    1255         240 :     pViewFrame->GetDispatcher()->Lock( !bConnect );
    1256             : 
    1257         240 :     if ( bConnect )
    1258             :     {
    1259         240 :         if ( i_eConnect == E_CONNECT )
    1260             :         {
    1261         480 :             if  (   ( m_pData->m_pViewShell->GetObjectShell() != NULL )
    1262         240 :                 &&  ( m_pData->m_pViewShell->GetObjectShell()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
    1263             :                 )
    1264             :             {
    1265           0 :                 SfxViewFrame* pViewFrm = m_pData->m_pViewShell->GetViewFrame();
    1266           0 :                 if ( !pViewFrm->GetFrame().IsInPlace() )
    1267             :                 {
    1268             :                     // for outplace embedded objects, we want the layout manager to keep the content window
    1269             :                     // size constant, if possible
    1270             :                     try
    1271             :                     {
    1272           0 :                         uno::Reference< beans::XPropertySet > xFrameProps( m_pData->m_xFrame, uno::UNO_QUERY_THROW );
    1273             :                         uno::Reference< beans::XPropertySet > xLayouterProps(
    1274           0 :                             xFrameProps->getPropertyValue( ::rtl::OUString( "LayoutManager"  ) ), uno::UNO_QUERY_THROW );
    1275           0 :                         xLayouterProps->setPropertyValue( ::rtl::OUString( "PreserveContentSize"  ), uno::makeAny( sal_True ) );
    1276             :                     }
    1277           0 :                     catch (const uno::Exception&)
    1278             :                     {
    1279             :                         DBG_UNHANDLED_EXCEPTION();
    1280             :                     }
    1281             :                 }
    1282             :             }
    1283             :         }
    1284             : 
    1285             :         // upon DISCONNECT, we did *not* pop the shells from the stack (this is done elsewhere), so upon
    1286             :         // RECONNECT, we're not allowed to push them
    1287         240 :         if ( i_eConnect != E_RECONNECT )
    1288             :         {
    1289         240 :             pViewFrame->GetDispatcher()->Push( *m_pData->m_pViewShell );
    1290         240 :             if ( m_pData->m_pViewShell->GetSubShell() )
    1291           0 :                 pViewFrame->GetDispatcher()->Push( *m_pData->m_pViewShell->GetSubShell() );
    1292         240 :             m_pData->m_pViewShell->PushSubShells_Impl();
    1293         240 :             pViewFrame->GetDispatcher()->Flush();
    1294             :         }
    1295             : 
    1296         240 :         Window* pEditWin = m_pData->m_pViewShell->GetWindow();
    1297         240 :         if ( pEditWin && m_pData->m_pViewShell->IsShowView_Impl() )
    1298         240 :             pEditWin->Show();
    1299             : 
    1300         240 :         if ( SfxViewFrame::Current() == pViewFrame )
    1301           0 :             pViewFrame->GetDispatcher()->Update_Impl( sal_True );
    1302             : 
    1303         240 :         Window* pFrameWin = &pViewFrame->GetWindow();
    1304         240 :         if ( pFrameWin != &pViewFrame->GetFrame().GetWindow() )
    1305         240 :             pFrameWin->Show();
    1306             : 
    1307         240 :         if ( i_eConnect == E_CONNECT )
    1308             :         {
    1309         240 :             ::comphelper::NamedValueCollection aDocumentArgs( getModel()->getArgs() );
    1310             : 
    1311         240 :             const sal_Int16 nPluginMode = aDocumentArgs.getOrDefault( "PluginMode", sal_Int16( 0 ) );
    1312         240 :             const bool bHasPluginMode = ( nPluginMode != 0 );
    1313             : 
    1314         240 :             SfxFrame& rFrame = pViewFrame->GetFrame();
    1315         240 :             SfxObjectShell& rDoc = *m_pData->m_pViewShell->GetObjectShell();
    1316         240 :             if ( !rFrame.IsMarkedHidden_Impl() )
    1317             :             {
    1318         236 :                 if ( rDoc.IsHelpDocument() || ( nPluginMode == 2 ) )
    1319           0 :                     pViewFrame->GetDispatcher()->HideUI( sal_True );
    1320             :                 else
    1321         236 :                     pViewFrame->GetDispatcher()->HideUI( sal_False );
    1322             : 
    1323         236 :                 if ( rFrame.IsInPlace() )
    1324           0 :                     pViewFrame->LockAdjustPosSizePixel();
    1325             : 
    1326         236 :                 if ( nPluginMode == 3 )
    1327           0 :                     rFrame.GetWorkWindow_Impl()->SetInternalDockingAllowed( sal_False );
    1328             : 
    1329         236 :                 if ( !rFrame.IsInPlace() )
    1330         236 :                     pViewFrame->GetDispatcher()->Update_Impl();
    1331         236 :                 pViewFrame->Show();
    1332         236 :                 rFrame.GetWindow().Show();
    1333         236 :                 if ( !rFrame.IsInPlace() || ( nPluginMode == 3 ) )
    1334         236 :                     pViewFrame->MakeActive_Impl( rFrame.GetFrameInterface()->isActive() );
    1335             : 
    1336         236 :                 if ( rFrame.IsInPlace() )
    1337             :                 {
    1338           0 :                     pViewFrame->UnlockAdjustPosSizePixel();
    1339             :                     // force resize for OLE server to fix layout problems of writer and math
    1340             :                     // see i53651
    1341           0 :                     if ( nPluginMode == 3 )
    1342           0 :                         pViewFrame->Resize( sal_True );
    1343             :                 }
    1344             :             }
    1345             :             else
    1346             :             {
    1347             :                 DBG_ASSERT( !rFrame.IsInPlace() && !bHasPluginMode, "Special modes not compatible with hidden mode!" );
    1348           4 :                 rFrame.GetWindow().Show();
    1349             :             }
    1350             : 
    1351             :             // UpdateTitle now, hidden TopFrames have otherwise no Name!
    1352         240 :             pViewFrame->UpdateTitle();
    1353             : 
    1354         240 :             if ( !rFrame.IsInPlace() )
    1355         240 :                 pViewFrame->Resize( sal_True );
    1356             : 
    1357             :             // if there's a JumpMark given, then, well, jump to it
    1358         240 :             ::comphelper::NamedValueCollection aViewArgs( getCreationArguments() );
    1359         240 :             const ::rtl::OUString sJumpMark = aViewArgs.getOrDefault( "JumpMark", ::rtl::OUString() );
    1360         240 :             const bool bHasJumpMark = !sJumpMark.isEmpty();
    1361             :             OSL_ENSURE( ( !m_pData->m_pViewShell->GetObjectShell()->IsLoading() )
    1362             :                     ||  ( sJumpMark.isEmpty() ),
    1363             :                 "SfxBaseController::ConnectSfxFrame_Impl: so this code wasn't dead?" );
    1364             :                 // Before CWS autorecovery, there was code which postponed jumping to the Mark to a later time
    1365             :                 // (SfxObjectShell::PositionView_Impl), but it seems this branch was never used, since this method
    1366             :                 // here is never called before the load process finished. At least not with a non-empty jump mark
    1367         240 :             if ( !sJumpMark.isEmpty() )
    1368           0 :                 m_pData->m_pViewShell->JumpToMark( sJumpMark );
    1369             : 
    1370             :             // if no plugin mode and no jump mark was supplied, check whether the document itself can provide view data, and
    1371             :             // if so, forward it to the view/shell.
    1372         240 :             if ( !bHasPluginMode && !bHasJumpMark )
    1373             :             {
    1374             :                 // Note that this might not be the ideal place here. Restoring view data should, IMO, be the
    1375             :                 // responsibility of the loader, not an implementation detail burried here deep within the controller's
    1376             :                 // implementation.
    1377             :                 // What I think should be done to replace the below code:
    1378             :                 // - change SfxBaseController::restoreViewData to also accept a PropertyValue[] (it currently accepts
    1379             :                 //   a string only), and forward it to its ViewShell's ReadUserDataSequence
    1380             :                 // - change the frame loader so that when a new document is loaded (as opposed to an existing
    1381             :                 //   document being loaded into a new frame), the model's view data is examine the very same
    1382             :                 //   way as below, and the proper view data is set via XController::restoreViewData
    1383             :                 // - extend SfxViewFrame::SwitchToViewShell_Impl. Currently, it cares for the case where a non-PrintPreview
    1384             :                 //   view is exchanged, and sets the old view's data at the model. It should also care for the other
    1385             :                 //   way, were the PrintPreview view is left: in this case, the new view should also be initialized
    1386             :                 //   with the model's view data
    1387             :                 try
    1388             :                 {
    1389         240 :                     Reference< XViewDataSupplier > xViewDataSupplier( getModel(), UNO_QUERY_THROW );
    1390         240 :                     Reference< XIndexAccess > xViewData( xViewDataSupplier->getViewData() );
    1391             : 
    1392             :                     // find the view data item whose ViewId matches the ID of the view we're just connecting to
    1393         240 :                     const SfxObjectFactory& rDocFactory( rDoc.GetFactory() );
    1394         240 :                     const sal_Int32 nCount = xViewData.is() ? xViewData->getCount() : 0;
    1395         240 :                     sal_Int32 nViewDataIndex = 0;
    1396         355 :                     for ( sal_Int32 i=0; i<nCount; ++i )
    1397             :                     {
    1398         236 :                         const ::comphelper::NamedValueCollection aViewData( xViewData->getByIndex(i) );
    1399         236 :                         ::rtl::OUString sViewId( aViewData.getOrDefault( "ViewId", ::rtl::OUString() ) );
    1400         236 :                         if ( sViewId.isEmpty() )
    1401         115 :                             continue;
    1402             : 
    1403         121 :                         const SfxViewFactory* pViewFactory = rDocFactory.GetViewFactoryByViewName( sViewId );
    1404         121 :                         if ( pViewFactory == NULL )
    1405           0 :                             continue;
    1406             : 
    1407         121 :                         if ( pViewFactory->GetOrdinal() == pViewFrame->GetCurViewId() )
    1408             :                         {
    1409         121 :                             nViewDataIndex = i;
    1410             :                             break;
    1411             :                         }
    1412         236 :                     }
    1413         240 :                     if ( nViewDataIndex < nCount )
    1414             :                     {
    1415         236 :                         Sequence< PropertyValue > aViewData;
    1416         236 :                         OSL_VERIFY( xViewData->getByIndex( nViewDataIndex ) >>= aViewData );
    1417         236 :                         if ( aViewData.getLength() > 0 )
    1418         236 :                             m_pData->m_pViewShell->ReadUserDataSequence( aViewData, sal_True );
    1419         240 :                     }
    1420             :                 }
    1421           0 :                 catch (const Exception&)
    1422             :                 {
    1423             :                     DBG_UNHANDLED_EXCEPTION();
    1424             :                 }
    1425         240 :             }
    1426             :         }
    1427             :     }
    1428             : 
    1429             :     // invalidate slot corresponding to the view shell
    1430         240 :     const sal_uInt16 nViewNo = m_pData->m_pViewShell->GetObjectShell()->GetFactory().GetViewNo_Impl( pViewFrame->GetCurViewId(), USHRT_MAX );
    1431             :     DBG_ASSERT( nViewNo != USHRT_MAX, "view shell id not found" );
    1432         240 :     if ( nViewNo != USHRT_MAX )
    1433         240 :         pViewFrame->GetBindings().Invalidate( nViewNo + SID_VIEWSHELL0 );
    1434         240 : }
    1435             : 
    1436         240 : void SfxBaseController::ShowInfoBars( )
    1437             : {
    1438         240 :     if ( m_pData->m_pViewShell )
    1439             :     {
    1440             :         // CMIS verifications
    1441         240 :         REFERENCE< document::XCmisDocument > xCmisDoc( m_pData->m_pViewShell->GetObjectShell()->GetModel(), uno::UNO_QUERY );
    1442         240 :         if ( xCmisDoc.is( ) )
    1443             :         {
    1444         240 :             beans::PropertyValues aCmisProperties = xCmisDoc->getCmisPropertiesValues( );
    1445             : 
    1446         240 :             if ( xCmisDoc->isVersionable( ) && aCmisProperties.hasElements( ) )
    1447             :             {
    1448             :                 // Loop over the CMIS Properties to find cmis:isVersionSeriesCheckedOut
    1449           0 :                 bool bFoundCheckedout = false;
    1450           0 :                 sal_Bool bCheckedOut = sal_False;
    1451           0 :                 for ( sal_Int32 i = 0; i < aCmisProperties.getLength() && !bFoundCheckedout; ++i )
    1452             :                 {
    1453           0 :                     if ( aCmisProperties[i].Name == "cmis:isVersionSeriesCheckedOut" )
    1454             :                     {
    1455           0 :                         bFoundCheckedout = true;
    1456           0 :                         aCmisProperties[i].Value >>= bCheckedOut;
    1457             :                     }
    1458             :                 }
    1459             : 
    1460           0 :                 if ( !bCheckedOut )
    1461             :                 {
    1462             :                     // Get the Frame and show the InfoBar if not checked out
    1463           0 :                     SfxViewFrame* pViewFrame = m_pData->m_pViewShell->GetFrame();
    1464           0 :                     std::vector< PushButton* > aButtons;
    1465           0 :                     PushButton* pBtn = new PushButton( &pViewFrame->GetWindow(), SfxResId( BT_CHECKOUT ) );
    1466           0 :                     pBtn->SetClickHdl( LINK( this, SfxBaseController, CheckOutHandler ) );
    1467           0 :                     aButtons.push_back( pBtn );
    1468           0 :                     pViewFrame->AppendInfoBar( "checkout", SfxResId( STR_NONCHECKEDOUT_DOCUMENT ), aButtons );
    1469             :                 }
    1470         240 :             }
    1471         240 :         }
    1472             :     }
    1473         240 : }
    1474             : 
    1475           0 : IMPL_LINK_NOARG ( SfxBaseController, CheckOutHandler )
    1476             : {
    1477           0 :     if ( m_pData->m_pViewShell )
    1478           0 :         m_pData->m_pViewShell->GetObjectShell()->CheckOut( );
    1479           0 :     return 0;
    1480             : }
    1481             : 
    1482             : 
    1483             : //=============================================================================
    1484         846 : css::uno::Reference< css::frame::XTitle > SfxBaseController::impl_getTitleHelper ()
    1485             : {
    1486         846 :     SolarMutexGuard aGuard;
    1487             : 
    1488         846 :     if ( ! m_pData->m_xTitleHelper.is ())
    1489             :     {
    1490         240 :         css::uno::Reference< css::frame::XModel >           xModel           = getModel ();
    1491         240 :         css::uno::Reference< css::frame::XUntitledNumbers > xUntitledProvider(xModel                                       , css::uno::UNO_QUERY      );
    1492         240 :         css::uno::Reference< css::frame::XController >      xThis            (static_cast< css::frame::XController* >(this), css::uno::UNO_QUERY_THROW);
    1493             : 
    1494         240 :         ::framework::TitleHelper* pHelper                 = new ::framework::TitleHelper(::comphelper::getProcessComponentContext());
    1495         240 :                                   m_pData->m_xTitleHelper = css::uno::Reference< css::frame::XTitle >(static_cast< ::cppu::OWeakObject* >(pHelper), css::uno::UNO_QUERY_THROW);
    1496             : 
    1497         240 :         pHelper->setOwner                   (xThis            );
    1498         240 :         pHelper->connectWithUntitledNumbers (xUntitledProvider);
    1499             :     }
    1500             : 
    1501         846 :     return m_pData->m_xTitleHelper;
    1502             : }
    1503             : 
    1504             : //=============================================================================
    1505             : // css::frame::XTitle
    1506         606 : ::rtl::OUString SAL_CALL SfxBaseController::getTitle()
    1507             :     throw (css::uno::RuntimeException)
    1508             : {
    1509         606 :     return impl_getTitleHelper()->getTitle ();
    1510             : }
    1511             : 
    1512             : //=============================================================================
    1513             : // css::frame::XTitle
    1514           0 : void SAL_CALL SfxBaseController::setTitle(const ::rtl::OUString& sTitle)
    1515             :     throw (css::uno::RuntimeException)
    1516             : {
    1517           0 :     impl_getTitleHelper()->setTitle (sTitle);
    1518           0 : }
    1519             : 
    1520             : //=============================================================================
    1521             : // css::frame::XTitleChangeBroadcaster
    1522         240 : void SAL_CALL SfxBaseController::addTitleChangeListener(const css::uno::Reference< css::frame::XTitleChangeListener >& xListener)
    1523             :     throw (css::uno::RuntimeException)
    1524             : {
    1525         240 :     css::uno::Reference< css::frame::XTitleChangeBroadcaster > xBroadcaster(impl_getTitleHelper(), css::uno::UNO_QUERY);
    1526         240 :     if (xBroadcaster.is ())
    1527         240 :         xBroadcaster->addTitleChangeListener (xListener);
    1528         240 : }
    1529             : 
    1530             : //=============================================================================
    1531             : // css::frame::XTitleChangeBroadcaster
    1532           0 : void SAL_CALL SfxBaseController::removeTitleChangeListener(const css::uno::Reference< css::frame::XTitleChangeListener >& xListener)
    1533             :     throw (css::uno::RuntimeException)
    1534             : {
    1535           0 :     css::uno::Reference< css::frame::XTitleChangeBroadcaster > xBroadcaster(impl_getTitleHelper(), css::uno::UNO_QUERY);
    1536           0 :     if (xBroadcaster.is ())
    1537           0 :         xBroadcaster->removeTitleChangeListener (xListener);
    1538           0 : }
    1539             : 
    1540             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10