GPU-Calc: remove Alloc_Host_Ptr for clmem of NAN vector
[LibreOffice.git] / oox / source / helper / propertyset.cxx
blobcd84e9fcd27bdfe1f8687b8c2ce289f7953fbd12
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 "oox/helper/propertyset.hxx"
22 #include <osl/diagnose.h>
23 #include <rtl/strbuf.hxx>
24 #include "oox/helper/propertymap.hxx"
26 namespace oox {
28 // ============================================================================
30 using namespace ::com::sun::star::beans;
31 using namespace ::com::sun::star::uno;
33 // ============================================================================
35 void PropertySet::set( const Reference< XPropertySet >& rxPropSet )
37 mxPropSet = rxPropSet;
38 mxMultiPropSet.set( mxPropSet, UNO_QUERY );
39 if( mxPropSet.is() ) try
41 mxPropSetInfo = mxPropSet->getPropertySetInfo();
43 catch( Exception& )
48 bool PropertySet::hasProperty( sal_Int32 nPropId ) const
50 if( mxPropSetInfo.is() ) try
52 const OUString& rPropName = PropertyMap::getPropertyName( nPropId );
53 return mxPropSetInfo->hasPropertyByName( rPropName );
55 catch( Exception& )
58 return false;
61 // Get properties -------------------------------------------------------------
63 Any PropertySet::getAnyProperty( sal_Int32 nPropId ) const
65 Any aValue;
66 return implGetPropertyValue( aValue, PropertyMap::getPropertyName( nPropId ) ) ? aValue : Any();
69 // Set properties -------------------------------------------------------------
71 bool PropertySet::setAnyProperty( sal_Int32 nPropId, const Any& rValue )
73 return implSetPropertyValue( PropertyMap::getPropertyName( nPropId ), rValue );
76 void PropertySet::setProperties( const Sequence< OUString >& rPropNames, const Sequence< Any >& rValues )
78 OSL_ENSURE( rPropNames.getLength() == rValues.getLength(),
79 "PropertySet::setProperties - length of sequences different" );
81 if( mxMultiPropSet.is() ) try
83 mxMultiPropSet->setPropertyValues( rPropNames, rValues );
84 return;
86 catch( Exception& )
88 SAL_WARN( "oox", "PropertySet::setProperties - cannot set all property values, fallback to single mode" );
91 if( mxPropSet.is() )
93 const OUString* pPropName = rPropNames.getConstArray();
94 const OUString* pPropNameEnd = pPropName + rPropNames.getLength();
95 const Any* pValue = rValues.getConstArray();
96 for( ; pPropName != pPropNameEnd; ++pPropName, ++pValue )
97 implSetPropertyValue( *pPropName, *pValue );
101 void PropertySet::setProperties( const PropertyMap& rPropertyMap )
103 if( !rPropertyMap.empty() )
105 Sequence< OUString > aPropNames;
106 Sequence< Any > aValues;
107 rPropertyMap.fillSequences( aPropNames, aValues );
108 setProperties( aPropNames, aValues );
112 // private --------------------------------------------------------------------
114 bool PropertySet::implGetPropertyValue( Any& orValue, const OUString& rPropName ) const
116 if( mxPropSet.is() ) try
118 orValue = mxPropSet->getPropertyValue( rPropName );
119 return true;
121 catch( Exception& e)
123 SAL_WARN( "oox", "PropertySet::implGetPropertyValue - cannot get property \"" <<
124 rPropName << "\" Error: " << e.Message);
126 return false;
129 bool PropertySet::implSetPropertyValue( const OUString& rPropName, const Any& rValue )
131 if( mxPropSet.is() ) try
133 mxPropSet->setPropertyValue( rPropName, rValue );
134 return true;
136 catch( Exception& e)
138 SAL_WARN( "oox", "PropertySet::implSetPropertyValue - cannot set property \"" <<
139 rPropName << "\" Error: " << e.Message);
141 return false;
144 #ifdef DBG_UTIL
145 void PropertySet::dump()
147 PropertyMap::dump( Reference< XPropertySet >( getXPropertySet(), UNO_QUERY ) );
149 #endif
151 } // namespace oox
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */