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