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