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