1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef __FRAMEWORK_DISPATCH_DISPATCHPROVIDER_HXX_ 29 #define __FRAMEWORK_DISPATCH_DISPATCHPROVIDER_HXX_ 30 31 //_________________________________________________________________________________________________________________ 32 // my own includes 33 //_________________________________________________________________________________________________________________ 34 35 #include <services/frame.hxx> 36 37 #include <classes/protocolhandlercache.hxx> 38 #include <threadhelp/threadhelpbase.hxx> 39 40 #ifndef __FRAMEWORK_THREADHELP_TRANSACTIONBASE_HXX_ 41 #include <threadhelp/transactionbase.hxx> 42 #endif 43 #include <macros/xinterface.hxx> 44 #include <macros/xtypeprovider.hxx> 45 #include <macros/debug.hxx> 46 #include <macros/generic.hxx> 47 #include <stdtypes.h> 48 49 //_________________________________________________________________________________________________________________ 50 // interface includes 51 //_________________________________________________________________________________________________________________ 52 #include <com/sun/star/lang/XTypeProvider.hpp> 53 #include <com/sun/star/frame/XDispatchProvider.hpp> 54 #include <com/sun/star/util/URL.hpp> 55 #include <com/sun/star/frame/DispatchDescriptor.hpp> 56 #include <com/sun/star/beans/PropertyValue.hpp> 57 58 //_________________________________________________________________________________________________________________ 59 // other includes 60 //_________________________________________________________________________________________________________________ 61 #include <cppuhelper/weak.hxx> 62 #include <cppuhelper/weakref.hxx> 63 64 //_________________________________________________________________________________________________________________ 65 // namespace 66 //_________________________________________________________________________________________________________________ 67 68 namespace framework{ 69 70 //_________________________________________________________________________________________________________________ 71 72 /** 73 @descr We know some special dispatch objects with diffrent functionality. 74 The can be created internaly by the following DispatchProvider. 75 Here we define some identifier to force creation of the right one. 76 */ 77 enum EDispatchHelper 78 { 79 E_DEFAULTDISPATCHER , 80 E_MENUDISPATCHER , 81 E_HELPAGENTDISPATCHER , 82 E_CREATEDISPATCHER , 83 E_BLANKDISPATCHER , 84 E_SELFDISPATCHER , 85 E_CLOSEDISPATCHER , 86 E_STARTMODULEDISPATCHER 87 }; 88 89 //_________________________________________________________________________________________________________________ 90 91 /** 92 @short implement a helper for XDispatchProvider interface 93 @descr The result of a queryDispatch() call depends from the owner, which use an instance of this class. 94 (frame, desktop) All of them must provides different functionality. 95 E.g: - task can be created by the desktop only 96 - a task can have a beamer as direct child 97 - a normal frame never can create a new one by himself 98 99 @attention Use this class as member only! Never use it as baseclass. 100 XInterface will be ambigous and we hold a weakreference to ouer OWNER - not to ouer SUPERCLASS! 101 102 @base ThreadHelpBase 103 supports threadsafe mechanism 104 @base OWeakObject 105 provides ref count and weak mechanism 106 107 @devstatus ready to use 108 @threadsafe yes 109 @modified 17.05.2002 07:56, as96863 110 */ 111 class DispatchProvider : // interfaces 112 public css::lang::XTypeProvider , 113 public css::frame::XDispatchProvider , 114 // baseclasses 115 // Order is neccessary for right initialization! 116 private ThreadHelpBase , 117 private TransactionBase , 118 public ::cppu::OWeakObject 119 { 120 /* member */ 121 private: 122 /// reference to global service manager to create new services 123 css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory; 124 /// weakreference to owner frame (Don't use a hard reference. Owner can't delete us then!) 125 css::uno::WeakReference< css::frame::XFrame > m_xFrame; 126 /// different dispatcher to handle special dispatch calls, protocols or URLs (they will be created on demand.) 127 css::uno::Reference< css::frame::XDispatch > m_xMenuDispatcher ; 128 css::uno::Reference< css::frame::XDispatch > m_xHelpAgentDispatcher; 129 /* css::uno::Reference< css::frame::XDispatch > m_xBlankDispatcher ; 130 css::uno::Reference< css::frame::XDispatch > m_xSelfDispatcher ; 131 css::uno::Reference< css::frame::XDispatch > m_xDefaultDispatcher ;*/ 132 /// cache of some other dispatch provider which are registered inside configuration to handle special URL protocols 133 HandlerCache m_aProtocolHandlerCache; 134 135 /* interface */ 136 public: 137 FWK_DECLARE_XINTERFACE 138 FWK_DECLARE_XTYPEPROVIDER 139 140 DispatchProvider( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory , 141 const css::uno::Reference< css::frame::XFrame >& xFrame ); 142 143 virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch ( const css::util::URL& aURL , 144 const ::rtl::OUString& sTargetFrameName , 145 sal_Int32 nSearchFlags ) throw( css::uno::RuntimeException ); 146 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 ); 147 148 /* helper */ 149 protected: 150 // Let him protected! So nobody can use us as base ... 151 virtual ~DispatchProvider(); 152 153 private: 154 css::uno::Reference< css::frame::XDispatch > implts_getOrCreateDispatchHelper ( EDispatchHelper eHelper , 155 const css::uno::Reference< css::frame::XFrame >& xOwner , 156 const ::rtl::OUString& sTarget = ::rtl::OUString() , 157 sal_Int32 nSearchFlags = 0 ); 158 sal_Bool implts_isLoadableContent ( const css::util::URL& aURL ); 159 css::uno::Reference< css::frame::XDispatch > implts_queryDesktopDispatch ( const css::uno::Reference< css::frame::XFrame > xDesktop , 160 const css::util::URL& aURL , 161 const ::rtl::OUString& sTargetFrameName , 162 sal_Int32 nSearchFlags ); 163 css::uno::Reference< css::frame::XDispatch > implts_queryFrameDispatch ( const css::uno::Reference< css::frame::XFrame > xFrame , 164 const css::util::URL& aURL , 165 const ::rtl::OUString& sTargetFrameName , 166 sal_Int32 nSearchFlags ); 167 css::uno::Reference< css::frame::XDispatch > implts_searchProtocolHandler ( const css::util::URL& aURL ); 168 169 }; // class DispatchProvider 170 171 } // namespace framework 172 173 #endif // #ifndef __FRAMEWORK_DISPATCH_DISPATCHPROVIDER_HXX_ 174