merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / inc / framework / Configuration.hxx
blobfda6033a68753723b0aa9e2870196316e9ce1fc3
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: Configuration.hxx,v $
10 * $Revision: 1.3 $
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 ************************************************************************/
31 #ifndef SD_FRAMEWORK_CONFIGURATION_CONFIGURATION_HXX
32 #define SD_FRAMEWORK_CONFIGURATION_CONFIGURATION_HXX
34 #include "MutexOwner.hxx"
35 #include <com/sun/star/drawing/framework/XConfiguration.hpp>
36 #include <com/sun/star/drawing/framework/XConfigurationControllerBroadcaster.hpp>
37 #include <com/sun/star/util/XCloneable.hpp>
38 #include <com/sun/star/container/XNamed.hpp>
39 #include <cppuhelper/compbase2.hxx>
41 #include <boost/scoped_ptr.hpp>
43 namespace {
45 typedef ::cppu::WeakComponentImplHelper2 <
46 ::com::sun::star::drawing::framework::XConfiguration,
47 ::com::sun::star::container::XNamed
48 > ConfigurationInterfaceBase;
50 } // end of anonymous namespace.
55 namespace sd { namespace framework {
57 /** A configuration describes the resources of an application like panes,
58 views, and tool bars and their relationships that are currently active
59 or are requested to be activated. Resources are specified by URLs rather
60 than references so that not only the current configuration but also a
61 requested configuration can be represented.
63 A resource URL describes the type of a resource, not its actual
64 instance. For resources, like panes, that are unique with respect to an
65 application frame, that does not mean much of a difference. For other
66 resources like views, that may have more than one instance per
67 application frame, this is different. To identify them unambigously a
68 second URL, one of a unique resource, is necessary. This second URL is
69 called the anchor of the first. The two types of resources are called
70 unique and linked respectively.
72 Direct manipulation of a configuration object is not advised with the
73 exception of the configuration controller and objects that implement the
74 XConfigurationChangeOperation interface.
76 class Configuration
77 : private sd::MutexOwner,
78 public ConfigurationInterfaceBase
80 public:
81 /** Create a new configuration with a broadcaster that is used to send
82 events about requested configuration changes.
83 @param rxBroadcaster
84 This broadcaster is typically the same as the one used by the
85 ConfigurationController.
86 @param bBroadcastRequestEvents
87 When this is <TRUE/> then modifications to the configuration
88 trigger the broadcasting of "ResourceActivationRequestEvent" and
89 "ResourceDeactivationRequestEvent". When this flag is <FALSE/>
90 then events with type "ResourceActivationEvent" and
91 "ResourceDeactivationEvent" are broadcasted.
93 Configuration (const ::com::sun::star::uno::Reference<
94 ::com::sun::star::drawing::framework::XConfigurationControllerBroadcaster>& rxBroadcaster,
95 bool bBroadcastRequestEvents);
96 virtual ~Configuration (void);
98 virtual void SAL_CALL disposing (void);
101 // XConfiguration
103 virtual void SAL_CALL addResource (
104 const ::com::sun::star::uno::Reference<com::sun::star::drawing::framework::XResourceId>&
105 rxResourceId)
106 throw (::com::sun::star::uno::RuntimeException);
108 virtual void SAL_CALL removeResource(
109 const ::com::sun::star::uno::Reference<com::sun::star::drawing::framework::XResourceId>&
110 rxResourceId)
111 throw (::com::sun::star::uno::RuntimeException);
113 virtual ::com::sun::star::uno::Sequence< com::sun::star::uno::Reference<
114 com::sun::star::drawing::framework::XResourceId> > SAL_CALL getResources (
115 const ::com::sun::star::uno::Reference<
116 ::com::sun::star::drawing::framework::XResourceId>& rxAnchorId,
117 const ::rtl::OUString& rsResourceURLPrefix,
118 ::com::sun::star::drawing::framework::AnchorBindingMode eMode)
119 throw (::com::sun::star::uno::RuntimeException);
121 virtual sal_Bool SAL_CALL hasResource (
122 const ::com::sun::star::uno::Reference<com::sun::star::drawing::framework::XResourceId>&
123 rxResourceId)
124 throw (::com::sun::star::uno::RuntimeException);
127 // XCloneable
129 virtual ::com::sun::star::uno::Reference<com::sun::star::util::XCloneable>
130 SAL_CALL createClone (void)
131 throw (::com::sun::star::uno::RuntimeException);
134 // XNamed
136 /** Return a human readable string representation. This is used for
137 debugging purposes.
139 virtual ::rtl::OUString SAL_CALL getName (void)
140 throw (::com::sun::star::uno::RuntimeException);
142 /** This call is ignored because the XNamed interface is (mis)used to
143 give access to a human readable name for debugging purposes.
145 virtual void SAL_CALL setName (const ::rtl::OUString& rName)
146 throw (::com::sun::star::uno::RuntimeException);
148 private:
149 class ResourceContainer;
150 /** The resource container holds the URLs of unique resource and of
151 resource linked to unique resources.
153 ::boost::scoped_ptr<ResourceContainer> mpResourceContainer;
155 /** The broadcaster used for notifying listeners of requests for
156 configuration changes.
158 ::com::sun::star::uno::Reference<
159 ::com::sun::star::drawing::framework::XConfigurationControllerBroadcaster>
160 mxBroadcaster;
162 bool mbBroadcastRequestEvents;
164 /** This private variant of the constructor is used for cloning a
165 Configuration object.
166 @param rResourceContainer
167 The new Configuration is created with a copy of the elements in
168 this container.
170 Configuration (const ::com::sun::star::uno::Reference<
171 ::com::sun::star::drawing::framework::XConfigurationControllerBroadcaster>& rxBroadcaster,
172 bool bBroadcastRequestEvents,
173 const ResourceContainer& rResourceContainer);
175 /** Send an event to all interested listeners that a resource has been
176 added or removed. The event is sent to the listeners via the
177 ConfigurationController.
178 @param rxResourceId
179 The resource that is added to or removed from the configuration.
180 @param bActivation
181 This specifies whether an activation or deactivation is
182 broadcasted. The mbBroadcastRequestEvents member is also taken
183 into account when the actual event type field is determined.
185 void PostEvent (
186 const ::com::sun::star::uno::Reference<com::sun::star::drawing::framework::XResourceId>&
187 rxResourceId,
188 const bool bActivation);
190 /** When the called object has already been disposed this method throws
191 an exception and does not return.
193 void ThrowIfDisposed (void) const
194 throw (::com::sun::star::lang::DisposedException);
198 /** Return whether the two given configurations contain the same resource
199 ids. The order of resource ids is ignored. Empty references are
200 treated like empty configurations.
202 bool AreConfigurationsEquivalent (
203 const ::com::sun::star::uno::Reference<
204 ::com::sun::star::drawing::framework::XConfiguration>& rxConfiguration1,
205 const ::com::sun::star::uno::Reference<
206 ::com::sun::star::drawing::framework::XConfiguration>& rxConfiguration2);
208 } } // end of namespace sd::framework
210 #endif