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