Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "STLPropertySet.hxx"
21 :
22 : using namespace com::sun::star::beans;
23 :
24 : using com::sun::star::uno::Any;
25 :
26 : namespace sd
27 : {
28 :
29 0 : STLPropertySet::STLPropertySet()
30 : {
31 0 : }
32 :
33 0 : STLPropertySet::~STLPropertySet()
34 : {
35 0 : }
36 :
37 0 : void STLPropertySet::setPropertyDefaultValue( sal_Int32 nHandle, const Any& rValue )
38 : {
39 0 : STLPropertyMapEntry aEntry( rValue, STLPropertyState_DEFAULT );
40 0 : maPropertyMap[ nHandle ] = aEntry;
41 0 : }
42 :
43 0 : void STLPropertySet::setPropertyValue( sal_Int32 nHandle, const Any& rValue, sal_Int32 /* nState = STLPropertyState_DIRECT */ )
44 : {
45 0 : PropertyMapIter aIter;
46 0 : if( findProperty( nHandle, aIter ) )
47 : {
48 0 : (*aIter).second.mnState = STLPropertyState_DIRECT;
49 0 : (*aIter).second.maValue = rValue;
50 : }
51 : else
52 : {
53 : OSL_FAIL( "sd::STLPropertySet::setPropertyValue(), unknown property!" );
54 : }
55 0 : }
56 :
57 0 : Any STLPropertySet::getPropertyValue( sal_Int32 nHandle ) const
58 : {
59 0 : PropertyMapConstIter aIter;
60 0 : if( findProperty( nHandle, aIter ) )
61 : {
62 0 : return (*aIter).second.maValue;
63 : }
64 : else
65 : {
66 : OSL_FAIL( "sd::STLPropertySet::setPropertyValue(), unknown property!" );
67 :
68 0 : Any aAny;
69 0 : return aAny;
70 : }
71 : }
72 :
73 0 : sal_Int32 STLPropertySet::getPropertyState( sal_Int32 nHandle ) const
74 : {
75 0 : PropertyMapConstIter aIter;
76 0 : if( findProperty( nHandle, aIter ) )
77 : {
78 0 : return (*aIter).second.mnState;
79 : }
80 : else
81 : {
82 : OSL_FAIL( "sd::STLPropertySet::setPropertyState(), unknown property!" );
83 0 : return STLPropertyState_AMBIGUOUS;
84 : }
85 : }
86 :
87 0 : void STLPropertySet::setPropertyState( sal_Int32 nHandle, sal_Int32 nState )
88 : {
89 0 : PropertyMapIter aIter;
90 0 : if( findProperty( nHandle, aIter ) )
91 : {
92 0 : (*aIter).second.mnState = nState;
93 : }
94 : else
95 : {
96 : OSL_FAIL( "sd::STLPropertySet::setPropertyState(), unknown property!" );
97 : }
98 0 : }
99 :
100 0 : bool STLPropertySet::findProperty( sal_Int32 nHandle, PropertyMapIter& rIter )
101 : {
102 0 : rIter = maPropertyMap.find(nHandle);
103 0 : return( rIter != maPropertyMap.end() );
104 : }
105 :
106 0 : bool STLPropertySet::findProperty( sal_Int32 nHandle, PropertyMapConstIter& rIter ) const
107 : {
108 0 : rIter = maPropertyMap.find(nHandle);
109 0 : return( rIter != maPropertyMap.end() );
110 : }
111 :
112 : }
113 :
114 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|