xref: /AOO41X/main/sd/source/ui/animations/STLPropertySet.cxx (revision 79aad27f7f29270c03e208e3d687e8e3850af11d)
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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 #include <tools/debug.hxx>
27 #include "STLPropertySet.hxx"
28 
29 using namespace com::sun::star::beans;
30 
31 using rtl::OUString;
32 using com::sun::star::uno::Any;
33 
34 namespace sd
35 {
36 
STLPropertySet()37 STLPropertySet::STLPropertySet()
38 {
39 }
40 
~STLPropertySet()41 STLPropertySet::~STLPropertySet()
42 {
43 }
44 
setPropertyDefaultValue(sal_Int32 nHandle,const Any & rValue)45 void STLPropertySet::setPropertyDefaultValue( sal_Int32 nHandle, const Any& rValue )
46 {
47     STLPropertyMapEntry aEntry( rValue, STLPropertyState_DEFAULT );
48     maPropertyMap[ nHandle ] = aEntry;
49 }
50 
setPropertyValue(sal_Int32 nHandle,const Any & rValue,sal_Int32)51 void STLPropertySet::setPropertyValue( sal_Int32 nHandle, const Any& rValue, sal_Int32 /* nState = STLPropertyState_DIRECT */ )
52 {
53     PropertyMapIter aIter;
54     if( findProperty( nHandle, aIter ) )
55     {
56         (*aIter).second.mnState = STLPropertyState_DIRECT;
57         (*aIter).second.maValue = rValue;
58     }
59     else
60     {
61         DBG_ERROR( "sd::STLPropertySet::setPropertyValue(), unknown property!" );
62     }
63 }
64 
getPropertyValue(sal_Int32 nHandle) const65 Any STLPropertySet::getPropertyValue( sal_Int32 nHandle ) const
66 {
67     PropertyMapConstIter aIter;
68     if( findProperty( nHandle, aIter ) )
69     {
70         return (*aIter).second.maValue;
71     }
72     else
73     {
74         DBG_ERROR( "sd::STLPropertySet::setPropertyValue(), unknown property!" );
75 
76         Any aAny;
77         return aAny;
78     }
79 }
80 
getPropertyState(sal_Int32 nHandle) const81 sal_Int32 STLPropertySet::getPropertyState( sal_Int32 nHandle ) const
82 {
83     PropertyMapConstIter aIter;
84     if( findProperty( nHandle, aIter ) )
85     {
86         return (*aIter).second.mnState;
87     }
88     else
89     {
90         DBG_ERROR( "sd::STLPropertySet::setPropertyState(), unknown property!" );
91         return STLPropertyState_AMBIGUOUS;
92     }
93 }
94 
setPropertyState(sal_Int32 nHandle,sal_Int32 nState)95 void STLPropertySet::setPropertyState( sal_Int32 nHandle, sal_Int32 nState )
96 {
97     PropertyMapIter aIter;
98     if( findProperty( nHandle, aIter ) )
99     {
100         (*aIter).second.mnState = nState;
101     }
102     else
103     {
104         DBG_ERROR( "sd::STLPropertySet::setPropertyState(), unknown property!" );
105     }
106 }
107 
findProperty(sal_Int32 nHandle,PropertyMapIter & rIter)108 bool STLPropertySet::findProperty( sal_Int32 nHandle, PropertyMapIter& rIter )
109 {
110     rIter = maPropertyMap.find(nHandle);
111     return( rIter != maPropertyMap.end() );
112 }
113 
findProperty(sal_Int32 nHandle,PropertyMapConstIter & rIter) const114 bool STLPropertySet::findProperty( sal_Int32 nHandle, PropertyMapConstIter& rIter ) const
115 {
116     rIter = maPropertyMap.find(nHandle);
117     return( rIter != maPropertyMap.end() );
118 }
119 
120 }
121