1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "STLPropertySet.hxx"
22 #include <osl/diagnose.h>
24 using namespace com::sun::star::beans
;
26 using com::sun::star::uno::Any
;
31 STLPropertySet::STLPropertySet()
35 STLPropertySet::~STLPropertySet()
39 void STLPropertySet::setPropertyDefaultValue( sal_Int32 nHandle
, const Any
& rValue
)
41 STLPropertyMapEntry
aEntry( rValue
, STLPropertyState_DEFAULT
);
42 maPropertyMap
[ nHandle
] = aEntry
;
45 void STLPropertySet::setPropertyValue( sal_Int32 nHandle
, const Any
& rValue
, sal_Int32
/* nState = STLPropertyState_DIRECT */ )
47 PropertyMapIter aIter
;
48 if( findProperty( nHandle
, aIter
) )
50 (*aIter
).second
.mnState
= STLPropertyState_DIRECT
;
51 (*aIter
).second
.maValue
= rValue
;
55 OSL_FAIL( "sd::STLPropertySet::setPropertyValue(), unknown property!" );
59 Any
STLPropertySet::getPropertyValue( sal_Int32 nHandle
) const
61 PropertyMapConstIter aIter
;
62 if( findProperty( nHandle
, aIter
) )
64 return (*aIter
).second
.maValue
;
68 OSL_FAIL( "sd::STLPropertySet::setPropertyValue(), unknown property!" );
75 sal_Int32
STLPropertySet::getPropertyState( sal_Int32 nHandle
) const
77 PropertyMapConstIter aIter
;
78 if( findProperty( nHandle
, aIter
) )
80 return (*aIter
).second
.mnState
;
84 OSL_FAIL( "sd::STLPropertySet::setPropertyState(), unknown property!" );
85 return STLPropertyState_AMBIGUOUS
;
89 void STLPropertySet::setPropertyState( sal_Int32 nHandle
, sal_Int32 nState
)
91 PropertyMapIter aIter
;
92 if( findProperty( nHandle
, aIter
) )
94 (*aIter
).second
.mnState
= nState
;
98 OSL_FAIL( "sd::STLPropertySet::setPropertyState(), unknown property!" );
102 bool STLPropertySet::findProperty( sal_Int32 nHandle
, PropertyMapIter
& rIter
)
104 rIter
= maPropertyMap
.find(nHandle
);
105 return( rIter
!= maPropertyMap
.end() );
108 bool STLPropertySet::findProperty( sal_Int32 nHandle
, PropertyMapConstIter
& rIter
) const
110 rIter
= maPropertyMap
.find(nHandle
);
111 return( rIter
!= maPropertyMap
.end() );
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */