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 rtl::OUString;
25 : using com::sun::star::uno::Any;
26 :
27 : namespace sd
28 : {
29 :
30 0 : STLPropertySet::STLPropertySet()
31 : {
32 0 : }
33 :
34 0 : STLPropertySet::~STLPropertySet()
35 : {
36 0 : }
37 :
38 0 : void STLPropertySet::setPropertyDefaultValue( sal_Int32 nHandle, const Any& rValue )
39 : {
40 0 : STLPropertyMapEntry aEntry( rValue, STLPropertyState_DEFAULT );
41 0 : maPropertyMap[ nHandle ] = aEntry;
42 0 : }
43 :
44 0 : void STLPropertySet::setPropertyValue( sal_Int32 nHandle, const Any& rValue, sal_Int32 /* nState = STLPropertyState_DIRECT */ )
45 : {
46 0 : PropertyMapIter aIter;
47 0 : if( findProperty( nHandle, aIter ) )
48 : {
49 0 : (*aIter).second.mnState = STLPropertyState_DIRECT;
50 0 : (*aIter).second.maValue = rValue;
51 : }
52 : else
53 : {
54 : OSL_FAIL( "sd::STLPropertySet::setPropertyValue(), unknown property!" );
55 : }
56 0 : }
57 :
58 0 : Any STLPropertySet::getPropertyValue( sal_Int32 nHandle ) const
59 : {
60 0 : PropertyMapConstIter aIter;
61 0 : if( findProperty( nHandle, aIter ) )
62 : {
63 0 : return (*aIter).second.maValue;
64 : }
65 : else
66 : {
67 : OSL_FAIL( "sd::STLPropertySet::setPropertyValue(), unknown property!" );
68 :
69 0 : Any aAny;
70 0 : return aAny;
71 : }
72 : }
73 :
74 0 : sal_Int32 STLPropertySet::getPropertyState( sal_Int32 nHandle ) const
75 : {
76 0 : PropertyMapConstIter aIter;
77 0 : if( findProperty( nHandle, aIter ) )
78 : {
79 0 : return (*aIter).second.mnState;
80 : }
81 : else
82 : {
83 : OSL_FAIL( "sd::STLPropertySet::setPropertyState(), unknown property!" );
84 0 : return STLPropertyState_AMBIGUOUS;
85 : }
86 : }
87 :
88 0 : void STLPropertySet::setPropertyState( sal_Int32 nHandle, sal_Int32 nState )
89 : {
90 0 : PropertyMapIter aIter;
91 0 : if( findProperty( nHandle, aIter ) )
92 : {
93 0 : (*aIter).second.mnState = nState;
94 : }
95 : else
96 : {
97 : OSL_FAIL( "sd::STLPropertySet::setPropertyState(), unknown property!" );
98 : }
99 0 : }
100 :
101 0 : bool STLPropertySet::findProperty( sal_Int32 nHandle, PropertyMapIter& rIter )
102 : {
103 0 : rIter = maPropertyMap.find(nHandle);
104 0 : return( rIter != maPropertyMap.end() );
105 : }
106 :
107 0 : bool STLPropertySet::findProperty( sal_Int32 nHandle, PropertyMapConstIter& rIter ) const
108 : {
109 0 : rIter = maPropertyMap.find(nHandle);
110 0 : return( rIter != maPropertyMap.end() );
111 : }
112 :
113 : }
114 :
115 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|