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>
27 #include <com/sun/star/lang/XTypeProvider.hpp>
28 #include <com/sun/star/frame/XDispatchProvider.hpp>
29 #include <com/sun/star/util/URL.hpp>
30 #include <com/sun/star/frame/DispatchDescriptor.hpp>
31 #include <com/sun/star/frame/XFrame.hpp>
32 #include <com/sun/star/beans/PropertyValue.hpp>
33 #include <com/sun/star/uno/XComponentContext.hpp>
35 #include <cppuhelper/implbase.hxx>
36 #include <cppuhelper/weakref.hxx>
41 @descr We know some special dispatch objects with different functionality.
42 The can be created internally by the following DispatchProvider.
43 Here we define some identifier to force creation of the right one.
52 E_STARTMODULEDISPATCHER
56 @short implement a helper for XDispatchProvider interface
57 @descr The result of a queryDispatch() call depends from the owner, which use an instance of this class.
58 (frame, desktop) All of them must provides different functionality.
59 E.g: - task can be created by the desktop only
60 - a task can have a beamer as direct child
61 - a normal frame never can create a new one by himself
63 @attention Use this class as member only! Never use it as baseclass.
64 XInterface will be ambiguous and we hold a weakreference to our OWNER - not to our SUPERCLASS!
67 provides ref count and weak mechanism
69 @devstatus ready to use
72 class DispatchProvider
: public ::cppu::WeakImplHelper
< css::frame::XDispatchProvider
>
76 /// reference to global service manager to create new services
77 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
78 /// weakreference to owner frame (Don't use a hard reference. Owner can't delete us then!)
79 css::uno::WeakReference
< css::frame::XFrame
> m_xFrame
;
80 /// cache of some other dispatch provider which are registered inside configuration to handle special URL protocols
81 HandlerCache m_aProtocolHandlerCache
;
86 DispatchProvider( const css::uno::Reference
< css::uno::XComponentContext
>& xContext
,
87 const css::uno::Reference
< css::frame::XFrame
>& xFrame
);
89 virtual css::uno::Reference
< css::frame::XDispatch
> SAL_CALL
queryDispatch ( const css::util::URL
& aURL
,
90 const OUString
& sTargetFrameName
,
91 sal_Int32 nSearchFlags
) override
;
92 virtual css::uno::Sequence
< css::uno::Reference
< css::frame::XDispatch
> > SAL_CALL
queryDispatches( const css::uno::Sequence
< css::frame::DispatchDescriptor
>& lDescriptions
) override
;
96 // Let him protected! So nobody can use us as base ...
97 virtual ~DispatchProvider() override
;
100 css::uno::Reference
< css::frame::XDispatch
> implts_getOrCreateDispatchHelper ( EDispatchHelper eHelper
,
101 const css::uno::Reference
< css::frame::XFrame
>& xOwner
,
102 const OUString
& sTarget
= OUString() ,
103 sal_Int32 nSearchFlags
= 0 );
104 bool implts_isLoadableContent ( const css::util::URL
& aURL
);
105 css::uno::Reference
< css::frame::XDispatch
> implts_queryDesktopDispatch ( const css::uno::Reference
< css::frame::XFrame
>& xDesktop
,
106 const css::util::URL
& aURL
,
107 const OUString
& sTargetFrameName
,
108 sal_Int32 nSearchFlags
);
109 css::uno::Reference
< css::frame::XDispatch
> implts_queryFrameDispatch ( const css::uno::Reference
< css::frame::XFrame
>& xFrame
,
110 const css::util::URL
& aURL
,
111 const OUString
& sTargetFrameName
,
112 sal_Int32 nSearchFlags
);
113 css::uno::Reference
< css::frame::XDispatch
> implts_searchProtocolHandler ( const css::util::URL
& aURL
);
115 }; // class DispatchProvider
117 } // namespace framework
119 #endif // INCLUDED_FRAMEWORK_INC_DISPATCH_DISPATCHPROVIDER_HXX
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */