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 .
22 #include <classes/protocolhandlercache.hxx>
24 #include <com/sun/star/frame/XDispatchProvider.hpp>
25 #include <com/sun/star/util/URL.hpp>
26 #include <com/sun/star/frame/DispatchDescriptor.hpp>
27 #include <com/sun/star/frame/XFrame.hpp>
28 #include <com/sun/star/uno/XComponentContext.hpp>
30 #include <cppuhelper/implbase.hxx>
31 #include <cppuhelper/weakref.hxx>
36 @descr We know some special dispatch objects with different functionality.
37 The can be created internally by the following DispatchProvider.
38 Here we define some identifier to force creation of the right one.
47 E_STARTMODULEDISPATCHER
51 @short implement a helper for XDispatchProvider interface
52 @descr The result of a queryDispatch() call depends from the owner, which use an instance of this class.
53 (frame, desktop) All of them must provides different functionality.
54 E.g: - task can be created by the desktop only
55 - a task can have a beamer as direct child
56 - a normal frame never can create a new one by himself
58 @attention Use this class as member only! Never use it as baseclass.
59 XInterface will be ambiguous and we hold a weakreference to our OWNER - not to our SUPERCLASS!
62 provides ref count and weak mechanism
64 @devstatus ready to use
67 class DispatchProvider final
: public ::cppu::WeakImplHelper
< css::frame::XDispatchProvider
>
71 /// reference to global service manager to create new services
72 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
73 /// weakreference to owner frame (Don't use a hard reference. Owner can't delete us then!)
74 css::uno::WeakReference
< css::frame::XFrame
> m_xFrame
;
75 /// cache of some other dispatch provider which are registered inside configuration to handle special URL protocols
76 HandlerCache m_aProtocolHandlerCache
;
77 std::unordered_map
<OUString
, css::uno::Reference
<css::frame::XDispatchProvider
>>
83 DispatchProvider( css::uno::Reference
< css::uno::XComponentContext
> xContext
,
84 const css::uno::Reference
< css::frame::XFrame
>& xFrame
);
86 virtual css::uno::Reference
< css::frame::XDispatch
> SAL_CALL
queryDispatch ( const css::util::URL
& aURL
,
87 const OUString
& sTargetFrameName
,
88 sal_Int32 nSearchFlags
) override
;
89 virtual css::uno::Sequence
< css::uno::Reference
< css::frame::XDispatch
> > SAL_CALL
queryDispatches( const css::uno::Sequence
< css::frame::DispatchDescriptor
>& lDescriptions
) override
;
91 void ClearProtocolHandlers() { m_aProtocolHandlers
.clear(); }
95 // Let him protected! So nobody can use us as base ...
96 virtual ~DispatchProvider() override
;
98 css::uno::Reference
< css::frame::XDispatch
> implts_getOrCreateDispatchHelper ( EDispatchHelper eHelper
,
99 const css::uno::Reference
< css::frame::XFrame
>& xOwner
,
100 const OUString
& sTarget
= OUString() ,
101 sal_Int32 nSearchFlags
= 0 );
102 static bool implts_isLoadableContent ( const css::util::URL
& aURL
);
103 css::uno::Reference
< css::frame::XDispatch
> implts_queryDesktopDispatch ( const css::uno::Reference
< css::frame::XFrame
>& xDesktop
,
104 const css::util::URL
& aURL
,
105 const OUString
& sTargetFrameName
,
106 sal_Int32 nSearchFlags
);
107 css::uno::Reference
< css::frame::XDispatch
> implts_queryFrameDispatch ( const css::uno::Reference
< css::frame::XFrame
>& xFrame
,
108 const css::util::URL
& aURL
,
109 const OUString
& sTargetFrameName
,
110 sal_Int32 nSearchFlags
);
111 css::uno::Reference
< css::frame::XDispatch
> implts_searchProtocolHandler ( const css::util::URL
& aURL
);
113 }; // class DispatchProvider
115 } // namespace framework
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */