1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: CommandDispatchContainer.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef CHART2_COMMANDDISPATCHCONTAINER_HXX
31 #define CHART2_COMMANDDISPATCHCONTAINER_HXX
33 #include <com/sun/star/uno/XComponentContext.hpp>
34 #include <com/sun/star/chart2/XUndoManager.hpp>
35 #include <com/sun/star/frame/XDispatch.hpp>
36 #include <com/sun/star/frame/XModel.hpp>
37 #include <com/sun/star/frame/DispatchDescriptor.hpp>
39 #include <cppuhelper/interfacecontainer.hxx>
49 Helper class for implementing the <code>XDispatchProvider</code> interface
50 of the ChartController. This class handles all commands to queryDispatch and
51 queryDispatches in the following way:
54 <li>Check if there is a cached <code>XDispatch</code> for a given command.
56 <li>Check if the command is handled by this class, e.g. Undo. If so,
57 return a corresponding <code>XDispatch</code> implementation, and cache
58 this implementation for later use</li>
59 <li>Otherwise send the command to the fallback dispatch provider, if it
60 can handle this dispatch (determined by the list of commands given in
61 <code>setFallbackDispatch()</code>).</li>
64 <p>The <code>XDispatch</code>Provider is designed to return different
65 <code>XDispatch</code> implementations for each command. This class here
66 decides which implementation to use for which command.</p>
68 <p>As most commands need much information of the controller and are
69 implemented there, the controller handles most of the commands itself (it
70 also implements <code>XDispatch</code>). Therefore it is set here as
71 fallback dispatch.</p>
73 class CommandDispatchContainer
76 // note: the fallback dispatcher should be removed when all commands are
77 // handled by other dispatchers. (Fallback is currently the controller
79 explicit CommandDispatchContainer(
80 const ::com::sun::star::uno::Reference
<
81 ::com::sun::star::uno::XComponentContext
> & xContext
);
84 const ::com::sun::star::uno::Reference
<
85 ::com::sun::star::frame::XModel
> & xModel
);
86 // void setUndoManager(
87 // const ::com::sun::star::uno::Reference<
88 // ::com::sun::star::chart2::XUndoManager > & xUndoManager );
90 /** Set a fallback dispatcher that is used for all commands contained in
93 void setFallbackDispatch(
94 const ::com::sun::star::uno::Reference
<
95 ::com::sun::star::frame::XDispatch
> xFallbackDispatch
,
96 const ::std::set
< ::rtl::OUString
> & rFallbackCommands
);
98 /** Returns the dispatch that is able to do the command given in rURL, if
99 implemented here. If the URL is not implemented here, it should be
100 checked whether the command is one of the commands given as fallback via
101 the setFallbackDispatch() method. If so, call the fallback dispatch.
103 <p>If all this fails, return an empty dispatch.</p>
105 ::com::sun::star::uno::Reference
<
106 ::com::sun::star::frame::XDispatch
> getDispatchForURL(
107 const ::com::sun::star::util::URL
& rURL
);
109 ::com::sun::star::uno::Sequence
<
110 ::com::sun::star::uno::Reference
<
111 ::com::sun::star::frame::XDispatch
> > getDispatchesForURLs(
112 const ::com::sun::star::uno::Sequence
<
113 ::com::sun::star::frame::DispatchDescriptor
> & aDescriptors
);
115 void DisposeAndClear();
117 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatch
>
118 getContainerDispatchForURL(
119 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XController
> & xChartController
,
120 const ::com::sun::star::util::URL
& rURL
);
124 ::std::map
< ::rtl::OUString
,
125 ::com::sun::star::uno::Reference
<
126 ::com::sun::star::frame::XDispatch
> >
130 ::std::vector
< ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatch
> > tDisposeVector
;
132 mutable tDispatchMap m_aCachedDispatches
;
133 mutable tDisposeVector m_aToBeDisposedDispatches
;
135 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> m_xContext
;
136 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
> m_xModel
;
137 ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XUndoManager
> m_xUndoManager
;
139 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatch
> m_xFallbackDispatcher
;
140 ::std::set
< ::rtl::OUString
> m_aFallbackCommands
;
142 ::std::set
< ::rtl::OUString
> m_aContainerDocumentCommands
;
147 // CHART2_COMMANDDISPATCHCONTAINER_HXX