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.hxx,v $
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 #ifndef __FRAMEWORK_DISPATCH_DISPATCHPROVIDER_HXX_
32 #define __FRAMEWORK_DISPATCH_DISPATCHPROVIDER_HXX_
34 //_________________________________________________________________________________________________________________
36 //_________________________________________________________________________________________________________________
38 #include <services/frame.hxx>
40 #include <classes/protocolhandlercache.hxx>
41 #include <threadhelp/threadhelpbase.hxx>
43 #ifndef __FRAMEWORK_THREADHELP_TRANSACTIONBASE_HXX_
44 #include <threadhelp/transactionbase.hxx>
46 #include <macros/xinterface.hxx>
47 #include <macros/xtypeprovider.hxx>
48 #include <macros/debug.hxx>
49 #include <macros/generic.hxx>
52 //_________________________________________________________________________________________________________________
54 //_________________________________________________________________________________________________________________
55 #include <com/sun/star/lang/XTypeProvider.hpp>
56 #include <com/sun/star/frame/XDispatchProvider.hpp>
57 #include <com/sun/star/util/URL.hpp>
58 #include <com/sun/star/frame/DispatchDescriptor.hpp>
59 #include <com/sun/star/beans/PropertyValue.hpp>
61 //_________________________________________________________________________________________________________________
63 //_________________________________________________________________________________________________________________
64 #include <cppuhelper/weak.hxx>
65 #include <cppuhelper/weakref.hxx>
67 //_________________________________________________________________________________________________________________
69 //_________________________________________________________________________________________________________________
73 //_________________________________________________________________________________________________________________
76 @descr We know some special dispatch objects with diffrent functionality.
77 The can be created internaly by the following DispatchProvider.
78 Here we define some identifier to force creation of the right one.
84 E_HELPAGENTDISPATCHER
,
89 E_STARTMODULEDISPATCHER
92 //_________________________________________________________________________________________________________________
95 @short implement a helper for XDispatchProvider interface
96 @descr The result of a queryDispatch() call depends from the owner, which use an instance of this class.
97 (frame, desktop) All of them must provides different functionality.
98 E.g: - task can be created by the desktop only
99 - a task can have a beamer as direct child
100 - a normal frame never can create a new one by himself
102 @attention Use this class as member only! Never use it as baseclass.
103 XInterface will be ambigous and we hold a weakreference to ouer OWNER - not to ouer SUPERCLASS!
106 supports threadsafe mechanism
108 provides ref count and weak mechanism
110 @devstatus ready to use
112 @modified 17.05.2002 07:56, as96863
114 class DispatchProvider
: // interfaces
115 public css::lang::XTypeProvider
,
116 public css::frame::XDispatchProvider
,
118 // Order is neccessary for right initialization!
119 private ThreadHelpBase
,
120 private TransactionBase
,
121 public ::cppu::OWeakObject
125 /// reference to global service manager to create new services
126 css::uno::Reference
< css::lang::XMultiServiceFactory
> m_xFactory
;
127 /// weakreference to owner frame (Don't use a hard reference. Owner can't delete us then!)
128 css::uno::WeakReference
< css::frame::XFrame
> m_xFrame
;
129 /// different dispatcher to handle special dispatch calls, protocols or URLs (they will be created on demand.)
130 css::uno::Reference
< css::frame::XDispatch
> m_xMenuDispatcher
;
131 css::uno::Reference
< css::frame::XDispatch
> m_xHelpAgentDispatcher
;
132 /* css::uno::Reference< css::frame::XDispatch > m_xBlankDispatcher ;
133 css::uno::Reference< css::frame::XDispatch > m_xSelfDispatcher ;
134 css::uno::Reference< css::frame::XDispatch > m_xDefaultDispatcher ;*/
135 /// cache of some other dispatch provider which are registered inside configuration to handle special URL protocols
136 HandlerCache m_aProtocolHandlerCache
;
140 FWK_DECLARE_XINTERFACE
141 FWK_DECLARE_XTYPEPROVIDER
143 DispatchProvider( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xFactory
,
144 const css::uno::Reference
< css::frame::XFrame
>& xFrame
);
146 virtual css::uno::Reference
< css::frame::XDispatch
> SAL_CALL
queryDispatch ( const css::util::URL
& aURL
,
147 const ::rtl::OUString
& sTargetFrameName
,
148 sal_Int32 nSearchFlags
) throw( css::uno::RuntimeException
);
149 virtual css::uno::Sequence
< css::uno::Reference
< css::frame::XDispatch
> > SAL_CALL
queryDispatches( const css::uno::Sequence
< css::frame::DispatchDescriptor
>& lDescriptions
) throw( css::uno::RuntimeException
);
153 // Let him protected! So nobody can use us as base ...
154 virtual ~DispatchProvider();
157 css::uno::Reference
< css::frame::XDispatch
> implts_getOrCreateDispatchHelper ( EDispatchHelper eHelper
,
158 const css::uno::Reference
< css::frame::XFrame
>& xOwner
,
159 const ::rtl::OUString
& sTarget
= ::rtl::OUString() ,
160 sal_Int32 nSearchFlags
= 0 );
161 sal_Bool
implts_isLoadableContent ( const css::util::URL
& aURL
);
162 css::uno::Reference
< css::frame::XDispatch
> implts_queryDesktopDispatch ( const css::uno::Reference
< css::frame::XFrame
> xDesktop
,
163 const css::util::URL
& aURL
,
164 const ::rtl::OUString
& sTargetFrameName
,
165 sal_Int32 nSearchFlags
);
166 css::uno::Reference
< css::frame::XDispatch
> implts_queryFrameDispatch ( const css::uno::Reference
< css::frame::XFrame
> xFrame
,
167 const css::util::URL
& aURL
,
168 const ::rtl::OUString
& sTargetFrameName
,
169 sal_Int32 nSearchFlags
);
170 css::uno::Reference
< css::frame::XDispatch
> implts_searchProtocolHandler ( const css::util::URL
& aURL
);
172 }; // class DispatchProvider
174 } // namespace framework
176 #endif // #ifndef __FRAMEWORK_DISPATCH_DISPATCHPROVIDER_HXX_