1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SD_FRAMEWORK_GENERIC_CONFIGURATTION_CHANGE_REQUEST_HXX
25 #define SD_FRAMEWORK_GENERIC_CONFIGURATTION_CHANGE_REQUEST_HXX
26 
27 #include "MutexOwner.hxx"
28 #include <com/sun/star/drawing/framework/XConfigurationChangeRequest.hpp>
29 #include <com/sun/star/container/XNamed.hpp>
30 #include <com/sun/star/drawing/framework/XConfiguration.hpp>
31 #include <com/sun/star/drawing/framework/XResourceId.hpp>
32 #include <com/sun/star/lang/IllegalArgumentException.hpp>
33 #include <com/sun/star/beans/PropertyValues.hpp>
34 #include <cppuhelper/compbase2.hxx>
35 
36 namespace css = ::com::sun::star;
37 
38 namespace {
39 
40 typedef ::cppu::WeakComponentImplHelper2 <
41       ::com::sun::star::drawing::framework::XConfigurationChangeRequest,
42       ::com::sun::star::container::XNamed
43     > GenericConfigurationChangeRequestInterfaceBase;
44 
45 } // end of anonymous namespace.
46 
47 
48 namespace sd { namespace framework {
49 
50 /** This implementation of the XConfigurationChangeRequest interface
51     represents a single explicit request for a configuration change.  On its
52     execution it may result in other, implicit, configuration changes.  For
53     example this is the case when the deactivation of a unique resource is
54     requested: the resources linked to it have to be deactivated as well.
55 */
56 class GenericConfigurationChangeRequest
57     : private MutexOwner,
58       public GenericConfigurationChangeRequestInterfaceBase
59 {
60 public:
61     /** This enum specified whether the activation or deactivation of a
62         resource is requested.
63     */
64     enum Mode { Activation, Deactivation };
65 
66     /** Create a new object that represents the request for activation or
67         deactivation of the specified resource.
68         @param rxsResourceId
69             Id of the resource that is to be activated or deactivated.
70         @param eMode
71             The mode specifies whether to activate or to deactivate the
72             resource.
73     */
74 	GenericConfigurationChangeRequest (
75         const ::com::sun::star::uno::Reference<com::sun::star::drawing::framework::XResourceId>&
76             rxResourceId,
77         const Mode eMode)
78         throw (::com::sun::star::lang::IllegalArgumentException);
79 
80 	virtual ~GenericConfigurationChangeRequest (void) throw();
81 
82 
83     // XConfigurationChangeOperation
84 
85     /** The requested configuration change is executed on the given
86         configuration.  Additionally to the explicitly requested change
87         other changes have to be made as well.  See class description for an
88         example.
89         @param rxConfiguration
90             The configuration to which the requested change is made.
91     */
92     virtual void SAL_CALL execute (
93         const ::com::sun::star::uno::Reference<
94             com::sun::star::drawing::framework::XConfiguration>& rxConfiguration)
95         throw (::com::sun::star::uno::RuntimeException);
96 
97 
98     // XNamed
99 
100     /** Return a human readable string representation.  This is used for
101         debugging purposes.
102     */
103     virtual ::rtl::OUString SAL_CALL getName (void)
104         throw (::com::sun::star::uno::RuntimeException);
105 
106     /** This call is ignored because the XNamed interface is (mis)used to
107         give access to a human readable name for debugging purposes.
108     */
109     virtual void SAL_CALL setName (const ::rtl::OUString& rName)
110         throw (::com::sun::star::uno::RuntimeException);
111 
112 private:
113     const css::uno::Reference<css::drawing::framework::XResourceId> mxResourceId;
114     const Mode meMode;
115 };
116 
117 } } // end of namespace sd::framework
118 
119 #endif
120