2010-10-27 12:43:08 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2007-05-22 17:06:27 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 19:53:21 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2007-05-22 17:06:27 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2007-05-22 17:06:27 +00:00
|
|
|
*
|
2008-04-10 19:53:21 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2007-05-22 17:06:27 +00:00
|
|
|
*
|
2008-04-10 19:53:21 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2007-05-22 17:06:27 +00:00
|
|
|
*
|
2008-04-10 19:53:21 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2007-05-22 17:06:27 +00:00
|
|
|
*
|
2008-04-10 19:53:21 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2007-05-22 17:06:27 +00:00
|
|
|
*
|
2008-04-10 19:53:21 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2007-05-22 17:06:27 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
#ifndef CHART2_COMMANDDISPATCHCONTAINER_HXX
|
|
|
|
#define CHART2_COMMANDDISPATCHCONTAINER_HXX
|
|
|
|
|
|
|
|
#include <com/sun/star/uno/XComponentContext.hpp>
|
|
|
|
#include <com/sun/star/frame/XDispatch.hpp>
|
|
|
|
#include <com/sun/star/frame/XModel.hpp>
|
|
|
|
#include <com/sun/star/frame/DispatchDescriptor.hpp>
|
|
|
|
|
2010-05-19 17:08:43 +02:00
|
|
|
#include <cppuhelper/weakref.hxx>
|
2007-05-22 17:06:27 +00:00
|
|
|
#include <cppuhelper/interfacecontainer.hxx>
|
|
|
|
|
|
|
|
#include <set>
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
namespace chart
|
|
|
|
{
|
|
|
|
|
2009-06-04 09:55:00 +00:00
|
|
|
class ChartController;
|
2009-04-27 13:39:52 +00:00
|
|
|
class DrawCommandDispatch;
|
2009-05-29 09:10:08 +00:00
|
|
|
class ShapeController;
|
2009-04-27 13:39:52 +00:00
|
|
|
|
2007-05-22 17:06:27 +00:00
|
|
|
/** @HTML
|
|
|
|
|
|
|
|
Helper class for implementing the <code>XDispatchProvider</code> interface
|
|
|
|
of the ChartController. This class handles all commands to queryDispatch and
|
|
|
|
queryDispatches in the following way:
|
|
|
|
|
|
|
|
<ul>
|
|
|
|
<li>Check if there is a cached <code>XDispatch</code> for a given command.
|
|
|
|
If so, use it.</li>
|
|
|
|
<li>Check if the command is handled by this class, e.g. Undo. If so,
|
|
|
|
return a corresponding <code>XDispatch</code> implementation, and cache
|
|
|
|
this implementation for later use</li>
|
2009-05-29 09:10:08 +00:00
|
|
|
<li>Otherwise send the command to the chart dispatch provider, if it
|
2007-05-22 17:06:27 +00:00
|
|
|
can handle this dispatch (determined by the list of commands given in
|
2009-05-29 09:10:08 +00:00
|
|
|
<code>setChartDispatch()</code>).</li>
|
2007-05-22 17:06:27 +00:00
|
|
|
</ul>
|
|
|
|
|
|
|
|
<p>The <code>XDispatch</code>Provider is designed to return different
|
|
|
|
<code>XDispatch</code> implementations for each command. This class here
|
|
|
|
decides which implementation to use for which command.</p>
|
|
|
|
|
|
|
|
<p>As most commands need much information of the controller and are
|
|
|
|
implemented there, the controller handles most of the commands itself (it
|
|
|
|
also implements <code>XDispatch</code>). Therefore it is set here as
|
2009-05-29 09:10:08 +00:00
|
|
|
chart dispatch.</p>
|
2007-05-22 17:06:27 +00:00
|
|
|
*/
|
|
|
|
class CommandDispatchContainer
|
|
|
|
{
|
|
|
|
public:
|
2009-05-29 09:10:08 +00:00
|
|
|
// note: the chart dispatcher should be removed when all commands are
|
|
|
|
// handled by other dispatchers. (Chart is currently the controller
|
2007-05-22 17:06:27 +00:00
|
|
|
// itself)
|
|
|
|
explicit CommandDispatchContainer(
|
|
|
|
const ::com::sun::star::uno::Reference<
|
2009-06-04 09:55:00 +00:00
|
|
|
::com::sun::star::uno::XComponentContext > & xContext,
|
|
|
|
ChartController* pController );
|
2007-05-22 17:06:27 +00:00
|
|
|
|
|
|
|
void setModel(
|
|
|
|
const ::com::sun::star::uno::Reference<
|
|
|
|
::com::sun::star::frame::XModel > & xModel );
|
|
|
|
|
2009-05-29 09:10:08 +00:00
|
|
|
/** Set a chart dispatcher that is used for all commands contained in
|
|
|
|
rChartCommands
|
2007-05-22 17:06:27 +00:00
|
|
|
*/
|
2009-05-29 09:10:08 +00:00
|
|
|
void setChartDispatch(
|
2007-05-22 17:06:27 +00:00
|
|
|
const ::com::sun::star::uno::Reference<
|
2009-05-29 09:10:08 +00:00
|
|
|
::com::sun::star::frame::XDispatch > xChartDispatch,
|
|
|
|
const ::std::set< ::rtl::OUString > & rChartCommands );
|
2007-05-22 17:06:27 +00:00
|
|
|
|
|
|
|
/** Returns the dispatch that is able to do the command given in rURL, if
|
|
|
|
implemented here. If the URL is not implemented here, it should be
|
2009-05-29 09:10:08 +00:00
|
|
|
checked whether the command is one of the commands given via
|
|
|
|
the setChartDispatch() method. If so, call the chart dispatch.
|
2007-05-22 17:06:27 +00:00
|
|
|
|
|
|
|
<p>If all this fails, return an empty dispatch.</p>
|
|
|
|
*/
|
|
|
|
::com::sun::star::uno::Reference<
|
|
|
|
::com::sun::star::frame::XDispatch > getDispatchForURL(
|
|
|
|
const ::com::sun::star::util::URL & rURL );
|
|
|
|
|
|
|
|
::com::sun::star::uno::Sequence<
|
|
|
|
::com::sun::star::uno::Reference<
|
|
|
|
::com::sun::star::frame::XDispatch > > getDispatchesForURLs(
|
|
|
|
const ::com::sun::star::uno::Sequence<
|
|
|
|
::com::sun::star::frame::DispatchDescriptor > & aDescriptors );
|
|
|
|
|
|
|
|
void DisposeAndClear();
|
|
|
|
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >
|
|
|
|
getContainerDispatchForURL(
|
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > & xChartController,
|
|
|
|
const ::com::sun::star::util::URL & rURL );
|
|
|
|
|
2009-04-27 13:39:52 +00:00
|
|
|
void setDrawCommandDispatch( DrawCommandDispatch* pDispatch );
|
2009-10-02 16:06:50 +00:00
|
|
|
DrawCommandDispatch* getDrawCommandDispatch() { return m_pDrawCommandDispatch; }
|
2009-05-29 09:10:08 +00:00
|
|
|
void setShapeController( ShapeController* pController );
|
2009-07-24 13:02:58 +00:00
|
|
|
ShapeController* getShapeController() { return m_pShapeController; }
|
2009-04-27 13:39:52 +00:00
|
|
|
|
2007-05-22 17:06:27 +00:00
|
|
|
private:
|
|
|
|
typedef
|
|
|
|
::std::map< ::rtl::OUString,
|
|
|
|
::com::sun::star::uno::Reference<
|
|
|
|
::com::sun::star::frame::XDispatch > >
|
|
|
|
tDispatchMap;
|
|
|
|
|
2008-06-16 11:51:13 +00:00
|
|
|
typedef
|
|
|
|
::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > tDisposeVector;
|
|
|
|
|
2007-05-22 17:06:27 +00:00
|
|
|
mutable tDispatchMap m_aCachedDispatches;
|
2008-06-16 11:51:13 +00:00
|
|
|
mutable tDisposeVector m_aToBeDisposedDispatches;
|
2007-05-22 17:06:27 +00:00
|
|
|
|
2010-11-09 21:37:01 +01:00
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
|
|
|
|
::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XModel > m_xModel;
|
2007-05-22 17:06:27 +00:00
|
|
|
|
2009-05-29 09:10:08 +00:00
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > m_xChartDispatcher;
|
|
|
|
::std::set< ::rtl::OUString > m_aChartCommands;
|
2007-05-22 17:06:27 +00:00
|
|
|
|
|
|
|
::std::set< ::rtl::OUString > m_aContainerDocumentCommands;
|
2009-04-27 13:39:52 +00:00
|
|
|
|
2009-06-04 09:55:00 +00:00
|
|
|
ChartController* m_pChartController;
|
2009-04-27 13:39:52 +00:00
|
|
|
DrawCommandDispatch* m_pDrawCommandDispatch;
|
2009-05-29 09:10:08 +00:00
|
|
|
ShapeController* m_pShapeController;
|
2007-05-22 17:06:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace chart
|
|
|
|
|
|
|
|
// CHART2_COMMANDDISPATCHCONTAINER_HXX
|
|
|
|
#endif
|
2010-10-27 12:43:08 +01:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|