/src/libreoffice/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx
Line | Count | Source |
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 | | #include "TitleWrapper.hxx" |
21 | | #include "Chart2ModelContact.hxx" |
22 | | #include <ControllerLockGuard.hxx> |
23 | | |
24 | | #include <comphelper/sequence.hxx> |
25 | | #include <cppuhelper/supportsservice.hxx> |
26 | | #include <com/sun/star/beans/PropertyAttribute.hpp> |
27 | | #include <com/sun/star/chart2/RelativePosition.hpp> |
28 | | #include <com/sun/star/chart2/XTitle.hpp> |
29 | | |
30 | | #include <CharacterProperties.hxx> |
31 | | #include <LinePropertiesHelper.hxx> |
32 | | #include <FillProperties.hxx> |
33 | | #include <UserDefinedProperties.hxx> |
34 | | #include "WrappedCharacterHeightProperty.hxx" |
35 | | #include "WrappedTextRotationProperty.hxx" |
36 | | #include "WrappedAutomaticPositionProperties.hxx" |
37 | | #include "WrappedScaleTextProperties.hxx" |
38 | | |
39 | | #include <algorithm> |
40 | | #include <sal/log.hxx> |
41 | | #include <rtl/ustrbuf.hxx> |
42 | | #include <cppuhelper/propshlp.hxx> |
43 | | #include <utility> |
44 | | |
45 | | using namespace ::com::sun::star; |
46 | | using ::com::sun::star::beans::Property; |
47 | | using ::com::sun::star::uno::Any; |
48 | | using ::com::sun::star::uno::Reference; |
49 | | using ::com::sun::star::uno::Sequence; |
50 | | |
51 | | namespace chart |
52 | | { |
53 | | namespace { |
54 | | |
55 | | class WrappedTitleStringProperty : public WrappedProperty |
56 | | { |
57 | | public: |
58 | | explicit WrappedTitleStringProperty( const Reference< uno::XComponentContext >& xContext ); |
59 | | |
60 | | virtual void setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const override; |
61 | | virtual Any getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const override; |
62 | | virtual Any getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const override; |
63 | | |
64 | | protected: |
65 | | Reference< uno::XComponentContext > m_xContext; |
66 | | }; |
67 | | |
68 | | } |
69 | | |
70 | | WrappedTitleStringProperty::WrappedTitleStringProperty( const Reference< uno::XComponentContext >& xContext ) |
71 | 0 | : ::chart::WrappedProperty( u"String"_ustr, OUString() ) |
72 | 0 | , m_xContext( xContext ) |
73 | 0 | { |
74 | 0 | } |
75 | | |
76 | | void WrappedTitleStringProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const |
77 | 0 | { |
78 | 0 | Title* pTitle = dynamic_cast<Title*>(xInnerPropertySet.get()); |
79 | 0 | if(pTitle) |
80 | 0 | { |
81 | 0 | OUString aString; |
82 | 0 | rOuterValue >>= aString; |
83 | 0 | TitleHelper::setCompleteString( aString, pTitle, m_xContext ); |
84 | 0 | } |
85 | 0 | } |
86 | | Any WrappedTitleStringProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const |
87 | 0 | { |
88 | 0 | Any aRet( getPropertyDefault( Reference< beans::XPropertyState >( xInnerPropertySet, uno::UNO_QUERY ) ) ); |
89 | 0 | Reference< chart2::XTitle > xTitle(xInnerPropertySet,uno::UNO_QUERY); |
90 | 0 | if(xTitle.is()) |
91 | 0 | { |
92 | 0 | const Sequence< Reference< chart2::XFormattedString > > aStrings( xTitle->getText()); |
93 | |
|
94 | 0 | OUStringBuffer aBuf; |
95 | 0 | for( Reference< chart2::XFormattedString > const & formattedStr : aStrings ) |
96 | 0 | { |
97 | 0 | aBuf.append( formattedStr->getString()); |
98 | 0 | } |
99 | 0 | aRet <<= aBuf.makeStringAndClear(); |
100 | 0 | } |
101 | 0 | return aRet; |
102 | 0 | } |
103 | | Any WrappedTitleStringProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const |
104 | 0 | { |
105 | 0 | return uno::Any( OUString() );//default title is an empty String |
106 | 0 | } |
107 | | |
108 | | namespace { |
109 | | |
110 | | class WrappedTitleFormStringsProperty : public WrappedProperty |
111 | | { |
112 | | public: |
113 | | explicit WrappedTitleFormStringsProperty(); |
114 | | |
115 | | virtual void setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const override; |
116 | | virtual Any getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const override; |
117 | | virtual Any getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const override; |
118 | | }; |
119 | | |
120 | | } |
121 | | |
122 | | WrappedTitleFormStringsProperty::WrappedTitleFormStringsProperty() |
123 | 0 | : ::chart::WrappedProperty( u"FormattedStrings"_ustr, OUString() ) |
124 | 0 | { |
125 | 0 | } |
126 | | |
127 | | void WrappedTitleFormStringsProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const |
128 | 0 | { |
129 | 0 | Title* pTitle = dynamic_cast<Title*>(xInnerPropertySet.get()); |
130 | 0 | if (pTitle) |
131 | 0 | { |
132 | 0 | Sequence< Reference< chart2::XFormattedString >> xFormattedStrings; |
133 | 0 | rOuterValue >>= xFormattedStrings; |
134 | 0 | TitleHelper::setFormattedString(pTitle, xFormattedStrings); |
135 | 0 | } |
136 | 0 | } |
137 | | Any WrappedTitleFormStringsProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const |
138 | 0 | { |
139 | 0 | Any aRet(getPropertyDefault(Reference< beans::XPropertyState >(xInnerPropertySet, uno::UNO_QUERY))); |
140 | 0 | Reference< chart2::XTitle > xTitle(xInnerPropertySet, uno::UNO_QUERY); |
141 | 0 | if (xTitle.is()) |
142 | 0 | { |
143 | 0 | const Sequence< Reference< chart2::XFormattedString > > aStrings(xTitle->getText()); |
144 | 0 | aRet <<= aStrings; |
145 | 0 | } |
146 | 0 | return aRet; |
147 | 0 | } |
148 | | Any WrappedTitleFormStringsProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const |
149 | 0 | { |
150 | 0 | return uno::Any(Sequence< Reference< chart2::XFormattedString > >()); //default title is an empty Sequence of XFormattedStrings |
151 | 0 | } |
152 | | |
153 | | namespace { |
154 | | |
155 | | class WrappedStackedTextProperty : public WrappedProperty |
156 | | { |
157 | | public: |
158 | | WrappedStackedTextProperty(); |
159 | | }; |
160 | | |
161 | | } |
162 | | |
163 | | WrappedStackedTextProperty::WrappedStackedTextProperty() |
164 | 0 | : ::chart::WrappedProperty( u"StackedText"_ustr, u"StackCharacters"_ustr ) |
165 | 0 | { |
166 | 0 | } |
167 | | |
168 | | }// end namespace chart |
169 | | |
170 | | namespace |
171 | | { |
172 | | |
173 | | enum |
174 | | { |
175 | | PROP_TITLE_STRING, |
176 | | PROP_TITLE_FORMATTED_STRINGS, |
177 | | PROP_TITLE_VISIBLE, |
178 | | PROP_TITLE_TEXT_ROTATION, |
179 | | PROP_TITLE_TEXT_STACKED |
180 | | }; |
181 | | |
182 | | void lcl_AddPropertiesToVector( |
183 | | std::vector< Property > & rOutProperties ) |
184 | 0 | { |
185 | 0 | rOutProperties.emplace_back( "String", |
186 | 0 | PROP_TITLE_STRING, |
187 | 0 | cppu::UnoType<OUString>::get(), |
188 | 0 | beans::PropertyAttribute::BOUND |
189 | 0 | | beans::PropertyAttribute::MAYBEVOID ); |
190 | |
|
191 | 0 | rOutProperties.emplace_back( "FormattedStrings", |
192 | 0 | PROP_TITLE_FORMATTED_STRINGS, |
193 | 0 | cppu::UnoType< Sequence< Reference< chart2::XFormattedString >>>::get(), |
194 | 0 | beans::PropertyAttribute::BOUND |
195 | 0 | | beans::PropertyAttribute::MAYBEVOID ); |
196 | |
|
197 | 0 | rOutProperties.emplace_back( "Visible", |
198 | 0 | PROP_TITLE_VISIBLE, |
199 | 0 | cppu::UnoType<OUString>::get(), |
200 | 0 | beans::PropertyAttribute::BOUND |
201 | 0 | | beans::PropertyAttribute::MAYBEVOID ); |
202 | |
|
203 | 0 | rOutProperties.emplace_back( "TextRotation", |
204 | 0 | PROP_TITLE_TEXT_ROTATION, |
205 | 0 | cppu::UnoType<sal_Int32>::get(), |
206 | 0 | beans::PropertyAttribute::BOUND |
207 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
208 | 0 | rOutProperties.emplace_back( "StackedText", |
209 | 0 | PROP_TITLE_TEXT_STACKED, |
210 | 0 | cppu::UnoType<bool>::get(), |
211 | 0 | beans::PropertyAttribute::BOUND |
212 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
213 | 0 | } |
214 | | |
215 | | const Sequence< Property > & StaticTitleWrapperPropertyArray() |
216 | 0 | { |
217 | 0 | static Sequence< Property > aPropSeq = []() |
218 | 0 | { |
219 | 0 | std::vector< beans::Property > aProperties; |
220 | 0 | lcl_AddPropertiesToVector( aProperties ); |
221 | 0 | ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); |
222 | 0 | ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); |
223 | 0 | ::chart::FillProperties::AddPropertiesToVector( aProperties ); |
224 | 0 | ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); |
225 | 0 | ::chart::wrapper::WrappedAutomaticPositionProperties::addProperties( aProperties ); |
226 | 0 | ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties ); |
227 | |
|
228 | 0 | std::sort( aProperties.begin(), aProperties.end(), |
229 | 0 | ::chart::PropertyNameLess() ); |
230 | |
|
231 | 0 | return comphelper::containerToSequence( aProperties ); |
232 | 0 | }(); |
233 | 0 | return aPropSeq; |
234 | 0 | }; |
235 | | |
236 | | |
237 | | } // anonymous namespace |
238 | | |
239 | | namespace chart::wrapper |
240 | | { |
241 | | |
242 | | TitleWrapper::TitleWrapper( ::chart::TitleHelper::eTitleType eTitleType, |
243 | | std::shared_ptr<Chart2ModelContact> spChart2ModelContact ) : |
244 | 0 | m_spChart2ModelContact(std::move( spChart2ModelContact )), |
245 | 0 | m_eTitleType(eTitleType) |
246 | 0 | { |
247 | 0 | ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getDocumentModel() ); |
248 | 0 | if( !getTitleObject().is() ) //#i83831# create an empty title at the model, thus references to properties can be mapped correctly |
249 | 0 | TitleHelper::createTitle( m_eTitleType, OUString(), m_spChart2ModelContact->getDocumentModel(), m_spChart2ModelContact->m_xContext ); |
250 | 0 | } |
251 | | |
252 | | TitleWrapper::~TitleWrapper() |
253 | 0 | { |
254 | 0 | } |
255 | | |
256 | | // ____ XShape ____ |
257 | | awt::Point SAL_CALL TitleWrapper::getPosition() |
258 | 0 | { |
259 | 0 | return m_spChart2ModelContact->GetTitlePosition( getTitleObject() ); |
260 | 0 | } |
261 | | |
262 | | void SAL_CALL TitleWrapper::setPosition( const awt::Point& aPosition ) |
263 | 0 | { |
264 | 0 | Reference< beans::XPropertySet > xPropertySet( getInnerPropertySet() ); |
265 | 0 | if(xPropertySet.is()) |
266 | 0 | { |
267 | 0 | awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() ); |
268 | |
|
269 | 0 | chart2::RelativePosition aRelativePosition; |
270 | 0 | aRelativePosition.Anchor = drawing::Alignment_TOP_LEFT; |
271 | 0 | aRelativePosition.Primary = double(aPosition.X)/double(aPageSize.Width); |
272 | 0 | aRelativePosition.Secondary = double(aPosition.Y)/double(aPageSize.Height); |
273 | 0 | xPropertySet->setPropertyValue( u"RelativePosition"_ustr, uno::Any(aRelativePosition) ); |
274 | 0 | } |
275 | 0 | } |
276 | | |
277 | | awt::Size SAL_CALL TitleWrapper::getSize() |
278 | 0 | { |
279 | 0 | return m_spChart2ModelContact->GetTitleSize( getTitleObject() ); |
280 | 0 | } |
281 | | |
282 | | void SAL_CALL TitleWrapper::setSize( const awt::Size& /*aSize*/ ) |
283 | 0 | { |
284 | 0 | OSL_FAIL( "trying to set size of title" ); |
285 | 0 | } |
286 | | |
287 | | // ____ XShapeDescriptor (base of XShape) ____ |
288 | | OUString SAL_CALL TitleWrapper::getShapeType() |
289 | 0 | { |
290 | 0 | return u"com.sun.star.chart.ChartTitle"_ustr; |
291 | 0 | } |
292 | | |
293 | | // ____ XComponent ____ |
294 | | void SAL_CALL TitleWrapper::dispose() |
295 | 0 | { |
296 | 0 | std::unique_lock g(m_aMutex); |
297 | 0 | Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); |
298 | 0 | m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( xSource ) ); |
299 | |
|
300 | 0 | clearWrappedPropertySet(); |
301 | 0 | } |
302 | | |
303 | | void SAL_CALL TitleWrapper::addEventListener( |
304 | | const Reference< lang::XEventListener >& xListener ) |
305 | 0 | { |
306 | 0 | std::unique_lock g(m_aMutex); |
307 | 0 | m_aEventListenerContainer.addInterface( g, xListener ); |
308 | 0 | } |
309 | | |
310 | | void SAL_CALL TitleWrapper::removeEventListener( |
311 | | const Reference< lang::XEventListener >& aListener ) |
312 | 0 | { |
313 | 0 | std::unique_lock g(m_aMutex); |
314 | 0 | m_aEventListenerContainer.removeInterface( g, aListener ); |
315 | 0 | } |
316 | | |
317 | | void TitleWrapper::getFastCharacterPropertyValue( sal_Int32 nHandle, Any& rValue ) |
318 | 0 | { |
319 | 0 | SAL_WARN_IF( nHandle < FAST_PROPERTY_ID_START_CHAR_PROP || |
320 | 0 | nHandle >= CharacterProperties::FAST_PROPERTY_ID_END_CHAR_PROP, |
321 | 0 | "chart2", "Handle out of range" ); |
322 | | |
323 | 0 | Reference< beans::XPropertySet > xProp = getInnerPropertySet(); |
324 | 0 | Reference< beans::XFastPropertySet > xFastProp( xProp, uno::UNO_QUERY ); |
325 | 0 | if(xProp.is()) |
326 | 0 | { |
327 | 0 | const WrappedProperty* pWrappedProperty = getWrappedProperty( nHandle ); |
328 | 0 | if( pWrappedProperty ) |
329 | 0 | { |
330 | 0 | rValue = pWrappedProperty->getPropertyValue( xProp ); |
331 | 0 | } |
332 | 0 | else if( xFastProp.is() ) |
333 | 0 | { |
334 | 0 | rValue = xFastProp->getFastPropertyValue( nHandle ); |
335 | 0 | } |
336 | 0 | } |
337 | |
|
338 | 0 | } |
339 | | |
340 | | void TitleWrapper::setFastCharacterPropertyValue( |
341 | | sal_Int32 nHandle, const Any& rValue ) |
342 | 0 | { |
343 | 0 | SAL_WARN_IF( nHandle < FAST_PROPERTY_ID_START_CHAR_PROP || |
344 | 0 | nHandle >= CharacterProperties::FAST_PROPERTY_ID_END_CHAR_PROP, |
345 | 0 | "chart2", "Handle out of range" ); |
346 | | |
347 | 0 | Reference< chart2::XTitle > xTitle( getTitleObject() ); |
348 | 0 | if( !xTitle.is()) |
349 | 0 | return; |
350 | | |
351 | 0 | const Sequence< Reference< chart2::XFormattedString > > aStrings( xTitle->getText()); |
352 | 0 | const WrappedProperty* pWrappedProperty = getWrappedProperty( nHandle ); |
353 | |
|
354 | 0 | for( Reference< chart2::XFormattedString > const & formattedStr : aStrings ) |
355 | 0 | { |
356 | 0 | Reference< beans::XFastPropertySet > xFastPropertySet( formattedStr, uno::UNO_QUERY ); |
357 | 0 | Reference< beans::XPropertySet > xPropSet( xFastPropertySet, uno::UNO_QUERY ); |
358 | |
|
359 | 0 | if( pWrappedProperty ) |
360 | 0 | pWrappedProperty->setPropertyValue( rValue, xPropSet ); |
361 | 0 | else if( xFastPropertySet.is() ) |
362 | 0 | xFastPropertySet->setFastPropertyValue( nHandle, rValue ); |
363 | 0 | } |
364 | |
|
365 | 0 | Reference< beans::XPropertySet > xInnerProp = getInnerPropertySet(); |
366 | 0 | Reference< beans::XFastPropertySet > xFastInnerProp( xInnerProp, uno::UNO_QUERY ); |
367 | 0 | if (xInnerProp.is()) |
368 | 0 | { |
369 | 0 | if (pWrappedProperty) |
370 | 0 | pWrappedProperty->setPropertyValue(rValue, xInnerProp); |
371 | 0 | else if (xFastInnerProp.is()) |
372 | 0 | xFastInnerProp->setFastPropertyValue(nHandle, rValue); |
373 | 0 | } |
374 | 0 | } |
375 | | |
376 | | // WrappedPropertySet |
377 | | |
378 | | void SAL_CALL TitleWrapper::setPropertyValue( const OUString& rPropertyName, const Any& rValue ) |
379 | 0 | { |
380 | 0 | sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); |
381 | 0 | if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) ) |
382 | 0 | { |
383 | 0 | setFastCharacterPropertyValue( nHandle, rValue ); |
384 | 0 | } |
385 | 0 | else |
386 | 0 | WrappedPropertySet::setPropertyValue( rPropertyName, rValue ); |
387 | 0 | } |
388 | | |
389 | | Any SAL_CALL TitleWrapper::getPropertyValue( const OUString& rPropertyName ) |
390 | 0 | { |
391 | 0 | Any aRet; |
392 | 0 | sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); |
393 | 0 | if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) ) |
394 | 0 | getFastCharacterPropertyValue( nHandle, aRet ); |
395 | 0 | else |
396 | 0 | aRet = WrappedPropertySet::getPropertyValue( rPropertyName ); |
397 | 0 | return aRet; |
398 | 0 | } |
399 | | |
400 | | beans::PropertyState SAL_CALL TitleWrapper::getPropertyState( const OUString& rPropertyName ) |
401 | 0 | { |
402 | 0 | beans::PropertyState aState( beans::PropertyState_DIRECT_VALUE ); |
403 | |
|
404 | 0 | sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); |
405 | 0 | if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) ) |
406 | 0 | { |
407 | 0 | Reference< beans::XPropertyState > xPropState( getInnerPropertySet(), uno::UNO_QUERY); |
408 | 0 | if( xPropState.is() ) |
409 | 0 | { |
410 | 0 | const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName ); |
411 | 0 | if( pWrappedProperty ) |
412 | 0 | aState = pWrappedProperty->getPropertyState( xPropState ); |
413 | 0 | else |
414 | 0 | aState = xPropState->getPropertyState( rPropertyName ); |
415 | 0 | } |
416 | 0 | } |
417 | 0 | else |
418 | 0 | aState = WrappedPropertySet::getPropertyState( rPropertyName ); |
419 | |
|
420 | 0 | return aState; |
421 | 0 | } |
422 | | void SAL_CALL TitleWrapper::setPropertyToDefault( const OUString& rPropertyName ) |
423 | 0 | { |
424 | 0 | sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); |
425 | 0 | if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) ) |
426 | 0 | { |
427 | 0 | Any aDefault = getPropertyDefault( rPropertyName ); |
428 | 0 | setFastCharacterPropertyValue( nHandle, aDefault ); |
429 | 0 | } |
430 | 0 | else |
431 | 0 | WrappedPropertySet::setPropertyToDefault( rPropertyName ); |
432 | 0 | } |
433 | | Any SAL_CALL TitleWrapper::getPropertyDefault( const OUString& rPropertyName ) |
434 | 0 | { |
435 | 0 | Any aRet; |
436 | |
|
437 | 0 | sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); |
438 | 0 | if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) ) |
439 | 0 | { |
440 | 0 | Reference< beans::XPropertyState > xPropState( getInnerPropertySet(), uno::UNO_QUERY ); |
441 | 0 | if( xPropState.is() ) |
442 | 0 | { |
443 | 0 | const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName ); |
444 | 0 | if( pWrappedProperty ) |
445 | 0 | aRet = pWrappedProperty->getPropertyDefault(xPropState); |
446 | 0 | else |
447 | 0 | aRet = xPropState->getPropertyDefault( rPropertyName ); |
448 | 0 | } |
449 | 0 | } |
450 | 0 | else |
451 | 0 | aRet = WrappedPropertySet::getPropertyDefault( rPropertyName ); |
452 | |
|
453 | 0 | return aRet; |
454 | 0 | } |
455 | | |
456 | | void SAL_CALL TitleWrapper::addPropertyChangeListener( const OUString& rPropertyName, const Reference< beans::XPropertyChangeListener >& xListener ) |
457 | 0 | { |
458 | 0 | sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); |
459 | 0 | if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) ) |
460 | 0 | { |
461 | 0 | Reference< beans::XPropertySet > xPropSet = getInnerPropertySet(); |
462 | 0 | if( xPropSet.is() ) |
463 | 0 | xPropSet->addPropertyChangeListener( rPropertyName, xListener ); |
464 | 0 | } |
465 | 0 | else |
466 | 0 | WrappedPropertySet::addPropertyChangeListener( rPropertyName, xListener ); |
467 | 0 | } |
468 | | void SAL_CALL TitleWrapper::removePropertyChangeListener( const OUString& rPropertyName, const Reference< beans::XPropertyChangeListener >& xListener ) |
469 | 0 | { |
470 | 0 | sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); |
471 | 0 | if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) ) |
472 | 0 | { |
473 | 0 | Reference< beans::XPropertySet > xPropSet = getInnerPropertySet(); |
474 | 0 | if( xPropSet.is() ) |
475 | 0 | xPropSet->removePropertyChangeListener( rPropertyName, xListener ); |
476 | 0 | } |
477 | 0 | else |
478 | 0 | WrappedPropertySet::removePropertyChangeListener( rPropertyName, xListener ); |
479 | 0 | } |
480 | | |
481 | | //ReferenceSizePropertyProvider |
482 | | void TitleWrapper::updateReferenceSize() |
483 | 0 | { |
484 | 0 | Reference< beans::XPropertySet > xProp( getTitleObject(), uno::UNO_QUERY ); |
485 | 0 | if( xProp.is() ) |
486 | 0 | { |
487 | 0 | if( xProp->getPropertyValue( u"ReferencePageSize"_ustr ).hasValue() ) |
488 | 0 | xProp->setPropertyValue( u"ReferencePageSize"_ustr, uno::Any( |
489 | 0 | m_spChart2ModelContact->GetPageSize() )); |
490 | 0 | } |
491 | 0 | } |
492 | | Any TitleWrapper::getReferenceSize() |
493 | 0 | { |
494 | 0 | Any aRet; |
495 | 0 | Reference< beans::XPropertySet > xProp( getTitleObject(), uno::UNO_QUERY ); |
496 | 0 | if( xProp.is() ) |
497 | 0 | aRet = xProp->getPropertyValue( u"ReferencePageSize"_ustr ); |
498 | |
|
499 | 0 | return aRet; |
500 | 0 | } |
501 | | awt::Size TitleWrapper::getCurrentSizeForReference() |
502 | 0 | { |
503 | 0 | return m_spChart2ModelContact->GetPageSize(); |
504 | 0 | } |
505 | | |
506 | | Reference< chart2::XTitle > TitleWrapper::getTitleObject() |
507 | 0 | { |
508 | 0 | return TitleHelper::getTitle( m_eTitleType, m_spChart2ModelContact->getDocumentModel() ); |
509 | 0 | } |
510 | | |
511 | | // WrappedPropertySet |
512 | | |
513 | | Reference< beans::XPropertySet > TitleWrapper::getInnerPropertySet() |
514 | 0 | { |
515 | 0 | return Reference< beans::XPropertySet >( getTitleObject(), uno::UNO_QUERY ); |
516 | 0 | } |
517 | | |
518 | | const Sequence< beans::Property >& TitleWrapper::getPropertySequence() |
519 | 0 | { |
520 | 0 | return StaticTitleWrapperPropertyArray(); |
521 | 0 | } |
522 | | |
523 | | std::vector< std::unique_ptr<WrappedProperty> > TitleWrapper::createWrappedProperties() |
524 | 0 | { |
525 | 0 | std::vector< std::unique_ptr<WrappedProperty> > aWrappedProperties; |
526 | |
|
527 | 0 | aWrappedProperties.emplace_back( new WrappedTitleStringProperty( m_spChart2ModelContact->m_xContext ) ); |
528 | 0 | aWrappedProperties.emplace_back( new WrappedTitleFormStringsProperty() ); |
529 | 0 | aWrappedProperties.emplace_back( new WrappedTextRotationProperty( true ) ); |
530 | 0 | aWrappedProperties.emplace_back( new WrappedStackedTextProperty() ); |
531 | 0 | WrappedCharacterHeightProperty::addWrappedProperties( aWrappedProperties, this ); |
532 | 0 | WrappedAutomaticPositionProperties::addWrappedProperties( aWrappedProperties ); |
533 | 0 | WrappedScaleTextProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact ); |
534 | |
|
535 | 0 | return aWrappedProperties; |
536 | 0 | } |
537 | | |
538 | | OUString SAL_CALL TitleWrapper::getImplementationName() |
539 | 0 | { |
540 | 0 | return u"com.sun.star.comp.chart.Title"_ustr; |
541 | 0 | } |
542 | | |
543 | | sal_Bool SAL_CALL TitleWrapper::supportsService( const OUString& rServiceName ) |
544 | 0 | { |
545 | 0 | return cppu::supportsService(this, rServiceName); |
546 | 0 | } |
547 | | |
548 | | css::uno::Sequence< OUString > SAL_CALL TitleWrapper::getSupportedServiceNames() |
549 | 0 | { |
550 | 0 | return { |
551 | 0 | u"com.sun.star.chart.ChartTitle"_ustr, |
552 | 0 | u"com.sun.star.drawing.Shape"_ustr, |
553 | 0 | u"com.sun.star.xml.UserDefinedAttributesSupplier"_ustr, |
554 | 0 | u"com.sun.star.style.CharacterProperties"_ustr |
555 | 0 | }; |
556 | 0 | } |
557 | | |
558 | | } // namespace chart |
559 | | |
560 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |