1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _SD_STLPROPERTYSET_HXX 25 #define _SD_STLPROPERTYSET_HXX 26 27 #include <com/sun/star/beans/PropertyValue.hpp> 28 29 #ifndef _UTL_STLTYPES_HXX_ 30 #include <comphelper/stl_types.hxx> 31 #endif 32 33 #include <list> 34 #include <map> 35 36 namespace sd 37 { 38 39 const sal_Int32 STLPropertyState_DEFAULT = 0; 40 const sal_Int32 STLPropertyState_DIRECT = 1; 41 const sal_Int32 STLPropertyState_AMBIGUOUS = 3; 42 43 struct STLPropertyMapEntry 44 { 45 ::com::sun::star::uno::Any maValue; 46 sal_Int32 mnState; 47 STLPropertyMapEntrysd::STLPropertyMapEntry48 STLPropertyMapEntry() 49 : mnState( STLPropertyState_AMBIGUOUS ) {} STLPropertyMapEntrysd::STLPropertyMapEntry50 STLPropertyMapEntry( ::com::sun::star::uno::Any aValue, sal_Int32 nState = STLPropertyState_DEFAULT ) 51 : maValue( aValue ), mnState( nState ) {} 52 53 }; 54 55 typedef std::map<sal_Int32, STLPropertyMapEntry > PropertyMap; 56 typedef PropertyMap::iterator PropertyMapIter; 57 typedef PropertyMap::const_iterator PropertyMapConstIter; 58 59 class STLPropertySet 60 { 61 public: 62 STLPropertySet(); 63 ~STLPropertySet(); 64 65 void setPropertyDefaultValue( sal_Int32 nHandle, const com::sun::star::uno::Any& rValue ); 66 void setPropertyValue( sal_Int32 nHandle, const com::sun::star::uno::Any& rValue, sal_Int32 nState = STLPropertyState_DIRECT ); 67 ::com::sun::star::uno::Any getPropertyValue( sal_Int32 nHandle ) const; 68 69 sal_Int32 getPropertyState( sal_Int32 nHandle ) const; 70 void setPropertyState( sal_Int32 nHandle, sal_Int32 nState ); 71 72 private: 73 bool findProperty( sal_Int32 nHandle, PropertyMapIter& rIter ); 74 bool findProperty( sal_Int32 nHandle, PropertyMapConstIter& rIter ) const; 75 76 private: 77 PropertyMap maPropertyMap; 78 }; 79 80 } 81 82 #endif // _SD_STLPROPERTYSET_HXX 83