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 INCLUDED_SD_SOURCE_UI_INC_FRAMEWORK_CONFIGURATION_HXX
21 #define INCLUDED_SD_SOURCE_UI_INC_FRAMEWORK_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/lang/XServiceInfo.hpp>
27 #include <com/sun/star/util/XCloneable.hpp>
28 #include <com/sun/star/container/XNamed.hpp>
29 #include <cppuhelper/compbase.hxx>
31 #include <boost/scoped_ptr.hpp>
35 typedef ::cppu::WeakComponentImplHelper
<
36 ::com::sun::star::drawing::framework::XConfiguration
,
37 ::com::sun::star::container::XNamed
,
38 css::lang::XServiceInfo
39 > ConfigurationInterfaceBase
;
41 } // end of anonymous namespace.
43 namespace sd
{ namespace framework
{
45 /** A configuration describes the resources of an application like panes,
46 views, and tool bars and their relationships that are currently active
47 or are requested to be activated. Resources are specified by URLs rather
48 than references so that not only the current configuration but also a
49 requested configuration can be represented.
51 A resource URL describes the type of a resource, not its actual
52 instance. For resources, like panes, that are unique with respect to an
53 application frame, that does not mean much of a difference. For other
54 resources like views, that may have more than one instance per
55 application frame, this is different. To identify them unambigously a
56 second URL, one of a unique resource, is necessary. This second URL is
57 called the anchor of the first. The two types of resources are called
58 unique and linked respectively.
60 Direct manipulation of a configuration object is not advised with the
61 exception of the configuration controller and objects that implement the
62 XConfigurationChangeOperation interface.
65 : private sd::MutexOwner
,
66 public ConfigurationInterfaceBase
69 /** Create a new configuration with a broadcaster that is used to send
70 events about requested configuration changes.
72 This broadcaster is typically the same as the one used by the
73 ConfigurationController.
74 @param bBroadcastRequestEvents
75 When this is <TRUE/> then modifications to the configuration
76 trigger the broadcasting of "ResourceActivationRequestEvent" and
77 "ResourceDeactivationRequestEvent". When this flag is <FALSE/>
78 then events with type "ResourceActivationEvent" and
79 "ResourceDeactivationEvent" are broadcasted.
81 Configuration (const ::com::sun::star::uno::Reference
<
82 ::com::sun::star::drawing::framework::XConfigurationControllerBroadcaster
>& rxBroadcaster
,
83 bool bBroadcastRequestEvents
);
84 virtual ~Configuration();
86 virtual void SAL_CALL
disposing() SAL_OVERRIDE
;
90 virtual void SAL_CALL
addResource (
91 const ::com::sun::star::uno::Reference
<com::sun::star::drawing::framework::XResourceId
>&
93 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
95 virtual void SAL_CALL
removeResource(
96 const ::com::sun::star::uno::Reference
<com::sun::star::drawing::framework::XResourceId
>&
98 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
100 virtual ::com::sun::star::uno::Sequence
< com::sun::star::uno::Reference
<
101 com::sun::star::drawing::framework::XResourceId
> > SAL_CALL
getResources (
102 const ::com::sun::star::uno::Reference
<
103 ::com::sun::star::drawing::framework::XResourceId
>& rxAnchorId
,
104 const OUString
& rsResourceURLPrefix
,
105 ::com::sun::star::drawing::framework::AnchorBindingMode eMode
)
106 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
108 virtual sal_Bool SAL_CALL
hasResource (
109 const ::com::sun::star::uno::Reference
<com::sun::star::drawing::framework::XResourceId
>&
111 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
115 virtual ::com::sun::star::uno::Reference
<com::sun::star::util::XCloneable
>
116 SAL_CALL
createClone()
117 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
121 /** Return a human readable string representation. This is used for
124 virtual OUString SAL_CALL
getName()
125 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
127 /** This call is ignored because the XNamed interface is (mis)used to
128 give access to a human readable name for debugging purposes.
130 virtual void SAL_CALL
setName (const OUString
& rName
)
131 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
133 OUString SAL_CALL
getImplementationName()
134 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
136 sal_Bool SAL_CALL
supportsService(OUString
const & ServiceName
)
137 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
139 css::uno::Sequence
<OUString
> SAL_CALL
getSupportedServiceNames()
140 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
143 class ResourceContainer
;
144 /** The resource container holds the URLs of unique resource and of
145 resource linked to unique resources.
147 ::boost::scoped_ptr
<ResourceContainer
> mpResourceContainer
;
149 /** The broadcaster used for notifying listeners of requests for
150 configuration changes.
152 ::com::sun::star::uno::Reference
<
153 ::com::sun::star::drawing::framework::XConfigurationControllerBroadcaster
>
156 bool mbBroadcastRequestEvents
;
158 /** This private variant of the constructor is used for cloning a
159 Configuration object.
160 @param rResourceContainer
161 The new Configuration is created with a copy of the elements in
164 Configuration (const ::com::sun::star::uno::Reference
<
165 ::com::sun::star::drawing::framework::XConfigurationControllerBroadcaster
>& rxBroadcaster
,
166 bool bBroadcastRequestEvents
,
167 const ResourceContainer
& rResourceContainer
);
169 /** Send an event to all interested listeners that a resource has been
170 added or removed. The event is sent to the listeners via the
171 ConfigurationController.
173 The resource that is added to or removed from the configuration.
175 This specifies whether an activation or deactivation is
176 broadcasted. The mbBroadcastRequestEvents member is also taken
177 into account when the actual event type field is determined.
180 const ::com::sun::star::uno::Reference
<com::sun::star::drawing::framework::XResourceId
>&
182 const bool bActivation
);
184 /** When the called object has already been disposed this method throws
185 an exception and does not return.
187 void ThrowIfDisposed() const
188 throw (::com::sun::star::lang::DisposedException
);
191 /** Return whether the two given configurations contain the same resource
192 ids. The order of resource ids is ignored. Empty references are
193 treated like empty configurations.
195 bool AreConfigurationsEquivalent (
196 const ::com::sun::star::uno::Reference
<
197 ::com::sun::star::drawing::framework::XConfiguration
>& rxConfiguration1
,
198 const ::com::sun::star::uno::Reference
<
199 ::com::sun::star::drawing::framework::XConfiguration
>& rxConfiguration2
);
201 } } // end of namespace sd::framework
205 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */