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 #include "precompiled_sd.hxx"
25 
26 #include "GenericConfigurationChangeRequest.hxx"
27 
28 #include "framework/FrameworkHelper.hxx"
29 
30 using namespace ::com::sun::star;
31 using namespace ::com::sun::star::uno;
32 using namespace ::com::sun::star::drawing::framework;
33 
34 using ::rtl::OUString;
35 
36 namespace sd { namespace framework {
37 
GenericConfigurationChangeRequest(const Reference<XResourceId> & rxResourceId,const Mode eMode)38 GenericConfigurationChangeRequest::GenericConfigurationChangeRequest (
39     const Reference<XResourceId>& rxResourceId,
40     const Mode eMode) throw(::com::sun::star::lang::IllegalArgumentException)
41     : GenericConfigurationChangeRequestInterfaceBase(MutexOwner::maMutex),
42       mxResourceId(rxResourceId),
43       meMode(eMode)
44 {
45     if ( ! rxResourceId.is() || rxResourceId->getResourceURL().getLength()==0)
46         throw ::com::sun::star::lang::IllegalArgumentException();
47 }
48 
49 
50 
51 
~GenericConfigurationChangeRequest(void)52 GenericConfigurationChangeRequest::~GenericConfigurationChangeRequest (void) throw()
53 {
54 }
55 
56 
57 
58 
execute(const Reference<XConfiguration> & rxConfiguration)59 void SAL_CALL GenericConfigurationChangeRequest::execute (
60     const Reference<XConfiguration>& rxConfiguration)
61     throw (RuntimeException)
62 {
63     if (rxConfiguration.is())
64     {
65         switch (meMode)
66         {
67             case Activation:
68                 rxConfiguration->addResource(mxResourceId);
69                 break;
70 
71             case Deactivation:
72                 rxConfiguration->removeResource(mxResourceId);
73                 break;
74         }
75     }
76 }
77 
78 
79 
80 
getName(void)81 OUString SAL_CALL GenericConfigurationChangeRequest::getName (void)
82     throw (RuntimeException)
83 {
84     return OUString::createFromAscii("GenericConfigurationChangeRequest ")
85         + OUString::createFromAscii(meMode==Activation ? "activate " : "deactivate ")
86         + FrameworkHelper::ResourceIdToString(mxResourceId);
87 }
88 
89 
90 
91 
setName(const OUString & rsName)92 void SAL_CALL GenericConfigurationChangeRequest::setName (const OUString& rsName)
93     throw (RuntimeException)
94 {
95     (void)rsName;
96     // Ignored.
97 }
98 
99 } } // end of namespace sd::framework
100 
101