merge the formfield patch from ooo-build
[ooovba.git] / sfx2 / source / view / viewsh.cxx
blob7d41d2bfa0f426be917678c8da51f224ffa8a061
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: viewsh.cxx,v $
10 * $Revision: 1.82.98.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sfx2.hxx"
33 #include <svtools/stritem.hxx>
34 #include <svtools/eitem.hxx>
35 #include <svtools/whiter.hxx>
36 #include <vcl/msgbox.hxx>
37 #include <vcl/toolbox.hxx>
38 #include <svtools/intitem.hxx>
39 #include <svtools/sfxecode.hxx>
40 #include <svtools/ehdl.hxx>
41 #include <com/sun/star/frame/XLayoutManager.hpp>
42 #include <com/sun/star/frame/XModuleManager.hpp>
43 #include <com/sun/star/beans/XPropertySet.hpp>
44 #include <com/sun/star/embed/EmbedStates.hpp>
45 #include <com/sun/star/embed/EmbedMisc.hpp>
46 #include <com/sun/star/system/XSystemShellExecute.hpp>
47 #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
48 #include <com/sun/star/container/XContainerQuery.hpp>
49 #include <com/sun/star/frame/XStorable.hpp>
50 #include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp>
51 #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
52 #include <cppuhelper/implbase1.hxx>
54 #include <osl/file.hxx>
55 #include <vos/mutex.hxx>
56 #include <tools/urlobj.hxx>
57 #include <unotools/tempfile.hxx>
58 #include <svtools/pathoptions.hxx>
59 #include <svtools/miscopt.hxx>
60 #include <svtools/soerr.hxx>
61 #include <svtools/internaloptions.hxx>
63 #include <svtools/javaoptions.hxx>
64 #include <basic/basmgr.hxx>
65 #include <basic/sbuno.hxx>
66 #include <framework/actiontriggerhelper.hxx>
67 #include <comphelper/processfactory.hxx>
68 #include <comphelper/sequenceashashmap.hxx>
69 #include <toolkit/unohlp.hxx>
72 #include <sfx2/app.hxx>
73 #include "view.hrc"
74 #include <sfx2/viewsh.hxx>
75 #include "viewimp.hxx"
76 #include "sfxresid.hxx"
77 #include <sfx2/request.hxx>
78 #include <sfx2/templdlg.hxx>
79 #include <sfx2/printer.hxx>
80 #include <sfx2/docfile.hxx>
81 #include <sfx2/dispatch.hxx>
82 #include "arrdecl.hxx"
83 #include <sfx2/docfac.hxx>
84 #include "view.hrc"
85 #include "sfxlocal.hrc"
86 #include <sfx2/sfxbasecontroller.hxx>
87 #include <sfx2/topfrm.hxx>
88 #include "mailmodelapi.hxx"
89 #include <sfx2/event.hxx>
90 #include <sfx2/fcontnr.hxx>
91 #include <sfx2/ipclient.hxx>
92 #include "workwin.hxx"
93 #include <sfx2/objface.hxx>
94 #include <sfx2/docfilt.hxx>
96 // #110897#
97 #ifndef _UNOTOOLS_PROCESSFACTORY_HXX
98 #include <comphelper/processfactory.hxx>
99 #endif
101 using namespace ::com::sun::star;
102 using namespace ::com::sun::star::uno;
103 using namespace ::com::sun::star::frame;
104 using namespace ::com::sun::star::beans;
105 using namespace ::com::sun::star::util;
106 using namespace ::com::sun::star::system;
107 using namespace ::cppu;
108 namespace css = ::com::sun::star;
110 //=========================================================================
111 DBG_NAME(SfxViewShell)
113 #define SfxViewShell
114 #include "sfxslots.hxx"
116 //=========================================================================
118 class SfxClipboardChangeListener : public ::cppu::WeakImplHelper1<
119 datatransfer::clipboard::XClipboardListener >
121 SfxViewShell* pViewShell;
123 // XEventListener
124 virtual void SAL_CALL disposing( const lang::EventObject& rEventObject )
125 throw ( uno::RuntimeException );
127 // XClipboardListener
128 virtual void SAL_CALL changedContents( const datatransfer::clipboard::ClipboardEvent& rEventObject )
129 throw ( uno::RuntimeException );
131 public:
132 SfxClipboardChangeListener( SfxViewShell* pView );
133 virtual ~SfxClipboardChangeListener();
136 SfxClipboardChangeListener::SfxClipboardChangeListener( SfxViewShell* pView )
137 : pViewShell( 0 )
139 uno::Reference < lang::XComponent > xCtrl( pView->GetController(), uno::UNO_QUERY );
140 if ( xCtrl.is() )
142 xCtrl->addEventListener( uno::Reference < lang::XEventListener > ( static_cast < lang::XEventListener* >( this ) ) );
143 pViewShell = pView;
147 SfxClipboardChangeListener::~SfxClipboardChangeListener()
151 void SAL_CALL SfxClipboardChangeListener::disposing( const lang::EventObject& /*rEventObject*/ )
152 throw ( uno::RuntimeException )
154 // either clipboard or ViewShell is going to be destroyed -> no interest in listening anymore
155 const ::vos::OGuard aGuard( Application::GetSolarMutex() );
156 if ( pViewShell )
158 uno::Reference < lang::XComponent > xCtrl( pViewShell->GetController(), uno::UNO_QUERY );
159 if ( xCtrl.is() )
160 xCtrl->removeEventListener( uno::Reference < lang::XEventListener > ( static_cast < lang::XEventListener* >( this ) ) );
161 pViewShell->AddRemoveClipboardListener( uno::Reference < datatransfer::clipboard::XClipboardListener > (this), FALSE );
162 pViewShell = 0;
166 void SAL_CALL SfxClipboardChangeListener::changedContents( const datatransfer::clipboard::ClipboardEvent& )
167 throw ( RuntimeException )
169 const ::vos::OGuard aGuard( Application::GetSolarMutex() );
170 if( pViewShell )
172 SfxBindings& rBind = pViewShell->GetViewFrame()->GetBindings();
173 rBind.Invalidate( SID_PASTE );
174 rBind.Invalidate( SID_PASTE_SPECIAL );
175 rBind.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
180 static ::rtl::OUString RetrieveLabelFromCommand(
181 const ::rtl::OUString& rCommandURL,
182 const css::uno::Reference< css::frame::XFrame >& rFrame )
184 static css::uno::WeakReference< frame::XModuleManager > s_xModuleManager;
185 static css::uno::WeakReference< container::XNameAccess > s_xNameAccess;
187 ::rtl::OUString aLabel;
188 css::uno::Reference< css::frame::XModuleManager > xModuleManager( s_xModuleManager );
189 css::uno::Reference< css::container::XNameAccess > xNameAccess( s_xNameAccess );
190 css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR(
191 ::comphelper::getProcessServiceFactory(), css::uno::UNO_QUERY_THROW);
195 if ( !xModuleManager.is() )
197 xModuleManager = css::uno::Reference< css::frame::XModuleManager >(
198 xSMGR->createInstance(
199 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ModuleManager" ))),
200 css::uno::UNO_QUERY_THROW );
201 s_xModuleManager = xModuleManager;
204 ::rtl::OUString aModuleIdentifier = xModuleManager->identify( rFrame );
206 if ( !xNameAccess.is() )
208 xNameAccess = css::uno::Reference< css::container::XNameAccess >(
209 xSMGR->createInstance(
210 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.UICommandDescription" ))),
211 css::uno::UNO_QUERY_THROW );
212 s_xNameAccess = xNameAccess;
215 css::uno::Any a = xNameAccess->getByName( aModuleIdentifier );
216 css::uno::Reference< css::container::XNameAccess > xUICommands;
217 a >>= xUICommands;
219 rtl::OUString aStr;
220 css::uno::Sequence< css::beans::PropertyValue > aPropSeq;
222 a = xUICommands->getByName( rCommandURL );
223 if ( a >>= aPropSeq )
225 for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ )
227 if ( aPropSeq[i].Name.equalsAscii( "Label" ))
229 aPropSeq[i].Value >>= aStr;
230 break;
233 aLabel = aStr;
236 catch ( css::uno::Exception& )
240 return aLabel;
243 //=========================================================================
245 SFX_IMPL_INTERFACE(SfxViewShell,SfxShell,SfxResId(0))
247 SFX_CHILDWINDOW_REGISTRATION( SID_MAIL_CHILDWIN );
250 TYPEINIT2(SfxViewShell,SfxShell,SfxListener);
252 //--------------------------------------------------------------------
253 /** search for a filter name dependent on type and module
256 static ::rtl::OUString impl_retrieveFilterNameFromTypeAndModule(
257 const css::uno::Reference< css::container::XContainerQuery >& rContainerQuery,
258 const ::rtl::OUString& rType,
259 const ::rtl::OUString& rModuleIdentifier,
260 const sal_Int32 nFlags )
262 // Retrieve filter from type
263 css::uno::Sequence< css::beans::NamedValue > aQuery( 2 );
264 aQuery[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Type" ));
265 aQuery[0].Value = css::uno::makeAny( rType );
266 aQuery[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DocumentService" ));
267 aQuery[1].Value = css::uno::makeAny( rModuleIdentifier );
269 css::uno::Reference< css::container::XEnumeration > xEnumeration =
270 rContainerQuery->createSubSetEnumerationByProperties( aQuery );
272 ::rtl::OUString aFoundFilterName;
273 while ( xEnumeration->hasMoreElements() )
275 ::comphelper::SequenceAsHashMap aFilterPropsHM( xEnumeration->nextElement() );
276 ::rtl::OUString aFilterName = aFilterPropsHM.getUnpackedValueOrDefault(
277 ::rtl::OUString::createFromAscii( "Name" ),
278 ::rtl::OUString() );
280 sal_Int32 nFilterFlags = aFilterPropsHM.getUnpackedValueOrDefault(
281 ::rtl::OUString::createFromAscii( "Flags" ),
282 sal_Int32( 0 ) );
284 if ( nFilterFlags & nFlags )
286 aFoundFilterName = aFilterName;
287 break;
291 return aFoundFilterName;
294 //--------------------------------------------------------------------
295 /** search for an internal typename, which map to the current app module
296 and map also to a "family" of file formats as e.g. PDF/MS Doc/OOo Doc.
298 enum ETypeFamily
300 E_MS_DOC,
301 E_OOO_DOC
304 ::rtl::OUString impl_searchFormatTypeForApp(const css::uno::Reference< css::frame::XFrame >& xFrame ,
305 ETypeFamily eTypeFamily)
307 static ::rtl::OUString SERVICENAME_MODULEMANAGER = ::rtl::OUString::createFromAscii("com.sun.star.frame.ModuleManager");
311 css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR (::comphelper::getProcessServiceFactory() , css::uno::UNO_QUERY_THROW);
312 css::uno::Reference< css::frame::XModuleManager > xModuleManager(xSMGR->createInstance(SERVICENAME_MODULEMANAGER), css::uno::UNO_QUERY_THROW);
314 ::rtl::OUString sModule = xModuleManager->identify(xFrame);
315 ::rtl::OUString sType ;
317 switch(eTypeFamily)
319 case E_MS_DOC:
321 if (sModule.equalsAscii( "com.sun.star.text.TextDocument" ))
322 sType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "writer_MS_Word_97" ));
323 else
324 if (sModule.equalsAscii( "com.sun.star.sheet.SpreadsheetDocument" ))
325 sType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "calc_MS_Excel_97" ));
326 else
327 if (sModule.equalsAscii( "com.sun.star.drawing.DrawingDocument" ))
328 sType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "impress_MS_PowerPoint_97" ));
329 else
330 if (sModule.equalsAscii( "com.sun.star.presentation.PresentationDocument" ))
331 sType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "impress_MS_PowerPoint_97" ));
333 break;
335 case E_OOO_DOC:
337 if (sModule.equalsAscii( "com.sun.star.text.TextDocument" ))
338 sType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "writer8" ));
339 else
340 if (sModule.equalsAscii( "com.sun.star.sheet.SpreadsheetDocument" ))
341 sType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "calc8" ));
342 else
343 if (sModule.equalsAscii( "com.sun.star.drawing.DrawingDocument" ))
344 sType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "draw8" ));
345 else
346 if (sModule.equalsAscii( "com.sun.star.presentation.PresentationDocument" ))
347 sType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "impress8" ));
349 break;
352 return sType;
354 catch(const css::uno::RuntimeException& exRun)
355 { throw exRun; }
356 catch(const css::uno::Exception&)
359 return ::rtl::OUString();
362 //--------------------------------------------------------------------
364 void SfxViewShell::ExecMisc_Impl( SfxRequest &rReq )
366 const USHORT nId = rReq.GetSlot();
367 switch( nId )
369 case SID_STYLE_FAMILY :
371 SFX_REQUEST_ARG(rReq, pItem, SfxUInt16Item, nId, FALSE);
372 if (pItem)
373 pImp->nFamily = pItem->GetValue();
374 break;
377 case SID_STYLE_CATALOG:
379 SfxTemplateCatalog aCatalog(
380 SFX_APP()->GetTopWindow(), &GetViewFrame()->GetBindings());
381 aCatalog.Execute();
382 rReq.Ignore();
383 break;
385 case SID_ACTIVATE_STYLE_APPLY:
387 com::sun::star::uno::Reference< com::sun::star::frame::XFrame > xFrame(
388 GetViewFrame()->GetFrame()->GetFrameInterface(),
389 com::sun::star::uno::UNO_QUERY);
391 Reference< com::sun::star::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY );
392 Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
393 if ( xPropSet.is() )
397 Any aValue = xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" )));
398 aValue >>= xLayoutManager;
399 if ( xLayoutManager.is() )
401 rtl::OUString aTextResString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/textobjectbar" ));
402 uno::Reference< ui::XUIElement > xElement = xLayoutManager->getElement( aTextResString );
403 if(!xElement.is())
405 rtl::OUString aFrameResString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/frameobjectbar" ));
406 xElement = xLayoutManager->getElement( aFrameResString );
408 if(!xElement.is())
410 rtl::OUString aOleResString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/oleobjectbar" ));
411 xElement = xLayoutManager->getElement( aOleResString );
413 if(xElement.is())
415 uno::Reference< awt::XWindow > xWin( xElement->getRealInterface(), uno::UNO_QUERY_THROW );
416 Window* pWin = VCLUnoHelper::GetWindow( xWin );
417 ToolBox* pTextToolbox = dynamic_cast< ToolBox* >( pWin );
418 if( pTextToolbox )
420 USHORT nItemCount = pTextToolbox->GetItemCount();
421 for( USHORT nItem = 0; nItem < nItemCount; ++nItem )
423 USHORT nItemId = pTextToolbox->GetItemId( nItem );
424 const XubString& rCommand = pTextToolbox->GetItemCommand( nItemId );
425 if( rCommand.EqualsAscii( ".uno:StyleApply" ) )
427 Window* pItemWin = pTextToolbox->GetItemWindow( nItemId );
428 if( pItemWin )
429 pItemWin->GrabFocus();
430 break;
437 catch ( Exception& )
441 rReq.Done();
443 break;
444 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
446 case SID_MAIL_SENDDOCASMS:
447 case SID_MAIL_SENDDOCASOOO:
448 case SID_MAIL_SENDDOCASPDF:
449 case SID_MAIL_SENDDOC:
450 case SID_MAIL_SENDDOCASFORMAT:
452 SfxObjectShell* pDoc = GetObjectShell();
453 if ( pDoc && pDoc->QueryHiddenInformation(
454 WhenSaving, &GetViewFrame()->GetWindow() ) != RET_YES )
455 break;
457 if ( SvtInternalOptions().MailUIEnabled() )
459 GetViewFrame()->SetChildWindow( SID_MAIL_CHILDWIN, TRUE );
461 else
463 SfxMailModel aModel;
464 rtl::OUString aDocType;
466 SFX_REQUEST_ARG(rReq, pMailSubject, SfxStringItem, SID_MAIL_SUBJECT, FALSE );
467 if ( pMailSubject )
468 aModel.SetSubject( pMailSubject->GetValue() );
470 SFX_REQUEST_ARG(rReq, pMailRecipient, SfxStringItem, SID_MAIL_RECIPIENT, FALSE );
471 if ( pMailRecipient )
473 String aRecipient( pMailRecipient->GetValue() );
474 String aMailToStr( String::CreateFromAscii( "mailto:" ));
476 if ( aRecipient.Search( aMailToStr ) == 0 )
477 aRecipient = aRecipient.Erase( 0, aMailToStr.Len() );
478 aModel.AddAddress( aRecipient, SfxMailModel::ROLE_TO );
480 SFX_REQUEST_ARG(rReq, pMailDocType, SfxStringItem, SID_TYPE_NAME, FALSE );
481 if ( pMailDocType )
482 aDocType = pMailDocType->GetValue();
484 uno::Reference < frame::XFrame > xFrame( pFrame->GetFrame()->GetFrameInterface() );
485 SfxMailModel::SendMailResult eResult = SfxMailModel::SEND_MAIL_ERROR;
487 if ( nId == SID_MAIL_SENDDOC )
488 eResult = aModel.SaveAndSend( xFrame, rtl::OUString() );
489 else
490 if ( nId == SID_MAIL_SENDDOCASPDF )
491 eResult = aModel.SaveAndSend( xFrame, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "pdf_Portable_Document_Format" )));
492 else
493 if ( nId == SID_MAIL_SENDDOCASMS )
495 aDocType = impl_searchFormatTypeForApp(xFrame, E_MS_DOC);
496 if (aDocType.getLength() > 0)
497 eResult = aModel.SaveAndSend( xFrame, aDocType );
499 else
500 if ( nId == SID_MAIL_SENDDOCASOOO )
502 aDocType = impl_searchFormatTypeForApp(xFrame, E_OOO_DOC);
503 if (aDocType.getLength() > 0)
504 eResult = aModel.SaveAndSend( xFrame, aDocType );
507 if ( eResult == SfxMailModel::SEND_MAIL_ERROR )
509 InfoBox aBox( SFX_APP()->GetTopWindow(), SfxResId( MSG_ERROR_SEND_MAIL ));
510 aBox.Execute();
511 rReq.Ignore();
513 else
514 rReq.Done();
517 break;
520 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
521 case SID_WEBHTML:
523 static const char HTML_DOCUMENT_TYPE[] = "writer_web_HTML";
524 static const char HTML_GRAPHIC_TYPE[] = "graphic_HTML";
525 const sal_Int32 FILTERFLAG_EXPORT = 0x00000002;
527 css::uno::Reference< lang::XMultiServiceFactory > xSMGR(::comphelper::getProcessServiceFactory(), css::uno::UNO_QUERY_THROW);
528 css::uno::Reference < css::frame::XFrame > xFrame( pFrame->GetFrame()->GetFrameInterface() );
529 css::uno::Reference< css::frame::XModel > xModel;
531 const rtl::OUString aModuleManager( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ModuleManager" ));
532 css::uno::Reference< css::frame::XModuleManager > xModuleManager( xSMGR->createInstance( aModuleManager ), css::uno::UNO_QUERY_THROW );
533 if ( !xModuleManager.is() )
535 rReq.Done(FALSE);
536 return;
539 rtl::OUString aModule;
542 aModule = xModuleManager->identify( xFrame );
544 catch ( css::uno::RuntimeException& )
546 throw;
548 catch ( css::uno::Exception& )
552 if ( xFrame.is() )
554 css::uno::Reference< css::frame::XController > xController = xFrame->getController();
555 if ( xController.is() )
556 xModel = xController->getModel();
559 // We need at least a valid module name and model reference
560 css::uno::Reference< css::frame::XStorable > xStorable( xModel, css::uno::UNO_QUERY );
561 if ( xModel.is() && xStorable.is() )
563 rtl::OUString aFilterName;
564 rtl::OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM( HTML_DOCUMENT_TYPE ));
565 rtl::OUString aFileName;
566 rtl::OUString aExtension( RTL_CONSTASCII_USTRINGPARAM( "htm" ));
568 rtl::OUString aLocation = xStorable->getLocation();
569 INetURLObject aFileObj( aLocation );
571 bool bPrivateProtocol = ( aFileObj.GetProtocol() == INET_PROT_PRIV_SOFFICE );
572 bool bHasLocation = ( aLocation.getLength() > 0 ) && !bPrivateProtocol;
574 css::uno::Reference< css::container::XContainerQuery > xContainerQuery(
575 xSMGR->createInstance( rtl::OUString(
576 RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.FilterFactory" ))),
577 css::uno::UNO_QUERY_THROW );
579 // Retrieve filter from type
580 sal_Int32 nFilterFlags = FILTERFLAG_EXPORT;
581 aFilterName = impl_retrieveFilterNameFromTypeAndModule( xContainerQuery, aTypeName, aModule, nFilterFlags );
582 if ( aFilterName.getLength() == 0 )
584 // Draw/Impress uses a different type. 2nd chance try to use alternative type name
585 aFilterName = impl_retrieveFilterNameFromTypeAndModule(
586 xContainerQuery, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( HTML_GRAPHIC_TYPE )), aModule, nFilterFlags );
589 // No filter found => error
590 // No type and no location => error
591 if (( aFilterName.getLength() == 0 ) || ( aTypeName.getLength() == 0 ))
593 rReq.Done(FALSE);
594 return;
597 // Use provided save file name. If empty determine file name
598 if ( !bHasLocation )
600 // Create a default file name with the correct extension
601 const rtl::OUString aPreviewFileName( RTL_CONSTASCII_USTRINGPARAM( "webpreview" ));
602 aFileName = aPreviewFileName;
604 else
606 // Determine file name from model
607 INetURLObject aFObj( xStorable->getLocation() );
608 aFileName = aFObj.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::NO_DECODE );
611 OSL_ASSERT( aFilterName.getLength() > 0 );
612 OSL_ASSERT( aFileName.getLength() > 0 );
614 // Creates a temporary directory to store our predefined file into it.
615 ::utl::TempFile aTempDir( NULL, sal_True );
617 INetURLObject aFilePathObj( aTempDir.GetURL() );
618 aFilePathObj.insertName( aFileName );
619 aFilePathObj.setExtension( aExtension );
621 rtl::OUString aFileURL = aFilePathObj.GetMainURL( INetURLObject::NO_DECODE );
623 css::uno::Sequence< css::beans::PropertyValue > aArgs( 1 );
624 aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterName" ));
625 aArgs[0].Value = css::uno::makeAny( aFilterName );
627 // Store document in the html format
630 xStorable->storeToURL( aFileURL, aArgs );
632 catch ( com::sun::star::io::IOException& )
634 rReq.Done(FALSE);
635 return;
638 ::com::sun::star::uno::Reference< XSystemShellExecute > xSystemShellExecute( xSMGR->createInstance(
639 ::rtl::OUString::createFromAscii( "com.sun.star.system.SystemShellExecute" )),
640 css::uno::UNO_QUERY );
642 BOOL bRet( TRUE );
643 if ( xSystemShellExecute.is() )
647 xSystemShellExecute->execute(
648 aFileURL, ::rtl::OUString(), SystemShellExecuteFlags::DEFAULTS );
650 catch ( uno::Exception& )
652 vos::OGuard aGuard( Application::GetSolarMutex() );
653 Window *pParent = SFX_APP()->GetTopWindow();
654 ErrorBox( pParent, SfxResId( MSG_ERROR_NO_WEBBROWSER_FOUND )).Execute();
655 bRet = FALSE;
659 rReq.Done(bRet);
660 break;
662 else
664 rReq.Done(FALSE);
665 return;
669 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
670 case SID_PLUGINS_ACTIVE:
672 SFX_REQUEST_ARG(rReq, pShowItem, SfxBoolItem, nId, FALSE);
673 BOOL bActive = pShowItem ? pShowItem->GetValue() : !pImp->bPlugInsActive;
674 // ggf. recorden
675 if ( !rReq.IsAPI() )
676 rReq.AppendItem( SfxBoolItem( nId, bActive ) );
678 // Jetzt schon DONE aufrufen, da die Argumente evtl. einen Pool
679 // benutzen, der demn"achst weg ist
680 rReq.Done(TRUE);
682 // ausfuehren
683 if ( !pShowItem || bActive != pImp->bPlugInsActive )
685 SfxFrame* pTopFrame = GetFrame()->GetTopFrame();
686 if ( pTopFrame != GetFrame()->GetFrame() )
688 // FramesetDocument
689 SfxViewShell *pShell = pTopFrame->GetCurrentViewFrame()->GetViewShell();
690 if ( pShell->GetInterface()->GetSlot( nId ) )
691 pShell->ExecuteSlot( rReq );
692 break;
695 SfxFrameIterator aIter( *pTopFrame );
696 while ( pTopFrame )
698 if ( pTopFrame->GetCurrentViewFrame() )
700 SfxViewShell *pView = pTopFrame->GetCurrentViewFrame()->GetViewShell();
701 if ( pView )
703 pView->pImp->bPlugInsActive = bActive;
704 Rectangle aVisArea = GetObjectShell()->GetVisArea();
705 VisAreaChanged(aVisArea);
707 // the plugins might need change in their state
708 SfxInPlaceClientList *pClients = pView->GetIPClientList_Impl(FALSE);
709 if ( pClients )
711 for (USHORT n=0; n < pClients->Count(); n++)
713 SfxInPlaceClient* pIPClient = pClients->GetObject(n);
714 if ( pIPClient )
715 pView->CheckIPClient_Impl( pIPClient, aVisArea );
721 if ( !pTopFrame->GetParentFrame() )
722 pTopFrame = aIter.FirstFrame();
723 else
724 pTopFrame = aIter.NextFrame( *pTopFrame );
728 break;
733 //--------------------------------------------------------------------
735 void SfxViewShell::GetState_Impl( SfxItemSet &rSet )
737 DBG_CHKTHIS(SfxViewShell, 0);
739 SfxWhichIter aIter( rSet );
740 for ( USHORT nSID = aIter.FirstWhich(); nSID; nSID = aIter.NextWhich() )
742 switch ( nSID )
744 case SID_STYLE_CATALOG:
746 if ( !GetViewFrame()->KnowsChildWindow( SID_STYLE_DESIGNER ) )
747 rSet.DisableItem( nSID );
748 break;
751 // Printer-Funktionen
752 case SID_PRINTDOC:
753 case SID_PRINTDOCDIRECT:
754 case SID_SETUPPRINTER:
755 case SID_PRINTER_NAME:
757 BOOL bEnabled = pImp->bCanPrint && !pImp->nPrinterLocks;
758 bEnabled = bEnabled && !Application::GetSettings().GetMiscSettings().GetDisablePrinting();
759 if ( bEnabled )
761 SfxPrinter *pPrinter = GetPrinter(FALSE);
763 if ( SID_PRINTDOCDIRECT == nSID )
765 rtl::OUString aPrinterName;
766 if ( pPrinter != NULL )
767 aPrinterName = pPrinter->GetName();
768 else
769 aPrinterName = Printer::GetDefaultPrinterName();
770 if ( aPrinterName.getLength() > 0 )
772 uno::Reference < frame::XFrame > xFrame( pFrame->GetFrame()->GetFrameInterface() );
774 ::rtl::OUStringBuffer aBuffer( 60 );
775 aBuffer.append( RetrieveLabelFromCommand(
776 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:PrintDefault" )),
777 xFrame ));
778 aBuffer.appendAscii( " (" );
779 aBuffer.append( aPrinterName );
780 aBuffer.appendAscii( ")" );
782 rSet.Put( SfxStringItem( SID_PRINTDOCDIRECT, aBuffer.makeStringAndClear() ) );
785 bEnabled = !pPrinter || !pPrinter->IsPrinting();
787 if ( !bEnabled )
789 // will now be handled by requeing the request
790 /* rSet.DisableItem( SID_PRINTDOC );
791 rSet.DisableItem( SID_PRINTDOCDIRECT );
792 rSet.DisableItem( SID_SETUPPRINTER ); */
794 break;
797 // Mail-Funktionen
798 case SID_MAIL_SENDDOCASPDF:
799 case SID_MAIL_SENDDOC:
800 case SID_MAIL_SENDDOCASFORMAT:
802 BOOL bEnable = !GetViewFrame()->HasChildWindow( SID_MAIL_CHILDWIN );
803 if ( !bEnable )
804 rSet.DisableItem( nSID );
805 break;
808 // PlugIns running
809 case SID_PLUGINS_ACTIVE:
811 rSet.Put( SfxBoolItem( SID_PLUGINS_ACTIVE, !pImp->bPlugInsActive) );
812 break;
815 // SelectionText
816 case SID_SELECTION_TEXT:
818 rSet.Put( SfxStringItem( SID_SELECTION_TEXT, GetSelectionText() ) );
819 break;
822 // SelectionTextExt
823 case SID_SELECTION_TEXT_EXT:
825 rSet.Put( SfxStringItem( SID_SELECTION_TEXT_EXT, GetSelectionText(TRUE) ) );
826 break;
829 case SID_STYLE_FAMILY :
831 rSet.Put( SfxUInt16Item( SID_STYLE_FAMILY, pImp->nFamily ) );
832 break;
838 //--------------------------------------------------------------------
840 void SfxViewShell::SetZoomFactor( const Fraction &rZoomX,
841 const Fraction &rZoomY )
843 DBG_ASSERT( GetWindow(), "no window" );
844 MapMode aMap( GetWindow()->GetMapMode() );
845 aMap.SetScaleX( rZoomX );
846 aMap.SetScaleY( rZoomY );
847 GetWindow()->SetMapMode( aMap );
850 //--------------------------------------------------------------------
851 ErrCode SfxViewShell::DoVerb(long /*nVerb*/)
853 /* [Beschreibung]
855 Virtuelle Methode, um am selektierten Objekt ein Verb auszuf"uhren.
856 Da dieses Objekt nur den abgeleiteten Klassen bekannt ist, muss DoVerb
857 dort "uberschrieben werden.
862 return ERRCODE_SO_NOVERBS;
865 //--------------------------------------------------------------------
867 void SfxViewShell::OutplaceActivated( sal_Bool bActive, SfxInPlaceClient* /*pClient*/ )
869 if ( !bActive )
870 GetFrame()->GetFrame()->Appear();
873 //--------------------------------------------------------------------
875 void SfxViewShell::InplaceActivating( SfxInPlaceClient* /*pClient*/ )
877 // TODO/LATER: painting of the bitmap can be stopped, it is required if CLIPCHILDREN problem #i25788# is not solved,
878 // but may be the bug will not affect the real office vcl windows, then it is not required
881 //--------------------------------------------------------------------
883 void SfxViewShell::InplaceDeactivated( SfxInPlaceClient* /*pClient*/ )
885 // TODO/LATER: paint the replacement image in normal way if the painting was stopped
888 //--------------------------------------------------------------------
890 void SfxViewShell::UIActivating( SfxInPlaceClient* /*pClient*/ )
892 uno::Reference < frame::XFrame > xOwnFrame( pFrame->GetFrame()->GetFrameInterface() );
893 uno::Reference < frame::XFramesSupplier > xParentFrame( xOwnFrame->getCreator(), uno::UNO_QUERY );
894 if ( xParentFrame.is() )
895 xParentFrame->setActiveFrame( xOwnFrame );
897 pFrame->GetBindings().HidePopups(TRUE);
898 pFrame->GetDispatcher()->Update_Impl( TRUE );
901 //--------------------------------------------------------------------
903 void SfxViewShell::UIDeactivated( SfxInPlaceClient* /*pClient*/ )
905 if ( !pFrame->GetFrame()->IsClosing_Impl() ||
906 SfxViewFrame::Current() != pFrame )
907 pFrame->GetDispatcher()->Update_Impl( TRUE );
908 pFrame->GetBindings().HidePopups(FALSE);
910 // uno::Reference < frame::XFrame > xOwnFrame( pFrame->GetFrame()->GetFrameInterface() );
911 // uno::Reference < frame::XFramesSupplier > xParentFrame( xOwnFrame->getCreator(), uno::UNO_QUERY );
912 // if ( xParentFrame.is() )
913 // xParentFrame->setActiveFrame( uno::Reference < frame::XFrame >() );
916 //--------------------------------------------------------------------
918 SfxInPlaceClient* SfxViewShell::FindIPClient
920 const uno::Reference < embed::XEmbeddedObject >& xObj,
921 Window* pObjParentWin
922 ) const
924 SfxInPlaceClientList *pClients = GetIPClientList_Impl(FALSE);
925 if ( !pClients )
926 return 0;
928 if( !pObjParentWin )
929 pObjParentWin = GetWindow();
930 for (USHORT n=0; n < pClients->Count(); n++)
932 SfxInPlaceClient *pIPClient = (SfxInPlaceClient*) pClients->GetObject(n);
933 if ( pIPClient->GetObject() == xObj && pIPClient->GetEditWin() == pObjParentWin )
934 return pIPClient;
937 return 0;
940 //--------------------------------------------------------------------
942 SfxInPlaceClient* SfxViewShell::GetIPClient() const
944 return GetUIActiveClient();
947 //--------------------------------------------------------------------
949 SfxInPlaceClient* SfxViewShell::GetUIActiveIPClient_Impl() const
951 // this method is needed as long as SFX still manages the border space for ChildWindows (see SfxFrame::Resize)
952 SfxInPlaceClientList *pClients = GetIPClientList_Impl(FALSE);
953 if ( !pClients )
954 return 0;
956 for (USHORT n=0; n < pClients->Count(); n++)
958 SfxInPlaceClient* pIPClient = pClients->GetObject(n);
959 if ( pIPClient->IsUIActive() )
960 return pIPClient;
963 return NULL;
966 SfxInPlaceClient* SfxViewShell::GetUIActiveClient() const
968 SfxInPlaceClientList *pClients = GetIPClientList_Impl(FALSE);
969 if ( !pClients )
970 return 0;
972 for (USHORT n=0; n < pClients->Count(); n++)
974 SfxInPlaceClient* pIPClient = pClients->GetObject(n);
975 if ( pIPClient->IsObjectUIActive() )
976 return pIPClient;
979 return NULL;
982 //--------------------------------------------------------------------
984 void SfxViewShell::Activate( BOOL bMDI )
986 DBG_CHKTHIS(SfxViewShell, 0);
987 if ( bMDI )
989 SfxObjectShell *pSh = GetViewFrame()->GetObjectShell();
990 if ( pSh->GetModel().is() )
991 pSh->GetModel()->setCurrentController( GetViewFrame()->GetFrame()->GetController() );
993 SetCurrentDocument();
997 //--------------------------------------------------------------------
999 void SfxViewShell::Deactivate(BOOL /*bMDI*/)
1001 DBG_CHKTHIS(SfxViewShell, 0);
1004 //--------------------------------------------------------------------
1006 void SfxViewShell::AdjustPosSizePixel
1008 const Point& /*rToolOffset*/,// linke obere Ecke der Tools im Frame-Window
1009 const Size& /*rSize*/ // gesamte zur Verf"ugung stehende Gr"o\se
1013 DBG_CHKTHIS(SfxViewShell, 0);
1016 //--------------------------------------------------------------------
1018 void SfxViewShell::Move()
1020 /* [Beschreibung]
1022 Diese virtuelle Methode wird gerufen, wenn das Fenster, in dem die
1023 SfxViewShell dargestellt wird eine StarView-Move() Nachricht erh"alt.
1025 Die Basisimplementierung braucht nicht gerufen zu werden.
1028 [Anmerkung]
1030 Diese Methode kann dazu verwendet werden, eine Selektion abzubrechen,
1031 um durch das Moven des Fensters erzeugte Maus-Bewegungen anzufangen.
1033 Zur Zeit funktioniert die Benachrichtigung nicht In-Place.
1039 //--------------------------------------------------------------------
1041 void SfxViewShell::OuterResizePixel
1043 const Point& /*rToolOffset*/,// linke obere Ecke der Tools im Frame-Window
1044 const Size& /*rSize*/ // gesamte zur Verf"ugung stehende Gr"o\se
1047 /* [Beschreibung]
1049 Diese Methode muss ueberladen werden, um auf "Anderungen der Groesse
1050 der View zu reagieren. Dabei definieren wir die View als das Edit-Window
1051 zuz"uglich der um das Edit-Window angeordnenten Tools (z.B. Lineale).
1053 Das Edit-Window darf weder in Gr"o\se noch Position ver"andert werden.
1055 Die Vis-Area der SfxObjectShell, dessen Skalierung und Position
1056 d"urfen hier ver"andert werden. Der Hauptanwendungsfall ist dabei,
1057 das Ver"andern der Gr"o\se der Vis-Area.
1059 "Andert sich durch die neue Berechnung der Border, so mu\s dieser
1060 mit <SfxViewShell::SetBorderPixel(const SvBorder&)> gesetzt werden.
1061 Erst nach Aufruf von 'SetBorderPixel' ist das Positionieren von
1062 Tools erlaubt.
1065 [Beispiel]
1067 void AppViewSh::OuterViewResizePixel( const Point &rOfs, const Size &rSz )
1069 // Tool-Positionen und Gr"o\sen von au\sen berechnen, NICHT setzen!
1070 // (wegen folgender Border-Berechnung)
1071 Point aHLinPos...; Size aHLinSz...;
1074 // Border f"ur Tools passend zu rSize berechnen und setzen
1075 SvBorder aBorder...
1076 SetBorderPixel( aBorder ); // ab jetzt sind Positionierungen erlaubt
1078 // Tools anordnen
1079 pHLin->SetPosSizePixel( aHLinPos, aHLinSz );
1084 [Querverweise]
1086 <SfxViewShell::InnerResizePixel(const Point&,const Size& rSize)>
1090 DBG_CHKTHIS(SfxViewShell, 0);
1091 SetBorderPixel( SvBorder() );
1094 //--------------------------------------------------------------------
1096 void SfxViewShell::InnerResizePixel
1098 const Point& /*rToolOffset*/,// linke obere Ecke der Tools im Frame-Window
1099 const Size& /*rSize*/ // dem Edit-Win zur Verf"ugung stehende Gr"o\se
1102 /* [Beschreibung]
1104 Diese Methode muss ueberladen werden, um auf "Anderungen der Groesse
1105 des Edit-Windows zu reagieren.
1107 Das Edit-Window darf weder in Gr"o\se noch Position ver"andert werden.
1108 Weder die Vis-Area der SfxObjectShell noch dessen Skalierung oder
1109 Position d"urfen ver"andert werden.
1111 "Andert sich durch die neue Berechnung der Border, so mu\s dieser
1112 mit <SfxViewShell::SetBorderPixel(const SvBorder&)> gesetzt werden.
1113 Erst nach Aufruf von 'SetBorderPixel' ist das Positionieren von
1114 Tools erlaubt.
1117 [Beispiel]
1119 void AppViewSh::InnerViewResizePixel( const Point &rOfs, const Size &rSz )
1121 // Tool-Positionen und Gr"o\sen von innen berechnen, NICHT setzen!
1122 // (wegen folgender Border-Berechnung)
1123 Point aHLinPos...; Size aHLinSz...;
1126 // Border f"ur Tools passend zu rSz berechnen und setzen
1127 SvBorder aBorder...
1128 SetBorderPixel( aBorder ); // ab jetzt sind Positionierungen erlaubt
1130 // Tools anordnen
1131 pHLin->SetPosSizePixel( aHLinPos, aHLinSz );
1136 [Querverweise]
1138 <SfxViewShell::OuterResizePixel(const Point&,const Size& rSize)>
1142 DBG_CHKTHIS(SfxViewShell, 0);
1143 SetBorderPixel( SvBorder() );
1146 //--------------------------------------------------------------------
1148 void SfxViewShell::InvalidateBorder()
1150 DBG_CHKTHIS(SfxViewShell, 0);
1151 DBG_ASSERT( GetViewFrame(), "SfxViewShell without SfxViewFrame" );
1153 GetViewFrame()->InvalidateBorderImpl( this );
1154 if ( pImp->pController )
1155 pImp->pController->BorderWidthsChanged_Impl();
1158 //--------------------------------------------------------------------
1160 void SfxViewShell::SetBorderPixel( const SvBorder &rBorder )
1162 DBG_CHKTHIS(SfxViewShell, 0);
1163 DBG_ASSERT( GetViewFrame(), "SfxViewShell without SfxViewFrame" );
1165 //if ( rBorder != GetBorderPixel())
1167 GetViewFrame()->SetBorderPixelImpl( this, rBorder );
1169 // notify related controller that border size is changed
1170 if ( pImp->pController )
1171 pImp->pController->BorderWidthsChanged_Impl();
1175 //--------------------------------------------------------------------
1177 const SvBorder& SfxViewShell::GetBorderPixel() const
1179 DBG_CHKTHIS(SfxViewShell, 0);
1180 DBG_ASSERT( GetViewFrame(), "SfxViewShell without SfxViewFrame" );
1182 return GetViewFrame()->GetBorderPixelImpl( this );
1185 //--------------------------------------------------------------------
1187 void SfxViewShell::SetWindow
1189 Window* pViewPort // Pointer auf das Datenfenster bzw. 0 im Destruktor
1192 /* [Beschreibung]
1194 Mit dieser Methode wird der SfxViewShell das Datenfenster mitgeteilt.
1195 Dieses wird f"ur den In-Place-Container und f"ur das korrekte
1196 Wiederherstellen des Focus ben"otigt.
1198 Selbst In-Place-aktiv ist das Umsetzen des ViewPort-Windows verboten.
1202 if( pWindow == pViewPort )
1203 return;
1205 // ggf. vorhandene IP-Clients disconnecten
1206 DisconnectAllClients();
1208 //TODO: should we have a "ReconnectAllClients" method?
1209 DiscardClients_Impl();
1211 // View-Port austauschen
1212 BOOL bHadFocus = pWindow ? pWindow->HasChildPathFocus( TRUE ) : FALSE;
1213 pWindow = pViewPort;
1215 if( pWindow )
1217 // Disable automatic GUI mirroring (right-to-left) for document windows
1218 pWindow->EnableRTL( FALSE );
1221 if ( bHadFocus && pWindow )
1222 pWindow->GrabFocus();
1223 //TODO/CLEANUP
1224 //brauchen wir die Methode doch noch?!
1225 //SFX_APP()->GrabFocus( pWindow );
1228 //--------------------------------------------------------------------
1230 Size SfxViewShell::GetOptimalSizePixel() const
1232 DBG_ERROR( "Useless call!" );
1233 return Size();
1236 //------------------------------------------------------------------------
1238 SfxViewShell::SfxViewShell
1240 SfxViewFrame* pViewFrame, /* <SfxViewFrame>, in dem diese View
1241 dargestellt wird */
1242 USHORT nFlags /* siehe <SfxViewShell-Flags> */
1245 : SfxShell(this)
1246 ,pImp( new SfxViewShell_Impl )
1247 ,pIPClientList( 0 )
1248 ,pFrame(pViewFrame)
1249 ,pSubShell(0)
1250 ,pWindow(0)
1251 ,bMaximizeFirst( 0 != (nFlags & SFX_VIEW_MAXIMIZE_FIRST) )
1252 ,bOptimizeEach(0 != (nFlags & SFX_VIEW_OPTIMIZE_EACH))
1253 ,bNoNewWindow( 0 != (nFlags & SFX_VIEW_NO_NEWWINDOW) )
1255 DBG_CTOR(SfxViewShell, 0);
1257 pImp->pPrinterCommandQueue = new SfxAsyncPrintExec_Impl( this );
1258 pImp->pController = 0;
1259 pImp->bIsShowView =
1260 !(SFX_VIEW_NO_SHOW == (nFlags & SFX_VIEW_NO_SHOW));
1262 pImp->bUseObjectSize = FALSE;
1263 // SFX_CREATE_MODE_EMBEDDED==pFrame->GetObjectShell()->GetCreateMode() &&
1264 // SFX_VIEW_OBJECTSIZE_EMBEDDED == (nFlags & SFX_VIEW_OBJECTSIZE_EMBEDDED);
1265 pImp->bCanPrint = SFX_VIEW_CAN_PRINT == (nFlags & SFX_VIEW_CAN_PRINT);
1266 pImp->bFrameSetImpl = (nFlags & SFX_VIEW_IMPLEMENTED_AS_FRAMESET) != 0;
1267 pImp->bHasPrintOptions =
1268 SFX_VIEW_HAS_PRINTOPTIONS == (nFlags & SFX_VIEW_HAS_PRINTOPTIONS);
1269 pImp->bPlugInsActive = TRUE;
1270 pImp->bGotOwnerShip = FALSE;
1271 pImp->bGotFrameOwnerShip = FALSE;
1272 if ( pViewFrame->GetParentViewFrame() )
1273 pImp->bPlugInsActive = pViewFrame->GetParentViewFrame()->GetViewShell()->pImp->bPlugInsActive;
1274 pImp->eScroll = SCROLLING_DEFAULT;
1275 pImp->nPrinterLocks = 0;
1276 pImp->bControllerSet = FALSE;
1277 pImp->nFamily = 0xFFFF; // undefined, default set by TemplateDialog
1278 SetMargin( pViewFrame->GetMargin_Impl() );
1280 SetPool( &pViewFrame->GetObjectShell()->GetPool() );
1281 StartListening(*pViewFrame->GetObjectShell());
1283 // in Liste eintragen
1284 const SfxViewShell *pThis = this; // wegen der kranken Array-Syntax
1285 SfxViewShellArr_Impl &rViewArr = SFX_APP()->GetViewShells_Impl();
1286 rViewArr.Insert(pThis, rViewArr.Count() );
1289 //--------------------------------------------------------------------
1291 SfxViewShell::~SfxViewShell()
1293 DBG_DTOR(SfxViewShell, 0);
1295 // aus Liste austragen
1296 const SfxViewShell *pThis = this;
1297 SfxViewShellArr_Impl &rViewArr = SFX_APP()->GetViewShells_Impl();
1298 rViewArr.Remove( rViewArr.GetPos(pThis) );
1300 if ( pImp->pController )
1302 pImp->pController->ReleaseShell_Impl();
1303 pImp->pController->release();
1306 if (pImp->pAccExec)
1308 delete pImp->pAccExec;
1309 pImp->pAccExec = 0;
1312 delete pImp->pPrinterCommandQueue;
1313 delete pImp;
1314 delete pIPClientList;
1317 //--------------------------------------------------------------------
1319 USHORT SfxViewShell::PrepareClose
1321 BOOL bUI, // TRUE: Dialoge etc. erlaubt, FALSE: silent-mode
1322 BOOL /*bForBrowsing*/
1325 SfxPrinter *pPrinter = GetPrinter();
1326 if ( pPrinter && pPrinter->IsPrinting() )
1328 if ( bUI )
1330 InfoBox aInfoBox( &GetViewFrame()->GetWindow(), SfxResId( MSG_CANT_CLOSE ) );
1331 aInfoBox.Execute();
1334 return FALSE;
1337 if( GetViewFrame()->IsInModalMode() )
1338 return FALSE;
1340 if( bUI && GetViewFrame()->GetDispatcher()->IsLocked() )
1341 return FALSE;
1343 return TRUE;
1346 //--------------------------------------------------------------------
1348 SfxViewShell* SfxViewShell::Current()
1350 SfxViewFrame *pCurrent = SfxViewFrame::Current();
1351 return pCurrent ? pCurrent->GetViewShell() : NULL;
1354 //--------------------------------------------------------------------
1356 SdrView* SfxViewShell::GetDrawView() const
1358 /* [Beschreibung]
1360 Diese virtuelle Methode mu\s von den Subklassen "uberladen werden, wenn
1361 der Property-Editor zur Verf"ugung stehen soll.
1363 Die Default-Implementierung liefert immer 0.
1367 return 0;
1370 //--------------------------------------------------------------------
1372 String SfxViewShell::GetSelectionText
1374 BOOL /*bCompleteWords*/ /* FALSE (default)
1375 Nur der tats"achlich selektierte Text wird
1376 zur"uckgegeben.
1378 TRUE
1379 Der selektierte Text wird soweit erweitert,
1380 da\s nur ganze W"orter zur"uckgegeben werden.
1381 Als Worttrenner gelten White-Spaces und die
1382 Satzzeichen ".,;" sowie einfache und doppelte
1383 Anf"uhrungszeichen.
1387 /* [Beschreibung]
1389 Diese Methode kann von Anwendungsprogrammierer "uberladen werden,
1390 um einen Text zur"uckzuliefern, der in der aktuellen Selektion
1391 steht. Dieser wird z.B. beim Versenden (email) verwendet.
1393 Mit "CompleteWords == TRUE" ger"ufen, reicht z.B. auch der Cursor,
1394 der in einer URL steht, um die gesamte URL zu liefern.
1398 return String();
1401 //--------------------------------------------------------------------
1403 BOOL SfxViewShell::HasSelection( BOOL ) const
1405 /* [Beschreibung]
1407 Mit dieser virtuellen Methode kann z.B. ein Dialog abfragen, ob in der
1408 aktuellen View etwas selektiert ist. Wenn der Parameter <BOOL> TRUE ist,
1409 wird abgefragt, ob Text selektiert ist.
1413 return FALSE;
1416 //--------------------------------------------------------------------
1418 void SfxViewShell::SetSubShell( SfxShell *pShell )
1420 /* [Beschreibung]
1422 Mit dieser Methode kann eine Selektions- oder Cursor-Shell angemeldet
1423 werden, die automatisch unmittelbar nach der SfxViewShell auf den
1424 SfxDispatcher gepusht wird, und automatisch umittelbar vor ihr
1425 gepoppt wird.
1427 Ist die SfxViewShell-Instanz bereits gepusht, dann wird pShell
1428 sofort ebenfalls gepusht. Wird mit SetSubShell eine andere SfxShell
1429 Instanz angemeldet, als vorher angemeldet war, wird die zuvor angemeldete
1430 ggf. automatisch gepoppt. Mit pShell==0 kann daher die aktuelle
1431 Sub-Shell abgemeldet werden.
1435 // ist diese ViewShell "uberhaupt aktiv?
1436 SfxDispatcher *pDisp = pFrame->GetDispatcher();
1437 if ( pDisp->IsActive(*this) )
1439 // Dispatcher updaten
1440 if ( pSubShell )
1441 pDisp->Pop(*pSubShell);
1442 if ( pShell )
1443 pDisp->Push(*pShell);
1444 pDisp->Flush();
1447 pSubShell = pShell;
1450 void SfxViewShell::AddSubShell( SfxShell& rShell )
1452 pImp->aArr.Insert( &rShell, pImp->aArr.Count() );
1453 SfxDispatcher *pDisp = pFrame->GetDispatcher();
1454 if ( pDisp->IsActive(*this) )
1456 pDisp->Push(rShell);
1457 pDisp->Flush();
1461 void SfxViewShell::RemoveSubShell( SfxShell* pShell )
1463 SfxDispatcher *pDisp = pFrame->GetDispatcher();
1464 if ( !pShell )
1466 USHORT nCount = pImp->aArr.Count();
1467 if ( pDisp->IsActive(*this) )
1469 for ( USHORT n=nCount; n>0; n-- )
1470 pDisp->Pop( *pImp->aArr[n-1] );
1471 pDisp->Flush();
1474 pImp->aArr.Remove(0, nCount);
1476 else
1478 USHORT nPos = pImp->aArr.GetPos( pShell );
1479 if ( nPos != 0xFFFF )
1481 pImp->aArr.Remove( nPos );
1482 if ( pDisp->IsActive(*this) )
1484 pDisp->RemoveShell_Impl( *pShell );
1485 pDisp->Flush();
1491 SfxShell* SfxViewShell::GetSubShell( USHORT nNo )
1493 USHORT nCount = pImp->aArr.Count();
1494 if ( nNo<nCount )
1495 return pImp->aArr[nCount-nNo-1];
1496 return NULL;
1499 void SfxViewShell::PushSubShells_Impl( BOOL bPush )
1501 USHORT nCount = pImp->aArr.Count();
1502 SfxDispatcher *pDisp = pFrame->GetDispatcher();
1503 if ( bPush )
1505 for ( USHORT n=0; n<nCount; n++ )
1506 pDisp->Push( *pImp->aArr[n] );
1508 // HACK(evtl. PushSubShells fuer SW virtuell machen oder im SW umbauen)
1509 // Notify( *this, SfxSimpleHint( SFX_HINT_RESERVED4 ) );
1511 else if ( nCount )
1513 pDisp->Pop( *pImp->aArr[0], SFX_SHELL_POP_UNTIL );
1515 // HACK(evtl. PushSubShells fuer SW virtuell machen oder im SW umbauen)
1516 // Notify( *this, SfxSimpleHint( SFX_HINT_RESERVED3 ) );
1519 pDisp->Flush();
1522 //--------------------------------------------------------------------
1524 void SfxViewShell::WriteUserData( String&, BOOL )
1528 //--------------------------------------------------------------------
1530 void SfxViewShell::ReadUserData(const String&, BOOL )
1534 void SfxViewShell::ReadUserDataSequence ( const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >&, sal_Bool )
1537 void SfxViewShell::WriteUserDataSequence ( ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >&, sal_Bool )
1542 //--------------------------------------------------------------------
1543 // returns the first shell of spec. type viewing the specified doc.
1545 SfxViewShell* SfxViewShell::GetFirst
1547 const TypeId* pType,
1548 BOOL bOnlyVisible
1551 // search for a SfxViewShell of the specified type
1552 SfxViewShellArr_Impl &rShells = SFX_APP()->GetViewShells_Impl();
1553 SfxViewFrameArr_Impl &rFrames = SFX_APP()->GetViewFrames_Impl();
1554 for ( USHORT nPos = 0; nPos < rShells.Count(); ++nPos )
1556 SfxViewShell *pShell = rShells.GetObject(nPos);
1557 if ( pShell )
1559 // sometimes dangling SfxViewShells exist that point to a dead SfxViewFrame
1560 // these ViewShells shouldn't be accessible anymore
1561 // a destroyed ViewFrame is not in the ViewFrame array anymore, so checking this array helps
1562 for ( sal_uInt16 n=0; n<rFrames.Count(); ++n )
1564 SfxViewFrame *pFrame = rFrames.GetObject(n);
1565 if ( pFrame == pShell->GetViewFrame() )
1567 // only ViewShells with a valid ViewFrame will be returned
1568 if ( ( !bOnlyVisible || pFrame->IsVisible_Impl() ) && ( !pType || pShell->IsA(*pType) ) )
1569 return pShell;
1570 break;
1576 return 0;
1579 //--------------------------------------------------------------------
1580 // returns the next shell of spec. type viewing the specified doc.
1582 SfxViewShell* SfxViewShell::GetNext
1584 const SfxViewShell& rPrev,
1585 const TypeId* pType,
1586 BOOL bOnlyVisible
1589 SfxViewShellArr_Impl &rShells = SFX_APP()->GetViewShells_Impl();
1590 SfxViewFrameArr_Impl &rFrames = SFX_APP()->GetViewFrames_Impl();
1591 USHORT nPos;
1592 for ( nPos = 0; nPos < rShells.Count(); ++nPos )
1593 if ( rShells.GetObject(nPos) == &rPrev )
1594 break;
1596 for ( ++nPos; nPos < rShells.Count(); ++nPos )
1598 SfxViewShell *pShell = rShells.GetObject(nPos);
1599 if ( pShell )
1601 // sometimes dangling SfxViewShells exist that point to a dead SfxViewFrame
1602 // these ViewShells shouldn't be accessible anymore
1603 // a destroyed ViewFrame is not in the ViewFrame array anymore, so checking this array helps
1604 for ( sal_uInt16 n=0; n<rFrames.Count(); ++n )
1606 SfxViewFrame *pFrame = rFrames.GetObject(n);
1607 if ( pFrame == pShell->GetViewFrame() )
1609 // only ViewShells with a valid ViewFrame will be returned
1610 if ( ( !bOnlyVisible || pFrame->IsVisible_Impl() ) && ( !pType || pShell->IsA(*pType) ) )
1611 return pShell;
1612 break;
1618 return 0;
1621 //--------------------------------------------------------------------
1623 void SfxViewShell::Notify( SfxBroadcaster& rBC,
1624 const SfxHint& rHint )
1626 if ( rHint.IsA(TYPE(SfxEventHint)) )
1628 switch ( ((SfxEventHint&)rHint).GetEventId() )
1630 case SFX_EVENT_LOADFINISHED:
1632 if ( GetController().is() )
1634 // avoid access to dangling ViewShells
1635 SfxViewFrameArr_Impl &rFrames = SFX_APP()->GetViewFrames_Impl();
1636 for ( sal_uInt16 n=0; n<rFrames.Count(); ++n )
1638 SfxViewFrame *frame = rFrames.GetObject(n);
1639 if ( frame == GetViewFrame() && &rBC == GetObjectShell() )
1641 SfxItemSet* pSet = GetObjectShell()->GetMedium()->GetItemSet();
1642 SFX_ITEMSET_ARG( pSet, pItem, SfxUnoAnyItem, SID_VIEW_DATA, sal_False );
1643 if ( pItem )
1645 pImp->pController->restoreViewData( pItem->GetValue() );
1646 pSet->ClearItem( SID_VIEW_DATA );
1649 break;
1654 break;
1660 //--------------------------------------------------------------------
1662 BOOL SfxViewShell::ExecKey_Impl(const KeyEvent& aKey)
1664 if (!pImp->pAccExec)
1666 pImp->pAccExec = ::svt::AcceleratorExecute::createAcceleratorHelper();
1667 pImp->pAccExec->init(::comphelper::getProcessServiceFactory(), pFrame->GetFrame()->GetFrameInterface());
1670 return pImp->pAccExec->execute(aKey.GetKeyCode());
1673 //--------------------------------------------------------------------
1675 FASTBOOL SfxViewShell::KeyInput( const KeyEvent &rKeyEvent )
1677 /* [Beschreibung]
1679 Diese Methode f"uhrt das KeyEvent 'rKeyEvent' "uber die an dieser
1680 SfxViewShell direkt oder indirekt (z.B. via Applikation) konfigurierten
1681 Tasten (Accelerator) aus.
1684 [R"uckgabewert]
1686 FASTBOOL TRUE
1687 die Taste ist konfiguriert, der betreffende
1688 Handler wurde gerufen
1690 FALSE
1691 die Taste ist nicht konfiguriert, es konnte
1692 also kein Handler gerufen werden
1695 [Querverweise]
1696 <SfxApplication::KeyInput(const KeyEvent&)>
1699 return ExecKey_Impl(rKeyEvent);
1702 FASTBOOL SfxViewShell::GlobalKeyInput_Impl( const KeyEvent &rKeyEvent )
1704 return ExecKey_Impl(rKeyEvent);
1707 //--------------------------------------------------------------------
1709 void SfxViewShell::ShowCursor( FASTBOOL /*bOn*/ )
1711 /* [Beschreibung]
1713 Diese Methode mu\s von Subklassen "uberladen werden, damit vom SFx
1714 aus der Cursor ein- und ausgeschaltet werden kann. Dies geschieht
1715 z.B. bei laufendem <SfxProgress>.
1721 //--------------------------------------------------------------------
1723 void SfxViewShell::GotFocus() const
1725 /* [Beschreibung]
1727 Diese Methode mu\s vom Applikationsentwickler gerufen werden, wenn
1728 das Edit-Window den Focus erhalten hat. Der SFx hat so z.B. die
1729 M"oglichkeit, den Accelerator einzuschalten.
1732 [Anmerkung]
1734 <StarView> liefert leider keine M"oglichkeit, solche Events
1735 'von der Seite' einzuh"angen.
1741 //--------------------------------------------------------------------
1742 void SfxViewShell::ResetAllClients_Impl( SfxInPlaceClient *pIP )
1745 SfxInPlaceClientList *pClients = GetIPClientList_Impl(FALSE);
1746 if ( !pClients )
1747 return;
1749 for ( USHORT n=0; n < pClients->Count(); n++ )
1751 SfxInPlaceClient* pIPClient = pClients->GetObject(n);
1752 if( pIPClient != pIP )
1753 pIPClient->ResetObject();
1757 //--------------------------------------------------------------------
1759 void SfxViewShell::DisconnectAllClients()
1761 SfxInPlaceClientList *pClients = GetIPClientList_Impl(FALSE);
1762 if ( !pClients )
1763 return;
1765 for ( USHORT n=0; n<pClients->Count(); )
1766 // clients will remove themselves from the list
1767 delete pClients->GetObject(n);
1770 //--------------------------------------------------------------------
1772 BOOL SfxViewShell::UseObjectSize() const
1774 return pImp->bUseObjectSize;
1777 //--------------------------------------------------------------------
1779 void SfxViewShell::QueryObjAreaPixel( Rectangle& ) const
1783 //--------------------------------------------------------------------
1785 void SfxViewShell::AdjustVisArea(const Rectangle& rRect)
1787 DBG_ASSERT (pFrame, "Kein Frame?");
1788 if ( UseObjectSize() )
1790 Point aPos = rRect.TopLeft();
1791 Size aSize = GetObjectShell()->GetVisArea().GetSize();
1792 GetObjectShell()->SetVisArea( Rectangle(aPos, aSize) );
1794 else
1795 GetObjectShell()->SetVisArea( rRect );
1798 //--------------------------------------------------------------------
1800 void SfxViewShell::VisAreaChanged(const Rectangle& /*rVisArea*/)
1802 SfxInPlaceClientList *pClients = GetIPClientList_Impl(FALSE);
1803 if ( !pClients )
1804 return;
1806 for (USHORT n=0; n < pClients->Count(); n++)
1808 SfxInPlaceClient* pIPClient = pClients->GetObject(n);
1809 if ( pIPClient->IsObjectInPlaceActive() )
1810 // client is active, notify client that the VisArea might have changed
1811 pIPClient->VisAreaChanged();
1815 //--------------------------------------------------------------------
1816 void SfxViewShell::CheckIPClient_Impl( SfxInPlaceClient *pIPClient, const Rectangle& rVisArea )
1818 if ( GetObjectShell()->IsInClose() )
1819 return;
1821 sal_Bool bAlwaysActive =
1822 ( ( pIPClient->GetObjectMiscStatus() & embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY ) != 0 );
1823 sal_Bool bActiveWhenVisible =
1824 ( ( pIPClient->GetObjectMiscStatus() & embed::EmbedMisc::MS_EMBED_ACTIVATEWHENVISIBLE ) != 0 );
1826 // this method is called when either a client is created or the "Edit/Plugins" checkbox is checked
1827 if ( !pIPClient->IsObjectInPlaceActive() && pImp->bPlugInsActive )
1829 // object in client is currently not active
1830 // check if the object wants to be activated always or when it becomes at least partially visible
1831 // TODO/LATER: maybe we should use the scaled area instead of the ObjArea?!
1832 if ( bAlwaysActive || (bActiveWhenVisible && rVisArea.IsOver(pIPClient->GetObjArea())) )
1836 pIPClient->GetObject()->changeState( embed::EmbedStates::INPLACE_ACTIVE );
1838 catch ( uno::Exception& )
1843 else if ( !pImp->bPlugInsActive )
1845 // object in client is currently active and "Edit/Plugins" checkbox is selected
1846 // check if the object wants to be activated always or when it becomes at least partially visible
1847 // in this case selecting of the "Edit/Plugin" checkbox should let such objects deactivate
1848 if ( bAlwaysActive || bActiveWhenVisible )
1849 pIPClient->GetObject()->changeState( embed::EmbedStates::RUNNING );
1853 //--------------------------------------------------------------------
1855 BOOL SfxViewShell::PlugInsActive() const
1857 return pImp->bPlugInsActive;
1860 //--------------------------------------------------------------------
1861 void SfxViewShell::DiscardClients_Impl()
1863 /* [Beschreibung]
1865 Diese Methode dient dazu, vor dem Schlie\sen eines Dokuments das
1866 Speichern der Objekte zu verhindern, wenn der Benutzer Schlie\en ohne
1867 Speichern gew"ahlt hatte.
1871 SfxInPlaceClientList *pClients = GetIPClientList_Impl(FALSE);
1872 if ( !pClients )
1873 return;
1875 for (USHORT n=0; n < pClients->Count(); )
1876 delete pClients->GetObject(n);
1879 //--------------------------------------------------------------------
1881 SfxScrollingMode SfxViewShell::GetScrollingMode() const
1883 return pImp->eScroll;
1886 //--------------------------------------------------------------------
1888 void SfxViewShell::SetScrollingMode( SfxScrollingMode eMode )
1890 pImp->eScroll = eMode;
1893 //--------------------------------------------------------------------
1895 SfxObjectShell* SfxViewShell::GetObjectShell()
1897 return pFrame ? pFrame->GetObjectShell() : NULL;
1900 //--------------------------------------------------------------------
1902 Reference< XModel > SfxViewShell::GetCurrentDocument() const
1904 Reference< XModel > xDocument;
1906 const SfxObjectShell* pDocShell( const_cast< SfxViewShell* >( this )->GetObjectShell() );
1907 OSL_ENSURE( pDocShell, "SfxViewFrame::GetCurrentDocument: no DocShell!?" );
1908 if ( pDocShell )
1909 xDocument = pDocShell->GetModel();
1910 return xDocument;
1913 //--------------------------------------------------------------------
1915 void SfxViewShell::SetCurrentDocument() const
1917 uno::Reference< frame::XModel > xDocument( GetCurrentDocument() );
1918 if ( xDocument.is() )
1919 SfxObjectShell::SetCurrentComponent( xDocument );
1922 //--------------------------------------------------------------------
1924 const Size& SfxViewShell::GetMargin() const
1926 return pImp->aMargin;
1929 //--------------------------------------------------------------------
1931 void SfxViewShell::SetMargin( const Size& rSize )
1933 // Der default-Margin wurde "geeicht" mit www.apple.com !!
1934 Size aMargin = rSize;
1935 if ( aMargin.Width() == -1 )
1936 aMargin.Width() = DEFAULT_MARGIN_WIDTH;
1937 if ( aMargin.Height() == -1 )
1938 aMargin.Height() = DEFAULT_MARGIN_HEIGHT;
1940 if ( aMargin != pImp->aMargin )
1942 pImp->aMargin = aMargin;
1943 MarginChanged();
1947 //--------------------------------------------------------------------
1949 void SfxViewShell::MarginChanged()
1953 //--------------------------------------------------------------------
1955 BOOL SfxViewShell::IsShowView_Impl() const
1957 return pImp->bIsShowView;
1960 //--------------------------------------------------------------------
1962 SfxFrame* SfxViewShell::GetSmartSelf( SfxFrame* pSelf, SfxMedium& /*rMedium*/ )
1964 return pSelf;
1967 //--------------------------------------------------------------------
1969 BOOL SfxViewShell::IsImplementedAsFrameset_Impl( ) const
1971 return pImp->bFrameSetImpl;
1974 //------------------------------------------------------------------------
1976 void SfxViewShell::JumpToMark( const String& rMark )
1978 SfxStringItem aMarkItem( SID_JUMPTOMARK, rMark );
1979 GetViewFrame()->GetDispatcher()->Execute(
1980 SID_JUMPTOMARK,
1981 SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD,
1982 &aMarkItem, 0L );
1985 //------------------------------------------------------------------------
1987 SfxInPlaceClientList* SfxViewShell::GetIPClientList_Impl( BOOL bCreate ) const
1989 if ( !pIPClientList && bCreate )
1990 ( (SfxViewShell*) this )->pIPClientList = new SfxInPlaceClientList;
1991 return pIPClientList;
1994 void SfxViewShell::SetController( SfxBaseController* pController )
1996 pImp->pController = pController;
1997 pImp->pController->acquire();
1998 pImp->bControllerSet = TRUE;
2000 AddRemoveClipboardListener( new SfxClipboardChangeListener( this ), TRUE );
2003 Reference < XController > SfxViewShell::GetController()
2005 return pImp->pController;
2008 void SfxViewShell::AddContextMenuInterceptor_Impl( const REFERENCE< XCONTEXTMENUINTERCEPTOR >& xInterceptor )
2010 pImp->aInterceptorContainer.addInterface( xInterceptor );
2013 void SfxViewShell::RemoveContextMenuInterceptor_Impl( const REFERENCE< XCONTEXTMENUINTERCEPTOR >& xInterceptor )
2015 pImp->aInterceptorContainer.removeInterface( xInterceptor );
2018 ::cppu::OInterfaceContainerHelper& SfxViewShell::GetContextMenuInterceptors() const
2020 return pImp->aInterceptorContainer;
2023 void Change( Menu* pMenu, SfxViewShell* pView )
2025 SfxDispatcher *pDisp = pView->GetViewFrame()->GetDispatcher();
2026 USHORT nCount = pMenu->GetItemCount();
2027 for ( USHORT nPos=0; nPos<nCount; ++nPos )
2029 USHORT nId = pMenu->GetItemId(nPos);
2030 String aCmd = pMenu->GetItemCommand(nId);
2031 PopupMenu* pPopup = pMenu->GetPopupMenu(nId);
2032 if ( pPopup )
2034 Change( pPopup, pView );
2036 else if ( nId < 5000 )
2038 if ( aCmd.CompareToAscii(".uno:", 5) == 0 )
2040 for (USHORT nIdx=0;;)
2042 SfxShell *pShell=pDisp->GetShell(nIdx++);
2043 if (pShell == NULL)
2044 break;
2045 const SfxInterface *pIFace = pShell->GetInterface();
2046 const SfxSlot* pSlot = pIFace->GetSlot( aCmd );
2047 if ( pSlot )
2049 pMenu->InsertItem( pSlot->GetSlotId(), pMenu->GetItemText( nId ), pMenu->GetItemBits( nId ), nPos );
2050 pMenu->RemoveItem( nPos+1 );
2051 break;
2060 BOOL SfxViewShell::TryContextMenuInterception( Menu& rIn, const ::rtl::OUString& rMenuIdentifier, Menu*& rpOut, ::com::sun::star::ui::ContextMenuExecuteEvent aEvent )
2062 rpOut = NULL;
2063 BOOL bModified = FALSE;
2065 // create container from menu
2066 // #110897#
2067 // aEvent.ActionTriggerContainer = ::framework::ActionTriggerHelper::CreateActionTriggerContainerFromMenu( &rIn );
2068 aEvent.ActionTriggerContainer = ::framework::ActionTriggerHelper::CreateActionTriggerContainerFromMenu(
2069 ::comphelper::getProcessServiceFactory(), &rIn, &rMenuIdentifier );
2071 // get selection from controller
2072 aEvent.Selection = ::com::sun::star::uno::Reference < ::com::sun::star::view::XSelectionSupplier > ( GetController(), ::com::sun::star::uno::UNO_QUERY );
2074 // call interceptors
2075 ::cppu::OInterfaceIteratorHelper aIt( pImp->aInterceptorContainer );
2076 while( aIt.hasMoreElements() )
2080 ::com::sun::star::ui::ContextMenuInterceptorAction eAction =
2081 ((::com::sun::star::ui::XContextMenuInterceptor*)aIt.next())->notifyContextMenuExecute( aEvent );
2082 switch ( eAction )
2084 case ::com::sun::star::ui::ContextMenuInterceptorAction_CANCELLED :
2085 // interceptor does not want execution
2086 return FALSE;
2087 case ::com::sun::star::ui::ContextMenuInterceptorAction_EXECUTE_MODIFIED :
2088 // interceptor wants his modified menu to be executed
2089 bModified = TRUE;
2090 break;
2091 case ::com::sun::star::ui::ContextMenuInterceptorAction_CONTINUE_MODIFIED :
2092 // interceptor has modified menu, but allows for calling other interceptors
2093 bModified = TRUE;
2094 continue;
2095 case ::com::sun::star::ui::ContextMenuInterceptorAction_IGNORED :
2096 // interceptor is indifferent
2097 continue;
2098 default:
2099 DBG_ERROR("Wrong return value of ContextMenuInterceptor!");
2100 continue;
2103 catch( ::com::sun::star::uno::RuntimeException& )
2105 aIt.remove();
2108 break;
2111 if ( bModified )
2113 // container was modified, create a new window out of it
2114 rpOut = new PopupMenu;
2115 ::framework::ActionTriggerHelper::CreateMenuFromActionTriggerContainer( rpOut, aEvent.ActionTriggerContainer );
2117 Change( rpOut, this );
2120 return TRUE;
2123 void SfxViewShell::TakeOwnerShip_Impl()
2125 // currently there is only one reason to take OwnerShip: a hidden frame is printed
2126 // so the ViewShell will check this on EndPrint (->prnmon.cxx)
2127 pImp->bGotOwnerShip = TRUE;
2130 void SfxViewShell::TakeFrameOwnerShip_Impl()
2132 // currently there is only one reason to take OwnerShip: a hidden frame is printed
2133 // so the ViewShell will check this on EndPrint (->prnmon.cxx)
2134 pImp->bGotFrameOwnerShip = TRUE;
2137 void SfxViewShell::CheckOwnerShip_Impl()
2139 BOOL bSuccess = FALSE;
2140 if( pImp->bGotOwnerShip )
2142 com::sun::star::uno::Reference < com::sun::star::util::XCloseable > xModel(
2143 GetObjectShell()->GetModel(), com::sun::star::uno::UNO_QUERY );
2144 if ( xModel.is() )
2148 // this call will destroy this object in case of success!
2149 xModel->close( sal_True );
2150 bSuccess = TRUE;
2152 catch ( com::sun::star::util::CloseVetoException& )
2158 if( !bSuccess && pImp->bGotFrameOwnerShip )
2160 // document couldn't be closed or it shouldn't, now try at least to close the frame
2161 com::sun::star::uno::Reference < com::sun::star::util::XCloseable > xFrame(
2162 GetViewFrame()->GetFrame()->GetFrameInterface(), com::sun::star::uno::UNO_QUERY );
2163 if ( xFrame.is() )
2167 xFrame->close( sal_True );
2169 catch ( com::sun::star::util::CloseVetoException& )
2176 long SfxViewShell::HandleNotifyEvent_Impl( NotifyEvent& rEvent )
2178 if ( pImp->pController )
2179 return pImp->pController->HandleEvent_Impl( rEvent );
2180 return 0;
2183 BOOL SfxViewShell::HasKeyListeners_Impl()
2185 return pImp->pController ? pImp->pController->HasKeyListeners_Impl() : FALSE;
2188 BOOL SfxViewShell::HasMouseClickListeners_Impl()
2190 return pImp->pController ? pImp->pController->HasMouseClickListeners_Impl() : FALSE;
2193 void SfxViewShell::SetAdditionalPrintOptions( const com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue >& rOpts )
2195 pImp->aPrintOpts = rOpts;
2196 GetObjectShell()->Broadcast( SfxPrintingHint( -3, NULL, NULL, rOpts ) );
2199 BOOL SfxViewShell::Escape()
2201 return GetViewFrame()->GetBindings().Execute( SID_TERMINATE_INPLACEACTIVATION );
2204 void SfxViewShell::AddRemoveClipboardListener( const uno::Reference < datatransfer::clipboard::XClipboardListener >& rClp, BOOL bAdd )
2208 uno::Reference< datatransfer::clipboard::XClipboard > xClipboard( GetViewFrame()->GetWindow().GetClipboard() );
2209 if( !xClipboard.is() )
2210 return;
2212 uno::Reference< datatransfer::clipboard::XClipboardNotifier > xClpbrdNtfr( xClipboard, uno::UNO_QUERY );
2213 if( xClpbrdNtfr.is() )
2215 if( bAdd )
2216 xClpbrdNtfr->addClipboardListener( rClp );
2217 else
2218 xClpbrdNtfr->removeClipboardListener( rClp );
2221 catch( const uno::Exception& )