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 .
22 #include <com/sun/star/drawing/framework/XConfiguration.hpp>
23 #include <com/sun/star/lang/XServiceInfo.hpp>
24 #include <com/sun/star/container/XNamed.hpp>
25 #include <comphelper/compbase.hxx>
29 namespace com::sun::star::util
{ class XCloneable
; }
30 namespace com::sun::star::drawing::framework
{ class XConfigurationControllerBroadcaster
; }
32 namespace sd::framework
{
34 typedef comphelper::WeakComponentImplHelper
<
35 css::drawing::framework::XConfiguration
,
36 css::container::XNamed
37 > ConfigurationInterfaceBase
;
39 /** A configuration describes the resources of an application like panes,
40 views, and tool bars and their relationships that are currently active
41 or are requested to be activated. Resources are specified by URLs rather
42 than references so that not only the current configuration but also a
43 requested configuration can be represented.
45 A resource URL describes the type of a resource, not its actual
46 instance. For resources, like panes, that are unique with respect to an
47 application frame, that does not mean much of a difference. For other
48 resources like views, that may have more than one instance per
49 application frame, this is different. To identify them unambiguously a
50 second URL, one of a unique resource, is necessary. This second URL is
51 called the anchor of the first. The two types of resources are called
52 unique and linked respectively.
54 Direct manipulation of a configuration object is not advised with the
55 exception of the configuration controller and objects that implement the
56 XConfigurationChangeOperation interface.
58 class Configuration final
59 : public ConfigurationInterfaceBase
62 /** Create a new configuration with a broadcaster that is used to send
63 events about requested configuration changes.
65 This broadcaster is typically the same as the one used by the
66 ConfigurationController.
67 @param bBroadcastRequestEvents
68 When this is <TRUE/> then modifications to the configuration
69 trigger the broadcasting of "ResourceActivationRequestEvent" and
70 "ResourceDeactivationRequestEvent". When this flag is <FALSE/>
71 then events with type "ResourceActivationEvent" and
72 "ResourceDeactivationEvent" are broadcasted.
74 Configuration (const css::uno::Reference
<css::drawing::framework::XConfigurationControllerBroadcaster
>& rxBroadcaster
,
75 bool bBroadcastRequestEvents
);
76 virtual ~Configuration() override
;
78 virtual void disposing(std::unique_lock
<std::mutex
>&) override
;
82 virtual void SAL_CALL
addResource (
83 const css::uno::Reference
<css::drawing::framework::XResourceId
>&
84 rxResourceId
) override
;
86 virtual void SAL_CALL
removeResource(
87 const css::uno::Reference
<css::drawing::framework::XResourceId
>&
88 rxResourceId
) override
;
90 virtual css::uno::Sequence
< css::uno::Reference
<
91 css::drawing::framework::XResourceId
> > SAL_CALL
getResources (
92 const css::uno::Reference
<css::drawing::framework::XResourceId
>& rxAnchorId
,
93 const OUString
& rsResourceURLPrefix
,
94 css::drawing::framework::AnchorBindingMode eMode
) override
;
96 virtual sal_Bool SAL_CALL
hasResource (
97 const css::uno::Reference
<css::drawing::framework::XResourceId
>&
98 rxResourceId
) override
;
102 virtual css::uno::Reference
<css::util::XCloneable
>
103 SAL_CALL
createClone() override
;
107 /** Return a human readable string representation. This is used for
110 virtual OUString SAL_CALL
getName() override
;
112 /** This call is ignored because the XNamed interface is (mis)used to
113 give access to a human readable name for debugging purposes.
115 virtual void SAL_CALL
setName (const OUString
& rName
) override
;
118 class ResourceContainer
;
119 /** The resource container holds the URLs of unique resource and of
120 resource linked to unique resources.
122 std::unique_ptr
<ResourceContainer
> mpResourceContainer
;
124 /** The broadcaster used for notifying listeners of requests for
125 configuration changes.
127 css::uno::Reference
<css::drawing::framework::XConfigurationControllerBroadcaster
>
130 bool mbBroadcastRequestEvents
;
132 /** This private variant of the constructor is used for cloning a
133 Configuration object.
134 @param rResourceContainer
135 The new Configuration is created with a copy of the elements in
138 Configuration (const css::uno::Reference
<css::drawing::framework::XConfigurationControllerBroadcaster
>& rxBroadcaster
,
139 bool bBroadcastRequestEvents
,
140 const ResourceContainer
& rResourceContainer
);
142 /** Send an event to all interested listeners that a resource has been
143 added or removed. The event is sent to the listeners via the
144 ConfigurationController.
146 The resource that is added to or removed from the configuration.
148 This specifies whether an activation or deactivation is
149 broadcasted. The mbBroadcastRequestEvents member is also taken
150 into account when the actual event type field is determined.
153 const css::uno::Reference
<css::drawing::framework::XResourceId
>& rxResourceId
,
154 const bool bActivation
);
156 /** When the called object has already been disposed this method throws
157 an exception and does not return.
159 @throws css::lang::DisposedException
161 void ThrowIfDisposed() const;
164 /** Return whether the two given configurations contain the same resource
165 ids. The order of resource ids is ignored. Empty references are
166 treated like empty configurations.
168 bool AreConfigurationsEquivalent (
169 const css::uno::Reference
<css::drawing::framework::XConfiguration
>& rxConfiguration1
,
170 const css::uno::Reference
<css::drawing::framework::XConfiguration
>& rxConfiguration2
);
172 } // end of namespace sd::framework
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */