Coverage Report

Created: 2026-04-09 11:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/oox/source/drawingml/shape.cxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
5
 * This Source Code Form is subject to the terms of the Mozilla Public
6
 * License, v. 2.0. If a copy of the MPL was not distributed with this
7
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
11
 *   Licensed to the Apache Software Foundation (ASF) under one or more
12
 *   contributor license agreements. See the NOTICE file distributed
13
 *   with this work for additional information regarding copyright
14
 *   ownership. The ASF licenses this file to you under the Apache
15
 *   License, Version 2.0 (the "License"); you may not use this file
16
 *   except in compliance with the License. You may obtain a copy of
17
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18
 */
19
20
#include <config_wasm_strip.h>
21
22
#include <oox/drawingml/shape.hxx>
23
#include <drawingml/customshapeproperties.hxx>
24
#include <oox/drawingml/theme.hxx>
25
#include <drawingml/fillproperties.hxx>
26
#include <drawingml/fontworkhelpers.hxx>
27
#include <drawingml/graphicproperties.hxx>
28
#include <drawingml/lineproperties.hxx>
29
#include <drawingml/presetgeometrynames.hxx>
30
#include <drawingml/shape3dproperties.hxx>
31
#include <drawingml/scene3dhelper.hxx>
32
#include <drawingml/effectproperties.hxx>
33
#include <oox/drawingml/shapepropertymap.hxx>
34
#include <drawingml/textbody.hxx>
35
#include <drawingml/textparagraph.hxx>
36
#include <drawingml/ThemeOverrideFragmentHandler.hxx>
37
#include <drawingml/table/tableproperties.hxx>
38
#include <oox/drawingml/chart/chartconverter.hxx>
39
#include <drawingml/chart/chartspacefragment.hxx>
40
#include <drawingml/chart/stylefragment.hxx>
41
#include <drawingml/chart/stylemodel.hxx>
42
#include <drawingml/chart/colorsmodel.hxx>
43
#include <drawingml/chart/chartspacemodel.hxx>
44
#include <o3tl/safeint.hxx>
45
#include <o3tl/unit_conversion.hxx>
46
#include <oox/ppt/pptimport.hxx>
47
#include <oox/vml/vmldrawing.hxx>
48
#include <oox/vml/vmlshape.hxx>
49
#include <oox/vml/vmlshapecontainer.hxx>
50
#include <oox/core/xmlfilterbase.hxx>
51
#include <oox/helper/graphichelper.hxx>
52
#include <oox/helper/propertyset.hxx>
53
#include <oox/helper/modelobjecthelper.hxx>
54
#include <oox/mathml/imexport.hxx>
55
#include <oox/mathml/importutils.hxx>
56
#include <oox/token/properties.hxx>
57
#include "diagram/datamodel_oox.hxx"
58
#include <oox/drawingml/diagram/diagramhelper_oox.hxx>
59
60
#include <comphelper/classids.hxx>
61
#include <comphelper/propertysequence.hxx>
62
#include <comphelper/propertyvalue.hxx>
63
#include <comphelper/sequence.hxx>
64
#include <comphelper/diagnose_ex.hxx>
65
#include <comphelper/sequenceashashmap.hxx>
66
#include <tools/gen.hxx>
67
#include <tools/globname.hxx>
68
#include <tools/mapunit.hxx>
69
#include <editeng/unoprnms.hxx>
70
#include <com/sun/star/awt/FontSlant.hpp>
71
#include <com/sun/star/awt/Size.hpp>
72
#include <com/sun/star/awt/XBitmap.hpp>
73
#include <com/sun/star/awt/FontWeight.hpp>
74
#include <com/sun/star/graphic/XGraphic.hpp>
75
#include <com/sun/star/container/XNamed.hpp>
76
#include <com/sun/star/container/XEnumerationAccess.hpp>
77
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
78
#include <com/sun/star/xml/dom/XDocument.hpp>
79
#include <com/sun/star/xml/sax/XFastSAXSerializable.hpp>
80
#include <com/sun/star/drawing/FillStyle.hpp>
81
#include <com/sun/star/drawing/HomogenMatrix3.hpp>
82
#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
83
#include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
84
#include <com/sun/star/drawing/GraphicExportFilter.hpp>
85
#include <com/sun/star/drawing/XShapes.hpp>
86
#include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
87
#include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp>
88
#include <com/sun/star/drawing/EnhancedCustomShapeTextPathMode.hpp>
89
#include <com/sun/star/drawing/ConnectorType.hpp>
90
#include <com/sun/star/embed/XEmbeddedObject.hpp>
91
#include <com/sun/star/text/XText.hpp>
92
#include <com/sun/star/table/BorderLine2.hpp>
93
#include <com/sun/star/table/ShadowFormat.hpp>
94
#include <com/sun/star/chart2/XChartDocument.hpp>
95
#include <com/sun/star/chart2/XChartStyle.hpp>
96
#include <com/sun/star/chart2/XChartColorStyle.hpp>
97
#include <com/sun/star/style/ParagraphAdjust.hpp>
98
#include <com/sun/star/io/XOutputStream.hpp>
99
#include <com/sun/star/lang/Locale.hpp>
100
#include <com/sun/star/i18n/ScriptType.hpp>
101
#include <com/sun/star/text/WritingMode2.hpp>
102
103
#include <basegfx/point/b2dpoint.hxx>
104
#include <basegfx/polygon/b2dpolygon.hxx>
105
#include <basegfx/matrix/b2dhommatrix.hxx>
106
#include <com/sun/star/document/XActionLockable.hpp>
107
#include <com/sun/star/chart2/data/XDataReceiver.hpp>
108
#include <officecfg/Office/Common.hxx>
109
#include <svx/svdobj.hxx>
110
#include <svx/svdotable.hxx>
111
#include <svx/svdtrans.hxx>
112
#include <tools/stream.hxx>
113
#include <unotools/streamwrap.hxx>
114
#include <unotools/mediadescriptor.hxx>
115
#include <vcl/graph.hxx>
116
#include <vcl/graphicfilter.hxx>
117
#include <vcl/svapp.hxx>
118
#include <vcl/wmfexternal.hxx>
119
#include <sal/log.hxx>
120
#include <svx/sdtaitm.hxx>
121
#include <oox/drawingml/diagram/diagram.hxx>
122
#include <docmodel/theme/Theme.hxx>
123
#include <i18nlangtag/languagetag.hxx>
124
#include <i18nlangtag/mslangid.hxx>
125
126
using namespace ::oox::core;
127
using namespace ::com::sun::star;
128
using namespace ::com::sun::star::uno;
129
using namespace ::com::sun::star::beans;
130
using namespace ::com::sun::star::frame;
131
using namespace ::com::sun::star::text;
132
using namespace ::com::sun::star::drawing;
133
using namespace ::com::sun::star::style;
134
135
namespace oox::drawingml {
136
137
Shape::Shape()
138
29.0k
: mpLinePropertiesPtr( std::make_shared<LineProperties>() )
139
29.0k
, mpShapeRefLinePropPtr( std::make_shared<LineProperties>() )
140
29.0k
, mpFillPropertiesPtr( std::make_shared<FillProperties>() )
141
29.0k
, mpShapeRefFillPropPtr( std::make_shared<FillProperties>() )
142
29.0k
, mpGraphicPropertiesPtr( std::make_shared<GraphicProperties>() )
143
29.0k
, mpCustomShapePropertiesPtr( std::make_shared<CustomShapeProperties>() )
144
29.0k
, mp3DPropertiesPtr( std::make_shared<Shape3DProperties>() )
145
29.0k
, mpEffectPropertiesPtr( std::make_shared<EffectProperties>() )
146
29.0k
, mpShapeRefEffectPropPtr( std::make_shared<EffectProperties>() )
147
29.0k
, mpMasterTextListStyle( std::make_shared<TextListStyle>() )
148
29.0k
, mnSubType( 0 )
149
29.0k
, meFrameType( FRAMETYPE_GENERIC )
150
29.0k
, mnRotation( 0 )
151
29.0k
, mnDiagramRotation( 0 )
152
29.0k
, mbFlipH( false )
153
29.0k
, mbFlipV( false )
154
29.0k
, mbHidden( false )
155
29.0k
, mbHiddenMasterShape( false )
156
29.0k
, mbLocked( false )
157
29.0k
, mbWPGChild(false)
158
29.0k
, mbLockedCanvas( false )
159
29.0k
, mbWordprocessingCanvas(false)
160
29.0k
, mbWps( false )
161
29.0k
, mbTextBox( false )
162
29.0k
, mbHasLinkedTxbx( false )
163
29.0k
, mbHasCustomPrompt( false )
164
29.0k
, mpDiagramHelper( nullptr )
165
29.0k
{
166
29.0k
    setDefaults(/*bDefaultHeight*/true);
167
29.0k
}
168
169
170
Shape::Shape( const OUString& rServiceName, bool bDefaultHeight )
171
150k
: mpLinePropertiesPtr( std::make_shared<LineProperties>() )
172
150k
, mpShapeRefLinePropPtr( std::make_shared<LineProperties>() )
173
150k
, mpFillPropertiesPtr( std::make_shared<FillProperties>() )
174
150k
, mpShapeRefFillPropPtr( std::make_shared<FillProperties>() )
175
150k
, mpGraphicPropertiesPtr( std::make_shared<GraphicProperties>() )
176
150k
, mpCustomShapePropertiesPtr( std::make_shared<CustomShapeProperties>() )
177
150k
, mp3DPropertiesPtr( std::make_shared<Shape3DProperties>() )
178
150k
, mpEffectPropertiesPtr( std::make_shared<EffectProperties>() )
179
150k
, mpShapeRefEffectPropPtr( std::make_shared<EffectProperties>() )
180
150k
, mpMasterTextListStyle( std::make_shared<TextListStyle>() )
181
150k
, mnSubType( 0 )
182
150k
, meFrameType( FRAMETYPE_GENERIC )
183
150k
, mnRotation( 0 )
184
150k
, mnDiagramRotation( 0 )
185
150k
, mbFlipH( false )
186
150k
, mbFlipV( false )
187
150k
, mbHidden( false )
188
150k
, mbHiddenMasterShape( false )
189
150k
, mbLocked( false )
190
150k
, mbWPGChild(false)
191
150k
, mbLockedCanvas( false )
192
150k
, mbWordprocessingCanvas(false)
193
150k
, mbWps( false )
194
150k
, mbTextBox( false )
195
150k
, mbHasLinkedTxbx( false )
196
150k
, mbHasCustomPrompt( false )
197
150k
, mpDiagramHelper( nullptr )
198
150k
{
199
150k
    msServiceName = rServiceName;
200
150k
    setDefaults(bDefaultHeight);
201
150k
}
202
203
Shape::Shape( const ShapePtr& pSourceShape )
204
390
: mpTextBody(pSourceShape->mpTextBody)
205
390
, mpLinePropertiesPtr( pSourceShape->mpLinePropertiesPtr )
206
390
, mpShapeRefLinePropPtr( pSourceShape->mpShapeRefLinePropPtr )
207
390
, mpFillPropertiesPtr( pSourceShape->mpFillPropertiesPtr )
208
390
, mpShapeRefFillPropPtr( pSourceShape->mpShapeRefFillPropPtr )
209
390
, mpGraphicPropertiesPtr( pSourceShape->mpGraphicPropertiesPtr )
210
390
, mpCustomShapePropertiesPtr( pSourceShape->mpCustomShapePropertiesPtr )
211
390
, mpTablePropertiesPtr( pSourceShape->mpTablePropertiesPtr )
212
390
, mp3DPropertiesPtr( pSourceShape->mp3DPropertiesPtr )
213
390
, mpEffectPropertiesPtr (pSourceShape->mpEffectPropertiesPtr)
214
390
, mpShapeRefEffectPropPtr(pSourceShape->mpShapeRefEffectPropPtr)
215
390
, maShapeProperties( pSourceShape->maShapeProperties )
216
390
, mpMasterTextListStyle( pSourceShape->mpMasterTextListStyle )
217
390
, msServiceName( pSourceShape->msServiceName )
218
390
, msName( pSourceShape->msName )
219
390
, msInternalName( pSourceShape->msInternalName )
220
390
, msId( pSourceShape->msId )
221
390
, mnSubType( pSourceShape->mnSubType )
222
390
, moSubTypeIndex( pSourceShape->moSubTypeIndex )
223
390
, maShapeStyleRefs( pSourceShape->maShapeStyleRefs )
224
390
, maSize( pSourceShape->maSize )
225
390
, maPosition( pSourceShape->maPosition )
226
390
, meFrameType( pSourceShape->meFrameType )
227
390
, mnRotation( pSourceShape->mnRotation )
228
390
, mnDiagramRotation( pSourceShape->mnDiagramRotation )
229
390
, mbFlipH( pSourceShape->mbFlipH )
230
390
, mbFlipV( pSourceShape->mbFlipV )
231
390
, mbHidden( pSourceShape->mbHidden )
232
390
, mbHiddenMasterShape( pSourceShape->mbHiddenMasterShape )
233
390
, mbLocked( pSourceShape->mbLocked )
234
390
, mbWPGChild( pSourceShape->mbWPGChild )
235
390
, mbLockedCanvas( pSourceShape->mbLockedCanvas )
236
390
, mbWordprocessingCanvas(pSourceShape->mbWordprocessingCanvas)
237
390
, mbWps( pSourceShape->mbWps )
238
390
, mbTextBox( pSourceShape->mbTextBox )
239
390
, mbHasLinkedTxbx(false)
240
390
, mbHasCustomPrompt( pSourceShape->mbHasCustomPrompt )
241
390
, mnZOrder(pSourceShape->mnZOrder)
242
390
, mnZOrderOff(pSourceShape->mnZOrderOff)
243
390
, mnDataNodeType(pSourceShape->mnDataNodeType)
244
390
, mfAspectRatio(pSourceShape->mfAspectRatio)
245
390
, mpDiagramHelper( nullptr )
246
390
, msDiagramDataModelID(pSourceShape->msDiagramDataModelID)
247
390
{}
248
249
Shape::~Shape()
250
180k
{
251
    // DiagramHelper should not be set here anymore, see
252
    // propagateDiagramHelper below (maybe assert..?)
253
180k
    delete mpDiagramHelper;
254
180k
}
255
256
void Shape::prepareDiagramHelper(
257
    const std::shared_ptr< SmartArtDiagram >& rDiagramPtr,
258
    const std::shared_ptr<::oox::drawingml::Theme>& rTheme)
259
143
{
260
    // Prepare Diagram data collecting for this Shape
261
143
    if( nullptr == mpDiagramHelper && FRAMETYPE_DIAGRAM == meFrameType )
262
143
    {
263
143
        mpDiagramHelper = new DiagramHelper_oox(
264
143
            rDiagramPtr,
265
143
            rTheme);
266
143
    }
267
143
}
268
269
void Shape::propagateDiagramHelper()
270
293
{
271
    // Propagate collected Diagram data to data holder
272
293
    if (FRAMETYPE_DIAGRAM == meFrameType && nullptr != mpDiagramHelper)
273
143
    {
274
143
        if (mxShape)
275
143
        {
276
143
            mpDiagramHelper->doAnchor(mxShape);
277
143
            mpDiagramHelper = nullptr;
278
143
        }
279
143
    }
280
281
    // If propagation failed, delete/cleanup here. Since the DiagramHelper
282
    // holds a Diagram and that this Shape it is necessary - the destructor
283
    // will not be called and will be too late
284
293
    if (nullptr != mpDiagramHelper)
285
0
    {
286
0
        delete mpDiagramHelper;
287
0
        mpDiagramHelper = nullptr;
288
0
    }
289
293
}
290
291
void Shape::migrateDiagramHelperToNewShape(const ShapePtr& pTarget)
292
36
{
293
36
    if(!mpDiagramHelper)
294
0
    {
295
0
        return;
296
0
    }
297
298
36
    if(!pTarget)
299
0
    {
300
        // no migrate target, but cleanup helper
301
0
        delete mpDiagramHelper;
302
0
        mpDiagramHelper = nullptr;
303
0
        return;
304
0
    }
305
306
36
    if(pTarget->mpDiagramHelper)
307
0
    {
308
        // this should no happen, but if there is already a helper, clean it up
309
0
        delete pTarget->mpDiagramHelper;
310
0
        pTarget->mpDiagramHelper = nullptr;
311
0
    }
312
313
    // exchange and reset to nullptr
314
36
    pTarget->mpDiagramHelper = mpDiagramHelper;
315
36
    mpDiagramHelper = nullptr;
316
36
}
317
318
table::TablePropertiesPtr const & Shape::getTableProperties()
319
130
{
320
130
    if ( !mpTablePropertiesPtr )
321
130
        mpTablePropertiesPtr = std::make_shared<table::TableProperties>();
322
130
    return mpTablePropertiesPtr;
323
130
}
324
325
void Shape::setDefaults(bool bHeight)
326
179k
{
327
179k
    maDefaultShapeProperties.setProperty(PROP_TextAutoGrowHeight, false);
328
179k
    maDefaultShapeProperties.setProperty(PROP_TextWordWrap, true);
329
179k
    maDefaultShapeProperties.setProperty(PROP_TextLeftDistance, static_cast< sal_Int32 >( 250 ));
330
179k
    maDefaultShapeProperties.setProperty(PROP_TextUpperDistance, static_cast< sal_Int32 >( 125 ));
331
179k
    maDefaultShapeProperties.setProperty(PROP_TextRightDistance, static_cast< sal_Int32 >( 250 ));
332
179k
    maDefaultShapeProperties.setProperty(PROP_TextLowerDistance, static_cast< sal_Int32 >( 125 ));
333
179k
    if (bHeight)
334
179k
        maDefaultShapeProperties.setProperty(PROP_CharHeight, static_cast< float >( 18.0 ));
335
179k
    maDefaultShapeProperties.setProperty(PROP_TextVerticalAdjust, TextVerticalAdjust_TOP);
336
179k
    maDefaultShapeProperties.setProperty(PROP_ParaAdjust,
337
179k
                                         static_cast<sal_Int16>(ParagraphAdjust_LEFT));
338
179k
}
339
340
::oox::vml::OleObjectInfo& Shape::setOleObjectType()
341
0
{
342
0
    OSL_ENSURE( meFrameType == FRAMETYPE_GENERIC, "Shape::setOleObjectType - multiple frame types" );
343
0
    meFrameType = FRAMETYPE_OLEOBJECT;
344
0
    mxOleObjectInfo = std::make_shared<::oox::vml::OleObjectInfo>( true );
345
0
    return *mxOleObjectInfo;
346
0
}
347
348
ChartShapeInfo& Shape::setChartType( bool bEmbedShapes )
349
437
{
350
437
    OSL_ENSURE( meFrameType == FRAMETYPE_GENERIC, "Shape::setChartType - multiple frame types" );
351
437
    meFrameType = FRAMETYPE_CHART;
352
437
    if (mbWps)
353
0
        msServiceName = u"com.sun.star.drawing.temporaryForXMLImportOLE2Shape"_ustr;
354
437
    else
355
437
        msServiceName = u"com.sun.star.drawing.OLE2Shape"_ustr;
356
437
    mxChartShapeInfo = std::make_shared<ChartShapeInfo>( bEmbedShapes );
357
437
    return *mxChartShapeInfo;
358
437
}
359
360
void Shape::setDiagramType()
361
451
{
362
451
    OSL_ENSURE( meFrameType == FRAMETYPE_GENERIC, "Shape::setDiagramType - multiple frame types" );
363
451
    meFrameType = FRAMETYPE_DIAGRAM;
364
451
    msServiceName = u"com.sun.star.drawing.GroupShape"_ustr;
365
451
    mnSubType = 0;
366
451
}
367
368
void Shape::setTableType()
369
130
{
370
130
    OSL_ENSURE( meFrameType == FRAMETYPE_GENERIC, "Shape::setTableType - multiple frame types" );
371
130
    meFrameType = FRAMETYPE_TABLE;
372
130
    msServiceName = u"com.sun.star.drawing.TableShape"_ustr;
373
130
    mnSubType = 0;
374
130
}
375
376
const ShapeStyleRef* Shape::getShapeStyleRef( sal_Int32 nRefType ) const
377
427k
{
378
427k
    ShapeStyleRefMap::const_iterator aIt = maShapeStyleRefs.find( nRefType );
379
427k
    return (aIt == maShapeStyleRefs.end()) ? nullptr : &aIt->second;
380
427k
}
381
382
void Shape::addShape(
383
        ::oox::core::XmlFilterBase& rFilterBase,
384
        const Theme* pTheme,
385
        const Reference< XShapes >& rxShapes,
386
        const basegfx::B2DHomMatrix& aTransformation,
387
        const FillProperties& rShapeOrParentShapeFillProps,
388
        ShapeIdMap* pShapeMap,
389
        const oox::drawingml::ShapePtr& pParentGroupShape)
390
10.1k
{
391
10.1k
    SAL_INFO("oox.drawingml", "Shape::addShape: id='" << msId << "'");
392
393
10.1k
    try
394
10.1k
    {
395
10.1k
        OUString sServiceName( msServiceName );
396
10.1k
        if( !sServiceName.isEmpty() )
397
10.1k
        {
398
10.1k
            basegfx::B2DHomMatrix aMatrix( aTransformation );
399
10.1k
            Reference< XShape > xShape( createAndInsert( rFilterBase, sServiceName, pTheme, rxShapes, false, nullptr, aMatrix, rShapeOrParentShapeFillProps, pParentGroupShape) );
400
401
10.1k
            if( pShapeMap && !msId.isEmpty() )
402
26
            {
403
26
                (*pShapeMap)[ msId ] = shared_from_this();
404
26
            }
405
406
            // if this is a group shape, we have to add also each child shape
407
10.1k
            Reference< XShapes > xShapes( xShape, UNO_QUERY );
408
10.1k
            if ( xShapes.is() )
409
659
                addChildren( rFilterBase, *this, pTheme, xShapes, pShapeMap, aMatrix );
410
411
10.1k
            if (isInWordprocessingCanvas() && !isWPGChild())
412
0
            {
413
                // This is a drawing canvas. In case the canvas has no fill and no stroke, Word does
414
                // not render shadow or glow, even if it is set for the canvas. Thus we disable shadow
415
                // and glow in this case for the ersatz background shape of the drawing canvas.
416
0
                try
417
0
                {
418
0
                    oox::drawingml::ShapePtr pBgShape = getChildren().front();
419
0
                    const Reference<css::drawing::XShape>& xBgShape = pBgShape->getXShape();
420
0
                    Reference<XPropertySet> xBgProps(xBgShape, uno::UNO_QUERY);
421
0
                    drawing::FillStyle eFillStyle = drawing::FillStyle_NONE;
422
0
                    xBgProps->getPropertyValue(u"FillStyle"_ustr) >>= eFillStyle;
423
0
                    drawing::LineStyle eLineStyle = drawing::LineStyle_NONE;
424
0
                    xBgProps->getPropertyValue(u"LineStyle"_ustr) >>= eLineStyle;
425
0
                    if (eFillStyle == drawing::FillStyle_NONE
426
0
                        && eLineStyle == drawing::LineStyle_NONE)
427
0
                    {
428
0
                        xBgProps->setPropertyValue(UNO_NAME_SHADOW, uno::Any(false));
429
0
                        xBgProps->setPropertyValue(u"GlowEffectRadius"_ustr, uno::Any(sal_Int32(0)));
430
0
                    }
431
0
                }
432
0
                catch (const Exception&)
433
0
                {
434
0
                    TOOLS_WARN_EXCEPTION("oox.drawingml", "Shape::addShape mbWordprocessingCanvas");
435
0
                }
436
0
            }
437
438
10.1k
            if (isWPGChild() && xShape)
439
372
            {
440
                // This is a wps shape and it is the child of the WPG, now copy the
441
                // the text body properties to the xshape.
442
372
                Reference<XPropertySet> xChildWPSProperties(xShape, uno::UNO_QUERY);
443
444
372
                if (getTextBody() && xChildWPSProperties)
445
372
                {
446
372
                    xChildWPSProperties->setPropertyValue(
447
372
                        UNO_NAME_TEXT_VERTADJUST,
448
372
                        uno::Any(getTextBody()->getTextProperties().meVA));
449
450
372
                    xChildWPSProperties->setPropertyValue(
451
372
                        UNO_NAME_TEXT_LEFTDIST,
452
372
                        uno::Any(getTextBody()->getTextProperties().moInsets[0].has_value()
453
372
                                     ? *getTextBody()->getTextProperties().moInsets[0]
454
372
                                     : 0));
455
372
                    xChildWPSProperties->setPropertyValue(
456
372
                        UNO_NAME_TEXT_UPPERDIST,
457
372
                        uno::Any(getTextBody()->getTextProperties().moInsets[1].has_value()
458
372
                                     ? *getTextBody()->getTextProperties().moInsets[1]
459
372
                                     : 0));
460
372
                    xChildWPSProperties->setPropertyValue(
461
372
                        UNO_NAME_TEXT_RIGHTDIST,
462
372
                        uno::Any(getTextBody()->getTextProperties().moInsets[2].has_value()
463
372
                                     ? *getTextBody()->getTextProperties().moInsets[2]
464
372
                                     : 0));
465
372
                    xChildWPSProperties->setPropertyValue(
466
372
                        UNO_NAME_TEXT_LOWERDIST,
467
372
                        uno::Any(getTextBody()->getTextProperties().moInsets[3].has_value()
468
372
                                     ? *getTextBody()->getTextProperties().moInsets[3]
469
372
                                     : 0));
470
372
                }
471
472
                // tdf#145147 Set the Hyperlink property to the child wps shape.
473
372
                if (getShapeProperties().hasProperty(PROP_URL)) try
474
0
                {
475
0
                    uno::Any aAny = getShapeProperties().getProperty(PROP_URL);
476
0
                    OUString sUrl = aAny.get<OUString>();
477
0
                    if (!sUrl.isEmpty())
478
0
                        xChildWPSProperties->setPropertyValue(UNO_NAME_HYPERLINK, aAny);
479
0
                }
480
0
                catch (const Exception&)
481
0
                {
482
0
                }
483
372
            }
484
485
10.1k
            if( meFrameType == FRAMETYPE_DIAGRAM )
486
293
            {
487
                // set DiagramHelper at SdrObjGroup
488
293
                propagateDiagramHelper();
489
490
                // Check if this is the PPTX import, so far converting SmartArt to a non-editable
491
                // metafile is only implemented for DOCX.
492
293
                bool bPowerPoint = dynamic_cast<oox::ppt::PowerPointImport*>(&rFilterBase) != nullptr;
493
494
293
                if (!officecfg::Office::Common::Filter::Microsoft::Import::SmartArtToShapes::get() && !bPowerPoint)
495
293
                    convertSmartArtToMetafile( rFilterBase );
496
293
            }
497
498
10.1k
            NamedShapePairs* pNamedShapePairs = rFilterBase.getDiagramFontHeights();
499
10.1k
            if (xShape.is() && pNamedShapePairs)
500
937
            {
501
937
                auto itPairs = pNamedShapePairs->find(getInternalName());
502
937
                if (itPairs != pNamedShapePairs->end())
503
16
                {
504
16
                    auto it = itPairs->second.find(shared_from_this());
505
16
                    if (it != itPairs->second.end())
506
0
                    {
507
                        // Our drawingml::Shape is in the list of an internal name, remember the now
508
                        // inserted XShape.
509
0
                        it->second = std::move(xShape);
510
0
                    }
511
16
                }
512
937
            }
513
10.1k
        }
514
10.1k
    }
515
10.1k
    catch( const Exception& )
516
10.1k
    {
517
0
        TOOLS_WARN_EXCEPTION( "oox.drawingml", "Shape::addShape" );
518
0
    }
519
10.1k
}
520
521
void Shape::setLockedCanvas(bool bLockedCanvas)
522
1.56k
{
523
1.56k
    mbLockedCanvas = bLockedCanvas;
524
1.56k
}
525
526
void Shape::setWordprocessingCanvas(bool bWordprocessingCanvas)
527
1.50k
{
528
1.50k
    mbWordprocessingCanvas = bWordprocessingCanvas;
529
1.50k
}
530
531
void Shape::setWPGChild(bool bWPG)
532
372
{
533
372
    mbWPGChild = bWPG;
534
372
}
535
536
void Shape::setWps(bool bWps)
537
24.5k
{
538
24.5k
    mbWps = bWps;
539
24.5k
}
540
541
void Shape::setTextBox(bool bTextBox)
542
478
{
543
478
    mbTextBox = bTextBox;
544
478
}
545
546
void Shape::applyShapeReference( const Shape& rReferencedShape, bool bUseText )
547
23.5k
{
548
23.5k
    SAL_INFO("oox.drawingml", "Shape::applyShapeReference: apply '" << rReferencedShape.msId << "' to '" << msId << "'");
549
550
23.5k
    if ( rReferencedShape.mpTextBody && bUseText )
551
23.0k
        mpTextBody = std::make_shared<TextBody>( *rReferencedShape.mpTextBody );
552
489
    else
553
489
        mpTextBody.reset();
554
23.5k
    maShapeProperties = rReferencedShape.maShapeProperties;
555
23.5k
    mpShapeRefLinePropPtr = std::make_shared<LineProperties>( rReferencedShape.getActualLineProperties(nullptr) );
556
23.5k
    mpShapeRefFillPropPtr = std::make_shared<FillProperties>( rReferencedShape.getActualFillProperties(nullptr, nullptr) );
557
23.5k
    mpCustomShapePropertiesPtr = std::make_shared<CustomShapeProperties>( *rReferencedShape.mpCustomShapePropertiesPtr );
558
23.5k
    mpTablePropertiesPtr = rReferencedShape.mpTablePropertiesPtr ? std::make_shared<table::TableProperties>( *rReferencedShape.mpTablePropertiesPtr ) : nullptr;
559
23.5k
    mpShapeRefEffectPropPtr = std::make_shared<EffectProperties>( rReferencedShape.getActualEffectProperties(nullptr) );
560
23.5k
    mpMasterTextListStyle = std::make_shared<TextListStyle>( *rReferencedShape.mpMasterTextListStyle );
561
23.5k
    setSize(rReferencedShape.maSize);
562
23.5k
    setPosition(rReferencedShape.maPosition);
563
23.5k
    setRotation(rReferencedShape.getRotation());
564
23.5k
    setFlipH(rReferencedShape.getFlipH());
565
23.5k
    setFlipV(rReferencedShape.getFlipV());
566
23.5k
    setHidden(rReferencedShape.getHidden());
567
23.5k
    setLocked(rReferencedShape.getLocked());
568
23.5k
}
569
570
namespace {
571
572
struct ActionLockGuard
573
{
574
    explicit ActionLockGuard(Reference<drawing::XShape> const& xShape)
575
67.2k
        : m_xLockable(xShape, UNO_QUERY)
576
67.2k
    {
577
67.2k
        if (m_xLockable.is()) {
578
67.2k
            m_xLockable->addActionLock();
579
67.2k
        }
580
67.2k
    }
581
    ~ActionLockGuard()
582
67.2k
    {
583
67.2k
        if (m_xLockable.is()) {
584
67.2k
            m_xLockable->removeActionLock();
585
67.2k
        }
586
67.2k
    }
587
private:
588
    Reference<document::XActionLockable> m_xLockable;
589
};
590
591
}
592
593
// for group shapes, the following method is also adding each child
594
void Shape::addChildren(
595
        XmlFilterBase& rFilterBase,
596
        Shape& rMaster,
597
        const Theme* pTheme,
598
        const Reference< XShapes >& rxShapes,
599
        ShapeIdMap* pShapeMap,
600
        const basegfx::B2DHomMatrix& aTransformation )
601
670
{
602
670
    for (auto const& child : rMaster.maChildren)
603
4.44k
    {
604
4.44k
        child->setMasterTextListStyle( mpMasterTextListStyle );
605
4.44k
        child->addShape( rFilterBase, pTheme, rxShapes, aTransformation, getFillProperties(), pShapeMap, rMaster.shared_from_this());
606
4.44k
    }
607
670
}
608
609
static SdrTextHorzAdjust lcl_convertAdjust( ParagraphAdjust eAdjust )
610
0
{
611
0
    if (eAdjust == ParagraphAdjust_LEFT)
612
0
        return SDRTEXTHORZADJUST_LEFT;
613
0
    else if (eAdjust == ParagraphAdjust_RIGHT)
614
0
        return SDRTEXTHORZADJUST_RIGHT;
615
0
    else if (eAdjust == ParagraphAdjust_CENTER)
616
0
        return SDRTEXTHORZADJUST_CENTER;
617
0
    return SDRTEXTHORZADJUST_LEFT;
618
0
}
619
620
static TextHorizontalAdjust lcl_convertTextAdjust(ParagraphAdjust eAdjust)
621
360
{
622
360
    if (eAdjust == ParagraphAdjust_LEFT)
623
223
        return drawing::TextHorizontalAdjust_LEFT;
624
137
    else if (eAdjust == ParagraphAdjust_RIGHT)
625
134
        return drawing::TextHorizontalAdjust_RIGHT;
626
3
    else
627
3
        return drawing::TextHorizontalAdjust_BLOCK;
628
360
}
629
630
// LO does not interpret properties in styles belonging to the text content of a FontWork shape,
631
// but only those in the shape style. This method copies properties from the text content styles to
632
// the shape style.
633
static void lcl_copyCharPropsToShape(const uno::Reference<drawing::XShape>& xShape,
634
                                     const TextBodyPtr& pTextBody,
635
                                     const ::oox::core::XmlFilterBase& rFilter)
636
0
{
637
0
    if (!xShape.is() || !pTextBody)
638
0
        return;
639
640
0
    Reference<XPropertySet> xSet(xShape, UNO_QUERY);
641
0
    if (!xSet.is())
642
0
        return;
643
644
    // Content stretches or scales to given width and height, thus disable autogrow.
645
0
    xSet->setPropertyValue(UNO_NAME_TEXT_AUTOGROWHEIGHT, uno::Any(false));
646
0
    xSet->setPropertyValue(UNO_NAME_TEXT_AUTOGROWWIDTH, uno::Any(false));
647
648
    // LibreOffice is not able (as of Nov 2022) to use different styles for the paragraphs or
649
    // characters in FontWork, since that was not allowed in old binary WordArt. We use the
650
    // properties of the first non empty paragraph for now.
651
0
    const TextParagraphVector& rParagraphs = pTextBody->getParagraphs();
652
0
    auto aParaIt = std::find_if_not(rParagraphs.cbegin(), rParagraphs.cend(),
653
0
                                    [](const std::shared_ptr<TextParagraph> pParagraph) {
654
0
                                        return pParagraph->getRuns().empty();
655
0
                                    });
656
0
    if (aParaIt != rParagraphs.cend())
657
0
    {
658
0
        const std::shared_ptr<TextParagraph>& pParagraph = *aParaIt;
659
0
        const TextRunVector& rRuns = pParagraph->getRuns();
660
0
        auto aRunIt = std::find_if_not(rRuns.cbegin(), rRuns.cend(),
661
0
                                       [](const std::shared_ptr<TextRun> pRun)
662
0
                                       {
663
0
                                           return pRun->getText().isEmpty()
664
0
                                                  || pRun->getText() == " "
665
0
                                                  || pRun->getText().toChar() == 0xA0; // NBSP
666
0
                                       });
667
0
        if (aRunIt != rRuns.cend())
668
0
        {
669
0
            const std::shared_ptr<TextRun>& pRun = *aRunIt;
670
0
            TextCharacterProperties& rCharProps = pRun->getTextCharacterProperties();
671
672
            // set language
673
0
            if (rCharProps.moLang.has_value() && !rCharProps.moLang.value().isEmpty())
674
0
            {
675
0
                LanguageTag aTag(rCharProps.moLang.value());
676
0
                const css::lang::Locale& aLocale(aTag.getLocale(false));
677
0
                switch (MsLangId::getScriptType(aTag.getLanguageType()))
678
0
                {
679
0
                    case css::i18n::ScriptType::LATIN:
680
0
                        xSet->setPropertyValue(u"CharLocale"_ustr, uno::Any(aLocale));
681
0
                        break;
682
0
                    case css::i18n::ScriptType::ASIAN:
683
0
                        xSet->setPropertyValue(u"CharLocaleAsian"_ustr, uno::Any(aLocale));
684
0
                        break;
685
0
                    case css::i18n::ScriptType::COMPLEX:
686
0
                        xSet->setPropertyValue(u"CharLocaleComplex"_ustr, uno::Any(aLocale));
687
0
                        break;
688
0
                    default:;
689
0
                }
690
0
            }
691
692
            // Font Weight, Posture, Height
693
0
            if (rCharProps.moBold.has_value() && rCharProps.moBold.value())
694
0
            {
695
0
                xSet->setPropertyValue(UNO_NAME_CHAR_WEIGHT, uno::Any(css::awt::FontWeight::BOLD));
696
0
            }
697
0
            if (rCharProps.moItalic.has_value() && rCharProps.moItalic.value())
698
0
            {
699
0
                xSet->setPropertyValue(UNO_NAME_CHAR_POSTURE,
700
0
                                       uno::Any(css::awt::FontSlant::FontSlant_ITALIC));
701
0
            }
702
0
            if (rCharProps.moHeight.has_value())
703
0
            {
704
0
                sal_Int32 nHeight = rCharProps.moHeight.value() / 100;
705
0
                xSet->setPropertyValue(UNO_NAME_CHAR_HEIGHT, uno::Any(nHeight));
706
0
            }
707
708
            // Put theme fonts into shape properties
709
0
            OUString sFontName;
710
0
            sal_Int16 nFontPitch = 0;
711
0
            sal_Int16 nFontFamily = 0;
712
0
            bool bRet(false);
713
0
            if (const Theme* pTheme = rFilter.getCurrentTheme())
714
0
            {
715
                // minor Latin
716
0
                if (const TextFont* pFont = pTheme->resolveFont(u"+mn-lt"))
717
0
                {
718
0
                    bRet = pFont->getFontData(sFontName, nFontPitch, nFontFamily, nullptr, rFilter);
719
0
                    if (bRet)
720
0
                    {
721
0
                        xSet->setPropertyValue(u"CharFontName"_ustr, uno::Any(sFontName));
722
0
                        xSet->setPropertyValue(u"CharFontPitch"_ustr, uno::Any(nFontPitch));
723
0
                        xSet->setPropertyValue(u"CharFontFamily"_ustr, uno::Any(nFontFamily));
724
0
                    }
725
0
                }
726
                // minor Asian
727
0
                if (const TextFont* pFont = pTheme->resolveFont(u"+mn-ea"))
728
0
                {
729
0
                    bRet = pFont->getFontData(sFontName, nFontPitch, nFontFamily, nullptr, rFilter);
730
0
                    if (bRet)
731
0
                    {
732
0
                        xSet->setPropertyValue(u"CharFontNameAsian"_ustr, uno::Any(sFontName));
733
0
                        xSet->setPropertyValue(u"CharFontPitchAsian"_ustr, uno::Any(nFontPitch));
734
0
                        xSet->setPropertyValue(u"CharFontFamilyAsian"_ustr, uno::Any(nFontFamily));
735
0
                    }
736
0
                }
737
                // minor Complex
738
0
                if (const TextFont* pFont = pTheme->resolveFont(u"+mn-cs"))
739
0
                {
740
0
                    bRet = pFont->getFontData(sFontName, nFontPitch, nFontFamily, nullptr, rFilter);
741
0
                    if (bRet)
742
0
                    {
743
0
                        xSet->setPropertyValue(u"CharFontNameComplex"_ustr, uno::Any(sFontName));
744
0
                        xSet->setPropertyValue(u"CharFontPitchComplex"_ustr, uno::Any(nFontPitch));
745
0
                        xSet->setPropertyValue(u"CharFontFamilyComplex"_ustr, uno::Any(nFontFamily));
746
0
                    }
747
0
                }
748
0
            }
749
750
            // Replace theme fonts with formatting at run if any. ToDo: Inspect paragraph too?
751
            // Latin
752
0
            bRet = rCharProps.maLatinFont.getFontData(sFontName, nFontPitch, nFontFamily, nullptr, rFilter);
753
0
            if (!bRet)
754
                // In case there is no direct font, try to look it up as a theme reference.
755
0
                bRet = rCharProps.maLatinThemeFont.getFontData(sFontName, nFontPitch, nFontFamily, nullptr,
756
0
                                                               rFilter);
757
758
0
            if (bRet)
759
0
            {
760
0
                xSet->setPropertyValue(u"CharFontName"_ustr, uno::Any(sFontName));
761
0
                xSet->setPropertyValue(u"CharFontPitch"_ustr, uno::Any(nFontPitch));
762
0
                xSet->setPropertyValue(u"CharFontFamily"_ustr, uno::Any(nFontFamily));
763
0
            }
764
            // Asian
765
0
            bRet = rCharProps.maAsianFont.getFontData(sFontName, nFontPitch, nFontFamily, nullptr, rFilter);
766
0
            if (!bRet)
767
                // In case there is no direct font, try to look it up as a theme reference.
768
0
                bRet = rCharProps.maAsianThemeFont.getFontData(sFontName, nFontPitch, nFontFamily, nullptr,
769
0
                                                               rFilter);
770
0
            if (bRet)
771
0
            {
772
0
                xSet->setPropertyValue(u"CharFontNameAsian"_ustr, uno::Any(sFontName));
773
0
                xSet->setPropertyValue(u"CharFontPitchAsian"_ustr, uno::Any(nFontPitch));
774
0
                xSet->setPropertyValue(u"CharFontFamilyAsian"_ustr, uno::Any(nFontFamily));
775
0
            }
776
            // Complex
777
0
            bRet
778
0
                = rCharProps.maComplexFont.getFontData(sFontName, nFontPitch, nFontFamily, nullptr, rFilter);
779
0
            if (!bRet)
780
                // In case there is no direct font, try to look it up as a theme reference.
781
0
                bRet = rCharProps.maComplexThemeFont.getFontData(sFontName, nFontPitch, nFontFamily, nullptr,
782
0
                                                                 rFilter);
783
0
            if (bRet)
784
0
            {
785
0
                xSet->setPropertyValue(u"CharFontNameComplex"_ustr, uno::Any(sFontName));
786
0
                xSet->setPropertyValue(u"CharFontPitchComplex"_ustr, uno::Any(nFontPitch));
787
0
                xSet->setPropertyValue(u"CharFontFamilyComplex"_ustr, uno::Any(nFontFamily));
788
0
            }
789
790
            // LO uses shape properties, MS Office character properties. Copy them from char to shape.
791
            // Outline
792
0
            if (rCharProps.moTextOutlineProperties.has_value())
793
0
            {
794
0
                oox::drawingml::ShapePropertyMap aStrokeShapeProps(rFilter.getModelObjectHelper());
795
0
                rCharProps.moTextOutlineProperties.value().pushToPropMap(
796
0
                    aStrokeShapeProps, rFilter.getGraphicHelper());
797
0
                for (const auto& rProp : aStrokeShapeProps.makePropertyValueSequence())
798
0
                {
799
0
                    xSet->setPropertyValue(rProp.Name, rProp.Value);
800
0
                }
801
0
            }
802
0
            else
803
0
            {
804
0
                xSet->setPropertyValue(UNO_NAME_LINESTYLE, uno::Any(drawing::LineStyle_NONE));
805
0
            }
806
807
            // Fill
808
            // ToDo: Replace flip and rotate constants in parameters with actual values.
809
            // tdf#155327 If color is not explicitly set, MS Office uses scheme color 'tx1'.
810
0
            oox::drawingml::ShapePropertyMap aFillShapeProps(rFilter.getModelObjectHelper());
811
0
            if (!rCharProps.maFillProperties.moFillType.has_value())
812
0
                rCharProps.maFillProperties.moFillType = XML_solidFill;
813
0
            if (!rCharProps.maFillProperties.maFillColor.isUsed())
814
0
                rCharProps.maFillProperties.maFillColor.setSchemeClr(XML_tx1);
815
0
            rCharProps.maFillProperties.pushToPropMap(aFillShapeProps, rFilter.getGraphicHelper(),
816
0
                                                      /*nShapeRotation*/ 0,
817
0
                                                      /*nPhClr*/ API_RGB_TRANSPARENT,
818
0
                                                      /*aShapeSize*/ css::awt::Size(0, 0),
819
0
                                                      /*nPhClrTheme*/ -1,
820
0
                                                      /*bFlipH*/ false, /*bFlipV*/ false,
821
0
                                                      /*bIsCustomShape*/ true);
822
0
            for (const auto& rProp : aFillShapeProps.makePropertyValueSequence())
823
0
            {
824
0
                xSet->setPropertyValue(rProp.Name, rProp.Value);
825
0
            }
826
827
            // ToDo: Import WordArt glow and simple shadow effects. They are available in LO.
828
0
        }
829
830
        // LO does not evaluate paragraph alignment in text path mode. Use text area anchor instead.
831
0
        {
832
0
            ParagraphAdjust eAdjust = ParagraphAdjust_LEFT;
833
0
            if (pParagraph->getProperties().getParaAdjust())
834
0
                eAdjust = *pParagraph->getProperties().getParaAdjust();
835
0
            xSet->setPropertyValue(u"ParaAdjust"_ustr, uno::Any(eAdjust));
836
0
            SdrObject* pShape = SdrObject::getSdrObjectFromXShape(xShape);
837
0
            assert(pShape);
838
0
            SdrTextHorzAdjust eHorzAdjust = lcl_convertAdjust(eAdjust);
839
0
            pShape->SetMergedItem(SdrTextHorzAdjustItem(eHorzAdjust));
840
0
        }
841
0
    }
842
843
    // Vertical adjustment is only meaningful for OOXML WordArt shapes of 'Follow Path' kinds. We set
844
    // it so, that text position is approximately same as in MS Office.
845
0
    const OUString sMSPresetType = pTextBody->getTextProperties().msPrst;
846
0
    const OUString sFontworkType = PresetGeometryTypeNames::GetFontworkType(sMSPresetType);
847
0
    SdrObject* pShape = SdrObject::getSdrObjectFromXShape(xShape);
848
0
    assert(pShape);
849
0
    if (sFontworkType == "fontwork-arch-up-curve" || sFontworkType == "fontwork-circle-curve")
850
0
        pShape->SetMergedItem(SdrTextVertAdjustItem(SdrTextVertAdjust::SDRTEXTVERTADJUST_BOTTOM));
851
0
    else if (sFontworkType == "fontwork-arch-down-curve")
852
0
        pShape->SetMergedItem(SdrTextVertAdjustItem(SdrTextVertAdjust::SDRTEXTVERTADJUST_TOP));
853
0
    else
854
0
        pShape->SetMergedItem(SdrTextVertAdjustItem(SdrTextVertAdjust::SDRTEXTVERTADJUST_CENTER));
855
0
}
856
857
// Some helper methods for createAndInsert
858
namespace
859
{
860
// mirrors aTransformation at its center axis
861
// only valid if neither rotation or shear included
862
void lcl_mirrorAtCenter(basegfx::B2DHomMatrix& aTransformation, bool bFlipH, bool bFlipV)
863
3.67k
{
864
3.67k
    if (!bFlipH && !bFlipV)
865
2.62k
        return;
866
1.04k
    basegfx::B2DPoint aCenter(0.5, 0.5);
867
1.04k
    aCenter *= aTransformation;
868
1.04k
    aTransformation.translate(-aCenter);
869
1.04k
    aTransformation.scale(bFlipH ? -1.0 : 1.0, bFlipV ? -1.0 : 1.0);
870
1.04k
    aTransformation.translate(aCenter);
871
1.04k
    return;
872
3.67k
}
873
874
// only valid if neither rotation or shear included
875
void lcl_doSpecialMSOWidthHeightToggle(basegfx::B2DHomMatrix& aTransformation)
876
0
{
877
    // The values are directly set at the matrix without any matrix multiplication.
878
    // That way it is valid for lines too. Those have zero width or height.
879
0
    const double fSx(aTransformation.get(0, 0));
880
0
    const double fSy(aTransformation.get(1, 1));
881
0
    const double fTx(aTransformation.get(0, 2));
882
0
    const double fTy(aTransformation.get(1, 2));
883
0
    aTransformation.set(0, 0, fSy);
884
0
    aTransformation.set(1, 1, fSx);
885
0
    aTransformation.set(0, 2, fTx + 0.5 * (fSx - fSy));
886
0
    aTransformation.set(1, 2, fTy + 0.5 * (fSy - fSx));
887
0
    return;
888
0
}
889
890
void lcl_RotateAtCenter(basegfx::B2DHomMatrix& aTransformation, sal_Int32 nMSORotationAngle)
891
2.12k
{
892
2.12k
    if (nMSORotationAngle == 0)
893
0
        return;
894
2.12k
    double fRad = basegfx::deg2rad<60000>(nMSORotationAngle);
895
2.12k
    basegfx::B2DPoint aCenter(0.5, 0.5);
896
2.12k
    aCenter *= aTransformation;
897
2.12k
    aTransformation.translate(-aCenter);
898
2.12k
    aTransformation.rotate(fRad);
899
2.12k
    aTransformation.translate(aCenter);
900
2.12k
    return;
901
2.12k
}
902
903
Degree100 lcl_MSORotateAngleToAPIAngle(const sal_Int32 nMSORotationAngle)
904
2.39k
{
905
    // Converts a shape rotation angle from MSO to angle for API property RotateAngle
906
    // from unit 1/60000 deg to unit 1/100 deg
907
2.39k
    Degree100 nAngle(nMSORotationAngle / 600);
908
    // API RotateAngle has opposite direction than nMSORotationAngle, thus 'minus'.
909
2.39k
    return NormAngle36000(-nAngle);
910
2.39k
}
911
912
void PushMasterTextListStyleToMasterShapeParagraphs(TextListStyle& rMasterTextListStyle, const uno::Reference<drawing::XShape>& xShape)
913
5.26k
{
914
5.26k
    uno::Reference<text::XTextRange> xShapeText(xShape, UNO_QUERY);
915
5.26k
    if (!xShapeText.is())
916
0
    {
917
0
        return;
918
0
    }
919
920
5.26k
    uno::Reference<container::XEnumerationAccess> xText(xShapeText->getText(), uno::UNO_QUERY);
921
5.26k
    if (!xText.is())
922
0
    {
923
0
        return;
924
0
    }
925
926
5.26k
    uno::Reference<container::XEnumeration> xParagraphs = xText->createEnumeration();
927
5.26k
    if (!xParagraphs.is())
928
0
    {
929
0
        return;
930
0
    }
931
932
41.7k
    while (xParagraphs->hasMoreElements())
933
36.4k
    {
934
36.4k
        uno::Reference<beans::XPropertySet> xParagraph(xParagraphs->nextElement(), uno::UNO_QUERY);
935
36.4k
        if (!xParagraph.is())
936
0
        {
937
0
            continue;
938
0
        }
939
940
36.4k
        uno::Reference<container::XIndexReplace> xNumberingRules;
941
36.4k
        if (!(xParagraph->getPropertyValue("NumberingRules") >>= xNumberingRules))
942
0
        {
943
0
            continue;
944
0
        }
945
946
36.4k
        rMasterTextListStyle.pushToNumberingRules(xNumberingRules, std::nullopt);
947
36.4k
        xParagraph->setPropertyValue("NumberingRules", uno::Any(xNumberingRules));
948
36.4k
    }
949
5.26k
}
950
}
951
952
Reference< XShape > const & Shape::createAndInsert(
953
        ::oox::core::XmlFilterBase& rFilterBase,
954
        const OUString& rServiceName,
955
        const Theme* pTheme,
956
        const css::uno::Reference< css::drawing::XShapes >& rxShapes,
957
        bool bClearText,
958
        const oox::drawingml::ShapePtr& pPlaceholder,
959
        basegfx::B2DHomMatrix& aParentTransformation,
960
        const FillProperties& rShapeOrParentShapeFillProps,
961
        const oox::drawingml::ShapePtr& pParentGroupShape)
962
67.2k
{
963
67.2k
    bool bIsEmbMedia = false;
964
67.2k
    SAL_INFO("oox.drawingml", "Shape::createAndInsert: id='" << msId << "' service='" << rServiceName << "'");
965
966
67.2k
    formulaimport::XmlStreamBuilder * pMathXml(nullptr);
967
67.2k
    if (mpTextBody)
968
51.7k
    {
969
51.7k
        for (auto const& it : mpTextBody->getParagraphs())
970
69.2k
        {
971
69.2k
            if (it->HasMathXml())
972
0
            {
973
0
                if (!mpTextBody->isEmpty() || pMathXml != nullptr)
974
0
                {
975
0
                    SAL_WARN("oox.drawingml", "losing a Math object...");
976
0
                }
977
0
                else
978
0
                {
979
0
                    pMathXml = &it->GetMathXml();
980
0
                }
981
0
            }
982
69.2k
        }
983
51.7k
    }
984
985
    // tdf#90403 PowerPoint ignores a:ext cx and cy values of p:xfrm, and uses real table width and height
986
67.2k
    if ( mpTablePropertiesPtr && rServiceName == "com.sun.star.drawing.TableShape" )
987
130
    {
988
130
        maSize.Width = 0;
989
130
        for (auto const& elem : mpTablePropertiesPtr->getTableGrid())
990
610
        {
991
610
            maSize.Width = o3tl::saturating_add(maSize.Width, static_cast<sal_Int32>(elem));
992
610
        }
993
130
        maSize.Height = 0;
994
130
        for (auto const& elem : mpTablePropertiesPtr->getTableRows())
995
604
        {
996
            // WARN: If some rows can't fit the content, this is not the final height
997
604
            maSize.Height = o3tl::saturating_add(maSize.Height, elem.getHeight());
998
604
        }
999
130
    }
1000
1001
67.2k
    awt::Rectangle aShapeRectHmm(
1002
67.2k
        o3tl::convert(maPosition.X, o3tl::Length::emu, o3tl::Length::mm100),
1003
67.2k
        o3tl::convert(maPosition.Y, o3tl::Length::emu, o3tl::Length::mm100),
1004
67.2k
        o3tl::convert(maSize.Width, o3tl::Length::emu, o3tl::Length::mm100),
1005
67.2k
        o3tl::convert(maSize.Height, o3tl::Length::emu, o3tl::Length::mm100));
1006
1007
67.2k
    OUString aServiceName;
1008
67.2k
    if (pMathXml)
1009
0
    {
1010
        // convert this shape to OLE
1011
0
        aServiceName = u"com.sun.star.drawing.OLE2Shape"_ustr;
1012
0
        msServiceName = aServiceName;
1013
0
        meFrameType = FRAMETYPE_GENERIC; // not OLEOBJECT, no stream in package
1014
0
        mnSubType = 0;
1015
0
    }
1016
67.2k
    else if (rServiceName == "com.sun.star.drawing.GraphicObjectShape" &&
1017
3.36k
        mpGraphicPropertiesPtr && !mpGraphicPropertiesPtr->m_sMediaPackageURL.isEmpty())
1018
0
    {
1019
0
        aServiceName = finalizeServiceName( rFilterBase, u"com.sun.star.presentation.MediaShape"_ustr, aShapeRectHmm );
1020
0
        bIsEmbMedia = true;
1021
0
    }
1022
67.2k
    else
1023
67.2k
    {
1024
67.2k
        aServiceName = finalizeServiceName( rFilterBase, rServiceName, aShapeRectHmm );
1025
67.2k
    }
1026
    // Use custom shape instead of GraphicObjectShape if the image is cropped to
1027
    // shape. Except rectangle, which does not require further cropping
1028
67.2k
    bool bIsCroppedGraphic = (aServiceName == "com.sun.star.drawing.GraphicObjectShape" &&
1029
3.36k
                              !mpCustomShapePropertiesPtr->representsDefaultShape());
1030
1031
67.2k
    bool bIsCustomShape = (aServiceName == "com.sun.star.drawing.CustomShape" || bIsCroppedGraphic);
1032
67.2k
    bool bIsConnectorShape = (aServiceName == "com.sun.star.drawing.ConnectorShape");
1033
1034
    // Look for 3D. Its z-rotation and extrusion color become shape properties. We consider a
1035
    // z-rotation of an image even we currently do not extrude an image to 3D-scene.
1036
67.2k
    bool bBlockExtrusion = !bIsCustomShape && mp3DPropertiesPtr->mnPreset.has_value();
1037
67.2k
    double fShapeRotateInclCamera = 0.0; // unit rad; same orientation as shape property RotateAngle
1038
67.2k
    Color aExtrusionColor;
1039
67.2k
    Scene3DHelper aScene3DHelper;
1040
67.2k
    bool bHas3DEffect = aScene3DHelper.setExtrusionProperties(
1041
67.2k
        mp3DPropertiesPtr, getRotation(), getCustomShapeProperties()->getExtrusionPropertyMap(),
1042
67.2k
        fShapeRotateInclCamera, aExtrusionColor, bBlockExtrusion);
1043
    // Currently the other places use unit 1/60000deg and MSO shape rotate orientation.
1044
67.2k
    sal_Int32 nShapeRotateInclCamera = -basegfx::rad2deg<60000>(fShapeRotateInclCamera);
1045
67.2k
    bool bIs3DGraphic = aServiceName == "com.sun.star.drawing.GraphicObjectShape" && bHas3DEffect;
1046
67.2k
    bIsCustomShape |= bIs3DGraphic;
1047
1048
    // The extrusion color does not belong to the extrusion properties but is secondary color in
1049
    // the style of the shape, FillColor2 in API. The case that no extrusion color was set is handled
1050
    // further down when FillProperties and LineProperties are handled.
1051
67.2k
    if (aExtrusionColor.isUsed())
1052
3
    {
1053
        // FillColor2 is not yet transformed to ComplexColor.
1054
3
        ::Color aColor = aExtrusionColor.getColor(rFilterBase.getGraphicHelper());
1055
3
        maShapeProperties.setProperty(PROP_FillColor2, aColor);
1056
3
    }
1057
1058
67.2k
    if (bHas3DEffect)
1059
3
    {
1060
3
        aScene3DHelper.setLightingProperties(mp3DPropertiesPtr, fShapeRotateInclCamera,
1061
3
                                             getCustomShapeProperties()->getExtrusionPropertyMap());
1062
3
        oox::Scene3DHelper::setMaterialProperties(
1063
3
            mp3DPropertiesPtr, getCustomShapeProperties()->getExtrusionPropertyMap());
1064
3
    }
1065
1066
67.2k
    if (bIsCroppedGraphic || bIs3DGraphic)
1067
0
    {
1068
0
        aServiceName = "com.sun.star.drawing.CustomShape";
1069
0
        mpGraphicPropertiesPtr->mbIsCustomShape = true;
1070
0
        mpGraphicPropertiesPtr->mbIsExtruded = bIs3DGraphic;
1071
0
    }
1072
67.2k
    bool bUseRotationTransform = !getWps() ||
1073
1.52k
            aServiceName == "com.sun.star.drawing.LineShape" ||
1074
1.34k
            aServiceName == "com.sun.star.drawing.GroupShape" ||
1075
1.15k
            getFlipH() ||
1076
1.15k
            getFlipV();
1077
1078
67.2k
    basegfx::B2DHomMatrix aTransformation; // will be cumulative transformation of this object
1079
1080
    // Special for SmartArt import. Rotate diagram's shape around object's center before sizing.
1081
67.2k
    if (bUseRotationTransform && getDiagramRotation() != 0)
1082
0
    {
1083
0
        aTransformation.translate(-0.5, -0.5);
1084
0
        aTransformation.rotate(basegfx::deg2rad<60000>(getDiagramRotation()));
1085
0
        aTransformation.translate(0.5, 0.5);
1086
0
    }
1087
1088
67.2k
    bool bLineShape = aServiceName == "com.sun.star.drawing.LineShape";
1089
67.2k
    bool bTopWriterLine = !pParentGroupShape && getWps() && bLineShape;
1090
    // Build object matrix from shape size and position; corresponds to MSO ext and off
1091
    // Only LineShape and ConnectorShape may have zero width or height.
1092
67.2k
    if (bLineShape || aServiceName == "com.sun.star.drawing.ConnectorShape")
1093
2.13k
    {
1094
        // For toplevel Writer lines, size is included in the point coordinates.
1095
2.13k
        if (!bTopWriterLine)
1096
2.13k
        {
1097
2.13k
            aTransformation.scale(maSize.Width, maSize.Height);
1098
2.13k
        }
1099
2.13k
    }
1100
65.1k
    else
1101
65.1k
    {
1102
65.1k
        aTransformation.scale(maSize.Width ? maSize.Width : 1.0,
1103
65.1k
                              maSize.Height ? maSize.Height : 1.0);
1104
65.1k
    }
1105
1106
    // Evaluate object flip. Other shapes than custom shapes have no attribute for flip but use
1107
    // negative scale. Flip in MSO is at object center.
1108
67.2k
    if (!bIsCustomShape && (getFlipH() || getFlipV()))
1109
1.04k
        lcl_mirrorAtCenter(aTransformation, getFlipH(), getFlipV());
1110
1111
    // Evaluate parent flip.
1112
    // A CustomShape has mirror not as negative scale, but as attributes.
1113
67.2k
    basegfx::B2DVector aParentScale(1.0, 1.0);
1114
67.2k
    basegfx::B2DVector aParentTranslate(0.0, 0.0);
1115
67.2k
    double fParentRotate(0.0);
1116
67.2k
    double fParentShearX(0.0);
1117
67.2k
    if (pParentGroupShape)
1118
4.44k
    {
1119
4.44k
        aParentTransformation.decompose(aParentScale, aParentTranslate, fParentRotate, fParentShearX);
1120
4.44k
        if (bIsCustomShape)
1121
2.62k
        {
1122
2.62k
            lcl_mirrorAtCenter(aTransformation, aParentScale.getX() < 0, aParentScale.getY() < 0);
1123
2.62k
            if (aParentScale.getX() < 0)
1124
0
                setFlipH(!getFlipH());
1125
2.62k
            if (aParentScale.getY() < 0)
1126
0
                setFlipV(!getFlipV());
1127
2.62k
        }
1128
4.44k
    }
1129
1130
67.2k
    if (maPosition.X != 0 || maPosition.Y != 0)
1131
57.3k
    {
1132
        // if global position is used, add it to transformation
1133
57.3k
        if (getWps() && pParentGroupShape == nullptr)
1134
857
            aTransformation.translate(
1135
857
                o3tl::convert(maPosition.X, o3tl::Length::mm100, o3tl::Length::emu),
1136
857
                o3tl::convert(maPosition.Y, o3tl::Length::mm100, o3tl::Length::emu));
1137
56.4k
        else
1138
56.4k
            aTransformation.translate(maPosition.X, maPosition.Y);
1139
57.3k
    }
1140
1141
    // Apply further parent transformations. First scale object then rotate. Other way round would
1142
    // introduce shearing.
1143
1144
    // The attributes chExt and chOff of the group in oox file contain the values on which the size
1145
    // and position of the child is based on. If they differ from the actual size of the group as
1146
    // given in its ext and off attributes, the child has to be transformed according the new values.
1147
67.2k
    if (pParentGroupShape)
1148
4.44k
    {
1149
        // ToDo: A diagram in a group might need special handling because it cannot flip and only
1150
        // resize uniformly. But currently it is imported with zero size, see tdf#139575. That needs
1151
        // to be fixed beforehand.
1152
1153
        // Scaling is done from left/top edges of the group. So these need to become coordinate axes.
1154
4.44k
        aTransformation.translate(-pParentGroupShape->maChPosition.X,
1155
4.44k
                                  -pParentGroupShape->maChPosition.Y);
1156
1157
        // oox allows zero or missing attribute chExt. In that case the scaling factor is 1.
1158
        // Transform2DContext::onCreateContext has set maChSize to maSize for groups in oox file in
1159
        // such cases. For own made groups (e.g. diagrams) that is missing.
1160
        // The factors cumulate on the way through the parent groups, so we do not use maSize of the
1161
        // direct parent group but the cumulated value from aParentScale.
1162
4.44k
        double fFactorX = 1.0;
1163
4.44k
        double fFactorY = 1.0;
1164
4.44k
        if (pParentGroupShape->maChSize.Width != 0)
1165
3.31k
            fFactorX = aParentScale.getX() / pParentGroupShape->maChSize.Width;
1166
4.44k
        if (pParentGroupShape->maChSize.Height != 0)
1167
3.31k
            fFactorY = aParentScale.getY() / pParentGroupShape->maChSize.Height;
1168
4.44k
        if (fFactorX != 1 || fFactorY != 1)
1169
90
        {
1170
            // It depends on the object rotation angle whether scaling is applied to switched
1171
            // width and height. MSO acts strange in that case (as of May 2021).
1172
90
            const sal_Int32 nDeg(getRotation() / 60000);
1173
90
            const bool bNeedsMSOWidthHeightToggle
1174
90
                = (nDeg >= 45 && nDeg < 135) || (nDeg >= 225 && nDeg < 315);
1175
90
            if (bNeedsMSOWidthHeightToggle)
1176
0
                lcl_doSpecialMSOWidthHeightToggle(aTransformation);
1177
1178
90
            aTransformation.scale(fFactorX, fFactorY);
1179
1180
90
            if (bNeedsMSOWidthHeightToggle)
1181
0
            {
1182
0
                lcl_doSpecialMSOWidthHeightToggle(aTransformation);
1183
                // In case of flip the special case needs an additional 180deg rotation.
1184
0
                if ((aParentScale.getX() < 0) != (aParentScale.getY() < 0))
1185
0
                    lcl_RotateAtCenter(aTransformation, 10800000);
1186
0
            }
1187
90
        }
1188
4.44k
    }
1189
1190
    // Apply object rotation at current object center
1191
    // The flip contained in aParentScale will affect orientation of object rotation angle.
1192
67.2k
    sal_Int16 nOrientation = ((aParentScale.getX() < 0) != (aParentScale.getY() < 0)) ? -1 : 1;
1193
    // ToDo: Not sure about the restrictions given by bUseRotationTransform.
1194
67.2k
    if (bUseRotationTransform && nShapeRotateInclCamera != 0)
1195
2.12k
    {
1196
2.12k
        lcl_RotateAtCenter(aTransformation, nOrientation * nShapeRotateInclCamera);
1197
2.12k
    }
1198
1199
67.2k
    if (fParentRotate != 0.0)
1200
372
        aTransformation.rotate(fParentRotate);
1201
67.2k
    if (!aParentTranslate.equalZero())
1202
1.16k
        aTransformation.translate(aParentTranslate);
1203
1204
67.2k
    aParentTransformation = aTransformation;
1205
1206
67.2k
    constexpr double fEmuToMm100 = o3tl::convert(1.0, o3tl::Length::emu, o3tl::Length::mm100);
1207
67.2k
    if (!bTopWriterLine)
1208
67.2k
    {
1209
67.2k
        aTransformation.scale(fEmuToMm100, fEmuToMm100);
1210
67.2k
    }
1211
1212
    // OOXML flips shapes before rotating them, so the rotation needs to be inverted
1213
67.2k
    if (bIsCustomShape && getFlipH() != getFlipV())
1214
40
    {
1215
40
        basegfx::B2DVector aScale, aTranslate;
1216
40
        double fRotate, fShearX;
1217
40
        aTransformation.decompose(aScale, aTranslate, fRotate, fShearX);
1218
1219
40
        if(fRotate != 0)
1220
32
        {
1221
32
            basegfx::B2DPoint aCenter(0.5, 0.5);
1222
32
            aCenter *= aTransformation;
1223
32
            aTransformation.translate( -aCenter.getX(), -aCenter.getY() );
1224
32
            aTransformation.rotate( fRotate * -2.0 );
1225
32
            aTransformation.translate( aCenter.getX(), aCenter.getY() );
1226
32
        }
1227
40
    }
1228
1229
    // special for lineshape
1230
67.2k
    uno::Sequence< uno::Sequence< awt::Point > > aPolyPolySequence( 1 );
1231
67.2k
    if (bLineShape)
1232
233
    {
1233
233
        ::basegfx::B2DPolygon aPoly;
1234
233
        aPoly.insert( 0, ::basegfx::B2DPoint( 0, 0 ) );
1235
233
        if (bTopWriterLine)
1236
0
        {
1237
            // No transform of individual points, everything apart from size is part of the
1238
            // transform matrix.
1239
0
            sal_Int32 nMM100Width = o3tl::convert(maSize.Width, o3tl::Length::emu, o3tl::Length::mm100);
1240
0
            sal_Int32 nMM100Height = o3tl::convert(maSize.Height, o3tl::Length::emu, o3tl::Length::mm100);
1241
0
            aPoly.insert(1, ::basegfx::B2DPoint(nMM100Width, nMM100Height));
1242
0
        }
1243
233
        else
1244
233
        {
1245
233
            aPoly.insert( 1, ::basegfx::B2DPoint( maSize.Width ? 1 : 0, maSize.Height ? 1 : 0 ) );
1246
233
            aPoly.transform( aTransformation );
1247
233
        }
1248
1249
        // now creating the corresponding PolyPolygon
1250
233
        sal_Int32 i, nNumPoints = aPoly.count();
1251
233
        uno::Sequence< awt::Point > aPointSequence( nNumPoints );
1252
233
        awt::Point* pPoints = aPointSequence.getArray();
1253
699
        for( i = 0; i < nNumPoints; ++i )
1254
466
        {
1255
466
            basegfx::B2DPoint aPoint( aPoly.getB2DPoint( i ) );
1256
1257
            // Guard against zero width or height.
1258
466
            if (i)
1259
233
            {
1260
233
                const basegfx::B2DPoint& rPreviousPoint = aPoly.getB2DPoint(i - 1);
1261
233
                if (aPoint.getX() - rPreviousPoint.getX() == 0)
1262
0
                    aPoint.setX(aPoint.getX() + 1);
1263
233
                if (aPoint.getY() - rPreviousPoint.getY() == 0)
1264
27
                    aPoint.setY(aPoint.getY() + 1);
1265
233
            }
1266
1267
466
            pPoints[i] = awt::Point(static_cast<sal_Int32>(aPoint.getX()), static_cast<sal_Int32>(aPoint.getY()));
1268
466
        }
1269
233
        aPolyPolySequence.getArray()[ 0 ] = std::move(aPointSequence);
1270
1271
233
        if (!(bTopWriterLine && !maSize.Width))
1272
233
        {
1273
233
            maShapeProperties.setProperty(PROP_PolyPolygon, aPolyPolySequence);
1274
233
        }
1275
233
    }
1276
67.2k
    HomogenMatrix3 aMatrix;
1277
67.2k
    tools::Rectangle aOrigSize;
1278
67.2k
    if ( aServiceName == "com.sun.star.drawing.ConnectorShape" )
1279
1.89k
    {
1280
1.89k
        ::basegfx::B2DPolygon aPoly;
1281
1.89k
        aPoly.insert( 0, ::basegfx::B2DPoint( 0, 0 ) );
1282
1.89k
        aPoly.insert( 1, ::basegfx::B2DPoint( maSize.Width ? 1 : 0, maSize.Height ? 1 : 0 ) );
1283
1.89k
        aPoly.transform( aTransformation );
1284
1285
1.89k
        basegfx::B2DPoint aStartPosition( aPoly.getB2DPoint( 0 ) );
1286
1.89k
        basegfx::B2DPoint aEndPosition( aPoly.getB2DPoint( 1 ) );
1287
1.89k
        awt::Point aAWTStartPosition( static_cast< sal_Int32 >( aStartPosition.getX() ), static_cast< sal_Int32 >( aStartPosition.getY() ) );
1288
1.89k
        awt::Point aAWTEndPosition( static_cast< sal_Int32 >( aEndPosition.getX() ), static_cast< sal_Int32 >( aEndPosition.getY() ) );
1289
1290
1.89k
        maShapeProperties.setProperty(PROP_StartPosition, aAWTStartPosition);
1291
1.89k
        maShapeProperties.setProperty(PROP_EndPosition, aAWTEndPosition);
1292
1.89k
    }
1293
65.3k
    else if (!bLineShape || bTopWriterLine)
1294
65.1k
    {
1295
        // now set transformation for this object
1296
1297
65.1k
        aMatrix.Line1.Column1 = aTransformation.get(0,0);
1298
65.1k
        aMatrix.Line1.Column2 = aTransformation.get(0,1);
1299
65.1k
        aMatrix.Line1.Column3 = aTransformation.get(0,2);
1300
1301
65.1k
        aMatrix.Line2.Column1 = aTransformation.get(1,0);
1302
65.1k
        aMatrix.Line2.Column2 = aTransformation.get(1,1);
1303
65.1k
        aMatrix.Line2.Column3 = aTransformation.get(1,2);
1304
1305
65.1k
        aMatrix.Line3.Column1 = 0;
1306
65.1k
        aMatrix.Line3.Column2 = 0;
1307
65.1k
        aMatrix.Line3.Column3 = 1;
1308
1309
65.1k
        if (!(bTopWriterLine && !maSize.Width))
1310
65.1k
        {
1311
65.1k
            maShapeProperties.setProperty(PROP_Transformation, aMatrix);
1312
65.1k
        }
1313
65.1k
    }
1314
1315
67.2k
    Reference< lang::XMultiServiceFactory > xServiceFact( rFilterBase.getModel(), UNO_QUERY_THROW );
1316
67.2k
    if ( !mxShape.is() )
1317
67.2k
    {
1318
67.2k
        mxShape.set( xServiceFact->createInstance( aServiceName ), UNO_QUERY_THROW );
1319
67.2k
    }
1320
1321
67.2k
    Reference< XPropertySet > xSet( mxShape, UNO_QUERY );
1322
67.2k
    bool bPlaceholderWithCustomPrompt = pPlaceholder && pPlaceholder->getCustomPrompt();
1323
67.2k
    if (xSet.is())
1324
67.2k
    {
1325
67.2k
        if (bTopWriterLine && !maSize.Width)
1326
0
        {
1327
            // Entirely vertical line, set the points and the transform separately to match the ODF
1328
            // import.
1329
0
            xSet->setPropertyValue(u"PolyPolygon"_ustr, Any(aPolyPolySequence));
1330
0
            xSet->setPropertyValue(u"Transformation"_ustr, Any(aMatrix));
1331
0
        }
1332
1333
67.2k
        if( !msName.isEmpty() )
1334
64.9k
        {
1335
64.9k
            Reference< container::XNamed > xNamed( mxShape, UNO_QUERY );
1336
64.9k
            if( xNamed.is() )
1337
64.9k
                xNamed->setName( msName );
1338
64.9k
        }
1339
67.2k
        if( !msDescription.isEmpty() )
1340
1.41k
        {
1341
1.41k
            xSet->setPropertyValue( u"Description"_ustr, Any( msDescription ) );
1342
1.41k
        }
1343
67.2k
        if (m_isDecorative)
1344
0
        {
1345
0
            xSet->setPropertyValue(u"Decorative"_ustr, Any(m_isDecorative));
1346
0
        }
1347
67.2k
        if (!msMacro.isEmpty())
1348
0
        {
1349
0
            putPropertyToGrabBag(u"mso-sp-macro"_ustr, Any(msMacro));
1350
0
        }
1351
67.2k
        if (!msTextLink.isEmpty())
1352
0
        {
1353
0
            putPropertyToGrabBag(u"mso-sp-textlink"_ustr, Any(msTextLink));
1354
0
        }
1355
67.2k
        if (!mbFLocksText) // set only if "false", otherwise it will use "true" by default
1356
5
        {
1357
5
            putPropertyToGrabBag(u"mso-sp-fLocksText"_ustr, Any(mbFLocksText));
1358
5
        }
1359
67.2k
        if (mbFPublished)
1360
0
        {
1361
0
            putPropertyToGrabBag(u"mso-sp-fPublished"_ustr, Any(mbFPublished));
1362
0
        }
1363
67.2k
        if (!msTitle.isEmpty())
1364
1
        {
1365
1
            xSet->setPropertyValue(u"Title"_ustr, Any(msTitle));
1366
1
        }
1367
1368
        // get tooltip attribute of <hlinkClick>
1369
67.2k
        OUString sTooltip;
1370
67.2k
        getShapeProperties().getProperty(PROP_Representation) >>= sTooltip;
1371
67.2k
        if (!sTooltip.isEmpty())
1372
2
            putPropertyToGrabBag(u"mso-hlinkClick-tooltip"_ustr, Any(sTooltip));
1373
1374
        // Placeholder uses the height set on the slide instead of the height from the master slide,
1375
        // if it has the "TextAutoGrowHeight" property
1376
67.2k
        if (getTextBody() && mxShape->getShapeType().startsWith("com.sun.star.presentation."))
1377
40.4k
        {
1378
40.4k
            bool bAutoGrowHeight = getTextBody()
1379
40.4k
                                       ->getTextProperties()
1380
40.4k
                                       .maPropertyMap.getProperty(PROP_TextAutoGrowHeight)
1381
40.4k
                                       .get<bool>();
1382
40.4k
            if (bAutoGrowHeight)
1383
0
            {
1384
0
                ppt::PowerPointImport* pPPT = dynamic_cast<ppt::PowerPointImport*>(&rFilterBase);
1385
0
                if (!pPPT->getActualSlidePersist()->isMasterPage())
1386
0
                {
1387
0
                    sal_Int32 nUpper = 0;
1388
0
                    sal_Int32 nLower = 0;
1389
0
                    sal_Int32 nHeight = maSize.Height / 360;
1390
0
                    if (getTextBody()->getTextProperties().moInsets[1].has_value()
1391
0
                        && getTextBody()->getTextProperties().moInsets[3].has_value())
1392
0
                    {
1393
0
                        nUpper = *getTextBody()->getTextProperties().moInsets[1];
1394
0
                        nLower = *getTextBody()->getTextProperties().moInsets[3];
1395
0
                    }
1396
0
                    else
1397
0
                    {
1398
0
                        maDefaultShapeProperties.getProperty(PROP_TextUpperDistance) >>= nUpper;
1399
0
                        maDefaultShapeProperties.getProperty(PROP_TextLowerDistance) >>= nLower;
1400
0
                    }
1401
0
                    nHeight -= (nUpper + nLower);
1402
0
                    mxShape->setSize(awt::Size(0, nHeight));
1403
0
                }
1404
0
            }
1405
40.4k
            else // the placeholder uses the height set on the master slide
1406
40.4k
                mxShape->setSize(awt::Size(0, 0));
1407
40.4k
        }
1408
1409
67.2k
        if (aServiceName != "com.sun.star.text.TextFrame")
1410
67.2k
            rxShapes->add( mxShape );
1411
1412
67.2k
        if (getHidden() || getHiddenMasterShape())
1413
1.22k
        {
1414
1.22k
            SAL_INFO("oox.drawingml", "Shape::createAndInsert: invisible shape with id='" << msId << "'");
1415
1.22k
            xSet->setPropertyValue( u"Visible"_ustr, Any( false ) );
1416
            // In Excel hidden means not printed, let's use visibility for now until that's handled separately
1417
1.22k
            xSet->setPropertyValue( u"Printable"_ustr, Any( false ) );
1418
1.22k
        }
1419
1420
67.2k
        if (getLocked())
1421
0
        {
1422
0
            xSet->setPropertyValue(u"MoveProtect"_ustr, Any(true));
1423
0
            xSet->setPropertyValue(u"SizeProtect"_ustr, Any(true));
1424
0
        }
1425
1426
67.2k
        ActionLockGuard const alg(mxShape);
1427
1428
67.2k
        if (!getDiagramDataModelID().isEmpty())
1429
437
        {
1430
437
            SdrObject* pSdrObject(SdrObject::getSdrObjectFromXShape(mxShape));
1431
1432
437
            if (nullptr != pSdrObject)
1433
437
            {
1434
                // I checked if pSdrObject has a DiagramHelper here once, but this is
1435
                // highly dependent on when propagateDiagramHelper() will be called
1436
                // and not needed since when a DiagramDataModelID is set locally
1437
                // is sufficient to know that we are in a Diagram context.
1438
437
                pSdrObject->setDiagramDataModelID(getDiagramDataModelID());
1439
437
            }
1440
437
        }
1441
1442
        // sj: removing default text of placeholder objects such as SlideNumberShape or HeaderShape
1443
67.2k
        if ( bClearText )
1444
14.3k
        {
1445
14.3k
            uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY );
1446
14.3k
            if ( xText.is() )
1447
14.3k
            {
1448
14.3k
                xText->setString( u""_ustr );
1449
14.3k
            }
1450
14.3k
        }
1451
1452
67.2k
        if (pMathXml)
1453
0
        {
1454
            // the "EmbeddedObject" property is read-only, so we have to create
1455
            // the shape first, and it can be read only after the shape is
1456
            // inserted into the document, so delay the actual import until here
1457
0
            SvGlobalName name(SO3_SM_CLASSID);
1458
0
            xSet->setPropertyValue(u"CLSID"_ustr, uno::Any(name.GetHexName()));
1459
0
            uno::Reference<embed::XEmbeddedObject> const xObj(
1460
0
                xSet->getPropertyValue(u"EmbeddedObject"_ustr), uno::UNO_QUERY);
1461
0
            if (xObj.is())
1462
0
            {
1463
0
                uno::Reference<uno::XInterface> const xMathModel(xObj->getComponent());
1464
0
                oox::FormulaImExportBase *const pMagic(
1465
0
                        dynamic_cast<oox::FormulaImExportBase*>(xMathModel.get()));
1466
0
                assert(pMagic);
1467
0
                pMagic->readFormulaOoxml(*pMathXml);
1468
0
            }
1469
0
        }
1470
1471
67.2k
        const GraphicHelper& rGraphicHelper = rFilterBase.getGraphicHelper();
1472
1473
67.2k
        ::Color nLinePhClr(ColorTransparency, 0xffffffff);
1474
67.2k
        ::Color nFillPhClr(ColorTransparency, 0xffffffff);
1475
67.2k
        sal_Int16 nFillPhClrTheme = -1;
1476
67.2k
        sal_Int16 nLinePhClrTheme = -1;
1477
        // TODO: use ph color when applying effect properties
1478
        //sal_Int32 nEffectPhClr = -1;
1479
1480
        // dmapper needs the original rotation angle for calculating square wrap. This angle is not
1481
        // available as property there, so store it in InteropGrabBag.
1482
67.2k
        putPropertyToGrabBag(u"mso-rotation-angle"_ustr, Any(getRotation()));
1483
1484
67.2k
        if( pTheme )
1485
64.3k
        {
1486
64.3k
            if( const ShapeStyleRef* pLineRef = getShapeStyleRef( XML_lnRef ) )
1487
3.27k
            {
1488
3.27k
                LineProperties aLineProperties;
1489
3.27k
                aLineProperties.maLineFill.moFillType = XML_noFill;
1490
3.27k
                if( const LineProperties* pLineProps = pTheme->getLineStyle( pLineRef->mnThemedIdx ) )
1491
948
                    aLineProperties.assignUsed( *pLineProps );
1492
3.27k
                nLinePhClr = pLineRef->maPhClr.getColor( rGraphicHelper );
1493
3.27k
                nLinePhClrTheme = pLineRef->maPhClr.getSchemeColorIndex();
1494
1495
                // Store style-related properties to InteropGrabBag to be able to export them back
1496
3.27k
                uno::Sequence<beans::PropertyValue> aProperties = comphelper::InitPropertySequence(
1497
3.27k
                {
1498
3.27k
                    {"SchemeClr", uno::Any(pLineRef->maPhClr.getSchemeColorName())},
1499
3.27k
                    {"Idx", uno::Any(pLineRef->mnThemedIdx)},
1500
3.27k
                    {"Color", uno::Any(nLinePhClr)},
1501
3.27k
                    {"LineStyle", uno::Any(aLineProperties.getLineStyle())},
1502
3.27k
                    {"LineCap", uno::Any(aLineProperties.getLineCap())},
1503
3.27k
                    {"LineJoint", uno::Any(aLineProperties.getLineJoint())},
1504
3.27k
                    {"LineWidth", uno::Any(aLineProperties.getLineWidth())},
1505
3.27k
                    {"Transformations", uno::Any(pLineRef->maPhClr.getTransformations())}
1506
3.27k
                });
1507
3.27k
                putPropertyToGrabBag( u"StyleLnRef"_ustr, Any( aProperties ) );
1508
3.27k
            }
1509
64.3k
            if( const ShapeStyleRef* pFillRef = getShapeStyleRef( XML_fillRef ) )
1510
3.27k
            {
1511
3.27k
                if (!getFillProperties().moUseBgFill.value_or(false))
1512
3.27k
                {
1513
3.27k
                    nFillPhClr = pFillRef->maPhClr.getColor(rGraphicHelper);
1514
3.27k
                    nFillPhClrTheme = pFillRef->maPhClr.getSchemeColorIndex();
1515
3.27k
                }
1516
1517
3.27k
                OUString sColorScheme = pFillRef->maPhClr.getSchemeColorName();
1518
3.27k
                if( !sColorScheme.isEmpty() )
1519
1.34k
                {
1520
1.34k
                    uno::Sequence<beans::PropertyValue> aProperties = comphelper::InitPropertySequence(
1521
1.34k
                    {
1522
1.34k
                        {"SchemeClr", uno::Any(sColorScheme)},
1523
1.34k
                        {"Idx", uno::Any(pFillRef->mnThemedIdx)},
1524
1.34k
                        {"Color", uno::Any(nFillPhClr)},
1525
1.34k
                        {"Transformations", uno::Any(pFillRef->maPhClr.getTransformations())}
1526
1.34k
                    });
1527
1528
1.34k
                    putPropertyToGrabBag( u"StyleFillRef"_ustr, Any( aProperties ) );
1529
1.34k
                }
1530
3.27k
            }
1531
64.3k
            if( const ShapeStyleRef* pEffectRef = getShapeStyleRef( XML_effectRef ) )
1532
3.27k
            {
1533
                // TODO: use ph color when applying effect properties
1534
                // nEffectPhClr = pEffectRef->maPhClr.getColor( rGraphicHelper );
1535
1536
                // Store style-related properties to InteropGrabBag to be able to export them back
1537
3.27k
                uno::Sequence<beans::PropertyValue> aProperties = comphelper::InitPropertySequence(
1538
3.27k
                {
1539
3.27k
                    {"SchemeClr", uno::Any(pEffectRef->maPhClr.getSchemeColorName())},
1540
3.27k
                    {"Idx", uno::Any(pEffectRef->mnThemedIdx)},
1541
3.27k
                    {"Transformations", uno::Any(pEffectRef->maPhClr.getTransformations())}
1542
3.27k
                });
1543
3.27k
                putPropertyToGrabBag( u"StyleEffectRef"_ustr, Any( aProperties ) );
1544
3.27k
            }
1545
64.3k
        }
1546
67.2k
        ShapePropertyMap aShapeProps( rFilterBase.getModelObjectHelper() );
1547
1548
        // add properties from textbody to shape properties
1549
67.2k
        if( mpTextBody )
1550
51.7k
        {
1551
            // tdf#67347: In case of Stacked, PP calculates in the vertical direction with the
1552
            // horizontal alignment.
1553
            // In LO, we simulate it by setting TextVerticalAdjust based on the ParagraphAdjust
1554
            // of the 1. paragraph
1555
            // It is not perfect, because we have 1 TextVerticalAdjust / 1 shape, and it
1556
            // does not support justified, while we can have many ParagraphAdjust / 1 shape
1557
            // (if the shape have more paragraphs)
1558
51.7k
            if (mpTextBody->getTextProperties().maPropertyMap.hasProperty(PROP_WritingMode)
1559
17.1k
                && mpTextBody->getTextProperties().maPropertyMap.getProperty(PROP_WritingMode)
1560
17.1k
                       == uno::Any(text::WritingMode2::STACKED)
1561
0
                && mpTextBody->getParagraphs().size() > 0
1562
0
                && aServiceName != "com.sun.star.drawing.GroupShape")
1563
0
            {
1564
0
                std::optional<css::style::ParagraphAdjust>& oParaAdjust
1565
0
                    = mpTextBody->getParagraphs()[0]->getProperties().getParaAdjust();
1566
1567
0
                if (oParaAdjust)
1568
0
                {
1569
0
                    switch (*oParaAdjust)
1570
0
                    {
1571
0
                        case ParagraphAdjust::ParagraphAdjust_LEFT:
1572
0
                            mpTextBody->getTextProperties().meVA
1573
0
                                = TextVerticalAdjust::TextVerticalAdjust_TOP;
1574
0
                            break;
1575
0
                        case ParagraphAdjust::ParagraphAdjust_CENTER:
1576
0
                            mpTextBody->getTextProperties().meVA
1577
0
                                = TextVerticalAdjust::TextVerticalAdjust_CENTER;
1578
0
                            break;
1579
0
                        case ParagraphAdjust::ParagraphAdjust_RIGHT:
1580
0
                            mpTextBody->getTextProperties().meVA
1581
0
                                = TextVerticalAdjust::TextVerticalAdjust_BOTTOM;
1582
0
                            break;
1583
0
                        default:
1584
0
                            break;
1585
0
                    }
1586
0
                    mpTextBody->getTextProperties().maPropertyMap.setProperty(
1587
0
                        PROP_TextVerticalAdjust, mpTextBody->getTextProperties().meVA);
1588
0
                }
1589
0
            }
1590
1591
            // tdf#162571: In case of shapes with TextAutoGrowHeight, PP calculates/grow the
1592
            // shapes size in edit mode (typing) based on the text horizontal alignment.
1593
            // In LO, we simulate it by setting TextHorizontalAdjust based on the ParagraphAdjust
1594
            // of the 1. paragraph
1595
            // It is not perfect, because we have 1 TextHorizontalAdjust / 1 shape,
1596
            // while we can have many ParagraphAdjust / 1 shape
1597
51.7k
            if (!mpTextBody->getTextProperties().maPropertyMap.hasProperty(PROP_WritingMode)
1598
34.5k
                && mpTextBody->getParagraphs().size() > 0)
1599
34.1k
            {
1600
34.1k
                std::optional<css::style::ParagraphAdjust>& oParaAdjust
1601
34.1k
                    = mpTextBody->getParagraphs()[0]->getProperties().getParaAdjust();
1602
1603
34.1k
                bool bAutoGrowHeight = getTextBody()
1604
34.1k
                    ->getTextProperties()
1605
34.1k
                    .maPropertyMap.getProperty(PROP_TextAutoGrowHeight)
1606
34.1k
                    .get<bool>();
1607
1608
34.1k
                bool bWrap = getTextBody()
1609
34.1k
                    ->getTextProperties()
1610
34.1k
                    .maPropertyMap.getProperty(PROP_TextWordWrap)
1611
34.1k
                    .get<bool>();
1612
1613
34.1k
                if (bAutoGrowHeight && !bWrap && nShapeRotateInclCamera == 0)
1614
360
                {
1615
360
                    mpTextBody->getTextProperties().maPropertyMap.setProperty(
1616
360
                        PROP_TextHorizontalAdjust, lcl_convertTextAdjust(
1617
360
                            oParaAdjust ? *oParaAdjust : ParagraphAdjust_LEFT));
1618
360
                }
1619
34.1k
            }
1620
1621
51.7k
            mpTextBody->getTextProperties().pushTextDistances(Size(aShapeRectHmm.Width, aShapeRectHmm.Height));
1622
51.7k
            aShapeProps.assignUsed( mpTextBody->getTextProperties().maPropertyMap );
1623
            // Push char properties as well - specifically useful when this is a placeholder
1624
51.7k
            if( mpMasterTextListStyle &&  mpMasterTextListStyle->getListStyle()[0].getTextCharacterProperties().moHeight.has_value() )
1625
23.7k
                aShapeProps.setProperty(PROP_CharHeight, GetFontHeight( mpMasterTextListStyle->getListStyle()[0].getTextCharacterProperties().moHeight.value() ));
1626
51.7k
        }
1627
1628
67.2k
        Sequence<PropertyValue> aCamera3DEffects = get3DProperties().getCameraAttributes();
1629
67.2k
        Sequence<PropertyValue> aLightRig3DEffects = get3DProperties().getLightRigAttributes();
1630
67.2k
        Sequence<PropertyValue> aShape3DEffects
1631
67.2k
            = get3DProperties().getShape3DAttributes(rGraphicHelper, nFillPhClr);
1632
67.2k
        bool bHas3DProps = aCamera3DEffects.hasElements() || aLightRig3DEffects.hasElements()
1633
67.2k
                           || aShape3DEffects.hasElements();
1634
67.2k
        if (bHas3DProps && getEffectProperties().maSoftEdge.moRad.has_value())
1635
0
        {
1636
            // 3D properties override softeEdge
1637
0
            getEffectProperties().maSoftEdge.moRad.reset();
1638
0
        }
1639
1640
        // applying properties
1641
67.2k
        aShapeProps.assignUsed( getShapeProperties() );
1642
67.2k
        aShapeProps.assignUsed( maDefaultShapeProperties );
1643
67.2k
        if(nShapeRotateInclCamera != 0 && bIsCustomShape)
1644
2.13k
            aShapeProps.setProperty(PROP_RotateAngle,
1645
2.13k
                                    sal_Int32(lcl_MSORotateAngleToAPIAngle(nShapeRotateInclCamera)));
1646
67.2k
        if( bIsEmbMedia ||
1647
67.2k
            bIsCustomShape ||
1648
47.2k
            aServiceName == "com.sun.star.drawing.GraphicObjectShape" ||
1649
43.8k
            aServiceName == "com.sun.star.drawing.OLE2Shape")
1650
23.8k
        {
1651
23.8k
            mpGraphicPropertiesPtr->pushToPropMap(aShapeProps, rGraphicHelper, getFlipH(), getFlipV());
1652
23.8k
        }
1653
67.2k
        if ( mpTablePropertiesPtr && aServiceName == "com.sun.star.drawing.TableShape" )
1654
130
        {
1655
130
            mpTablePropertiesPtr->pushToPropSet( rFilterBase, xSet, mpMasterTextListStyle );
1656
130
            if ( auto* pTableShape = dynamic_cast<sdr::table::SdrTableObj*>(SdrObject::getSdrObjectFromXShape(mxShape)) )
1657
130
            {
1658
                // Disable layouting until table height is expanded to fit the content
1659
130
                pTableShape->SetSkipChangeLayout(true);
1660
130
            }
1661
130
        }
1662
1663
67.2k
        FillProperties aFillProperties = getActualFillProperties(pTheme, &rShapeOrParentShapeFillProps);
1664
67.2k
        if ((getFillProperties().moFillType.has_value() && getFillProperties().moFillType.value() == XML_grpFill) ||
1665
67.2k
            aFillProperties.maFillColor.isPlaceHolder() )
1666
603
            getFillProperties().assignUsed(aFillProperties);
1667
67.2k
        if (!bIsCroppedGraphic && !bIs3DGraphic)
1668
67.2k
        {
1669
67.2k
            aFillProperties.pushToPropMap(aShapeProps, rGraphicHelper, getRotation(), nFillPhClr,
1670
67.2k
                                          css::awt::Size(aShapeRectHmm.Width, aShapeRectHmm.Height),
1671
67.2k
                                          nFillPhClrTheme, getFlipH(), getFlipV(), bIsCustomShape);
1672
67.2k
        }
1673
67.2k
        LineProperties aLineProperties = getActualLineProperties(pTheme);
1674
67.2k
        aLineProperties.pushToPropMap( aShapeProps, rGraphicHelper, nLinePhClr, nLinePhClrTheme);
1675
67.2k
        EffectProperties aEffectProperties = getActualEffectProperties(pTheme);
1676
        // TODO: use ph color when applying effect properties
1677
67.2k
        aEffectProperties.pushToPropMap( aShapeProps, rGraphicHelper );
1678
1679
        // applying autogrowheight property before setting shape size, because
1680
        // the shape size might be changed if currently autogrowheight is true
1681
        // we must also check that the PropertySet supports the property.
1682
67.2k
        Reference< XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() );
1683
67.2k
        const OUString& rPropName = PropertyMap::getPropertyName( PROP_TextAutoGrowHeight );
1684
67.2k
        if( xSetInfo.is() && xSetInfo->hasPropertyByName( rPropName ) )
1685
66.4k
            if( aShapeProps.hasProperty( PROP_TextAutoGrowHeight ) )
1686
66.3k
                xSet->setPropertyValue( rPropName, Any( false ) );
1687
1688
        // For extruded shapes, MSO uses the line color if no extrusion color is specified. LO uses
1689
        // fill color in 'automatic' case. Thus we set extrusion color explicitly.
1690
67.2k
        if (bHas3DEffect && !aExtrusionColor.isUsed())
1691
0
        {
1692
0
            const OUString& rFillColor2PropName = PropertyMap::getPropertyName(PROP_FillColor2);
1693
0
            if (xSetInfo.is() && xSetInfo->hasPropertyByName(rFillColor2PropName))
1694
0
            {
1695
0
                Color aComplexColor;
1696
0
                if (aLineProperties.maLineFill.moFillType.has_value()
1697
0
                    && aLineProperties.maLineFill.moFillType.value() != XML_noFill)
1698
0
                    aComplexColor = aLineProperties.maLineFill.getBestSolidColor();
1699
0
                else if (aFillProperties.moFillType.has_value()
1700
0
                    && aFillProperties.moFillType.value() != XML_noFill)
1701
0
                    aComplexColor = aFillProperties.getBestSolidColor();
1702
0
                if (aComplexColor.isUsed())
1703
0
                {
1704
0
                    const ::Color aSimpleColor = aComplexColor.getColor(rFilterBase.getGraphicHelper());
1705
0
                    xSet->setPropertyValue(rFillColor2PropName, Any(aSimpleColor));
1706
0
                }
1707
0
            }
1708
0
        }
1709
1710
        // do not set properties at a group shape (this causes
1711
        // assertions from svx) ...
1712
67.2k
        if( aServiceName != "com.sun.star.drawing.GroupShape" )
1713
66.6k
        {
1714
66.6k
            if (aServiceName == "com.sun.star.text.TextFrame")
1715
0
            {
1716
0
                if (mpCustomShapePropertiesPtr && mpCustomShapePropertiesPtr->getShapeTypeOverride())
1717
0
                {
1718
0
                    uno::Reference<beans::XPropertySet> propertySet (mxShape, uno::UNO_QUERY);
1719
0
                    uno::Sequence<beans::PropertyValue> aGrabBag;
1720
0
                    propertySet->getPropertyValue(u"FrameInteropGrabBag"_ustr) >>= aGrabBag;
1721
0
                    sal_Int32 length = aGrabBag.getLength();
1722
0
                    aGrabBag.realloc( length+1);
1723
0
                    auto pGrabBag = aGrabBag.getArray();
1724
0
                    pGrabBag[length].Name = "mso-orig-shape-type";
1725
0
                    pGrabBag[length].Value <<= mpCustomShapePropertiesPtr->getShapePresetTypeName();
1726
0
                    propertySet->setPropertyValue(u"FrameInteropGrabBag"_ustr,uno::Any(aGrabBag));
1727
0
                }
1728
                //If the text box has links then save the link information so that
1729
                //it can be accessed in DomainMapper_Impl.cxx while chaining the text frames.
1730
0
                if (isLinkedTxbx())
1731
0
                {
1732
0
                    uno::Reference<beans::XPropertySet> propertySet (mxShape, uno::UNO_QUERY);
1733
0
                    uno::Sequence<beans::PropertyValue> aGrabBag;
1734
0
                    propertySet->getPropertyValue(u"FrameInteropGrabBag"_ustr) >>= aGrabBag;
1735
0
                    sal_Int32 length = aGrabBag.getLength();
1736
0
                    aGrabBag.realloc( length + 3 );
1737
0
                    auto pGrabBag = aGrabBag.getArray();
1738
0
                    pGrabBag[length].Name = "TxbxHasLink";
1739
0
                    pGrabBag[length].Value <<= isLinkedTxbx();
1740
0
                    pGrabBag[length + 1 ].Name = "Txbx-Id";
1741
0
                    pGrabBag[length + 1 ].Value <<= getLinkedTxbxAttributes().id;
1742
0
                    pGrabBag[length + 2 ].Name = "Txbx-Seq";
1743
0
                    pGrabBag[length + 2 ].Value <<= getLinkedTxbxAttributes().seq;
1744
0
                    propertySet->setPropertyValue(u"FrameInteropGrabBag"_ustr,uno::Any(aGrabBag));
1745
0
                }
1746
1747
                // TextFrames have BackColor, not FillColor
1748
0
                if (aShapeProps.hasProperty(PROP_FillColor))
1749
0
                {
1750
0
                    aShapeProps.setAnyProperty(PROP_BackColor, aShapeProps.getProperty(PROP_FillColor));
1751
0
                    aShapeProps.erase(PROP_FillColor);
1752
0
                }
1753
                // TextFrames have BackColorTransparency, not FillTransparence
1754
0
                if (aShapeProps.hasProperty(PROP_FillTransparence))
1755
0
                {
1756
0
                    aShapeProps.setAnyProperty(PROP_BackColorTransparency, aShapeProps.getProperty(PROP_FillTransparence));
1757
0
                    aShapeProps.erase(PROP_FillTransparence);
1758
0
                }
1759
                // TextFrames have BackGraphic, not FillBitmap
1760
0
                if (aShapeProps.hasProperty(PROP_FillBitmap))
1761
0
                {
1762
0
                    aShapeProps.setAnyProperty(PROP_BackGraphic, aShapeProps.getProperty(PROP_FillBitmap));
1763
0
                    aShapeProps.erase(PROP_FillBitmap);
1764
0
                }
1765
0
                if (aShapeProps.hasProperty(PROP_FillBitmapName))
1766
0
                {
1767
0
                    uno::Any aAny = aShapeProps.getProperty(PROP_FillBitmapName);
1768
0
                    OUString aFillBitmapName = aAny.get<OUString>();
1769
0
                    uno::Reference<awt::XBitmap> xBitmap = rFilterBase.getModelObjectHelper().getFillBitmap(aFillBitmapName);
1770
0
                    uno::Reference<graphic::XGraphic> xGraphic(xBitmap, uno::UNO_QUERY);
1771
0
                    aShapeProps.setProperty(PROP_BackGraphic, xGraphic);
1772
                    // aShapeProps.erase(PROP_FillBitmapName);  // Maybe, leave the name as well
1773
0
                }
1774
                // And no LineColor property; individual borders can have colors
1775
0
                if (aShapeProps.hasProperty(PROP_LineColor))
1776
0
                {
1777
0
                    uno::Reference<beans::XPropertySet> xPropertySet(mxShape, uno::UNO_QUERY);
1778
0
                    static const sal_Int32 aBorders[] =
1779
0
                    {
1780
0
                        PROP_TopBorder, PROP_LeftBorder, PROP_BottomBorder, PROP_RightBorder
1781
0
                    };
1782
0
                    for (sal_Int32 nBorder : aBorders)
1783
0
                    {
1784
0
                        css::table::BorderLine2 aBorderLine = xPropertySet->getPropertyValue(PropertyMap::getPropertyName(nBorder)).get<css::table::BorderLine2>();
1785
0
                        aBorderLine.Color = aShapeProps.getProperty(PROP_LineColor).get<sal_Int32>();
1786
0
                        if (aLineProperties.moLineWidth.has_value())
1787
0
                            aBorderLine.LineWidth = convertEmuToHmm(aLineProperties.moLineWidth.value());
1788
0
                        aShapeProps.setProperty(nBorder, aBorderLine);
1789
0
                    }
1790
0
                    aShapeProps.erase(PROP_LineColor);
1791
0
                }
1792
0
                if (getRotation())
1793
0
                {
1794
0
                    uno::Reference<beans::XPropertySet> xPropertySet(mxShape, uno::UNO_QUERY);
1795
0
                    static constexpr OUString aGrabBagPropName = u"FrameInteropGrabBag"_ustr;
1796
0
                    uno::Sequence<beans::PropertyValue> aGrabBag;
1797
0
                    xPropertySet->getPropertyValue(aGrabBagPropName) >>= aGrabBag;
1798
0
                    beans::PropertyValue aPair(comphelper::makePropertyValue(u"mso-rotation-angle"_ustr,
1799
0
                                                                             getRotation()));
1800
0
                    if (aGrabBag.hasElements())
1801
0
                    {
1802
0
                        sal_Int32 nLength = aGrabBag.getLength();
1803
0
                        aGrabBag.realloc(nLength + 1);
1804
0
                        aGrabBag.getArray()[nLength] = std::move(aPair);
1805
0
                    }
1806
0
                    else
1807
0
                    {
1808
0
                        aGrabBag = { std::move(aPair) };
1809
0
                    }
1810
0
                    xPropertySet->setPropertyValue(aGrabBagPropName, uno::Any(aGrabBag));
1811
0
                }
1812
                // TextFrames have ShadowFormat, not individual shadow properties.
1813
0
                std::optional<sal_Int32> oShadowDistance;
1814
0
                if (aShapeProps.hasProperty(PROP_ShadowXDistance))
1815
0
                {
1816
0
                    oShadowDistance = aShapeProps.getProperty(PROP_ShadowXDistance).get<sal_Int32>();
1817
0
                    aShapeProps.erase(PROP_ShadowXDistance);
1818
0
                }
1819
0
                if (aShapeProps.hasProperty(PROP_ShadowYDistance))
1820
0
                {
1821
                    // There is a single 'dist' attribute, so no need to count the avg of x and y.
1822
0
                    aShapeProps.erase(PROP_ShadowYDistance);
1823
0
                }
1824
0
                std::optional<sal_Int32> oShadowColor;
1825
0
                if (aShapeProps.hasProperty(PROP_ShadowColor))
1826
0
                {
1827
0
                    oShadowColor = aShapeProps.getProperty(PROP_ShadowColor).get<sal_Int32>();
1828
0
                    aShapeProps.erase(PROP_ShadowColor);
1829
0
                }
1830
0
                if (aShapeProps.hasProperty(PROP_Shadow))
1831
0
                    aShapeProps.erase(PROP_Shadow);
1832
1833
0
                if (oShadowDistance || oShadowColor || aEffectProperties.maShadow.moShadowDir.has_value())
1834
0
                {
1835
0
                    css::table::ShadowFormat aFormat;
1836
0
                    if (oShadowColor)
1837
0
                        aFormat.Color = *oShadowColor;
1838
0
                    if (aEffectProperties.maShadow.moShadowDir.has_value())
1839
0
                    {
1840
0
                        css::table::ShadowLocation nLocation = css::table::ShadowLocation_NONE;
1841
0
                        switch (aEffectProperties.maShadow.moShadowDir.value())
1842
0
                        {
1843
0
                        case 13500000:
1844
0
                            nLocation = css::table::ShadowLocation_TOP_LEFT;
1845
0
                            break;
1846
0
                        case 18900000:
1847
0
                            nLocation = css::table::ShadowLocation_TOP_RIGHT;
1848
0
                            break;
1849
0
                        case 8100000:
1850
0
                            nLocation = css::table::ShadowLocation_BOTTOM_LEFT;
1851
0
                            break;
1852
0
                        case 2700000:
1853
0
                            nLocation = css::table::ShadowLocation_BOTTOM_RIGHT;
1854
0
                            break;
1855
0
                        }
1856
0
                        aFormat.Location = nLocation;
1857
0
                    }
1858
0
                    aFormat.ShadowWidth = *oShadowDistance;
1859
0
                    aShapeProps.setProperty(PROP_ShadowFormat, aFormat);
1860
0
                }
1861
1862
0
            }
1863
66.6k
            else if (getIsTextBox())
1864
478
            {
1865
                // This introduces a TextBox in a shape in Writer. ToDo: Can we restrict it to cases
1866
                // where the TextBox edit engine is really needed? tdf#82627
1867
478
                aShapeProps.setProperty(PROP_TextBox, true);
1868
478
            }
1869
1870
66.6k
            if (aServiceName != "com.sun.star.text.TextFrame" && isLinkedTxbx())
1871
0
            {
1872
0
                uno::Reference<beans::XPropertySet> propertySet (mxShape, uno::UNO_QUERY);
1873
0
                uno::Sequence<beans::PropertyValue> aGrabBag;
1874
0
                propertySet->getPropertyValue(u"InteropGrabBag"_ustr) >>= aGrabBag;
1875
0
                sal_Int32 length = aGrabBag.getLength();
1876
0
                aGrabBag.realloc( length + 3 );
1877
0
                auto pGrabBag = aGrabBag.getArray();
1878
0
                pGrabBag[length].Name = "TxbxHasLink";
1879
0
                pGrabBag[length].Value <<= isLinkedTxbx();
1880
0
                pGrabBag[length + 1 ].Name = "Txbx-Id";
1881
0
                pGrabBag[length + 1 ].Value <<= getLinkedTxbxAttributes().id;
1882
0
                pGrabBag[length + 2 ].Name = "Txbx-Seq";
1883
0
                pGrabBag[length + 2 ].Value <<= getLinkedTxbxAttributes().seq;
1884
0
                propertySet->setPropertyValue(u"InteropGrabBag"_ustr,uno::Any(aGrabBag));
1885
0
            }
1886
1887
            // set custom prompt text if available
1888
66.6k
            if (getCustomPrompt() && getTextBody() && !getTextBody()->isEmpty())
1889
0
            {
1890
0
                aShapeProps.setProperty(PROP_CustomPromptText, getTextBody()->firstParatoString());
1891
0
            }
1892
66.6k
            else if (pPlaceholder && pPlaceholder->getCustomPrompt() && pPlaceholder->getTextBody() && !pPlaceholder->getTextBody()->isEmpty())
1893
0
            {
1894
0
                aShapeProps.setProperty(PROP_CustomPromptText, pPlaceholder->getTextBody()->firstParatoString());
1895
0
            }
1896
1897
66.6k
            PropertySet( xSet ).setProperties( aShapeProps );
1898
1899
66.6k
            if (mpTablePropertiesPtr && aServiceName == "com.sun.star.drawing.TableShape")
1900
130
            {
1901
                // Powerpoint exports desired row heights (i.e. what user attempted to set it as, not how it appears visually)
1902
                // Expand table height if there are rows that can't fit the content
1903
130
                if (auto* pTableShape = dynamic_cast<sdr::table::SdrTableObj*>(SdrObject::getSdrObjectFromXShape(mxShape)))
1904
130
                {
1905
130
                    tools::Rectangle aArea{};
1906
130
                    pTableShape->LayoutTableHeight(aArea);
1907
130
                    sal_Int32 nCorrectedHeight = aArea.GetHeight();
1908
130
                    const auto aShapeSize = mxShape->getSize();
1909
130
                    if( nCorrectedHeight > aShapeSize.Height )
1910
0
                        mxShape->setSize( {aShapeSize.Width, nCorrectedHeight} );
1911
130
                    pTableShape->SetSkipChangeLayout(false);
1912
130
                }
1913
130
            }
1914
1915
66.6k
            if (getLockedCanvas())
1916
0
            {
1917
0
                putPropertyToGrabBag( u"LockedCanvas"_ustr, Any( true ) );
1918
0
                if (aServiceName == "com.sun.star.drawing.LineShape")
1919
0
                {
1920
                    // It seems the position and size for lines inside a locked canvas is absolute.
1921
0
                    mxShape->setPosition(awt::Point(aShapeRectHmm.X, aShapeRectHmm.Y));
1922
0
                    mxShape->setSize(awt::Size(aShapeRectHmm.Width, aShapeRectHmm.Height));
1923
0
                }
1924
0
            }
1925
1926
66.6k
            if (isInWordprocessingCanvas())
1927
0
            {
1928
0
                putPropertyToGrabBag(u"WordprocessingCanvas"_ustr, Any(true));
1929
0
            }
1930
1931
            // Store original fill and line colors of the shape and the theme color name to InteropGrabBag
1932
66.6k
            std::vector<beans::PropertyValue> aProperties
1933
66.6k
            {
1934
66.6k
                comphelper::makePropertyValue(u"EmuLineWidth"_ustr, aLineProperties.moLineWidth.value_or(0)),
1935
66.6k
                comphelper::makePropertyValue(u"OriginalSolidFillClr"_ustr, aShapeProps.getProperty(PROP_FillColor)),
1936
66.6k
                comphelper::makePropertyValue(u"OriginalLnSolidFillClr"_ustr, aShapeProps.getProperty(PROP_LineColor))
1937
66.6k
            };
1938
66.6k
            OUString sColorFillScheme = aFillProperties.maFillColor.getSchemeColorName();
1939
66.6k
            if( !aFillProperties.maFillColor.isPlaceHolder() && !sColorFillScheme.isEmpty() )
1940
3.25k
            {
1941
3.25k
                aProperties.push_back(comphelper::makePropertyValue(u"SpPrSolidFillSchemeClr"_ustr, sColorFillScheme));
1942
3.25k
                aProperties.push_back(comphelper::makePropertyValue(u"SpPrSolidFillSchemeClrTransformations"_ustr, aFillProperties.maFillColor.getTransformations()));
1943
3.25k
            }
1944
66.6k
            OUString sLnColorFillScheme = aLineProperties.maLineFill.maFillColor.getSchemeColorName();
1945
66.6k
            if( !aLineProperties.maLineFill.maFillColor.isPlaceHolder() && !sLnColorFillScheme.isEmpty() )
1946
3.48k
            {
1947
3.48k
                aProperties.push_back(comphelper::makePropertyValue(u"SpPrLnSolidFillSchemeClr"_ustr, sLnColorFillScheme));
1948
3.48k
                auto aResolvedSchemeClr = aLineProperties.maLineFill.maFillColor;
1949
3.48k
                aResolvedSchemeClr.clearTransformations();
1950
3.48k
                aProperties.push_back(comphelper::makePropertyValue(u"SpPrLnSolidFillResolvedSchemeClr"_ustr, aResolvedSchemeClr.getColor(rGraphicHelper, nFillPhClr)));
1951
3.48k
                aProperties.push_back(comphelper::makePropertyValue(u"SpPrLnSolidFillSchemeClrTransformations"_ustr, aLineProperties.maLineFill.maFillColor.getTransformations()));
1952
3.48k
            }
1953
66.6k
            putPropertiesToGrabBag(comphelper::containerToSequence(aProperties));
1954
1955
            // Store original gradient fill of the shape to InteropGrabBag
1956
            // LibreOffice doesn't support all the kinds of gradient so we save its complete definition
1957
66.6k
            if( aShapeProps.hasProperty( PROP_FillGradient ) )
1958
1.96k
            {
1959
1.96k
                std::vector<beans::PropertyValue> aGradientStops;
1960
1.96k
                size_t i = 0;
1961
1.96k
                for( const auto& [rPos, rColor] : aFillProperties.maGradientProps.maGradientStops )
1962
4.21k
                { // for each stop in the gradient definition:
1963
1964
                    // save position
1965
4.21k
                    std::vector<beans::PropertyValue> aGradientStop
1966
4.21k
                    {
1967
4.21k
                        comphelper::makePropertyValue(u"Pos"_ustr, rPos)
1968
4.21k
                    };
1969
1970
4.21k
                    OUString sStopColorScheme = rColor.getSchemeColorName();
1971
4.21k
                    if( sStopColorScheme.isEmpty() )
1972
3.52k
                    {
1973
                        // save RGB color
1974
3.52k
                        aGradientStop.push_back(comphelper::makePropertyValue(u"RgbClr"_ustr, rColor.getColor(rGraphicHelper, nFillPhClr)));
1975
                        // in the case of a RGB color, transformations are already applied to
1976
                        // the color with the exception of alpha transformations. We only need
1977
                        // to keep the transparency value to calculate the alpha value later.
1978
3.52k
                        if( rColor.hasTransparency() )
1979
0
                            aGradientStop.push_back(comphelper::makePropertyValue(u"Transparency"_ustr, rColor.getTransparency()));
1980
3.52k
                    }
1981
696
                    else
1982
696
                    {
1983
                        // save color with scheme name
1984
696
                        aGradientStop.push_back(comphelper::makePropertyValue(u"SchemeClr"_ustr, sStopColorScheme));
1985
                        // save all color transformations
1986
696
                        aGradientStop.push_back(comphelper::makePropertyValue(u"Transformations"_ustr, rColor.getTransformations()));
1987
696
                    }
1988
1989
4.21k
                    aGradientStops.push_back(comphelper::makePropertyValue(OUString::number(i), comphelper::containerToSequence(aGradientStop)));
1990
4.21k
                    ++i;
1991
4.21k
                }
1992
                // If getFillProperties.moFillType is unused that means gradient is defined by a theme
1993
                // which is already saved into StyleFillRef property, so no need to save the explicit values too
1994
1.96k
                if( getFillProperties().moFillType.has_value() )
1995
1.94k
                    putPropertyToGrabBag( u"GradFillDefinition"_ustr, uno::Any(comphelper::containerToSequence(aGradientStops)));
1996
1.96k
                putPropertyToGrabBag( u"OriginalGradFill"_ustr, aShapeProps.getProperty(PROP_FillGradient) );
1997
1.96k
            }
1998
1999
            // store unsupported effect attributes in the grab bag
2000
66.6k
            if (!aEffectProperties.m_Effects.empty())
2001
97
            {
2002
97
                std::vector<beans::PropertyValue> aEffects;
2003
97
                for (auto const& it : aEffectProperties.m_Effects)
2004
97
                {
2005
97
                    PropertyValue aEffect = it->getEffect();
2006
97
                    if( !aEffect.Name.isEmpty() )
2007
97
                    {
2008
97
                        std::vector<beans::PropertyValue> aEffectsGrabBag
2009
97
                        {
2010
97
                            comphelper::makePropertyValue(u"Attribs"_ustr, aEffect.Value)
2011
97
                        };
2012
2013
97
                        Color& aColor( it->moColor );
2014
97
                        OUString sColorScheme = aColor.getSchemeColorName();
2015
97
                        if( sColorScheme.isEmpty() )
2016
86
                        {
2017
                            // RGB color and transparency value
2018
86
                            aEffectsGrabBag.push_back(comphelper::makePropertyValue(u"RgbClr"_ustr, aColor.getColor(rGraphicHelper, nFillPhClr)));
2019
86
                            aEffectsGrabBag.push_back(comphelper::makePropertyValue(u"RgbClrTransparency"_ustr, aColor.getTransparency()));
2020
86
                        }
2021
11
                        else
2022
11
                        {
2023
                            // scheme color with name and transformations
2024
11
                            aEffectsGrabBag.push_back(comphelper::makePropertyValue(u"SchemeClr"_ustr, sColorScheme));
2025
11
                            aEffectsGrabBag.push_back(comphelper::makePropertyValue(u"SchemeClrTransformations"_ustr, aColor.getTransformations()));
2026
11
                        }
2027
97
                        aEffects.push_back(comphelper::makePropertyValue(aEffect.Name, comphelper::containerToSequence(aEffectsGrabBag)));
2028
97
                    }
2029
97
                }
2030
97
                putPropertyToGrabBag(u"EffectProperties"_ustr, uno::Any(comphelper::containerToSequence(aEffects)));
2031
97
            }
2032
2033
            // add 3D effects if any to GrabBag. They are still used in export.
2034
66.6k
            if (bHas3DProps)
2035
17
            {
2036
17
                uno::Sequence<beans::PropertyValue> a3DEffectsGrabBag = comphelper::InitPropertySequence(
2037
17
                {
2038
17
                    {"Camera", uno::Any(aCamera3DEffects)},
2039
17
                    {"LightRig", uno::Any(aLightRig3DEffects)},
2040
17
                    {"Shape3D", uno::Any(aShape3DEffects)}
2041
17
                });
2042
17
                putPropertyToGrabBag( u"3DEffectProperties"_ustr, Any( a3DEffectsGrabBag ) );
2043
17
            }
2044
2045
66.6k
            if( bIsCustomShape && getTextBody())
2046
11.0k
            {
2047
2048
11.0k
                Sequence< PropertyValue > aTextCamera3DEffects = getTextBody()->get3DProperties().getCameraAttributes();
2049
11.0k
                Sequence< PropertyValue > aTextLightRig3DEffects = getTextBody()->get3DProperties().getLightRigAttributes();
2050
11.0k
                Sequence< PropertyValue > aTextShape3DEffects = getTextBody()->get3DProperties().getShape3DAttributes( rGraphicHelper, nFillPhClr );
2051
11.0k
                if( aTextCamera3DEffects.hasElements() || aTextLightRig3DEffects.hasElements() || aTextShape3DEffects.hasElements() )
2052
0
                {
2053
0
                    uno::Sequence<beans::PropertyValue> aText3DEffectsGrabBag = comphelper::InitPropertySequence(
2054
0
                    {
2055
0
                        {"Camera", uno::Any(aTextCamera3DEffects)},
2056
0
                        {"LightRig", uno::Any(aTextLightRig3DEffects)},
2057
0
                        {"Shape3D", uno::Any(aTextShape3DEffects)}
2058
0
                    });
2059
0
                    putPropertyToGrabBag( u"Text3DEffectProperties"_ustr, Any( aText3DEffectsGrabBag ) );
2060
0
                }
2061
11.0k
            }
2062
2063
            // store bitmap artistic effects in the grab bag
2064
66.6k
            if( !mpGraphicPropertiesPtr->maBlipProps.maEffect.isEmpty() )
2065
0
                putPropertyToGrabBag( u"ArtisticEffectProperties"_ustr,
2066
0
                                      Any( mpGraphicPropertiesPtr->maBlipProps.maEffect.getEffect() ) );
2067
66.6k
        }
2068
2069
670
        else if (getLockedCanvas())
2070
52
        {
2071
            //If we have aServiceName as "com.sun.star.drawing.GroupShape" and lockedCanvas
2072
52
            putPropertyToGrabBag( u"LockedCanvas"_ustr, Any( true ) );
2073
52
        }
2074
618
        else if (isInWordprocessingCanvas())
2075
0
        {
2076
0
            putPropertyToGrabBag(u"WordprocessingCanvas"_ustr, Any(true));
2077
0
            putPropertyToGrabBag(u"mso-edit-as"_ustr, Any(u"canvas"_ustr)); // for export VML Fallback
2078
0
        }
2079
2080
        // These can have a custom geometry, so position should be set here,
2081
        // after creation but before custom shape handling, using the position
2082
        // we got from the caller.
2083
67.2k
        if (getWps() && aServiceName == "com.sun.star.drawing.LineShape" && !pParentGroupShape)
2084
0
            mxShape->setPosition(maPosition);
2085
2086
67.2k
        SdrObject* pShape = SdrObject::getSdrObjectFromXShape(mxShape);
2087
67.2k
        if (pShape)
2088
67.2k
            aOrigSize = pShape->GetLogicRect();
2089
2090
67.2k
        if (bIsConnectorShape)
2091
1.89k
        {
2092
1.89k
            msConnectorName = mpCustomShapePropertiesPtr->getShapePresetTypeName();
2093
2094
1.89k
            const auto& aAdjustmentList = mpCustomShapePropertiesPtr->getAdjustmentGuideList();
2095
1.91k
            for (size_t i = 0; i < aAdjustmentList.size(); i++)
2096
18
                maConnectorAdjustmentList.push_back(aAdjustmentList[i].maFormula);
2097
2098
1.89k
            sal_Int32 nType = mpCustomShapePropertiesPtr->getShapePresetType();
2099
1.89k
            switch (nType)
2100
1.89k
            {
2101
1.53k
            case XML_line:
2102
1.85k
            case XML_straightConnector1:
2103
1.85k
                xSet->setPropertyValue(u"EdgeKind"_ustr, Any(ConnectorType_LINE));
2104
1.85k
                break;
2105
21
            case XML_bentConnector2:
2106
39
            case XML_bentConnector3:
2107
39
            case XML_bentConnector4:
2108
39
            case XML_bentConnector5:
2109
39
                xSet->setPropertyValue(u"EdgeKind"_ustr, Any(ConnectorType_STANDARD));
2110
39
                break;
2111
0
            case XML_curvedConnector2:
2112
0
            case XML_curvedConnector3:
2113
0
            case XML_curvedConnector4:
2114
0
            case XML_curvedConnector5:
2115
0
                xSet->setPropertyValue(u"EdgeKind"_ustr, Any(ConnectorType_CURVE));
2116
0
                break;
2117
0
            default:
2118
0
                break;
2119
1.89k
            }
2120
1.89k
        }
2121
2122
67.2k
        if( bIsCustomShape )
2123
20.0k
        {
2124
20.0k
            if (getFlipH())
2125
10
                mpCustomShapePropertiesPtr->setMirroredX( true );
2126
20.0k
            if (getFlipV())
2127
36
                mpCustomShapePropertiesPtr->setMirroredY( true );
2128
20.0k
            if( getTextBody() )
2129
11.0k
            {
2130
11.0k
                sal_Int32 nTextCameraZRotation = getTextBody()->get3DProperties().maCameraRotation.mnRevolution.value_or(0);
2131
11.0k
                mpCustomShapePropertiesPtr->setTextCameraZRotateAngle( nTextCameraZRotation / 60000 );
2132
2133
                // TextPreRotateAngle. Text rotates inside the text area. Might be used for diagram layout 'upr' and 'grav'.
2134
11.0k
                sal_Int32 nTextPreRotateAngle = static_cast< sal_Int32 >( getTextBody()->getTextProperties().moTextPreRotation.value_or( 0 ) );
2135
2136
11.0k
                nTextPreRotateAngle -= getDiagramRotation(); // Use of mnDiagramRotation is unclear. It seems to be always 0 here.
2137
2138
                // TextRotateAngle. The text area rotates.
2139
11.0k
                sal_Int32 nTextAreaRotateAngle = getTextBody()->getTextProperties().moTextAreaRotation.value_or(0);
2140
11.0k
                if (getTextBody()->getTextProperties().moUpright)
2141
83
                {
2142
                    // When upright is set, any text area transformation and shape rotation is ignored
2143
                    // in MS Office. To simulate this behaviour, we rotate the text area into the
2144
                    // opposite direction of the shape rotation by as much as the shape was rotated
2145
                    // and so compensate the shape rotation, which is added in rendering.
2146
83
                    nTextAreaRotateAngle = -getRotation();
2147
                    // If 45° <= shape rotation < 135° or 225° <= shape rotation < 315°,
2148
                    // then MS Office adds an additional 90° rotation to the text area.
2149
83
                    const sal_Int32 nDeg(getRotation() / 60000);
2150
83
                    if ((nDeg >= 45 && nDeg < 135) || (nDeg >= 225 && nDeg < 315))
2151
2
                    {
2152
2
                        nTextAreaRotateAngle += 5400000;
2153
2
                        nTextPreRotateAngle -= 5400000; // compensate the additional text area rotation
2154
2
                    }
2155
83
                    putPropertyToGrabBag(u"Upright"_ustr, Any(true));
2156
83
                }
2157
                /* OOX measures text rotation clockwise in 1/60000th degrees,
2158
                   relative to the containing shape. set*Angle wants degrees counter-clockwise. */
2159
11.0k
                mpCustomShapePropertiesPtr->setTextPreRotateAngle(-nTextPreRotateAngle / 60000);
2160
11.0k
                if (nTextAreaRotateAngle != 0)
2161
61
                    mpCustomShapePropertiesPtr->setTextAreaRotateAngle(-nTextAreaRotateAngle / 60000);
2162
2163
11.0k
                auto sHorzOverflow = getTextBody()->getTextProperties().msHorzOverflow;
2164
11.0k
                if (!sHorzOverflow.isEmpty())
2165
165
                    putPropertyToGrabBag(u"horzOverflow"_ustr, uno::Any(getTextBody()->getTextProperties().msHorzOverflow));
2166
11.0k
                if (XML_ellipsis == getTextBody()->getTextProperties().moVertOverflow)
2167
0
                    putPropertyToGrabBag(u"vertOverflow"_ustr, uno::Any(u"ellipsis"_ustr));
2168
11.0k
            }
2169
2170
            // Note that the script oox/source/drawingml/customshapes/generatePresetsData.pl looks
2171
            // for these ==cscode== and ==csdata== markers, so don't "clean up" these SAL_INFOs
2172
20.0k
            SAL_INFO("oox.cscode", "==cscode== shape name: '" << msName << "'");
2173
20.0k
            SAL_INFO("oox.csdata", "==csdata== shape name: '" << msName << "'");
2174
2175
20.0k
            mpCustomShapePropertiesPtr->pushToPropSet(xSet, maSize);
2176
2177
            // Consider WordArt
2178
20.0k
            if (mpTextBody && !mpTextBody->getTextProperties().msPrst.isEmpty()
2179
1.41k
                && mpTextBody->getTextProperties().msPrst != u"textNoShape")
2180
0
            {
2181
0
                bool bFromWordArt(aShapeProps.hasProperty(PROP_FromWordArt)
2182
0
                                      ? aShapeProps.getProperty(PROP_FromWordArt).get<bool>()
2183
0
                                      : false);
2184
0
                FontworkHelpers::putCustomShapeIntoTextPathMode(
2185
0
                    mxShape, mpCustomShapePropertiesPtr, mpTextBody->getTextProperties().msPrst,
2186
0
                    bFromWordArt);
2187
0
            }
2188
20.0k
        }
2189
47.2k
        else if( getTextBody() )
2190
40.7k
            getTextBody()->getTextProperties().pushVertSimulation();
2191
2192
        // tdf#133037: a bit hackish: force Shape to rotate in the opposite direction the camera would rotate
2193
67.2k
        PropertySet aPropertySet(mxShape);
2194
67.2k
        if ( !bUseRotationTransform && (nShapeRotateInclCamera !=0) )
2195
260
        {
2196
260
            Degree100 nAngle(lcl_MSORotateAngleToAPIAngle(nShapeRotateInclCamera));
2197
260
            aPropertySet.setAnyProperty(PROP_RotateAngle, Any( sal_Int32(nAngle)));
2198
260
            aPropertySet.setAnyProperty( PROP_HoriOrientPosition, Any( maPosition.X ) );
2199
260
            aPropertySet.setAnyProperty( PROP_VertOrientPosition, Any( maPosition.Y ) );
2200
260
        }
2201
2202
        // Make sure to not set text to placeholders. Doing it here would eventually call
2203
        // SvxTextEditSourceImpl::UpdateData, SdrObject::SetEmptyPresObj(false), and that
2204
        // would make the object behave like a standard outline object.
2205
        // TODO/FIXME: support custom prompt text in placeholders.
2206
67.2k
        if (rServiceName == "com.sun.star.presentation.GraphicObjectShape")
2207
0
            mpTextBody.reset();
2208
2209
        // in some cases, we don't have any text body.
2210
67.2k
        if( mpTextBody && ( !pPlaceholder || !mpTextBody->isEmpty() ) )
2211
40.4k
        {
2212
40.4k
            Reference < XText > xText( mxShape, UNO_QUERY );
2213
40.4k
            if ( xText.is() )   // not every shape is supporting an XText interface (e.g. GroupShape)
2214
40.4k
            {
2215
40.4k
                TextCharacterProperties aCharStyleProperties;
2216
40.4k
                if( const ShapeStyleRef* pFontRef = getShapeStyleRef( XML_fontRef ) )
2217
1.37k
                {
2218
1.37k
                    if( pFontRef->mnThemedIdx != 0 )
2219
1.37k
                    {
2220
1.37k
                        if( pTheme )
2221
1.27k
                            if( const TextCharacterProperties* pCharProps = pTheme->getFontStyle( pFontRef->mnThemedIdx ) )
2222
806
                                aCharStyleProperties.assignUsed( *pCharProps );
2223
1.37k
                        SAL_INFO("oox.drawingml", "Shape::createAndInsert: use font color");
2224
1.37k
                        if ( pFontRef->maPhClr.isUsed() )
2225
1.37k
                        {
2226
1.37k
                            aCharStyleProperties.maFillProperties.maFillColor = pFontRef->maPhClr;
2227
1.37k
                            aCharStyleProperties.maFillProperties.moFillType = XML_solidFill;
2228
1.37k
                        }
2229
1.37k
                    }
2230
1.37k
                }
2231
40.4k
                xText->setString(u""_ustr);
2232
40.4k
                Reference < XTextCursor > xAt = xText->createTextCursor();
2233
40.4k
                getTextBody()->insertAt( rFilterBase, xText, xAt, aCharStyleProperties, mpMasterTextListStyle );
2234
2235
40.4k
                const TextParagraphVector& rParagraphs = getTextBody()->getParagraphs();
2236
40.4k
                if (!rParagraphs.empty())
2237
40.0k
                {
2238
40.0k
                    const std::shared_ptr<TextParagraph>& pParagraph = rParagraphs[0];
2239
40.0k
                    if (pParagraph->getProperties().getParaAdjust())
2240
9.50k
                    {
2241
9.50k
                        style::ParagraphAdjust eAdjust = *pParagraph->getProperties().getParaAdjust();
2242
9.50k
                        if (eAdjust == style::ParagraphAdjust_CENTER)
2243
6.99k
                        {
2244
                            // If the first paragraph is centered, then set the para adjustment of
2245
                            // the shape itself to centered as well.
2246
6.99k
                            aPropertySet.setAnyProperty(PROP_ParaAdjust, uno::Any(eAdjust));
2247
6.99k
                        }
2248
9.50k
                    }
2249
2250
                    // tdf#144092 For empty textboxes push character styles &
2251
                    // endParaRPr into the Shape's properties
2252
40.0k
                    if (rParagraphs.size() == 1 && pParagraph->getRuns().empty())
2253
10.7k
                    {
2254
10.7k
                        TextCharacterProperties aTextCharacterProps{ pParagraph->getCharacterStyle(
2255
10.7k
                            aCharStyleProperties, *mpMasterTextListStyle,
2256
10.7k
                            getTextBody()->getTextListStyle()) };
2257
10.7k
                        aTextCharacterProps.assignUsed(pParagraph->getEndProperties());
2258
10.7k
                        aTextCharacterProps.pushToPropSet(aPropertySet, rFilterBase);
2259
10.7k
                    }
2260
40.0k
                }
2261
2262
                // MS Office has e.g. fill and stroke of WordArt in the character properties,
2263
                // LibreOffice uses shape properties.
2264
40.4k
                if (!mpTextBody->getTextProperties().msPrst.isEmpty()
2265
1.85k
                    && mpTextBody->getTextProperties().msPrst != u"textNoShape")
2266
0
                {
2267
0
                    lcl_copyCharPropsToShape(mxShape, mpTextBody, rFilterBase);
2268
0
                }
2269
40.4k
            }
2270
40.4k
        }
2271
26.8k
        else if (mpTextBody && aServiceName == "com.sun.star.presentation.OutlinerShape"
2272
5.26k
                 && mpMasterTextListStyle && !bPlaceholderWithCustomPrompt)
2273
5.26k
        {
2274
            // If mpTextBody is not empty, then the insertAt() above inserts formatted text. If it's
2275
            // empty, then we format the existing text of the outliner shape here.
2276
5.26k
            PushMasterTextListStyleToMasterShapeParagraphs(*mpMasterTextListStyle, mxShape);
2277
5.26k
        }
2278
21.5k
        else if (getIsTextBox())
2279
478
        {
2280
            // No drawingML text, but WPS text is expected: save the theme
2281
            // character color on the shape, then.
2282
478
            if(const ShapeStyleRef* pFontRef = getShapeStyleRef(XML_fontRef))
2283
284
            {
2284
284
                ::Color nCharColor = pFontRef->maPhClr.getColor(rGraphicHelper);
2285
284
                aPropertySet.setAnyProperty(PROP_CharColor, uno::Any(nCharColor));
2286
284
            }
2287
478
        }
2288
2289
        // Set glow effect properties
2290
67.2k
        if (aEffectProperties.maGlow.moGlowRad.has_value()
2291
13
            && aServiceName != "com.sun.star.drawing.GroupShape")
2292
13
        {
2293
13
            uno::Reference<beans::XPropertySet> propertySet (mxShape, uno::UNO_QUERY);
2294
13
            propertySet->setPropertyValue(u"GlowEffectRadius"_ustr, Any(convertEmuToHmm(aEffectProperties.maGlow.moGlowRad.value())));
2295
13
            propertySet->setPropertyValue(u"GlowEffectColor"_ustr, Any(aEffectProperties.maGlow.moGlowColor.getColor(rGraphicHelper)));
2296
13
            propertySet->setPropertyValue(u"GlowEffectTransparency"_ustr, Any(aEffectProperties.maGlow.moGlowColor.getTransparency()));
2297
13
        }
2298
2299
        // Set soft edge effect properties
2300
67.2k
        if (aEffectProperties.maSoftEdge.moRad.has_value())
2301
0
        {
2302
0
            uno::Reference<beans::XPropertySet> propertySet(mxShape, uno::UNO_QUERY);
2303
0
            propertySet->setPropertyValue(
2304
0
                u"SoftEdgeRadius"_ustr, Any(convertEmuToHmm(aEffectProperties.maSoftEdge.moRad.value())));
2305
0
        }
2306
2307
        // Set text glow effect for shapes
2308
67.2k
        if (mpTextBody && (!pPlaceholder || !mpTextBody->isEmpty()))
2309
40.4k
        {
2310
40.4k
            const TextParagraphVector& rParagraphs = mpTextBody->getParagraphs();
2311
40.4k
            if (!rParagraphs.empty())
2312
40.0k
            {
2313
40.0k
                EffectProperties aTextEffectProperties;
2314
98.0k
                for (TextParagraphVector::const_iterator aPIt = rParagraphs.begin(), aPEnd = rParagraphs.end(); aPIt != aPEnd; ++aPIt)
2315
57.9k
                {
2316
57.9k
                    const TextParagraph& rTextPara = **aPIt;
2317
57.9k
                    const TextCharacterProperties & rParaProps = rTextPara.getProperties().getTextCharacterProperties();
2318
57.9k
                    if (rParaProps.getEffectProperties().maGlow.moGlowRad.has_value())
2319
0
                    {
2320
0
                        aTextEffectProperties.assignUsed(rParaProps.getEffectProperties());
2321
0
                        goto found;
2322
0
                    }
2323
57.9k
                    else
2324
57.9k
                    {
2325
120k
                        for (TextRunVector::const_iterator aRIt = rTextPara.getRuns().begin(), aREnd = rTextPara.getRuns().end(); aRIt != aREnd; ++aRIt)
2326
62.2k
                        {
2327
62.2k
                            const TextRun& rTextRun = **aRIt;
2328
62.2k
                            const TextCharacterProperties& rRunrops = rTextRun.getTextCharacterProperties();
2329
62.2k
                            if (rRunrops.getEffectProperties().maGlow.moGlowRad.has_value())
2330
0
                            {
2331
0
                                aTextEffectProperties.assignUsed(rRunrops.getEffectProperties());
2332
0
                                goto found;
2333
0
                            }
2334
62.2k
                        }
2335
57.9k
                    }
2336
57.9k
                }
2337
2338
40.0k
            found:
2339
40.0k
                if (aTextEffectProperties.maGlow.moGlowRad.has_value())
2340
0
                {
2341
0
                    xSet->setPropertyValue(u"GlowTextEffectRadius"_ustr,
2342
0
                        uno::Any(convertEmuToHmm(aTextEffectProperties.maGlow.moGlowRad.value())));
2343
0
                    xSet->setPropertyValue(u"GlowTextEffectColor"_ustr,
2344
0
                        uno::Any(aTextEffectProperties.maGlow.moGlowColor.getColor(rGraphicHelper)));
2345
0
                    xSet->setPropertyValue(u"GlowTextEffectTransparency"_ustr,
2346
0
                        uno::Any(aTextEffectProperties.maGlow.moGlowColor.getTransparency()));
2347
0
                }
2348
40.0k
            }
2349
40.4k
        }
2350
2351
        // Set the stroke and fill-color properties of the OLE shape
2352
67.2k
        if (aServiceName == "com.sun.star.drawing.OLE2Shape" && mxOleObjectInfo
2353
0
            && !mxOleObjectInfo->maShapeId.isEmpty())
2354
0
            if (::oox::vml::Drawing* pVmlDrawing = rFilterBase.getVmlDrawing())
2355
0
                if (const ::oox::vml::ShapeBase* pVmlShape
2356
0
                    = pVmlDrawing->getShapes().getShapeById(mxOleObjectInfo->maShapeId))
2357
0
                {
2358
                    // Apply stroke props from the type model of the related VML shape.
2359
0
                    ShapePropertyMap aPropMap(rFilterBase.getModelObjectHelper());
2360
0
                    pVmlShape->getTypeModel().maStrokeModel.pushToPropMap(
2361
0
                        aPropMap, rFilterBase.getGraphicHelper());
2362
                    // And, fill-color properties as well...
2363
0
                    pVmlShape->getTypeModel().maFillModel.pushToPropMap(
2364
0
                        aPropMap, rFilterBase.getGraphicHelper());
2365
0
                    PropertySet(xSet).setProperties(aPropMap);
2366
0
                }
2367
67.2k
    }
2368
2369
67.2k
    if (mxShape.is())
2370
67.2k
    {
2371
67.2k
        finalizeXShape( rFilterBase, rxShapes );
2372
2373
67.2k
        if (mpTextBody)
2374
51.7k
        {
2375
            // tdf#151518. The method readjustTextDistances is fix for tdf#148321, but conflicts with
2376
            // text position in some of the SmartArt types in Writer. So exclude Writer here.
2377
51.7k
            OUString sDocumentService;
2378
51.7k
            rFilterBase.getMediaDescriptor()[utl::MediaDescriptor::PROP_DOCUMENTSERVICE] >>= sDocumentService;
2379
51.7k
            if (sDocumentService != u"com.sun.star.text.TextDocument")
2380
51.7k
                mpTextBody->getTextProperties().readjustTextDistances(mxShape);
2381
2382
            // tdf#156857: ooxml files can have shape size with spAutoFit=true and the first priority of
2383
            // shape size is the fix size even if TextAutoGrowHeight is true.
2384
51.7k
            bool bAutoHeight = false;
2385
51.7k
            Reference< XPropertySetInfo > xSetInfo(xSet->getPropertySetInfo());
2386
51.7k
            const OUString& rPropName = PropertyMap::getPropertyName(PROP_TextAutoGrowHeight);
2387
51.7k
            if (xSetInfo.is() && xSetInfo->hasPropertyByName(rPropName))
2388
51.7k
            {
2389
51.7k
                uno::Any aTextAutoGrowHeight = xSet->getPropertyValue(u"TextAutoGrowHeight"_ustr);
2390
51.7k
                aTextAutoGrowHeight >>= bAutoHeight;
2391
51.7k
            }
2392
2393
51.7k
            SdrObject* pShape = SdrObject::getSdrObjectFromXShape(mxShape);
2394
51.7k
            if (pShape && bAutoHeight)
2395
475
            {
2396
475
                tools::Rectangle aAutoSize = pShape->GetLogicRect();
2397
                // little tolerance same as in \svx\source\svdraw\svdoashp.cxx:AdjustTextFrameWidthAndHeight
2398
475
                if (!aOrigSize.IsEmpty() && (std::abs(aOrigSize.GetHeight() - aAutoSize.GetHeight()) > 1 ||
2399
475
                    std::abs(aOrigSize.GetWidth() - aAutoSize.GetWidth()) > 1))
2400
0
                {
2401
0
                    pShape->NbcSetLogicRect(aOrigSize, false);
2402
0
                }
2403
475
            }
2404
51.7k
        }
2405
67.2k
    }
2406
67.2k
    return mxShape;
2407
67.2k
}
2408
2409
void Shape::keepDiagramDrawing(XmlFilterBase& rFilterBase, const OUString& rFragmentPath)
2410
36
{
2411
36
    DiagramHelper_oox* pAdvancedDiagramHelper(getDiagramHelper());
2412
36
    if (nullptr == pAdvancedDiagramHelper)
2413
0
        return;
2414
2415
36
    pAdvancedDiagramHelper->setOOXDomValue(
2416
36
        svx::diagram::DomMapFlag::OOXDrawing,
2417
36
        uno::Any(rFilterBase.importFragment(rFragmentPath)));
2418
36
    pAdvancedDiagramHelper->setOOXDomValue(
2419
36
        svx::diagram::DomMapFlag::OOXDrawingImageRels,
2420
36
        uno::Any(resolveRelationshipsOfTypeFromOfficeDoc(rFilterBase, rFragmentPath, u"image")));
2421
36
    pAdvancedDiagramHelper->setOOXDomValue(
2422
36
        svx::diagram::DomMapFlag::OOXDrawingHlinkRels,
2423
36
        uno::Any(resolveRelationshipsOfTypeFromOfficeDoc(rFilterBase, rFragmentPath, u"hlink")));
2424
36
}
2425
2426
void Shape::convertSmartArtToMetafile(XmlFilterBase const & rFilterBase)
2427
293
{
2428
293
    try
2429
293
    {
2430
293
        Reference<XPropertySet> xSet(mxShape, UNO_QUERY_THROW);
2431
2432
293
        xSet->setPropertyValue(u"MoveProtect"_ustr, Any(true));
2433
293
        xSet->setPropertyValue(u"SizeProtect"_ustr, Any(true));
2434
2435
        // Replace existing shapes with a new Graphic Object rendered
2436
        // from them
2437
293
        Reference<XShape> xShape(renderDiagramToGraphic(rFilterBase));
2438
293
        Reference<XShapes> xShapes(mxShape, UNO_QUERY_THROW);
2439
293
        tools::Rectangle aBackgroundRect
2440
293
            = SdrObject::getSdrObjectFromXShape(
2441
293
                  Reference<XShape>(xShapes->getByIndex(0), UNO_QUERY_THROW))
2442
293
                  ->GetLogicRect();
2443
1.00k
        while (xShapes->hasElements())
2444
710
            xShapes->remove(Reference<XShape>(xShapes->getByIndex(0), UNO_QUERY_THROW));
2445
293
        xShapes->add(xShape);
2446
293
        SdrObject::getSdrObjectFromXShape(
2447
293
            Reference<XShape>(xShapes->getByIndex(0), UNO_QUERY_THROW))
2448
293
            ->NbcSetLogicRect(aBackgroundRect);
2449
293
    }
2450
293
    catch (const Exception&)
2451
293
    {
2452
150
        TOOLS_WARN_EXCEPTION("oox.drawingml", "Shape::convertSmartArtToMetafile");
2453
150
    }
2454
293
}
2455
2456
Reference < XShape > Shape::renderDiagramToGraphic( XmlFilterBase const & rFilterBase )
2457
293
{
2458
293
    Reference< XShape > xShape;
2459
2460
293
    try
2461
293
    {
2462
293
        if( nullptr != getDiagramHelper() )
2463
        // if( !maDiagramDoms.hasElements() )
2464
0
            return xShape;
2465
2466
        // Stream in which to place the rendered shape
2467
293
        SvMemoryStream aTempStream;
2468
293
        Reference < io::XStream > xStream( new utl::OStreamWrapper( aTempStream ) );
2469
293
        Reference < io::XOutputStream > xOutputStream( xStream->getOutputStream() );
2470
2471
        // Size of the rendering
2472
293
        awt::Size aActualSize = mxShape->getSize();
2473
293
        Size aResolution(Application::GetDefaultDevice()->LogicToPixel(Size(100, 100), MapMode(MapUnit::MapCM)));
2474
293
        double fPixelsPer100thmm = static_cast < double > ( aResolution.Width() ) / 100000.0;
2475
293
        awt::Size aSize( static_cast < sal_Int32 > ( ( fPixelsPer100thmm * aActualSize.Width ) + 0.5 ),
2476
293
                         static_cast < sal_Int32 > ( ( fPixelsPer100thmm * aActualSize.Height ) + 0.5 ) );
2477
2478
293
        Sequence< PropertyValue > aFilterData{
2479
293
            comphelper::makePropertyValue(u"PixelWidth"_ustr, aSize.Width),
2480
293
            comphelper::makePropertyValue(u"PixelHeight"_ustr, aSize.Height),
2481
293
            comphelper::makePropertyValue(u"LogicalWidth"_ustr, aActualSize.Width),
2482
293
            comphelper::makePropertyValue(u"LogicalHeight"_ustr, aActualSize.Height)
2483
293
        };
2484
2485
293
        Sequence < PropertyValue > aDescriptor{
2486
293
            comphelper::makePropertyValue(u"OutputStream"_ustr, xOutputStream),
2487
293
            comphelper::makePropertyValue(u"FilterName"_ustr, u"SVM"_ustr), // Rendering format
2488
293
            comphelper::makePropertyValue(u"FilterData"_ustr, aFilterData)
2489
293
        };
2490
2491
293
        Reference < lang::XComponent > xSourceDoc( mxShape, UNO_QUERY_THROW );
2492
293
        Reference < XGraphicExportFilter > xGraphicExporter = GraphicExportFilter::create( rFilterBase.getComponentContext() );
2493
293
        xGraphicExporter->setSourceDocument( xSourceDoc );
2494
293
        xGraphicExporter->filter( aDescriptor );
2495
2496
293
        aTempStream.Seek( STREAM_SEEK_TO_BEGIN );
2497
2498
293
        Graphic aGraphic;
2499
293
        GraphicFilter aFilter;
2500
293
        if ( aFilter.ImportGraphic( aGraphic, u"", aTempStream, GRFILTER_FORMAT_NOTFOUND, nullptr, GraphicFilterImportFlags::NONE ) != ERRCODE_NONE )
2501
0
        {
2502
0
            SAL_WARN( "oox.drawingml", "Shape::renderDiagramToGraphic: Unable to import rendered stream into graphic object" );
2503
0
            return xShape;
2504
0
        }
2505
2506
293
        Reference < graphic::XGraphic > xGraphic( aGraphic.GetXGraphic() );
2507
293
        Reference < lang::XMultiServiceFactory > xServiceFact( rFilterBase.getModel(), UNO_QUERY_THROW );
2508
293
        xShape.set( xServiceFact->createInstance( u"com.sun.star.drawing.GraphicObjectShape"_ustr ), UNO_QUERY_THROW );
2509
293
        Reference < XPropertySet > xPropSet( xShape, UNO_QUERY_THROW );
2510
293
        xPropSet->setPropertyValue(  u"Graphic"_ustr, Any( xGraphic ) );
2511
293
        xPropSet->setPropertyValue(  u"MoveProtect"_ustr, Any( true ) );
2512
293
        xPropSet->setPropertyValue(  u"SizeProtect"_ustr, Any( true ) );
2513
293
        xPropSet->setPropertyValue(  u"Name"_ustr, Any( u"RenderedShapes"_ustr ) );
2514
293
    }
2515
293
    catch( const Exception& )
2516
293
    {
2517
0
        TOOLS_WARN_EXCEPTION( "oox.drawingml", "Shape::renderDiagramToGraphic" );
2518
0
    }
2519
2520
293
    return xShape;
2521
293
}
2522
2523
void Shape::setTextBody(const TextBodyPtr & pTextBody)
2524
93.1k
{
2525
93.1k
    mpTextBody = pTextBody;
2526
93.1k
}
2527
2528
void Shape::setMasterTextListStyle( const TextListStylePtr& pMasterTextListStyle )
2529
98.7k
{
2530
98.7k
    SAL_INFO("oox.drawingml", "Shape::setMasterTextListStyle: Set master text list style to shape id='" << msId << "'");
2531
2532
98.7k
    mpMasterTextListStyle = pMasterTextListStyle;
2533
98.7k
}
2534
2535
OUString Shape::finalizeServiceName( XmlFilterBase& rFilter, const OUString& rServiceName, const awt::Rectangle& rShapeRect )
2536
67.2k
{
2537
67.2k
    OUString aServiceName = rServiceName;
2538
67.2k
    switch( meFrameType )
2539
67.2k
    {
2540
0
        case FRAMETYPE_OLEOBJECT:
2541
0
        {
2542
0
            awt::Size aOleSize( rShapeRect.Width, rShapeRect.Height );
2543
0
            if( rFilter.getOleObjectHelper().importOleObject( maShapeProperties, *mxOleObjectInfo, aOleSize ) )
2544
0
                aServiceName = "com.sun.star.drawing.OLE2Shape";
2545
2546
            // get the path to the representation graphic
2547
0
            OUString aGraphicPath;
2548
0
            if( !mxOleObjectInfo->maShapeId.isEmpty() )
2549
0
                if( ::oox::vml::Drawing* pVmlDrawing = rFilter.getVmlDrawing() )
2550
0
                    if( const ::oox::vml::ShapeBase* pVmlShape = pVmlDrawing->getShapes().getShapeById( mxOleObjectInfo->maShapeId ) )
2551
0
                        aGraphicPath = pVmlShape->getGraphicPath();
2552
2553
            // import and store the graphic
2554
0
            if( !aGraphicPath.isEmpty() )
2555
0
            {
2556
                // Transfer shape's width and height to graphicsfilter (can be used by WMF/EMF)
2557
0
                WmfExternal aExtHeader;
2558
0
                aExtHeader.mapMode = 8; // MM_ANISOTROPIC
2559
0
                aExtHeader.xExt = rShapeRect.Width;
2560
0
                aExtHeader.yExt = rShapeRect.Height;
2561
2562
0
                Reference< graphic::XGraphic > xGraphic = rFilter.getGraphicHelper().importEmbeddedGraphic( aGraphicPath, &aExtHeader );
2563
0
                if( xGraphic.is() )
2564
0
                    maShapeProperties.setProperty(PROP_Graphic, xGraphic);
2565
0
            }
2566
0
        }
2567
0
        break;
2568
2569
67.2k
        default:;
2570
67.2k
    }
2571
67.2k
    return aServiceName;
2572
67.2k
}
2573
2574
void Shape::finalizeXShape( XmlFilterBase& rFilter, const Reference< XShapes >& rxShapes )
2575
67.2k
{
2576
67.2k
    switch( meFrameType )
2577
67.2k
    {
2578
436
        case FRAMETYPE_CHART:
2579
436
        {
2580
436
            OSL_ENSURE( !mxChartShapeInfo->maFragmentPath.isEmpty(), "Shape::finalizeXShape - missing chart fragment" );
2581
436
            if( mxShape.is() && !mxChartShapeInfo->maFragmentPath.isEmpty() ) try
2582
403
            {
2583
                // set the chart2 OLE class ID at the OLE shape
2584
403
                PropertySet aShapeProp( mxShape );
2585
403
                aShapeProp.setProperty( PROP_CLSID, u"12dcae26-281f-416f-a234-c3086127382e"_ustr );
2586
2587
                // get the XModel interface of the embedded object from the OLE shape
2588
403
                Reference< frame::XModel > xDocModel;
2589
403
                aShapeProp.getProperty( xDocModel, PROP_Model );
2590
403
                Reference< chart2::XChartDocument > xChartDoc( xDocModel, UNO_QUERY_THROW );
2591
2592
                // load the chart data from the XML fragment
2593
#if ENABLE_WASM_STRIP_CHART
2594
                (void) rFilter;
2595
                (void) rxShapes;
2596
#else
2597
                // WASM_CHART change
2598
                // TODO: Instead of using convertFromModel an alternative may be
2599
                // added to convert not to Chart/OLE SdrObejct, but to GraphicObject
2600
                // with the Chart visualization. There should be a preview available
2601
                // in the imported chart data
2602
403
                bool bMSO2007Doc = rFilter.isMSO2007Document();
2603
403
                chart::ChartSpaceModel aModel(bMSO2007Doc);
2604
403
                oox::ppt::PowerPointImport* pPowerPointImport
2605
403
                    = dynamic_cast<oox::ppt::PowerPointImport*>(&rFilter);
2606
2607
403
                ClrMapPtr pClrMap; // The original color map
2608
403
                if (pPowerPointImport)
2609
0
                {
2610
                    // Use a copy of current color map, which the fragment may override locally
2611
0
                    pClrMap = pPowerPointImport->getActualSlidePersist()->getClrMap();
2612
0
                    aModel.mpClrMap = pClrMap ? std::make_shared<ClrMap>(*pClrMap)
2613
0
                                              : std::make_shared<ClrMap>();
2614
0
                    pPowerPointImport->getActualSlidePersist()->setClrMap(aModel.mpClrMap);
2615
0
                }
2616
2617
403
                rtl::Reference<chart::ChartSpaceFragment> pChartSpaceFragment = new chart::ChartSpaceFragment(
2618
403
                        rFilter, mxChartShapeInfo->maFragmentPath, aModel );
2619
403
                rFilter.importFragment( pChartSpaceFragment );
2620
2621
                // Import styles file.
2622
                // Create the styles path from the path to the chart*.xml file
2623
403
                sal_Int32 nLastSlash = mxChartShapeInfo->maFragmentPath.lastIndexOf('/');
2624
403
                const sal_Unicode *pFPath = mxChartShapeInfo->maFragmentPath.getStr();
2625
403
                OUString sStylePath(pFPath, nLastSlash + 1);
2626
403
                const OUString sFullPath(pFPath);
2627
403
                sStylePath += u"style"_ustr;
2628
403
                OUString sChartFName(sFullPath.copy(nLastSlash + 1, sFullPath.getLength() - nLastSlash - 1));
2629
403
                OUString sTail;
2630
                // Verify that the path is the way we expect it, and extract the
2631
                // end bit. Don't put the startsWith() call inside an assert,
2632
                // because we don't want it optimized away.
2633
403
                const bool bWellFormed = sChartFName.startsWith(std::u16string_view(u"chart"), &sTail);
2634
403
                if (!bWellFormed) {
2635
0
                    assert(false);
2636
0
                }
2637
                // We should have something of the form 'chart1234.xml'. We
2638
                // want to get the numeric ('1234') part, since it should be
2639
                // the same for the style file.
2640
403
                sal_Int32 nPeriod = sTail.indexOf('.');
2641
403
                OUString sNumber(sTail.copy(0, nPeriod));
2642
2643
403
                sStylePath += sNumber;
2644
403
                sStylePath += u".xml"_ustr;
2645
2646
403
                chart::StyleModel aStyleModel;
2647
403
                rtl::Reference<chart::StyleFragment> pStyleFragment = new chart::StyleFragment(
2648
403
                        rFilter, sStylePath, aStyleModel );
2649
403
                rFilter.importFragment( pStyleFragment );
2650
2651
                // Import colors file.
2652
403
                OUString sColorPath(pFPath, nLastSlash + 1);
2653
403
                sColorPath += u"colors"_ustr;
2654
403
                sChartFName = sFullPath.copy(nLastSlash + 1, sFullPath.getLength() - nLastSlash - 1);
2655
403
                sColorPath += sNumber;
2656
403
                sColorPath += u".xml"_ustr;
2657
2658
403
                chart::ColorStyleModel aColorsModel;
2659
403
                rtl::Reference<chart::ColorsFragment> pColorsFragment =
2660
403
                    new chart::ColorsFragment( rFilter, sColorPath, aColorsModel );
2661
403
                rFilter.importFragment( pColorsFragment );
2662
2663
2664
                // The original theme.
2665
403
                ThemePtr pTheme;
2666
403
                const OUString aThemeOverrideFragmentPath( pChartSpaceFragment->
2667
403
                        getFragmentPathFromFirstTypeFromOfficeDoc(u"themeOverride") );
2668
2669
403
                if (!aThemeOverrideFragmentPath.isEmpty() && pPowerPointImport)
2670
0
                {
2671
                    // Handle theme override.
2672
0
                    uno::Reference< xml::sax::XFastSAXSerializable > xDoc(
2673
0
                            rFilter.importFragment(aThemeOverrideFragmentPath), uno::UNO_QUERY_THROW);
2674
0
                    pTheme = pPowerPointImport->getActualSlidePersist()->getTheme();
2675
0
                    auto pThemeOverride = std::make_shared<Theme>(*pTheme);
2676
0
                    rFilter.importFragment(
2677
0
                        new ThemeOverrideFragmentHandler(rFilter, aThemeOverrideFragmentPath, *pThemeOverride, *pThemeOverride->getTheme()),
2678
0
                        xDoc);
2679
0
                    pPowerPointImport->getActualSlidePersist()->setTheme(pThemeOverride);
2680
0
                }
2681
2682
                // convert imported chart model to chart document
2683
403
                Reference< drawing::XShapes > xExternalPage;
2684
403
                if( !mxChartShapeInfo->mbEmbedShapes )
2685
0
                    xExternalPage = rxShapes;
2686
2687
                // There are several calls to rFilter.getChartConverter() here.
2688
                // Doing just one call and storing the result, as in
2689
                //     chart::ChartConverter *pChartConv = rFilter.getChartConverter();
2690
                // *doesn't work* (tests crash).
2691
403
                if( rFilter.getChartConverter() )
2692
0
                {
2693
0
                    rFilter.getChartConverter()->convertFromModel( rFilter, aModel, xChartDoc, xExternalPage, mxShape->getPosition(), mxShape->getSize() );
2694
0
                    if( !xChartDoc->hasInternalDataProvider() )
2695
0
                    {
2696
0
                        Reference< chart2::data::XDataReceiver > xDataRec( xChartDoc, UNO_QUERY );
2697
0
                        Reference< chart2::data::XDataSource > xData = xDataRec->getUsedData();
2698
0
                        if( !xData->getDataSequences().hasElements() || !xData->getDataSequences()[0]->getValues().is() ||
2699
0
                                !xData->getDataSequences()[0]->getValues()->getData().hasElements() )
2700
0
                        {
2701
0
                            rFilter.useInternalChartDataTable( true );
2702
0
                            rFilter.getChartConverter()->convertFromModel( rFilter, aModel, xChartDoc, xExternalPage, mxShape->getPosition(), mxShape->getSize() );
2703
0
                            rFilter.useInternalChartDataTable( false );
2704
0
                        }
2705
0
                    }
2706
2707
0
                }
2708
2709
                // convert chart style model to docmodel style data
2710
403
                Reference<com::sun::star::chart2::XChartStyle> xStyle = xChartDoc->getStyles();
2711
403
                oox::drawingml::chart::ChartStyleConverter::convertFromModel(rFilter, aStyleModel, xStyle);
2712
                // convert color style model to docmodel colors data
2713
403
                Reference<com::sun::star::chart2::XChartColorStyle> xCStyle = xChartDoc->getColorStyles();
2714
403
                oox::drawingml::chart::ChartColorStyleConverter::convertFromModel(rFilter, aColorsModel, xCStyle);
2715
2716
403
                if (pPowerPointImport)
2717
0
                {
2718
0
                    if (!aThemeOverrideFragmentPath.isEmpty())
2719
0
                    {
2720
                        // Restore the original theme.
2721
0
                        pPowerPointImport->getActualSlidePersist()->setTheme(pTheme);
2722
0
                    }
2723
                    // Restore the original color map
2724
0
                    pPowerPointImport->getActualSlidePersist()->setClrMap(std::move(pClrMap));
2725
0
                }
2726
403
#endif
2727
403
            }
2728
403
            catch( Exception& )
2729
403
            {
2730
403
            }
2731
436
        }
2732
436
        break;
2733
2734
66.8k
        default:;
2735
67.2k
    }
2736
67.2k
}
2737
2738
void Shape::putPropertyToGrabBag( const OUString& sPropertyName, const Any& aPropertyValue )
2739
79.5k
{
2740
79.5k
    PropertyValue aNewProperty;
2741
79.5k
    aNewProperty.Name = sPropertyName;
2742
79.5k
    aNewProperty.Value = aPropertyValue;
2743
79.5k
    putPropertyToGrabBag( aNewProperty );
2744
79.5k
}
2745
2746
void Shape::putPropertyToGrabBag( const PropertyValue& pProperty )
2747
79.5k
{
2748
79.5k
    Reference< XPropertySet > xSet( mxShape, UNO_QUERY );
2749
79.5k
    Reference< XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() );
2750
79.5k
    const OUString aGrabBagPropName = UNO_NAME_MISC_OBJ_INTEROPGRABBAG;
2751
79.5k
    if( mxShape.is() && xSet.is() && xSetInfo.is() && xSetInfo->hasPropertyByName( aGrabBagPropName ) )
2752
38.8k
    {
2753
38.8k
        Sequence< PropertyValue > aGrabBag;
2754
38.8k
        xSet->getPropertyValue( aGrabBagPropName ) >>= aGrabBag;
2755
2756
38.8k
        sal_Int32 length = aGrabBag.getLength();
2757
38.8k
        aGrabBag.realloc( length + 1 );
2758
38.8k
        aGrabBag.getArray()[length] = pProperty;
2759
2760
38.8k
        xSet->setPropertyValue( aGrabBagPropName, Any( aGrabBag ) );
2761
38.8k
    }
2762
79.5k
}
2763
2764
void Shape::putPropertiesToGrabBag( const Sequence< PropertyValue >& aProperties )
2765
66.6k
{
2766
66.6k
    Reference< XPropertySet > xSet( mxShape, UNO_QUERY );
2767
66.6k
    Reference< XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() );
2768
66.6k
    const OUString aGrabBagPropName = UNO_NAME_MISC_OBJ_INTEROPGRABBAG;
2769
66.6k
    if( !(mxShape.is() && xSet.is() && xSetInfo.is() && xSetInfo->hasPropertyByName( aGrabBagPropName )) )
2770
40.6k
        return;
2771
2772
    // get existing grab bag
2773
25.9k
    Sequence< PropertyValue > aGrabBag;
2774
25.9k
    xSet->getPropertyValue( aGrabBagPropName ) >>= aGrabBag;
2775
2776
25.9k
    std::vector<PropertyValue> aVec;
2777
25.9k
    aVec.reserve(aProperties.getLength());
2778
2779
    // put the new items
2780
25.9k
    std::transform(aProperties.begin(), aProperties.end(), std::back_inserter(aVec),
2781
94.9k
        [](const PropertyValue& rProp) {
2782
94.9k
            PropertyValue aProp;
2783
94.9k
            aProp.Name = rProp.Name;
2784
94.9k
            aProp.Value = rProp.Value;
2785
94.9k
            return aProp;
2786
94.9k
        });
2787
2788
    // put it back to the shape
2789
25.9k
    xSet->setPropertyValue( aGrabBagPropName, Any( comphelper::concatSequences(aGrabBag, aVec) ) );
2790
25.9k
}
2791
2792
FillProperties Shape::getActualFillProperties(const Theme* pTheme, const FillProperties* pParentShapeFillProps) const
2793
90.7k
{
2794
90.7k
    FillProperties aFillProperties;
2795
90.7k
    aFillProperties.moFillType = XML_noFill;
2796
2797
    // Reference shape properties
2798
90.7k
    aFillProperties.assignUsed( *mpShapeRefFillPropPtr );
2799
2800
    // Theme
2801
90.7k
    if( pTheme != nullptr )
2802
64.3k
    {
2803
64.3k
        if( const ShapeStyleRef* pFillRef = getShapeStyleRef( XML_fillRef ) )
2804
3.27k
        {
2805
3.27k
            if( const FillProperties* pFillProps = pTheme->getFillStyle( pFillRef->mnThemedIdx ) )
2806
782
                aFillProperties.assignUsed( *pFillProps );
2807
3.27k
        }
2808
64.3k
    }
2809
2810
    // Properties specified directly for this shape
2811
90.7k
    aFillProperties.assignUsed(getFillProperties());
2812
2813
    // Parent shape's properties
2814
90.7k
    if ( pParentShapeFillProps != nullptr)
2815
67.2k
        if( getFillProperties().moFillType.has_value() && getFillProperties().moFillType.value() == XML_grpFill )
2816
6
            aFillProperties.assignUsed( *pParentShapeFillProps );
2817
2818
90.7k
    return aFillProperties;
2819
90.7k
}
2820
2821
LineProperties Shape::getActualLineProperties(const Theme* pTheme) const
2822
90.7k
{
2823
90.7k
    LineProperties aLineProperties;
2824
90.7k
    aLineProperties.maLineFill.moFillType = XML_noFill;
2825
2826
    // Reference shape properties
2827
90.7k
    aLineProperties.assignUsed( *mpShapeRefLinePropPtr );
2828
2829
    // Theme
2830
90.7k
    if( pTheme != nullptr )
2831
64.3k
    {
2832
64.3k
        if( const ShapeStyleRef* pLineRef = getShapeStyleRef( XML_lnRef ) )
2833
3.27k
        {
2834
3.27k
            if( const LineProperties* pLineProps = pTheme->getLineStyle( pLineRef->mnThemedIdx ) )
2835
948
                aLineProperties.assignUsed( *pLineProps );
2836
3.27k
        }
2837
64.3k
    }
2838
2839
    // Properties specified directly for this shape
2840
90.7k
    aLineProperties.assignUsed( getLineProperties() );
2841
2842
90.7k
    return aLineProperties;
2843
90.7k
}
2844
2845
EffectProperties Shape::getActualEffectProperties(const Theme* pTheme) const
2846
90.7k
{
2847
90.7k
    EffectProperties aEffectProperties;
2848
2849
    // Reference shape properties
2850
90.7k
    aEffectProperties.assignUsed( *mpShapeRefEffectPropPtr );
2851
2852
    // Theme
2853
90.7k
    if( pTheme != nullptr )
2854
64.3k
    {
2855
64.3k
        if( const ShapeStyleRef* pEffectRef = getShapeStyleRef( XML_effectRef ) )
2856
3.27k
        {
2857
3.27k
            if( const EffectProperties* pEffectProps = pTheme->getEffectStyle( pEffectRef->mnThemedIdx ) )
2858
44
                aEffectProperties.assignUsed( *pEffectProps );
2859
3.27k
        }
2860
64.3k
    }
2861
2862
    // Properties specified directly for this shape
2863
90.7k
    aEffectProperties.assignUsed ( getEffectProperties() );
2864
2865
90.7k
    return aEffectProperties;
2866
90.7k
}
2867
2868
uno::Sequence< uno::Sequence< uno::Any > >  Shape::resolveRelationshipsOfTypeFromOfficeDoc(core::XmlFilterBase& rFilter, const OUString& sFragment, std::u16string_view sType )
2869
822
{
2870
822
    uno::Sequence< uno::Sequence< uno::Any > > xRelListTemp;
2871
822
    sal_Int32 counter = 0;
2872
2873
822
    core::RelationsRef xRels = rFilter.importRelations( sFragment );
2874
822
    if ( xRels )
2875
822
    {
2876
822
        if (sType == u"image")
2877
411
        {
2878
411
            core::RelationsRef xImageRels = xRels->getRelationsFromTypeFromOfficeDoc(sType);
2879
411
            if (xImageRels)
2880
411
            {
2881
411
                xRelListTemp.realloc(xImageRels->size());
2882
411
                auto pxRelListTemp = xRelListTemp.getArray();
2883
411
                for (auto const& imageRel : *xImageRels)
2884
0
                {
2885
0
                    uno::Sequence<uno::Any> diagramRelTuple(3);
2886
0
                    auto pdiagramRelTuple = diagramRelTuple.getArray();
2887
                    // [0] => RID, [1] => InputStream [2] => extension
2888
0
                    OUString sRelId = imageRel.second.maId;
2889
2890
0
                    pdiagramRelTuple[0] <<= sRelId;
2891
0
                    OUString sTarget = xImageRels->getFragmentPathFromRelId(sRelId);
2892
2893
0
                    uno::Reference<io::XInputStream> xImageInputStrm(
2894
0
                        rFilter.openInputStream(sTarget), uno::UNO_SET_THROW);
2895
0
                    StreamDataSequence dataSeq;
2896
0
                    if (rFilter.importBinaryData(dataSeq, sTarget))
2897
0
                    {
2898
0
                        pdiagramRelTuple[1] <<= dataSeq;
2899
0
                    }
2900
2901
0
                    pdiagramRelTuple[2] <<= sTarget.copy(sTarget.lastIndexOf("."));
2902
2903
0
                    pxRelListTemp[counter] = std::move(diagramRelTuple);
2904
0
                    ++counter;
2905
0
                }
2906
411
            }
2907
411
        }
2908
411
        else if (sType == u"hlink")
2909
411
        {
2910
            // Hyperlink can be internal or external
2911
411
            core::RelationsRef xSlideRels = xRels->getRelationsFromTypeFromOfficeDoc(u"slide");
2912
411
            core::RelationsRef xHlinkRels = xRels->getRelationsFromTypeFromOfficeDoc(u"hyperlink");
2913
2914
411
            sal_Int32 totalSize
2915
411
                = (xSlideRels ? xSlideRels->size() : 0) + (xHlinkRels ? xHlinkRels->size() : 0);
2916
411
            xRelListTemp.realloc(totalSize);
2917
411
            auto pxRelListTemp = xRelListTemp.getArray();
2918
2919
            // Helper to create relation tuple
2920
411
            auto addRelation = [&](const auto& rel, const OUString& relType)
2921
411
            {
2922
0
                uno::Sequence<uno::Any> tuple(3);
2923
0
                auto pTuple = tuple.getArray();
2924
0
                pTuple[0] <<= rel.second.maId;
2925
0
                pTuple[1] <<= rel.second.maTarget;
2926
0
                pTuple[2] <<= relType;
2927
0
                pxRelListTemp[counter++] = std::move(tuple);
2928
0
            };
2929
2930
411
            if (xSlideRels)
2931
411
            {
2932
411
                for (auto const& slideRel : *xSlideRels)
2933
0
                    addRelation(slideRel, "slide");
2934
411
            }
2935
411
            if (xHlinkRels)
2936
411
            {
2937
411
                for (auto const& hlinkRel : *xHlinkRels)
2938
0
                    addRelation(hlinkRel, "hyperlink");
2939
411
            }
2940
411
        }
2941
822
        xRelListTemp.realloc(counter);
2942
822
    }
2943
822
    return xRelListTemp;
2944
822
}
2945
2946
void Shape::cloneFillProperties()
2947
390
{
2948
390
    auto pFillProperties = std::make_shared<FillProperties>();
2949
390
    pFillProperties->assignUsed(*mpFillPropertiesPtr);
2950
390
    mpFillPropertiesPtr = std::move(pFillProperties);
2951
390
}
2952
}
2953
2954
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */