23 #include <oox/token/properties.hxx>
25 #include <com/sun/star/awt/Rectangle.hpp>
26 #include <com/sun/star/awt/Size.hpp>
27 #include <com/sun/star/beans/PropertyValues.hpp>
28 #include <com/sun/star/beans/XPropertySet.hpp>
29 #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
30 #include <com/sun/star/drawing/EnhancedCustomShapeTextFrame.hpp>
31 #include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp>
32 #include <com/sun/star/drawing/XShape.hpp>
47 : mnShapePresetType ( -1 )
48 , mbShapeTypeOverride(
false)
49 , mbMirroredX (
false )
50 , mbMirroredY (
false )
51 , mnTextRotateAngle ( 0 )
52 , mnTextCameraZRotateAngle ( 0 )
64 std::vector<CustomShapeGuide>::size_type
nIndex = 0;
65 for( ; nIndex < rGuideList.size(); nIndex++ )
70 if ( nIndex == rGuideList.size() )
71 rGuideList.push_back( rGuide );
72 return static_cast< sal_Int32
>( nIndex );
82 sal_Int32
nIndex =
static_cast< sal_Int32
>( rGuideList.size() ) - 1;
83 for( ; nIndex >= 0; nIndex-- )
85 if ( rGuideList[ nIndex ].
maName == rFormulaName )
131 aPropSet.
setProperty( PROP_CustomShapeGeometry, aSeq );
135 static const OUStringLiteral sCustomShapeGeometry(
u"CustomShapeGeometry");
136 static const OUStringLiteral sAdjustmentValues(
u"AdjustmentValues");
137 uno::Any aGeoPropSet = xPropSet->getPropertyValue( sCustomShapeGeometry );
138 uno::Sequence< beans::PropertyValue > aGeoPropSeq;
139 if ( aGeoPropSet >>= aGeoPropSeq )
141 for (
auto& rGeoProp : asNonConstRange(aGeoPropSeq) )
143 if ( rGeoProp.Name == sAdjustmentValues )
145 uno::Sequence< css::drawing::EnhancedCustomShapeAdjustmentValue > aAdjustmentSeq;
146 if ( rGeoProp.Value >>= aAdjustmentSeq )
148 auto aAdjustmentSeqRange = asNonConstRange(aAdjustmentSeq);
152 if ( adjustmentGuide.maName.getLength() > 3 )
154 sal_Int32 nAdjustmentIndex =
o3tl::toInt32(adjustmentGuide.maName.subView( 3 )) - 1;
155 if ( ( nAdjustmentIndex >= 0 ) && ( nAdjustmentIndex < aAdjustmentSeq.getLength() ) )
157 EnhancedCustomShapeAdjustmentValue aAdjustmentVal;
158 aAdjustmentVal.Value <<= adjustmentGuide.maFormula.toInt32();
159 aAdjustmentVal.State = PropertyState_DIRECT_VALUE;
160 aAdjustmentVal.Name = adjustmentGuide.maName;
161 aAdjustmentSeqRange[ nAdjustmentIndex ] = aAdjustmentVal;
163 }
else if ( aAdjustmentSeq.hasElements() ) {
164 EnhancedCustomShapeAdjustmentValue aAdjustmentVal;
165 aAdjustmentVal.Value <<= adjustmentGuide.maFormula.toInt32();
166 aAdjustmentVal.State = PropertyState_DIRECT_VALUE;
167 aAdjustmentVal.Name = adjustmentGuide.maName;
168 if (nIndex < aAdjustmentSeq.getLength())
170 aAdjustmentSeqRange[nIndex] = aAdjustmentVal;
175 rGeoProp.Value <<= aAdjustmentSeq;
176 xPropSet->setPropertyValue( sCustomShapeGeometry,
Any( aGeoPropSeq ) );
187 aPropertyMap.
setProperty( PROP_Type, OUString(
"ooxml-non-primitive" ));
196 awt::Rectangle aViewBox( 0, 0, aSize.Width, aSize.Height );
198 aViewBox = awt::Rectangle( 0, 0, 0, 0 );
202 auto aAdjustmentValuesRange = asNonConstRange(aAdjustmentValues);
205 EnhancedCustomShapeAdjustmentValue aAdjustmentVal;
207 aAdjustmentVal.State = PropertyState_DIRECT_VALUE;
209 aAdjustmentValuesRange[
i ] = aAdjustmentVal;
211 aPropertyMap.
setProperty( PROP_AdjustmentValues, aAdjustmentValues);
225 sal_uInt32 nParameterPairs = 0;
227 nParameterPairs +=
i.parameter.size();
230 auto aParameterPairsRange = asNonConstRange(aParameterPairs);
232 for (
auto const &
i: maPath2DList )
233 for (
auto const & j:
i.parameter )
234 aParameterPairsRange[ k++ ] = j;
235 aPath.
setProperty( PROP_Coordinates, aParameterPairs);
237 if ( !maPath2DList.empty() )
239 bool bAllZero =
true;
240 for (
auto const &
i: maPath2DList )
250 std::transform(maPath2DList.begin(), maPath2DList.end(), aSubViewSize.getArray(),
254 "set subpath; size: " << p2d.w <<
" x " << p2d.h);
255 return awt::Size(p2d.w, p2d.h);
257 aPath.
setProperty( PROP_SubViewSize, aSubViewSize);
262 aPropertyMap.
setProperty( PROP_Path, aPathSequence);
266 [](
const auto& g) {
return g.maFormula; });
267 aPropertyMap.
setProperty( PROP_Equations, aEquations);
270 auto aHandlesRange = asNonConstRange(aHandles);
346 SAL_INFO(
"oox.cscode",
"==cscode== begin");
348 SAL_INFO(
"oox.cscode",
"==cscode== end");
349 SAL_INFO(
"oox.csdata",
"==csdata== begin");
351 SAL_INFO(
"oox.csdata",
"==csdata== end");
356 aPropSet.
setProperty( PROP_CustomShapeGeometry, aSeq );
TokenMap & StaticTokenMap()
static void dumpData(const css::uno::Reference< css::beans::XPropertySet > &rXPropSet)
A helper that maps property identifiers to property values.
static sal_Int32 GetCustomShapeGuideValue(const std::vector< CustomShapeGuide > &rGuideList, std::u16string_view rFormulaName)
bool setProperty(sal_Int32 nPropId, Type &&rValue)
Sets the specified property to the passed value.
sal_Int32 mnTextRotateAngle
std::unordered_map< sal_Int32, PropertyMap > PresetDataMap
std::vector< CustomShapeGuide > maGuideList
static void initializePresetDataMap()
css::uno::Reference< css::beans::XPropertySet > makePropertySet() const
Creates a property set supporting the XPropertySet interface and inserts all properties.
static PresetDataMap maPresetDataMap
std::vector< AdjustHandle > maAdjustHandleList
bool representsDefaultShape() const
Returns whether or not the current CustomShapeProperties represent a default shape preset that is rec...
sal_Int32 mnShapePresetType
sal_Int32 mnTextCameraZRotateAngle
css::uno::Sequence< sal_Int8 > const & getUtf8TokenName(sal_Int32 nToken) const
Returns the UTF8 name of the passed token identifier as byte sequence.
OptValue< GeomRect > maTextRect
css::uno::Sequence< css::beans::PropertyValue > makePropertyValueSequence() const
Returns a sequence of property values, filled with all contained properties.
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
A wrapper for a UNO property set.
std::vector< css::drawing::EnhancedCustomShapeSegment > maSegments
css::uno::Sequence< sal_Int8 > const & getShapePresetTypeName() const
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
std::vector< Path2D > maPath2DList
#define SAL_INFO(area, stream)
static void dumpCode(const css::uno::Reference< css::beans::XPropertySet > &rXPropSet)
Sequence< sal_Int8 > aSeq
static sal_Int32 SetCustomShapeGuideValue(std::vector< CustomShapeGuide > &rGuideList, const CustomShapeGuide &rGuide)
void pushToPropSet(const css::uno::Reference< css::beans::XPropertySet > &xPropSet, const css::awt::Size &aSize)
sal_Int32 getShapePresetType() const
std::vector< CustomShapeGuide > maAdjustmentGuideList
bool setProperty(sal_Int32 nPropId, const Type &rValue)
Puts the passed value into the property set.
bool m_bDetectedRangeSegmentation false