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