1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_FRAMEWORK_INC_DISPATCH_DISPATCHPROVIDER_HXX
21 #define INCLUDED_FRAMEWORK_INC_DISPATCH_DISPATCHPROVIDER_HXX
23 #include <classes/protocolhandlercache.hxx>
25 #include <threadhelp/transactionbase.hxx>
26 #include <macros/xinterface.hxx>
27 #include <macros/xtypeprovider.hxx>
28 #include <macros/generic.hxx>
31 #include <com/sun/star/lang/XTypeProvider.hpp>
32 #include <com/sun/star/frame/XDispatchProvider.hpp>
33 #include <com/sun/star/util/URL.hpp>
34 #include <com/sun/star/frame/DispatchDescriptor.hpp>
35 #include <com/sun/star/frame/XFrame.hpp>
36 #include <com/sun/star/beans/PropertyValue.hpp>
37 #include <com/sun/star/uno/XComponentContext.hpp>
39 #include <cppuhelper/implbase1.hxx>
40 #include <cppuhelper/weakref.hxx>
45 @descr We know some special dispatch objects with different functionality.
46 The can be created internally by the following DispatchProvider.
47 Here we define some identifier to force creation of the right one.
57 E_STARTMODULEDISPATCHER
61 @short implement a helper for XDispatchProvider interface
62 @descr The result of a queryDispatch() call depends from the owner, which use an instance of this class.
63 (frame, desktop) All of them must provides different functionality.
64 E.g: - task can be created by the desktop only
65 - a task can have a beamer as direct child
66 - a normal frame never can create a new one by himself
68 @attention Use this class as member only! Never use it as baseclass.
69 XInterface will be ambigous and we hold a weakreference to our OWNER - not to our SUPERCLASS!
72 provides ref count and weak mechanism
74 @devstatus ready to use
77 class DispatchProvider
: private TransactionBase
,
79 public ::cppu::WeakImplHelper1
< css::frame::XDispatchProvider
>
83 /// reference to global service manager to create new services
84 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
85 /// weakreference to owner frame (Don't use a hard reference. Owner can't delete us then!)
86 css::uno::WeakReference
< css::frame::XFrame
> m_xFrame
;
87 /// different dispatcher to handle special dispatch calls, protocols or URLs (they will be created on demand.)
88 css::uno::Reference
< css::frame::XDispatch
> m_xMenuDispatcher
;
89 /// cache of some other dispatch provider which are registered inside configuration to handle special URL protocols
90 HandlerCache m_aProtocolHandlerCache
;
95 DispatchProvider( const css::uno::Reference
< css::uno::XComponentContext
>& xContext
,
96 const css::uno::Reference
< css::frame::XFrame
>& xFrame
);
98 virtual css::uno::Reference
< css::frame::XDispatch
> SAL_CALL
queryDispatch ( const css::util::URL
& aURL
,
99 const OUString
& sTargetFrameName
,
100 sal_Int32 nSearchFlags
) throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
101 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
, std::exception
) SAL_OVERRIDE
;
105 // Let him protected! So nobody can use us as base ...
106 virtual ~DispatchProvider();
109 css::uno::Reference
< css::frame::XDispatch
> implts_getOrCreateDispatchHelper ( EDispatchHelper eHelper
,
110 const css::uno::Reference
< css::frame::XFrame
>& xOwner
,
111 const OUString
& sTarget
= OUString() ,
112 sal_Int32 nSearchFlags
= 0 );
113 bool implts_isLoadableContent ( const css::util::URL
& aURL
);
114 css::uno::Reference
< css::frame::XDispatch
> implts_queryDesktopDispatch ( const css::uno::Reference
< css::frame::XFrame
> xDesktop
,
115 const css::util::URL
& aURL
,
116 const OUString
& sTargetFrameName
,
117 sal_Int32 nSearchFlags
);
118 css::uno::Reference
< css::frame::XDispatch
> implts_queryFrameDispatch ( const css::uno::Reference
< css::frame::XFrame
> xFrame
,
119 const css::util::URL
& aURL
,
120 const OUString
& sTargetFrameName
,
121 sal_Int32 nSearchFlags
);
122 css::uno::Reference
< css::frame::XDispatch
> implts_searchProtocolHandler ( const css::util::URL
& aURL
);
124 }; // class DispatchProvider
126 } // namespace framework
128 #endif // INCLUDED_FRAMEWORK_INC_DISPATCH_DISPATCHPROVIDER_HXX
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */