LibreOffice Module svx (master)  1
propertyset.cxx
Go to the documentation of this file.
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 
21 #include "propertyset.hxx"
22 
23 using namespace ::com::sun::star::uno;
24 using namespace ::com::sun::star::beans;
25 using namespace ::com::sun::star::lang;
26 
27 namespace sdr::table {
28 
30 {
31  addProperties( rProps );
32 }
33 
34 
36 {
37 }
38 
39 
41 {
42  sal_uInt32 nIndex = maProperties.size();
43  sal_uInt32 nCount = rProps.size();
44  maProperties.resize( nIndex + nCount );
45  for( const Property& rProperty : rProps )
46  {
47  maProperties[nIndex] = rProperty;
48  maMap[ rProperty.Name ] = nIndex++;
49  }
50 }
51 
52 
53 const Property& FastPropertySetInfo::getProperty( const OUString& aName )
54 {
55  PropertyMap::iterator aIter( maMap.find( aName ) );
56  if( aIter == maMap.end() )
57  throw UnknownPropertyException( aName, static_cast<cppu::OWeakObject*>(this));
58  return maProperties[(*aIter).second];
59 }
60 
61 
62 const Property* FastPropertySetInfo::hasProperty( const OUString& aName )
63 {
64  PropertyMap::iterator aIter( maMap.find( aName ) );
65  if( aIter == maMap.end() )
66  return nullptr;
67  else
68  return &maProperties[(*aIter).second];
69 }
70 
71 
72 // XPropertySetInfo
73 
74 
75 Sequence< Property > SAL_CALL FastPropertySetInfo::getProperties()
76 {
77  return Sequence< Property >( maProperties.data(), maProperties.size() );
78 }
79 
80 
81 Property SAL_CALL FastPropertySetInfo::getPropertyByName( const OUString& aName )
82 {
83  return getProperty( aName );
84 }
85 
86 
87 sal_Bool SAL_CALL FastPropertySetInfo::hasPropertyByName( const OUString& aName )
88 {
89  return hasProperty( aName ) != nullptr;
90 }
91 
93 : mxInfo( xInfo )
94 {
95 }
96 
97 
99 {
100 }
101 
102 
103 // XPropertySet
104 
105 
106 Reference< XPropertySetInfo > SAL_CALL FastPropertySet::getPropertySetInfo( )
107 {
108  return Reference< XPropertySetInfo >( mxInfo.get() );
109 }
110 
111 
112 void SAL_CALL FastPropertySet::setPropertyValue( const OUString& aPropertyName, const Any& aValue )
113 {
114  setFastPropertyValue( mxInfo->getProperty( aPropertyName ).Handle, aValue );
115 }
116 
117 
118 Any SAL_CALL FastPropertySet::getPropertyValue( const OUString& aPropertyName )
119 {
120  return getFastPropertyValue( mxInfo->getProperty( aPropertyName ).Handle );
121 }
122 
123 
124 void SAL_CALL FastPropertySet::addPropertyChangeListener( const OUString&, const Reference< XPropertyChangeListener >& )
125 {
126 }
127 
128 
129 void SAL_CALL FastPropertySet::removePropertyChangeListener( const OUString&, const Reference< XPropertyChangeListener >& )
130 {
131 }
132 
133 
134 void SAL_CALL FastPropertySet::addVetoableChangeListener( const OUString&, const Reference< XVetoableChangeListener >& )
135 {
136 }
137 
138 
139 void SAL_CALL FastPropertySet::removeVetoableChangeListener( const OUString&, const Reference< XVetoableChangeListener >& )
140 {
141 }
142 
143 
144 // XMultiPropertySet
145 
146 
147 void SAL_CALL FastPropertySet::setPropertyValues( const Sequence< OUString >& aPropertyNames, const Sequence< Any >& aValues )
148 {
149  if( aPropertyNames.getLength() != aValues.getLength() )
150  throw IllegalArgumentException();
151 
152  const Any* pValues = aValues.getConstArray();
153  for( const OUString& rPropertyName : aPropertyNames )
154  {
155  const Property* pProperty = mxInfo->hasProperty( rPropertyName );
156  if( pProperty ) try
157  {
158  setFastPropertyValue( pProperty->Handle, *pValues );
159  }
160  catch( UnknownPropertyException& )
161  {
162  }
163  pValues++;
164  }
165 }
166 
167 
168 Sequence< Any > SAL_CALL FastPropertySet::getPropertyValues( const Sequence< OUString >& aPropertyNames )
169 {
170  sal_Int32 nCount = aPropertyNames.getLength();
171  Sequence< Any > aValues( nCount );
172 
173  Any* pValues = aValues.getArray();
174  for( const OUString& rPropertyName : aPropertyNames )
175  {
176  const Property* pProperty = mxInfo->hasProperty( rPropertyName );
177  if( pProperty ) try
178  {
179  *pValues = getFastPropertyValue( pProperty->Handle );
180  }
181  catch( UnknownPropertyException& )
182  {
183  }
184  pValues++;
185  }
186  return aValues;
187 }
188 
189 
190 void SAL_CALL FastPropertySet::addPropertiesChangeListener( const Sequence< OUString >&, const Reference< XPropertiesChangeListener >& )
191 {
192 }
193 
194 
195 void SAL_CALL FastPropertySet::removePropertiesChangeListener( const Reference< XPropertiesChangeListener >& )
196 {
197 }
198 
199 
200 void SAL_CALL FastPropertySet::firePropertiesChangeEvent( const Sequence< OUString >&, const Reference< XPropertiesChangeListener >& )
201 {
202 }
203 
204 }
205 
206 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 nIndex
virtual css::beans::Property SAL_CALL getPropertyByName(const OUString &aName) override
Definition: propertyset.cxx:81
virtual void SAL_CALL addPropertiesChangeListener(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
std::vector< css::beans::Property > PropertyVector
Definition: propertyset.hxx:35
int nCount
const css::beans::Property & getProperty(const OUString &aName)
Definition: propertyset.cxx:53
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
rtl::Reference< FastPropertySetInfo > mxInfo
Definition: propertyset.hxx:89
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
virtual sal_Bool SAL_CALL hasPropertyByName(const OUString &Name) override
Definition: propertyset.cxx:87
unsigned char sal_Bool
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues(const css::uno::Sequence< OUString > &aPropertyNames) override
virtual void SAL_CALL setFastPropertyValue(::sal_Int32 nHandle, const css::uno::Any &aValue) override=0
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
const PropertyValue * pValues
virtual void SAL_CALL setPropertyValues(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Sequence< css::uno::Any > &aValues) override
virtual ~FastPropertySet() override
Definition: propertyset.cxx:98
void addProperties(const PropertyVector &rProps)
Definition: propertyset.cxx:40
virtual void SAL_CALL removePropertiesChangeListener(const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
virtual css::uno::Any SAL_CALL getFastPropertyValue(::sal_Int32 nHandle) override=0
FastPropertySetInfo(const PropertyVector &rProps)
Definition: propertyset.cxx:29
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
FastPropertySet(const rtl::Reference< FastPropertySetInfo > &xInfo)
Definition: propertyset.cxx:92
virtual void SAL_CALL firePropertiesChangeEvent(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
virtual ~FastPropertySetInfo() override
Definition: propertyset.cxx:35
virtual css::uno::Sequence< css::beans::Property > SAL_CALL getProperties() override
Definition: propertyset.cxx:75
const css::beans::Property * hasProperty(const OUString &aName)
Definition: propertyset.cxx:62