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