1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dispatchprovider.cxx,v $
10 * $Revision: 1.37.82.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_framework.hxx"
34 //_________________________________________________________________________________________________________________
36 //_________________________________________________________________________________________________________________
39 #include <dispatch/dispatchprovider.hxx>
40 #include <loadenv/loadenv.hxx>
41 #include <dispatch/loaddispatcher.hxx>
42 #include <dispatch/closedispatcher.hxx>
43 #include <dispatch/menudispatcher.hxx>
44 #include <dispatch/helpagentdispatcher.hxx>
45 #include <dispatch/startmoduledispatcher.hxx>
47 #include <pattern/window.hxx>
48 #include <threadhelp/transactionguard.hxx>
49 #include <threadhelp/readguard.hxx>
50 #include <threadhelp/writeguard.hxx>
51 #include <dispatchcommands.h>
52 #include <protocols.h>
57 //_________________________________________________________________________________________________________________
59 //_________________________________________________________________________________________________________________
60 #include <com/sun/star/frame/FrameSearchFlag.hpp>
61 #include <com/sun/star/uno/Exception.hpp>
62 #include <com/sun/star/ucb/XContentProviderManager.hpp>
63 #include <com/sun/star/document/XTypeDetection.hpp>
64 #include <com/sun/star/lang/XInitialization.hpp>
66 //_________________________________________________________________________________________________________________
67 // includes of other projects
68 //_________________________________________________________________________________________________________________
69 #include <osl/diagnose.h>
70 #include <rtl/string.h>
71 #include <rtl/ustring.hxx>
72 #include <vcl/svapp.hxx>
73 #include <rtl/ustrbuf.hxx>
74 //_________________________________________________________________________________________________________________
76 //_________________________________________________________________________________________________________________
80 //_________________________________________________________________________________________________________________
82 //_________________________________________________________________________________________________________________
84 //_________________________________________________________________________________________________________________
85 // non exported definitions
86 //_________________________________________________________________________________________________________________
88 //_________________________________________________________________________________________________________________
90 //_________________________________________________________________________________________________________________
92 //*****************************************************************************************************************
93 // XInterface, XTypeProvider
94 //*****************************************************************************************************************
95 DEFINE_XINTERFACE_2( DispatchProvider
,
97 DIRECT_INTERFACE(css::lang::XTypeProvider
),
98 DIRECT_INTERFACE(css::frame::XDispatchProvider
)
101 DEFINE_XTYPEPROVIDER_2( DispatchProvider
,
102 css::lang::XTypeProvider
,
103 css::frame::XDispatchProvider
106 //_________________________________________________________________________________________________________________
109 @short standard ctor/dtor
110 @descr These initialize a new instance of tihs class with needed informations for work.
111 We hold a weakreference to our owner frame which start dispatches at us.
112 We can't use a normal reference because he hold a reference of us too ...
113 nobody can die so ...!
115 @seealso using at owner
118 reference to servicemanager to create new services.
120 reference to our owner frame.
122 @modified 17.05.2002 10:07, as96863
124 DispatchProvider::DispatchProvider( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xFactory
,
125 const css::uno::Reference
< css::frame::XFrame
>& xFrame
)
126 // Init baseclasses first
127 : ThreadHelpBase( &Application::GetSolarMutex() )
130 , m_xFactory ( xFactory
)
131 , m_xFrame ( xFrame
)
135 //_________________________________________________________________________________________________________________
138 @short protected(!) dtor for deinitializing
139 @descr We made it protected to prevent using of us as base class instead as a member.
141 @modified 17.05.2002 10:05, as96863
143 DispatchProvider::~DispatchProvider()
147 //_________________________________________________________________________________________________________________
150 @interface XDispatchProvider
151 @short search a dispatcher for given URL
152 @descr If no interceptor is set on owner, we search for right frame and dispatch URL to it.
153 If no frame was found, we do nothing.
154 But we doesn't do it directly here. We detect the type of our owner frame and calls
155 specialized queryDispatch() helper dependen from that. Because a Desktop handle some
156 requests in another way then a normal frame.
160 @param sTargetFrameName
161 name of searched frame.
164 @return A reference to a dispatch object for this URL (if someone was found!).
167 @modified 17.05.2002 10:59, as96863
169 css::uno::Reference
< css::frame::XDispatch
> SAL_CALL
DispatchProvider::queryDispatch( const css::util::URL
& aURL
,
170 const ::rtl::OUString
& sTargetFrameName
,
171 sal_Int32 nSearchFlags
) throw( css::uno::RuntimeException
)
173 css::uno::Reference
< css::frame::XDispatch
> xDispatcher
;
176 ReadGuard
aReadLock( m_aLock
);
177 css::uno::Reference
< css::frame::XFrame
> xOwner( m_xFrame
.get(), css::uno::UNO_QUERY
);
181 css::uno::Reference
< css::frame::XDesktop
> xDesktopCheck( xOwner
, css::uno::UNO_QUERY
);
183 if (xDesktopCheck
.is())
184 xDispatcher
= implts_queryDesktopDispatch(xOwner
, aURL
, sTargetFrameName
, nSearchFlags
);
186 xDispatcher
= implts_queryFrameDispatch(xOwner
, aURL
, sTargetFrameName
, nSearchFlags
);
191 //_________________________________________________________________________________________________________________
194 @interface XDispatchProvider
195 @short do the same like queryDispatch() ... but handle multiple dispatches at the same time
196 @descr It's an optimism. User give us a list of queries ... and we return a list of dispatcher.
197 If one of given queries couldn't be solved to a real existing dispatcher ...
198 we return a list with empty references in it! Order of both lists will be retained!
200 @seealso method queryDispatch()
203 a list of all dispatch parameters for multiple requests
204 @return A reference a list of dispatch objects for these URLs - may with some <NULL/> values inside.
207 @modified 17.05.2002 09:55, as96863
209 css::uno::Sequence
< css::uno::Reference
< css::frame::XDispatch
> > SAL_CALL
DispatchProvider::queryDispatches( const css::uno::Sequence
< css::frame::DispatchDescriptor
>& lDescriptions
) throw( css::uno::RuntimeException
)
211 // Create return list - which must have same size then the given descriptor
212 // It's not allowed to pack it!
213 sal_Int32 nCount
= lDescriptions
.getLength();
214 css::uno::Sequence
< css::uno::Reference
< css::frame::XDispatch
> > lDispatcher( nCount
);
216 // Step over all descriptors and try to get any dispatcher for it.
217 for( sal_Int32 i
=0; i
<nCount
; ++i
)
219 lDispatcher
[i
] = queryDispatch( lDescriptions
[i
].FeatureURL
,
220 lDescriptions
[i
].FrameName
,
221 lDescriptions
[i
].SearchFlags
);
227 //_________________________________________________________________________________________________________________
229 ::sal_Bool
lcl_isStartModuleDispatch (const css::util::URL
& aURL
)
231 return (aURL
.Complete
.equals(CMD_UNO_SHOWSTARTMODULE
));
234 //_________________________________________________________________________________________________________________
237 @short helper for queryDispatch()
238 @descr Every member of the frame tree (frame, desktop) must handle such request
239 in another way. So we implement different specialized metods for every one.
242 @modified 20.08.2003 08:32, as96863
244 css::uno::Reference
< css::frame::XDispatch
> DispatchProvider::implts_queryDesktopDispatch( const css::uno::Reference
< css::frame::XFrame
> xDesktop
,
245 const css::util::URL
& aURL
,
246 const ::rtl::OUString
& sTargetFrameName
,
247 sal_Int32 nSearchFlags
)
249 css::uno::Reference
< css::frame::XDispatch
> xDispatcher
;
251 // ignore wrong requests which are not supported
253 (sTargetFrameName
==SPECIALTARGET_MENUBAR
) || // valid for frame dispatches - not for desktop
254 (sTargetFrameName
==SPECIALTARGET_HELPAGENT
) || // valid for frame dispatches - not for desktop
255 (sTargetFrameName
==SPECIALTARGET_PARENT
) || // we have no parent by definition
256 (sTargetFrameName
==SPECIALTARGET_BEAMER
) // beamer frames are allowed as child of tasks only -
257 // and they exist more then ones. We have no idea which our sub tasks is the right one
263 //-----------------------------------------------------------------------------------------------------
264 // I) handle special cases which not right for using findFrame() first
265 //-----------------------------------------------------------------------------------------------------
267 //-----------------------------------------------------------------------------------------------------
269 // It's not the right place to create a new task here - because we are queried for a dispatch object
270 // only, which can handle such request. Such dispatcher should create the required task on demand.
271 // Normaly the functionality for "_blank" is provided by findFrame() - but that would create it directly
272 // here. Thats why we must "intercept" here.
273 //-----------------------------------------------------------------------------------------------------
274 if (sTargetFrameName
==SPECIALTARGET_BLANK
)
276 if (implts_isLoadableContent(aURL
))
277 xDispatcher
= implts_getOrCreateDispatchHelper( E_BLANKDISPATCHER
, xDesktop
);
280 //-----------------------------------------------------------------------------------------------------
282 // This is a combination of search an empty task for recycling - or create a new one.
283 //-----------------------------------------------------------------------------------------------------
285 if (sTargetFrameName
==SPECIALTARGET_DEFAULT
)
287 if (implts_isLoadableContent(aURL
))
288 xDispatcher
= implts_getOrCreateDispatchHelper( E_DEFAULTDISPATCHER
, xDesktop
);
290 if (lcl_isStartModuleDispatch(aURL
))
291 xDispatcher
= implts_getOrCreateDispatchHelper( E_STARTMODULEDISPATCHER
, xDesktop
);
294 //-----------------------------------------------------------------------------------------------------
295 // I.III) "_self", "", "_top"
296 // The desktop can't load any document - but he can handle some special protocols like "uno", "slot" ...
297 // Why is "top" here handled too? Because the desktop is the topest frame. Normaly it's superflous
298 // to use this target - but we can handle it in the same manner then "_self".
299 //-----------------------------------------------------------------------------------------------------
302 (sTargetFrameName
==SPECIALTARGET_SELF
) ||
303 (sTargetFrameName
==SPECIALTARGET_TOP
) ||
304 (sTargetFrameName
.getLength()<1 )
307 xDispatcher
= implts_searchProtocolHandler(aURL
);
310 //-----------------------------------------------------------------------------------------------------
311 // I.IV) no further special targets exist
312 // Now we have to search for the right target frame by calling findFrame() - but should provide our code
313 // against creation of a new task if no frame could be found.
314 // I said it b efore - it's allowed for dispatch() only.
315 //-----------------------------------------------------------------------------------------------------
318 sal_Int32 nRightFlags
= nSearchFlags
;
319 nRightFlags
&= ~css::frame::FrameSearchFlag::CREATE
;
321 // try to find any existing target and ask him for his dispatcher
322 css::uno::Reference
< css::frame::XFrame
> xFoundFrame
= xDesktop
->findFrame(sTargetFrameName
, nRightFlags
);
323 if (xFoundFrame
.is())
325 css::uno::Reference
< css::frame::XDispatchProvider
> xProvider( xFoundFrame
, css::uno::UNO_QUERY
);
326 xDispatcher
= xProvider
->queryDispatch(aURL
,SPECIALTARGET_SELF
,0);
329 // if it couldn't be found - but creation was allowed
330 // use special dispatcher for creatio or froward it to the browser
331 if (nSearchFlags
& css::frame::FrameSearchFlag::CREATE
)
332 xDispatcher
= implts_getOrCreateDispatchHelper( E_CREATEDISPATCHER
, xDesktop
, sTargetFrameName
, nSearchFlags
);
338 //_________________________________________________________________________________________________________________
340 css::uno::Reference
< css::frame::XDispatch
> DispatchProvider::implts_queryFrameDispatch( const css::uno::Reference
< css::frame::XFrame
> xFrame
,
341 const css::util::URL
& aURL
,
342 const ::rtl::OUString
& sTargetFrameName
,
343 sal_Int32 nSearchFlags
)
345 css::uno::Reference
< css::frame::XDispatch
> xDispatcher
;
347 //-----------------------------------------------------------------------------------------------------
348 // 0) Some URLs are dispatched in a generic way (e.g. by the menu) using the default target "".
349 // But they are specified to use her own fix target. Detect such URLs here and use the correct target.
350 //-----------------------------------------------------------------------------------------------------
352 ::rtl::OUString sTargetName
= sTargetFrameName
;
354 //-----------------------------------------------------------------------------------------------------
355 // I) handle special cases which not right for using findFrame() first
356 //-----------------------------------------------------------------------------------------------------
358 //-----------------------------------------------------------------------------------------------------
359 // I.I) "_blank", "_default"
360 // It's not the right place to create a new task here. Only the desktop can do that.
361 // Normaly the functionality for "_blank" is provided by findFrame() - but that would create it directly
362 // here. Thats why we must "intercept" here.
363 //-----------------------------------------------------------------------------------------------------
365 (sTargetName
==SPECIALTARGET_BLANK
) ||
366 (sTargetName
==SPECIALTARGET_DEFAULT
)
369 css::uno::Reference
< css::frame::XDispatchProvider
> xParent( xFrame
->getCreator(), css::uno::UNO_QUERY
);
371 xDispatcher
= xParent
->queryDispatch(aURL
, sTargetName
, 0); // its a special target - ignore search flags
374 //-----------------------------------------------------------------------------------------------------
376 // Special mode on frame or task to receive the local menu. Not supported by findFrame()
377 //-----------------------------------------------------------------------------------------------------
379 if (sTargetName
==SPECIALTARGET_MENUBAR
)
381 xDispatcher
= implts_getOrCreateDispatchHelper( E_MENUDISPATCHER
, xFrame
);
384 //-----------------------------------------------------------------------------------------------------
385 // I.III) "_helpagent"
386 // Special mode on frame or task to start the help agent.
387 // It's defined for top level frames only.
388 //-----------------------------------------------------------------------------------------------------
390 if (sTargetName
==SPECIALTARGET_HELPAGENT
)
392 if (WindowHelper::isTopWindow(xFrame
->getContainerWindow()))
393 xDispatcher
= implts_getOrCreateDispatchHelper( E_HELPAGENTDISPATCHER
, xFrame
);
396 // Don''t use findFrame() here - because it's not possible to find
397 // a top lebel frame without knowing his name. And a frame with name
398 // "" can't be realy searched! That's why forward query to any parent
400 css::uno::Reference
< css::frame::XDispatchProvider
> xProvider( xFrame
->getCreator(), css::uno::UNO_QUERY
);
402 xDispatcher
= xProvider
->queryDispatch(aURL
,SPECIALTARGET_HELPAGENT
,0);
406 //-----------------------------------------------------------------------------------------------------
407 // I.IV) "_helpagent"
408 // Special sub frame of a top frame only. Search or create it. ... OK it's currently a little bit HACKI.
409 // Only the sfx (means the controller) can create it it.
410 //-----------------------------------------------------------------------------------------------------
412 if (sTargetName
==SPECIALTARGET_BEAMER
)
414 css::uno::Reference
< css::frame::XDispatchProvider
> xBeamer( xFrame
->findFrame( SPECIALTARGET_BEAMER
, css::frame::FrameSearchFlag::CHILDREN
| css::frame::FrameSearchFlag::SELF
), css::uno::UNO_QUERY
);
417 xDispatcher
= xBeamer
->queryDispatch(aURL
, SPECIALTARGET_SELF
, 0);
421 css::uno::Reference
< css::frame::XDispatchProvider
> xController( xFrame
->getController(), css::uno::UNO_QUERY
);
422 if (xController
.is())
423 // force using of special target - but use original search flags
424 // May the caller used the CREATE flag or not!
425 xDispatcher
= xController
->queryDispatch(aURL
, SPECIALTARGET_BEAMER
, nSearchFlags
);
429 //-----------------------------------------------------------------------------------------------------
431 // Our parent frame (if it exist) should handle this URL.
432 //-----------------------------------------------------------------------------------------------------
434 if (sTargetName
==SPECIALTARGET_PARENT
)
436 css::uno::Reference
< css::frame::XDispatchProvider
> xParent( xFrame
->getCreator(), css::uno::UNO_QUERY
);
438 // SELF => we must adress the parent directly... and not his parent or any other parent!
439 xDispatcher
= xParent
->queryDispatch(aURL
, SPECIALTARGET_SELF
, 0);
442 //-----------------------------------------------------------------------------------------------------
444 // This request must be forwarded to any parent frame, till we reach a top frame.
445 // If no parent exist, we can handle itself.
446 //-----------------------------------------------------------------------------------------------------
448 if (sTargetName
==SPECIALTARGET_TOP
)
452 // If we are this top frame itself (means our owner frame)
453 // we should call ourself recursiv with a better target "_self".
454 // So we can share the same code! (see reaction for "_self" inside this method too.)
455 xDispatcher
= this->queryDispatch(aURL
,SPECIALTARGET_SELF
,0);
459 css::uno::Reference
< css::frame::XDispatchProvider
> xParent( xFrame
->getCreator(), css::uno::UNO_QUERY
);
460 // Normaly if isTop() returned FALSE ... the parent frame MUST(!) exist ...
461 // But it seams to be better to check that here to prevent us against an access violation.
463 xDispatcher
= xParent
->queryDispatch(aURL
, SPECIALTARGET_TOP
, 0);
467 //-----------------------------------------------------------------------------------------------------
468 // I.VII) "_self", ""
469 // Our owner frame should handle this URL. But we can't do it for all of them.
470 // So we ask the internal setted controller first. If he disagree we try to find a registered
471 // protocol handler. If this failed too - we check for a loadable content and in case of true
472 // we load it into the frame by returning specilized dispatch object.
473 //-----------------------------------------------------------------------------------------------------
476 (sTargetName
==SPECIALTARGET_SELF
) ||
477 (sTargetName
.getLength()<1 )
480 // There exist a hard coded interception for special URLs.
482 (aURL
.Complete
.equalsAscii(".uno:CloseDoc" )) ||
483 (aURL
.Complete
.equalsAscii(".uno:CloseWin" ))
486 css::uno::Reference
< css::frame::XDispatchProvider
> xParent( xFrame
->getCreator(), css::uno::UNO_QUERY
);
487 // In case the frame is not a top one, is not based on system window and has a parent,
488 // the parent frame should to be queried for the correct dispatcher.
491 !WindowHelper::isTopWindow(xFrame
->getContainerWindow()) &&
492 !VCLUnoHelper::GetWindow(xFrame
->getContainerWindow())->IsSystemWindow() &&
495 xDispatcher
= xParent
->queryDispatch(aURL
, SPECIALTARGET_SELF
, 0);
497 xDispatcher
= implts_getOrCreateDispatchHelper( E_CLOSEDISPATCHER
, xFrame
);
499 else if (aURL
.Complete
.equalsAscii(".uno:CloseFrame"))
500 xDispatcher
= implts_getOrCreateDispatchHelper( E_CLOSEDISPATCHER
, xFrame
);
502 if ( ! xDispatcher
.is())
504 // Ask our controller for his agreement for these dispatched URL ...
505 // because some URLs are internal and can be handled faster by SFX - which most is the current controller!
506 // But in case of e.g. the bibliography not all queries will be handled successfully here.
507 css::uno::Reference
< css::frame::XDispatchProvider
> xController( xFrame
->getController(), css::uno::UNO_QUERY
);
508 if (xController
.is())
509 xDispatcher
= xController
->queryDispatch(aURL
, SPECIALTARGET_SELF
, 0);
512 // If controller has no fun to dispatch these URL - we must search another right dispatcher.
513 // Search for any registered protocol handler first.
514 if (!xDispatcher
.is())
515 xDispatcher
= implts_searchProtocolHandler(aURL
);
517 // Not for controller - not for protocol handler
518 // It should be a loadable content - may be a file. Check it ...
519 // This check is neccessary to found out, that
520 // support for some protocols isn't installed by user. May be
521 // "ftp" isn't available. So we suppress creation of our self dispatcher.
522 // The result will be clear. He can't handle it - but he would try it.
524 ( ! xDispatcher
.is() ) &&
525 ( implts_isLoadableContent(aURL
) )
528 xDispatcher
= implts_getOrCreateDispatchHelper( E_SELFDISPATCHER
, xFrame
);
532 //-----------------------------------------------------------------------------------------------------
533 // I.VI) no further special handlings exist
534 // Now we have to search for the right target frame by calling findFrame() - but should provide our code
535 // against creation of a new task if no frame could be found.
536 // I said it before - it's allowed for dispatch() only.
537 //-----------------------------------------------------------------------------------------------------
540 sal_Int32 nRightFlags
= nSearchFlags
;
541 nRightFlags
&= ~css::frame::FrameSearchFlag::CREATE
;
543 // try to find any existing target and ask him for his dispatcher
544 css::uno::Reference
< css::frame::XFrame
> xFoundFrame
= xFrame
->findFrame(sTargetName
, nRightFlags
);
545 if (xFoundFrame
.is())
547 // Attention: Found target is our own owner frame!
548 // Don't ask him for his dispatcher. We know it already - it's our self dispatch helper.
549 // Otherwhise we can start a never ending recursiv call. Why?
550 // Somewere called our owner frame - he called some interceptor objects - and may by this dispatch provider
551 // is called. If wa use queryDispatch() on our owner frame again - we start this call stack again ... and again.
552 if (xFoundFrame
==xFrame
)
553 xDispatcher
= implts_getOrCreateDispatchHelper( E_SELFDISPATCHER
, xFrame
);
556 css::uno::Reference
< css::frame::XDispatchProvider
> xProvider( xFoundFrame
, css::uno::UNO_QUERY
);
557 xDispatcher
= xProvider
->queryDispatch(aURL
,SPECIALTARGET_SELF
,0);
561 // if it couldn't be found - but creation was allowed
562 // forward request to the desktop.
563 // Note: The given target name must be used to set the name on new created task!
564 // Don't forward request by changing it to a special one e.g _blank.
565 // Use the CREATE flag only to prevent call against further searches.
566 // We already know it - the target must be created new.
567 if (nSearchFlags
& css::frame::FrameSearchFlag::CREATE
)
569 css::uno::Reference
< css::frame::XDispatchProvider
> xParent( xFrame
->getCreator(), css::uno::UNO_QUERY
);
571 xDispatcher
= xParent
->queryDispatch(aURL
, sTargetName
, css::frame::FrameSearchFlag::CREATE
);
578 //_________________________________________________________________________________________________________________
581 @short search for a registered protocol handler and ask him for a dispatch object
582 @descr Wes earch a suitable handler inside our cfg package org.openoffice.Office.ProtocolHandler.
583 If we found anyone, we create and initialize it. Initialize means: we set our owner frame on it
584 as context information. He can use it or leave it. Of course - we are aware of handler implementations,
585 which doesn't support initialization. It's an optional feature.
588 the dispatch URL for which may a handler is registered
590 @return A dispatch object if a handler was found and agree with the given URL or <NULL/> otherwhise.
593 @modified 05.09.2002 13:43, as96863
595 css::uno::Reference
< css::frame::XDispatch
> DispatchProvider::implts_searchProtocolHandler( const css::util::URL
& aURL
)
597 css::uno::Reference
< css::frame::XDispatch
> xDispatcher
;
598 ProtocolHandler aHandler
;
600 // This member is threadsafe by himself and lives if we live - we doesn't need any mutex here.
601 if (m_aProtocolHandlerCache
.search(aURL
,&aHandler
))
604 ReadGuard
aReadLock( m_aLock
);
607 css::uno::Reference
< css::frame::XDispatchProvider
> xHandler
;
610 xHandler
= css::uno::Reference
< css::frame::XDispatchProvider
>(
611 m_xFactory
->createInstance(aHandler
.m_sUNOName
),
612 css::uno::UNO_QUERY
);
614 catch(css::uno::Exception
&) {}
616 // look if initialization is neccessary
617 css::uno::Reference
< css::lang::XInitialization
> xInit( xHandler
, css::uno::UNO_QUERY
);
620 css::uno::Reference
< css::frame::XFrame
> xOwner( m_xFrame
.get(), css::uno::UNO_QUERY
);
621 LOG_ASSERT(xOwner
.is(), "DispatchProvider::implts_searchProtocolHandler()\nCouldn't get reference to my owner frame. So I can't set may needed context information for this protocol handler.")
626 // but do it only, if all context informations are OK
627 css::uno::Sequence
< css::uno::Any
> lContext(1);
628 lContext
[0] <<= xOwner
;
629 xInit
->initialize(lContext
);
631 catch(css::uno::Exception
&) {}
638 // ask for his (sub)dispatcher for the given URL
640 xDispatcher
= xHandler
->queryDispatch(aURL
,SPECIALTARGET_SELF
,0);
646 //_________________________________________________________________________________________________________________
649 @short get or create new dispatch helper
650 @descr Sometimes we need some helper implementations to support dispatching of special URLs or commands.
651 But it's not a good idea to hold these services for the whole life time of this provider instance.
652 We should create it on demand ...
653 Thats why we implement this method. It return an already existing helper or create a new one otherwise.
655 @attention The parameter sTarget and nSearchFlags are defaulted to "" and 0!
656 Please use it only, if you can be shure, that the realy given by the outside calli!
657 Mostly it depends from the parameter eHelper is they are required or not.
660 specify the requested dispatch helper
662 the target of possible dispatch() call on created dispatch helper
664 the target parameter of the original queryDispatch() request
666 the flags parameter of the original queryDispatch() request
667 @return A reference to a dispatch helper.
670 @modified 20.08.2003 10:22, as96863
672 css::uno::Reference
< css::frame::XDispatch
> DispatchProvider::implts_getOrCreateDispatchHelper( EDispatchHelper eHelper
,
673 const css::uno::Reference
< css::frame::XFrame
>& xOwner
,
674 const ::rtl::OUString
& sTarget
,
675 sal_Int32 nSearchFlags
)
677 css::uno::Reference
< css::frame::XDispatch
> xDispatchHelper
;
680 ReadGuard
aReadLock( m_aLock
);
681 css::uno::Reference
< css::lang::XMultiServiceFactory
> xFactory
= m_xFactory
;
687 case E_MENUDISPATCHER
:
689 // Attention: Such menue dispatcher must be a singleton for this frame - means our owner frame.
690 // Otherwhise he can make some trouble.
692 WriteGuard
aWriteLock( m_aLock
);
693 if ( ! m_xMenuDispatcher
.is() )
695 MenuDispatcher
* pDispatcher
= new MenuDispatcher( xFactory
, xOwner
);
696 m_xMenuDispatcher
= css::uno::Reference
< css::frame::XDispatch
>( static_cast< ::cppu::OWeakObject
* >(pDispatcher
), css::uno::UNO_QUERY
);
698 xDispatchHelper
= m_xMenuDispatcher
;
704 case E_HELPAGENTDISPATCHER
:
706 // Attention: It's not a good idea to create this help agent twice for the same frame (window)
707 // May it will be shown twice too - and user activate the first one. Then he get the corresponding
708 // help window ... but there exist another help agent window on bottom side of the frame window.
709 // It's superflous. Create it on demand - but hold it alive till this provider dies.
711 WriteGuard
aWriteLock( m_aLock
);
712 if ( ! m_xHelpAgentDispatcher
.is() )
714 HelpAgentDispatcher
* pDispatcher
= new HelpAgentDispatcher( xOwner
);
715 m_xHelpAgentDispatcher
= css::uno::Reference
< css::frame::XDispatch
>( static_cast< ::cppu::OWeakObject
* >(pDispatcher
), css::uno::UNO_QUERY
);
717 xDispatchHelper
= m_xHelpAgentDispatcher
;
723 case E_CREATEDISPATCHER
:
725 LoadDispatcher
* pDispatcher
= new LoadDispatcher(xFactory
, xOwner
, sTarget
, nSearchFlags
);
726 xDispatchHelper
= css::uno::Reference
< css::frame::XDispatch
>( static_cast< ::cppu::OWeakObject
* >(pDispatcher
), css::uno::UNO_QUERY
);
730 case E_BLANKDISPATCHER
:
732 css::uno::Reference
< css::frame::XFrame
> xDesktop( xOwner
, css::uno::UNO_QUERY
);
735 LoadDispatcher
* pDispatcher
= new LoadDispatcher(xFactory
, xOwner
, SPECIALTARGET_BLANK
, 0);
736 xDispatchHelper
= css::uno::Reference
< css::frame::XDispatch
>( static_cast< ::cppu::OWeakObject
* >(pDispatcher
), css::uno::UNO_QUERY
);
741 case E_DEFAULTDISPATCHER
:
743 css::uno::Reference
< css::frame::XFrame
> xDesktop( xOwner
, css::uno::UNO_QUERY
);
746 LoadDispatcher
* pDispatcher
= new LoadDispatcher(xFactory
, xOwner
, SPECIALTARGET_DEFAULT
, 0);
747 xDispatchHelper
= css::uno::Reference
< css::frame::XDispatch
>( static_cast< ::cppu::OWeakObject
* >(pDispatcher
), css::uno::UNO_QUERY
);
752 case E_SELFDISPATCHER
:
754 LoadDispatcher
* pDispatcher
= new LoadDispatcher(xFactory
, xOwner
, SPECIALTARGET_SELF
, 0);
755 xDispatchHelper
= css::uno::Reference
< css::frame::XDispatch
>( static_cast< ::cppu::OWeakObject
* >(pDispatcher
), css::uno::UNO_QUERY
);
759 case E_CLOSEDISPATCHER
:
761 CloseDispatcher
* pDispatcher
= new CloseDispatcher( xFactory
, xOwner
, sTarget
);
762 xDispatchHelper
= css::uno::Reference
< css::frame::XDispatch
>( static_cast< ::cppu::OWeakObject
* >(pDispatcher
), css::uno::UNO_QUERY
);
766 case E_STARTMODULEDISPATCHER
:
768 StartModuleDispatcher
* pDispatcher
= new StartModuleDispatcher( xFactory
, xOwner
, sTarget
);
769 xDispatchHelper
= css::uno::Reference
< css::frame::XDispatch
>( static_cast< ::cppu::OWeakObject
* >(pDispatcher
), css::uno::UNO_QUERY
);
774 return xDispatchHelper
;
777 //_________________________________________________________________________________________________________________
780 @short check URL for support by our used loader or handler
781 @descr If we must return our own dispatch helper implementations (self, blank, create dispatcher!)
782 we should be shure, that URL describe any loadable content. Otherwise slot/uno URLs
783 will be detected ... but there exist nothing for ral loading into a target frame!
786 URL which should be "detected"
787 @return <TRUE/> if somewhere could handle that - <FALSE/> otherwise.
790 @modified 17.05.2002 09:47, as96863
792 sal_Bool
DispatchProvider::implts_isLoadableContent( const css::util::URL
& aURL
)
794 LoadEnv::EContentType eType
= LoadEnv::classifyContent(aURL
.Complete
, css::uno::Sequence
< css::beans::PropertyValue
>());
795 return ( eType
== LoadEnv::E_CAN_BE_LOADED
);
798 } // namespace framework