xref: /trunk/main/sd/source/ui/animations/STLPropertySet.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sd.hxx"
30 #include <tools/debug.hxx>
31 #include "STLPropertySet.hxx"
32 
33 using namespace com::sun::star::beans;
34 
35 using rtl::OUString;
36 using com::sun::star::uno::Any;
37 
38 namespace sd
39 {
40 
41 STLPropertySet::STLPropertySet()
42 {
43 }
44 
45 STLPropertySet::~STLPropertySet()
46 {
47 }
48 
49 void STLPropertySet::setPropertyDefaultValue( sal_Int32 nHandle, const Any& rValue )
50 {
51     STLPropertyMapEntry aEntry( rValue, STLPropertyState_DEFAULT );
52     maPropertyMap[ nHandle ] = aEntry;
53 }
54 
55 void STLPropertySet::setPropertyValue( sal_Int32 nHandle, const Any& rValue, sal_Int32 /* nState = STLPropertyState_DIRECT */ )
56 {
57     PropertyMapIter aIter;
58     if( findProperty( nHandle, aIter ) )
59     {
60         (*aIter).second.mnState = STLPropertyState_DIRECT;
61         (*aIter).second.maValue = rValue;
62     }
63     else
64     {
65         DBG_ERROR( "sd::STLPropertySet::setPropertyValue(), unknown property!" );
66     }
67 }
68 
69 Any STLPropertySet::getPropertyValue( sal_Int32 nHandle ) const
70 {
71     PropertyMapConstIter aIter;
72     if( findProperty( nHandle, aIter ) )
73     {
74         return (*aIter).second.maValue;
75     }
76     else
77     {
78         DBG_ERROR( "sd::STLPropertySet::setPropertyValue(), unknown property!" );
79 
80         Any aAny;
81         return aAny;
82     }
83 }
84 
85 sal_Int32 STLPropertySet::getPropertyState( sal_Int32 nHandle ) const
86 {
87     PropertyMapConstIter aIter;
88     if( findProperty( nHandle, aIter ) )
89     {
90         return (*aIter).second.mnState;
91     }
92     else
93     {
94         DBG_ERROR( "sd::STLPropertySet::setPropertyState(), unknown property!" );
95         return STLPropertyState_AMBIGUOUS;
96     }
97 }
98 
99 void STLPropertySet::setPropertyState( sal_Int32 nHandle, sal_Int32 nState )
100 {
101     PropertyMapIter aIter;
102     if( findProperty( nHandle, aIter ) )
103     {
104         (*aIter).second.mnState = nState;
105     }
106     else
107     {
108         DBG_ERROR( "sd::STLPropertySet::setPropertyState(), unknown property!" );
109     }
110 }
111 
112 bool STLPropertySet::findProperty( sal_Int32 nHandle, PropertyMapIter& rIter )
113 {
114     rIter = maPropertyMap.find(nHandle);
115     return( rIter != maPropertyMap.end() );
116 }
117 
118 bool STLPropertySet::findProperty( sal_Int32 nHandle, PropertyMapConstIter& rIter ) const
119 {
120     rIter = maPropertyMap.find(nHandle);
121     return( rIter != maPropertyMap.end() );
122 }
123 
124 }
125