1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/propertymap.hxx>
21 #include <oox/helper/helper.hxx>
23 #if OSL_DEBUG_LEVEL > 0
25 # include <com/sun/star/style/LineSpacing.hpp>
26 # include <com/sun/star/style/LineSpacingMode.hpp>
27 # include <com/sun/star/text/WritingMode.hpp>
28 using ::com::sun::star::style::LineSpacing
;
29 using ::com::sun::star::text::WritingMode
;
30 #include <comphelper/anytostring.hxx>
34 #include <com/sun/star/beans/PropertyValue.hpp>
35 #include <com/sun/star/beans/XPropertySet.hpp>
36 #include <com/sun/star/beans/XPropertySetInfo.hpp>
37 #include <com/sun/star/container/XIndexReplace.hpp>
38 #include <com/sun/star/awt/Rectangle.hpp>
39 #include <com/sun/star/awt/Size.hpp>
40 #include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
41 #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
42 #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
43 #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
44 #include <com/sun/star/drawing/EnhancedCustomShapeTextFrame.hpp>
45 #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
46 #include <com/sun/star/drawing/EnhancedCustomShapeParameterType.hpp>
47 #include <com/sun/star/drawing/HomogenMatrix3.hpp>
48 #include <cppuhelper/implbase.hxx>
49 #include <osl/diagnose.h>
50 #include <osl/mutex.hxx>
51 #include <sal/log.hxx>
52 #include <oox/token/properties.hxx>
53 #include <oox/token/propertynames.hxx>
54 using ::com::sun::star::uno::Any
;
55 using ::com::sun::star::uno::Reference
;
56 using ::com::sun::star::uno::RuntimeException
;
57 using ::com::sun::star::uno::Sequence
;
58 using ::com::sun::star::lang::IllegalArgumentException
;
59 using ::com::sun::star::lang::WrappedTargetException
;
60 using ::com::sun::star::beans::Property
;
61 using ::com::sun::star::beans::PropertyValue
;
62 using ::com::sun::star::beans::PropertyVetoException
;
63 using ::com::sun::star::beans::UnknownPropertyException
;
64 using ::com::sun::star::beans::XPropertyChangeListener
;
65 using ::com::sun::star::beans::XPropertySet
;
66 using ::com::sun::star::beans::XPropertySetInfo
;
67 using ::com::sun::star::beans::XVetoableChangeListener
;
68 using ::com::sun::star::container::XIndexReplace
;
70 #if OSL_DEBUG_LEVEL > 0
71 #define USS(x) OUStringToOString( x, RTL_TEXTENCODING_UTF8 ).getStr()
72 using namespace ::com::sun::star
;
73 using namespace ::com::sun::star::drawing
;
74 using namespace ::com::sun::star::uno
;
75 using ::com::sun::star::style::LineSpacing
;
76 using ::com::sun::star::text::WritingMode
;
77 using ::com::sun::star::drawing::TextHorizontalAdjust
;
78 using ::com::sun::star::drawing::TextVerticalAdjust
;
82 using ::com::sun::star::container::XIndexReplace
;
84 using namespace ::com::sun::star::beans
;
85 using namespace ::com::sun::star::lang
;
86 using namespace ::com::sun::star::drawing
;
87 using namespace ::com::sun::star::uno
;
88 using ::com::sun::star::drawing::TextHorizontalAdjust
;
89 using ::com::sun::star::drawing::TextVerticalAdjust
;
93 /** This class implements a generic XPropertySet.
95 Properties of all names and types can be set and later retrieved.
96 TODO: move this to comphelper or better find an existing implementation
98 class GenericPropertySet
: public ::cppu::WeakImplHelper
< XPropertySet
, XPropertySetInfo
>
101 explicit GenericPropertySet( const PropertyMap
& rPropMap
);
104 virtual Reference
< XPropertySetInfo
> SAL_CALL
getPropertySetInfo() override
;
105 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
, const Any
& aValue
) override
;
106 virtual Any SAL_CALL
getPropertyValue( const OUString
& PropertyName
) override
;
107 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
, const Reference
< XPropertyChangeListener
>& xListener
) override
;
108 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
, const Reference
< XPropertyChangeListener
>& aListener
) override
;
109 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
, const Reference
< XVetoableChangeListener
>& aListener
) override
;
110 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
, const Reference
< XVetoableChangeListener
>& aListener
) override
;
113 virtual Sequence
< Property
> SAL_CALL
getProperties() override
;
114 virtual Property SAL_CALL
getPropertyByName( const OUString
& aName
) override
;
115 virtual sal_Bool SAL_CALL
hasPropertyByName( const OUString
& Name
) override
;
119 PropertyNameMap maPropMap
;
122 GenericPropertySet::GenericPropertySet( const PropertyMap
& rPropMap
)
124 rPropMap
.fillPropertyNameMap(maPropMap
);
127 Reference
< XPropertySetInfo
> SAL_CALL
GenericPropertySet::getPropertySetInfo()
132 void SAL_CALL
GenericPropertySet::setPropertyValue( const OUString
& rPropertyName
, const Any
& rValue
)
134 ::osl::MutexGuard
aGuard( mMutex
);
135 maPropMap
[ rPropertyName
] = rValue
;
138 Any SAL_CALL
GenericPropertySet::getPropertyValue( const OUString
& rPropertyName
)
140 PropertyNameMap::iterator aIt
= maPropMap
.find( rPropertyName
);
141 if( aIt
== maPropMap
.end() )
142 throw UnknownPropertyException(rPropertyName
);
146 // listeners are not supported by this implementation
147 void SAL_CALL
GenericPropertySet::addPropertyChangeListener( const OUString
& , const Reference
< XPropertyChangeListener
>& ) {}
148 void SAL_CALL
GenericPropertySet::removePropertyChangeListener( const OUString
& , const Reference
< XPropertyChangeListener
>& ) {}
149 void SAL_CALL
GenericPropertySet::addVetoableChangeListener( const OUString
& , const Reference
< XVetoableChangeListener
>& ) {}
150 void SAL_CALL
GenericPropertySet::removeVetoableChangeListener( const OUString
& , const Reference
< XVetoableChangeListener
>& ) {}
153 Sequence
< Property
> SAL_CALL
GenericPropertySet::getProperties()
155 Sequence
< Property
> aSeq( static_cast< sal_Int32
>( maPropMap
.size() ) );
156 Property
* pProperty
= aSeq
.getArray();
157 for (auto const& prop
: maPropMap
)
159 pProperty
->Name
= prop
.first
;
160 pProperty
->Handle
= 0;
161 pProperty
->Type
= prop
.second
.getValueType();
162 pProperty
->Attributes
= 0;
168 Property SAL_CALL
GenericPropertySet::getPropertyByName( const OUString
& rPropertyName
)
170 PropertyNameMap::iterator aIt
= maPropMap
.find( rPropertyName
);
171 if( aIt
== maPropMap
.end() )
172 throw UnknownPropertyException(rPropertyName
);
174 aProperty
.Name
= aIt
->first
;
175 aProperty
.Handle
= 0;
176 aProperty
.Type
= aIt
->second
.getValueType();
177 aProperty
.Attributes
= 0;
181 sal_Bool SAL_CALL
GenericPropertySet::hasPropertyByName( const OUString
& rPropertyName
)
183 return maPropMap
.find( rPropertyName
) != maPropMap
.end();
188 PropertyMap::PropertyMap() :
189 mpPropNames( &StaticPropertyNameVector::get() ) // pointer instead reference to get compiler generated copy c'tor and operator=
193 bool PropertyMap::hasProperty( sal_Int32 nPropId
) const
195 return maProperties
.find( nPropId
) != maProperties
.end();
198 bool PropertyMap::setAnyProperty( sal_Int32 nPropId
, const Any
& rValue
)
203 maProperties
[ nPropId
] = rValue
;
207 Any
PropertyMap::getProperty( sal_Int32 nPropId
)
209 return maProperties
[ nPropId
];
212 void PropertyMap::erase( sal_Int32 nPropId
)
214 maProperties
.erase(nPropId
);
217 bool PropertyMap::empty() const
219 return maProperties
.empty();
222 void PropertyMap::assignUsed( const PropertyMap
& rPropMap
)
224 maProperties
.insert(rPropMap
.maProperties
.begin(), rPropMap
.maProperties
.end());
227 const OUString
& PropertyMap::getPropertyName( sal_Int32 nPropId
)
229 OSL_ENSURE( (0 <= nPropId
) && (nPropId
< PROP_COUNT
), "PropertyMap::getPropertyName - invalid property identifier" );
230 return StaticPropertyNameVector::get()[ nPropId
];
233 void PropertyMap::assignAll( const PropertyMap
& rPropMap
)
235 for (auto const& prop
: rPropMap
.maProperties
)
236 maProperties
[prop
.first
] = prop
.second
;
239 Sequence
< PropertyValue
> PropertyMap::makePropertyValueSequence() const
241 Sequence
< PropertyValue
> aSeq( static_cast< sal_Int32
>( maProperties
.size() ) );
242 PropertyValue
* pValues
= aSeq
.getArray();
243 for (auto const& prop
: maProperties
)
245 OSL_ENSURE( (0 <= prop
.first
) && (prop
.first
< PROP_COUNT
), "PropertyMap::makePropertyValueSequence - invalid property identifier" );
246 pValues
->Name
= (*mpPropNames
)[ prop
.first
];
247 pValues
->Value
= prop
.second
;
248 pValues
->State
= PropertyState_DIRECT_VALUE
;
254 void PropertyMap::fillSequences( Sequence
< OUString
>& rNames
, Sequence
< Any
>& rValues
) const
256 rNames
.realloc( static_cast< sal_Int32
>( maProperties
.size() ) );
257 rValues
.realloc( static_cast< sal_Int32
>( maProperties
.size() ) );
258 if( !maProperties
.empty() )
260 OUString
* pNames
= rNames
.getArray();
261 Any
* pValues
= rValues
.getArray();
262 for (auto const& prop
: maProperties
)
264 OSL_ENSURE( (0 <= prop
.first
) && (prop
.first
< PROP_COUNT
), "PropertyMap::fillSequences - invalid property identifier" );
265 *pNames
= (*mpPropNames
)[ prop
.first
];
266 *pValues
= prop
.second
;
273 void PropertyMap::fillPropertyNameMap(PropertyNameMap
& rMap
) const
275 for (auto const& prop
: maProperties
)
277 rMap
.insert(std::pair
<OUString
, Any
>((*mpPropNames
)[prop
.first
], prop
.second
));
281 Reference
< XPropertySet
> PropertyMap::makePropertySet() const
283 return new GenericPropertySet( *this );
286 #if OSL_DEBUG_LEVEL > 0
287 static void lclDumpAnyValue( const Any
& value
)
290 Sequence
< OUString
> strArray
;
291 Sequence
< Any
> anyArray
;
292 Sequence
< PropertyValue
> propArray
;
293 Sequence
< Sequence
< PropertyValue
> > propArrayArray
;
294 Sequence
< EnhancedCustomShapeAdjustmentValue
> adjArray
;
295 Sequence
< EnhancedCustomShapeSegment
> segArray
;
296 Sequence
< EnhancedCustomShapeParameterPair
> ppArray
;
297 EnhancedCustomShapeSegment segment
;
298 EnhancedCustomShapeParameterPair pp
;
299 EnhancedCustomShapeParameter par
;
300 HomogenMatrix3 aMatrix
;
301 sal_Int32 intValue
= 0;
302 sal_uInt32 uintValue
= 0;
303 sal_Int16 int16Value
= 0;
304 sal_uInt16 uint16Value
= 0;
305 float floatValue
= 0;
306 bool boolValue
= false;
308 // RectanglePoint pointValue;
309 WritingMode aWritingMode
;
310 TextVerticalAdjust aTextVertAdj
;
311 TextHorizontalAdjust aTextHorizAdj
;
312 Reference
< XIndexReplace
> xNumRule
;
314 if( value
>>= strValue
)
315 fprintf (stderr
,"\"%s\"\n", USS( strValue
) );
316 else if( value
>>= strArray
) {
317 fprintf (stderr
,"%s\n", USS(value
.getValueTypeName()));
318 for( int i
=0; i
<strArray
.getLength(); i
++ )
319 fprintf (stderr
,"\t\t\t[%3d] \"%s\"\n", i
, USS( strArray
[i
] ) );
320 } else if( value
>>= propArray
) {
321 fprintf (stderr
,"%s\n", USS(value
.getValueTypeName()));
322 for( int i
=0; i
<propArray
.getLength(); i
++ ) {
323 fprintf (stderr
,"\t\t\t[%3d] %s (%s) ", i
, USS( propArray
[i
].Name
), USS(propArray
[i
].Value
.getValueTypeName()) );
324 lclDumpAnyValue( propArray
[i
].Value
);
326 } else if( value
>>= propArrayArray
) {
327 fprintf (stderr
,"%s\n", USS(value
.getValueTypeName()));
328 for( int i
=0; i
<propArrayArray
.getLength(); i
++ ) {
329 fprintf (stderr
,"\t\t\t[%3d] ", i
);
330 lclDumpAnyValue( makeAny (propArrayArray
[i
]) );
332 } else if( value
>>= anyArray
) {
333 fprintf (stderr
,"%s\n", USS(value
.getValueTypeName()));
334 for( int i
=0; i
<anyArray
.getLength(); i
++ ) {
335 fprintf (stderr
,"\t\t\t[%3d] (%s) ", i
, USS(value
.getValueTypeName()) );
336 lclDumpAnyValue( anyArray
[i
] );
338 } else if( value
>>= adjArray
) {
339 fprintf (stderr
,"%s\n", USS(value
.getValueTypeName()));
340 for( int i
=0; i
<adjArray
.getLength(); i
++ ) {
341 fprintf (stderr
,"\t\t\t[%3d] (%s) ", i
, USS(adjArray
[i
].Value
.getValueTypeName()) );
342 lclDumpAnyValue( adjArray
[i
].Value
);
344 } else if( value
>>= segArray
) {
345 fprintf (stderr
,"%s\n", USS(value
.getValueTypeName()));
346 for( int i
=0; i
<segArray
.getLength(); i
++ ) {
347 fprintf (stderr
,"\t\t\t[%3d] ", i
);
348 lclDumpAnyValue( makeAny( segArray
[i
] ) );
350 } else if( value
>>= ppArray
) {
351 fprintf (stderr
,"%s\n", USS(value
.getValueTypeName()));
352 for( int i
=0; i
<ppArray
.getLength(); i
++ ) {
353 fprintf (stderr
,"\t\t\t[%3d] ", i
);
354 lclDumpAnyValue( makeAny( ppArray
[i
] ) );
356 } else if( value
>>= segment
) {
357 fprintf (stderr
,"Command: %d Count: %d\n", segment
.Command
, segment
.Count
);
358 } else if( value
>>= pp
) {
359 fprintf (stderr
,"First: ");
360 lclDumpAnyValue( makeAny (pp
.First
) );
361 fprintf (stderr
,"\t\t\t Second: ");
362 lclDumpAnyValue( makeAny (pp
.Second
) );
363 } else if( value
>>= par
) {
364 fprintf (stderr
,"Parameter (%s): ", USS(par
.Value
.getValueTypeName()));
365 lclDumpAnyValue( par
.Value
);
366 } else if( value
>>= aMatrix
) {
367 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
);
368 } else if( value
>>= intValue
)
369 fprintf (stderr
,"%-10" SAL_PRIdINT32
" (hex: %" SAL_PRIxUINT32
")\n", intValue
, intValue
);
370 else if( value
>>= uintValue
)
371 fprintf (stderr
,"%-10" SAL_PRIuUINT32
" (hex: %" SAL_PRIxUINT32
")\n", uintValue
, uintValue
);
372 else if( value
>>= int16Value
)
373 fprintf (stderr
,"%-10d (hex: %x)\n", int16Value
, int16Value
);
374 else if( value
>>= uint16Value
)
375 fprintf (stderr
,"%-10d (hex: %x)\n", uint16Value
, uint16Value
);
376 else if( value
>>= floatValue
)
377 fprintf (stderr
,"%f\n", floatValue
);
378 else if( value
>>= boolValue
)
379 fprintf (stderr
,"%-10d (bool)\n", boolValue
);
380 else if( value
>>= xNumRule
) {
381 fprintf (stderr
, "XIndexReplace\n");
383 for (int k
=0; k
<xNumRule
->getCount(); k
++) {
384 Sequence
< PropertyValue
> aBulletPropSeq
;
385 fprintf (stderr
, "level %d\n", k
);
386 if (xNumRule
->getByIndex (k
) >>= aBulletPropSeq
) {
387 for (int j
=0; j
<aBulletPropSeq
.getLength(); j
++) {
388 fprintf(stderr
, "%46s = ", USS (aBulletPropSeq
[j
].Name
));
389 lclDumpAnyValue (aBulletPropSeq
[j
].Value
);
394 fprintf (stderr
, "empty reference\n");
396 } else if( value
>>= aWritingMode
)
397 fprintf(stderr
, "%d writing mode\n", static_cast<int>(aWritingMode
));
398 else if( value
>>= aTextVertAdj
) {
399 const char* s
= "unknown";
400 switch( aTextVertAdj
) {
401 case TextVerticalAdjust_TOP
:
404 case TextVerticalAdjust_CENTER
:
407 case TextVerticalAdjust_BOTTOM
:
410 case TextVerticalAdjust_BLOCK
:
413 case TextVerticalAdjust::TextVerticalAdjust_MAKE_FIXED_SIZE
:
414 s
= "make_fixed_size";
417 fprintf (stderr
, "%s\n", s
);
418 } else if( value
>>= aTextHorizAdj
) {
419 const char* s
= "unknown";
420 switch( aTextHorizAdj
) {
421 case TextHorizontalAdjust_LEFT
:
424 case TextHorizontalAdjust_CENTER
:
427 case TextHorizontalAdjust_RIGHT
:
430 case TextHorizontalAdjust_BLOCK
:
433 case TextHorizontalAdjust::TextHorizontalAdjust_MAKE_FIXED_SIZE
:
434 s
= "make_fixed_size";
437 fprintf (stderr
, "%s\n", s
);
438 } else if( value
>>= spacing
) {
439 fprintf (stderr
, "mode: %d value: %d\n", spacing
.Mode
, spacing
.Height
);
440 } else if( value
.isExtractableTo(::cppu::UnoType
<sal_Int32
>::get())) {
441 fprintf (stderr
,"is extractable to int32\n");
443 // else if( value >>= pointValue )
444 // fprintf (stderr,"%d (RectanglePoint)\n", pointValue);
446 fprintf (stderr
,"??? <unhandled type %s>\n", USS(value
.getValueTypeName()));
450 void PropertyMap::dump( const Reference
< XPropertySet
>& rXPropSet
)
452 Reference
< XPropertySetInfo
> info
= rXPropSet
->getPropertySetInfo ();
453 Sequence
< Property
> props
= info
->getProperties ();
455 SAL_INFO("oox", "dump props, len: " << props
.getLength ());
457 for (int i
=0; i
< props
.getLength (); i
++) {
458 OString name
= OUStringToOString( props
[i
].Name
, RTL_TEXTENCODING_UTF8
);
459 fprintf (stderr
,"%30s = ", name
.getStr() );
462 lclDumpAnyValue (rXPropSet
->getPropertyValue( props
[i
].Name
));
463 } catch (const Exception
&) {
464 fprintf (stderr
,"unable to get '%s' value\n", USS(props
[i
].Name
));
470 static void printLevel (int level
)
472 for (int i
=0; i
<level
; i
++)
473 fprintf (stderr
, " ");
476 static const char *lclGetEnhancedParameterType( sal_uInt16 nType
)
480 case EnhancedCustomShapeParameterType::NORMAL
:
481 type
= "EnhancedCustomShapeParameterType::NORMAL";
483 case EnhancedCustomShapeParameterType::EQUATION
:
484 type
= "EnhancedCustomShapeParameterType::EQUATION";
486 case EnhancedCustomShapeParameterType::ADJUSTMENT
:
487 type
= "EnhancedCustomShapeParameterType::ADJUSTMENT";
489 case EnhancedCustomShapeParameterType::LEFT
:
490 type
= "EnhancedCustomShapeParameterType::LEFT";
492 case EnhancedCustomShapeParameterType::TOP
:
493 type
= "EnhancedCustomShapeParameterType::TOP";
495 case EnhancedCustomShapeParameterType::RIGHT
:
496 type
= "EnhancedCustomShapeParameterType::RIGHT";
498 case EnhancedCustomShapeParameterType::BOTTOM
:
499 type
= "EnhancedCustomShapeParameterType::BOTTOM";
501 case EnhancedCustomShapeParameterType::XSTRETCH
:
502 type
= "EnhancedCustomShapeParameterType::XSTRETCH";
504 case EnhancedCustomShapeParameterType::YSTRETCH
:
505 type
= "EnhancedCustomShapeParameterType::YSTRETCH";
507 case EnhancedCustomShapeParameterType::HASSTROKE
:
508 type
= "EnhancedCustomShapeParameterType::HASSTROKE";
510 case EnhancedCustomShapeParameterType::HASFILL
:
511 type
= "EnhancedCustomShapeParameterType::HASFILL";
513 case EnhancedCustomShapeParameterType::WIDTH
:
514 type
= "EnhancedCustomShapeParameterType::WIDTH";
516 case EnhancedCustomShapeParameterType::HEIGHT
:
517 type
= "EnhancedCustomShapeParameterType::HEIGHT";
519 case EnhancedCustomShapeParameterType::LOGWIDTH
:
520 type
= "EnhancedCustomShapeParameterType::LOGWIDTH";
522 case EnhancedCustomShapeParameterType::LOGHEIGHT
:
523 type
= "EnhancedCustomShapeParameterType::LOGHEIGHT";
532 static void printParameterPairData(int level
, EnhancedCustomShapeParameterPair
const &pp
)
534 // These are always sal_Int32s so lets depend on that for our packing ...
535 sal_Int32 nFirstValue
, nSecondValue
;
536 if (!(pp
.First
.Value
>>= nFirstValue
))
538 if (!(pp
.Second
.Value
>>= nSecondValue
))
542 fprintf (stderr
, "{\n");
543 printLevel (level
+ 1);
544 fprintf (stderr
, "%s,\n", lclGetEnhancedParameterType(pp
.First
.Type
));
545 printLevel (level
+ 1);
546 fprintf (stderr
, "%s,\n", lclGetEnhancedParameterType(pp
.Second
.Type
));
547 printLevel (level
+ 1);
548 fprintf (stderr
, "%d, %d\n", static_cast<int>(nFirstValue
), static_cast<int>(nSecondValue
));
550 fprintf (stderr
, "}");
553 static const char* lclDumpAnyValueCode( const Any
& value
, int level
)
556 Sequence
< OUString
> strArray
;
557 Sequence
< Any
> anyArray
;
558 Sequence
< awt::Size
> sizeArray
;
559 Sequence
< PropertyValue
> propArray
;
560 Sequence
< Sequence
< PropertyValue
> > propArrayArray
;
561 Sequence
< EnhancedCustomShapeAdjustmentValue
> adjArray
;
562 Sequence
< EnhancedCustomShapeTextFrame
> segTextFrame
;
563 Sequence
< EnhancedCustomShapeSegment
> segArray
;
564 Sequence
< EnhancedCustomShapeParameterPair
> ppArray
;
565 EnhancedCustomShapeSegment segment
;
566 EnhancedCustomShapeTextFrame textFrame
;
567 EnhancedCustomShapeParameterPair pp
;
568 EnhancedCustomShapeParameter par
;
572 sal_uInt32 uintValue
;
573 sal_Int16 int16Value
;
574 sal_uInt16 uint16Value
;
576 float floatValue
= 0;
579 // RectanglePoint pointValue;
580 WritingMode aWritingMode
;
581 TextVerticalAdjust aTextVertAdj
;
582 TextHorizontalAdjust aTextHorizAdj
;
583 Reference
< XIndexReplace
> xNumRule
;
585 if( value
>>= strValue
)
588 fprintf (stderr
,"OUString str = \"%s\";\n", USS( strValue
) );
591 else if( value
>>= strArray
)
593 if (strArray
.getLength() == 0)
594 return "Sequence< OUString >(0)";
597 fprintf (stderr
,"static const char *aStrings[] = {\n");
598 for( int i
=0; i
<strArray
.getLength(); i
++ ) {
599 printLevel (level
+ 1);
600 fprintf (stderr
,"\"%s\"%s\n", USS( strArray
[i
] ), i
< strArray
.getLength() - 1 ? "," : "" );
603 fprintf (stderr
,"};\n");
604 return "createStringSequence( SAL_N_ELEMENTS( aStrings ), aStrings )";
606 else if( value
>>= propArray
)
609 fprintf (stderr
,"Sequence< PropertyValue > aPropSequence (%" SAL_PRIdINT32
");\n", propArray
.getLength());
610 for( int i
=0; i
<propArray
.getLength(); i
++ ) {
612 fprintf (stderr
, "{\n");
613 printLevel (level
+ 1);
614 fprintf (stderr
, "aPropSequence [%d].Name = \"%s\";\n", i
, USS( propArray
[i
].Name
));
615 const char *var
= lclDumpAnyValueCode( propArray
[i
].Value
, level
+ 1 );
616 printLevel (level
+ 1);
617 fprintf (stderr
, "aPropSequence [%d].Value = makeAny (%s);\n", i
, var
);
619 fprintf (stderr
, "}\n");
621 return "aPropSequence";
623 else if( value
>>= sizeArray
)
626 fprintf (stderr
, "Sequence< awt::Size > aSizeSequence (%" SAL_PRIdINT32
");\n", sizeArray
.getLength());
627 for( int i
=0; i
<sizeArray
.getLength(); i
++ ) {
629 fprintf (stderr
, "{\n");
630 const char *var
= lclDumpAnyValueCode (makeAny (sizeArray
[i
]), level
+ 1);
631 printLevel (level
+ 1);
632 fprintf (stderr
, "aSizeSequence [%d] = %s;\n", i
, var
);
634 fprintf (stderr
, "}\n");
636 return "aSizeSequence";
638 else if( value
>>= propArrayArray
)
641 fprintf (stderr
,"Sequence< Sequence < PropertyValue > > aPropSequenceSequence (%" SAL_PRIdINT32
");\n", propArrayArray
.getLength());
642 for( int i
=0; i
<propArrayArray
.getLength(); i
++ ) {
644 fprintf (stderr
, "{\n");
645 const char *var
= lclDumpAnyValueCode( makeAny (propArrayArray
[i
]), level
+ 1 );
646 printLevel (level
+ 1);
647 fprintf (stderr
, "aPropSequenceSequence [%d] = %s;\n", i
, var
);
649 fprintf (stderr
, "}\n");
651 return "aPropSequenceSequence";
653 else if( value
>>= anyArray
)
655 fprintf (stderr
,"%s\n", USS(value
.getValueTypeName()));
656 for( int i
=0; i
<anyArray
.getLength(); i
++ ) {
657 fprintf (stderr
,"\t\t\t[%3d] (%s) ", i
, USS(value
.getValueTypeName()) );
658 lclDumpAnyValue( anyArray
[i
] );
661 else if( value
>>= adjArray
)
664 fprintf (stderr
,"Sequence< EnhancedCustomShapeAdjustmentValue > aAdjSequence (%" SAL_PRIdINT32
");\n", adjArray
.getLength());
665 for( int i
=0; i
<adjArray
.getLength(); i
++ ) {
667 fprintf (stderr
, "{\n");
668 const char *var
= lclDumpAnyValueCode( adjArray
[i
].Value
, level
+ 1 );
669 printLevel (level
+ 1);
670 fprintf (stderr
, "aAdjSequence [%d].Value = %s;\n", i
, var
);
671 if (adjArray
[i
].Name
.getLength() > 0) {
672 printLevel (level
+ 1);
673 fprintf (stderr
, "aAdjSequence [%d].Name = \"%s\";\n", i
, USS (adjArray
[i
].Name
));
676 fprintf (stderr
, "}\n");
678 return "aAdjSequence";
680 else if( value
>>= segArray
)
682 if (segArray
.getLength() == 0)
683 return "Sequence< EnhancedCustomShapeSegment >(0)";
686 fprintf (stderr
,"static const sal_uInt16 nValues[] = {\n");
688 fprintf (stderr
,"// Command, Count\n");
689 for( int i
= 0; i
< segArray
.getLength(); i
++ ) {
690 printLevel (level
+ 1);
691 fprintf (stderr
,"%d,%d%s\n", segArray
[i
].Command
,
692 segArray
[i
].Count
, i
< segArray
.getLength() - 1 ? "," : "");
695 fprintf (stderr
,"};\n");
696 return "createSegmentSequence( SAL_N_ELEMENTS( nValues ), nValues )";
698 else if( value
>>= segTextFrame
)
701 fprintf (stderr
, "Sequence< EnhancedCustomShapeTextFrame > aTextFrameSeq (%" SAL_PRIdINT32
");\n", segTextFrame
.getLength());
702 for( int i
=0; i
<segTextFrame
.getLength(); i
++ ) {
704 fprintf (stderr
, "{\n");
705 const char *var
= lclDumpAnyValueCode (makeAny (segTextFrame
[i
]), level
+ 1);
706 printLevel (level
+ 1);
707 fprintf (stderr
, "aTextFrameSeq [%d] = %s;\n", i
, var
);
709 fprintf (stderr
, "}\n");
711 return "aTextFrameSeq";
713 else if( value
>>= ppArray
)
716 if (ppArray
.getLength() == 0)
717 return "Sequence< EnhancedCustomShapeParameterPair >(0)";
719 fprintf (stderr
, "static const CustomShapeProvider::ParameterPairData aData[] = {\n");
720 for( int i
= 0; i
< ppArray
.getLength(); i
++ ) {
721 printParameterPairData(level
+ 1, ppArray
[i
]);
722 fprintf (stderr
,"%s\n", i
< ppArray
.getLength() - 1 ? "," : "");
725 fprintf (stderr
,"};\n");
727 return "createParameterPairSequence(SAL_N_ELEMENTS(aData), aData)";
729 else if( value
>>= segment
)
732 fprintf (stderr
, "EnhancedCustomShapeSegment aSegment;\n");
734 // TODO: use EnhancedCustomShapeSegmentCommand constants
735 fprintf (stderr
, "aSegment.Command = %d;\n", segment
.Command
);
737 fprintf (stderr
, "aSegment.Count = %d;\n", segment
.Count
);
740 else if( value
>>= textFrame
)
743 fprintf (stderr
, "EnhancedCustomShapeTextFrame aTextFrame;\n");
745 fprintf (stderr
, "{\n");
747 const char* var
= lclDumpAnyValueCode( makeAny (textFrame
.TopLeft
), level
+ 1 );
748 printLevel (level
+ 1);
749 fprintf (stderr
, "aTextFrame.TopLeft = %s;\n", var
);
752 fprintf (stderr
, "}\n");
755 fprintf (stderr
, "{\n");
757 const char* var
= lclDumpAnyValueCode( makeAny (textFrame
.BottomRight
), level
+ 1 );
758 printLevel (level
+ 1);
759 fprintf (stderr
, "aTextFrame.BottomRight = %s;\n", var
);
762 fprintf (stderr
, "}\n");
766 else if( value
>>= pp
)
769 fprintf (stderr
, "static const CustomShapeProvider::ParameterPairData aData =\n");
770 printParameterPairData(level
, pp
);
771 fprintf (stderr
, ";\n");
773 return "createParameterPair(&aData)";
775 else if( value
>>= par
)
778 fprintf (stderr
,"EnhancedCustomShapeParameter aParameter;\n");
779 const char* var
= lclDumpAnyValueCode( par
.Value
, level
);
781 fprintf (stderr
,"aParameter.Value = %s;\n", var
);
783 fprintf (stderr
,"aParameter.Type = %s;\n",
784 lclGetEnhancedParameterType(par
.Type
));
787 else if( value
>>= longValue
)
790 fprintf (stderr
,"Any aAny ((sal_Int32) %ld);\n", longValue
);
793 else if( value
>>= intValue
)
794 fprintf (stderr
,"%" SAL_PRIdINT32
" (hex: %" SAL_PRIxUINT32
")\n", intValue
, intValue
);
795 else if( value
>>= uintValue
)
796 fprintf (stderr
,"%" SAL_PRIdINT32
" (hex: %" SAL_PRIxUINT32
")\n", uintValue
, uintValue
);
797 else if( value
>>= int16Value
)
798 fprintf (stderr
,"%d (hex: %x)\n", int16Value
, int16Value
);
799 else if( value
>>= uint16Value
)
800 fprintf (stderr
,"%d (hex: %x)\n", uint16Value
, uint16Value
);
801 else if( value
>>= floatValue
)
802 fprintf (stderr
,"%f\n", floatValue
);
803 else if( value
>>= boolValue
) {
805 return "(sal_Bool) sal_True";
807 return "(sal_Bool) sal_False";
809 else if( value
>>= xNumRule
) {
810 fprintf (stderr
, "XIndexReplace\n");
811 for (int k
=0; k
<xNumRule
->getCount(); k
++) {
812 Sequence
< PropertyValue
> aBulletPropSeq
;
813 fprintf (stderr
, "level %d\n", k
);
814 if (xNumRule
->getByIndex (k
) >>= aBulletPropSeq
) {
815 for (int j
=0; j
<aBulletPropSeq
.getLength(); j
++) {
816 fprintf(stderr
, "%46s = ", USS (aBulletPropSeq
[j
].Name
));
817 lclDumpAnyValue (aBulletPropSeq
[j
].Value
);
822 else if( value
>>= aWritingMode
)
823 fprintf (stderr
, "%d writing mode\n", static_cast<int>(aWritingMode
));
824 else if( value
>>= aTextVertAdj
) {
825 const char* s
= "unknown";
826 switch( aTextVertAdj
) {
827 case TextVerticalAdjust_TOP
:
830 case TextVerticalAdjust_CENTER
:
833 case TextVerticalAdjust_BOTTOM
:
836 case TextVerticalAdjust_BLOCK
:
839 case TextVerticalAdjust::TextVerticalAdjust_MAKE_FIXED_SIZE
:
840 s
= "make_fixed_size";
843 fprintf (stderr
, "%s\n", s
);
845 else if( value
>>= aTextHorizAdj
) {
846 const char* s
= "unknown";
847 switch( aTextHorizAdj
) {
848 case TextHorizontalAdjust_LEFT
:
851 case TextHorizontalAdjust_CENTER
:
854 case TextHorizontalAdjust_RIGHT
:
857 case TextHorizontalAdjust_BLOCK
:
860 case TextHorizontalAdjust::TextHorizontalAdjust_MAKE_FIXED_SIZE
:
861 s
= "make_fixed_size";
864 fprintf (stderr
, "%s\n", s
);
866 else if( value
>>= spacing
) {
867 fprintf (stderr
, "mode: %d value: %d\n", spacing
.Mode
, spacing
.Height
);
869 else if( value
>>= rect
) {
871 fprintf (stderr
, "awt::Rectangle aRectangle;\n");
873 fprintf (stderr
, "aRectangle.X = %" SAL_PRIdINT32
";\n", rect
.X
);
875 fprintf (stderr
, "aRectangle.Y = %" SAL_PRIdINT32
";\n", rect
.Y
);
877 fprintf (stderr
, "aRectangle.Width = %" SAL_PRIdINT32
";\n", rect
.Width
);
879 fprintf (stderr
, "aRectangle.Height = %" SAL_PRIdINT32
";\n", rect
.Height
);
882 else if( value
>>= size
) {
884 fprintf (stderr
, "awt::Size aSize;\n");
886 fprintf (stderr
, "aSize.Width = %" SAL_PRIdINT32
";\n", size
.Width
);
888 fprintf (stderr
, "aSize.Height = %" SAL_PRIdINT32
";\n", size
.Height
);
891 else if( value
.isExtractableTo(::cppu::UnoType
<sal_Int32
>::get())) {
892 fprintf (stderr
,"is extractable to int32\n");
895 fprintf (stderr
,"??? <unhandled type %s>\n", USS(value
.getValueTypeName()));
900 void PropertyMap::dumpCode( const Reference
< XPropertySet
>& rXPropSet
)
902 Reference
< XPropertySetInfo
> info
= rXPropSet
->getPropertySetInfo ();
903 Sequence
< Property
> props
= info
->getProperties ();
904 const OUString sType
= "Type";
906 for (int i
=0; i
< props
.getLength (); i
++) {
908 // ignore Type, it is set elsewhere
909 if (props
[i
].Name
== sType
)
912 OString name
= OUStringToOString( props
[i
].Name
, RTL_TEXTENCODING_UTF8
);
917 fprintf (stderr
, "{\n");
918 const char* var
= lclDumpAnyValueCode (rXPropSet
->getPropertyValue (props
[i
].Name
), level
+ 1);
919 printLevel (level
+ 1);
920 fprintf (stderr
,"aPropertyMap.setProperty(PROP_%s, %s);\n", name
.getStr(), var
);
922 fprintf (stderr
, "}\n");
923 } catch (const Exception
&) {
924 fprintf (stderr
,"unable to get '%s' value\n", USS(props
[i
].Name
));
929 void PropertyMap::dumpData(const Reference
<XPropertySet
>& xPropertySet
)
931 Reference
<XPropertySetInfo
> xPropertySetInfo
= xPropertySet
->getPropertySetInfo();
932 Sequence
<Property
> aProperties
= xPropertySetInfo
->getProperties();
934 for (int i
= 0; i
< aProperties
.getLength(); ++i
)
936 std::cerr
<< aProperties
[i
].Name
<< std::endl
;
937 std::cerr
<< comphelper::anyToString(xPropertySet
->getPropertyValue(aProperties
[i
].Name
)) << std::endl
;
945 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */