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