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