LibreOffice Module oox (master) 1
propertymap.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
21
22#if OSL_DEBUG_LEVEL > 0
23# include <cstdio>
24# include <com/sun/star/style/LineSpacing.hpp>
25# include <com/sun/star/text/WritingMode.hpp>
26using ::com::sun::star::style::LineSpacing;
27using ::com::sun::star::text::WritingMode;
29#include <iostream>
30#endif
31
32#include <com/sun/star/beans/PropertyValue.hpp>
33#include <com/sun/star/beans/XPropertySet.hpp>
34#include <com/sun/star/beans/XPropertySetInfo.hpp>
35#include <com/sun/star/container/XIndexReplace.hpp>
36#include <com/sun/star/awt/Rectangle.hpp>
37#include <com/sun/star/awt/Size.hpp>
38#include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
39#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
40#include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
41#include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
42#include <com/sun/star/drawing/EnhancedCustomShapeTextFrame.hpp>
43#include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
44#include <com/sun/star/drawing/EnhancedCustomShapeParameterType.hpp>
45#include <com/sun/star/drawing/HomogenMatrix3.hpp>
47#include <osl/diagnose.h>
48#include <mutex>
49#include <sal/log.hxx>
50#include <oox/token/properties.hxx>
52using ::com::sun::star::uno::Any;
53using ::com::sun::star::uno::Reference;
54using ::com::sun::star::uno::Sequence;
55using ::com::sun::star::beans::Property;
56using ::com::sun::star::beans::PropertyValue;
57using ::com::sun::star::beans::UnknownPropertyException;
58using ::com::sun::star::beans::XPropertyChangeListener;
59using ::com::sun::star::beans::XPropertySet;
60using ::com::sun::star::beans::XPropertySetInfo;
61using ::com::sun::star::beans::XVetoableChangeListener;
62using ::com::sun::star::container::XIndexReplace;
63
64#if OSL_DEBUG_LEVEL > 0
65#define USS(x) OUStringToOString( x, RTL_TEXTENCODING_UTF8 ).getStr()
66using namespace ::com::sun::star;
67using namespace ::com::sun::star::drawing;
68using namespace ::com::sun::star::uno;
69using ::com::sun::star::style::LineSpacing;
70using ::com::sun::star::text::WritingMode;
71using ::com::sun::star::drawing::TextHorizontalAdjust;
72using ::com::sun::star::drawing::TextVerticalAdjust;
73#endif
74
75namespace oox {
76
77using namespace ::com::sun::star::beans;
78using namespace ::com::sun::star::lang;
79using namespace ::com::sun::star::drawing;
80using namespace ::com::sun::star::uno;
81
82namespace {
83
89class GenericPropertySet : public ::cppu::WeakImplHelper< XPropertySet, XPropertySetInfo >
90{
91public:
92 explicit GenericPropertySet( const PropertyMap& rPropMap );
93
94 // XPropertySet
95 virtual Reference< XPropertySetInfo > SAL_CALL getPropertySetInfo() override;
96 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const Any& aValue ) override;
97 virtual Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
98 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const Reference< XPropertyChangeListener >& xListener ) override;
99 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const Reference< XPropertyChangeListener >& aListener ) override;
100 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const Reference< XVetoableChangeListener >& aListener ) override;
101 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const Reference< XVetoableChangeListener >& aListener ) override;
102
103 // XPropertySetInfo
104 virtual Sequence< Property > SAL_CALL getProperties() override;
105 virtual Property SAL_CALL getPropertyByName( const OUString& aName ) override;
106 virtual sal_Bool SAL_CALL hasPropertyByName( const OUString& Name ) override;
107
108private:
109 std::mutex mMutex;
110 PropertyNameMap maPropMap;
111};
112
113GenericPropertySet::GenericPropertySet( const PropertyMap& rPropMap )
114{
115 rPropMap.fillPropertyNameMap(maPropMap);
116}
117
118Reference< XPropertySetInfo > SAL_CALL GenericPropertySet::getPropertySetInfo()
119{
120 return this;
121}
122
123void SAL_CALL GenericPropertySet::setPropertyValue( const OUString& rPropertyName, const Any& rValue )
124{
125 std::scoped_lock aGuard( mMutex );
126 maPropMap[ rPropertyName ] = rValue;
127}
128
129Any SAL_CALL GenericPropertySet::getPropertyValue( const OUString& rPropertyName )
130{
131 PropertyNameMap::iterator aIt = maPropMap.find( rPropertyName );
132 if( aIt == maPropMap.end() )
133 throw UnknownPropertyException(rPropertyName);
134 return aIt->second;
135}
136
137// listeners are not supported by this implementation
138void SAL_CALL GenericPropertySet::addPropertyChangeListener( const OUString& , const Reference< XPropertyChangeListener >& ) {}
139void SAL_CALL GenericPropertySet::removePropertyChangeListener( const OUString& , const Reference< XPropertyChangeListener >& ) {}
140void SAL_CALL GenericPropertySet::addVetoableChangeListener( const OUString& , const Reference< XVetoableChangeListener >& ) {}
141void SAL_CALL GenericPropertySet::removeVetoableChangeListener( const OUString& , const Reference< XVetoableChangeListener >& ) {}
142
143// XPropertySetInfo
144Sequence< Property > SAL_CALL GenericPropertySet::getProperties()
145{
146 Sequence< Property > aSeq( static_cast< sal_Int32 >( maPropMap.size() ) );
147 Property* pProperty = aSeq.getArray();
148 for (auto const& prop : maPropMap)
149 {
150 pProperty->Name = prop.first;
151 pProperty->Handle = 0;
152 pProperty->Type = prop.second.getValueType();
153 pProperty->Attributes = 0;
154 ++pProperty;
155 }
156 return aSeq;
157}
158
159Property SAL_CALL GenericPropertySet::getPropertyByName( const OUString& rPropertyName )
160{
161 PropertyNameMap::iterator aIt = maPropMap.find( rPropertyName );
162 if( aIt == maPropMap.end() )
163 throw UnknownPropertyException(rPropertyName);
164 Property aProperty;
165 aProperty.Name = aIt->first;
166 aProperty.Handle = 0;
167 aProperty.Type = aIt->second.getValueType();
168 aProperty.Attributes = 0;
169 return aProperty;
170}
171
172sal_Bool SAL_CALL GenericPropertySet::hasPropertyByName( const OUString& rPropertyName )
173{
174 return maPropMap.find( rPropertyName ) != maPropMap.end();
175}
176
177} // namespace
178
180 mpPropNames( &GetPropertyNameVector() ) // pointer instead reference to get compiler generated copy c'tor and operator=
181{
182}
183
184bool PropertyMap::hasProperty( sal_Int32 nPropId ) const
185{
186 return maProperties.find( nPropId ) != maProperties.end();
187}
188
189bool PropertyMap::setAnyProperty( sal_Int32 nPropId, const Any& rValue )
190{
191 if( nPropId < 0 )
192 return false;
193
194 maProperties[ nPropId ] = rValue;
195 return true;
196}
197
198Any PropertyMap::getProperty( sal_Int32 nPropId )
199{
200 return maProperties[ nPropId ];
201}
202
203void PropertyMap::erase( sal_Int32 nPropId )
204{
205 maProperties.erase(nPropId);
206}
207
209{
210 return maProperties.empty();
211}
212
214{
215 maProperties.insert(rPropMap.maProperties.begin(), rPropMap.maProperties.end());
216}
217
218const OUString& PropertyMap::getPropertyName( sal_Int32 nPropId )
219{
220 OSL_ENSURE( (0 <= nPropId) && (nPropId < PROP_COUNT), "PropertyMap::getPropertyName - invalid property identifier" );
221 return GetPropertyNameVector()[ nPropId ];
222}
223
224sal_Int32 PropertyMap::getPropertyId( std::u16string_view sPropName )
225{
226 // This may use a std::map to get faster from String to ID in the
227 // future, inside the [0..PROP_COUNT[ entries. Since it is currently
228 // only used for Diagram re-creation I opted for less memory usage here
229 if(sPropName.empty())
230 return -1;
231
232 const std::vector<OUString>& rVec(GetPropertyNameVector());
233 for(size_t a(0); a < rVec.size(); a++)
234 if(rVec[a] == sPropName)
235 return a;
236
237 return -1;
238}
239
240void PropertyMap::assignAll( const PropertyMap& rPropMap )
241{
242 for (auto const& prop : rPropMap.maProperties)
243 maProperties[prop.first] = prop.second;
244}
245
246Sequence< PropertyValue > PropertyMap::makePropertyValueSequence() const
247{
248 Sequence< PropertyValue > aSeq( static_cast< sal_Int32 >( maProperties.size() ) );
249 PropertyValue* pValues = aSeq.getArray();
250 for (auto const& prop : maProperties)
251 {
252 OSL_ENSURE( (0 <= prop.first) && (prop.first < PROP_COUNT), "PropertyMap::makePropertyValueSequence - invalid property identifier" );
253 pValues->Name = (*mpPropNames)[ prop.first ];
254 pValues->Value = prop.second;
255 pValues->State = PropertyState_DIRECT_VALUE;
256 ++pValues;
257 }
258 return aSeq;
259}
260
261void PropertyMap::fillSequences( Sequence< OUString >& rNames, Sequence< Any >& rValues ) const
262{
263 rNames.realloc( static_cast< sal_Int32 >( maProperties.size() ) );
264 rValues.realloc( static_cast< sal_Int32 >( maProperties.size() ) );
265 if( maProperties.empty() )
266 return;
267
268 OUString* pNames = rNames.getArray();
269 Any* pValues = rValues.getArray();
270 for (auto const& prop : maProperties)
271 {
272 OSL_ENSURE( (0 <= prop.first) && (prop.first < PROP_COUNT), "PropertyMap::fillSequences - invalid property identifier" );
273 *pNames = (*mpPropNames)[ prop.first ];
274 *pValues = prop.second;
275 ++pNames;
276 ++pValues;
277 }
278}
279
281{
282 for (auto const& prop : maProperties)
283 {
284 rMap.insert(std::pair<OUString, Any>((*mpPropNames)[prop.first], prop.second));
285 }
286}
287
288Reference< XPropertySet > PropertyMap::makePropertySet() const
289{
290 return new GenericPropertySet( *this );
291}
292
293#if OSL_DEBUG_LEVEL > 0
294static void lclDumpAnyValue( const Any& value)
295{
296 OUString strValue;
297 Sequence< OUString > strArray;
298 Sequence< Any > anyArray;
299 Sequence< PropertyValue > propArray;
300 Sequence< Sequence< PropertyValue > > propArrayArray;
301 Sequence< EnhancedCustomShapeAdjustmentValue > adjArray;
302 Sequence< EnhancedCustomShapeSegment > segArray;
303 Sequence< EnhancedCustomShapeParameterPair > ppArray;
304 EnhancedCustomShapeSegment segment;
305 EnhancedCustomShapeParameterPair pp;
306 EnhancedCustomShapeParameter par;
307 HomogenMatrix3 aMatrix;
308 sal_Int32 intValue = 0;
309 sal_uInt32 uintValue = 0;
310 sal_Int16 int16Value = 0;
311 sal_uInt16 uint16Value = 0;
312 float floatValue = 0;
313 bool boolValue = false;
314 LineSpacing spacing;
315// RectanglePoint pointValue;
316 WritingMode aWritingMode;
317 TextVerticalAdjust aTextVertAdj;
318 TextHorizontalAdjust aTextHorizAdj;
319 Reference< XIndexReplace > xNumRule;
320
321 if( value >>= strValue )
322 fprintf (stderr,"\"%s\"\n", USS( strValue ) );
323 else if( value >>= strArray ) {
324 fprintf (stderr,"%s\n", USS(value.getValueTypeName()));
325 for( int i=0; i<strArray.getLength(); i++ )
326 fprintf (stderr,"\t\t\t[%3d] \"%s\"\n", i, USS( strArray[i] ) );
327 } else if( value >>= propArray ) {
328 fprintf (stderr,"%s\n", USS(value.getValueTypeName()));
329 for( int i=0; i<propArray.getLength(); i++ ) {
330 fprintf (stderr,"\t\t\t[%3d] %s (%s) ", i, USS( propArray[i].Name ), USS(propArray[i].Value.getValueTypeName()) );
331 lclDumpAnyValue( propArray[i].Value );
332 }
333 } else if( value >>= propArrayArray ) {
334 fprintf (stderr,"%s\n", USS(value.getValueTypeName()));
335 for( int i=0; i<propArrayArray.getLength(); i++ ) {
336 fprintf (stderr,"\t\t\t[%3d] ", i);
337 lclDumpAnyValue( Any (propArrayArray[i]) );
338 }
339 } else if( value >>= anyArray ) {
340 fprintf (stderr,"%s\n", USS(value.getValueTypeName()));
341 for( int i=0; i<anyArray.getLength(); i++ ) {
342 fprintf (stderr,"\t\t\t[%3d] (%s) ", i, USS(value.getValueTypeName()) );
343 lclDumpAnyValue( anyArray[i] );
344 }
345 } else if( value >>= adjArray ) {
346 fprintf (stderr,"%s\n", USS(value.getValueTypeName()));
347 for( int i=0; i<adjArray.getLength(); i++ ) {
348 fprintf (stderr,"\t\t\t[%3d] (%s) ", i, USS(adjArray[i].Value.getValueTypeName()) );
349 lclDumpAnyValue( adjArray[i].Value );
350 }
351 } else if( value >>= segArray ) {
352 fprintf (stderr,"%s\n", USS(value.getValueTypeName()));
353 for( int i=0; i<segArray.getLength(); i++ ) {
354 fprintf (stderr,"\t\t\t[%3d] ", i );
355 lclDumpAnyValue( Any( segArray[i] ) );
356 }
357 } else if( value >>= ppArray ) {
358 fprintf (stderr,"%s\n", USS(value.getValueTypeName()));
359 for( int i=0; i<ppArray.getLength(); i++ ) {
360 fprintf (stderr,"\t\t\t[%3d] ", i );
361 lclDumpAnyValue( Any( ppArray[i] ) );
362 }
363 } else if( value >>= segment ) {
364 fprintf (stderr,"Command: %d Count: %d\n", segment.Command, segment.Count);
365 } else if( value >>= pp ) {
366 fprintf (stderr,"First: ");
367 lclDumpAnyValue( Any (pp.First) );
368 fprintf (stderr,"\t\t\t Second: ");
369 lclDumpAnyValue( Any (pp.Second) );
370 } else if( value >>= par ) {
371 fprintf (stderr,"Parameter (%s): ", USS(par.Value.getValueTypeName()));
372 lclDumpAnyValue( par.Value );
373 } else if( value >>= aMatrix ) {
374 fprintf (stderr,"Matrix\n%f %f %f\n%f %f %f\n%f %f %f\n", aMatrix.Line1.Column1, aMatrix.Line1.Column2, aMatrix.Line1.Column3, aMatrix.Line2.Column1, aMatrix.Line2.Column2, aMatrix.Line2.Column3, aMatrix.Line3.Column1, aMatrix.Line3.Column2, aMatrix.Line3.Column3);
375 } else if( value >>= intValue )
376 fprintf (stderr,"%-10" SAL_PRIdINT32 " (hex: %" SAL_PRIxUINT32 ")\n", intValue, intValue);
377 else if( value >>= uintValue )
378 fprintf (stderr,"%-10" SAL_PRIuUINT32 " (hex: %" SAL_PRIxUINT32 ")\n", uintValue, uintValue);
379 else if( value >>= int16Value )
380 fprintf (stderr,"%-10d (hex: %x)\n", int16Value, int16Value);
381 else if( value >>= uint16Value )
382 fprintf (stderr,"%-10d (hex: %x)\n", uint16Value, uint16Value);
383 else if( value >>= floatValue )
384 fprintf (stderr,"%f\n", floatValue);
385 else if( value >>= boolValue )
386 fprintf (stderr,"%-10d (bool)\n", boolValue);
387 else if( value >>= xNumRule ) {
388 fprintf (stderr, "XIndexReplace\n");
389 if (xNumRule.is()) {
390 for (int k=0; k<xNumRule->getCount(); k++) {
391 Sequence< PropertyValue > aBulletPropSeq;
392 fprintf (stderr, "level %d\n", k);
393 if (xNumRule->getByIndex (k) >>= aBulletPropSeq) {
394 for (const PropertyValue& rProp : std::as_const(aBulletPropSeq)) {
395 fprintf(stderr, "%46s = ", USS (rProp.Name));
396 lclDumpAnyValue (rProp.Value);
397 }
398 }
399 }
400 } else {
401 fprintf (stderr, "empty reference\n");
402 }
403 } else if( value >>= aWritingMode )
404 fprintf(stderr, "%d writing mode\n", static_cast<int>(aWritingMode));
405 else if( value >>= aTextVertAdj ) {
406 const char* s = "unknown";
407 switch( aTextVertAdj ) {
408 case TextVerticalAdjust_TOP:
409 s = "top";
410 break;
411 case TextVerticalAdjust_CENTER:
412 s = "center";
413 break;
414 case TextVerticalAdjust_BOTTOM:
415 s = "bottom";
416 break;
417 case TextVerticalAdjust_BLOCK:
418 s = "block";
419 break;
420 case TextVerticalAdjust::TextVerticalAdjust_MAKE_FIXED_SIZE:
421 s = "make_fixed_size";
422 break;
423 }
424 fprintf (stderr, "%s\n", s);
425 } else if( value >>= aTextHorizAdj ) {
426 const char* s = "unknown";
427 switch( aTextHorizAdj ) {
428 case TextHorizontalAdjust_LEFT:
429 s = "left";
430 break;
431 case TextHorizontalAdjust_CENTER:
432 s = "center";
433 break;
434 case TextHorizontalAdjust_RIGHT:
435 s = "right";
436 break;
437 case TextHorizontalAdjust_BLOCK:
438 s = "block";
439 break;
440 case TextHorizontalAdjust::TextHorizontalAdjust_MAKE_FIXED_SIZE:
441 s = "make_fixed_size";
442 break;
443 }
444 fprintf (stderr, "%s\n", s);
445 } else if( value >>= spacing ) {
446 fprintf (stderr, "mode: %d value: %d\n", spacing.Mode, spacing.Height);
447 } else if( value.isExtractableTo(::cppu::UnoType<sal_Int32>::get())) {
448 fprintf (stderr,"is extractable to int32\n");
449 }
450// else if( value >>= pointValue )
451// fprintf (stderr,"%d (RectanglePoint)\n", pointValue);
452 else
453 fprintf (stderr,"??? <unhandled type %s>\n", USS(value.getValueTypeName()));
454}
455
456#ifdef DBG_UTIL
457void PropertyMap::dump( const Reference< XPropertySet >& rXPropSet )
458{
459 Reference< XPropertySetInfo > info = rXPropSet->getPropertySetInfo ();
460 const Sequence< Property > props = info->getProperties ();
461
462 SAL_INFO("oox", "dump props, len: " << props.getLength ());
463
464 for (Property const & prop : props) {
465 OString name = OUStringToOString( prop.Name, RTL_TEXTENCODING_UTF8);
466 fprintf (stderr,"%30s = ", name.getStr() );
467
468 try {
469 lclDumpAnyValue (rXPropSet->getPropertyValue( prop.Name ));
470 } catch (const Exception&) {
471 fprintf (stderr,"unable to get '%s' value\n", USS(prop.Name));
472 }
473 }
474}
475#endif
476
477static void printLevel (int level)
478{
479 for (int i=0; i<level; i++)
480 fprintf (stderr, " ");
481}
482
483static const char *lclGetEnhancedParameterType( sal_uInt16 nType )
484{
485 const char* type;
486 switch (nType) {
487 case EnhancedCustomShapeParameterType::NORMAL:
488 type = "EnhancedCustomShapeParameterType::NORMAL";
489 break;
490 case EnhancedCustomShapeParameterType::EQUATION:
491 type = "EnhancedCustomShapeParameterType::EQUATION";
492 break;
493 case EnhancedCustomShapeParameterType::ADJUSTMENT:
494 type = "EnhancedCustomShapeParameterType::ADJUSTMENT";
495 break;
496 case EnhancedCustomShapeParameterType::LEFT:
497 type = "EnhancedCustomShapeParameterType::LEFT";
498 break;
499 case EnhancedCustomShapeParameterType::TOP:
500 type = "EnhancedCustomShapeParameterType::TOP";
501 break;
502 case EnhancedCustomShapeParameterType::RIGHT:
503 type = "EnhancedCustomShapeParameterType::RIGHT";
504 break;
505 case EnhancedCustomShapeParameterType::BOTTOM:
506 type = "EnhancedCustomShapeParameterType::BOTTOM";
507 break;
508 case EnhancedCustomShapeParameterType::XSTRETCH:
509 type = "EnhancedCustomShapeParameterType::XSTRETCH";
510 break;
511 case EnhancedCustomShapeParameterType::YSTRETCH:
512 type = "EnhancedCustomShapeParameterType::YSTRETCH";
513 break;
514 case EnhancedCustomShapeParameterType::HASSTROKE:
515 type = "EnhancedCustomShapeParameterType::HASSTROKE";
516 break;
517 case EnhancedCustomShapeParameterType::HASFILL:
518 type = "EnhancedCustomShapeParameterType::HASFILL";
519 break;
520 case EnhancedCustomShapeParameterType::WIDTH:
521 type = "EnhancedCustomShapeParameterType::WIDTH";
522 break;
523 case EnhancedCustomShapeParameterType::HEIGHT:
524 type = "EnhancedCustomShapeParameterType::HEIGHT";
525 break;
526 case EnhancedCustomShapeParameterType::LOGWIDTH:
527 type = "EnhancedCustomShapeParameterType::LOGWIDTH";
528 break;
529 case EnhancedCustomShapeParameterType::LOGHEIGHT:
530 type = "EnhancedCustomShapeParameterType::LOGHEIGHT";
531 break;
532 default:
533 type = "unknown";
534 break;
535 }
536 return type;
537}
538
539static void printParameterPairData(int level, EnhancedCustomShapeParameterPair const &pp)
540{
541 // These are always sal_Int32s so lets depend on that for our packing ...
542 sal_Int32 nFirstValue = {};
543 sal_Int32 nSecondValue = {}; // spurious -Werror=maybe-uninitialized
544 if (!(pp.First.Value >>= nFirstValue))
545 assert (false);
546 if (!(pp.Second.Value >>= nSecondValue))
547 assert (false);
548
549 printLevel (level);
550 fprintf (stderr, "{\n");
551 printLevel (level + 1);
552 fprintf (stderr, "%s,\n", lclGetEnhancedParameterType(pp.First.Type));
553 printLevel (level + 1);
554 fprintf (stderr, "%s,\n", lclGetEnhancedParameterType(pp.Second.Type));
555 printLevel (level + 1);
556 fprintf (stderr, "%d, %d\n", static_cast<int>(nFirstValue), static_cast<int>(nSecondValue));
557 printLevel (level);
558 fprintf (stderr, "}");
559}
560
561static const char* lclDumpAnyValueCode( const Any& value, int level)
562{
563 OUString strValue;
564 Sequence< OUString > strArray;
565 Sequence< Any > anyArray;
566 Sequence< awt::Size > sizeArray;
567 Sequence< PropertyValue > propArray;
568 Sequence< Sequence< PropertyValue > > propArrayArray;
569 Sequence< EnhancedCustomShapeAdjustmentValue > adjArray;
570 Sequence< EnhancedCustomShapeTextFrame > segTextFrame;
571 Sequence< EnhancedCustomShapeSegment > segArray;
572 Sequence< EnhancedCustomShapeParameterPair > ppArray;
573 EnhancedCustomShapeSegment segment;
574 EnhancedCustomShapeTextFrame textFrame;
575 EnhancedCustomShapeParameterPair pp;
576 EnhancedCustomShapeParameter par;
577 awt::Rectangle rect;
578 awt::Size size;
579 sal_Int32 intValue;
580 sal_uInt32 uintValue;
581 sal_Int16 int16Value;
582 sal_uInt16 uint16Value;
583 sal_Int64 int64Value;
584 float floatValue = 0;
585 bool boolValue;
586 LineSpacing spacing;
587// RectanglePoint pointValue;
588 WritingMode aWritingMode;
589 TextVerticalAdjust aTextVertAdj;
590 TextHorizontalAdjust aTextHorizAdj;
591 Reference< XIndexReplace > xNumRule;
592
593 if( value >>= strValue )
594 {
595 printLevel (level);
596 fprintf (stderr,"OUString str = \"%s\";\n", USS( strValue ) );
597 return "Any (str)";
598 }
599 else if( value >>= strArray )
600 {
601 if (strArray.getLength() == 0)
602 return "Sequence< OUString >(0)";
603
604 printLevel (level);
605 fprintf (stderr,"static const char *aStrings[] = {\n");
606 for( int i=0; i<strArray.getLength(); i++ ) {
607 printLevel (level + 1);
608 fprintf (stderr,"\"%s\"%s\n", USS( strArray[i] ), i < strArray.getLength() - 1 ? "," : "" );
609 }
610 printLevel (level);
611 fprintf (stderr,"};\n");
612 return "createStringSequence( SAL_N_ELEMENTS( aStrings ), aStrings )";
613 }
614 else if( value >>= propArray )
615 {
616 printLevel (level);
617 fprintf (stderr,"Sequence< PropertyValue > aPropSequence (%" SAL_PRIdINT32 ");\n", propArray.getLength());
618 for( int i=0; i<propArray.getLength(); i++ ) {
619 printLevel (level);
620 fprintf (stderr, "{\n");
621 printLevel (level + 1);
622 fprintf (stderr, "aPropSequence [%d].Name = \"%s\";\n", i, USS( propArray[i].Name ));
623 const char *var = lclDumpAnyValueCode( propArray[i].Value, level + 1 );
624 printLevel (level + 1);
625 fprintf (stderr, "aPropSequence [%d].Value = makeAny (%s);\n", i, var);
626 printLevel (level);
627 fprintf (stderr, "}\n");
628 }
629 return "aPropSequence";
630 }
631 else if( value >>= sizeArray )
632 {
633 printLevel (level);
634 fprintf (stderr, "Sequence< awt::Size > aSizeSequence (%" SAL_PRIdINT32 ");\n", sizeArray.getLength());
635 for( int i=0; i<sizeArray.getLength(); i++ ) {
636 printLevel (level);
637 fprintf (stderr, "{\n");
638 const char *var = lclDumpAnyValueCode (Any (sizeArray[i]), level + 1);
639 printLevel (level + 1);
640 fprintf (stderr, "aSizeSequence [%d] = %s;\n", i, var);
641 printLevel (level);
642 fprintf (stderr, "}\n");
643 }
644 return "aSizeSequence";
645 }
646 else if( value >>= propArrayArray )
647 {
648 printLevel (level);
649 fprintf (stderr,"Sequence< Sequence < PropertyValue > > aPropSequenceSequence (%" SAL_PRIdINT32 ");\n", propArrayArray.getLength());
650 for( int i=0; i<propArrayArray.getLength(); i++ ) {
651 printLevel (level);
652 fprintf (stderr, "{\n");
653 const char *var = lclDumpAnyValueCode( Any (propArrayArray[i]), level + 1 );
654 printLevel (level + 1);
655 fprintf (stderr, "aPropSequenceSequence [%d] = %s;\n", i, var);
656 printLevel (level);
657 fprintf (stderr, "}\n");
658 }
659 return "aPropSequenceSequence";
660 }
661 else if( value >>= anyArray )
662 {
663 fprintf (stderr,"%s\n", USS(value.getValueTypeName()));
664 for( int i=0; i<anyArray.getLength(); i++ ) {
665 fprintf (stderr,"\t\t\t[%3d] (%s) ", i, USS(value.getValueTypeName()) );
666 lclDumpAnyValue( anyArray[i] );
667 }
668 }
669 else if( value >>= adjArray )
670 {
671 printLevel (level);
672 fprintf (stderr,"Sequence< EnhancedCustomShapeAdjustmentValue > aAdjSequence (%" SAL_PRIdINT32 ");\n", adjArray.getLength());
673 for( int i=0; i<adjArray.getLength(); i++ ) {
674 printLevel (level);
675 fprintf (stderr, "{\n");
676 const char *var = lclDumpAnyValueCode( adjArray[i].Value, level + 1 );
677 printLevel (level + 1);
678 fprintf (stderr, "aAdjSequence [%d].Value = %s;\n", i, var);
679 if (adjArray[i].Name.getLength() > 0) {
680 printLevel (level + 1);
681 fprintf (stderr, "aAdjSequence [%d].Name = \"%s\";\n", i, USS (adjArray[i].Name));
682 }
683 printLevel (level);
684 fprintf (stderr, "}\n");
685 }
686 return "aAdjSequence";
687 }
688 else if( value >>= segArray )
689 {
690 if (segArray.getLength() == 0)
691 return "Sequence< EnhancedCustomShapeSegment >(0)";
692
693 printLevel (level);
694 fprintf (stderr,"static const sal_uInt16 nValues[] = {\n");
695 printLevel (level);
696 fprintf (stderr,"// Command, Count\n");
697 for( int i = 0; i < segArray.getLength(); i++ ) {
698 printLevel (level + 1);
699 fprintf (stderr,"%d,%d%s\n", segArray[i].Command,
700 segArray[i].Count, i < segArray.getLength() - 1 ? "," : "");
701 }
702 printLevel (level);
703 fprintf (stderr,"};\n");
704 return "createSegmentSequence( SAL_N_ELEMENTS( nValues ), nValues )";
705 }
706 else if( value >>= segTextFrame )
707 {
708 printLevel (level);
709 fprintf (stderr, "Sequence< EnhancedCustomShapeTextFrame > aTextFrameSeq (%" SAL_PRIdINT32 ");\n", segTextFrame.getLength());
710 for( int i=0; i<segTextFrame.getLength(); i++ ) {
711 printLevel (level);
712 fprintf (stderr, "{\n");
713 const char *var = lclDumpAnyValueCode (Any (segTextFrame[i]), level + 1);
714 printLevel (level + 1);
715 fprintf (stderr, "aTextFrameSeq [%d] = %s;\n", i, var);
716 printLevel (level);
717 fprintf (stderr, "}\n");
718 }
719 return "aTextFrameSeq";
720 }
721 else if( value >>= ppArray )
722 {
723 printLevel (level);
724 if (ppArray.getLength() == 0)
725 return "Sequence< EnhancedCustomShapeParameterPair >(0)";
726
727 fprintf (stderr, "static const CustomShapeProvider::ParameterPairData aData[] = {\n");
728 for( int i = 0; i < ppArray.getLength(); i++ ) {
729 printParameterPairData(level + 1, ppArray[i]);
730 fprintf (stderr,"%s\n", i < ppArray.getLength() - 1 ? "," : "");
731 }
732 printLevel (level);
733 fprintf (stderr,"};\n");
734
735 return "createParameterPairSequence(SAL_N_ELEMENTS(aData), aData)";
736 }
737 else if( value >>= segment )
738 {
739 printLevel (level);
740 fprintf (stderr, "EnhancedCustomShapeSegment aSegment;\n");
741 printLevel (level);
742 // TODO: use EnhancedCustomShapeSegmentCommand constants
743 fprintf (stderr, "aSegment.Command = %d;\n", segment.Command);
744 printLevel (level);
745 fprintf (stderr, "aSegment.Count = %d;\n", segment.Count);
746 return "aSegment";
747 }
748 else if( value >>= textFrame )
749 {
750 printLevel (level);
751 fprintf (stderr, "EnhancedCustomShapeTextFrame aTextFrame;\n");
752 printLevel (level);
753 fprintf (stderr, "{\n");
754 {
755 const char* var = lclDumpAnyValueCode( Any (textFrame.TopLeft), level + 1 );
756 printLevel (level + 1);
757 fprintf (stderr, "aTextFrame.TopLeft = %s;\n", var);
758 }
759 printLevel (level);
760 fprintf (stderr, "}\n");
761
762 printLevel (level);
763 fprintf (stderr, "{\n");
764 {
765 const char* var = lclDumpAnyValueCode( Any (textFrame.BottomRight), level + 1 );
766 printLevel (level + 1);
767 fprintf (stderr, "aTextFrame.BottomRight = %s;\n", var);
768 }
769 printLevel (level);
770 fprintf (stderr, "}\n");
771
772 return "aTextFrame";
773 }
774 else if( value >>= pp )
775 {
776 printLevel (level);
777 fprintf (stderr, "static const CustomShapeProvider::ParameterPairData aData =\n");
778 printParameterPairData(level, pp);
779 fprintf (stderr, ";\n");
780
781 return "createParameterPair(&aData)";
782 }
783 else if( value >>= par )
784 {
785 printLevel (level);
786 fprintf (stderr,"EnhancedCustomShapeParameter aParameter;\n");
787 const char* var = lclDumpAnyValueCode( par.Value, level );
788 printLevel (level);
789 fprintf (stderr,"aParameter.Value = %s;\n", var);
790 printLevel (level);
791 fprintf (stderr,"aParameter.Type = %s;\n",
793 return "aParameter";
794 }
795 else if( value >>= int64Value )
796 {
797 printLevel (level);
798 fprintf (stderr,"Any aAny ((sal_Int64) %" SAL_PRIdINT64 ");\n", int64Value);
799 return "aAny";
800 }
801 else if( value >>= intValue )
802 fprintf (stderr,"%" SAL_PRIdINT32 " (hex: %" SAL_PRIxUINT32 ")\n", intValue, intValue);
803 else if( value >>= uintValue )
804 fprintf (stderr,"%" SAL_PRIdINT32 " (hex: %" SAL_PRIxUINT32 ")\n", uintValue, uintValue);
805 else if( value >>= int16Value )
806 fprintf (stderr,"%d (hex: %x)\n", int16Value, int16Value);
807 else if( value >>= uint16Value )
808 fprintf (stderr,"%d (hex: %x)\n", uint16Value, uint16Value);
809 else if( value >>= floatValue )
810 fprintf (stderr,"%f\n", floatValue);
811 else if( value >>= boolValue ) {
812 if (boolValue)
813 return "(sal_Bool) sal_True";
814 else
815 return "(sal_Bool) sal_False";
816 }
817 else if( value >>= xNumRule ) {
818 fprintf (stderr, "XIndexReplace\n");
819 for (int k=0; k<xNumRule->getCount(); k++) {
820 Sequence< PropertyValue > aBulletPropSeq;
821 fprintf (stderr, "level %d\n", k);
822 if (xNumRule->getByIndex (k) >>= aBulletPropSeq) {
823 for (const PropertyValue& rProp : std::as_const(aBulletPropSeq)) {
824 fprintf(stderr, "%46s = ", USS (rProp.Name));
825 lclDumpAnyValue (rProp.Value);
826 }
827 }
828 }
829 }
830 else if( value >>= aWritingMode )
831 fprintf (stderr, "%d writing mode\n", static_cast<int>(aWritingMode));
832 else if( value >>= aTextVertAdj ) {
833 const char* s = "unknown";
834 switch( aTextVertAdj ) {
835 case TextVerticalAdjust_TOP:
836 s = "top";
837 break;
838 case TextVerticalAdjust_CENTER:
839 s = "center";
840 break;
841 case TextVerticalAdjust_BOTTOM:
842 s = "bottom";
843 break;
844 case TextVerticalAdjust_BLOCK:
845 s = "block";
846 break;
847 case TextVerticalAdjust::TextVerticalAdjust_MAKE_FIXED_SIZE:
848 s = "make_fixed_size";
849 break;
850 }
851 fprintf (stderr, "%s\n", s);
852 }
853 else if( value >>= aTextHorizAdj ) {
854 const char* s = "unknown";
855 switch( aTextHorizAdj ) {
856 case TextHorizontalAdjust_LEFT:
857 s = "left";
858 break;
859 case TextHorizontalAdjust_CENTER:
860 s = "center";
861 break;
862 case TextHorizontalAdjust_RIGHT:
863 s = "right";
864 break;
865 case TextHorizontalAdjust_BLOCK:
866 s = "block";
867 break;
868 case TextHorizontalAdjust::TextHorizontalAdjust_MAKE_FIXED_SIZE:
869 s = "make_fixed_size";
870 break;
871 }
872 fprintf (stderr, "%s\n", s);
873 }
874 else if( value >>= spacing ) {
875 fprintf (stderr, "mode: %d value: %d\n", spacing.Mode, spacing.Height);
876 }
877 else if( value >>= rect ) {
878 printLevel (level);
879 fprintf (stderr, "awt::Rectangle aRectangle;\n");
880 printLevel (level);
881 fprintf (stderr, "aRectangle.X = %" SAL_PRIdINT32 ";\n", rect.X);
882 printLevel (level);
883 fprintf (stderr, "aRectangle.Y = %" SAL_PRIdINT32 ";\n", rect.Y);
884 printLevel (level);
885 fprintf (stderr, "aRectangle.Width = %" SAL_PRIdINT32 ";\n", rect.Width);
886 printLevel (level);
887 fprintf (stderr, "aRectangle.Height = %" SAL_PRIdINT32 ";\n", rect.Height);
888 return "aRectangle";
889 }
890 else if( value >>= size ) {
891 printLevel (level);
892 fprintf (stderr, "awt::Size aSize;\n");
893 printLevel (level);
894 fprintf (stderr, "aSize.Width = %" SAL_PRIdINT32 ";\n", size.Width);
895 printLevel (level);
896 fprintf (stderr, "aSize.Height = %" SAL_PRIdINT32 ";\n", size.Height);
897 return "aSize";
898 }
899 else if( value.isExtractableTo(::cppu::UnoType<sal_Int32>::get())) {
900 fprintf (stderr,"is extractable to int32\n");
901 }
902 else
903 fprintf (stderr,"??? <unhandled type %s>\n", USS(value.getValueTypeName()));
904
905 return "";
906}
907
908void PropertyMap::dumpCode( const Reference< XPropertySet >& rXPropSet )
909{
910 Reference< XPropertySetInfo > info = rXPropSet->getPropertySetInfo ();
911 const Sequence< Property > props = info->getProperties ();
912 static constexpr OUStringLiteral sType = u"Type";
913
914 for (const Property& rProp : props) {
915
916 // ignore Type, it is set elsewhere
917 if (rProp.Name == sType)
918 continue;
919
920 OString name = OUStringToOString( rProp.Name, RTL_TEXTENCODING_UTF8);
921
922 try {
923 int level = 1;
924 printLevel (level);
925 fprintf (stderr, "{\n");
926 const char* var = lclDumpAnyValueCode (rXPropSet->getPropertyValue (rProp.Name), level + 1);
927 printLevel (level + 1);
928 fprintf (stderr,"aPropertyMap.setProperty(PROP_%s, %s);\n", name.getStr(), var);
929 printLevel (level);
930 fprintf (stderr, "}\n");
931 } catch (const Exception&) {
932 fprintf (stderr,"unable to get '%s' value\n", USS(rProp.Name));
933 }
934 }
935}
936
937void PropertyMap::dumpData(const Reference<XPropertySet>& xPropertySet)
938{
939 Reference<XPropertySetInfo> xPropertySetInfo = xPropertySet->getPropertySetInfo();
940 const Sequence<Property> aProperties = xPropertySetInfo->getProperties();
941
942 for (const Property& rProp : aProperties)
943 {
944 std::cerr << rProp.Name << std::endl;
945 std::cerr << comphelper::anyToString(xPropertySet->getPropertyValue(rProp.Name)) << std::endl;
946 }
947}
948
949#endif
950
951} // namespace oox
952
953/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const PropertyValue * pValues
OptionalString sType
PropertiesInfo aProperties
A helper that maps property identifiers to property values.
Definition: propertymap.hxx:52
const std::vector< OUString > * mpPropNames
bool setAnyProperty(sal_Int32 nPropId, const css::uno::Any &rValue)
Sets the specified property to the passed value.
void assignUsed(const PropertyMap &rPropMap)
Inserts all properties contained in the passed property map.
void erase(sal_Int32 nPropId)
std::map< sal_Int32, css::uno::Any > maProperties
void fillSequences(css::uno::Sequence< OUString > &rNames, css::uno::Sequence< css::uno::Any > &rValues) const
Fills the passed sequences of names and anys with all contained properties.
static void dumpData(const css::uno::Reference< css::beans::XPropertySet > &rXPropSet)
css::uno::Any getProperty(sal_Int32 nPropId)
bool hasProperty(sal_Int32 nPropId) const
Returns true, if the map contains a property with the passed identifier.
void assignAll(const PropertyMap &rPropMap)
Inserts all properties contained in the passed property map.
bool empty() const
static const OUString & getPropertyName(sal_Int32 nPropId)
Returns the name of the passed property identifier.
static void dump(const css::uno::Reference< css::beans::XPropertySet > &rXPropSet)
static sal_Int32 getPropertyId(std::u16string_view sPropName)
Returns the property identifier of the passed name.
css::uno::Sequence< css::beans::PropertyValue > makePropertyValueSequence() const
Returns a sequence of property values, filled with all contained properties.
void fillPropertyNameMap(PropertyNameMap &rMap) const
static void dumpCode(const css::uno::Reference< css::beans::XPropertySet > &rXPropSet)
css::uno::Reference< css::beans::XPropertySet > makePropertySet() const
Creates a property set supporting the XPropertySet interface and inserts all properties.
Any value
float u
const char * name
OUString aName
uno_Any a
Sequence< sal_Int8 > aSeq
#define SAL_INFO(area, stream)
size
@ Exception
OUString anyToString(uno::Any const &value)
Value
VBAHELPER_DLLPUBLIC bool setPropertyValue(css::uno::Sequence< css::beans::PropertyValue > &aProp, const OUString &aName, const css::uno::Any &aValue)
static void printLevel(int level)
static const char * lclGetEnhancedParameterType(sal_uInt16 nType)
static void lclDumpAnyValue(const Any &value)
const std::vector< OUString > & GetPropertyNameVector()
A vector that contains all predefined property names used in the filters.
static void printParameterPairData(int level, EnhancedCustomShapeParameterPair const &pp)
static const char * lclDumpAnyValueCode(const Any &value, int level)
::std::map< OUString, css::uno::Any > PropertyNameMap
Definition: propertymap.hxx:42
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
dictionary props
Definition: properties.py:26
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)
#define USS(x)
Definition: propertymap.cxx:65
QPRO_FUNC_TYPE nType
OUString Name
unsigned char sal_Bool
ResultType type
Count