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>
22 #if OSL_DEBUG_LEVEL > 0
24 # include <com/sun/star/style/LineSpacing.hpp>
25 # include <com/sun/star/text/WritingMode.hpp>
26 using ::com::sun::star::style::LineSpacing
;
27 using ::com::sun::star::text::WritingMode
;
28 #include <comphelper/anytostring.hxx>
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>
46 #include <cppuhelper/implbase.hxx>
47 #include <osl/diagnose.h>
49 #include <sal/log.hxx>
50 #include <oox/token/properties.hxx>
51 #include <oox/token/propertynames.hxx>
52 using ::com::sun::star::uno::Any
;
53 using ::com::sun::star::uno::Reference
;
54 using ::com::sun::star::uno::Sequence
;
55 using ::com::sun::star::beans::Property
;
56 using ::com::sun::star::beans::PropertyValue
;
57 using ::com::sun::star::beans::UnknownPropertyException
;
58 using ::com::sun::star::beans::XPropertyChangeListener
;
59 using ::com::sun::star::beans::XPropertySet
;
60 using ::com::sun::star::beans::XPropertySetInfo
;
61 using ::com::sun::star::beans::XVetoableChangeListener
;
62 using ::com::sun::star::container::XIndexReplace
;
64 #if OSL_DEBUG_LEVEL > 0
65 #define USS(x) OUStringToOString( x, RTL_TEXTENCODING_UTF8 ).getStr()
66 using namespace ::com::sun::star
;
67 using namespace ::com::sun::star::drawing
;
68 using namespace ::com::sun::star::uno
;
69 using ::com::sun::star::style::LineSpacing
;
70 using ::com::sun::star::text::WritingMode
;
71 using ::com::sun::star::drawing::TextHorizontalAdjust
;
72 using ::com::sun::star::drawing::TextVerticalAdjust
;
77 using namespace ::com::sun::star::beans
;
78 using namespace ::com::sun::star::lang
;
79 using namespace ::com::sun::star::drawing
;
80 using namespace ::com::sun::star::uno
;
84 /** This class implements a generic XPropertySet.
86 Properties of all names and types can be set and later retrieved.
87 TODO: move this to comphelper or better find an existing implementation
89 class GenericPropertySet
: public ::cppu::WeakImplHelper
< XPropertySet
, XPropertySetInfo
>
92 explicit GenericPropertySet( const PropertyMap
& rPropMap
);
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
;
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
;
110 PropertyNameMap maPropMap
;
113 GenericPropertySet::GenericPropertySet( const PropertyMap
& rPropMap
)
115 rPropMap
.fillPropertyNameMap(maPropMap
);
118 Reference
< XPropertySetInfo
> SAL_CALL
GenericPropertySet::getPropertySetInfo()
123 void SAL_CALL
GenericPropertySet::setPropertyValue( const OUString
& rPropertyName
, const Any
& rValue
)
125 std::scoped_lock
aGuard( mMutex
);
126 maPropMap
[ rPropertyName
] = rValue
;
129 Any SAL_CALL
GenericPropertySet::getPropertyValue( const OUString
& rPropertyName
)
131 PropertyNameMap::iterator aIt
= maPropMap
.find( rPropertyName
);
132 if( aIt
== maPropMap
.end() )
133 throw UnknownPropertyException(rPropertyName
);
137 // listeners are not supported by this implementation
138 void SAL_CALL
GenericPropertySet::addPropertyChangeListener( const OUString
& , const Reference
< XPropertyChangeListener
>& ) {}
139 void SAL_CALL
GenericPropertySet::removePropertyChangeListener( const OUString
& , const Reference
< XPropertyChangeListener
>& ) {}
140 void SAL_CALL
GenericPropertySet::addVetoableChangeListener( const OUString
& , const Reference
< XVetoableChangeListener
>& ) {}
141 void SAL_CALL
GenericPropertySet::removeVetoableChangeListener( const OUString
& , const Reference
< XVetoableChangeListener
>& ) {}
144 Sequence
< Property
> SAL_CALL
GenericPropertySet::getProperties()
146 Sequence
< Property
> aSeq( static_cast< sal_Int32
>( maPropMap
.size() ) );
147 Property
* pProperty
= aSeq
.getArray();
148 for (auto const& prop
: maPropMap
)
150 pProperty
->Name
= prop
.first
;
151 pProperty
->Handle
= 0;
152 pProperty
->Type
= prop
.second
.getValueType();
153 pProperty
->Attributes
= 0;
159 Property SAL_CALL
GenericPropertySet::getPropertyByName( const OUString
& rPropertyName
)
161 PropertyNameMap::iterator aIt
= maPropMap
.find( rPropertyName
);
162 if( aIt
== maPropMap
.end() )
163 throw UnknownPropertyException(rPropertyName
);
165 aProperty
.Name
= aIt
->first
;
166 aProperty
.Handle
= 0;
167 aProperty
.Type
= aIt
->second
.getValueType();
168 aProperty
.Attributes
= 0;
172 sal_Bool SAL_CALL
GenericPropertySet::hasPropertyByName( const OUString
& rPropertyName
)
174 return maPropMap
.contains(rPropertyName
);
179 PropertyMap::PropertyMap() :
180 mpPropNames( &GetPropertyNameVector() ) // pointer instead reference to get compiler generated copy c'tor and operator=
184 bool PropertyMap::hasProperty( sal_Int32 nPropId
) const
186 return maProperties
.find( nPropId
) != maProperties
.end();
189 bool PropertyMap::setAnyProperty( sal_Int32 nPropId
, const Any
& rValue
)
194 maProperties
[ nPropId
] = rValue
;
198 Any
PropertyMap::getProperty( sal_Int32 nPropId
)
200 return maProperties
[ nPropId
];
203 void PropertyMap::erase( sal_Int32 nPropId
)
205 maProperties
.erase(nPropId
);
208 bool PropertyMap::empty() const
210 return maProperties
.empty();
213 void PropertyMap::assignUsed( const PropertyMap
& rPropMap
)
215 maProperties
.insert(rPropMap
.maProperties
.begin(), rPropMap
.maProperties
.end());
218 const OUString
& PropertyMap::getPropertyName( sal_Int32 nPropId
)
220 OSL_ENSURE( (0 <= nPropId
) && (nPropId
< PROP_COUNT
), "PropertyMap::getPropertyName - invalid property identifier" );
221 return GetPropertyNameVector()[ nPropId
];
224 sal_Int32
PropertyMap::getPropertyId( std::u16string_view sPropName
)
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())
232 const std::vector
<OUString
>& rVec(GetPropertyNameVector());
233 for(size_t a(0); a
< rVec
.size(); a
++)
234 if(rVec
[a
] == sPropName
)
240 void PropertyMap::assignAll( const PropertyMap
& rPropMap
)
242 for (auto const& prop
: rPropMap
.maProperties
)
243 maProperties
[prop
.first
] = prop
.second
;
246 Sequence
< PropertyValue
> PropertyMap::makePropertyValueSequence() const
248 Sequence
< PropertyValue
> aSeq( static_cast< sal_Int32
>( maProperties
.size() ) );
249 PropertyValue
* pValues
= aSeq
.getArray();
250 for (auto const& prop
: maProperties
)
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
;
261 void PropertyMap::fillSequences( Sequence
< OUString
>& rNames
, Sequence
< Any
>& rValues
) const
263 rNames
.realloc( static_cast< sal_Int32
>( maProperties
.size() ) );
264 rValues
.realloc( static_cast< sal_Int32
>( maProperties
.size() ) );
265 if( maProperties
.empty() )
268 OUString
* pNames
= rNames
.getArray();
269 Any
* pValues
= rValues
.getArray();
270 for (auto const& prop
: maProperties
)
272 OSL_ENSURE( (0 <= prop
.first
) && (prop
.first
< PROP_COUNT
), "PropertyMap::fillSequences - invalid property identifier" );
273 *pNames
= (*mpPropNames
)[ prop
.first
];
274 *pValues
= prop
.second
;
280 void PropertyMap::fillPropertyNameMap(PropertyNameMap
& rMap
) const
282 for (auto const& prop
: maProperties
)
284 rMap
.insert(std::pair
<OUString
, Any
>((*mpPropNames
)[prop
.first
], prop
.second
));
288 Reference
< XPropertySet
> PropertyMap::makePropertySet() const
290 return new GenericPropertySet( *this );
293 #if OSL_DEBUG_LEVEL > 0
294 static void lclDumpAnyValue( const Any
& value
)
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;
315 // RectanglePoint pointValue;
316 WritingMode aWritingMode
;
317 TextVerticalAdjust aTextVertAdj
;
318 TextHorizontalAdjust aTextHorizAdj
;
319 Reference
< XIndexReplace
> xNumRule
;
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
);
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
]) );
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
] );
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
);
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
] ) );
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
] ) );
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");
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
: aBulletPropSeq
) {
395 fprintf(stderr
, "%46s = ", USS (rProp
.Name
));
396 lclDumpAnyValue (rProp
.Value
);
401 fprintf (stderr
, "empty reference\n");
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
:
411 case TextVerticalAdjust_CENTER
:
414 case TextVerticalAdjust_BOTTOM
:
417 case TextVerticalAdjust_BLOCK
:
420 case TextVerticalAdjust::TextVerticalAdjust_MAKE_FIXED_SIZE
:
421 s
= "make_fixed_size";
424 fprintf (stderr
, "%s\n", s
);
425 } else if( value
>>= aTextHorizAdj
) {
426 const char* s
= "unknown";
427 switch( aTextHorizAdj
) {
428 case TextHorizontalAdjust_LEFT
:
431 case TextHorizontalAdjust_CENTER
:
434 case TextHorizontalAdjust_RIGHT
:
437 case TextHorizontalAdjust_BLOCK
:
440 case TextHorizontalAdjust::TextHorizontalAdjust_MAKE_FIXED_SIZE
:
441 s
= "make_fixed_size";
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");
450 // else if( value >>= pointValue )
451 // fprintf (stderr,"%d (RectanglePoint)\n", pointValue);
453 fprintf (stderr
,"??? <unhandled type %s>\n", USS(value
.getValueTypeName()));
457 void PropertyMap::dump( const Reference
< XPropertySet
>& rXPropSet
)
459 Reference
< XPropertySetInfo
> info
= rXPropSet
->getPropertySetInfo ();
460 const Sequence
< Property
> props
= info
->getProperties ();
462 SAL_INFO("oox", "dump props, len: " << props
.getLength ());
464 for (Property
const & prop
: props
) {
465 OString name
= OUStringToOString( prop
.Name
, RTL_TEXTENCODING_UTF8
);
466 fprintf (stderr
,"%30s = ", name
.getStr() );
469 lclDumpAnyValue (rXPropSet
->getPropertyValue( prop
.Name
));
470 } catch (const Exception
&) {
471 fprintf (stderr
,"unable to get '%s' value\n", USS(prop
.Name
));
477 static void printLevel (int level
)
479 for (int i
=0; i
<level
; i
++)
480 fprintf (stderr
, " ");
483 static const char *lclGetEnhancedParameterType( sal_uInt16 nType
)
487 case EnhancedCustomShapeParameterType::NORMAL
:
488 type
= "EnhancedCustomShapeParameterType::NORMAL";
490 case EnhancedCustomShapeParameterType::EQUATION
:
491 type
= "EnhancedCustomShapeParameterType::EQUATION";
493 case EnhancedCustomShapeParameterType::ADJUSTMENT
:
494 type
= "EnhancedCustomShapeParameterType::ADJUSTMENT";
496 case EnhancedCustomShapeParameterType::LEFT
:
497 type
= "EnhancedCustomShapeParameterType::LEFT";
499 case EnhancedCustomShapeParameterType::TOP
:
500 type
= "EnhancedCustomShapeParameterType::TOP";
502 case EnhancedCustomShapeParameterType::RIGHT
:
503 type
= "EnhancedCustomShapeParameterType::RIGHT";
505 case EnhancedCustomShapeParameterType::BOTTOM
:
506 type
= "EnhancedCustomShapeParameterType::BOTTOM";
508 case EnhancedCustomShapeParameterType::XSTRETCH
:
509 type
= "EnhancedCustomShapeParameterType::XSTRETCH";
511 case EnhancedCustomShapeParameterType::YSTRETCH
:
512 type
= "EnhancedCustomShapeParameterType::YSTRETCH";
514 case EnhancedCustomShapeParameterType::HASSTROKE
:
515 type
= "EnhancedCustomShapeParameterType::HASSTROKE";
517 case EnhancedCustomShapeParameterType::HASFILL
:
518 type
= "EnhancedCustomShapeParameterType::HASFILL";
520 case EnhancedCustomShapeParameterType::WIDTH
:
521 type
= "EnhancedCustomShapeParameterType::WIDTH";
523 case EnhancedCustomShapeParameterType::HEIGHT
:
524 type
= "EnhancedCustomShapeParameterType::HEIGHT";
526 case EnhancedCustomShapeParameterType::LOGWIDTH
:
527 type
= "EnhancedCustomShapeParameterType::LOGWIDTH";
529 case EnhancedCustomShapeParameterType::LOGHEIGHT
:
530 type
= "EnhancedCustomShapeParameterType::LOGHEIGHT";
539 static void printParameterPairData(int level
, EnhancedCustomShapeParameterPair
const &pp
)
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
))
546 if (!(pp
.Second
.Value
>>= nSecondValue
))
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
));
558 fprintf (stderr
, "}");
561 static const char* lclDumpAnyValueCode( const Any
& value
, int level
)
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
;
580 sal_uInt32 uintValue
;
581 sal_Int16 int16Value
;
582 sal_uInt16 uint16Value
;
583 sal_Int64 int64Value
;
584 float floatValue
= 0;
587 // RectanglePoint pointValue;
588 WritingMode aWritingMode
;
589 TextVerticalAdjust aTextVertAdj
;
590 TextHorizontalAdjust aTextHorizAdj
;
591 Reference
< XIndexReplace
> xNumRule
;
593 if( value
>>= strValue
)
596 fprintf (stderr
,"OUString str = \"%s\";\n", USS( strValue
) );
599 else if( value
>>= strArray
)
601 if (strArray
.getLength() == 0)
602 return "Sequence< OUString >(0)";
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 ? "," : "" );
611 fprintf (stderr
,"};\n");
612 return "createStringSequence( SAL_N_ELEMENTS( aStrings ), aStrings )";
614 else if( value
>>= propArray
)
617 fprintf (stderr
,"Sequence< PropertyValue > aPropSequence (%" SAL_PRIdINT32
");\n", propArray
.getLength());
618 for( int i
=0; i
<propArray
.getLength(); i
++ ) {
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
);
627 fprintf (stderr
, "}\n");
629 return "aPropSequence";
631 else if( value
>>= sizeArray
)
634 fprintf (stderr
, "Sequence< awt::Size > aSizeSequence (%" SAL_PRIdINT32
");\n", sizeArray
.getLength());
635 for( int i
=0; i
<sizeArray
.getLength(); i
++ ) {
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
);
642 fprintf (stderr
, "}\n");
644 return "aSizeSequence";
646 else if( value
>>= propArrayArray
)
649 fprintf (stderr
,"Sequence< Sequence < PropertyValue > > aPropSequenceSequence (%" SAL_PRIdINT32
");\n", propArrayArray
.getLength());
650 for( int i
=0; i
<propArrayArray
.getLength(); i
++ ) {
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
);
657 fprintf (stderr
, "}\n");
659 return "aPropSequenceSequence";
661 else if( value
>>= anyArray
)
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
] );
669 else if( value
>>= adjArray
)
672 fprintf (stderr
,"Sequence< EnhancedCustomShapeAdjustmentValue > aAdjSequence (%" SAL_PRIdINT32
");\n", adjArray
.getLength());
673 for( int i
=0; i
<adjArray
.getLength(); i
++ ) {
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
));
684 fprintf (stderr
, "}\n");
686 return "aAdjSequence";
688 else if( value
>>= segArray
)
690 if (segArray
.getLength() == 0)
691 return "Sequence< EnhancedCustomShapeSegment >(0)";
694 fprintf (stderr
,"static const sal_uInt16 nValues[] = {\n");
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 ? "," : "");
703 fprintf (stderr
,"};\n");
704 return "createSegmentSequence( SAL_N_ELEMENTS( nValues ), nValues )";
706 else if( value
>>= segTextFrame
)
709 fprintf (stderr
, "Sequence< EnhancedCustomShapeTextFrame > aTextFrameSeq (%" SAL_PRIdINT32
");\n", segTextFrame
.getLength());
710 for( int i
=0; i
<segTextFrame
.getLength(); i
++ ) {
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
);
717 fprintf (stderr
, "}\n");
719 return "aTextFrameSeq";
721 else if( value
>>= ppArray
)
724 if (ppArray
.getLength() == 0)
725 return "Sequence< EnhancedCustomShapeParameterPair >(0)";
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 ? "," : "");
733 fprintf (stderr
,"};\n");
735 return "createParameterPairSequence(SAL_N_ELEMENTS(aData), aData)";
737 else if( value
>>= segment
)
740 fprintf (stderr
, "EnhancedCustomShapeSegment aSegment;\n");
742 // TODO: use EnhancedCustomShapeSegmentCommand constants
743 fprintf (stderr
, "aSegment.Command = %d;\n", segment
.Command
);
745 fprintf (stderr
, "aSegment.Count = %d;\n", segment
.Count
);
748 else if( value
>>= textFrame
)
751 fprintf (stderr
, "EnhancedCustomShapeTextFrame aTextFrame;\n");
753 fprintf (stderr
, "{\n");
755 const char* var
= lclDumpAnyValueCode( Any (textFrame
.TopLeft
), level
+ 1 );
756 printLevel (level
+ 1);
757 fprintf (stderr
, "aTextFrame.TopLeft = %s;\n", var
);
760 fprintf (stderr
, "}\n");
763 fprintf (stderr
, "{\n");
765 const char* var
= lclDumpAnyValueCode( Any (textFrame
.BottomRight
), level
+ 1 );
766 printLevel (level
+ 1);
767 fprintf (stderr
, "aTextFrame.BottomRight = %s;\n", var
);
770 fprintf (stderr
, "}\n");
774 else if( value
>>= pp
)
777 fprintf (stderr
, "static const CustomShapeProvider::ParameterPairData aData =\n");
778 printParameterPairData(level
, pp
);
779 fprintf (stderr
, ";\n");
781 return "createParameterPair(&aData)";
783 else if( value
>>= par
)
786 fprintf (stderr
,"EnhancedCustomShapeParameter aParameter;\n");
787 const char* var
= lclDumpAnyValueCode( par
.Value
, level
);
789 fprintf (stderr
,"aParameter.Value = %s;\n", var
);
791 fprintf (stderr
,"aParameter.Type = %s;\n",
792 lclGetEnhancedParameterType(par
.Type
));
795 else if( value
>>= int64Value
)
798 fprintf (stderr
,"Any aAny ((sal_Int64) %" SAL_PRIdINT64
");\n", int64Value
);
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
) {
813 return "(sal_Bool) sal_True";
815 return "(sal_Bool) sal_False";
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
: aBulletPropSeq
) {
824 fprintf(stderr
, "%46s = ", USS (rProp
.Name
));
825 lclDumpAnyValue (rProp
.Value
);
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
:
838 case TextVerticalAdjust_CENTER
:
841 case TextVerticalAdjust_BOTTOM
:
844 case TextVerticalAdjust_BLOCK
:
847 case TextVerticalAdjust::TextVerticalAdjust_MAKE_FIXED_SIZE
:
848 s
= "make_fixed_size";
851 fprintf (stderr
, "%s\n", s
);
853 else if( value
>>= aTextHorizAdj
) {
854 const char* s
= "unknown";
855 switch( aTextHorizAdj
) {
856 case TextHorizontalAdjust_LEFT
:
859 case TextHorizontalAdjust_CENTER
:
862 case TextHorizontalAdjust_RIGHT
:
865 case TextHorizontalAdjust_BLOCK
:
868 case TextHorizontalAdjust::TextHorizontalAdjust_MAKE_FIXED_SIZE
:
869 s
= "make_fixed_size";
872 fprintf (stderr
, "%s\n", s
);
874 else if( value
>>= spacing
) {
875 fprintf (stderr
, "mode: %d value: %d\n", spacing
.Mode
, spacing
.Height
);
877 else if( value
>>= rect
) {
879 fprintf (stderr
, "awt::Rectangle aRectangle;\n");
881 fprintf (stderr
, "aRectangle.X = %" SAL_PRIdINT32
";\n", rect
.X
);
883 fprintf (stderr
, "aRectangle.Y = %" SAL_PRIdINT32
";\n", rect
.Y
);
885 fprintf (stderr
, "aRectangle.Width = %" SAL_PRIdINT32
";\n", rect
.Width
);
887 fprintf (stderr
, "aRectangle.Height = %" SAL_PRIdINT32
";\n", rect
.Height
);
890 else if( value
>>= size
) {
892 fprintf (stderr
, "awt::Size aSize;\n");
894 fprintf (stderr
, "aSize.Width = %" SAL_PRIdINT32
";\n", size
.Width
);
896 fprintf (stderr
, "aSize.Height = %" SAL_PRIdINT32
";\n", size
.Height
);
899 else if( value
.isExtractableTo(::cppu::UnoType
<sal_Int32
>::get())) {
900 fprintf (stderr
,"is extractable to int32\n");
903 fprintf (stderr
,"??? <unhandled type %s>\n", USS(value
.getValueTypeName()));
908 void PropertyMap::dumpCode( const Reference
< XPropertySet
>& rXPropSet
)
910 Reference
< XPropertySetInfo
> info
= rXPropSet
->getPropertySetInfo ();
911 const Sequence
< Property
> props
= info
->getProperties ();
912 static constexpr OUStringLiteral sType
= u
"Type";
914 for (const Property
& rProp
: props
) {
916 // ignore Type, it is set elsewhere
917 if (rProp
.Name
== sType
)
920 OString name
= OUStringToOString( rProp
.Name
, RTL_TEXTENCODING_UTF8
);
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
);
930 fprintf (stderr
, "}\n");
931 } catch (const Exception
&) {
932 fprintf (stderr
,"unable to get '%s' value\n", USS(rProp
.Name
));
937 void PropertyMap::dumpData(const Reference
<XPropertySet
>& xPropertySet
)
939 Reference
<XPropertySetInfo
> xPropertySetInfo
= xPropertySet
->getPropertySetInfo();
940 const Sequence
<Property
> aProperties
= xPropertySetInfo
->getProperties();
942 for (const Property
& rProp
: aProperties
)
944 std::cerr
<< rProp
.Name
<< std::endl
;
945 std::cerr
<< comphelper::anyToString(xPropertySet
->getPropertyValue(rProp
.Name
)) << std::endl
;
953 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */