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 #include <svl/stritem.hxx> 31*cdf0e10cSrcweir #include <svl/eitem.hxx> 32*cdf0e10cSrcweir #include <svl/whiter.hxx> 33*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 34*cdf0e10cSrcweir #include <vcl/toolbox.hxx> 35*cdf0e10cSrcweir #include <svl/intitem.hxx> 36*cdf0e10cSrcweir #include <svtools/sfxecode.hxx> 37*cdf0e10cSrcweir #include <svtools/ehdl.hxx> 38*cdf0e10cSrcweir #include <com/sun/star/frame/XLayoutManager.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/frame/XModuleManager.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/embed/EmbedStates.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/embed/EmbedMisc.hpp> 43*cdf0e10cSrcweir #include <com/sun/star/system/XSystemShellExecute.hpp> 44*cdf0e10cSrcweir #include <com/sun/star/system/SystemShellExecuteFlags.hpp> 45*cdf0e10cSrcweir #include <com/sun/star/container/XContainerQuery.hpp> 46*cdf0e10cSrcweir #include <com/sun/star/frame/XStorable.hpp> 47*cdf0e10cSrcweir #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp> 48*cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir #include <osl/file.hxx> 51*cdf0e10cSrcweir #include <vos/mutex.hxx> 52*cdf0e10cSrcweir #include <tools/urlobj.hxx> 53*cdf0e10cSrcweir #include <unotools/tempfile.hxx> 54*cdf0e10cSrcweir #include <unotools/pathoptions.hxx> 55*cdf0e10cSrcweir #include <svtools/miscopt.hxx> 56*cdf0e10cSrcweir #include <svtools/soerr.hxx> 57*cdf0e10cSrcweir #include <unotools/internaloptions.hxx> 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir #include <unotools/javaoptions.hxx> 60*cdf0e10cSrcweir #include <basic/basmgr.hxx> 61*cdf0e10cSrcweir #include <basic/sbuno.hxx> 62*cdf0e10cSrcweir #include <framework/actiontriggerhelper.hxx> 63*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 64*cdf0e10cSrcweir #include <comphelper/sequenceashashmap.hxx> 65*cdf0e10cSrcweir #include <toolkit/unohlp.hxx> 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir #include <sfx2/app.hxx> 69*cdf0e10cSrcweir #include "view.hrc" 70*cdf0e10cSrcweir #include <sfx2/viewsh.hxx> 71*cdf0e10cSrcweir #include "viewimp.hxx" 72*cdf0e10cSrcweir #include "sfx2/sfxresid.hxx" 73*cdf0e10cSrcweir #include <sfx2/request.hxx> 74*cdf0e10cSrcweir #include <sfx2/templdlg.hxx> 75*cdf0e10cSrcweir #include <sfx2/printer.hxx> 76*cdf0e10cSrcweir #include <sfx2/docfile.hxx> 77*cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 78*cdf0e10cSrcweir #include "arrdecl.hxx" 79*cdf0e10cSrcweir #include <sfx2/docfac.hxx> 80*cdf0e10cSrcweir #include "view.hrc" 81*cdf0e10cSrcweir #include "sfxlocal.hrc" 82*cdf0e10cSrcweir #include <sfx2/sfxbasecontroller.hxx> 83*cdf0e10cSrcweir #include "sfx2/mailmodelapi.hxx" 84*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 85*cdf0e10cSrcweir #include <sfx2/event.hxx> 86*cdf0e10cSrcweir #include <sfx2/fcontnr.hxx> 87*cdf0e10cSrcweir #include <sfx2/ipclient.hxx> 88*cdf0e10cSrcweir #include "workwin.hxx" 89*cdf0e10cSrcweir #include <sfx2/objface.hxx> 90*cdf0e10cSrcweir #include <sfx2/docfilt.hxx> 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir // #110897# 93*cdf0e10cSrcweir #ifndef _UNOTOOLS_PROCESSFACTORY_HXX 94*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 95*cdf0e10cSrcweir #endif 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir using namespace ::com::sun::star; 98*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 99*cdf0e10cSrcweir using namespace ::com::sun::star::frame; 100*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 101*cdf0e10cSrcweir using namespace ::com::sun::star::util; 102*cdf0e10cSrcweir using namespace ::com::sun::star::system; 103*cdf0e10cSrcweir using namespace ::cppu; 104*cdf0e10cSrcweir namespace css = ::com::sun::star; 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir //========================================================================= 107*cdf0e10cSrcweir DBG_NAME(SfxViewShell) 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir #define SfxViewShell 110*cdf0e10cSrcweir #include "sfxslots.hxx" 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir //========================================================================= 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir class SfxClipboardChangeListener : public ::cppu::WeakImplHelper1< 115*cdf0e10cSrcweir datatransfer::clipboard::XClipboardListener > 116*cdf0e10cSrcweir { 117*cdf0e10cSrcweir public: 118*cdf0e10cSrcweir SfxClipboardChangeListener( SfxViewShell* pView, const uno::Reference< datatransfer::clipboard::XClipboardNotifier >& xClpbrdNtfr ); 119*cdf0e10cSrcweir virtual ~SfxClipboardChangeListener(); 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir // XEventListener 122*cdf0e10cSrcweir virtual void SAL_CALL disposing( const lang::EventObject& rEventObject ) 123*cdf0e10cSrcweir throw ( uno::RuntimeException ); 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir // XClipboardListener 126*cdf0e10cSrcweir virtual void SAL_CALL changedContents( const datatransfer::clipboard::ClipboardEvent& rEventObject ) 127*cdf0e10cSrcweir throw ( uno::RuntimeException ); 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir void DisconnectViewShell() { m_pViewShell = NULL; } 130*cdf0e10cSrcweir void ChangedContents(); 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir enum AsyncExecuteCmd 133*cdf0e10cSrcweir { 134*cdf0e10cSrcweir ASYNCEXECUTE_CMD_DISPOSING, 135*cdf0e10cSrcweir ASYNCEXECUTE_CMD_CHANGEDCONTENTS 136*cdf0e10cSrcweir }; 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir struct AsyncExecuteInfo 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir AsyncExecuteInfo( AsyncExecuteCmd eCmd, uno::Reference< datatransfer::clipboard::XClipboardListener > xThis, SfxClipboardChangeListener* pListener ) : 141*cdf0e10cSrcweir m_eCmd( eCmd ), m_xThis( xThis ), m_pListener( pListener ) {} 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir AsyncExecuteCmd m_eCmd; 144*cdf0e10cSrcweir uno::Reference< datatransfer::clipboard::XClipboardListener > m_xThis; 145*cdf0e10cSrcweir SfxClipboardChangeListener* m_pListener; 146*cdf0e10cSrcweir }; 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir private: 149*cdf0e10cSrcweir SfxViewShell* m_pViewShell; 150*cdf0e10cSrcweir uno::Reference< datatransfer::clipboard::XClipboardNotifier > m_xClpbrdNtfr; 151*cdf0e10cSrcweir uno::Reference< lang::XComponent > m_xCtrl; 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir DECL_STATIC_LINK( SfxClipboardChangeListener, AsyncExecuteHdl_Impl, AsyncExecuteInfo* ); 154*cdf0e10cSrcweir }; 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir SfxClipboardChangeListener::SfxClipboardChangeListener( SfxViewShell* pView, const uno::Reference< datatransfer::clipboard::XClipboardNotifier >& xClpbrdNtfr ) 157*cdf0e10cSrcweir : m_pViewShell( 0 ), m_xClpbrdNtfr( xClpbrdNtfr ) 158*cdf0e10cSrcweir { 159*cdf0e10cSrcweir m_xCtrl = uno::Reference < lang::XComponent >( pView->GetController(), uno::UNO_QUERY ); 160*cdf0e10cSrcweir if ( m_xCtrl.is() ) 161*cdf0e10cSrcweir { 162*cdf0e10cSrcweir m_xCtrl->addEventListener( uno::Reference < lang::XEventListener > ( static_cast < lang::XEventListener* >( this ) ) ); 163*cdf0e10cSrcweir m_pViewShell = pView; 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir if ( m_xClpbrdNtfr.is() ) 166*cdf0e10cSrcweir { 167*cdf0e10cSrcweir m_xClpbrdNtfr->addClipboardListener( uno::Reference< datatransfer::clipboard::XClipboardListener >( 168*cdf0e10cSrcweir static_cast< datatransfer::clipboard::XClipboardListener* >( this ))); 169*cdf0e10cSrcweir } 170*cdf0e10cSrcweir } 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir SfxClipboardChangeListener::~SfxClipboardChangeListener() 173*cdf0e10cSrcweir { 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir void SfxClipboardChangeListener::ChangedContents() 177*cdf0e10cSrcweir { 178*cdf0e10cSrcweir const ::vos::OGuard aGuard( Application::GetSolarMutex() ); 179*cdf0e10cSrcweir if( m_pViewShell ) 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir SfxBindings& rBind = m_pViewShell->GetViewFrame()->GetBindings(); 182*cdf0e10cSrcweir rBind.Invalidate( SID_PASTE ); 183*cdf0e10cSrcweir rBind.Invalidate( SID_PASTE_SPECIAL ); 184*cdf0e10cSrcweir rBind.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS ); 185*cdf0e10cSrcweir } 186*cdf0e10cSrcweir } 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir IMPL_STATIC_LINK_NOINSTANCE( SfxClipboardChangeListener, AsyncExecuteHdl_Impl, AsyncExecuteInfo*, pAsyncExecuteInfo ) 189*cdf0e10cSrcweir { 190*cdf0e10cSrcweir if ( pAsyncExecuteInfo ) 191*cdf0e10cSrcweir { 192*cdf0e10cSrcweir uno::Reference< datatransfer::clipboard::XClipboardListener > xThis( pAsyncExecuteInfo->m_xThis ); 193*cdf0e10cSrcweir if ( pAsyncExecuteInfo->m_pListener ) 194*cdf0e10cSrcweir { 195*cdf0e10cSrcweir if ( pAsyncExecuteInfo->m_eCmd == ASYNCEXECUTE_CMD_DISPOSING ) 196*cdf0e10cSrcweir pAsyncExecuteInfo->m_pListener->DisconnectViewShell(); 197*cdf0e10cSrcweir else if ( pAsyncExecuteInfo->m_eCmd == ASYNCEXECUTE_CMD_CHANGEDCONTENTS ) 198*cdf0e10cSrcweir pAsyncExecuteInfo->m_pListener->ChangedContents(); 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir delete pAsyncExecuteInfo; 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir return 0; 204*cdf0e10cSrcweir } 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir void SAL_CALL SfxClipboardChangeListener::disposing( const lang::EventObject& /*rEventObject*/ ) 207*cdf0e10cSrcweir throw ( uno::RuntimeException ) 208*cdf0e10cSrcweir { 209*cdf0e10cSrcweir // Either clipboard or ViewShell is going to be destroyed -> no interest in listening anymore 210*cdf0e10cSrcweir uno::Reference< lang::XComponent > xCtrl( m_xCtrl ); 211*cdf0e10cSrcweir uno::Reference< datatransfer::clipboard::XClipboardNotifier > xNotify( m_xClpbrdNtfr ); 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir uno::Reference< datatransfer::clipboard::XClipboardListener > xThis( static_cast< datatransfer::clipboard::XClipboardListener* >( this )); 214*cdf0e10cSrcweir if ( xCtrl.is() ) 215*cdf0e10cSrcweir xCtrl->removeEventListener( uno::Reference < lang::XEventListener > ( static_cast < lang::XEventListener* >( this ))); 216*cdf0e10cSrcweir if ( xNotify.is() ) 217*cdf0e10cSrcweir xNotify->removeClipboardListener( xThis ); 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir // Make asynchronous call to avoid locking SolarMutex which is the 220*cdf0e10cSrcweir // root for many deadlocks, especially in conjuction with the "Windows" 221*cdf0e10cSrcweir // based single thread apartment clipboard code! 222*cdf0e10cSrcweir AsyncExecuteInfo* pInfo = new AsyncExecuteInfo( ASYNCEXECUTE_CMD_DISPOSING, xThis, this ); 223*cdf0e10cSrcweir Application::PostUserEvent( STATIC_LINK( 0, SfxClipboardChangeListener, AsyncExecuteHdl_Impl ), pInfo ); 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir void SAL_CALL SfxClipboardChangeListener::changedContents( const datatransfer::clipboard::ClipboardEvent& ) 227*cdf0e10cSrcweir throw ( RuntimeException ) 228*cdf0e10cSrcweir { 229*cdf0e10cSrcweir // Make asynchronous call to avoid locking SolarMutex which is the 230*cdf0e10cSrcweir // root for many deadlocks, especially in conjuction with the "Windows" 231*cdf0e10cSrcweir // based single thread apartment clipboard code! 232*cdf0e10cSrcweir uno::Reference< datatransfer::clipboard::XClipboardListener > xThis( static_cast< datatransfer::clipboard::XClipboardListener* >( this )); 233*cdf0e10cSrcweir AsyncExecuteInfo* pInfo = new AsyncExecuteInfo( ASYNCEXECUTE_CMD_CHANGEDCONTENTS, xThis, this ); 234*cdf0e10cSrcweir Application::PostUserEvent( STATIC_LINK( 0, SfxClipboardChangeListener, AsyncExecuteHdl_Impl ), pInfo ); 235*cdf0e10cSrcweir } 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir //========================================================================= 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir static ::rtl::OUString RetrieveLabelFromCommand( 240*cdf0e10cSrcweir const ::rtl::OUString& rCommandURL, 241*cdf0e10cSrcweir const css::uno::Reference< css::frame::XFrame >& rFrame ) 242*cdf0e10cSrcweir { 243*cdf0e10cSrcweir static css::uno::WeakReference< frame::XModuleManager > s_xModuleManager; 244*cdf0e10cSrcweir static css::uno::WeakReference< container::XNameAccess > s_xNameAccess; 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir ::rtl::OUString aLabel; 247*cdf0e10cSrcweir css::uno::Reference< css::frame::XModuleManager > xModuleManager( s_xModuleManager ); 248*cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > xNameAccess( s_xNameAccess ); 249*cdf0e10cSrcweir css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR( 250*cdf0e10cSrcweir ::comphelper::getProcessServiceFactory(), css::uno::UNO_QUERY_THROW); 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir try 253*cdf0e10cSrcweir { 254*cdf0e10cSrcweir if ( !xModuleManager.is() ) 255*cdf0e10cSrcweir { 256*cdf0e10cSrcweir xModuleManager = css::uno::Reference< css::frame::XModuleManager >( 257*cdf0e10cSrcweir xSMGR->createInstance( 258*cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ModuleManager" ))), 259*cdf0e10cSrcweir css::uno::UNO_QUERY_THROW ); 260*cdf0e10cSrcweir s_xModuleManager = xModuleManager; 261*cdf0e10cSrcweir } 262*cdf0e10cSrcweir 263*cdf0e10cSrcweir ::rtl::OUString aModuleIdentifier = xModuleManager->identify( rFrame ); 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir if ( !xNameAccess.is() ) 266*cdf0e10cSrcweir { 267*cdf0e10cSrcweir xNameAccess = css::uno::Reference< css::container::XNameAccess >( 268*cdf0e10cSrcweir xSMGR->createInstance( 269*cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.UICommandDescription" ))), 270*cdf0e10cSrcweir css::uno::UNO_QUERY_THROW ); 271*cdf0e10cSrcweir s_xNameAccess = xNameAccess; 272*cdf0e10cSrcweir } 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir css::uno::Any a = xNameAccess->getByName( aModuleIdentifier ); 275*cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > xUICommands; 276*cdf0e10cSrcweir a >>= xUICommands; 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir rtl::OUString aStr; 279*cdf0e10cSrcweir css::uno::Sequence< css::beans::PropertyValue > aPropSeq; 280*cdf0e10cSrcweir 281*cdf0e10cSrcweir a = xUICommands->getByName( rCommandURL ); 282*cdf0e10cSrcweir if ( a >>= aPropSeq ) 283*cdf0e10cSrcweir { 284*cdf0e10cSrcweir for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ ) 285*cdf0e10cSrcweir { 286*cdf0e10cSrcweir if ( aPropSeq[i].Name.equalsAscii( "Label" )) 287*cdf0e10cSrcweir { 288*cdf0e10cSrcweir aPropSeq[i].Value >>= aStr; 289*cdf0e10cSrcweir break; 290*cdf0e10cSrcweir } 291*cdf0e10cSrcweir } 292*cdf0e10cSrcweir aLabel = aStr; 293*cdf0e10cSrcweir } 294*cdf0e10cSrcweir } 295*cdf0e10cSrcweir catch ( css::uno::Exception& ) 296*cdf0e10cSrcweir { 297*cdf0e10cSrcweir } 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir return aLabel; 300*cdf0e10cSrcweir } 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir //========================================================================= 303*cdf0e10cSrcweir SfxViewShell_Impl::SfxViewShell_Impl(sal_uInt16 const nFlags) 304*cdf0e10cSrcweir : aInterceptorContainer( aMutex ) 305*cdf0e10cSrcweir , m_bControllerSet(false) 306*cdf0e10cSrcweir , m_nPrinterLocks(0) 307*cdf0e10cSrcweir , m_bCanPrint(SFX_VIEW_CAN_PRINT == (nFlags & SFX_VIEW_CAN_PRINT)) 308*cdf0e10cSrcweir , m_bHasPrintOptions( 309*cdf0e10cSrcweir SFX_VIEW_HAS_PRINTOPTIONS == (nFlags & SFX_VIEW_HAS_PRINTOPTIONS)) 310*cdf0e10cSrcweir , m_bPlugInsActive(true) 311*cdf0e10cSrcweir , m_bIsShowView(SFX_VIEW_NO_SHOW != (nFlags & SFX_VIEW_NO_SHOW)) 312*cdf0e10cSrcweir , m_bGotOwnership(false) 313*cdf0e10cSrcweir , m_bGotFrameOwnership(false) 314*cdf0e10cSrcweir , m_eScroll(SCROLLING_DEFAULT) 315*cdf0e10cSrcweir , m_nFamily(0xFFFF) // undefined, default set by TemplateDialog 316*cdf0e10cSrcweir , m_pController(0) 317*cdf0e10cSrcweir , m_pAccExec(0) 318*cdf0e10cSrcweir {} 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir //========================================================================= 321*cdf0e10cSrcweir SFX_IMPL_INTERFACE(SfxViewShell,SfxShell,SfxResId(0)) 322*cdf0e10cSrcweir { 323*cdf0e10cSrcweir SFX_CHILDWINDOW_REGISTRATION( SID_MAIL_CHILDWIN ); 324*cdf0e10cSrcweir } 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir TYPEINIT2(SfxViewShell,SfxShell,SfxListener); 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir //-------------------------------------------------------------------- 329*cdf0e10cSrcweir /** search for a filter name dependent on type and module 330*cdf0e10cSrcweir */ 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir static ::rtl::OUString impl_retrieveFilterNameFromTypeAndModule( 333*cdf0e10cSrcweir const css::uno::Reference< css::container::XContainerQuery >& rContainerQuery, 334*cdf0e10cSrcweir const ::rtl::OUString& rType, 335*cdf0e10cSrcweir const ::rtl::OUString& rModuleIdentifier, 336*cdf0e10cSrcweir const sal_Int32 nFlags ) 337*cdf0e10cSrcweir { 338*cdf0e10cSrcweir // Retrieve filter from type 339*cdf0e10cSrcweir css::uno::Sequence< css::beans::NamedValue > aQuery( 2 ); 340*cdf0e10cSrcweir aQuery[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Type" )); 341*cdf0e10cSrcweir aQuery[0].Value = css::uno::makeAny( rType ); 342*cdf0e10cSrcweir aQuery[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DocumentService" )); 343*cdf0e10cSrcweir aQuery[1].Value = css::uno::makeAny( rModuleIdentifier ); 344*cdf0e10cSrcweir 345*cdf0e10cSrcweir css::uno::Reference< css::container::XEnumeration > xEnumeration = 346*cdf0e10cSrcweir rContainerQuery->createSubSetEnumerationByProperties( aQuery ); 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir ::rtl::OUString aFoundFilterName; 349*cdf0e10cSrcweir while ( xEnumeration->hasMoreElements() ) 350*cdf0e10cSrcweir { 351*cdf0e10cSrcweir ::comphelper::SequenceAsHashMap aFilterPropsHM( xEnumeration->nextElement() ); 352*cdf0e10cSrcweir ::rtl::OUString aFilterName = aFilterPropsHM.getUnpackedValueOrDefault( 353*cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "Name" ), 354*cdf0e10cSrcweir ::rtl::OUString() ); 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir sal_Int32 nFilterFlags = aFilterPropsHM.getUnpackedValueOrDefault( 357*cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "Flags" ), 358*cdf0e10cSrcweir sal_Int32( 0 ) ); 359*cdf0e10cSrcweir 360*cdf0e10cSrcweir if ( nFilterFlags & nFlags ) 361*cdf0e10cSrcweir { 362*cdf0e10cSrcweir aFoundFilterName = aFilterName; 363*cdf0e10cSrcweir break; 364*cdf0e10cSrcweir } 365*cdf0e10cSrcweir } 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir return aFoundFilterName; 368*cdf0e10cSrcweir } 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir //-------------------------------------------------------------------- 371*cdf0e10cSrcweir /** search for an internal typename, which map to the current app module 372*cdf0e10cSrcweir and map also to a "family" of file formats as e.g. PDF/MS Doc/OOo Doc. 373*cdf0e10cSrcweir */ 374*cdf0e10cSrcweir enum ETypeFamily 375*cdf0e10cSrcweir { 376*cdf0e10cSrcweir E_MS_DOC, 377*cdf0e10cSrcweir E_OOO_DOC 378*cdf0e10cSrcweir }; 379*cdf0e10cSrcweir 380*cdf0e10cSrcweir ::rtl::OUString impl_searchFormatTypeForApp(const css::uno::Reference< css::frame::XFrame >& xFrame , 381*cdf0e10cSrcweir ETypeFamily eTypeFamily) 382*cdf0e10cSrcweir { 383*cdf0e10cSrcweir static ::rtl::OUString SERVICENAME_MODULEMANAGER = ::rtl::OUString::createFromAscii("com.sun.star.frame.ModuleManager"); 384*cdf0e10cSrcweir 385*cdf0e10cSrcweir try 386*cdf0e10cSrcweir { 387*cdf0e10cSrcweir css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR (::comphelper::getProcessServiceFactory() , css::uno::UNO_QUERY_THROW); 388*cdf0e10cSrcweir css::uno::Reference< css::frame::XModuleManager > xModuleManager(xSMGR->createInstance(SERVICENAME_MODULEMANAGER), css::uno::UNO_QUERY_THROW); 389*cdf0e10cSrcweir 390*cdf0e10cSrcweir ::rtl::OUString sModule = xModuleManager->identify(xFrame); 391*cdf0e10cSrcweir ::rtl::OUString sType ; 392*cdf0e10cSrcweir 393*cdf0e10cSrcweir switch(eTypeFamily) 394*cdf0e10cSrcweir { 395*cdf0e10cSrcweir case E_MS_DOC: 396*cdf0e10cSrcweir { 397*cdf0e10cSrcweir if (sModule.equalsAscii( "com.sun.star.text.TextDocument" )) 398*cdf0e10cSrcweir sType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "writer_MS_Word_97" )); 399*cdf0e10cSrcweir else 400*cdf0e10cSrcweir if (sModule.equalsAscii( "com.sun.star.sheet.SpreadsheetDocument" )) 401*cdf0e10cSrcweir sType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "calc_MS_Excel_97" )); 402*cdf0e10cSrcweir else 403*cdf0e10cSrcweir if (sModule.equalsAscii( "com.sun.star.drawing.DrawingDocument" )) 404*cdf0e10cSrcweir sType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "impress_MS_PowerPoint_97" )); 405*cdf0e10cSrcweir else 406*cdf0e10cSrcweir if (sModule.equalsAscii( "com.sun.star.presentation.PresentationDocument" )) 407*cdf0e10cSrcweir sType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "impress_MS_PowerPoint_97" )); 408*cdf0e10cSrcweir } 409*cdf0e10cSrcweir break; 410*cdf0e10cSrcweir 411*cdf0e10cSrcweir case E_OOO_DOC: 412*cdf0e10cSrcweir { 413*cdf0e10cSrcweir if (sModule.equalsAscii( "com.sun.star.text.TextDocument" )) 414*cdf0e10cSrcweir sType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "writer8" )); 415*cdf0e10cSrcweir else 416*cdf0e10cSrcweir if (sModule.equalsAscii( "com.sun.star.sheet.SpreadsheetDocument" )) 417*cdf0e10cSrcweir sType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "calc8" )); 418*cdf0e10cSrcweir else 419*cdf0e10cSrcweir if (sModule.equalsAscii( "com.sun.star.drawing.DrawingDocument" )) 420*cdf0e10cSrcweir sType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "draw8" )); 421*cdf0e10cSrcweir else 422*cdf0e10cSrcweir if (sModule.equalsAscii( "com.sun.star.presentation.PresentationDocument" )) 423*cdf0e10cSrcweir sType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "impress8" )); 424*cdf0e10cSrcweir } 425*cdf0e10cSrcweir break; 426*cdf0e10cSrcweir } 427*cdf0e10cSrcweir 428*cdf0e10cSrcweir return sType; 429*cdf0e10cSrcweir } 430*cdf0e10cSrcweir catch(const css::uno::RuntimeException& exRun) 431*cdf0e10cSrcweir { throw exRun; } 432*cdf0e10cSrcweir catch(const css::uno::Exception&) 433*cdf0e10cSrcweir {} 434*cdf0e10cSrcweir 435*cdf0e10cSrcweir return ::rtl::OUString(); 436*cdf0e10cSrcweir } 437*cdf0e10cSrcweir 438*cdf0e10cSrcweir //-------------------------------------------------------------------- 439*cdf0e10cSrcweir 440*cdf0e10cSrcweir void SfxViewShell::ExecMisc_Impl( SfxRequest &rReq ) 441*cdf0e10cSrcweir { 442*cdf0e10cSrcweir const sal_uInt16 nId = rReq.GetSlot(); 443*cdf0e10cSrcweir switch( nId ) 444*cdf0e10cSrcweir { 445*cdf0e10cSrcweir case SID_STYLE_FAMILY : 446*cdf0e10cSrcweir { 447*cdf0e10cSrcweir SFX_REQUEST_ARG(rReq, pItem, SfxUInt16Item, nId, sal_False); 448*cdf0e10cSrcweir if (pItem) 449*cdf0e10cSrcweir { 450*cdf0e10cSrcweir pImp->m_nFamily = pItem->GetValue(); 451*cdf0e10cSrcweir } 452*cdf0e10cSrcweir break; 453*cdf0e10cSrcweir } 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir case SID_STYLE_CATALOG: 456*cdf0e10cSrcweir { 457*cdf0e10cSrcweir SfxTemplateCatalog aCatalog( 458*cdf0e10cSrcweir SFX_APP()->GetTopWindow(), &GetViewFrame()->GetBindings()); 459*cdf0e10cSrcweir aCatalog.Execute(); 460*cdf0e10cSrcweir rReq.Ignore(); 461*cdf0e10cSrcweir break; 462*cdf0e10cSrcweir } 463*cdf0e10cSrcweir case SID_ACTIVATE_STYLE_APPLY: 464*cdf0e10cSrcweir { 465*cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::frame::XFrame > xFrame( 466*cdf0e10cSrcweir GetViewFrame()->GetFrame().GetFrameInterface(), 467*cdf0e10cSrcweir com::sun::star::uno::UNO_QUERY); 468*cdf0e10cSrcweir 469*cdf0e10cSrcweir Reference< com::sun::star::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY ); 470*cdf0e10cSrcweir Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager; 471*cdf0e10cSrcweir if ( xPropSet.is() ) 472*cdf0e10cSrcweir { 473*cdf0e10cSrcweir try 474*cdf0e10cSrcweir { 475*cdf0e10cSrcweir Any aValue = xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ))); 476*cdf0e10cSrcweir aValue >>= xLayoutManager; 477*cdf0e10cSrcweir if ( xLayoutManager.is() ) 478*cdf0e10cSrcweir { 479*cdf0e10cSrcweir rtl::OUString aTextResString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/textobjectbar" )); 480*cdf0e10cSrcweir uno::Reference< ui::XUIElement > xElement = xLayoutManager->getElement( aTextResString ); 481*cdf0e10cSrcweir if(!xElement.is()) 482*cdf0e10cSrcweir { 483*cdf0e10cSrcweir rtl::OUString aFrameResString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/frameobjectbar" )); 484*cdf0e10cSrcweir xElement = xLayoutManager->getElement( aFrameResString ); 485*cdf0e10cSrcweir } 486*cdf0e10cSrcweir if(!xElement.is()) 487*cdf0e10cSrcweir { 488*cdf0e10cSrcweir rtl::OUString aOleResString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/oleobjectbar" )); 489*cdf0e10cSrcweir xElement = xLayoutManager->getElement( aOleResString ); 490*cdf0e10cSrcweir } 491*cdf0e10cSrcweir if(xElement.is()) 492*cdf0e10cSrcweir { 493*cdf0e10cSrcweir uno::Reference< awt::XWindow > xWin( xElement->getRealInterface(), uno::UNO_QUERY_THROW ); 494*cdf0e10cSrcweir Window* pWin = VCLUnoHelper::GetWindow( xWin ); 495*cdf0e10cSrcweir ToolBox* pTextToolbox = dynamic_cast< ToolBox* >( pWin ); 496*cdf0e10cSrcweir if( pTextToolbox ) 497*cdf0e10cSrcweir { 498*cdf0e10cSrcweir sal_uInt16 nItemCount = pTextToolbox->GetItemCount(); 499*cdf0e10cSrcweir for( sal_uInt16 nItem = 0; nItem < nItemCount; ++nItem ) 500*cdf0e10cSrcweir { 501*cdf0e10cSrcweir sal_uInt16 nItemId = pTextToolbox->GetItemId( nItem ); 502*cdf0e10cSrcweir const XubString& rCommand = pTextToolbox->GetItemCommand( nItemId ); 503*cdf0e10cSrcweir if( rCommand.EqualsAscii( ".uno:StyleApply" ) ) 504*cdf0e10cSrcweir { 505*cdf0e10cSrcweir Window* pItemWin = pTextToolbox->GetItemWindow( nItemId ); 506*cdf0e10cSrcweir if( pItemWin ) 507*cdf0e10cSrcweir pItemWin->GrabFocus(); 508*cdf0e10cSrcweir break; 509*cdf0e10cSrcweir } 510*cdf0e10cSrcweir } 511*cdf0e10cSrcweir } 512*cdf0e10cSrcweir } 513*cdf0e10cSrcweir } 514*cdf0e10cSrcweir } 515*cdf0e10cSrcweir catch ( Exception& ) 516*cdf0e10cSrcweir { 517*cdf0e10cSrcweir } 518*cdf0e10cSrcweir } 519*cdf0e10cSrcweir rReq.Done(); 520*cdf0e10cSrcweir } 521*cdf0e10cSrcweir break; 522*cdf0e10cSrcweir // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 523*cdf0e10cSrcweir 524*cdf0e10cSrcweir case SID_MAIL_SENDDOCASMS: 525*cdf0e10cSrcweir case SID_MAIL_SENDDOCASOOO: 526*cdf0e10cSrcweir case SID_MAIL_SENDDOCASPDF: 527*cdf0e10cSrcweir case SID_MAIL_SENDDOC: 528*cdf0e10cSrcweir case SID_MAIL_SENDDOCASFORMAT: 529*cdf0e10cSrcweir { 530*cdf0e10cSrcweir SfxObjectShell* pDoc = GetObjectShell(); 531*cdf0e10cSrcweir if ( pDoc && pDoc->QueryHiddenInformation( 532*cdf0e10cSrcweir WhenSaving, &GetViewFrame()->GetWindow() ) != RET_YES ) 533*cdf0e10cSrcweir break; 534*cdf0e10cSrcweir 535*cdf0e10cSrcweir if ( SvtInternalOptions().MailUIEnabled() ) 536*cdf0e10cSrcweir { 537*cdf0e10cSrcweir GetViewFrame()->SetChildWindow( SID_MAIL_CHILDWIN, sal_True ); 538*cdf0e10cSrcweir } 539*cdf0e10cSrcweir else 540*cdf0e10cSrcweir { 541*cdf0e10cSrcweir SfxMailModel aModel; 542*cdf0e10cSrcweir rtl::OUString aDocType; 543*cdf0e10cSrcweir 544*cdf0e10cSrcweir SFX_REQUEST_ARG(rReq, pMailSubject, SfxStringItem, SID_MAIL_SUBJECT, sal_False ); 545*cdf0e10cSrcweir if ( pMailSubject ) 546*cdf0e10cSrcweir aModel.SetSubject( pMailSubject->GetValue() ); 547*cdf0e10cSrcweir 548*cdf0e10cSrcweir SFX_REQUEST_ARG(rReq, pMailRecipient, SfxStringItem, SID_MAIL_RECIPIENT, sal_False ); 549*cdf0e10cSrcweir if ( pMailRecipient ) 550*cdf0e10cSrcweir { 551*cdf0e10cSrcweir String aRecipient( pMailRecipient->GetValue() ); 552*cdf0e10cSrcweir String aMailToStr( String::CreateFromAscii( "mailto:" )); 553*cdf0e10cSrcweir 554*cdf0e10cSrcweir if ( aRecipient.Search( aMailToStr ) == 0 ) 555*cdf0e10cSrcweir aRecipient = aRecipient.Erase( 0, aMailToStr.Len() ); 556*cdf0e10cSrcweir aModel.AddAddress( aRecipient, SfxMailModel::ROLE_TO ); 557*cdf0e10cSrcweir } 558*cdf0e10cSrcweir SFX_REQUEST_ARG(rReq, pMailDocType, SfxStringItem, SID_TYPE_NAME, sal_False ); 559*cdf0e10cSrcweir if ( pMailDocType ) 560*cdf0e10cSrcweir aDocType = pMailDocType->GetValue(); 561*cdf0e10cSrcweir 562*cdf0e10cSrcweir uno::Reference < frame::XFrame > xFrame( pFrame->GetFrame().GetFrameInterface() ); 563*cdf0e10cSrcweir SfxMailModel::SendMailResult eResult = SfxMailModel::SEND_MAIL_ERROR; 564*cdf0e10cSrcweir 565*cdf0e10cSrcweir if ( nId == SID_MAIL_SENDDOC ) 566*cdf0e10cSrcweir eResult = aModel.SaveAndSend( xFrame, rtl::OUString() ); 567*cdf0e10cSrcweir else 568*cdf0e10cSrcweir if ( nId == SID_MAIL_SENDDOCASPDF ) 569*cdf0e10cSrcweir eResult = aModel.SaveAndSend( xFrame, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "pdf_Portable_Document_Format" ))); 570*cdf0e10cSrcweir else 571*cdf0e10cSrcweir if ( nId == SID_MAIL_SENDDOCASMS ) 572*cdf0e10cSrcweir { 573*cdf0e10cSrcweir aDocType = impl_searchFormatTypeForApp(xFrame, E_MS_DOC); 574*cdf0e10cSrcweir if (aDocType.getLength() > 0) 575*cdf0e10cSrcweir eResult = aModel.SaveAndSend( xFrame, aDocType ); 576*cdf0e10cSrcweir } 577*cdf0e10cSrcweir else 578*cdf0e10cSrcweir if ( nId == SID_MAIL_SENDDOCASOOO ) 579*cdf0e10cSrcweir { 580*cdf0e10cSrcweir aDocType = impl_searchFormatTypeForApp(xFrame, E_OOO_DOC); 581*cdf0e10cSrcweir if (aDocType.getLength() > 0) 582*cdf0e10cSrcweir eResult = aModel.SaveAndSend( xFrame, aDocType ); 583*cdf0e10cSrcweir } 584*cdf0e10cSrcweir 585*cdf0e10cSrcweir if ( eResult == SfxMailModel::SEND_MAIL_ERROR ) 586*cdf0e10cSrcweir { 587*cdf0e10cSrcweir InfoBox aBox( SFX_APP()->GetTopWindow(), SfxResId( MSG_ERROR_SEND_MAIL )); 588*cdf0e10cSrcweir aBox.Execute(); 589*cdf0e10cSrcweir rReq.Ignore(); 590*cdf0e10cSrcweir } 591*cdf0e10cSrcweir else 592*cdf0e10cSrcweir rReq.Done(); 593*cdf0e10cSrcweir } 594*cdf0e10cSrcweir 595*cdf0e10cSrcweir break; 596*cdf0e10cSrcweir } 597*cdf0e10cSrcweir 598*cdf0e10cSrcweir // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 599*cdf0e10cSrcweir case SID_WEBHTML: 600*cdf0e10cSrcweir { 601*cdf0e10cSrcweir static const char HTML_DOCUMENT_TYPE[] = "writer_web_HTML"; 602*cdf0e10cSrcweir static const char HTML_GRAPHIC_TYPE[] = "graphic_HTML"; 603*cdf0e10cSrcweir const sal_Int32 FILTERFLAG_EXPORT = 0x00000002; 604*cdf0e10cSrcweir 605*cdf0e10cSrcweir css::uno::Reference< lang::XMultiServiceFactory > xSMGR(::comphelper::getProcessServiceFactory(), css::uno::UNO_QUERY_THROW); 606*cdf0e10cSrcweir css::uno::Reference < css::frame::XFrame > xFrame( pFrame->GetFrame().GetFrameInterface() ); 607*cdf0e10cSrcweir css::uno::Reference< css::frame::XModel > xModel; 608*cdf0e10cSrcweir 609*cdf0e10cSrcweir const rtl::OUString aModuleManager( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ModuleManager" )); 610*cdf0e10cSrcweir css::uno::Reference< css::frame::XModuleManager > xModuleManager( xSMGR->createInstance( aModuleManager ), css::uno::UNO_QUERY_THROW ); 611*cdf0e10cSrcweir if ( !xModuleManager.is() ) 612*cdf0e10cSrcweir { 613*cdf0e10cSrcweir rReq.Done(sal_False); 614*cdf0e10cSrcweir return; 615*cdf0e10cSrcweir } 616*cdf0e10cSrcweir 617*cdf0e10cSrcweir rtl::OUString aModule; 618*cdf0e10cSrcweir try 619*cdf0e10cSrcweir { 620*cdf0e10cSrcweir aModule = xModuleManager->identify( xFrame ); 621*cdf0e10cSrcweir } 622*cdf0e10cSrcweir catch ( css::uno::RuntimeException& ) 623*cdf0e10cSrcweir { 624*cdf0e10cSrcweir throw; 625*cdf0e10cSrcweir } 626*cdf0e10cSrcweir catch ( css::uno::Exception& ) 627*cdf0e10cSrcweir { 628*cdf0e10cSrcweir } 629*cdf0e10cSrcweir 630*cdf0e10cSrcweir if ( xFrame.is() ) 631*cdf0e10cSrcweir { 632*cdf0e10cSrcweir css::uno::Reference< css::frame::XController > xController = xFrame->getController(); 633*cdf0e10cSrcweir if ( xController.is() ) 634*cdf0e10cSrcweir xModel = xController->getModel(); 635*cdf0e10cSrcweir } 636*cdf0e10cSrcweir 637*cdf0e10cSrcweir // We need at least a valid module name and model reference 638*cdf0e10cSrcweir css::uno::Reference< css::frame::XStorable > xStorable( xModel, css::uno::UNO_QUERY ); 639*cdf0e10cSrcweir if ( xModel.is() && xStorable.is() ) 640*cdf0e10cSrcweir { 641*cdf0e10cSrcweir rtl::OUString aFilterName; 642*cdf0e10cSrcweir rtl::OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM( HTML_DOCUMENT_TYPE )); 643*cdf0e10cSrcweir rtl::OUString aFileName; 644*cdf0e10cSrcweir rtl::OUString aExtension( RTL_CONSTASCII_USTRINGPARAM( "htm" )); 645*cdf0e10cSrcweir 646*cdf0e10cSrcweir rtl::OUString aLocation = xStorable->getLocation(); 647*cdf0e10cSrcweir INetURLObject aFileObj( aLocation ); 648*cdf0e10cSrcweir 649*cdf0e10cSrcweir bool bPrivateProtocol = ( aFileObj.GetProtocol() == INET_PROT_PRIV_SOFFICE ); 650*cdf0e10cSrcweir bool bHasLocation = ( aLocation.getLength() > 0 ) && !bPrivateProtocol; 651*cdf0e10cSrcweir 652*cdf0e10cSrcweir css::uno::Reference< css::container::XContainerQuery > xContainerQuery( 653*cdf0e10cSrcweir xSMGR->createInstance( rtl::OUString( 654*cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.FilterFactory" ))), 655*cdf0e10cSrcweir css::uno::UNO_QUERY_THROW ); 656*cdf0e10cSrcweir 657*cdf0e10cSrcweir // Retrieve filter from type 658*cdf0e10cSrcweir sal_Int32 nFilterFlags = FILTERFLAG_EXPORT; 659*cdf0e10cSrcweir aFilterName = impl_retrieveFilterNameFromTypeAndModule( xContainerQuery, aTypeName, aModule, nFilterFlags ); 660*cdf0e10cSrcweir if ( aFilterName.getLength() == 0 ) 661*cdf0e10cSrcweir { 662*cdf0e10cSrcweir // Draw/Impress uses a different type. 2nd chance try to use alternative type name 663*cdf0e10cSrcweir aFilterName = impl_retrieveFilterNameFromTypeAndModule( 664*cdf0e10cSrcweir xContainerQuery, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( HTML_GRAPHIC_TYPE )), aModule, nFilterFlags ); 665*cdf0e10cSrcweir } 666*cdf0e10cSrcweir 667*cdf0e10cSrcweir // No filter found => error 668*cdf0e10cSrcweir // No type and no location => error 669*cdf0e10cSrcweir if (( aFilterName.getLength() == 0 ) || ( aTypeName.getLength() == 0 )) 670*cdf0e10cSrcweir { 671*cdf0e10cSrcweir rReq.Done(sal_False); 672*cdf0e10cSrcweir return; 673*cdf0e10cSrcweir } 674*cdf0e10cSrcweir 675*cdf0e10cSrcweir // Use provided save file name. If empty determine file name 676*cdf0e10cSrcweir if ( !bHasLocation ) 677*cdf0e10cSrcweir { 678*cdf0e10cSrcweir // Create a default file name with the correct extension 679*cdf0e10cSrcweir const rtl::OUString aPreviewFileName( RTL_CONSTASCII_USTRINGPARAM( "webpreview" )); 680*cdf0e10cSrcweir aFileName = aPreviewFileName; 681*cdf0e10cSrcweir } 682*cdf0e10cSrcweir else 683*cdf0e10cSrcweir { 684*cdf0e10cSrcweir // Determine file name from model 685*cdf0e10cSrcweir INetURLObject aFObj( xStorable->getLocation() ); 686*cdf0e10cSrcweir aFileName = aFObj.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::NO_DECODE ); 687*cdf0e10cSrcweir } 688*cdf0e10cSrcweir 689*cdf0e10cSrcweir OSL_ASSERT( aFilterName.getLength() > 0 ); 690*cdf0e10cSrcweir OSL_ASSERT( aFileName.getLength() > 0 ); 691*cdf0e10cSrcweir 692*cdf0e10cSrcweir // Creates a temporary directory to store our predefined file into it. 693*cdf0e10cSrcweir ::utl::TempFile aTempDir( NULL, sal_True ); 694*cdf0e10cSrcweir 695*cdf0e10cSrcweir INetURLObject aFilePathObj( aTempDir.GetURL() ); 696*cdf0e10cSrcweir aFilePathObj.insertName( aFileName ); 697*cdf0e10cSrcweir aFilePathObj.setExtension( aExtension ); 698*cdf0e10cSrcweir 699*cdf0e10cSrcweir rtl::OUString aFileURL = aFilePathObj.GetMainURL( INetURLObject::NO_DECODE ); 700*cdf0e10cSrcweir 701*cdf0e10cSrcweir css::uno::Sequence< css::beans::PropertyValue > aArgs( 1 ); 702*cdf0e10cSrcweir aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterName" )); 703*cdf0e10cSrcweir aArgs[0].Value = css::uno::makeAny( aFilterName ); 704*cdf0e10cSrcweir 705*cdf0e10cSrcweir // Store document in the html format 706*cdf0e10cSrcweir try 707*cdf0e10cSrcweir { 708*cdf0e10cSrcweir xStorable->storeToURL( aFileURL, aArgs ); 709*cdf0e10cSrcweir } 710*cdf0e10cSrcweir catch ( com::sun::star::io::IOException& ) 711*cdf0e10cSrcweir { 712*cdf0e10cSrcweir rReq.Done(sal_False); 713*cdf0e10cSrcweir return; 714*cdf0e10cSrcweir } 715*cdf0e10cSrcweir 716*cdf0e10cSrcweir ::com::sun::star::uno::Reference< XSystemShellExecute > xSystemShellExecute( xSMGR->createInstance( 717*cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "com.sun.star.system.SystemShellExecute" )), 718*cdf0e10cSrcweir css::uno::UNO_QUERY ); 719*cdf0e10cSrcweir 720*cdf0e10cSrcweir sal_Bool bRet( sal_True ); 721*cdf0e10cSrcweir if ( xSystemShellExecute.is() ) 722*cdf0e10cSrcweir { 723*cdf0e10cSrcweir try 724*cdf0e10cSrcweir { 725*cdf0e10cSrcweir xSystemShellExecute->execute( 726*cdf0e10cSrcweir aFileURL, ::rtl::OUString(), SystemShellExecuteFlags::DEFAULTS ); 727*cdf0e10cSrcweir } 728*cdf0e10cSrcweir catch ( uno::Exception& ) 729*cdf0e10cSrcweir { 730*cdf0e10cSrcweir vos::OGuard aGuard( Application::GetSolarMutex() ); 731*cdf0e10cSrcweir Window *pParent = SFX_APP()->GetTopWindow(); 732*cdf0e10cSrcweir ErrorBox( pParent, SfxResId( MSG_ERROR_NO_WEBBROWSER_FOUND )).Execute(); 733*cdf0e10cSrcweir bRet = sal_False; 734*cdf0e10cSrcweir } 735*cdf0e10cSrcweir } 736*cdf0e10cSrcweir 737*cdf0e10cSrcweir rReq.Done(bRet); 738*cdf0e10cSrcweir break; 739*cdf0e10cSrcweir } 740*cdf0e10cSrcweir else 741*cdf0e10cSrcweir { 742*cdf0e10cSrcweir rReq.Done(sal_False); 743*cdf0e10cSrcweir return; 744*cdf0e10cSrcweir } 745*cdf0e10cSrcweir } 746*cdf0e10cSrcweir 747*cdf0e10cSrcweir // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 748*cdf0e10cSrcweir case SID_PLUGINS_ACTIVE: 749*cdf0e10cSrcweir { 750*cdf0e10cSrcweir SFX_REQUEST_ARG(rReq, pShowItem, SfxBoolItem, nId, sal_False); 751*cdf0e10cSrcweir bool const bActive = (pShowItem) 752*cdf0e10cSrcweir ? pShowItem->GetValue() 753*cdf0e10cSrcweir : !pImp->m_bPlugInsActive; 754*cdf0e10cSrcweir // ggf. recorden 755*cdf0e10cSrcweir if ( !rReq.IsAPI() ) 756*cdf0e10cSrcweir rReq.AppendItem( SfxBoolItem( nId, bActive ) ); 757*cdf0e10cSrcweir 758*cdf0e10cSrcweir // Jetzt schon DONE aufrufen, da die Argumente evtl. einen Pool 759*cdf0e10cSrcweir // benutzen, der demn"achst weg ist 760*cdf0e10cSrcweir rReq.Done(sal_True); 761*cdf0e10cSrcweir 762*cdf0e10cSrcweir // ausfuehren 763*cdf0e10cSrcweir if (!pShowItem || (bActive != pImp->m_bPlugInsActive)) 764*cdf0e10cSrcweir { 765*cdf0e10cSrcweir SfxFrame* pTopFrame = &GetFrame()->GetTopFrame(); 766*cdf0e10cSrcweir if ( pTopFrame != &GetFrame()->GetFrame() ) 767*cdf0e10cSrcweir { 768*cdf0e10cSrcweir // FramesetDocument 769*cdf0e10cSrcweir SfxViewShell *pShell = pTopFrame->GetCurrentViewFrame()->GetViewShell(); 770*cdf0e10cSrcweir if ( pShell->GetInterface()->GetSlot( nId ) ) 771*cdf0e10cSrcweir pShell->ExecuteSlot( rReq ); 772*cdf0e10cSrcweir break; 773*cdf0e10cSrcweir } 774*cdf0e10cSrcweir 775*cdf0e10cSrcweir SfxFrameIterator aIter( *pTopFrame ); 776*cdf0e10cSrcweir while ( pTopFrame ) 777*cdf0e10cSrcweir { 778*cdf0e10cSrcweir if ( pTopFrame->GetCurrentViewFrame() ) 779*cdf0e10cSrcweir { 780*cdf0e10cSrcweir SfxViewShell *pView = pTopFrame->GetCurrentViewFrame()->GetViewShell(); 781*cdf0e10cSrcweir if ( pView ) 782*cdf0e10cSrcweir { 783*cdf0e10cSrcweir pView->pImp->m_bPlugInsActive = bActive; 784*cdf0e10cSrcweir Rectangle aVisArea = GetObjectShell()->GetVisArea(); 785*cdf0e10cSrcweir VisAreaChanged(aVisArea); 786*cdf0e10cSrcweir 787*cdf0e10cSrcweir // the plugins might need change in their state 788*cdf0e10cSrcweir SfxInPlaceClientList *pClients = pView->GetIPClientList_Impl(sal_False); 789*cdf0e10cSrcweir if ( pClients ) 790*cdf0e10cSrcweir { 791*cdf0e10cSrcweir for (sal_uInt16 n=0; n < pClients->Count(); n++) 792*cdf0e10cSrcweir { 793*cdf0e10cSrcweir SfxInPlaceClient* pIPClient = pClients->GetObject(n); 794*cdf0e10cSrcweir if ( pIPClient ) 795*cdf0e10cSrcweir pView->CheckIPClient_Impl( pIPClient, aVisArea ); 796*cdf0e10cSrcweir } 797*cdf0e10cSrcweir } 798*cdf0e10cSrcweir } 799*cdf0e10cSrcweir } 800*cdf0e10cSrcweir 801*cdf0e10cSrcweir if ( !pTopFrame->GetParentFrame() ) 802*cdf0e10cSrcweir pTopFrame = aIter.FirstFrame(); 803*cdf0e10cSrcweir else 804*cdf0e10cSrcweir pTopFrame = aIter.NextFrame( *pTopFrame ); 805*cdf0e10cSrcweir } 806*cdf0e10cSrcweir } 807*cdf0e10cSrcweir 808*cdf0e10cSrcweir break; 809*cdf0e10cSrcweir } 810*cdf0e10cSrcweir } 811*cdf0e10cSrcweir } 812*cdf0e10cSrcweir 813*cdf0e10cSrcweir //-------------------------------------------------------------------- 814*cdf0e10cSrcweir 815*cdf0e10cSrcweir void SfxViewShell::GetState_Impl( SfxItemSet &rSet ) 816*cdf0e10cSrcweir { 817*cdf0e10cSrcweir DBG_CHKTHIS(SfxViewShell, 0); 818*cdf0e10cSrcweir 819*cdf0e10cSrcweir SfxWhichIter aIter( rSet ); 820*cdf0e10cSrcweir for ( sal_uInt16 nSID = aIter.FirstWhich(); nSID; nSID = aIter.NextWhich() ) 821*cdf0e10cSrcweir { 822*cdf0e10cSrcweir switch ( nSID ) 823*cdf0e10cSrcweir { 824*cdf0e10cSrcweir case SID_STYLE_CATALOG: 825*cdf0e10cSrcweir { 826*cdf0e10cSrcweir if ( !GetViewFrame()->KnowsChildWindow( SID_STYLE_DESIGNER ) ) 827*cdf0e10cSrcweir rSet.DisableItem( nSID ); 828*cdf0e10cSrcweir break; 829*cdf0e10cSrcweir } 830*cdf0e10cSrcweir 831*cdf0e10cSrcweir // Printer-Funktionen 832*cdf0e10cSrcweir case SID_PRINTDOC: 833*cdf0e10cSrcweir case SID_PRINTDOCDIRECT: 834*cdf0e10cSrcweir case SID_SETUPPRINTER: 835*cdf0e10cSrcweir case SID_PRINTER_NAME: 836*cdf0e10cSrcweir { 837*cdf0e10cSrcweir bool bEnabled = pImp->m_bCanPrint && !pImp->m_nPrinterLocks; 838*cdf0e10cSrcweir bEnabled = bEnabled && !Application::GetSettings().GetMiscSettings().GetDisablePrinting(); 839*cdf0e10cSrcweir if ( bEnabled ) 840*cdf0e10cSrcweir { 841*cdf0e10cSrcweir SfxPrinter *pPrinter = GetPrinter(sal_False); 842*cdf0e10cSrcweir 843*cdf0e10cSrcweir if ( SID_PRINTDOCDIRECT == nSID ) 844*cdf0e10cSrcweir { 845*cdf0e10cSrcweir rtl::OUString aPrinterName; 846*cdf0e10cSrcweir if ( pPrinter != NULL ) 847*cdf0e10cSrcweir aPrinterName = pPrinter->GetName(); 848*cdf0e10cSrcweir else 849*cdf0e10cSrcweir aPrinterName = Printer::GetDefaultPrinterName(); 850*cdf0e10cSrcweir if ( aPrinterName.getLength() > 0 ) 851*cdf0e10cSrcweir { 852*cdf0e10cSrcweir uno::Reference < frame::XFrame > xFrame( pFrame->GetFrame().GetFrameInterface() ); 853*cdf0e10cSrcweir 854*cdf0e10cSrcweir ::rtl::OUStringBuffer aBuffer( 60 ); 855*cdf0e10cSrcweir aBuffer.append( RetrieveLabelFromCommand( 856*cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:PrintDefault" )), 857*cdf0e10cSrcweir xFrame )); 858*cdf0e10cSrcweir aBuffer.appendAscii( " (" ); 859*cdf0e10cSrcweir aBuffer.append( aPrinterName ); 860*cdf0e10cSrcweir aBuffer.appendAscii( ")" ); 861*cdf0e10cSrcweir 862*cdf0e10cSrcweir rSet.Put( SfxStringItem( SID_PRINTDOCDIRECT, aBuffer.makeStringAndClear() ) ); 863*cdf0e10cSrcweir } 864*cdf0e10cSrcweir } 865*cdf0e10cSrcweir bEnabled = !pPrinter || !pPrinter->IsPrinting(); 866*cdf0e10cSrcweir } 867*cdf0e10cSrcweir if ( !bEnabled ) 868*cdf0e10cSrcweir { 869*cdf0e10cSrcweir // will now be handled by requeing the request 870*cdf0e10cSrcweir /* rSet.DisableItem( SID_PRINTDOC ); 871*cdf0e10cSrcweir rSet.DisableItem( SID_PRINTDOCDIRECT ); 872*cdf0e10cSrcweir rSet.DisableItem( SID_SETUPPRINTER ); */ 873*cdf0e10cSrcweir } 874*cdf0e10cSrcweir break; 875*cdf0e10cSrcweir } 876*cdf0e10cSrcweir 877*cdf0e10cSrcweir // Mail-Funktionen 878*cdf0e10cSrcweir case SID_MAIL_SENDDOCASPDF: 879*cdf0e10cSrcweir case SID_MAIL_SENDDOC: 880*cdf0e10cSrcweir case SID_MAIL_SENDDOCASFORMAT: 881*cdf0e10cSrcweir { 882*cdf0e10cSrcweir sal_Bool bEnable = !GetViewFrame()->HasChildWindow( SID_MAIL_CHILDWIN ); 883*cdf0e10cSrcweir if ( !bEnable ) 884*cdf0e10cSrcweir rSet.DisableItem( nSID ); 885*cdf0e10cSrcweir break; 886*cdf0e10cSrcweir } 887*cdf0e10cSrcweir 888*cdf0e10cSrcweir // PlugIns running 889*cdf0e10cSrcweir case SID_PLUGINS_ACTIVE: 890*cdf0e10cSrcweir { 891*cdf0e10cSrcweir rSet.Put( SfxBoolItem( SID_PLUGINS_ACTIVE, 892*cdf0e10cSrcweir !pImp->m_bPlugInsActive) ); 893*cdf0e10cSrcweir break; 894*cdf0e10cSrcweir } 895*cdf0e10cSrcweir /* 896*cdf0e10cSrcweir // SelectionText 897*cdf0e10cSrcweir case SID_SELECTION_TEXT: 898*cdf0e10cSrcweir { 899*cdf0e10cSrcweir rSet.Put( SfxStringItem( SID_SELECTION_TEXT, GetSelectionText() ) ); 900*cdf0e10cSrcweir break; 901*cdf0e10cSrcweir } 902*cdf0e10cSrcweir 903*cdf0e10cSrcweir // SelectionTextExt 904*cdf0e10cSrcweir case SID_SELECTION_TEXT_EXT: 905*cdf0e10cSrcweir { 906*cdf0e10cSrcweir rSet.Put( SfxStringItem( SID_SELECTION_TEXT_EXT, GetSelectionText(sal_True) ) ); 907*cdf0e10cSrcweir break; 908*cdf0e10cSrcweir } 909*cdf0e10cSrcweir */ 910*cdf0e10cSrcweir case SID_STYLE_FAMILY : 911*cdf0e10cSrcweir { 912*cdf0e10cSrcweir rSet.Put( SfxUInt16Item( SID_STYLE_FAMILY, pImp->m_nFamily ) ); 913*cdf0e10cSrcweir break; 914*cdf0e10cSrcweir } 915*cdf0e10cSrcweir } 916*cdf0e10cSrcweir } 917*cdf0e10cSrcweir } 918*cdf0e10cSrcweir 919*cdf0e10cSrcweir //-------------------------------------------------------------------- 920*cdf0e10cSrcweir 921*cdf0e10cSrcweir void SfxViewShell::SetZoomFactor( const Fraction &rZoomX, 922*cdf0e10cSrcweir const Fraction &rZoomY ) 923*cdf0e10cSrcweir { 924*cdf0e10cSrcweir DBG_ASSERT( GetWindow(), "no window" ); 925*cdf0e10cSrcweir MapMode aMap( GetWindow()->GetMapMode() ); 926*cdf0e10cSrcweir aMap.SetScaleX( rZoomX ); 927*cdf0e10cSrcweir aMap.SetScaleY( rZoomY ); 928*cdf0e10cSrcweir GetWindow()->SetMapMode( aMap ); 929*cdf0e10cSrcweir } 930*cdf0e10cSrcweir 931*cdf0e10cSrcweir //-------------------------------------------------------------------- 932*cdf0e10cSrcweir ErrCode SfxViewShell::DoVerb(long /*nVerb*/) 933*cdf0e10cSrcweir 934*cdf0e10cSrcweir /* [Beschreibung] 935*cdf0e10cSrcweir 936*cdf0e10cSrcweir Virtuelle Methode, um am selektierten Objekt ein Verb auszuf"uhren. 937*cdf0e10cSrcweir Da dieses Objekt nur den abgeleiteten Klassen bekannt ist, muss DoVerb 938*cdf0e10cSrcweir dort "uberschrieben werden. 939*cdf0e10cSrcweir 940*cdf0e10cSrcweir */ 941*cdf0e10cSrcweir 942*cdf0e10cSrcweir { 943*cdf0e10cSrcweir return ERRCODE_SO_NOVERBS; 944*cdf0e10cSrcweir } 945*cdf0e10cSrcweir 946*cdf0e10cSrcweir //-------------------------------------------------------------------- 947*cdf0e10cSrcweir 948*cdf0e10cSrcweir void SfxViewShell::OutplaceActivated( sal_Bool bActive, SfxInPlaceClient* /*pClient*/ ) 949*cdf0e10cSrcweir { 950*cdf0e10cSrcweir if ( !bActive ) 951*cdf0e10cSrcweir GetFrame()->GetFrame().Appear(); 952*cdf0e10cSrcweir } 953*cdf0e10cSrcweir 954*cdf0e10cSrcweir //-------------------------------------------------------------------- 955*cdf0e10cSrcweir 956*cdf0e10cSrcweir void SfxViewShell::InplaceActivating( SfxInPlaceClient* /*pClient*/ ) 957*cdf0e10cSrcweir { 958*cdf0e10cSrcweir // TODO/LATER: painting of the bitmap can be stopped, it is required if CLIPCHILDREN problem #i25788# is not solved, 959*cdf0e10cSrcweir // but may be the bug will not affect the real office vcl windows, then it is not required 960*cdf0e10cSrcweir } 961*cdf0e10cSrcweir 962*cdf0e10cSrcweir //-------------------------------------------------------------------- 963*cdf0e10cSrcweir 964*cdf0e10cSrcweir void SfxViewShell::InplaceDeactivated( SfxInPlaceClient* /*pClient*/ ) 965*cdf0e10cSrcweir { 966*cdf0e10cSrcweir // TODO/LATER: paint the replacement image in normal way if the painting was stopped 967*cdf0e10cSrcweir } 968*cdf0e10cSrcweir 969*cdf0e10cSrcweir //-------------------------------------------------------------------- 970*cdf0e10cSrcweir 971*cdf0e10cSrcweir void SfxViewShell::UIActivating( SfxInPlaceClient* /*pClient*/ ) 972*cdf0e10cSrcweir { 973*cdf0e10cSrcweir uno::Reference < frame::XFrame > xOwnFrame( pFrame->GetFrame().GetFrameInterface() ); 974*cdf0e10cSrcweir uno::Reference < frame::XFramesSupplier > xParentFrame( xOwnFrame->getCreator(), uno::UNO_QUERY ); 975*cdf0e10cSrcweir if ( xParentFrame.is() ) 976*cdf0e10cSrcweir xParentFrame->setActiveFrame( xOwnFrame ); 977*cdf0e10cSrcweir 978*cdf0e10cSrcweir pFrame->GetBindings().HidePopups(sal_True); 979*cdf0e10cSrcweir pFrame->GetDispatcher()->Update_Impl( sal_True ); 980*cdf0e10cSrcweir } 981*cdf0e10cSrcweir 982*cdf0e10cSrcweir //-------------------------------------------------------------------- 983*cdf0e10cSrcweir 984*cdf0e10cSrcweir void SfxViewShell::UIDeactivated( SfxInPlaceClient* /*pClient*/ ) 985*cdf0e10cSrcweir { 986*cdf0e10cSrcweir if ( !pFrame->GetFrame().IsClosing_Impl() || 987*cdf0e10cSrcweir SfxViewFrame::Current() != pFrame ) 988*cdf0e10cSrcweir pFrame->GetDispatcher()->Update_Impl( sal_True ); 989*cdf0e10cSrcweir pFrame->GetBindings().HidePopups(sal_False); 990*cdf0e10cSrcweir 991*cdf0e10cSrcweir // uno::Reference < frame::XFrame > xOwnFrame( pFrame->GetFrame().GetFrameInterface() ); 992*cdf0e10cSrcweir // uno::Reference < frame::XFramesSupplier > xParentFrame( xOwnFrame->getCreator(), uno::UNO_QUERY ); 993*cdf0e10cSrcweir // if ( xParentFrame.is() ) 994*cdf0e10cSrcweir // xParentFrame->setActiveFrame( uno::Reference < frame::XFrame >() ); 995*cdf0e10cSrcweir } 996*cdf0e10cSrcweir 997*cdf0e10cSrcweir //-------------------------------------------------------------------- 998*cdf0e10cSrcweir 999*cdf0e10cSrcweir SfxInPlaceClient* SfxViewShell::FindIPClient 1000*cdf0e10cSrcweir ( 1001*cdf0e10cSrcweir const uno::Reference < embed::XEmbeddedObject >& xObj, 1002*cdf0e10cSrcweir Window* pObjParentWin 1003*cdf0e10cSrcweir ) const 1004*cdf0e10cSrcweir { 1005*cdf0e10cSrcweir SfxInPlaceClientList *pClients = GetIPClientList_Impl(sal_False); 1006*cdf0e10cSrcweir if ( !pClients ) 1007*cdf0e10cSrcweir return 0; 1008*cdf0e10cSrcweir 1009*cdf0e10cSrcweir if( !pObjParentWin ) 1010*cdf0e10cSrcweir pObjParentWin = GetWindow(); 1011*cdf0e10cSrcweir for (sal_uInt16 n=0; n < pClients->Count(); n++) 1012*cdf0e10cSrcweir { 1013*cdf0e10cSrcweir SfxInPlaceClient *pIPClient = (SfxInPlaceClient*) pClients->GetObject(n); 1014*cdf0e10cSrcweir if ( pIPClient->GetObject() == xObj && pIPClient->GetEditWin() == pObjParentWin ) 1015*cdf0e10cSrcweir return pIPClient; 1016*cdf0e10cSrcweir } 1017*cdf0e10cSrcweir 1018*cdf0e10cSrcweir return 0; 1019*cdf0e10cSrcweir } 1020*cdf0e10cSrcweir 1021*cdf0e10cSrcweir //-------------------------------------------------------------------- 1022*cdf0e10cSrcweir 1023*cdf0e10cSrcweir SfxInPlaceClient* SfxViewShell::GetIPClient() const 1024*cdf0e10cSrcweir { 1025*cdf0e10cSrcweir return GetUIActiveClient(); 1026*cdf0e10cSrcweir } 1027*cdf0e10cSrcweir 1028*cdf0e10cSrcweir //-------------------------------------------------------------------- 1029*cdf0e10cSrcweir 1030*cdf0e10cSrcweir SfxInPlaceClient* SfxViewShell::GetUIActiveIPClient_Impl() const 1031*cdf0e10cSrcweir { 1032*cdf0e10cSrcweir // this method is needed as long as SFX still manages the border space for ChildWindows (see SfxFrame::Resize) 1033*cdf0e10cSrcweir SfxInPlaceClientList *pClients = GetIPClientList_Impl(sal_False); 1034*cdf0e10cSrcweir if ( !pClients ) 1035*cdf0e10cSrcweir return 0; 1036*cdf0e10cSrcweir 1037*cdf0e10cSrcweir for (sal_uInt16 n=0; n < pClients->Count(); n++) 1038*cdf0e10cSrcweir { 1039*cdf0e10cSrcweir SfxInPlaceClient* pIPClient = pClients->GetObject(n); 1040*cdf0e10cSrcweir if ( pIPClient->IsUIActive() ) 1041*cdf0e10cSrcweir return pIPClient; 1042*cdf0e10cSrcweir } 1043*cdf0e10cSrcweir 1044*cdf0e10cSrcweir return NULL; 1045*cdf0e10cSrcweir } 1046*cdf0e10cSrcweir 1047*cdf0e10cSrcweir SfxInPlaceClient* SfxViewShell::GetUIActiveClient() const 1048*cdf0e10cSrcweir { 1049*cdf0e10cSrcweir SfxInPlaceClientList *pClients = GetIPClientList_Impl(sal_False); 1050*cdf0e10cSrcweir if ( !pClients ) 1051*cdf0e10cSrcweir return 0; 1052*cdf0e10cSrcweir 1053*cdf0e10cSrcweir for (sal_uInt16 n=0; n < pClients->Count(); n++) 1054*cdf0e10cSrcweir { 1055*cdf0e10cSrcweir SfxInPlaceClient* pIPClient = pClients->GetObject(n); 1056*cdf0e10cSrcweir if ( pIPClient->IsObjectUIActive() ) 1057*cdf0e10cSrcweir return pIPClient; 1058*cdf0e10cSrcweir } 1059*cdf0e10cSrcweir 1060*cdf0e10cSrcweir return NULL; 1061*cdf0e10cSrcweir } 1062*cdf0e10cSrcweir 1063*cdf0e10cSrcweir //-------------------------------------------------------------------- 1064*cdf0e10cSrcweir 1065*cdf0e10cSrcweir void SfxViewShell::Activate( sal_Bool bMDI ) 1066*cdf0e10cSrcweir { 1067*cdf0e10cSrcweir DBG_CHKTHIS(SfxViewShell, 0); 1068*cdf0e10cSrcweir if ( bMDI ) 1069*cdf0e10cSrcweir { 1070*cdf0e10cSrcweir SfxObjectShell *pSh = GetViewFrame()->GetObjectShell(); 1071*cdf0e10cSrcweir if ( pSh->GetModel().is() ) 1072*cdf0e10cSrcweir pSh->GetModel()->setCurrentController( GetViewFrame()->GetFrame().GetController() ); 1073*cdf0e10cSrcweir 1074*cdf0e10cSrcweir SetCurrentDocument(); 1075*cdf0e10cSrcweir } 1076*cdf0e10cSrcweir } 1077*cdf0e10cSrcweir 1078*cdf0e10cSrcweir //-------------------------------------------------------------------- 1079*cdf0e10cSrcweir 1080*cdf0e10cSrcweir void SfxViewShell::Deactivate(sal_Bool /*bMDI*/) 1081*cdf0e10cSrcweir { 1082*cdf0e10cSrcweir DBG_CHKTHIS(SfxViewShell, 0); 1083*cdf0e10cSrcweir } 1084*cdf0e10cSrcweir 1085*cdf0e10cSrcweir //-------------------------------------------------------------------- 1086*cdf0e10cSrcweir 1087*cdf0e10cSrcweir void SfxViewShell::AdjustPosSizePixel 1088*cdf0e10cSrcweir ( 1089*cdf0e10cSrcweir const Point& /*rToolOffset*/,// linke obere Ecke der Tools im Frame-Window 1090*cdf0e10cSrcweir const Size& /*rSize*/ // gesamte zur Verf"ugung stehende Gr"o\se 1091*cdf0e10cSrcweir ) 1092*cdf0e10cSrcweir 1093*cdf0e10cSrcweir { 1094*cdf0e10cSrcweir DBG_CHKTHIS(SfxViewShell, 0); 1095*cdf0e10cSrcweir } 1096*cdf0e10cSrcweir 1097*cdf0e10cSrcweir //-------------------------------------------------------------------- 1098*cdf0e10cSrcweir 1099*cdf0e10cSrcweir void SfxViewShell::Move() 1100*cdf0e10cSrcweir 1101*cdf0e10cSrcweir /* [Beschreibung] 1102*cdf0e10cSrcweir 1103*cdf0e10cSrcweir Diese virtuelle Methode wird gerufen, wenn das Fenster, in dem die 1104*cdf0e10cSrcweir SfxViewShell dargestellt wird eine StarView-Move() Nachricht erh"alt. 1105*cdf0e10cSrcweir 1106*cdf0e10cSrcweir Die Basisimplementierung braucht nicht gerufen zu werden. 1107*cdf0e10cSrcweir 1108*cdf0e10cSrcweir 1109*cdf0e10cSrcweir [Anmerkung] 1110*cdf0e10cSrcweir 1111*cdf0e10cSrcweir Diese Methode kann dazu verwendet werden, eine Selektion abzubrechen, 1112*cdf0e10cSrcweir um durch das Moven des Fensters erzeugte Maus-Bewegungen anzufangen. 1113*cdf0e10cSrcweir 1114*cdf0e10cSrcweir Zur Zeit funktioniert die Benachrichtigung nicht In-Place. 1115*cdf0e10cSrcweir */ 1116*cdf0e10cSrcweir 1117*cdf0e10cSrcweir { 1118*cdf0e10cSrcweir } 1119*cdf0e10cSrcweir 1120*cdf0e10cSrcweir //-------------------------------------------------------------------- 1121*cdf0e10cSrcweir 1122*cdf0e10cSrcweir void SfxViewShell::OuterResizePixel 1123*cdf0e10cSrcweir ( 1124*cdf0e10cSrcweir const Point& /*rToolOffset*/,// linke obere Ecke der Tools im Frame-Window 1125*cdf0e10cSrcweir const Size& /*rSize*/ // gesamte zur Verf"ugung stehende Gr"o\se 1126*cdf0e10cSrcweir ) 1127*cdf0e10cSrcweir 1128*cdf0e10cSrcweir /* [Beschreibung] 1129*cdf0e10cSrcweir 1130*cdf0e10cSrcweir Diese Methode muss ueberladen werden, um auf "Anderungen der Groesse 1131*cdf0e10cSrcweir der View zu reagieren. Dabei definieren wir die View als das Edit-Window 1132*cdf0e10cSrcweir zuz"uglich der um das Edit-Window angeordnenten Tools (z.B. Lineale). 1133*cdf0e10cSrcweir 1134*cdf0e10cSrcweir Das Edit-Window darf weder in Gr"o\se noch Position ver"andert werden. 1135*cdf0e10cSrcweir 1136*cdf0e10cSrcweir Die Vis-Area der SfxObjectShell, dessen Skalierung und Position 1137*cdf0e10cSrcweir d"urfen hier ver"andert werden. Der Hauptanwendungsfall ist dabei, 1138*cdf0e10cSrcweir das Ver"andern der Gr"o\se der Vis-Area. 1139*cdf0e10cSrcweir 1140*cdf0e10cSrcweir "Andert sich durch die neue Berechnung der Border, so mu\s dieser 1141*cdf0e10cSrcweir mit <SfxViewShell::SetBorderPixel(const SvBorder&)> gesetzt werden. 1142*cdf0e10cSrcweir Erst nach Aufruf von 'SetBorderPixel' ist das Positionieren von 1143*cdf0e10cSrcweir Tools erlaubt. 1144*cdf0e10cSrcweir 1145*cdf0e10cSrcweir 1146*cdf0e10cSrcweir [Beispiel] 1147*cdf0e10cSrcweir 1148*cdf0e10cSrcweir void AppViewSh::OuterViewResizePixel( const Point &rOfs, const Size &rSz ) 1149*cdf0e10cSrcweir { 1150*cdf0e10cSrcweir // Tool-Positionen und Gr"o\sen von au\sen berechnen, NICHT setzen! 1151*cdf0e10cSrcweir // (wegen folgender Border-Berechnung) 1152*cdf0e10cSrcweir Point aHLinPos...; Size aHLinSz...; 1153*cdf0e10cSrcweir ... 1154*cdf0e10cSrcweir 1155*cdf0e10cSrcweir // Border f"ur Tools passend zu rSize berechnen und setzen 1156*cdf0e10cSrcweir SvBorder aBorder... 1157*cdf0e10cSrcweir SetBorderPixel( aBorder ); // ab jetzt sind Positionierungen erlaubt 1158*cdf0e10cSrcweir 1159*cdf0e10cSrcweir // Tools anordnen 1160*cdf0e10cSrcweir pHLin->SetPosSizePixel( aHLinPos, aHLinSz ); 1161*cdf0e10cSrcweir ... 1162*cdf0e10cSrcweir } 1163*cdf0e10cSrcweir 1164*cdf0e10cSrcweir 1165*cdf0e10cSrcweir [Querverweise] 1166*cdf0e10cSrcweir 1167*cdf0e10cSrcweir <SfxViewShell::InnerResizePixel(const Point&,const Size& rSize)> 1168*cdf0e10cSrcweir */ 1169*cdf0e10cSrcweir 1170*cdf0e10cSrcweir { 1171*cdf0e10cSrcweir DBG_CHKTHIS(SfxViewShell, 0); 1172*cdf0e10cSrcweir SetBorderPixel( SvBorder() ); 1173*cdf0e10cSrcweir } 1174*cdf0e10cSrcweir 1175*cdf0e10cSrcweir //-------------------------------------------------------------------- 1176*cdf0e10cSrcweir 1177*cdf0e10cSrcweir void SfxViewShell::InnerResizePixel 1178*cdf0e10cSrcweir ( 1179*cdf0e10cSrcweir const Point& /*rToolOffset*/,// linke obere Ecke der Tools im Frame-Window 1180*cdf0e10cSrcweir const Size& /*rSize*/ // dem Edit-Win zur Verf"ugung stehende Gr"o\se 1181*cdf0e10cSrcweir ) 1182*cdf0e10cSrcweir 1183*cdf0e10cSrcweir /* [Beschreibung] 1184*cdf0e10cSrcweir 1185*cdf0e10cSrcweir Diese Methode muss ueberladen werden, um auf "Anderungen der Groesse 1186*cdf0e10cSrcweir des Edit-Windows zu reagieren. 1187*cdf0e10cSrcweir 1188*cdf0e10cSrcweir Das Edit-Window darf weder in Gr"o\se noch Position ver"andert werden. 1189*cdf0e10cSrcweir Weder die Vis-Area der SfxObjectShell noch dessen Skalierung oder 1190*cdf0e10cSrcweir Position d"urfen ver"andert werden. 1191*cdf0e10cSrcweir 1192*cdf0e10cSrcweir "Andert sich durch die neue Berechnung der Border, so mu\s dieser 1193*cdf0e10cSrcweir mit <SfxViewShell::SetBorderPixel(const SvBorder&)> gesetzt werden. 1194*cdf0e10cSrcweir Erst nach Aufruf von 'SetBorderPixel' ist das Positionieren von 1195*cdf0e10cSrcweir Tools erlaubt. 1196*cdf0e10cSrcweir 1197*cdf0e10cSrcweir 1198*cdf0e10cSrcweir [Beispiel] 1199*cdf0e10cSrcweir 1200*cdf0e10cSrcweir void AppViewSh::InnerViewResizePixel( const Point &rOfs, const Size &rSz ) 1201*cdf0e10cSrcweir { 1202*cdf0e10cSrcweir // Tool-Positionen und Gr"o\sen von innen berechnen, NICHT setzen! 1203*cdf0e10cSrcweir // (wegen folgender Border-Berechnung) 1204*cdf0e10cSrcweir Point aHLinPos...; Size aHLinSz...; 1205*cdf0e10cSrcweir ... 1206*cdf0e10cSrcweir 1207*cdf0e10cSrcweir // Border f"ur Tools passend zu rSz berechnen und setzen 1208*cdf0e10cSrcweir SvBorder aBorder... 1209*cdf0e10cSrcweir SetBorderPixel( aBorder ); // ab jetzt sind Positionierungen erlaubt 1210*cdf0e10cSrcweir 1211*cdf0e10cSrcweir // Tools anordnen 1212*cdf0e10cSrcweir pHLin->SetPosSizePixel( aHLinPos, aHLinSz ); 1213*cdf0e10cSrcweir ... 1214*cdf0e10cSrcweir } 1215*cdf0e10cSrcweir 1216*cdf0e10cSrcweir 1217*cdf0e10cSrcweir [Querverweise] 1218*cdf0e10cSrcweir 1219*cdf0e10cSrcweir <SfxViewShell::OuterResizePixel(const Point&,const Size& rSize)> 1220*cdf0e10cSrcweir */ 1221*cdf0e10cSrcweir 1222*cdf0e10cSrcweir { 1223*cdf0e10cSrcweir DBG_CHKTHIS(SfxViewShell, 0); 1224*cdf0e10cSrcweir SetBorderPixel( SvBorder() ); 1225*cdf0e10cSrcweir } 1226*cdf0e10cSrcweir 1227*cdf0e10cSrcweir //-------------------------------------------------------------------- 1228*cdf0e10cSrcweir 1229*cdf0e10cSrcweir void SfxViewShell::InvalidateBorder() 1230*cdf0e10cSrcweir { 1231*cdf0e10cSrcweir DBG_CHKTHIS(SfxViewShell, 0); 1232*cdf0e10cSrcweir DBG_ASSERT( GetViewFrame(), "SfxViewShell without SfxViewFrame" ); 1233*cdf0e10cSrcweir 1234*cdf0e10cSrcweir GetViewFrame()->InvalidateBorderImpl( this ); 1235*cdf0e10cSrcweir if (pImp->m_pController.is()) 1236*cdf0e10cSrcweir { 1237*cdf0e10cSrcweir pImp->m_pController->BorderWidthsChanged_Impl(); 1238*cdf0e10cSrcweir } 1239*cdf0e10cSrcweir } 1240*cdf0e10cSrcweir 1241*cdf0e10cSrcweir //-------------------------------------------------------------------- 1242*cdf0e10cSrcweir 1243*cdf0e10cSrcweir void SfxViewShell::SetBorderPixel( const SvBorder &rBorder ) 1244*cdf0e10cSrcweir { 1245*cdf0e10cSrcweir DBG_CHKTHIS(SfxViewShell, 0); 1246*cdf0e10cSrcweir DBG_ASSERT( GetViewFrame(), "SfxViewShell without SfxViewFrame" ); 1247*cdf0e10cSrcweir 1248*cdf0e10cSrcweir //if ( rBorder != GetBorderPixel()) 1249*cdf0e10cSrcweir { 1250*cdf0e10cSrcweir GetViewFrame()->SetBorderPixelImpl( this, rBorder ); 1251*cdf0e10cSrcweir 1252*cdf0e10cSrcweir // notify related controller that border size is changed 1253*cdf0e10cSrcweir if (pImp->m_pController.is()) 1254*cdf0e10cSrcweir { 1255*cdf0e10cSrcweir pImp->m_pController->BorderWidthsChanged_Impl(); 1256*cdf0e10cSrcweir } 1257*cdf0e10cSrcweir } 1258*cdf0e10cSrcweir } 1259*cdf0e10cSrcweir 1260*cdf0e10cSrcweir //-------------------------------------------------------------------- 1261*cdf0e10cSrcweir 1262*cdf0e10cSrcweir const SvBorder& SfxViewShell::GetBorderPixel() const 1263*cdf0e10cSrcweir { 1264*cdf0e10cSrcweir DBG_CHKTHIS(SfxViewShell, 0); 1265*cdf0e10cSrcweir DBG_ASSERT( GetViewFrame(), "SfxViewShell without SfxViewFrame" ); 1266*cdf0e10cSrcweir 1267*cdf0e10cSrcweir return GetViewFrame()->GetBorderPixelImpl( this ); 1268*cdf0e10cSrcweir } 1269*cdf0e10cSrcweir 1270*cdf0e10cSrcweir //-------------------------------------------------------------------- 1271*cdf0e10cSrcweir 1272*cdf0e10cSrcweir void SfxViewShell::SetWindow 1273*cdf0e10cSrcweir ( 1274*cdf0e10cSrcweir Window* pViewPort // Pointer auf das Datenfenster bzw. 0 im Destruktor 1275*cdf0e10cSrcweir ) 1276*cdf0e10cSrcweir 1277*cdf0e10cSrcweir /* [Beschreibung] 1278*cdf0e10cSrcweir 1279*cdf0e10cSrcweir Mit dieser Methode wird der SfxViewShell das Datenfenster mitgeteilt. 1280*cdf0e10cSrcweir Dieses wird f"ur den In-Place-Container und f"ur das korrekte 1281*cdf0e10cSrcweir Wiederherstellen des Focus ben"otigt. 1282*cdf0e10cSrcweir 1283*cdf0e10cSrcweir Selbst In-Place-aktiv ist das Umsetzen des ViewPort-Windows verboten. 1284*cdf0e10cSrcweir */ 1285*cdf0e10cSrcweir 1286*cdf0e10cSrcweir { 1287*cdf0e10cSrcweir if( pWindow == pViewPort ) 1288*cdf0e10cSrcweir return; 1289*cdf0e10cSrcweir 1290*cdf0e10cSrcweir // ggf. vorhandene IP-Clients disconnecten 1291*cdf0e10cSrcweir DisconnectAllClients(); 1292*cdf0e10cSrcweir 1293*cdf0e10cSrcweir //TODO: should we have a "ReconnectAllClients" method? 1294*cdf0e10cSrcweir DiscardClients_Impl(); 1295*cdf0e10cSrcweir 1296*cdf0e10cSrcweir // View-Port austauschen 1297*cdf0e10cSrcweir sal_Bool bHadFocus = pWindow ? pWindow->HasChildPathFocus( sal_True ) : sal_False; 1298*cdf0e10cSrcweir pWindow = pViewPort; 1299*cdf0e10cSrcweir 1300*cdf0e10cSrcweir if( pWindow ) 1301*cdf0e10cSrcweir { 1302*cdf0e10cSrcweir // Disable automatic GUI mirroring (right-to-left) for document windows 1303*cdf0e10cSrcweir pWindow->EnableRTL( sal_False ); 1304*cdf0e10cSrcweir } 1305*cdf0e10cSrcweir 1306*cdf0e10cSrcweir if ( bHadFocus && pWindow ) 1307*cdf0e10cSrcweir pWindow->GrabFocus(); 1308*cdf0e10cSrcweir //TODO/CLEANUP 1309*cdf0e10cSrcweir //brauchen wir die Methode doch noch?! 1310*cdf0e10cSrcweir //SFX_APP()->GrabFocus( pWindow ); 1311*cdf0e10cSrcweir } 1312*cdf0e10cSrcweir 1313*cdf0e10cSrcweir //-------------------------------------------------------------------- 1314*cdf0e10cSrcweir 1315*cdf0e10cSrcweir Size SfxViewShell::GetOptimalSizePixel() const 1316*cdf0e10cSrcweir { 1317*cdf0e10cSrcweir DBG_ERROR( "Useless call!" ); 1318*cdf0e10cSrcweir return Size(); 1319*cdf0e10cSrcweir } 1320*cdf0e10cSrcweir 1321*cdf0e10cSrcweir //------------------------------------------------------------------------ 1322*cdf0e10cSrcweir 1323*cdf0e10cSrcweir SfxViewShell::SfxViewShell 1324*cdf0e10cSrcweir ( 1325*cdf0e10cSrcweir SfxViewFrame* pViewFrame, /* <SfxViewFrame>, in dem diese View dargestellt wird */ 1326*cdf0e10cSrcweir sal_uInt16 nFlags /* siehe <SfxViewShell-Flags> */ 1327*cdf0e10cSrcweir ) 1328*cdf0e10cSrcweir 1329*cdf0e10cSrcweir : SfxShell(this) 1330*cdf0e10cSrcweir , pImp( new SfxViewShell_Impl(nFlags) ) 1331*cdf0e10cSrcweir ,pIPClientList( 0 ) 1332*cdf0e10cSrcweir ,pFrame(pViewFrame) 1333*cdf0e10cSrcweir ,pSubShell(0) 1334*cdf0e10cSrcweir ,pWindow(0) 1335*cdf0e10cSrcweir ,bNoNewWindow( 0 != (nFlags & SFX_VIEW_NO_NEWWINDOW) ) 1336*cdf0e10cSrcweir { 1337*cdf0e10cSrcweir DBG_CTOR(SfxViewShell, 0); 1338*cdf0e10cSrcweir 1339*cdf0e10cSrcweir //pImp->pPrinterCommandQueue = new SfxAsyncPrintExec_Impl( this ); 1340*cdf0e10cSrcweir 1341*cdf0e10cSrcweir if ( pViewFrame->GetParentViewFrame() ) 1342*cdf0e10cSrcweir { 1343*cdf0e10cSrcweir pImp->m_bPlugInsActive = pViewFrame->GetParentViewFrame() 1344*cdf0e10cSrcweir ->GetViewShell()->pImp->m_bPlugInsActive; 1345*cdf0e10cSrcweir } 1346*cdf0e10cSrcweir SetMargin( pViewFrame->GetMargin_Impl() ); 1347*cdf0e10cSrcweir 1348*cdf0e10cSrcweir SetPool( &pViewFrame->GetObjectShell()->GetPool() ); 1349*cdf0e10cSrcweir StartListening(*pViewFrame->GetObjectShell()); 1350*cdf0e10cSrcweir 1351*cdf0e10cSrcweir // in Liste eintragen 1352*cdf0e10cSrcweir const SfxViewShell *pThis = this; // wegen der kranken Array-Syntax 1353*cdf0e10cSrcweir SfxViewShellArr_Impl &rViewArr = SFX_APP()->GetViewShells_Impl(); 1354*cdf0e10cSrcweir rViewArr.Insert(pThis, rViewArr.Count() ); 1355*cdf0e10cSrcweir } 1356*cdf0e10cSrcweir 1357*cdf0e10cSrcweir //-------------------------------------------------------------------- 1358*cdf0e10cSrcweir 1359*cdf0e10cSrcweir SfxViewShell::~SfxViewShell() 1360*cdf0e10cSrcweir { 1361*cdf0e10cSrcweir DBG_DTOR(SfxViewShell, 0); 1362*cdf0e10cSrcweir 1363*cdf0e10cSrcweir // aus Liste austragen 1364*cdf0e10cSrcweir const SfxViewShell *pThis = this; 1365*cdf0e10cSrcweir SfxViewShellArr_Impl &rViewArr = SFX_APP()->GetViewShells_Impl(); 1366*cdf0e10cSrcweir rViewArr.Remove( rViewArr.GetPos(pThis) ); 1367*cdf0e10cSrcweir 1368*cdf0e10cSrcweir if ( pImp->xClipboardListener.is() ) 1369*cdf0e10cSrcweir { 1370*cdf0e10cSrcweir pImp->xClipboardListener->DisconnectViewShell(); 1371*cdf0e10cSrcweir pImp->xClipboardListener = NULL; 1372*cdf0e10cSrcweir } 1373*cdf0e10cSrcweir 1374*cdf0e10cSrcweir if (pImp->m_pController.is()) 1375*cdf0e10cSrcweir { 1376*cdf0e10cSrcweir pImp->m_pController->ReleaseShell_Impl(); 1377*cdf0e10cSrcweir pImp->m_pController.clear(); 1378*cdf0e10cSrcweir } 1379*cdf0e10cSrcweir 1380*cdf0e10cSrcweir //DELETEZ( pImp->pPrinterCommandQueue ); 1381*cdf0e10cSrcweir DELETEZ( pImp ); 1382*cdf0e10cSrcweir DELETEZ( pIPClientList ); 1383*cdf0e10cSrcweir } 1384*cdf0e10cSrcweir 1385*cdf0e10cSrcweir //-------------------------------------------------------------------- 1386*cdf0e10cSrcweir 1387*cdf0e10cSrcweir sal_uInt16 SfxViewShell::PrepareClose 1388*cdf0e10cSrcweir ( 1389*cdf0e10cSrcweir sal_Bool bUI, // sal_True: Dialoge etc. erlaubt, sal_False: silent-mode 1390*cdf0e10cSrcweir sal_Bool /*bForBrowsing*/ 1391*cdf0e10cSrcweir ) 1392*cdf0e10cSrcweir { 1393*cdf0e10cSrcweir SfxPrinter *pPrinter = GetPrinter(); 1394*cdf0e10cSrcweir if ( pPrinter && pPrinter->IsPrinting() ) 1395*cdf0e10cSrcweir { 1396*cdf0e10cSrcweir if ( bUI ) 1397*cdf0e10cSrcweir { 1398*cdf0e10cSrcweir InfoBox aInfoBox( &GetViewFrame()->GetWindow(), SfxResId( MSG_CANT_CLOSE ) ); 1399*cdf0e10cSrcweir aInfoBox.Execute(); 1400*cdf0e10cSrcweir } 1401*cdf0e10cSrcweir 1402*cdf0e10cSrcweir return sal_False; 1403*cdf0e10cSrcweir } 1404*cdf0e10cSrcweir 1405*cdf0e10cSrcweir if( GetViewFrame()->IsInModalMode() ) 1406*cdf0e10cSrcweir return sal_False; 1407*cdf0e10cSrcweir 1408*cdf0e10cSrcweir if( bUI && GetViewFrame()->GetDispatcher()->IsLocked() ) 1409*cdf0e10cSrcweir return sal_False; 1410*cdf0e10cSrcweir 1411*cdf0e10cSrcweir return sal_True; 1412*cdf0e10cSrcweir } 1413*cdf0e10cSrcweir 1414*cdf0e10cSrcweir //-------------------------------------------------------------------- 1415*cdf0e10cSrcweir 1416*cdf0e10cSrcweir SfxViewShell* SfxViewShell::Current() 1417*cdf0e10cSrcweir { 1418*cdf0e10cSrcweir SfxViewFrame *pCurrent = SfxViewFrame::Current(); 1419*cdf0e10cSrcweir return pCurrent ? pCurrent->GetViewShell() : NULL; 1420*cdf0e10cSrcweir } 1421*cdf0e10cSrcweir 1422*cdf0e10cSrcweir //-------------------------------------------------------------------- 1423*cdf0e10cSrcweir 1424*cdf0e10cSrcweir SfxViewShell* SfxViewShell::Get( const Reference< XController>& i_rController ) 1425*cdf0e10cSrcweir { 1426*cdf0e10cSrcweir if ( !i_rController.is() ) 1427*cdf0e10cSrcweir return NULL; 1428*cdf0e10cSrcweir 1429*cdf0e10cSrcweir for ( SfxViewShell* pViewShell = SfxViewShell::GetFirst( NULL, sal_False ); 1430*cdf0e10cSrcweir pViewShell; 1431*cdf0e10cSrcweir pViewShell = SfxViewShell::GetNext( *pViewShell, NULL, sal_False ) 1432*cdf0e10cSrcweir ) 1433*cdf0e10cSrcweir { 1434*cdf0e10cSrcweir if ( pViewShell->GetController() == i_rController ) 1435*cdf0e10cSrcweir return pViewShell; 1436*cdf0e10cSrcweir } 1437*cdf0e10cSrcweir return NULL; 1438*cdf0e10cSrcweir } 1439*cdf0e10cSrcweir 1440*cdf0e10cSrcweir //-------------------------------------------------------------------- 1441*cdf0e10cSrcweir 1442*cdf0e10cSrcweir SdrView* SfxViewShell::GetDrawView() const 1443*cdf0e10cSrcweir 1444*cdf0e10cSrcweir /* [Beschreibung] 1445*cdf0e10cSrcweir 1446*cdf0e10cSrcweir Diese virtuelle Methode mu\s von den Subklassen "uberladen werden, wenn 1447*cdf0e10cSrcweir der Property-Editor zur Verf"ugung stehen soll. 1448*cdf0e10cSrcweir 1449*cdf0e10cSrcweir Die Default-Implementierung liefert immer 0. 1450*cdf0e10cSrcweir */ 1451*cdf0e10cSrcweir 1452*cdf0e10cSrcweir { 1453*cdf0e10cSrcweir return 0; 1454*cdf0e10cSrcweir } 1455*cdf0e10cSrcweir 1456*cdf0e10cSrcweir //-------------------------------------------------------------------- 1457*cdf0e10cSrcweir 1458*cdf0e10cSrcweir String SfxViewShell::GetSelectionText 1459*cdf0e10cSrcweir ( 1460*cdf0e10cSrcweir sal_Bool /*bCompleteWords*/ /* sal_False (default) 1461*cdf0e10cSrcweir Nur der tats"achlich selektierte Text wird 1462*cdf0e10cSrcweir zur"uckgegeben. 1463*cdf0e10cSrcweir 1464*cdf0e10cSrcweir TRUE 1465*cdf0e10cSrcweir Der selektierte Text wird soweit erweitert, 1466*cdf0e10cSrcweir da\s nur ganze W"orter zur"uckgegeben werden. 1467*cdf0e10cSrcweir Als Worttrenner gelten White-Spaces und die 1468*cdf0e10cSrcweir Satzzeichen ".,;" sowie einfache und doppelte 1469*cdf0e10cSrcweir Anf"uhrungszeichen. 1470*cdf0e10cSrcweir */ 1471*cdf0e10cSrcweir ) 1472*cdf0e10cSrcweir 1473*cdf0e10cSrcweir /* [Beschreibung] 1474*cdf0e10cSrcweir 1475*cdf0e10cSrcweir Diese Methode kann von Anwendungsprogrammierer "uberladen werden, 1476*cdf0e10cSrcweir um einen Text zur"uckzuliefern, der in der aktuellen Selektion 1477*cdf0e10cSrcweir steht. Dieser wird z.B. beim Versenden (email) verwendet. 1478*cdf0e10cSrcweir 1479*cdf0e10cSrcweir Mit "CompleteWords == TRUE" ger"ufen, reicht z.B. auch der Cursor, 1480*cdf0e10cSrcweir der in einer URL steht, um die gesamte URL zu liefern. 1481*cdf0e10cSrcweir */ 1482*cdf0e10cSrcweir 1483*cdf0e10cSrcweir { 1484*cdf0e10cSrcweir return String(); 1485*cdf0e10cSrcweir } 1486*cdf0e10cSrcweir 1487*cdf0e10cSrcweir //-------------------------------------------------------------------- 1488*cdf0e10cSrcweir 1489*cdf0e10cSrcweir sal_Bool SfxViewShell::HasSelection( sal_Bool ) const 1490*cdf0e10cSrcweir 1491*cdf0e10cSrcweir /* [Beschreibung] 1492*cdf0e10cSrcweir 1493*cdf0e10cSrcweir Mit dieser virtuellen Methode kann z.B. ein Dialog abfragen, ob in der 1494*cdf0e10cSrcweir aktuellen View etwas selektiert ist. Wenn der Parameter <sal_Bool> sal_True ist, 1495*cdf0e10cSrcweir wird abgefragt, ob Text selektiert ist. 1496*cdf0e10cSrcweir */ 1497*cdf0e10cSrcweir 1498*cdf0e10cSrcweir { 1499*cdf0e10cSrcweir return sal_False; 1500*cdf0e10cSrcweir } 1501*cdf0e10cSrcweir 1502*cdf0e10cSrcweir //-------------------------------------------------------------------- 1503*cdf0e10cSrcweir 1504*cdf0e10cSrcweir void SfxViewShell::SetSubShell( SfxShell *pShell ) 1505*cdf0e10cSrcweir 1506*cdf0e10cSrcweir /* [Beschreibung] 1507*cdf0e10cSrcweir 1508*cdf0e10cSrcweir Mit dieser Methode kann eine Selektions- oder Cursor-Shell angemeldet 1509*cdf0e10cSrcweir werden, die automatisch unmittelbar nach der SfxViewShell auf den 1510*cdf0e10cSrcweir SfxDispatcher gepusht wird, und automatisch umittelbar vor ihr 1511*cdf0e10cSrcweir gepoppt wird. 1512*cdf0e10cSrcweir 1513*cdf0e10cSrcweir Ist die SfxViewShell-Instanz bereits gepusht, dann wird pShell 1514*cdf0e10cSrcweir sofort ebenfalls gepusht. Wird mit SetSubShell eine andere SfxShell 1515*cdf0e10cSrcweir Instanz angemeldet, als vorher angemeldet war, wird die zuvor angemeldete 1516*cdf0e10cSrcweir ggf. automatisch gepoppt. Mit pShell==0 kann daher die aktuelle 1517*cdf0e10cSrcweir Sub-Shell abgemeldet werden. 1518*cdf0e10cSrcweir */ 1519*cdf0e10cSrcweir 1520*cdf0e10cSrcweir { 1521*cdf0e10cSrcweir // ist diese ViewShell "uberhaupt aktiv? 1522*cdf0e10cSrcweir SfxDispatcher *pDisp = pFrame->GetDispatcher(); 1523*cdf0e10cSrcweir if ( pDisp->IsActive(*this) ) 1524*cdf0e10cSrcweir { 1525*cdf0e10cSrcweir // Dispatcher updaten 1526*cdf0e10cSrcweir if ( pSubShell ) 1527*cdf0e10cSrcweir pDisp->Pop(*pSubShell); 1528*cdf0e10cSrcweir if ( pShell ) 1529*cdf0e10cSrcweir pDisp->Push(*pShell); 1530*cdf0e10cSrcweir pDisp->Flush(); 1531*cdf0e10cSrcweir } 1532*cdf0e10cSrcweir 1533*cdf0e10cSrcweir pSubShell = pShell; 1534*cdf0e10cSrcweir } 1535*cdf0e10cSrcweir 1536*cdf0e10cSrcweir void SfxViewShell::AddSubShell( SfxShell& rShell ) 1537*cdf0e10cSrcweir { 1538*cdf0e10cSrcweir pImp->aArr.Insert( &rShell, pImp->aArr.Count() ); 1539*cdf0e10cSrcweir SfxDispatcher *pDisp = pFrame->GetDispatcher(); 1540*cdf0e10cSrcweir if ( pDisp->IsActive(*this) ) 1541*cdf0e10cSrcweir { 1542*cdf0e10cSrcweir pDisp->Push(rShell); 1543*cdf0e10cSrcweir pDisp->Flush(); 1544*cdf0e10cSrcweir } 1545*cdf0e10cSrcweir } 1546*cdf0e10cSrcweir 1547*cdf0e10cSrcweir void SfxViewShell::RemoveSubShell( SfxShell* pShell ) 1548*cdf0e10cSrcweir { 1549*cdf0e10cSrcweir SfxDispatcher *pDisp = pFrame->GetDispatcher(); 1550*cdf0e10cSrcweir if ( !pShell ) 1551*cdf0e10cSrcweir { 1552*cdf0e10cSrcweir sal_uInt16 nCount = pImp->aArr.Count(); 1553*cdf0e10cSrcweir if ( pDisp->IsActive(*this) ) 1554*cdf0e10cSrcweir { 1555*cdf0e10cSrcweir for ( sal_uInt16 n=nCount; n>0; n-- ) 1556*cdf0e10cSrcweir pDisp->Pop( *pImp->aArr[n-1] ); 1557*cdf0e10cSrcweir pDisp->Flush(); 1558*cdf0e10cSrcweir } 1559*cdf0e10cSrcweir 1560*cdf0e10cSrcweir pImp->aArr.Remove(0, nCount); 1561*cdf0e10cSrcweir } 1562*cdf0e10cSrcweir else 1563*cdf0e10cSrcweir { 1564*cdf0e10cSrcweir sal_uInt16 nPos = pImp->aArr.GetPos( pShell ); 1565*cdf0e10cSrcweir if ( nPos != 0xFFFF ) 1566*cdf0e10cSrcweir { 1567*cdf0e10cSrcweir pImp->aArr.Remove( nPos ); 1568*cdf0e10cSrcweir if ( pDisp->IsActive(*this) ) 1569*cdf0e10cSrcweir { 1570*cdf0e10cSrcweir pDisp->RemoveShell_Impl( *pShell ); 1571*cdf0e10cSrcweir pDisp->Flush(); 1572*cdf0e10cSrcweir } 1573*cdf0e10cSrcweir } 1574*cdf0e10cSrcweir } 1575*cdf0e10cSrcweir } 1576*cdf0e10cSrcweir 1577*cdf0e10cSrcweir SfxShell* SfxViewShell::GetSubShell( sal_uInt16 nNo ) 1578*cdf0e10cSrcweir { 1579*cdf0e10cSrcweir sal_uInt16 nCount = pImp->aArr.Count(); 1580*cdf0e10cSrcweir if ( nNo<nCount ) 1581*cdf0e10cSrcweir return pImp->aArr[nCount-nNo-1]; 1582*cdf0e10cSrcweir return NULL; 1583*cdf0e10cSrcweir } 1584*cdf0e10cSrcweir 1585*cdf0e10cSrcweir void SfxViewShell::PushSubShells_Impl( sal_Bool bPush ) 1586*cdf0e10cSrcweir { 1587*cdf0e10cSrcweir sal_uInt16 nCount = pImp->aArr.Count(); 1588*cdf0e10cSrcweir SfxDispatcher *pDisp = pFrame->GetDispatcher(); 1589*cdf0e10cSrcweir if ( bPush ) 1590*cdf0e10cSrcweir { 1591*cdf0e10cSrcweir for ( sal_uInt16 n=0; n<nCount; n++ ) 1592*cdf0e10cSrcweir pDisp->Push( *pImp->aArr[n] ); 1593*cdf0e10cSrcweir } 1594*cdf0e10cSrcweir else if ( nCount ) 1595*cdf0e10cSrcweir { 1596*cdf0e10cSrcweir SfxShell& rPopUntil = *pImp->aArr[0]; 1597*cdf0e10cSrcweir if ( pDisp->GetShellLevel( rPopUntil ) != USHRT_MAX ) 1598*cdf0e10cSrcweir pDisp->Pop( rPopUntil, SFX_SHELL_POP_UNTIL ); 1599*cdf0e10cSrcweir } 1600*cdf0e10cSrcweir 1601*cdf0e10cSrcweir pDisp->Flush(); 1602*cdf0e10cSrcweir } 1603*cdf0e10cSrcweir 1604*cdf0e10cSrcweir //-------------------------------------------------------------------- 1605*cdf0e10cSrcweir 1606*cdf0e10cSrcweir void SfxViewShell::WriteUserData( String&, sal_Bool ) 1607*cdf0e10cSrcweir { 1608*cdf0e10cSrcweir } 1609*cdf0e10cSrcweir 1610*cdf0e10cSrcweir //-------------------------------------------------------------------- 1611*cdf0e10cSrcweir 1612*cdf0e10cSrcweir void SfxViewShell::ReadUserData(const String&, sal_Bool ) 1613*cdf0e10cSrcweir { 1614*cdf0e10cSrcweir } 1615*cdf0e10cSrcweir 1616*cdf0e10cSrcweir void SfxViewShell::ReadUserDataSequence ( const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >&, sal_Bool ) 1617*cdf0e10cSrcweir { 1618*cdf0e10cSrcweir } 1619*cdf0e10cSrcweir 1620*cdf0e10cSrcweir void SfxViewShell::WriteUserDataSequence ( ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >&, sal_Bool ) 1621*cdf0e10cSrcweir { 1622*cdf0e10cSrcweir } 1623*cdf0e10cSrcweir 1624*cdf0e10cSrcweir 1625*cdf0e10cSrcweir //-------------------------------------------------------------------- 1626*cdf0e10cSrcweir // returns the first shell of spec. type viewing the specified doc. 1627*cdf0e10cSrcweir 1628*cdf0e10cSrcweir SfxViewShell* SfxViewShell::GetFirst 1629*cdf0e10cSrcweir ( 1630*cdf0e10cSrcweir const TypeId* pType, 1631*cdf0e10cSrcweir sal_Bool bOnlyVisible 1632*cdf0e10cSrcweir ) 1633*cdf0e10cSrcweir { 1634*cdf0e10cSrcweir // search for a SfxViewShell of the specified type 1635*cdf0e10cSrcweir SfxViewShellArr_Impl &rShells = SFX_APP()->GetViewShells_Impl(); 1636*cdf0e10cSrcweir SfxViewFrameArr_Impl &rFrames = SFX_APP()->GetViewFrames_Impl(); 1637*cdf0e10cSrcweir for ( sal_uInt16 nPos = 0; nPos < rShells.Count(); ++nPos ) 1638*cdf0e10cSrcweir { 1639*cdf0e10cSrcweir SfxViewShell *pShell = rShells.GetObject(nPos); 1640*cdf0e10cSrcweir if ( pShell ) 1641*cdf0e10cSrcweir { 1642*cdf0e10cSrcweir // sometimes dangling SfxViewShells exist that point to a dead SfxViewFrame 1643*cdf0e10cSrcweir // these ViewShells shouldn't be accessible anymore 1644*cdf0e10cSrcweir // a destroyed ViewFrame is not in the ViewFrame array anymore, so checking this array helps 1645*cdf0e10cSrcweir for ( sal_uInt16 n=0; n<rFrames.Count(); ++n ) 1646*cdf0e10cSrcweir { 1647*cdf0e10cSrcweir SfxViewFrame *pFrame = rFrames.GetObject(n); 1648*cdf0e10cSrcweir if ( pFrame == pShell->GetViewFrame() ) 1649*cdf0e10cSrcweir { 1650*cdf0e10cSrcweir // only ViewShells with a valid ViewFrame will be returned 1651*cdf0e10cSrcweir if ( ( !bOnlyVisible || pFrame->IsVisible() ) && ( !pType || pShell->IsA(*pType) ) ) 1652*cdf0e10cSrcweir return pShell; 1653*cdf0e10cSrcweir break; 1654*cdf0e10cSrcweir } 1655*cdf0e10cSrcweir } 1656*cdf0e10cSrcweir } 1657*cdf0e10cSrcweir } 1658*cdf0e10cSrcweir 1659*cdf0e10cSrcweir return 0; 1660*cdf0e10cSrcweir } 1661*cdf0e10cSrcweir 1662*cdf0e10cSrcweir //-------------------------------------------------------------------- 1663*cdf0e10cSrcweir // returns the next shell of spec. type viewing the specified doc. 1664*cdf0e10cSrcweir 1665*cdf0e10cSrcweir SfxViewShell* SfxViewShell::GetNext 1666*cdf0e10cSrcweir ( 1667*cdf0e10cSrcweir const SfxViewShell& rPrev, 1668*cdf0e10cSrcweir const TypeId* pType, 1669*cdf0e10cSrcweir sal_Bool bOnlyVisible 1670*cdf0e10cSrcweir ) 1671*cdf0e10cSrcweir { 1672*cdf0e10cSrcweir SfxViewShellArr_Impl &rShells = SFX_APP()->GetViewShells_Impl(); 1673*cdf0e10cSrcweir SfxViewFrameArr_Impl &rFrames = SFX_APP()->GetViewFrames_Impl(); 1674*cdf0e10cSrcweir sal_uInt16 nPos; 1675*cdf0e10cSrcweir for ( nPos = 0; nPos < rShells.Count(); ++nPos ) 1676*cdf0e10cSrcweir if ( rShells.GetObject(nPos) == &rPrev ) 1677*cdf0e10cSrcweir break; 1678*cdf0e10cSrcweir 1679*cdf0e10cSrcweir for ( ++nPos; nPos < rShells.Count(); ++nPos ) 1680*cdf0e10cSrcweir { 1681*cdf0e10cSrcweir SfxViewShell *pShell = rShells.GetObject(nPos); 1682*cdf0e10cSrcweir if ( pShell ) 1683*cdf0e10cSrcweir { 1684*cdf0e10cSrcweir // sometimes dangling SfxViewShells exist that point to a dead SfxViewFrame 1685*cdf0e10cSrcweir // these ViewShells shouldn't be accessible anymore 1686*cdf0e10cSrcweir // a destroyed ViewFrame is not in the ViewFrame array anymore, so checking this array helps 1687*cdf0e10cSrcweir for ( sal_uInt16 n=0; n<rFrames.Count(); ++n ) 1688*cdf0e10cSrcweir { 1689*cdf0e10cSrcweir SfxViewFrame *pFrame = rFrames.GetObject(n); 1690*cdf0e10cSrcweir if ( pFrame == pShell->GetViewFrame() ) 1691*cdf0e10cSrcweir { 1692*cdf0e10cSrcweir // only ViewShells with a valid ViewFrame will be returned 1693*cdf0e10cSrcweir if ( ( !bOnlyVisible || pFrame->IsVisible() ) && ( !pType || pShell->IsA(*pType) ) ) 1694*cdf0e10cSrcweir return pShell; 1695*cdf0e10cSrcweir break; 1696*cdf0e10cSrcweir } 1697*cdf0e10cSrcweir } 1698*cdf0e10cSrcweir } 1699*cdf0e10cSrcweir } 1700*cdf0e10cSrcweir 1701*cdf0e10cSrcweir return 0; 1702*cdf0e10cSrcweir } 1703*cdf0e10cSrcweir 1704*cdf0e10cSrcweir //-------------------------------------------------------------------- 1705*cdf0e10cSrcweir 1706*cdf0e10cSrcweir void SfxViewShell::Notify( SfxBroadcaster& rBC, 1707*cdf0e10cSrcweir const SfxHint& rHint ) 1708*cdf0e10cSrcweir { 1709*cdf0e10cSrcweir if ( rHint.IsA(TYPE(SfxEventHint)) ) 1710*cdf0e10cSrcweir { 1711*cdf0e10cSrcweir switch ( ((SfxEventHint&)rHint).GetEventId() ) 1712*cdf0e10cSrcweir { 1713*cdf0e10cSrcweir case SFX_EVENT_LOADFINISHED: 1714*cdf0e10cSrcweir { 1715*cdf0e10cSrcweir if ( GetController().is() ) 1716*cdf0e10cSrcweir { 1717*cdf0e10cSrcweir // avoid access to dangling ViewShells 1718*cdf0e10cSrcweir SfxViewFrameArr_Impl &rFrames = SFX_APP()->GetViewFrames_Impl(); 1719*cdf0e10cSrcweir for ( sal_uInt16 n=0; n<rFrames.Count(); ++n ) 1720*cdf0e10cSrcweir { 1721*cdf0e10cSrcweir SfxViewFrame *frame = rFrames.GetObject(n); 1722*cdf0e10cSrcweir if ( frame == GetViewFrame() && &rBC == GetObjectShell() ) 1723*cdf0e10cSrcweir { 1724*cdf0e10cSrcweir SfxItemSet* pSet = GetObjectShell()->GetMedium()->GetItemSet(); 1725*cdf0e10cSrcweir SFX_ITEMSET_ARG( pSet, pItem, SfxUnoAnyItem, SID_VIEW_DATA, sal_False ); 1726*cdf0e10cSrcweir if ( pItem ) 1727*cdf0e10cSrcweir { 1728*cdf0e10cSrcweir pImp->m_pController->restoreViewData( 1729*cdf0e10cSrcweir pItem->GetValue() ); 1730*cdf0e10cSrcweir pSet->ClearItem( SID_VIEW_DATA ); 1731*cdf0e10cSrcweir } 1732*cdf0e10cSrcweir 1733*cdf0e10cSrcweir break; 1734*cdf0e10cSrcweir } 1735*cdf0e10cSrcweir } 1736*cdf0e10cSrcweir } 1737*cdf0e10cSrcweir 1738*cdf0e10cSrcweir break; 1739*cdf0e10cSrcweir } 1740*cdf0e10cSrcweir } 1741*cdf0e10cSrcweir } 1742*cdf0e10cSrcweir } 1743*cdf0e10cSrcweir 1744*cdf0e10cSrcweir //-------------------------------------------------------------------- 1745*cdf0e10cSrcweir 1746*cdf0e10cSrcweir sal_Bool SfxViewShell::ExecKey_Impl(const KeyEvent& aKey) 1747*cdf0e10cSrcweir { 1748*cdf0e10cSrcweir if (!pImp->m_pAccExec.get()) 1749*cdf0e10cSrcweir { 1750*cdf0e10cSrcweir pImp->m_pAccExec.reset( 1751*cdf0e10cSrcweir ::svt::AcceleratorExecute::createAcceleratorHelper() ); 1752*cdf0e10cSrcweir pImp->m_pAccExec->init(::comphelper::getProcessServiceFactory(), 1753*cdf0e10cSrcweir pFrame->GetFrame().GetFrameInterface()); 1754*cdf0e10cSrcweir } 1755*cdf0e10cSrcweir 1756*cdf0e10cSrcweir return pImp->m_pAccExec->execute(aKey.GetKeyCode()); 1757*cdf0e10cSrcweir } 1758*cdf0e10cSrcweir 1759*cdf0e10cSrcweir //-------------------------------------------------------------------- 1760*cdf0e10cSrcweir 1761*cdf0e10cSrcweir FASTBOOL SfxViewShell::KeyInput( const KeyEvent &rKeyEvent ) 1762*cdf0e10cSrcweir 1763*cdf0e10cSrcweir /* [Beschreibung] 1764*cdf0e10cSrcweir 1765*cdf0e10cSrcweir Diese Methode f"uhrt das KeyEvent 'rKeyEvent' "uber die an dieser 1766*cdf0e10cSrcweir SfxViewShell direkt oder indirekt (z.B. via Applikation) konfigurierten 1767*cdf0e10cSrcweir Tasten (Accelerator) aus. 1768*cdf0e10cSrcweir 1769*cdf0e10cSrcweir 1770*cdf0e10cSrcweir [R"uckgabewert] 1771*cdf0e10cSrcweir 1772*cdf0e10cSrcweir FASTBOOL sal_True 1773*cdf0e10cSrcweir die Taste ist konfiguriert, der betreffende 1774*cdf0e10cSrcweir Handler wurde gerufen 1775*cdf0e10cSrcweir 1776*cdf0e10cSrcweir FALSE 1777*cdf0e10cSrcweir die Taste ist nicht konfiguriert, es konnte 1778*cdf0e10cSrcweir also kein Handler gerufen werden 1779*cdf0e10cSrcweir 1780*cdf0e10cSrcweir 1781*cdf0e10cSrcweir [Querverweise] 1782*cdf0e10cSrcweir <SfxApplication::KeyInput(const KeyEvent&)> 1783*cdf0e10cSrcweir */ 1784*cdf0e10cSrcweir { 1785*cdf0e10cSrcweir return ExecKey_Impl(rKeyEvent); 1786*cdf0e10cSrcweir } 1787*cdf0e10cSrcweir 1788*cdf0e10cSrcweir bool SfxViewShell::GlobalKeyInput_Impl( const KeyEvent &rKeyEvent ) 1789*cdf0e10cSrcweir { 1790*cdf0e10cSrcweir return ExecKey_Impl(rKeyEvent); 1791*cdf0e10cSrcweir } 1792*cdf0e10cSrcweir 1793*cdf0e10cSrcweir //-------------------------------------------------------------------- 1794*cdf0e10cSrcweir 1795*cdf0e10cSrcweir void SfxViewShell::ShowCursor( FASTBOOL /*bOn*/ ) 1796*cdf0e10cSrcweir 1797*cdf0e10cSrcweir /* [Beschreibung] 1798*cdf0e10cSrcweir 1799*cdf0e10cSrcweir Diese Methode mu\s von Subklassen "uberladen werden, damit vom SFx 1800*cdf0e10cSrcweir aus der Cursor ein- und ausgeschaltet werden kann. Dies geschieht 1801*cdf0e10cSrcweir z.B. bei laufendem <SfxProgress>. 1802*cdf0e10cSrcweir */ 1803*cdf0e10cSrcweir 1804*cdf0e10cSrcweir { 1805*cdf0e10cSrcweir } 1806*cdf0e10cSrcweir 1807*cdf0e10cSrcweir //-------------------------------------------------------------------- 1808*cdf0e10cSrcweir 1809*cdf0e10cSrcweir void SfxViewShell::GotFocus() const 1810*cdf0e10cSrcweir 1811*cdf0e10cSrcweir /* [Beschreibung] 1812*cdf0e10cSrcweir 1813*cdf0e10cSrcweir Diese Methode mu\s vom Applikationsentwickler gerufen werden, wenn 1814*cdf0e10cSrcweir das Edit-Window den Focus erhalten hat. Der SFx hat so z.B. die 1815*cdf0e10cSrcweir M"oglichkeit, den Accelerator einzuschalten. 1816*cdf0e10cSrcweir 1817*cdf0e10cSrcweir 1818*cdf0e10cSrcweir [Anmerkung] 1819*cdf0e10cSrcweir 1820*cdf0e10cSrcweir <StarView> liefert leider keine M"oglichkeit, solche Events 1821*cdf0e10cSrcweir 'von der Seite' einzuh"angen. 1822*cdf0e10cSrcweir */ 1823*cdf0e10cSrcweir 1824*cdf0e10cSrcweir { 1825*cdf0e10cSrcweir } 1826*cdf0e10cSrcweir 1827*cdf0e10cSrcweir //-------------------------------------------------------------------- 1828*cdf0e10cSrcweir void SfxViewShell::ResetAllClients_Impl( SfxInPlaceClient *pIP ) 1829*cdf0e10cSrcweir { 1830*cdf0e10cSrcweir 1831*cdf0e10cSrcweir SfxInPlaceClientList *pClients = GetIPClientList_Impl(sal_False); 1832*cdf0e10cSrcweir if ( !pClients ) 1833*cdf0e10cSrcweir return; 1834*cdf0e10cSrcweir 1835*cdf0e10cSrcweir for ( sal_uInt16 n=0; n < pClients->Count(); n++ ) 1836*cdf0e10cSrcweir { 1837*cdf0e10cSrcweir SfxInPlaceClient* pIPClient = pClients->GetObject(n); 1838*cdf0e10cSrcweir if( pIPClient != pIP ) 1839*cdf0e10cSrcweir pIPClient->ResetObject(); 1840*cdf0e10cSrcweir } 1841*cdf0e10cSrcweir } 1842*cdf0e10cSrcweir 1843*cdf0e10cSrcweir //-------------------------------------------------------------------- 1844*cdf0e10cSrcweir 1845*cdf0e10cSrcweir void SfxViewShell::DisconnectAllClients() 1846*cdf0e10cSrcweir { 1847*cdf0e10cSrcweir SfxInPlaceClientList *pClients = GetIPClientList_Impl(sal_False); 1848*cdf0e10cSrcweir if ( !pClients ) 1849*cdf0e10cSrcweir return; 1850*cdf0e10cSrcweir 1851*cdf0e10cSrcweir for ( sal_uInt16 n=0; n<pClients->Count(); ) 1852*cdf0e10cSrcweir // clients will remove themselves from the list 1853*cdf0e10cSrcweir delete pClients->GetObject(n); 1854*cdf0e10cSrcweir } 1855*cdf0e10cSrcweir 1856*cdf0e10cSrcweir //-------------------------------------------------------------------- 1857*cdf0e10cSrcweir 1858*cdf0e10cSrcweir void SfxViewShell::QueryObjAreaPixel( Rectangle& ) const 1859*cdf0e10cSrcweir { 1860*cdf0e10cSrcweir } 1861*cdf0e10cSrcweir 1862*cdf0e10cSrcweir //-------------------------------------------------------------------- 1863*cdf0e10cSrcweir 1864*cdf0e10cSrcweir void SfxViewShell::AdjustVisArea(const Rectangle& rRect) 1865*cdf0e10cSrcweir { 1866*cdf0e10cSrcweir DBG_ASSERT (pFrame, "Kein Frame?"); 1867*cdf0e10cSrcweir GetObjectShell()->SetVisArea( rRect ); 1868*cdf0e10cSrcweir } 1869*cdf0e10cSrcweir 1870*cdf0e10cSrcweir //-------------------------------------------------------------------- 1871*cdf0e10cSrcweir 1872*cdf0e10cSrcweir void SfxViewShell::VisAreaChanged(const Rectangle& /*rVisArea*/) 1873*cdf0e10cSrcweir { 1874*cdf0e10cSrcweir SfxInPlaceClientList *pClients = GetIPClientList_Impl(sal_False); 1875*cdf0e10cSrcweir if ( !pClients ) 1876*cdf0e10cSrcweir return; 1877*cdf0e10cSrcweir 1878*cdf0e10cSrcweir for (sal_uInt16 n=0; n < pClients->Count(); n++) 1879*cdf0e10cSrcweir { 1880*cdf0e10cSrcweir SfxInPlaceClient* pIPClient = pClients->GetObject(n); 1881*cdf0e10cSrcweir if ( pIPClient->IsObjectInPlaceActive() ) 1882*cdf0e10cSrcweir // client is active, notify client that the VisArea might have changed 1883*cdf0e10cSrcweir pIPClient->VisAreaChanged(); 1884*cdf0e10cSrcweir } 1885*cdf0e10cSrcweir } 1886*cdf0e10cSrcweir 1887*cdf0e10cSrcweir //-------------------------------------------------------------------- 1888*cdf0e10cSrcweir void SfxViewShell::CheckIPClient_Impl( SfxInPlaceClient *pIPClient, const Rectangle& rVisArea ) 1889*cdf0e10cSrcweir { 1890*cdf0e10cSrcweir if ( GetObjectShell()->IsInClose() ) 1891*cdf0e10cSrcweir return; 1892*cdf0e10cSrcweir 1893*cdf0e10cSrcweir sal_Bool bAlwaysActive = 1894*cdf0e10cSrcweir ( ( pIPClient->GetObjectMiscStatus() & embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY ) != 0 ); 1895*cdf0e10cSrcweir sal_Bool bActiveWhenVisible = 1896*cdf0e10cSrcweir ( ( pIPClient->GetObjectMiscStatus() & embed::EmbedMisc::MS_EMBED_ACTIVATEWHENVISIBLE ) != 0 ); 1897*cdf0e10cSrcweir 1898*cdf0e10cSrcweir // this method is called when either a client is created or the "Edit/Plugins" checkbox is checked 1899*cdf0e10cSrcweir if ( !pIPClient->IsObjectInPlaceActive() && pImp->m_bPlugInsActive ) 1900*cdf0e10cSrcweir { 1901*cdf0e10cSrcweir // object in client is currently not active 1902*cdf0e10cSrcweir // check if the object wants to be activated always or when it becomes at least partially visible 1903*cdf0e10cSrcweir // TODO/LATER: maybe we should use the scaled area instead of the ObjArea?! 1904*cdf0e10cSrcweir if ( bAlwaysActive || (bActiveWhenVisible && rVisArea.IsOver(pIPClient->GetObjArea())) ) 1905*cdf0e10cSrcweir { 1906*cdf0e10cSrcweir try 1907*cdf0e10cSrcweir { 1908*cdf0e10cSrcweir pIPClient->GetObject()->changeState( embed::EmbedStates::INPLACE_ACTIVE ); 1909*cdf0e10cSrcweir } 1910*cdf0e10cSrcweir catch ( uno::Exception& ) 1911*cdf0e10cSrcweir { 1912*cdf0e10cSrcweir } 1913*cdf0e10cSrcweir } 1914*cdf0e10cSrcweir } 1915*cdf0e10cSrcweir else if (!pImp->m_bPlugInsActive) 1916*cdf0e10cSrcweir { 1917*cdf0e10cSrcweir // object in client is currently active and "Edit/Plugins" checkbox is selected 1918*cdf0e10cSrcweir // check if the object wants to be activated always or when it becomes at least partially visible 1919*cdf0e10cSrcweir // in this case selecting of the "Edit/Plugin" checkbox should let such objects deactivate 1920*cdf0e10cSrcweir if ( bAlwaysActive || bActiveWhenVisible ) 1921*cdf0e10cSrcweir pIPClient->GetObject()->changeState( embed::EmbedStates::RUNNING ); 1922*cdf0e10cSrcweir } 1923*cdf0e10cSrcweir } 1924*cdf0e10cSrcweir 1925*cdf0e10cSrcweir //-------------------------------------------------------------------- 1926*cdf0e10cSrcweir 1927*cdf0e10cSrcweir sal_Bool SfxViewShell::PlugInsActive() const 1928*cdf0e10cSrcweir { 1929*cdf0e10cSrcweir return pImp->m_bPlugInsActive; 1930*cdf0e10cSrcweir } 1931*cdf0e10cSrcweir 1932*cdf0e10cSrcweir //-------------------------------------------------------------------- 1933*cdf0e10cSrcweir void SfxViewShell::DiscardClients_Impl() 1934*cdf0e10cSrcweir 1935*cdf0e10cSrcweir /* [Beschreibung] 1936*cdf0e10cSrcweir 1937*cdf0e10cSrcweir Diese Methode dient dazu, vor dem Schlie\sen eines Dokuments das 1938*cdf0e10cSrcweir Speichern der Objekte zu verhindern, wenn der Benutzer Schlie\en ohne 1939*cdf0e10cSrcweir Speichern gew"ahlt hatte. 1940*cdf0e10cSrcweir */ 1941*cdf0e10cSrcweir 1942*cdf0e10cSrcweir { 1943*cdf0e10cSrcweir SfxInPlaceClientList *pClients = GetIPClientList_Impl(sal_False); 1944*cdf0e10cSrcweir if ( !pClients ) 1945*cdf0e10cSrcweir return; 1946*cdf0e10cSrcweir 1947*cdf0e10cSrcweir for (sal_uInt16 n=0; n < pClients->Count(); ) 1948*cdf0e10cSrcweir delete pClients->GetObject(n); 1949*cdf0e10cSrcweir } 1950*cdf0e10cSrcweir 1951*cdf0e10cSrcweir //-------------------------------------------------------------------- 1952*cdf0e10cSrcweir 1953*cdf0e10cSrcweir SfxScrollingMode SfxViewShell::GetScrollingMode() const 1954*cdf0e10cSrcweir { 1955*cdf0e10cSrcweir return pImp->m_eScroll; 1956*cdf0e10cSrcweir } 1957*cdf0e10cSrcweir 1958*cdf0e10cSrcweir //-------------------------------------------------------------------- 1959*cdf0e10cSrcweir 1960*cdf0e10cSrcweir void SfxViewShell::SetScrollingMode( SfxScrollingMode eMode ) 1961*cdf0e10cSrcweir { 1962*cdf0e10cSrcweir pImp->m_eScroll = eMode; 1963*cdf0e10cSrcweir } 1964*cdf0e10cSrcweir 1965*cdf0e10cSrcweir //-------------------------------------------------------------------- 1966*cdf0e10cSrcweir 1967*cdf0e10cSrcweir SfxObjectShell* SfxViewShell::GetObjectShell() 1968*cdf0e10cSrcweir { 1969*cdf0e10cSrcweir return pFrame ? pFrame->GetObjectShell() : NULL; 1970*cdf0e10cSrcweir } 1971*cdf0e10cSrcweir 1972*cdf0e10cSrcweir //-------------------------------------------------------------------- 1973*cdf0e10cSrcweir 1974*cdf0e10cSrcweir Reference< XModel > SfxViewShell::GetCurrentDocument() const 1975*cdf0e10cSrcweir { 1976*cdf0e10cSrcweir Reference< XModel > xDocument; 1977*cdf0e10cSrcweir 1978*cdf0e10cSrcweir const SfxObjectShell* pDocShell( const_cast< SfxViewShell* >( this )->GetObjectShell() ); 1979*cdf0e10cSrcweir OSL_ENSURE( pDocShell, "SfxViewFrame::GetCurrentDocument: no DocShell!?" ); 1980*cdf0e10cSrcweir if ( pDocShell ) 1981*cdf0e10cSrcweir xDocument = pDocShell->GetModel(); 1982*cdf0e10cSrcweir return xDocument; 1983*cdf0e10cSrcweir } 1984*cdf0e10cSrcweir 1985*cdf0e10cSrcweir //-------------------------------------------------------------------- 1986*cdf0e10cSrcweir 1987*cdf0e10cSrcweir void SfxViewShell::SetCurrentDocument() const 1988*cdf0e10cSrcweir { 1989*cdf0e10cSrcweir uno::Reference< frame::XModel > xDocument( GetCurrentDocument() ); 1990*cdf0e10cSrcweir if ( xDocument.is() ) 1991*cdf0e10cSrcweir SfxObjectShell::SetCurrentComponent( xDocument ); 1992*cdf0e10cSrcweir } 1993*cdf0e10cSrcweir 1994*cdf0e10cSrcweir //-------------------------------------------------------------------- 1995*cdf0e10cSrcweir 1996*cdf0e10cSrcweir const Size& SfxViewShell::GetMargin() const 1997*cdf0e10cSrcweir { 1998*cdf0e10cSrcweir return pImp->aMargin; 1999*cdf0e10cSrcweir } 2000*cdf0e10cSrcweir 2001*cdf0e10cSrcweir //-------------------------------------------------------------------- 2002*cdf0e10cSrcweir 2003*cdf0e10cSrcweir void SfxViewShell::SetMargin( const Size& rSize ) 2004*cdf0e10cSrcweir { 2005*cdf0e10cSrcweir // Der default-Margin wurde "geeicht" mit www.apple.com !! 2006*cdf0e10cSrcweir Size aMargin = rSize; 2007*cdf0e10cSrcweir if ( aMargin.Width() == -1 ) 2008*cdf0e10cSrcweir aMargin.Width() = DEFAULT_MARGIN_WIDTH; 2009*cdf0e10cSrcweir if ( aMargin.Height() == -1 ) 2010*cdf0e10cSrcweir aMargin.Height() = DEFAULT_MARGIN_HEIGHT; 2011*cdf0e10cSrcweir 2012*cdf0e10cSrcweir if ( aMargin != pImp->aMargin ) 2013*cdf0e10cSrcweir { 2014*cdf0e10cSrcweir pImp->aMargin = aMargin; 2015*cdf0e10cSrcweir MarginChanged(); 2016*cdf0e10cSrcweir } 2017*cdf0e10cSrcweir } 2018*cdf0e10cSrcweir 2019*cdf0e10cSrcweir //-------------------------------------------------------------------- 2020*cdf0e10cSrcweir 2021*cdf0e10cSrcweir void SfxViewShell::MarginChanged() 2022*cdf0e10cSrcweir { 2023*cdf0e10cSrcweir } 2024*cdf0e10cSrcweir 2025*cdf0e10cSrcweir //-------------------------------------------------------------------- 2026*cdf0e10cSrcweir 2027*cdf0e10cSrcweir sal_Bool SfxViewShell::IsShowView_Impl() const 2028*cdf0e10cSrcweir { 2029*cdf0e10cSrcweir return pImp->m_bIsShowView; 2030*cdf0e10cSrcweir } 2031*cdf0e10cSrcweir 2032*cdf0e10cSrcweir //-------------------------------------------------------------------- 2033*cdf0e10cSrcweir 2034*cdf0e10cSrcweir SfxFrame* SfxViewShell::GetSmartSelf( SfxFrame* pSelf, SfxMedium& /*rMedium*/ ) 2035*cdf0e10cSrcweir { 2036*cdf0e10cSrcweir return pSelf; 2037*cdf0e10cSrcweir } 2038*cdf0e10cSrcweir 2039*cdf0e10cSrcweir //------------------------------------------------------------------------ 2040*cdf0e10cSrcweir 2041*cdf0e10cSrcweir void SfxViewShell::JumpToMark( const String& rMark ) 2042*cdf0e10cSrcweir { 2043*cdf0e10cSrcweir SfxStringItem aMarkItem( SID_JUMPTOMARK, rMark ); 2044*cdf0e10cSrcweir GetViewFrame()->GetDispatcher()->Execute( 2045*cdf0e10cSrcweir SID_JUMPTOMARK, 2046*cdf0e10cSrcweir SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, 2047*cdf0e10cSrcweir &aMarkItem, 0L ); 2048*cdf0e10cSrcweir } 2049*cdf0e10cSrcweir 2050*cdf0e10cSrcweir //------------------------------------------------------------------------ 2051*cdf0e10cSrcweir 2052*cdf0e10cSrcweir SfxInPlaceClientList* SfxViewShell::GetIPClientList_Impl( sal_Bool bCreate ) const 2053*cdf0e10cSrcweir { 2054*cdf0e10cSrcweir if ( !pIPClientList && bCreate ) 2055*cdf0e10cSrcweir ( (SfxViewShell*) this )->pIPClientList = new SfxInPlaceClientList; 2056*cdf0e10cSrcweir return pIPClientList; 2057*cdf0e10cSrcweir } 2058*cdf0e10cSrcweir 2059*cdf0e10cSrcweir void SfxViewShell::SetController( SfxBaseController* pController ) 2060*cdf0e10cSrcweir { 2061*cdf0e10cSrcweir pImp->m_pController = pController; 2062*cdf0e10cSrcweir pImp->m_bControllerSet = true; 2063*cdf0e10cSrcweir 2064*cdf0e10cSrcweir // there should be no old listener, but if there is one, it should be disconnected 2065*cdf0e10cSrcweir if ( pImp->xClipboardListener.is() ) 2066*cdf0e10cSrcweir pImp->xClipboardListener->DisconnectViewShell(); 2067*cdf0e10cSrcweir 2068*cdf0e10cSrcweir pImp->xClipboardListener = new SfxClipboardChangeListener( this, GetClipboardNotifier() ); 2069*cdf0e10cSrcweir } 2070*cdf0e10cSrcweir 2071*cdf0e10cSrcweir Reference < XController > SfxViewShell::GetController() 2072*cdf0e10cSrcweir { 2073*cdf0e10cSrcweir return pImp->m_pController.get(); 2074*cdf0e10cSrcweir } 2075*cdf0e10cSrcweir 2076*cdf0e10cSrcweir SfxBaseController* SfxViewShell::GetBaseController_Impl() const 2077*cdf0e10cSrcweir { 2078*cdf0e10cSrcweir return pImp->m_pController.get(); 2079*cdf0e10cSrcweir } 2080*cdf0e10cSrcweir 2081*cdf0e10cSrcweir void SfxViewShell::AddContextMenuInterceptor_Impl( const REFERENCE< XCONTEXTMENUINTERCEPTOR >& xInterceptor ) 2082*cdf0e10cSrcweir { 2083*cdf0e10cSrcweir pImp->aInterceptorContainer.addInterface( xInterceptor ); 2084*cdf0e10cSrcweir } 2085*cdf0e10cSrcweir 2086*cdf0e10cSrcweir void SfxViewShell::RemoveContextMenuInterceptor_Impl( const REFERENCE< XCONTEXTMENUINTERCEPTOR >& xInterceptor ) 2087*cdf0e10cSrcweir { 2088*cdf0e10cSrcweir pImp->aInterceptorContainer.removeInterface( xInterceptor ); 2089*cdf0e10cSrcweir } 2090*cdf0e10cSrcweir 2091*cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper& SfxViewShell::GetContextMenuInterceptors() const 2092*cdf0e10cSrcweir { 2093*cdf0e10cSrcweir return pImp->aInterceptorContainer; 2094*cdf0e10cSrcweir } 2095*cdf0e10cSrcweir 2096*cdf0e10cSrcweir void Change( Menu* pMenu, SfxViewShell* pView ) 2097*cdf0e10cSrcweir { 2098*cdf0e10cSrcweir SfxDispatcher *pDisp = pView->GetViewFrame()->GetDispatcher(); 2099*cdf0e10cSrcweir sal_uInt16 nCount = pMenu->GetItemCount(); 2100*cdf0e10cSrcweir for ( sal_uInt16 nPos=0; nPos<nCount; ++nPos ) 2101*cdf0e10cSrcweir { 2102*cdf0e10cSrcweir sal_uInt16 nId = pMenu->GetItemId(nPos); 2103*cdf0e10cSrcweir String aCmd = pMenu->GetItemCommand(nId); 2104*cdf0e10cSrcweir PopupMenu* pPopup = pMenu->GetPopupMenu(nId); 2105*cdf0e10cSrcweir if ( pPopup ) 2106*cdf0e10cSrcweir { 2107*cdf0e10cSrcweir Change( pPopup, pView ); 2108*cdf0e10cSrcweir } 2109*cdf0e10cSrcweir else if ( nId < 5000 ) 2110*cdf0e10cSrcweir { 2111*cdf0e10cSrcweir if ( aCmd.CompareToAscii(".uno:", 5) == 0 ) 2112*cdf0e10cSrcweir { 2113*cdf0e10cSrcweir for (sal_uInt16 nIdx=0;;) 2114*cdf0e10cSrcweir { 2115*cdf0e10cSrcweir SfxShell *pShell=pDisp->GetShell(nIdx++); 2116*cdf0e10cSrcweir if (pShell == NULL) 2117*cdf0e10cSrcweir break; 2118*cdf0e10cSrcweir const SfxInterface *pIFace = pShell->GetInterface(); 2119*cdf0e10cSrcweir const SfxSlot* pSlot = pIFace->GetSlot( aCmd ); 2120*cdf0e10cSrcweir if ( pSlot ) 2121*cdf0e10cSrcweir { 2122*cdf0e10cSrcweir pMenu->InsertItem( pSlot->GetSlotId(), pMenu->GetItemText( nId ), pMenu->GetItemBits( nId ), nPos ); 2123*cdf0e10cSrcweir pMenu->SetItemCommand( pSlot->GetSlotId(), aCmd ); 2124*cdf0e10cSrcweir pMenu->RemoveItem( nPos+1 ); 2125*cdf0e10cSrcweir break; 2126*cdf0e10cSrcweir } 2127*cdf0e10cSrcweir } 2128*cdf0e10cSrcweir } 2129*cdf0e10cSrcweir } 2130*cdf0e10cSrcweir } 2131*cdf0e10cSrcweir } 2132*cdf0e10cSrcweir 2133*cdf0e10cSrcweir 2134*cdf0e10cSrcweir sal_Bool SfxViewShell::TryContextMenuInterception( Menu& rIn, const ::rtl::OUString& rMenuIdentifier, Menu*& rpOut, ui::ContextMenuExecuteEvent aEvent ) 2135*cdf0e10cSrcweir { 2136*cdf0e10cSrcweir rpOut = NULL; 2137*cdf0e10cSrcweir sal_Bool bModified = sal_False; 2138*cdf0e10cSrcweir 2139*cdf0e10cSrcweir // create container from menu 2140*cdf0e10cSrcweir // #110897# 2141*cdf0e10cSrcweir // aEvent.ActionTriggerContainer = ::framework::ActionTriggerHelper::CreateActionTriggerContainerFromMenu( &rIn ); 2142*cdf0e10cSrcweir aEvent.ActionTriggerContainer = ::framework::ActionTriggerHelper::CreateActionTriggerContainerFromMenu( 2143*cdf0e10cSrcweir ::comphelper::getProcessServiceFactory(), &rIn, &rMenuIdentifier ); 2144*cdf0e10cSrcweir 2145*cdf0e10cSrcweir // get selection from controller 2146*cdf0e10cSrcweir aEvent.Selection = uno::Reference < view::XSelectionSupplier > ( GetController(), uno::UNO_QUERY ); 2147*cdf0e10cSrcweir 2148*cdf0e10cSrcweir // call interceptors 2149*cdf0e10cSrcweir ::cppu::OInterfaceIteratorHelper aIt( pImp->aInterceptorContainer ); 2150*cdf0e10cSrcweir while( aIt.hasMoreElements() ) 2151*cdf0e10cSrcweir { 2152*cdf0e10cSrcweir try 2153*cdf0e10cSrcweir { 2154*cdf0e10cSrcweir ui::ContextMenuInterceptorAction eAction = 2155*cdf0e10cSrcweir ((ui::XContextMenuInterceptor*)aIt.next())->notifyContextMenuExecute( aEvent ); 2156*cdf0e10cSrcweir switch ( eAction ) 2157*cdf0e10cSrcweir { 2158*cdf0e10cSrcweir case ui::ContextMenuInterceptorAction_CANCELLED : 2159*cdf0e10cSrcweir // interceptor does not want execution 2160*cdf0e10cSrcweir return sal_False; 2161*cdf0e10cSrcweir case ui::ContextMenuInterceptorAction_EXECUTE_MODIFIED : 2162*cdf0e10cSrcweir // interceptor wants his modified menu to be executed 2163*cdf0e10cSrcweir bModified = sal_True; 2164*cdf0e10cSrcweir break; 2165*cdf0e10cSrcweir case ui::ContextMenuInterceptorAction_CONTINUE_MODIFIED : 2166*cdf0e10cSrcweir // interceptor has modified menu, but allows for calling other interceptors 2167*cdf0e10cSrcweir bModified = sal_True; 2168*cdf0e10cSrcweir continue; 2169*cdf0e10cSrcweir case ui::ContextMenuInterceptorAction_IGNORED : 2170*cdf0e10cSrcweir // interceptor is indifferent 2171*cdf0e10cSrcweir continue; 2172*cdf0e10cSrcweir default: 2173*cdf0e10cSrcweir DBG_ERROR("Wrong return value of ContextMenuInterceptor!"); 2174*cdf0e10cSrcweir continue; 2175*cdf0e10cSrcweir } 2176*cdf0e10cSrcweir } 2177*cdf0e10cSrcweir catch( uno::RuntimeException& ) 2178*cdf0e10cSrcweir { 2179*cdf0e10cSrcweir aIt.remove(); 2180*cdf0e10cSrcweir } 2181*cdf0e10cSrcweir 2182*cdf0e10cSrcweir break; 2183*cdf0e10cSrcweir } 2184*cdf0e10cSrcweir 2185*cdf0e10cSrcweir if ( bModified ) 2186*cdf0e10cSrcweir { 2187*cdf0e10cSrcweir // container was modified, create a new window out of it 2188*cdf0e10cSrcweir rpOut = new PopupMenu; 2189*cdf0e10cSrcweir ::framework::ActionTriggerHelper::CreateMenuFromActionTriggerContainer( rpOut, aEvent.ActionTriggerContainer ); 2190*cdf0e10cSrcweir 2191*cdf0e10cSrcweir Change( rpOut, this ); 2192*cdf0e10cSrcweir } 2193*cdf0e10cSrcweir 2194*cdf0e10cSrcweir return sal_True; 2195*cdf0e10cSrcweir } 2196*cdf0e10cSrcweir 2197*cdf0e10cSrcweir void SfxViewShell::TakeOwnerShip_Impl() 2198*cdf0e10cSrcweir { 2199*cdf0e10cSrcweir // currently there is only one reason to take OwnerShip: a hidden frame is printed 2200*cdf0e10cSrcweir // so the ViewShell will check this on EndPrint (->prnmon.cxx) 2201*cdf0e10cSrcweir pImp->m_bGotOwnership = true; 2202*cdf0e10cSrcweir } 2203*cdf0e10cSrcweir 2204*cdf0e10cSrcweir void SfxViewShell::TakeFrameOwnerShip_Impl() 2205*cdf0e10cSrcweir { 2206*cdf0e10cSrcweir // currently there is only one reason to take OwnerShip: a hidden frame is printed 2207*cdf0e10cSrcweir // so the ViewShell will check this on EndPrint (->prnmon.cxx) 2208*cdf0e10cSrcweir pImp->m_bGotFrameOwnership = true; 2209*cdf0e10cSrcweir } 2210*cdf0e10cSrcweir 2211*cdf0e10cSrcweir void SfxViewShell::CheckOwnerShip_Impl() 2212*cdf0e10cSrcweir { 2213*cdf0e10cSrcweir sal_Bool bSuccess = sal_False; 2214*cdf0e10cSrcweir if (pImp->m_bGotOwnership) 2215*cdf0e10cSrcweir { 2216*cdf0e10cSrcweir uno::Reference < util::XCloseable > xModel( 2217*cdf0e10cSrcweir GetObjectShell()->GetModel(), uno::UNO_QUERY ); 2218*cdf0e10cSrcweir if ( xModel.is() ) 2219*cdf0e10cSrcweir { 2220*cdf0e10cSrcweir try 2221*cdf0e10cSrcweir { 2222*cdf0e10cSrcweir // this call will destroy this object in case of success! 2223*cdf0e10cSrcweir xModel->close( sal_True ); 2224*cdf0e10cSrcweir bSuccess = sal_True; 2225*cdf0e10cSrcweir } 2226*cdf0e10cSrcweir catch ( util::CloseVetoException& ) 2227*cdf0e10cSrcweir { 2228*cdf0e10cSrcweir } 2229*cdf0e10cSrcweir } 2230*cdf0e10cSrcweir } 2231*cdf0e10cSrcweir 2232*cdf0e10cSrcweir if (!bSuccess && pImp->m_bGotFrameOwnership) 2233*cdf0e10cSrcweir { 2234*cdf0e10cSrcweir // document couldn't be closed or it shouldn't, now try at least to close the frame 2235*cdf0e10cSrcweir uno::Reference < util::XCloseable > xFrame( 2236*cdf0e10cSrcweir GetViewFrame()->GetFrame().GetFrameInterface(), com::sun::star::uno::UNO_QUERY ); 2237*cdf0e10cSrcweir if ( xFrame.is() ) 2238*cdf0e10cSrcweir { 2239*cdf0e10cSrcweir try 2240*cdf0e10cSrcweir { 2241*cdf0e10cSrcweir xFrame->close( sal_True ); 2242*cdf0e10cSrcweir } 2243*cdf0e10cSrcweir catch ( util::CloseVetoException& ) 2244*cdf0e10cSrcweir { 2245*cdf0e10cSrcweir } 2246*cdf0e10cSrcweir } 2247*cdf0e10cSrcweir } 2248*cdf0e10cSrcweir } 2249*cdf0e10cSrcweir 2250*cdf0e10cSrcweir long SfxViewShell::HandleNotifyEvent_Impl( NotifyEvent& rEvent ) 2251*cdf0e10cSrcweir { 2252*cdf0e10cSrcweir if (pImp->m_pController.is()) 2253*cdf0e10cSrcweir return pImp->m_pController->HandleEvent_Impl( rEvent ); 2254*cdf0e10cSrcweir return 0; 2255*cdf0e10cSrcweir } 2256*cdf0e10cSrcweir 2257*cdf0e10cSrcweir sal_Bool SfxViewShell::HasKeyListeners_Impl() 2258*cdf0e10cSrcweir { 2259*cdf0e10cSrcweir return (pImp->m_pController.is()) 2260*cdf0e10cSrcweir ? pImp->m_pController->HasKeyListeners_Impl() : sal_False; 2261*cdf0e10cSrcweir } 2262*cdf0e10cSrcweir 2263*cdf0e10cSrcweir sal_Bool SfxViewShell::HasMouseClickListeners_Impl() 2264*cdf0e10cSrcweir { 2265*cdf0e10cSrcweir return (pImp->m_pController.is()) 2266*cdf0e10cSrcweir ? pImp->m_pController->HasMouseClickListeners_Impl() : sal_False; 2267*cdf0e10cSrcweir } 2268*cdf0e10cSrcweir 2269*cdf0e10cSrcweir void SfxViewShell::SetAdditionalPrintOptions( const com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue >& rOpts ) 2270*cdf0e10cSrcweir { 2271*cdf0e10cSrcweir pImp->aPrintOpts = rOpts; 2272*cdf0e10cSrcweir // GetObjectShell()->Broadcast( SfxPrintingHint( -3, NULL, NULL, rOpts ) ); 2273*cdf0e10cSrcweir } 2274*cdf0e10cSrcweir 2275*cdf0e10cSrcweir sal_Bool SfxViewShell::Escape() 2276*cdf0e10cSrcweir { 2277*cdf0e10cSrcweir return GetViewFrame()->GetBindings().Execute( SID_TERMINATE_INPLACEACTIVATION ); 2278*cdf0e10cSrcweir } 2279*cdf0e10cSrcweir 2280*cdf0e10cSrcweir Reference< view::XRenderable > SfxViewShell::GetRenderable() 2281*cdf0e10cSrcweir { 2282*cdf0e10cSrcweir Reference< view::XRenderable >xRender; 2283*cdf0e10cSrcweir SfxObjectShell* pObj = GetObjectShell(); 2284*cdf0e10cSrcweir if( pObj ) 2285*cdf0e10cSrcweir { 2286*cdf0e10cSrcweir Reference< frame::XModel > xModel( pObj->GetModel() ); 2287*cdf0e10cSrcweir if( xModel.is() ) 2288*cdf0e10cSrcweir xRender = Reference< view::XRenderable >( xModel, UNO_QUERY ); 2289*cdf0e10cSrcweir } 2290*cdf0e10cSrcweir return xRender; 2291*cdf0e10cSrcweir } 2292*cdf0e10cSrcweir 2293*cdf0e10cSrcweir uno::Reference< datatransfer::clipboard::XClipboardNotifier > SfxViewShell::GetClipboardNotifier() 2294*cdf0e10cSrcweir { 2295*cdf0e10cSrcweir uno::Reference< datatransfer::clipboard::XClipboardNotifier > xClipboardNotifier; 2296*cdf0e10cSrcweir if ( GetViewFrame() ) 2297*cdf0e10cSrcweir xClipboardNotifier = uno::Reference< datatransfer::clipboard::XClipboardNotifier >( GetViewFrame()->GetWindow().GetClipboard(), uno::UNO_QUERY ); 2298*cdf0e10cSrcweir 2299*cdf0e10cSrcweir return xClipboardNotifier; 2300*cdf0e10cSrcweir } 2301*cdf0e10cSrcweir 2302*cdf0e10cSrcweir void SfxViewShell::AddRemoveClipboardListener( const uno::Reference < datatransfer::clipboard::XClipboardListener >& rClp, sal_Bool bAdd ) 2303*cdf0e10cSrcweir { 2304*cdf0e10cSrcweir try 2305*cdf0e10cSrcweir { 2306*cdf0e10cSrcweir if ( GetViewFrame() ) 2307*cdf0e10cSrcweir { 2308*cdf0e10cSrcweir uno::Reference< datatransfer::clipboard::XClipboard > xClipboard( GetViewFrame()->GetWindow().GetClipboard() ); 2309*cdf0e10cSrcweir if( xClipboard.is() ) 2310*cdf0e10cSrcweir { 2311*cdf0e10cSrcweir uno::Reference< datatransfer::clipboard::XClipboardNotifier > xClpbrdNtfr( xClipboard, uno::UNO_QUERY ); 2312*cdf0e10cSrcweir if( xClpbrdNtfr.is() ) 2313*cdf0e10cSrcweir { 2314*cdf0e10cSrcweir if( bAdd ) 2315*cdf0e10cSrcweir xClpbrdNtfr->addClipboardListener( rClp ); 2316*cdf0e10cSrcweir else 2317*cdf0e10cSrcweir xClpbrdNtfr->removeClipboardListener( rClp ); 2318*cdf0e10cSrcweir } 2319*cdf0e10cSrcweir } 2320*cdf0e10cSrcweir } 2321*cdf0e10cSrcweir } 2322*cdf0e10cSrcweir catch( const uno::Exception& ) 2323*cdf0e10cSrcweir { 2324*cdf0e10cSrcweir } 2325*cdf0e10cSrcweir } 2326*cdf0e10cSrcweir 2327