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