1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef __FRAMEWORK_DISPATCH_DISPATCHPROVIDER_HXX_ 25 #define __FRAMEWORK_DISPATCH_DISPATCHPROVIDER_HXX_ 26 27 //_________________________________________________________________________________________________________________ 28 // my own includes 29 //_________________________________________________________________________________________________________________ 30 31 #include <services/frame.hxx> 32 33 #include <classes/protocolhandlercache.hxx> 34 #include <threadhelp/threadhelpbase.hxx> 35 36 #ifndef __FRAMEWORK_THREADHELP_TRANSACTIONBASE_HXX_ 37 #include <threadhelp/transactionbase.hxx> 38 #endif 39 #include <macros/xinterface.hxx> 40 #include <macros/xtypeprovider.hxx> 41 #include <macros/debug.hxx> 42 #include <macros/generic.hxx> 43 #include <stdtypes.h> 44 45 //_________________________________________________________________________________________________________________ 46 // interface includes 47 //_________________________________________________________________________________________________________________ 48 #include <com/sun/star/lang/XTypeProvider.hpp> 49 #include <com/sun/star/frame/XDispatchProvider.hpp> 50 #include <com/sun/star/util/URL.hpp> 51 #include <com/sun/star/frame/DispatchDescriptor.hpp> 52 #include <com/sun/star/beans/PropertyValue.hpp> 53 54 //_________________________________________________________________________________________________________________ 55 // other includes 56 //_________________________________________________________________________________________________________________ 57 #include <cppuhelper/weak.hxx> 58 #include <cppuhelper/weakref.hxx> 59 60 //_________________________________________________________________________________________________________________ 61 // namespace 62 //_________________________________________________________________________________________________________________ 63 64 namespace framework{ 65 66 //_________________________________________________________________________________________________________________ 67 68 /** 69 @descr We know some special dispatch objects with different functionality. 70 They can be created internally by the following DispatchProvider. 71 Here we define some identifier to force creation of the right one. 72 */ 73 enum EDispatchHelper 74 { 75 E_DEFAULTDISPATCHER , 76 E_MENUDISPATCHER , 77 E_HELPAGENTDISPATCHER , 78 E_CREATEDISPATCHER , 79 E_BLANKDISPATCHER , 80 E_SELFDISPATCHER , 81 E_CLOSEDISPATCHER , 82 E_STARTMODULEDISPATCHER 83 }; 84 85 //_________________________________________________________________________________________________________________ 86 87 /** 88 @short implement a helper for XDispatchProvider interface 89 @descr The result of a queryDispatch() call depends from the owner, which use an instance of this class. 90 (frame, desktop) All of them must provides different functionality. 91 E.g: - task can be created by the desktop only 92 - a task can have a beamer as direct child 93 - a normal frame never can create a new one by himself 94 95 @attention Use this class as member only! Never use it as baseclass. 96 XInterface will be ambigous and we hold a weakreference to ouer OWNER - not to ouer SUPERCLASS! 97 98 @base ThreadHelpBase 99 supports threadsafe mechanism 100 @base OWeakObject 101 provides ref count and weak mechanism 102 103 @devstatus ready to use 104 @threadsafe yes 105 @modified 17.05.2002 07:56, as96863 106 */ 107 class DispatchProvider : // interfaces 108 public css::lang::XTypeProvider , 109 public css::frame::XDispatchProvider , 110 // baseclasses 111 // Order is necessary for right initialization! 112 private ThreadHelpBase , 113 private TransactionBase , 114 public ::cppu::OWeakObject 115 { 116 /* member */ 117 private: 118 /// reference to global service manager to create new services 119 css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory; 120 /// weakreference to owner frame (Don't use a hard reference. Owner can't delete us then!) 121 css::uno::WeakReference< css::frame::XFrame > m_xFrame; 122 /// different dispatcher to handle special dispatch calls, protocols or URLs (they will be created on demand.) 123 css::uno::Reference< css::frame::XDispatch > m_xMenuDispatcher ; 124 css::uno::Reference< css::frame::XDispatch > m_xHelpAgentDispatcher; 125 /* css::uno::Reference< css::frame::XDispatch > m_xBlankDispatcher ; 126 css::uno::Reference< css::frame::XDispatch > m_xSelfDispatcher ; 127 css::uno::Reference< css::frame::XDispatch > m_xDefaultDispatcher ;*/ 128 /// cache of some other dispatch provider which are registered inside configuration to handle special URL protocols 129 HandlerCache m_aProtocolHandlerCache; 130 131 /* interface */ 132 public: 133 FWK_DECLARE_XINTERFACE 134 FWK_DECLARE_XTYPEPROVIDER 135 136 DispatchProvider( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory , 137 const css::uno::Reference< css::frame::XFrame >& xFrame ); 138 139 virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch ( const css::util::URL& aURL , 140 const ::rtl::OUString& sTargetFrameName , 141 sal_Int32 nSearchFlags ) throw( css::uno::RuntimeException ); 142 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 ); 143 144 /* helper */ 145 protected: 146 // Let him protected! So nobody can use us as base ... 147 virtual ~DispatchProvider(); 148 149 private: 150 css::uno::Reference< css::frame::XDispatch > implts_getOrCreateDispatchHelper ( EDispatchHelper eHelper , 151 const css::uno::Reference< css::frame::XFrame >& xOwner , 152 const ::rtl::OUString& sTarget = ::rtl::OUString() , 153 sal_Int32 nSearchFlags = 0 ); 154 sal_Bool implts_isLoadableContent ( const css::util::URL& aURL ); 155 css::uno::Reference< css::frame::XDispatch > implts_queryDesktopDispatch ( const css::uno::Reference< css::frame::XFrame > xDesktop , 156 const css::util::URL& aURL , 157 const ::rtl::OUString& sTargetFrameName , 158 sal_Int32 nSearchFlags ); 159 css::uno::Reference< css::frame::XDispatch > implts_queryFrameDispatch ( const css::uno::Reference< css::frame::XFrame > xFrame , 160 const css::util::URL& aURL , 161 const ::rtl::OUString& sTargetFrameName , 162 sal_Int32 nSearchFlags ); 163 css::uno::Reference< css::frame::XDispatch > implts_searchProtocolHandler ( const css::util::URL& aURL ); 164 165 }; // class DispatchProvider 166 167 } // namespace framework 168 169 #endif // #ifndef __FRAMEWORK_DISPATCH_DISPATCHPROVIDER_HXX_ 170