xref: /trunk/main/sd/source/ui/inc/framework/Configuration.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef SD_FRAMEWORK_CONFIGURATION_CONFIGURATION_HXX
29*cdf0e10cSrcweir #define SD_FRAMEWORK_CONFIGURATION_CONFIGURATION_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "MutexOwner.hxx"
32*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XConfiguration.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XConfigurationControllerBroadcaster.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/util/XCloneable.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/container/XNamed.hpp>
36*cdf0e10cSrcweir #include <cppuhelper/compbase2.hxx>
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir #include <boost/scoped_ptr.hpp>
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir namespace {
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper2 <
43*cdf0e10cSrcweir     ::com::sun::star::drawing::framework::XConfiguration,
44*cdf0e10cSrcweir     ::com::sun::star::container::XNamed
45*cdf0e10cSrcweir     > ConfigurationInterfaceBase;
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir } // end of anonymous namespace.
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir namespace sd { namespace framework {
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir /** A configuration describes the resources of an application like panes,
55*cdf0e10cSrcweir     views, and tool bars and their relationships that are currently active
56*cdf0e10cSrcweir     or are requested to be activated. Resources are specified by URLs rather
57*cdf0e10cSrcweir     than references so that not only the current configuration but also a
58*cdf0e10cSrcweir     requested configuration can be represented.
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir     A resource URL describes the type of a resource, not its actual
61*cdf0e10cSrcweir     instance. For resources, like panes, that are unique with respect to an
62*cdf0e10cSrcweir     application frame, that does not mean much of a difference. For other
63*cdf0e10cSrcweir     resources like views, that may have more than one instance per
64*cdf0e10cSrcweir     application frame, this is different. To identify them unambigously a
65*cdf0e10cSrcweir     second URL, one of a unique resource, is necessary. This second URL is
66*cdf0e10cSrcweir     called the anchor of the first. The two types of resources are called
67*cdf0e10cSrcweir     unique and linked respectively.
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir     Direct manipulation of a configuration object is not advised with the
70*cdf0e10cSrcweir     exception of the configuration controller and objects that implement the
71*cdf0e10cSrcweir     XConfigurationChangeOperation interface.
72*cdf0e10cSrcweir */
73*cdf0e10cSrcweir class Configuration
74*cdf0e10cSrcweir     : private sd::MutexOwner,
75*cdf0e10cSrcweir       public ConfigurationInterfaceBase
76*cdf0e10cSrcweir {
77*cdf0e10cSrcweir public:
78*cdf0e10cSrcweir     /** Create a new configuration with a broadcaster that is used to send
79*cdf0e10cSrcweir         events about requested configuration changes.
80*cdf0e10cSrcweir         @param rxBroadcaster
81*cdf0e10cSrcweir             This broadcaster is typically the same as the one used by the
82*cdf0e10cSrcweir             ConfigurationController.
83*cdf0e10cSrcweir         @param bBroadcastRequestEvents
84*cdf0e10cSrcweir             When this is <TRUE/> then modifications to the configuration
85*cdf0e10cSrcweir             trigger the broadcasting of "ResourceActivationRequestEvent" and
86*cdf0e10cSrcweir             "ResourceDeactivationRequestEvent".  When this flag is <FALSE/>
87*cdf0e10cSrcweir             then events with type "ResourceActivationEvent" and
88*cdf0e10cSrcweir             "ResourceDeactivationEvent" are broadcasted.
89*cdf0e10cSrcweir     */
90*cdf0e10cSrcweir     Configuration (const ::com::sun::star::uno::Reference<
91*cdf0e10cSrcweir         ::com::sun::star::drawing::framework::XConfigurationControllerBroadcaster>& rxBroadcaster,
92*cdf0e10cSrcweir         bool bBroadcastRequestEvents);
93*cdf0e10cSrcweir     virtual ~Configuration (void);
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir     virtual void SAL_CALL disposing (void);
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir     // XConfiguration
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir     virtual void SAL_CALL addResource (
101*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<com::sun::star::drawing::framework::XResourceId>&
102*cdf0e10cSrcweir             rxResourceId)
103*cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir     virtual void SAL_CALL removeResource(
106*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<com::sun::star::drawing::framework::XResourceId>&
107*cdf0e10cSrcweir             rxResourceId)
108*cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< com::sun::star::uno::Reference<
111*cdf0e10cSrcweir         com::sun::star::drawing::framework::XResourceId> > SAL_CALL getResources (
112*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
113*cdf0e10cSrcweir             ::com::sun::star::drawing::framework::XResourceId>& rxAnchorId,
114*cdf0e10cSrcweir         const ::rtl::OUString& rsResourceURLPrefix,
115*cdf0e10cSrcweir         ::com::sun::star::drawing::framework::AnchorBindingMode eMode)
116*cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL hasResource (
119*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<com::sun::star::drawing::framework::XResourceId>&
120*cdf0e10cSrcweir             rxResourceId)
121*cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir     // XCloneable
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference<com::sun::star::util::XCloneable>
127*cdf0e10cSrcweir         SAL_CALL createClone (void)
128*cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir     // XNamed
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir     /** Return a human readable string representation.  This is used for
134*cdf0e10cSrcweir         debugging purposes.
135*cdf0e10cSrcweir     */
136*cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getName (void)
137*cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir     /** This call is ignored because the XNamed interface is (mis)used to
140*cdf0e10cSrcweir         give access to a human readable name for debugging purposes.
141*cdf0e10cSrcweir     */
142*cdf0e10cSrcweir     virtual void SAL_CALL setName (const ::rtl::OUString& rName)
143*cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir private:
146*cdf0e10cSrcweir     class ResourceContainer;
147*cdf0e10cSrcweir     /** The resource container holds the URLs of unique resource and of
148*cdf0e10cSrcweir         resource linked to unique resources.
149*cdf0e10cSrcweir     */
150*cdf0e10cSrcweir     ::boost::scoped_ptr<ResourceContainer> mpResourceContainer;
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir     /** The broadcaster used for notifying listeners of requests for
153*cdf0e10cSrcweir         configuration changes.
154*cdf0e10cSrcweir     */
155*cdf0e10cSrcweir     ::com::sun::star::uno::Reference<
156*cdf0e10cSrcweir         ::com::sun::star::drawing::framework::XConfigurationControllerBroadcaster>
157*cdf0e10cSrcweir         mxBroadcaster;
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir     bool mbBroadcastRequestEvents;
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir     /** This private variant of the constructor is used for cloning a
162*cdf0e10cSrcweir         Configuration object.
163*cdf0e10cSrcweir         @param rResourceContainer
164*cdf0e10cSrcweir             The new Configuration is created with a copy of the elements in
165*cdf0e10cSrcweir             this container.
166*cdf0e10cSrcweir     */
167*cdf0e10cSrcweir     Configuration (const ::com::sun::star::uno::Reference<
168*cdf0e10cSrcweir         ::com::sun::star::drawing::framework::XConfigurationControllerBroadcaster>& rxBroadcaster,
169*cdf0e10cSrcweir         bool bBroadcastRequestEvents,
170*cdf0e10cSrcweir         const ResourceContainer& rResourceContainer);
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir     /** Send an event to all interested listeners that a resource has been
173*cdf0e10cSrcweir         added or removed.  The event is sent to the listeners via the
174*cdf0e10cSrcweir         ConfigurationController.
175*cdf0e10cSrcweir         @param rxResourceId
176*cdf0e10cSrcweir             The resource that is added to or removed from the configuration.
177*cdf0e10cSrcweir         @param bActivation
178*cdf0e10cSrcweir             This specifies whether an activation or deactivation is
179*cdf0e10cSrcweir             broadcasted.  The mbBroadcastRequestEvents member is also taken
180*cdf0e10cSrcweir             into account when the actual event type field is determined.
181*cdf0e10cSrcweir     */
182*cdf0e10cSrcweir     void PostEvent (
183*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<com::sun::star::drawing::framework::XResourceId>&
184*cdf0e10cSrcweir             rxResourceId,
185*cdf0e10cSrcweir         const bool bActivation);
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir     /** When the called object has already been disposed this method throws
188*cdf0e10cSrcweir         an exception and does not return.
189*cdf0e10cSrcweir     */
190*cdf0e10cSrcweir     void ThrowIfDisposed (void) const
191*cdf0e10cSrcweir         throw (::com::sun::star::lang::DisposedException);
192*cdf0e10cSrcweir };
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir /** Return whether the two given configurations contain the same resource
196*cdf0e10cSrcweir     ids.  The order of resource ids is ignored.  Empty references are
197*cdf0e10cSrcweir     treated like empty configurations.
198*cdf0e10cSrcweir */
199*cdf0e10cSrcweir bool AreConfigurationsEquivalent (
200*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
201*cdf0e10cSrcweir             ::com::sun::star::drawing::framework::XConfiguration>& rxConfiguration1,
202*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
203*cdf0e10cSrcweir             ::com::sun::star::drawing::framework::XConfiguration>& rxConfiguration2);
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir } } // end of namespace sd::framework
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir #endif
208