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 .
20 #ifndef SD_FRAMEWORK_CONFIGURATION_CONFIGURATION_HXX
21 #define SD_FRAMEWORK_CONFIGURATION_CONFIGURATION_HXX
23 #include "MutexOwner.hxx"
24 #include <com/sun/star/drawing/framework/XConfiguration.hpp>
25 #include <com/sun/star/drawing/framework/XConfigurationControllerBroadcaster.hpp>
26 #include <com/sun/star/util/XCloneable.hpp>
27 #include <com/sun/star/container/XNamed.hpp>
28 #include <cppuhelper/compbase2.hxx>
30 #include <boost/scoped_ptr.hpp>
34 typedef ::cppu::WeakComponentImplHelper2
<
35 ::com::sun::star::drawing::framework::XConfiguration
,
36 ::com::sun::star::container::XNamed
37 > ConfigurationInterfaceBase
;
39 } // end of anonymous namespace.
44 namespace sd
{ namespace framework
{
46 /** A configuration describes the resources of an application like panes,
47 views, and tool bars and their relationships that are currently active
48 or are requested to be activated. Resources are specified by URLs rather
49 than references so that not only the current configuration but also a
50 requested configuration can be represented.
52 A resource URL describes the type of a resource, not its actual
53 instance. For resources, like panes, that are unique with respect to an
54 application frame, that does not mean much of a difference. For other
55 resources like views, that may have more than one instance per
56 application frame, this is different. To identify them unambigously a
57 second URL, one of a unique resource, is necessary. This second URL is
58 called the anchor of the first. The two types of resources are called
59 unique and linked respectively.
61 Direct manipulation of a configuration object is not advised with the
62 exception of the configuration controller and objects that implement the
63 XConfigurationChangeOperation interface.
66 : private sd::MutexOwner
,
67 public ConfigurationInterfaceBase
70 /** Create a new configuration with a broadcaster that is used to send
71 events about requested configuration changes.
73 This broadcaster is typically the same as the one used by the
74 ConfigurationController.
75 @param bBroadcastRequestEvents
76 When this is <TRUE/> then modifications to the configuration
77 trigger the broadcasting of "ResourceActivationRequestEvent" and
78 "ResourceDeactivationRequestEvent". When this flag is <FALSE/>
79 then events with type "ResourceActivationEvent" and
80 "ResourceDeactivationEvent" are broadcasted.
82 Configuration (const ::com::sun::star::uno::Reference
<
83 ::com::sun::star::drawing::framework::XConfigurationControllerBroadcaster
>& rxBroadcaster
,
84 bool bBroadcastRequestEvents
);
85 virtual ~Configuration (void);
87 virtual void SAL_CALL
disposing (void);
92 virtual void SAL_CALL
addResource (
93 const ::com::sun::star::uno::Reference
<com::sun::star::drawing::framework::XResourceId
>&
95 throw (::com::sun::star::uno::RuntimeException
);
97 virtual void SAL_CALL
removeResource(
98 const ::com::sun::star::uno::Reference
<com::sun::star::drawing::framework::XResourceId
>&
100 throw (::com::sun::star::uno::RuntimeException
);
102 virtual ::com::sun::star::uno::Sequence
< com::sun::star::uno::Reference
<
103 com::sun::star::drawing::framework::XResourceId
> > SAL_CALL
getResources (
104 const ::com::sun::star::uno::Reference
<
105 ::com::sun::star::drawing::framework::XResourceId
>& rxAnchorId
,
106 const OUString
& rsResourceURLPrefix
,
107 ::com::sun::star::drawing::framework::AnchorBindingMode eMode
)
108 throw (::com::sun::star::uno::RuntimeException
);
110 virtual sal_Bool SAL_CALL
hasResource (
111 const ::com::sun::star::uno::Reference
<com::sun::star::drawing::framework::XResourceId
>&
113 throw (::com::sun::star::uno::RuntimeException
);
118 virtual ::com::sun::star::uno::Reference
<com::sun::star::util::XCloneable
>
119 SAL_CALL
createClone (void)
120 throw (::com::sun::star::uno::RuntimeException
);
125 /** Return a human readable string representation. This is used for
128 virtual OUString SAL_CALL
getName (void)
129 throw (::com::sun::star::uno::RuntimeException
);
131 /** This call is ignored because the XNamed interface is (mis)used to
132 give access to a human readable name for debugging purposes.
134 virtual void SAL_CALL
setName (const OUString
& rName
)
135 throw (::com::sun::star::uno::RuntimeException
);
138 class ResourceContainer
;
139 /** The resource container holds the URLs of unique resource and of
140 resource linked to unique resources.
142 ::boost::scoped_ptr
<ResourceContainer
> mpResourceContainer
;
144 /** The broadcaster used for notifying listeners of requests for
145 configuration changes.
147 ::com::sun::star::uno::Reference
<
148 ::com::sun::star::drawing::framework::XConfigurationControllerBroadcaster
>
151 bool mbBroadcastRequestEvents
;
153 /** This private variant of the constructor is used for cloning a
154 Configuration object.
155 @param rResourceContainer
156 The new Configuration is created with a copy of the elements in
159 Configuration (const ::com::sun::star::uno::Reference
<
160 ::com::sun::star::drawing::framework::XConfigurationControllerBroadcaster
>& rxBroadcaster
,
161 bool bBroadcastRequestEvents
,
162 const ResourceContainer
& rResourceContainer
);
164 /** Send an event to all interested listeners that a resource has been
165 added or removed. The event is sent to the listeners via the
166 ConfigurationController.
168 The resource that is added to or removed from the configuration.
170 This specifies whether an activation or deactivation is
171 broadcasted. The mbBroadcastRequestEvents member is also taken
172 into account when the actual event type field is determined.
175 const ::com::sun::star::uno::Reference
<com::sun::star::drawing::framework::XResourceId
>&
177 const bool bActivation
);
179 /** When the called object has already been disposed this method throws
180 an exception and does not return.
182 void ThrowIfDisposed (void) const
183 throw (::com::sun::star::lang::DisposedException
);
187 /** Return whether the two given configurations contain the same resource
188 ids. The order of resource ids is ignored. Empty references are
189 treated like empty configurations.
191 bool AreConfigurationsEquivalent (
192 const ::com::sun::star::uno::Reference
<
193 ::com::sun::star::drawing::framework::XConfiguration
>& rxConfiguration1
,
194 const ::com::sun::star::uno::Reference
<
195 ::com::sun::star::drawing::framework::XConfiguration
>& rxConfiguration2
);
197 } } // end of namespace sd::framework
201 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */