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 .
19 #ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_MAIN_COMMANDDISPATCHCONTAINER_HXX
20 #define INCLUDED_CHART2_SOURCE_CONTROLLER_MAIN_COMMANDDISPATCHCONTAINER_HXX
22 #include <com/sun/star/uno/XComponentContext.hpp>
23 #include <com/sun/star/frame/XDispatch.hpp>
24 #include <com/sun/star/frame/XModel.hpp>
25 #include <com/sun/star/frame/DispatchDescriptor.hpp>
27 #include <cppuhelper/weakref.hxx>
28 #include <cppuhelper/interfacecontainer.hxx>
36 class ChartController
;
37 class DrawCommandDispatch
;
38 class ShapeController
;
42 Helper class for implementing the <code>XDispatchProvider</code> interface
43 of the ChartController. This class handles all commands to queryDispatch and
44 queryDispatches in the following way:
47 <li>Check if there is a cached <code>XDispatch</code> for a given command.
49 <li>Check if the command is handled by this class, e.g. Undo. If so,
50 return a corresponding <code>XDispatch</code> implementation, and cache
51 this implementation for later use</li>
52 <li>Otherwise send the command to the chart dispatch provider, if it
53 can handle this dispatch (determined by the list of commands given in
54 <code>setChartDispatch()</code>).</li>
57 <p>The <code>XDispatch</code>Provider is designed to return different
58 <code>XDispatch</code> implementations for each command. This class here
59 decides which implementation to use for which command.</p>
61 <p>As most commands need much information of the controller and are
62 implemented there, the controller handles most of the commands itself (it
63 also implements <code>XDispatch</code>). Therefore it is set here as
66 class CommandDispatchContainer
69 // note: the chart dispatcher should be removed when all commands are
70 // handled by other dispatchers. (Chart is currently the controller
72 explicit CommandDispatchContainer(
73 const ::com::sun::star::uno::Reference
<
74 ::com::sun::star::uno::XComponentContext
> & xContext
,
75 ChartController
* pController
);
78 const ::com::sun::star::uno::Reference
<
79 ::com::sun::star::frame::XModel
> & xModel
);
81 /** Set a chart dispatcher that is used for all commands contained in
84 void setChartDispatch(
85 const ::com::sun::star::uno::Reference
<
86 ::com::sun::star::frame::XDispatch
>& rChartDispatch
,
87 const ::std::set
< OUString
> & rChartCommands
);
89 /** Returns the dispatch that is able to do the command given in rURL, if
90 implemented here. If the URL is not implemented here, it should be
91 checked whether the command is one of the commands given via
92 the setChartDispatch() method. If so, call the chart dispatch.
94 <p>If all this fails, return an empty dispatch.</p>
96 ::com::sun::star::uno::Reference
<
97 ::com::sun::star::frame::XDispatch
> getDispatchForURL(
98 const ::com::sun::star::util::URL
& rURL
);
100 ::com::sun::star::uno::Sequence
<
101 ::com::sun::star::uno::Reference
<
102 ::com::sun::star::frame::XDispatch
> > getDispatchesForURLs(
103 const ::com::sun::star::uno::Sequence
<
104 ::com::sun::star::frame::DispatchDescriptor
> & aDescriptors
);
106 void DisposeAndClear();
108 static ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatch
>
109 getContainerDispatchForURL(
110 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XController
> & xChartController
,
111 const ::com::sun::star::util::URL
& rURL
);
113 void setDrawCommandDispatch( DrawCommandDispatch
* pDispatch
);
114 DrawCommandDispatch
* getDrawCommandDispatch() { return m_pDrawCommandDispatch
; }
115 void setShapeController( ShapeController
* pController
);
116 ShapeController
* getShapeController() { return m_pShapeController
; }
120 ::std::map
< OUString
,
121 ::com::sun::star::uno::Reference
<
122 ::com::sun::star::frame::XDispatch
> >
126 ::std::vector
< ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatch
> > tDisposeVector
;
128 mutable tDispatchMap m_aCachedDispatches
;
129 mutable tDisposeVector m_aToBeDisposedDispatches
;
131 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> m_xContext
;
132 ::com::sun::star::uno::WeakReference
< ::com::sun::star::frame::XModel
> m_xModel
;
134 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatch
> m_xChartDispatcher
;
135 ::std::set
< OUString
> m_aChartCommands
;
137 ::std::set
< OUString
> m_aContainerDocumentCommands
;
139 ChartController
* m_pChartController
;
140 DrawCommandDispatch
* m_pDrawCommandDispatch
;
141 ShapeController
* m_pShapeController
;
146 // INCLUDED_CHART2_SOURCE_CONTROLLER_MAIN_COMMANDDISPATCHCONTAINER_HXX
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */