LibreOffice Module oox (master) 1
shape.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <config_wasm_strip.h>
21
31#include "effectproperties.hxx"
40#include <o3tl/safeint.hxx>
42#include <oox/ppt/pptimport.hxx>
44#include <oox/vml/vmlshape.hxx>
52#include <oox/token/properties.hxx>
53#include "diagram/datamodel.hxx"
55
61#include <tools/gen.hxx>
62#include <tools/globname.hxx>
63#include <tools/mapunit.hxx>
64#include <editeng/unoprnms.hxx>
65#include <com/sun/star/awt/FontSlant.hpp>
66#include <com/sun/star/awt/Size.hpp>
67#include <com/sun/star/awt/XBitmap.hpp>
68#include <com/sun/star/awt/FontWeight.hpp>
69#include <com/sun/star/graphic/XGraphic.hpp>
70#include <com/sun/star/container/XNamed.hpp>
71#include <com/sun/star/lang/XMultiServiceFactory.hpp>
72#include <com/sun/star/xml/dom/XDocument.hpp>
73#include <com/sun/star/xml/sax/XFastSAXSerializable.hpp>
74#include <com/sun/star/drawing/FillStyle.hpp>
75#include <com/sun/star/drawing/HomogenMatrix3.hpp>
76#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
77#include <com/sun/star/drawing/GraphicExportFilter.hpp>
78#include <com/sun/star/drawing/XShapes.hpp>
79#include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
80#include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp>
81#include <com/sun/star/drawing/EnhancedCustomShapeTextPathMode.hpp>
82#include <com/sun/star/drawing/ConnectorType.hpp>
83#include <com/sun/star/embed/XEmbeddedObject.hpp>
84#include <com/sun/star/text/XText.hpp>
85#include <com/sun/star/table/BorderLine2.hpp>
86#include <com/sun/star/table/ShadowFormat.hpp>
87#include <com/sun/star/chart2/XChartDocument.hpp>
88#include <com/sun/star/style/ParagraphAdjust.hpp>
89#include <com/sun/star/io/XOutputStream.hpp>
90#include <com/sun/star/lang/Locale.hpp>
91#include <com/sun/star/i18n/ScriptType.hpp>
92
96#include <com/sun/star/document/XActionLockable.hpp>
97#include <com/sun/star/chart2/data/XDataReceiver.hpp>
98#include <com/sun/star/text/GraphicCrop.hpp>
99#include <svx/svdobj.hxx>
100#include <svx/svdotable.hxx>
101#include <svx/svdtrans.hxx>
102#include <tools/stream.hxx>
104#include <unotools/fltrcfg.hxx>
106#include <vcl/graph.hxx>
107#include <vcl/graphicfilter.hxx>
108#include <vcl/svapp.hxx>
109#include <vcl/wmfexternal.hxx>
110#include <sal/log.hxx>
111#include <svx/sdtaitm.hxx>
116
117using namespace ::oox::core;
118using namespace ::com::sun::star;
119using namespace ::com::sun::star::uno;
120using namespace ::com::sun::star::beans;
121using namespace ::com::sun::star::frame;
122using namespace ::com::sun::star::text;
123using namespace ::com::sun::star::drawing;
124using namespace ::com::sun::star::style;
125
126namespace oox::drawingml {
127
128Shape::Shape( const char* pServiceName, bool bDefaultHeight )
129: mpLinePropertiesPtr( std::make_shared<LineProperties>() )
130, mpShapeRefLinePropPtr( std::make_shared<LineProperties>() )
131, mpFillPropertiesPtr( std::make_shared<FillProperties>() )
132, mpShapeRefFillPropPtr( std::make_shared<FillProperties>() )
133, mpGraphicPropertiesPtr( std::make_shared<GraphicProperties>() )
134, mpCustomShapePropertiesPtr( std::make_shared<CustomShapeProperties>() )
135, mp3DPropertiesPtr( std::make_shared<Shape3DProperties>() )
136, mpEffectPropertiesPtr( std::make_shared<EffectProperties>() )
137, mpShapeRefEffectPropPtr( std::make_shared<EffectProperties>() )
138, mpMasterTextListStyle( std::make_shared<TextListStyle>() )
139, mnSubType( 0 )
140, meFrameType( FRAMETYPE_GENERIC )
141, mnRotation( 0 )
142, mnDiagramRotation( 0 )
143, mbFlipH( false )
144, mbFlipV( false )
145, mbHidden( false )
146, mbHiddenMasterShape( false )
147, mbLocked( false )
148, mbWPGChild(false)
149, mbLockedCanvas( false )
150, mbWps( false )
151, mbTextBox( false )
152, mbHasLinkedTxbx( false )
153, maDiagramDoms( 0 )
154, mpDiagramHelper( nullptr )
155{
156 if ( pServiceName )
157 msServiceName = OUString::createFromAscii( pServiceName );
158 setDefaults(bDefaultHeight);
159}
160
161Shape::Shape( const ShapePtr& pSourceShape )
162: mpTextBody(pSourceShape->mpTextBody)
163, mpLinePropertiesPtr( pSourceShape->mpLinePropertiesPtr )
164, mpShapeRefLinePropPtr( pSourceShape->mpShapeRefLinePropPtr )
165, mpFillPropertiesPtr( pSourceShape->mpFillPropertiesPtr )
166, mpShapeRefFillPropPtr( pSourceShape->mpShapeRefFillPropPtr )
167, mpGraphicPropertiesPtr( pSourceShape->mpGraphicPropertiesPtr )
168, mpCustomShapePropertiesPtr( pSourceShape->mpCustomShapePropertiesPtr )
169, mpTablePropertiesPtr( pSourceShape->mpTablePropertiesPtr )
170, mp3DPropertiesPtr( pSourceShape->mp3DPropertiesPtr )
171, mpEffectPropertiesPtr (pSourceShape->mpEffectPropertiesPtr)
172, mpShapeRefEffectPropPtr(pSourceShape->mpShapeRefEffectPropPtr)
173, maShapeProperties( pSourceShape->maShapeProperties )
174, mpMasterTextListStyle( pSourceShape->mpMasterTextListStyle )
175, msServiceName( pSourceShape->msServiceName )
176, msName( pSourceShape->msName )
177, msInternalName( pSourceShape->msInternalName )
178, msId( pSourceShape->msId )
179, mnSubType( pSourceShape->mnSubType )
180, moSubTypeIndex( pSourceShape->moSubTypeIndex )
181, maShapeStyleRefs( pSourceShape->maShapeStyleRefs )
182, maSize( pSourceShape->maSize )
183, maPosition( pSourceShape->maPosition )
184, meFrameType( pSourceShape->meFrameType )
185, mnRotation( pSourceShape->mnRotation )
186, mnDiagramRotation( pSourceShape->mnDiagramRotation )
187, mbFlipH( pSourceShape->mbFlipH )
188, mbFlipV( pSourceShape->mbFlipV )
189, mbHidden( pSourceShape->mbHidden )
190, mbHiddenMasterShape( pSourceShape->mbHiddenMasterShape )
191, mbLocked( pSourceShape->mbLocked )
192, mbWPGChild( pSourceShape->mbWPGChild )
193, mbLockedCanvas( pSourceShape->mbLockedCanvas )
194, mbWps( pSourceShape->mbWps )
195, mbTextBox( pSourceShape->mbTextBox )
196, mbHasLinkedTxbx(false)
197, maDiagramDoms( pSourceShape->maDiagramDoms )
198, mnZOrder(pSourceShape->mnZOrder)
199, mnZOrderOff(pSourceShape->mnZOrderOff)
200, mnDataNodeType(pSourceShape->mnDataNodeType)
201, mfAspectRatio(pSourceShape->mfAspectRatio)
202, mpDiagramHelper( nullptr )
203, msDiagramDataModelID(pSourceShape->msDiagramDataModelID)
204{}
205
207{
208 // DiagramHelper should not be set here anymore, see
209 // propagateDiagramHelper below (maybe assert..?)
210 delete mpDiagramHelper;
211}
212
214 const std::shared_ptr< Diagram >& rDiagramPtr,
215 const std::shared_ptr<::oox::drawingml::Theme>& rTheme)
216{
217 // Prepare Diagram data collecting for this Shape
218 if( nullptr == mpDiagramHelper && FRAMETYPE_DIAGRAM == meFrameType )
219 {
221 rDiagramPtr,
222 rTheme,
223 getSize());
224 }
225}
226
228{
229 // Propagate collected Diagram data to data holder
230 if (FRAMETYPE_DIAGRAM == meFrameType && nullptr != mpDiagramHelper)
231 {
233
234 if(pAnchorObj)
235 {
236 static_cast<AdvancedDiagramHelper*>(mpDiagramHelper)->doAnchor(*pAnchorObj, *this);
237 mpDiagramHelper = nullptr;
238 }
239 }
240
241 // If propagation failed, delete/cleanup here. Since the DiagramHelper
242 // holds a Diagram and that this Shape it is necessary - the destructor
243 // will not be called and will be too late
244 if (nullptr != mpDiagramHelper)
245 {
246 delete mpDiagramHelper;
247 mpDiagramHelper = nullptr;
248 }
249}
250
252{
253 if(!mpDiagramHelper)
254 {
255 return;
256 }
257
258 if(!pTarget)
259 {
260 // no migrate target, but cleanup helper
261 delete mpDiagramHelper;
262 mpDiagramHelper = nullptr;
263 return;
264 }
265
266 if(pTarget->mpDiagramHelper)
267 {
268 // this should no happen, but if there is already a helper, clean it up
269 delete pTarget->mpDiagramHelper;
270 pTarget->mpDiagramHelper = nullptr;
271 }
272
273 // exchange and reset to nullptr
274 pTarget->mpDiagramHelper = mpDiagramHelper;
275 mpDiagramHelper = nullptr;
276}
277
279{
281 mpTablePropertiesPtr = std::make_shared<table::TableProperties>();
283}
284
285void Shape::setDefaults(bool bHeight)
286{
289 maDefaultShapeProperties.setProperty(PROP_TextLeftDistance, static_cast< sal_Int32 >( 250 ));
290 maDefaultShapeProperties.setProperty(PROP_TextUpperDistance, static_cast< sal_Int32 >( 125 ));
291 maDefaultShapeProperties.setProperty(PROP_TextRightDistance, static_cast< sal_Int32 >( 250 ));
292 maDefaultShapeProperties.setProperty(PROP_TextLowerDistance, static_cast< sal_Int32 >( 125 ));
293 if (bHeight)
294 maDefaultShapeProperties.setProperty(PROP_CharHeight, static_cast< float >( 18.0 ));
297 static_cast<sal_Int16>(ParagraphAdjust_LEFT));
298}
299
301{
302 OSL_ENSURE( meFrameType == FRAMETYPE_GENERIC, "Shape::setOleObjectType - multiple frame types" );
304 mxOleObjectInfo = std::make_shared<::oox::vml::OleObjectInfo>( true );
305 return *mxOleObjectInfo;
306}
307
309{
310 OSL_ENSURE( meFrameType == FRAMETYPE_GENERIC, "Shape::setChartType - multiple frame types" );
312 if (mbWps)
313 msServiceName = "com.sun.star.drawing.temporaryForXMLImportOLE2Shape";
314 else
315 msServiceName = "com.sun.star.drawing.OLE2Shape";
316 mxChartShapeInfo = std::make_shared<ChartShapeInfo>( bEmbedShapes );
317 return *mxChartShapeInfo;
318}
319
321{
322 OSL_ENSURE( meFrameType == FRAMETYPE_GENERIC, "Shape::setDiagramType - multiple frame types" );
324 msServiceName = "com.sun.star.drawing.GroupShape";
325 mnSubType = 0;
326}
327
329{
330 OSL_ENSURE( meFrameType == FRAMETYPE_GENERIC, "Shape::setTableType - multiple frame types" );
332 msServiceName = "com.sun.star.drawing.TableShape";
333 mnSubType = 0;
334}
335
336void Shape::setServiceName( const char* pServiceName )
337{
338 if ( pServiceName )
339 msServiceName = OUString::createFromAscii( pServiceName );
340}
341
342const ShapeStyleRef* Shape::getShapeStyleRef( sal_Int32 nRefType ) const
343{
344 ShapeStyleRefMap::const_iterator aIt = maShapeStyleRefs.find( nRefType );
345 return (aIt == maShapeStyleRefs.end()) ? nullptr : &aIt->second;
346}
347
349 ::oox::core::XmlFilterBase& rFilterBase,
350 const Theme* pTheme,
351 const Reference< XShapes >& rxShapes,
352 const basegfx::B2DHomMatrix& aTransformation,
353 const FillProperties& rShapeOrParentShapeFillProps,
354 ShapeIdMap* pShapeMap,
355 oox::drawingml::ShapePtr pParentGroupShape)
356{
357 SAL_INFO("oox.drawingml", "Shape::addShape: id='" << msId << "'");
358
359 try
360 {
361 OUString sServiceName( msServiceName );
362 if( !sServiceName.isEmpty() )
363 {
364 basegfx::B2DHomMatrix aMatrix( aTransformation );
365 Reference< XShape > xShape( createAndInsert( rFilterBase, sServiceName, pTheme, rxShapes, false, false, aMatrix, rShapeOrParentShapeFillProps, pParentGroupShape) );
366
367 if( pShapeMap && !msId.isEmpty() )
368 {
369 (*pShapeMap)[ msId ] = shared_from_this();
370 }
371
372 // if this is a group shape, we have to add also each child shape
373 Reference< XShapes > xShapes( xShape, UNO_QUERY );
374 if ( xShapes.is() )
375 addChildren( rFilterBase, *this, pTheme, xShapes, pShapeMap, aMatrix );
376
377 if (isWPGChild() && xShape)
378 {
379 // This is a wps shape and it is the child of the WPG, now copy the
380 // the text body properties to the xshape.
381 Reference<XPropertySet> xChildWPSProperties(xShape, uno::UNO_QUERY);
382
383 if (getTextBody() && xChildWPSProperties)
384 {
385 xChildWPSProperties->setPropertyValue(
387 uno::Any(getTextBody()->getTextProperties().meVA));
388
389 xChildWPSProperties->setPropertyValue(
391 uno::Any(getTextBody()->getTextProperties().moInsets[0].has_value()
392 ? *getTextBody()->getTextProperties().moInsets[0]
393 : 0));
394 xChildWPSProperties->setPropertyValue(
396 uno::Any(getTextBody()->getTextProperties().moInsets[1].has_value()
397 ? *getTextBody()->getTextProperties().moInsets[1]
398 : 0));
399 xChildWPSProperties->setPropertyValue(
401 uno::Any(getTextBody()->getTextProperties().moInsets[2].has_value()
402 ? *getTextBody()->getTextProperties().moInsets[2]
403 : 0));
404 xChildWPSProperties->setPropertyValue(
406 uno::Any(getTextBody()->getTextProperties().moInsets[3].has_value()
407 ? *getTextBody()->getTextProperties().moInsets[3]
408 : 0));
409 }
410
411 // tdf#145147 Set the Hyperlink property to the child wps shape.
412 if (getShapeProperties().hasProperty(PROP_URL)) try
413 {
414 uno::Any aAny = getShapeProperties().getProperty(PROP_URL);
415 OUString sUrl = aAny.get<OUString>();
416 if (!sUrl.isEmpty())
417 xChildWPSProperties->setPropertyValue(UNO_NAME_HYPERLINK, aAny);
418 }
419 catch (const Exception&)
420 {
421 }
422 }
423
425 {
427
428 // set DiagramHelper at SdrObjGroup
430
431 // Check if this is the PPTX import, so far converting SmartArt to a non-editable
432 // metafile is only implemented for DOCX.
433 bool bPowerPoint = dynamic_cast<oox::ppt::PowerPointImport*>(&rFilterBase) != nullptr;
434
435 if (!SvtFilterOptions::Get().IsSmartArt2Shape() && !bPowerPoint)
436 convertSmartArtToMetafile( rFilterBase );
437 }
438
439 NamedShapePairs* pNamedShapePairs = rFilterBase.getDiagramFontHeights();
440 if (xShape.is() && pNamedShapePairs)
441 {
442 auto itPairs = pNamedShapePairs->find(getInternalName());
443 if (itPairs != pNamedShapePairs->end())
444 {
445 auto it = itPairs->second.find(shared_from_this());
446 if (it != itPairs->second.end())
447 {
448 // Our drawingml::Shape is in the list of an internal name, remember the now
449 // inserted XShape.
450 it->second = xShape;
451 }
452 }
453 }
454 }
455 }
456 catch( const Exception& )
457 {
458 TOOLS_WARN_EXCEPTION( "oox.drawingml", "Shape::addShape" );
459 }
460}
461
462void Shape::setLockedCanvas(bool bLockedCanvas)
463{
464 mbLockedCanvas = bLockedCanvas;
465}
466
467void Shape::setWPGChild(bool bWPG)
468{
469 mbWPGChild = bWPG;
470}
471
472void Shape::setWps(bool bWps)
473{
474 mbWps = bWps;
475}
476
477void Shape::setTextBox(bool bTextBox)
478{
479 mbTextBox = bTextBox;
480}
481
482void Shape::applyShapeReference( const Shape& rReferencedShape, bool bUseText )
483{
484 SAL_INFO("oox.drawingml", "Shape::applyShapeReference: apply '" << rReferencedShape.msId << "' to '" << msId << "'");
485
486 if ( rReferencedShape.mpTextBody && bUseText )
487 mpTextBody = std::make_shared<TextBody>( *rReferencedShape.mpTextBody );
488 else
489 mpTextBody.reset();
490 maShapeProperties = rReferencedShape.maShapeProperties;
491 mpShapeRefLinePropPtr = std::make_shared<LineProperties>( rReferencedShape.getActualLineProperties(nullptr) );
492 mpShapeRefFillPropPtr = std::make_shared<FillProperties>( rReferencedShape.getActualFillProperties(nullptr, nullptr) );
493 mpCustomShapePropertiesPtr = std::make_shared<CustomShapeProperties>( *rReferencedShape.mpCustomShapePropertiesPtr );
494 mpTablePropertiesPtr = rReferencedShape.mpTablePropertiesPtr ? std::make_shared<table::TableProperties>( *rReferencedShape.mpTablePropertiesPtr ) : nullptr;
495 mpShapeRefEffectPropPtr = std::make_shared<EffectProperties>( rReferencedShape.getActualEffectProperties(nullptr) );
496 mpMasterTextListStyle = std::make_shared<TextListStyle>( *rReferencedShape.mpMasterTextListStyle );
497 maSize = rReferencedShape.maSize;
498 maPosition = rReferencedShape.maPosition;
499 mnRotation = rReferencedShape.mnRotation;
500 mbFlipH = rReferencedShape.mbFlipH;
501 mbFlipV = rReferencedShape.mbFlipV;
502 mbHidden = rReferencedShape.mbHidden;
503 mbLocked = rReferencedShape.mbLocked;
504}
505
506namespace {
507
508struct ActionLockGuard
509{
510 explicit ActionLockGuard(Reference<drawing::XShape> const& xShape)
511 : m_xLockable(xShape, UNO_QUERY)
512 {
513 if (m_xLockable.is()) {
514 m_xLockable->addActionLock();
515 }
516 }
517 ~ActionLockGuard()
518 {
519 if (m_xLockable.is()) {
520 m_xLockable->removeActionLock();
521 }
522 }
523private:
524 Reference<document::XActionLockable> m_xLockable;
525};
526
527}
528
529// for group shapes, the following method is also adding each child
531 XmlFilterBase& rFilterBase,
532 Shape& rMaster,
533 const Theme* pTheme,
534 const Reference< XShapes >& rxShapes,
535 ShapeIdMap* pShapeMap,
536 const basegfx::B2DHomMatrix& aTransformation )
537{
538 for (auto const& child : rMaster.maChildren)
539 {
540 child->setMasterTextListStyle( mpMasterTextListStyle );
541 child->addShape( rFilterBase, pTheme, rxShapes, aTransformation, getFillProperties(), pShapeMap, rMaster.shared_from_this());
542 }
543}
544
545static SdrTextHorzAdjust lcl_convertAdjust( ParagraphAdjust eAdjust )
546{
547 if (eAdjust == ParagraphAdjust_LEFT)
549 else if (eAdjust == ParagraphAdjust_RIGHT)
551 else if (eAdjust == ParagraphAdjust_CENTER)
554}
555
556// LO does not interpret properties in styles belonging to the text content of a FontWork shape,
557// but only those in the shape style. This method copies properties from the text content styles to
558// the shape style.
559static void lcl_copyCharPropsToShape(const uno::Reference<drawing::XShape>& xShape,
560 const TextBodyPtr& pTextBody,
561 const ::oox::core::XmlFilterBase& rFilter)
562{
563 if (!xShape.is() || !pTextBody)
564 return;
565
566 Reference<XPropertySet> xSet(xShape, UNO_QUERY);
567 if (!xSet.is())
568 return;
569
570 // Content stretches or scales to given width and height, thus disable autogrow.
571 xSet->setPropertyValue(UNO_NAME_TEXT_AUTOGROWHEIGHT, uno::Any(false));
572 xSet->setPropertyValue(UNO_NAME_TEXT_AUTOGROWWIDTH, uno::Any(false));
573
574 // LibreOffice is not able (as of Nov 2022) to use different styles for the paragraphs or
575 // characters in FontWork, since that was not allowed in old binary WordArt. We use the
576 // properties of the first non empty paragraph for now.
577 const TextParagraphVector& rParagraphs = pTextBody->getParagraphs();
578 auto aParaIt = std::find_if_not(rParagraphs.cbegin(), rParagraphs.cend(),
579 [](const std::shared_ptr<TextParagraph> pParagraph) {
580 return pParagraph->getRuns().empty();
581 });
582 if (aParaIt != rParagraphs.cend())
583 {
584 std::shared_ptr<TextParagraph> pParagraph = *aParaIt;
585 const TextRunVector& rRuns = pParagraph->getRuns();
586 auto aRunIt = std::find_if_not(
587 rRuns.cbegin(), rRuns.cend(),
588 [](const std::shared_ptr<TextRun> pRun) { return pRun->getText().isEmpty(); });
589 if (aRunIt != rRuns.cend())
590 {
591 std::shared_ptr<TextRun> pRun = *aRunIt;
592 TextCharacterProperties& rCharProps = pRun->getTextCharacterProperties();
593
594 // set language
595 if (rCharProps.moLang.has_value() && !rCharProps.moLang.value().isEmpty())
596 {
597 LanguageTag aTag(rCharProps.moLang.value());
598 css::lang::Locale aLocale(aTag.getLocale(false));
600 {
601 case css::i18n::ScriptType::LATIN:
602 xSet->setPropertyValue(u"CharLocale", uno::Any(aLocale));
603 break;
604 case css::i18n::ScriptType::ASIAN:
605 xSet->setPropertyValue(u"CharLocaleAsian", uno::Any(aLocale));
606 break;
607 case css::i18n::ScriptType::COMPLEX:
608 xSet->setPropertyValue(u"CharLocaleComplex", uno::Any(aLocale));
609 break;
610 default:;
611 }
612 }
613
614 // Font Weight, Posture, Height
615 if (rCharProps.moBold.has_value() && rCharProps.moBold.value())
616 {
617 xSet->setPropertyValue(UNO_NAME_CHAR_WEIGHT, uno::Any(css::awt::FontWeight::BOLD));
618 }
619 if (rCharProps.moItalic.has_value() && rCharProps.moItalic.value())
620 {
621 xSet->setPropertyValue(UNO_NAME_CHAR_POSTURE,
622 uno::Any(css::awt::FontSlant::FontSlant_ITALIC));
623 }
624 if (rCharProps.moHeight.has_value())
625 {
626 sal_Int32 nHeight = rCharProps.moHeight.value() / 100;
627 xSet->setPropertyValue(UNO_NAME_CHAR_HEIGHT, uno::Any(nHeight));
628 }
629
630 // Put theme fonts into shape properties
631 OUString sFontName;
632 sal_Int16 nFontPitch = 0;
633 sal_Int16 nFontFamily = 0;
634 bool bRet(false);
635 if (const Theme* pTheme = rFilter.getCurrentTheme())
636 {
637 // minor Latin
638 if (const TextFont* pFont = pTheme->resolveFont(u"+mn-lt"))
639 {
640 bRet = pFont->getFontData(sFontName, nFontPitch, nFontFamily, rFilter);
641 if (bRet)
642 {
643 xSet->setPropertyValue(u"CharFontName", uno::Any(sFontName));
644 xSet->setPropertyValue(u"CharFontPitch", uno::Any(nFontPitch));
645 xSet->setPropertyValue(u"CharFontFamily", uno::Any(nFontFamily));
646 }
647 }
648 // minor Asian
649 if (const TextFont* pFont = pTheme->resolveFont(u"+mn-ea"))
650 {
651 bRet = pFont->getFontData(sFontName, nFontPitch, nFontFamily, rFilter);
652 if (bRet)
653 {
654 xSet->setPropertyValue(u"CharFontNameAsian", uno::Any(sFontName));
655 xSet->setPropertyValue(u"CharFontPitchAsian", uno::Any(nFontPitch));
656 xSet->setPropertyValue(u"CharFontFamilyAsian", uno::Any(nFontFamily));
657 }
658 }
659 // minor Complex
660 if (const TextFont* pFont = pTheme->resolveFont(u"+mn-cs"))
661 {
662 bRet = pFont->getFontData(sFontName, nFontPitch, nFontFamily, rFilter);
663 if (bRet)
664 {
665 xSet->setPropertyValue(u"CharFontNameComplex", uno::Any(sFontName));
666 xSet->setPropertyValue(u"CharFontPitchComplex", uno::Any(nFontPitch));
667 xSet->setPropertyValue(u"CharFontFamilyComplex", uno::Any(nFontFamily));
668 }
669 }
670 }
671
672 // Replace theme fonts with formatting at run if any. ToDo: Inspect paragraph too?
673 // Latin
674 bRet = rCharProps.maLatinFont.getFontData(sFontName, nFontPitch, nFontFamily, rFilter);
675 if (!bRet)
676 // In case there is no direct font, try to look it up as a theme reference.
677 bRet = rCharProps.maLatinThemeFont.getFontData(sFontName, nFontPitch, nFontFamily,
678 rFilter);
679
680 if (bRet)
681 {
682 xSet->setPropertyValue(u"CharFontName", uno::Any(sFontName));
683 xSet->setPropertyValue(u"CharFontPitch", uno::Any(nFontPitch));
684 xSet->setPropertyValue(u"CharFontFamily", uno::Any(nFontFamily));
685 }
686 // Asian
687 bRet = rCharProps.maAsianFont.getFontData(sFontName, nFontPitch, nFontFamily, rFilter);
688 if (!bRet)
689 // In case there is no direct font, try to look it up as a theme reference.
690 bRet = rCharProps.maAsianThemeFont.getFontData(sFontName, nFontPitch, nFontFamily,
691 rFilter);
692 if (bRet)
693 {
694 xSet->setPropertyValue(u"CharFontNameAsian", uno::Any(sFontName));
695 xSet->setPropertyValue(u"CharFontPitchAsian", uno::Any(nFontPitch));
696 xSet->setPropertyValue(u"CharFontFamilyAsian", uno::Any(nFontFamily));
697 }
698 // Complex
699 bRet
700 = rCharProps.maComplexFont.getFontData(sFontName, nFontPitch, nFontFamily, rFilter);
701 if (!bRet)
702 // In case there is no direct font, try to look it up as a theme reference.
703 bRet = rCharProps.maComplexThemeFont.getFontData(sFontName, nFontPitch, nFontFamily,
704 rFilter);
705 if (bRet)
706 {
707 xSet->setPropertyValue(u"CharFontNameComplex", uno::Any(sFontName));
708 xSet->setPropertyValue(u"CharFontPitchComplex", uno::Any(nFontPitch));
709 xSet->setPropertyValue(u"CharFontFamilyComplex", uno::Any(nFontFamily));
710 }
711
712 // LO uses shape properties, MS Office character properties. Copy them from char to shape.
713 // Outline
714 if (rCharProps.moTextOutlineProperties.has_value())
715 {
716 oox::drawingml::ShapePropertyMap aStrokeShapeProps(rFilter.getModelObjectHelper());
717 rCharProps.moTextOutlineProperties.value().pushToPropMap(
718 aStrokeShapeProps, rFilter.getGraphicHelper());
719 for (const auto& rProp : aStrokeShapeProps.makePropertyValueSequence())
720 {
721 xSet->setPropertyValue(rProp.Name, rProp.Value);
722 }
723 }
724 else
725 {
726 xSet->setPropertyValue(UNO_NAME_LINESTYLE, uno::Any(drawing::LineStyle_NONE));
727 }
728
729 // Fill
730 // ToDo: Replace flip and rotate constants in parameters with actual values.
731 // tdf#155327 If color is not explicitly set, MS Office uses scheme color 'tx1'.
732 oox::drawingml::ShapePropertyMap aFillShapeProps(rFilter.getModelObjectHelper());
733 if (!rCharProps.maFillProperties.moFillType.has_value())
734 rCharProps.maFillProperties.moFillType = XML_solidFill;
735 if (!rCharProps.maFillProperties.maFillColor.isUsed())
736 rCharProps.maFillProperties.maFillColor.setSchemeClr(XML_tx1);
737 rCharProps.maFillProperties.pushToPropMap(aFillShapeProps, rFilter.getGraphicHelper(),
738 /*nShapeRotation*/ 0,
739 /*nPhClr*/ API_RGB_TRANSPARENT,
740 /*aShapeSize*/ css::awt::Size(0, 0),
741 /*nPhClrTheme*/ -1,
742 /*bFlipH*/ false, /*bFlipV*/ false,
743 /*bIsCustomShape*/ true);
744 for (const auto& rProp : aFillShapeProps.makePropertyValueSequence())
745 {
746 xSet->setPropertyValue(rProp.Name, rProp.Value);
747 }
748
749 // ToDo: Import WordArt glow and simple shadow effects. They are available in LO.
750 }
751
752 // LO does not evaluate paragraph alignment in text path mode. Use text area anchor instead.
753 {
754 ParagraphAdjust eAdjust = ParagraphAdjust_LEFT;
755 if (pParagraph->getProperties().getParaAdjust())
756 eAdjust = *pParagraph->getProperties().getParaAdjust();
757 xSet->setPropertyValue("ParaAdjust", uno::Any(eAdjust));
759 assert(pShape);
760 SdrTextHorzAdjust eHorzAdjust = lcl_convertAdjust(eAdjust);
761 pShape->SetMergedItem(SdrTextHorzAdjustItem(eHorzAdjust));
762 }
763 }
764
765 // Vertical adjustment is only meaningful for OOXML WordArt shapes of 'Follow Path' kinds. We set
766 // it so, that text position is approximately same as in MS Office.
767 const OUString sMSPresetType = pTextBody->getTextProperties().msPrst;
768 const OUString sFontworkType = PresetGeometryTypeNames::GetFontworkType(sMSPresetType);
770 assert(pShape);
771 if (sFontworkType == "fontwork-arch-up-curve" || sFontworkType == "fontwork-circle-curve")
772 pShape->SetMergedItem(SdrTextVertAdjustItem(SdrTextVertAdjust::SDRTEXTVERTADJUST_BOTTOM));
773 else if (sFontworkType == "fontwork-arch-down-curve")
774 pShape->SetMergedItem(SdrTextVertAdjustItem(SdrTextVertAdjust::SDRTEXTVERTADJUST_TOP));
775 else
776 pShape->SetMergedItem(SdrTextVertAdjustItem(SdrTextVertAdjust::SDRTEXTVERTADJUST_CENTER));
777}
778
779// Some helper methods for createAndInsert
780namespace
781{
782// mirrors aTransformation at its center axis
783// only valid if neither rotation or shear included
784void lcl_mirrorAtCenter(basegfx::B2DHomMatrix& aTransformation, bool bFlipH, bool bFlipV)
785{
786 if (!bFlipH && !bFlipV)
787 return;
788 basegfx::B2DPoint aCenter(0.5, 0.5);
789 aCenter *= aTransformation;
790 aTransformation.translate(-aCenter);
791 aTransformation.scale(bFlipH ? -1.0 : 1.0, bFlipV ? -1.0 : 1.0);
792 aTransformation.translate(aCenter);
793 return;
794}
795
796// only valid if neither rotation or shear included
797void lcl_doSpecialMSOWidthHeightToggle(basegfx::B2DHomMatrix& aTransformation)
798{
799 // The values are directly set at the matrix without any matrix multiplication.
800 // That way it is valid for lines too. Those have zero width or height.
801 const double fSx(aTransformation.get(0, 0));
802 const double fSy(aTransformation.get(1, 1));
803 const double fTx(aTransformation.get(0, 2));
804 const double fTy(aTransformation.get(1, 2));
805 aTransformation.set(0, 0, fSy);
806 aTransformation.set(1, 1, fSx);
807 aTransformation.set(0, 2, fTx + 0.5 * (fSx - fSy));
808 aTransformation.set(1, 2, fTy + 0.5 * (fSy - fSx));
809 return;
810}
811
812void lcl_RotateAtCenter(basegfx::B2DHomMatrix& aTransformation,sal_Int32 nMSORotationAngle)
813{
814 if (nMSORotationAngle == 0)
815 return;
816 double fRad = basegfx::deg2rad<60000>(nMSORotationAngle);
817 basegfx::B2DPoint aCenter(0.5, 0.5);
818 aCenter *= aTransformation;
819 aTransformation.translate(-aCenter);
820 aTransformation.rotate(fRad);
821 aTransformation.translate(aCenter);
822 return;
823}
824}
825
827 ::oox::core::XmlFilterBase& rFilterBase,
828 const OUString& rServiceName,
829 const Theme* pTheme,
830 const css::uno::Reference< css::drawing::XShapes >& rxShapes,
831 bool bClearText,
832 bool bDoNotInsertEmptyTextBody,
833 basegfx::B2DHomMatrix& aParentTransformation,
834 const FillProperties& rShapeOrParentShapeFillProps,
835 oox::drawingml::ShapePtr pParentGroupShape)
836{
837 bool bIsEmbMedia = false;
838 SAL_INFO("oox.drawingml", "Shape::createAndInsert: id='" << msId << "' service='" << rServiceName << "'");
839
840 formulaimport::XmlStreamBuilder * pMathXml(nullptr);
841 if (mpTextBody)
842 {
843 for (auto const& it : mpTextBody->getParagraphs())
844 {
845 if (it->HasMathXml())
846 {
847 if (!mpTextBody->isEmpty() || pMathXml != nullptr)
848 {
849 SAL_WARN("oox.drawingml", "losing a Math object...");
850 }
851 else
852 {
853 pMathXml = &it->GetMathXml();
854 }
855 }
856 }
857 }
858
859 // tdf#90403 PowerPoint ignores a:ext cx and cy values of p:xfrm, and uses real table width and height
860 if ( mpTablePropertiesPtr && rServiceName == "com.sun.star.drawing.TableShape" )
861 {
862 maSize.Width = 0;
863 for (auto const& elem : mpTablePropertiesPtr->getTableGrid())
864 {
865 maSize.Width = o3tl::saturating_add(maSize.Width, static_cast<sal_Int32>(elem));
866 }
867 maSize.Height = 0;
868 for (auto const& elem : mpTablePropertiesPtr->getTableRows())
869 {
870 // WARN: If some rows can't fit the content, this is not the final height
871 maSize.Height = o3tl::saturating_add(maSize.Height, elem.getHeight());
872 }
873 }
874
875 awt::Rectangle aShapeRectHmm(
880
881 OUString aServiceName;
882 if (pMathXml)
883 {
884 // convert this shape to OLE
885 aServiceName = "com.sun.star.drawing.OLE2Shape";
886 msServiceName = aServiceName;
887 meFrameType = FRAMETYPE_GENERIC; // not OLEOBJECT, no stream in package
888 mnSubType = 0;
889 }
890 else if (rServiceName == "com.sun.star.drawing.GraphicObjectShape" &&
891 mpGraphicPropertiesPtr && !mpGraphicPropertiesPtr->m_sMediaPackageURL.isEmpty())
892 {
893 aServiceName = finalizeServiceName( rFilterBase, "com.sun.star.presentation.MediaShape", aShapeRectHmm );
894 bIsEmbMedia = true;
895 }
896 else
897 {
898 aServiceName = finalizeServiceName( rFilterBase, rServiceName, aShapeRectHmm );
899 }
900 // Use custom shape instead of GraphicObjectShape if the image is cropped to
901 // shape. Except rectangle, which does not require further cropping
902 bool bIsCroppedGraphic = (aServiceName == "com.sun.star.drawing.GraphicObjectShape" &&
903 !mpCustomShapePropertiesPtr->representsDefaultShape());
904
905 bool bIsCustomShape = (aServiceName == "com.sun.star.drawing.CustomShape" || bIsCroppedGraphic);
906 bool bIsConnectorShape = (aServiceName == "com.sun.star.drawing.ConnectorShape");
907 if(bIsCroppedGraphic)
908 {
909 aServiceName = "com.sun.star.drawing.CustomShape";
910 mpGraphicPropertiesPtr->mbIsCustomShape = true;
911 }
912 bool bUseRotationTransform = ( !mbWps ||
913 aServiceName == "com.sun.star.drawing.LineShape" ||
914 aServiceName == "com.sun.star.drawing.GroupShape" ||
915 mbFlipH ||
916 mbFlipV );
917
918 basegfx::B2DHomMatrix aTransformation; // will be cumulative transformation of this object
919
920 // Special for SmartArt import. Rotate diagram's shape around object's center before sizing.
921 if (bUseRotationTransform && mnDiagramRotation != 0)
922 {
923 aTransformation.translate(-0.5, -0.5);
924 aTransformation.rotate(basegfx::deg2rad<60000>(mnDiagramRotation));
925 aTransformation.translate(0.5, 0.5);
926 }
927
928 // Build object matrix from shape size and position; corresponds to MSO ext and off
929 // Only LineShape and ConnectorShape may have zero width or height.
930 if (aServiceName == "com.sun.star.drawing.LineShape"
931 || aServiceName == "com.sun.star.drawing.ConnectorShape")
932 aTransformation.scale(maSize.Width, maSize.Height);
933 else
934 {
935 aTransformation.scale(maSize.Width ? maSize.Width : 1.0,
936 maSize.Height ? maSize.Height : 1.0);
937 }
938
939 // Evaluate object flip. Other shapes than custom shapes have no attribute for flip but use
940 // negative scale. Flip in MSO is at object center.
941 if (!bIsCustomShape && (mbFlipH || mbFlipV))
942 lcl_mirrorAtCenter(aTransformation, mbFlipH, mbFlipV);
943
944 // Evaluate parent flip.
945 // A CustomShape has mirror not as negative scale, but as attributes.
946 basegfx::B2DVector aParentScale(1.0, 1.0);
947 basegfx::B2DVector aParentTranslate(0.0, 0.0);
948 double fParentRotate(0.0);
949 double fParentShearX(0.0);
950 if (pParentGroupShape)
951 {
952 aParentTransformation.decompose(aParentScale, aParentTranslate, fParentRotate, fParentShearX);
953 if (bIsCustomShape)
954 {
955 lcl_mirrorAtCenter(aTransformation, aParentScale.getX() < 0, aParentScale.getY() < 0);
956 if(aParentScale.getX() < 0)
957 mbFlipH = !mbFlipH;
958 if(aParentScale.getY() < 0)
959 mbFlipV = !mbFlipV;
960 }
961 }
962
963 if (maPosition.X != 0 || maPosition.Y != 0)
964 {
965 // if global position is used, add it to transformation
966 if (mbWps && pParentGroupShape == nullptr)
967 aTransformation.translate(
970 else
971 aTransformation.translate(maPosition.X, maPosition.Y);
972 }
973
974 // Apply further parent transformations. First scale object then rotate. Other way round would
975 // introduce shearing.
976
977 // The attributes chExt and chOff of the group in oox file contain the values on which the size
978 // and position of the child is based on. If they differ from the actual size of the group as
979 // given in its ext and off attributes, the child has to be transformed according the new values.
980 if (pParentGroupShape)
981 {
982 // ToDo: A diagram in a group might need special handling because it cannot flip and only
983 // resize uniformly. But currently it is imported with zero size, see tdf#139575. That needs
984 // to be fixed beforehand.
985
986 // Scaling is done from left/top edges of the group. So these need to become coordinate axes.
987 aTransformation.translate(-pParentGroupShape->maChPosition.X,
988 -pParentGroupShape->maChPosition.Y);
989
990 // oox allows zero or missing attribute chExt. In that case the scaling factor is 1.
991 // Transform2DContext::onCreateContext has set maChSize to maSize for groups in oox file in
992 // such cases. For own made groups (e.g. diagrams) that is missing.
993 // The factors cumulate on the way through the parent groups, so we do not use maSize of the
994 // direct parent group but the cumulated value from aParentScale.
995 double fFactorX = 1.0;
996 double fFactorY = 1.0;
997 if (pParentGroupShape->maChSize.Width != 0)
998 fFactorX = aParentScale.getX() / pParentGroupShape->maChSize.Width;
999 if (pParentGroupShape->maChSize.Height != 0)
1000 fFactorY = aParentScale.getY() / pParentGroupShape->maChSize.Height;
1001 if (fFactorX != 1 || fFactorY != 1)
1002 {
1003 // It depends on the object rotation angle whether scaling is applied to switched
1004 // width and height. MSO acts strange in that case (as of May 2021).
1005 const sal_Int32 nDeg(mnRotation / 60000);
1006 const bool bNeedsMSOWidthHeightToggle
1007 = (nDeg >= 45 && nDeg < 135) || (nDeg >= 225 && nDeg < 315);
1008 if (bNeedsMSOWidthHeightToggle)
1009 lcl_doSpecialMSOWidthHeightToggle(aTransformation);
1010
1011 aTransformation.scale(fFactorX, fFactorY);
1012
1013 if (bNeedsMSOWidthHeightToggle)
1014 {
1015 lcl_doSpecialMSOWidthHeightToggle(aTransformation);
1016 // In case of flip the special case needs an additional 180deg rotation.
1017 if ((aParentScale.getX() < 0) != (aParentScale.getY() < 0))
1018 lcl_RotateAtCenter(aTransformation, 10800000);
1019 }
1020 }
1021 }
1022
1023 // Apply object rotation at current object center
1024 // The flip contained in aParentScale will affect orientation of object rotation angle.
1025 sal_Int16 nOrientation = ((aParentScale.getX() < 0) != (aParentScale.getY() < 0)) ? -1 : 1;
1026 // ToDo: Not sure about the restrictions given by bUseRotationTransform.
1027 // Since LibreOffice doesn't have 3D camera options for 2D shapes, rotate the shape opposite of
1028 // the camera Z axis rotation, in order to produce the same visual result from MSO
1029 const sal_Int32 nCameraRotation = get3DProperties().maCameraRotation.mnRevolution.value_or(0);
1030 if (bUseRotationTransform && (mnRotation != 0 || nCameraRotation != 0))
1031 lcl_RotateAtCenter(aTransformation, nOrientation * (mnRotation - nCameraRotation));
1032
1033 if (fParentRotate != 0.0)
1034 aTransformation.rotate(fParentRotate);
1035 if (!aParentTranslate.equalZero())
1036 aTransformation.translate(aParentTranslate);
1037
1038 aParentTransformation = aTransformation;
1039
1040 constexpr double fEmuToMm100 = o3tl::convert(1.0, o3tl::Length::emu, o3tl::Length::mm100);
1041 aTransformation.scale(fEmuToMm100, fEmuToMm100);
1042
1043 // OOXML flips shapes before rotating them, so the rotation needs to be inverted
1044 if( bIsCustomShape && mbFlipH != mbFlipV )
1045 {
1046 basegfx::B2DVector aScale, aTranslate;
1047 double fRotate, fShearX;
1048 aTransformation.decompose(aScale, aTranslate, fRotate, fShearX);
1049
1050 if(fRotate != 0)
1051 {
1052 basegfx::B2DPoint aCenter(0.5, 0.5);
1053 aCenter *= aTransformation;
1054 aTransformation.translate( -aCenter.getX(), -aCenter.getY() );
1055 aTransformation.rotate( fRotate * -2.0 );
1056 aTransformation.translate( aCenter.getX(), aCenter.getY() );
1057 }
1058 }
1059
1060 // special for lineshape
1061 if ( aServiceName == "com.sun.star.drawing.LineShape" )
1062 {
1064 aPoly.insert( 0, ::basegfx::B2DPoint( 0, 0 ) );
1065 aPoly.insert( 1, ::basegfx::B2DPoint( maSize.Width ? 1 : 0, maSize.Height ? 1 : 0 ) );
1066 aPoly.transform( aTransformation );
1067
1068 // now creating the corresponding PolyPolygon
1069 sal_Int32 i, nNumPoints = aPoly.count();
1070 uno::Sequence< awt::Point > aPointSequence( nNumPoints );
1071 awt::Point* pPoints = aPointSequence.getArray();
1072 for( i = 0; i < nNumPoints; ++i )
1073 {
1074 basegfx::B2DPoint aPoint( aPoly.getB2DPoint( i ) );
1075
1076 // Guard against zero width or height.
1077 if (i)
1078 {
1079 const basegfx::B2DPoint& rPreviousPoint = aPoly.getB2DPoint(i - 1);
1080 if (aPoint.getX() - rPreviousPoint.getX() == 0)
1081 aPoint.setX(aPoint.getX() + 1);
1082 if (aPoint.getY() - rPreviousPoint.getY() == 0)
1083 aPoint.setY(aPoint.getY() + 1);
1084 }
1085
1086 pPoints[i] = awt::Point(static_cast<sal_Int32>(aPoint.getX()), static_cast<sal_Int32>(aPoint.getY()));
1087 }
1088 uno::Sequence< uno::Sequence< awt::Point > > aPolyPolySequence( 1 );
1089 aPolyPolySequence.getArray()[ 0 ] = aPointSequence;
1090
1091 maShapeProperties.setProperty(PROP_PolyPolygon, aPolyPolySequence);
1092 }
1093 else if ( aServiceName == "com.sun.star.drawing.ConnectorShape" )
1094 {
1096 aPoly.insert( 0, ::basegfx::B2DPoint( 0, 0 ) );
1097 aPoly.insert( 1, ::basegfx::B2DPoint( maSize.Width ? 1 : 0, maSize.Height ? 1 : 0 ) );
1098 aPoly.transform( aTransformation );
1099
1100 basegfx::B2DPoint aStartPosition( aPoly.getB2DPoint( 0 ) );
1101 basegfx::B2DPoint aEndPosition( aPoly.getB2DPoint( 1 ) );
1102 awt::Point aAWTStartPosition( static_cast< sal_Int32 >( aStartPosition.getX() ), static_cast< sal_Int32 >( aStartPosition.getY() ) );
1103 awt::Point aAWTEndPosition( static_cast< sal_Int32 >( aEndPosition.getX() ), static_cast< sal_Int32 >( aEndPosition.getY() ) );
1104
1105 maShapeProperties.setProperty(PROP_StartPosition, aAWTStartPosition);
1106 maShapeProperties.setProperty(PROP_EndPosition, aAWTEndPosition);
1107 }
1108 else
1109 {
1110 // now set transformation for this object
1111 HomogenMatrix3 aMatrix;
1112
1113 aMatrix.Line1.Column1 = aTransformation.get(0,0);
1114 aMatrix.Line1.Column2 = aTransformation.get(0,1);
1115 aMatrix.Line1.Column3 = aTransformation.get(0,2);
1116
1117 aMatrix.Line2.Column1 = aTransformation.get(1,0);
1118 aMatrix.Line2.Column2 = aTransformation.get(1,1);
1119 aMatrix.Line2.Column3 = aTransformation.get(1,2);
1120
1121 aMatrix.Line3.Column1 = 0;
1122 aMatrix.Line3.Column2 = 0;
1123 aMatrix.Line3.Column3 = 1;
1124
1125 maShapeProperties.setProperty(PROP_Transformation, aMatrix);
1126 }
1127
1128 Reference< lang::XMultiServiceFactory > xServiceFact( rFilterBase.getModel(), UNO_QUERY_THROW );
1129 if ( !mxShape.is() )
1130 {
1131 mxShape.set( xServiceFact->createInstance( aServiceName ), UNO_QUERY_THROW );
1132 }
1133
1134 Reference< XPropertySet > xSet( mxShape, UNO_QUERY );
1135 if (xSet.is())
1136 {
1137 if( !msName.isEmpty() )
1138 {
1139 Reference< container::XNamed > xNamed( mxShape, UNO_QUERY );
1140 if( xNamed.is() )
1141 xNamed->setName( msName );
1142 }
1143 if( !msDescription.isEmpty() )
1144 {
1145 xSet->setPropertyValue( "Description", Any( msDescription ) );
1146 }
1147 if (m_isDecorative)
1148 {
1149 xSet->setPropertyValue("Decorative", Any(m_isDecorative));
1150 }
1151 if (aServiceName != "com.sun.star.text.TextFrame")
1152 rxShapes->add( mxShape );
1153
1155 {
1156 SAL_INFO("oox.drawingml", "Shape::createAndInsert: invisible shape with id='" << msId << "'");
1157 xSet->setPropertyValue( "Visible", Any( false ) );
1158 // In Excel hidden means not printed, let's use visibility for now until that's handled separately
1159 xSet->setPropertyValue( "Printable", Any( false ) );
1160 }
1161
1162 if (mbLocked)
1163 {
1164 xSet->setPropertyValue("MoveProtect", Any(true));
1165 xSet->setPropertyValue("SizeProtect", Any(true));
1166 }
1167
1168 ActionLockGuard const alg(mxShape);
1169
1170 // sj: removing default text of placeholder objects such as SlideNumberShape or HeaderShape
1171 if ( bClearText )
1172 {
1173 uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY );
1174 if ( xText.is() )
1175 {
1176 xText->setString( "" );
1177 }
1178 }
1179
1180 if (pMathXml)
1181 {
1182 // the "EmbeddedObject" property is read-only, so we have to create
1183 // the shape first, and it can be read only after the shape is
1184 // inserted into the document, so delay the actual import until here
1186 xSet->setPropertyValue("CLSID", uno::Any(name.GetHexName()));
1187 uno::Reference<embed::XEmbeddedObject> const xObj(
1188 xSet->getPropertyValue("EmbeddedObject"), uno::UNO_QUERY);
1189 if (xObj.is())
1190 {
1191 uno::Reference<uno::XInterface> const xMathModel(xObj->getComponent());
1192 oox::FormulaImExportBase *const pMagic(
1193 dynamic_cast<oox::FormulaImExportBase*>(xMathModel.get()));
1194 assert(pMagic);
1195 pMagic->readFormulaOoxml(*pMathXml);
1196 }
1197 }
1198
1199 const GraphicHelper& rGraphicHelper = rFilterBase.getGraphicHelper();
1200
1201 ::Color nLinePhClr(ColorTransparency, 0xffffffff);
1202 ::Color nFillPhClr(ColorTransparency, 0xffffffff);
1203 sal_Int16 nFillPhClrTheme = -1;
1204 sal_Int16 nLinePhClrTheme = -1;
1205 // TODO: use ph color when applying effect properties
1206 //sal_Int32 nEffectPhClr = -1;
1207
1208 // dmapper needs the original rotation angle for calculating square wrap. This angle is not
1209 // available as property there, so store it in InteropGrabBag.
1210 putPropertyToGrabBag("mso-rotation-angle", Any(mnRotation));
1211
1212 if( pTheme )
1213 {
1214 if( const ShapeStyleRef* pLineRef = getShapeStyleRef( XML_lnRef ) )
1215 {
1216 LineProperties aLineProperties;
1217 aLineProperties.maLineFill.moFillType = XML_noFill;
1218 if( const LineProperties* pLineProps = pTheme->getLineStyle( pLineRef->mnThemedIdx ) )
1219 aLineProperties.assignUsed( *pLineProps );
1220 nLinePhClr = pLineRef->maPhClr.getColor( rGraphicHelper );
1221 nLinePhClrTheme = pLineRef->maPhClr.getSchemeColorIndex();
1222
1223 // Store style-related properties to InteropGrabBag to be able to export them back
1224 uno::Sequence<beans::PropertyValue> aProperties = comphelper::InitPropertySequence(
1225 {
1226 {"SchemeClr", uno::Any(pLineRef->maPhClr.getSchemeColorName())},
1227 {"Idx", uno::Any(pLineRef->mnThemedIdx)},
1228 {"Color", uno::Any(nLinePhClr)},
1229 {"LineStyle", uno::Any(aLineProperties.getLineStyle())},
1230 {"LineCap", uno::Any(aLineProperties.getLineCap())},
1231 {"LineJoint", uno::Any(aLineProperties.getLineJoint())},
1232 {"LineWidth", uno::Any(aLineProperties.getLineWidth())},
1233 {"Transformations", uno::Any(pLineRef->maPhClr.getTransformations())}
1234 });
1235 putPropertyToGrabBag( "StyleLnRef", Any( aProperties ) );
1236 }
1237 if( const ShapeStyleRef* pFillRef = getShapeStyleRef( XML_fillRef ) )
1238 {
1239 if (!getFillProperties().moUseBgFill.value_or(false))
1240 {
1241 nFillPhClr = pFillRef->maPhClr.getColor(rGraphicHelper);
1242 nFillPhClrTheme = pFillRef->maPhClr.getSchemeColorIndex();
1243 }
1244
1245 OUString sColorScheme = pFillRef->maPhClr.getSchemeColorName();
1246 if( !sColorScheme.isEmpty() )
1247 {
1248 uno::Sequence<beans::PropertyValue> aProperties = comphelper::InitPropertySequence(
1249 {
1250 {"SchemeClr", uno::Any(sColorScheme)},
1251 {"Idx", uno::Any(pFillRef->mnThemedIdx)},
1252 {"Color", uno::Any(nFillPhClr)},
1253 {"Transformations", uno::Any(pFillRef->maPhClr.getTransformations())}
1254 });
1255
1256 putPropertyToGrabBag( "StyleFillRef", Any( aProperties ) );
1257 }
1258 }
1259 if( const ShapeStyleRef* pEffectRef = getShapeStyleRef( XML_effectRef ) )
1260 {
1261 // TODO: use ph color when applying effect properties
1262 // nEffectPhClr = pEffectRef->maPhClr.getColor( rGraphicHelper );
1263
1264 // Store style-related properties to InteropGrabBag to be able to export them back
1265 uno::Sequence<beans::PropertyValue> aProperties = comphelper::InitPropertySequence(
1266 {
1267 {"SchemeClr", uno::Any(pEffectRef->maPhClr.getSchemeColorName())},
1268 {"Idx", uno::Any(pEffectRef->mnThemedIdx)},
1269 {"Transformations", uno::Any(pEffectRef->maPhClr.getTransformations())}
1270 });
1271 putPropertyToGrabBag( "StyleEffectRef", Any( aProperties ) );
1272 }
1273 }
1274 ShapePropertyMap aShapeProps( rFilterBase.getModelObjectHelper() );
1275
1276 // add properties from textbody to shape properties
1277 if( mpTextBody )
1278 {
1279 mpTextBody->getTextProperties().pushTextDistances(Size(aShapeRectHmm.Width, aShapeRectHmm.Height));
1280 aShapeProps.assignUsed( mpTextBody->getTextProperties().maPropertyMap );
1281 // Push char properties as well - specifically useful when this is a placeholder
1282 if( mpMasterTextListStyle && mpMasterTextListStyle->getListStyle()[0].getTextCharacterProperties().moHeight.has_value() )
1283 aShapeProps.setProperty(PROP_CharHeight, GetFontHeight( mpMasterTextListStyle->getListStyle()[0].getTextCharacterProperties().moHeight.value() ));
1284 }
1285
1286 // applying properties
1287 aShapeProps.assignUsed( getShapeProperties() );
1288 aShapeProps.assignUsed( maDefaultShapeProperties );
1289 if(mnRotation != 0 && bIsCustomShape)
1290 aShapeProps.setProperty( PROP_RotateAngle, sal_Int32( NormAngle36000( Degree100(mnRotation / -600) ) ));
1291 if( bIsEmbMedia ||
1292 bIsCustomShape ||
1293 aServiceName == "com.sun.star.drawing.GraphicObjectShape" ||
1294 aServiceName == "com.sun.star.drawing.OLE2Shape")
1295 {
1296 mpGraphicPropertiesPtr->pushToPropMap( aShapeProps, rGraphicHelper, mbFlipH, mbFlipV );
1297 }
1298 if ( mpTablePropertiesPtr && aServiceName == "com.sun.star.drawing.TableShape" )
1299 {
1300 mpTablePropertiesPtr->pushToPropSet( rFilterBase, xSet, mpMasterTextListStyle );
1301 if ( auto* pTableShape = dynamic_cast<sdr::table::SdrTableObj*>(SdrObject::getSdrObjectFromXShape(mxShape)) )
1302 {
1303 // Disable layouting until table height is expanded to fit the content
1304 pTableShape->SetSkipChangeLayout(true);
1305 }
1306 }
1307
1308 FillProperties aFillProperties = getActualFillProperties(pTheme, &rShapeOrParentShapeFillProps);
1309 if (getFillProperties().moFillType.has_value() && getFillProperties().moFillType.value() == XML_grpFill)
1310 getFillProperties().assignUsed(aFillProperties);
1311 if(!bIsCroppedGraphic)
1312 aFillProperties.pushToPropMap(aShapeProps, rGraphicHelper, mnRotation, nFillPhClr,
1313 css::awt::Size(aShapeRectHmm.Width, aShapeRectHmm.Height),
1314 nFillPhClrTheme, mbFlipH, mbFlipV, bIsCustomShape);
1315
1316 LineProperties aLineProperties = getActualLineProperties(pTheme);
1317 aLineProperties.pushToPropMap( aShapeProps, rGraphicHelper, nLinePhClr, nLinePhClrTheme);
1318 EffectProperties aEffectProperties = getActualEffectProperties(pTheme);
1319 // TODO: use ph color when applying effect properties
1320 aEffectProperties.pushToPropMap( aShapeProps, rGraphicHelper );
1321
1322 // applying autogrowheight property before setting shape size, because
1323 // the shape size might be changed if currently autogrowheight is true
1324 // we must also check that the PropertySet supports the property.
1325 Reference< XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() );
1326 const OUString& rPropName = PropertyMap::getPropertyName( PROP_TextAutoGrowHeight );
1327 if( xSetInfo.is() && xSetInfo->hasPropertyByName( rPropName ) )
1328 if( aShapeProps.hasProperty( PROP_TextAutoGrowHeight ) )
1329 xSet->setPropertyValue( rPropName, Any( false ) );
1330
1331 // do not set properties at a group shape (this causes
1332 // assertions from svx) ...
1333 if( aServiceName != "com.sun.star.drawing.GroupShape" )
1334 {
1335 if (aServiceName == "com.sun.star.text.TextFrame")
1336 {
1337 if (mpCustomShapePropertiesPtr && mpCustomShapePropertiesPtr->getShapeTypeOverride())
1338 {
1339 uno::Reference<beans::XPropertySet> propertySet (mxShape, uno::UNO_QUERY);
1340 uno::Sequence<beans::PropertyValue> aGrabBag;
1341 propertySet->getPropertyValue("FrameInteropGrabBag") >>= aGrabBag;
1342 sal_Int32 length = aGrabBag.getLength();
1343 aGrabBag.realloc( length+1);
1344 auto pGrabBag = aGrabBag.getArray();
1345 pGrabBag[length].Name = "mso-orig-shape-type";
1346 uno::Sequence< sal_Int8 > const & aNameSeq =
1347 mpCustomShapePropertiesPtr->getShapePresetTypeName();
1348 OUString sShapePresetTypeName(reinterpret_cast< const char* >(
1349 aNameSeq.getConstArray()), aNameSeq.getLength(), RTL_TEXTENCODING_UTF8);
1350 pGrabBag[length].Value <<= sShapePresetTypeName;
1351 propertySet->setPropertyValue("FrameInteropGrabBag",uno::Any(aGrabBag));
1352 }
1353 //If the text box has links then save the link information so that
1354 //it can be accessed in DomainMapper_Impl.cxx while chaining the text frames.
1355 if (isLinkedTxbx())
1356 {
1357 uno::Reference<beans::XPropertySet> propertySet (mxShape, uno::UNO_QUERY);
1358 uno::Sequence<beans::PropertyValue> aGrabBag;
1359 propertySet->getPropertyValue("FrameInteropGrabBag") >>= aGrabBag;
1360 sal_Int32 length = aGrabBag.getLength();
1361 aGrabBag.realloc( length + 3 );
1362 auto pGrabBag = aGrabBag.getArray();
1363 pGrabBag[length].Name = "TxbxHasLink";
1364 pGrabBag[length].Value <<= isLinkedTxbx();
1365 pGrabBag[length + 1 ].Name = "Txbx-Id";
1366 pGrabBag[length + 1 ].Value <<= getLinkedTxbxAttributes().id;
1367 pGrabBag[length + 2 ].Name = "Txbx-Seq";
1368 pGrabBag[length + 2 ].Value <<= getLinkedTxbxAttributes().seq;
1369 propertySet->setPropertyValue("FrameInteropGrabBag",uno::Any(aGrabBag));
1370 }
1371
1372 // TextFrames have BackColor, not FillColor
1373 if (aShapeProps.hasProperty(PROP_FillColor))
1374 {
1375 aShapeProps.setAnyProperty(PROP_BackColor, aShapeProps.getProperty(PROP_FillColor));
1376 aShapeProps.erase(PROP_FillColor);
1377 }
1378 // TextFrames have BackColorTransparency, not FillTransparence
1379 if (aShapeProps.hasProperty(PROP_FillTransparence))
1380 {
1382 aShapeProps.erase(PROP_FillTransparence);
1383 }
1384 // TextFrames have BackGraphic, not FillBitmap
1385 if (aShapeProps.hasProperty(PROP_FillBitmap))
1386 {
1387 aShapeProps.setAnyProperty(PROP_BackGraphic, aShapeProps.getProperty(PROP_FillBitmap));
1388 aShapeProps.erase(PROP_FillBitmap);
1389 }
1390 if (aShapeProps.hasProperty(PROP_FillBitmapName))
1391 {
1392 uno::Any aAny = aShapeProps.getProperty(PROP_FillBitmapName);
1393 OUString aFillBitmapName = aAny.get<OUString>();
1394 uno::Reference<awt::XBitmap> xBitmap = rFilterBase.getModelObjectHelper().getFillBitmap(aFillBitmapName);
1395 uno::Reference<graphic::XGraphic> xGraphic(xBitmap, uno::UNO_QUERY);
1396 aShapeProps.setProperty(PROP_BackGraphic, xGraphic);
1397 // aShapeProps.erase(PROP_FillBitmapName); // Maybe, leave the name as well
1398 }
1399 // And no LineColor property; individual borders can have colors
1400 if (aShapeProps.hasProperty(PROP_LineColor))
1401 {
1402 uno::Reference<beans::XPropertySet> xPropertySet(mxShape, uno::UNO_QUERY);
1403 static const sal_Int32 aBorders[] =
1404 {
1406 };
1407 for (sal_Int32 nBorder : aBorders)
1408 {
1409 css::table::BorderLine2 aBorderLine = xPropertySet->getPropertyValue(PropertyMap::getPropertyName(nBorder)).get<css::table::BorderLine2>();
1410 aBorderLine.Color = aShapeProps.getProperty(PROP_LineColor).get<sal_Int32>();
1411 if (aLineProperties.moLineWidth.has_value())
1412 aBorderLine.LineWidth = convertEmuToHmm(aLineProperties.moLineWidth.value());
1413 aShapeProps.setProperty(nBorder, aBorderLine);
1414 }
1415 aShapeProps.erase(PROP_LineColor);
1416 }
1417 if(mnRotation)
1418 {
1419 uno::Reference<beans::XPropertySet> xPropertySet(mxShape, uno::UNO_QUERY);
1420 static constexpr OUStringLiteral aGrabBagPropName = u"FrameInteropGrabBag";
1421 uno::Sequence<beans::PropertyValue> aGrabBag;
1422 xPropertySet->getPropertyValue(aGrabBagPropName) >>= aGrabBag;
1423 beans::PropertyValue aPair(comphelper::makePropertyValue("mso-rotation-angle",
1424 mnRotation));
1425 if (aGrabBag.hasElements())
1426 {
1427 sal_Int32 nLength = aGrabBag.getLength();
1428 aGrabBag.realloc(nLength + 1);
1429 aGrabBag.getArray()[nLength] = aPair;
1430 }
1431 else
1432 {
1433 aGrabBag = { aPair };
1434 }
1435 xPropertySet->setPropertyValue(aGrabBagPropName, uno::Any(aGrabBag));
1436 }
1437 // TextFrames have ShadowFormat, not individual shadow properties.
1438 std::optional<sal_Int32> oShadowDistance;
1439 if (aShapeProps.hasProperty(PROP_ShadowXDistance))
1440 {
1441 oShadowDistance = aShapeProps.getProperty(PROP_ShadowXDistance).get<sal_Int32>();
1442 aShapeProps.erase(PROP_ShadowXDistance);
1443 }
1444 if (aShapeProps.hasProperty(PROP_ShadowYDistance))
1445 {
1446 // There is a single 'dist' attribute, so no need to count the avg of x and y.
1447 aShapeProps.erase(PROP_ShadowYDistance);
1448 }
1449 std::optional<sal_Int32> oShadowColor;
1450 if (aShapeProps.hasProperty(PROP_ShadowColor))
1451 {
1452 oShadowColor = aShapeProps.getProperty(PROP_ShadowColor).get<sal_Int32>();
1453 aShapeProps.erase(PROP_ShadowColor);
1454 }
1455 if (aShapeProps.hasProperty(PROP_Shadow))
1456 aShapeProps.erase(PROP_Shadow);
1457
1458 if (oShadowDistance || oShadowColor || aEffectProperties.maShadow.moShadowDir.has_value())
1459 {
1460 css::table::ShadowFormat aFormat;
1461 if (oShadowColor)
1462 aFormat.Color = *oShadowColor;
1463 if (aEffectProperties.maShadow.moShadowDir.has_value())
1464 {
1465 css::table::ShadowLocation nLocation = css::table::ShadowLocation_NONE;
1466 switch (aEffectProperties.maShadow.moShadowDir.value())
1467 {
1468 case 13500000:
1469 nLocation = css::table::ShadowLocation_TOP_LEFT;
1470 break;
1471 case 18900000:
1472 nLocation = css::table::ShadowLocation_TOP_RIGHT;
1473 break;
1474 case 8100000:
1475 nLocation = css::table::ShadowLocation_BOTTOM_LEFT;
1476 break;
1477 case 2700000:
1478 nLocation = css::table::ShadowLocation_BOTTOM_RIGHT;
1479 break;
1480 }
1481 aFormat.Location = nLocation;
1482 }
1483 aFormat.ShadowWidth = *oShadowDistance;
1484 aShapeProps.setProperty(PROP_ShadowFormat, aFormat);
1485 }
1486
1487 }
1488 else if (mbTextBox)
1489 {
1490 // This introduces a TextBox in a shape in Writer. ToDo: Can we restrict it to cases
1491 // where the TextBox edit engine is really needed? tdf#82627
1492 aShapeProps.setProperty(PROP_TextBox, true);
1493 }
1494
1495 if (aServiceName != "com.sun.star.text.TextFrame" && isLinkedTxbx())
1496 {
1497 uno::Reference<beans::XPropertySet> propertySet (mxShape, uno::UNO_QUERY);
1498 uno::Sequence<beans::PropertyValue> aGrabBag;
1499 propertySet->getPropertyValue("InteropGrabBag") >>= aGrabBag;
1500 sal_Int32 length = aGrabBag.getLength();
1501 aGrabBag.realloc( length + 3 );
1502 auto pGrabBag = aGrabBag.getArray();
1503 pGrabBag[length].Name = "TxbxHasLink";
1504 pGrabBag[length].Value <<= isLinkedTxbx();
1505 pGrabBag[length + 1 ].Name = "Txbx-Id";
1506 pGrabBag[length + 1 ].Value <<= getLinkedTxbxAttributes().id;
1507 pGrabBag[length + 2 ].Name = "Txbx-Seq";
1508 pGrabBag[length + 2 ].Value <<= getLinkedTxbxAttributes().seq;
1509 propertySet->setPropertyValue("InteropGrabBag",uno::Any(aGrabBag));
1510 }
1511
1512 // If the shape is a picture placeholder.
1513 if (aServiceName == "com.sun.star.presentation.GraphicObjectShape" && !bClearText)
1514 {
1515 // Placeholder text should be in center of the shape.
1516 aShapeProps.setProperty(PROP_TextContourFrame, false);
1517
1518 /* Placeholder icon should be at the center of the parent shape.
1519 * We use negative graphic crop property because of that we don't
1520 * have padding support.
1521 */
1522 uno::Reference<beans::XPropertySet> xGraphic(xSet->getPropertyValue("Graphic"), uno::UNO_QUERY);
1523 if (xGraphic.is())
1524 {
1525 awt::Size aBitmapSize;
1526 xGraphic->getPropertyValue("Size100thMM") >>= aBitmapSize;
1527 sal_Int32 nXMargin = (aShapeRectHmm.Width - aBitmapSize.Width) / 2;
1528 sal_Int32 nYMargin = (aShapeRectHmm.Height - aBitmapSize.Height) / 2;
1529 if (nXMargin > 0 && nYMargin > 0)
1530 {
1531 text::GraphicCrop aGraphicCrop;
1532 aGraphicCrop.Top = nYMargin * -1;
1533 aGraphicCrop.Bottom = nYMargin * -1;
1534 aGraphicCrop.Left = nXMargin * -1;
1535 aGraphicCrop.Right = nXMargin * -1;
1536 aShapeProps.setProperty(PROP_GraphicCrop, aGraphicCrop);
1537 }
1538 }
1539 }
1540
1541 PropertySet( xSet ).setProperties( aShapeProps );
1542
1543 if (mpTablePropertiesPtr && aServiceName == "com.sun.star.drawing.TableShape")
1544 {
1545 // Powerpoint exports desired row heights (i.e. what user attempted to set it as, not how it appears visually)
1546 // Expand table height if there are rows that can't fit the content
1547 if (auto* pTableShape = dynamic_cast<sdr::table::SdrTableObj*>(SdrObject::getSdrObjectFromXShape(mxShape)))
1548 {
1549 tools::Rectangle aArea{};
1550 pTableShape->LayoutTableHeight(aArea);
1551 sal_Int32 nCorrectedHeight = aArea.GetHeight();
1552 const auto& aShapeSize = mxShape->getSize();
1553 if( nCorrectedHeight > aShapeSize.Height )
1554 mxShape->setSize( {aShapeSize.Width, nCorrectedHeight} );
1555 pTableShape->SetSkipChangeLayout(false);
1556 }
1557 }
1558
1559 if (mbLockedCanvas)
1560 {
1561 putPropertyToGrabBag( "LockedCanvas", Any( true ) );
1562 if (aServiceName == "com.sun.star.drawing.LineShape")
1563 {
1564 // It seems the position and size for lines inside a locked canvas is absolute.
1565 mxShape->setPosition(awt::Point(aShapeRectHmm.X, aShapeRectHmm.Y));
1566 mxShape->setSize(awt::Size(aShapeRectHmm.Width, aShapeRectHmm.Height));
1567 }
1568 }
1569
1570 // Store original fill and line colors of the shape and the theme color name to InteropGrabBag
1571 std::vector<beans::PropertyValue> aProperties
1572 {
1573 comphelper::makePropertyValue("EmuLineWidth", aLineProperties.moLineWidth.value_or(0)),
1574 comphelper::makePropertyValue("OriginalSolidFillClr", aShapeProps.getProperty(PROP_FillColor)),
1575 comphelper::makePropertyValue("OriginalLnSolidFillClr", aShapeProps.getProperty(PROP_LineColor))
1576 };
1577 OUString sColorFillScheme = aFillProperties.maFillColor.getSchemeColorName();
1578 if( !aFillProperties.maFillColor.isPlaceHolder() && !sColorFillScheme.isEmpty() )
1579 {
1580 aProperties.push_back(comphelper::makePropertyValue("SpPrSolidFillSchemeClr", sColorFillScheme));
1581 aProperties.push_back(comphelper::makePropertyValue("SpPrSolidFillSchemeClrTransformations", aFillProperties.maFillColor.getTransformations()));
1582 }
1583 OUString sLnColorFillScheme = aLineProperties.maLineFill.maFillColor.getSchemeColorName();
1584 if( !aLineProperties.maLineFill.maFillColor.isPlaceHolder() && !sLnColorFillScheme.isEmpty() )
1585 {
1586 aProperties.push_back(comphelper::makePropertyValue("SpPrLnSolidFillSchemeClr", sLnColorFillScheme));
1587 auto aResolvedSchemeClr = aLineProperties.maLineFill.maFillColor;
1588 aResolvedSchemeClr.clearTransformations();
1589 aProperties.push_back(comphelper::makePropertyValue("SpPrLnSolidFillResolvedSchemeClr", aResolvedSchemeClr.getColor(rGraphicHelper, nFillPhClr)));
1590 aProperties.push_back(comphelper::makePropertyValue("SpPrLnSolidFillSchemeClrTransformations", aLineProperties.maLineFill.maFillColor.getTransformations()));
1591 }
1593
1594 // Store original gradient fill of the shape to InteropGrabBag
1595 // LibreOffice doesn't support all the kinds of gradient so we save its complete definition
1596 if( aShapeProps.hasProperty( PROP_FillGradient ) )
1597 {
1598 std::vector<beans::PropertyValue> aGradientStops;
1599 size_t i = 0;
1600 for( const auto& [rPos, rColor] : aFillProperties.maGradientProps.maGradientStops )
1601 { // for each stop in the gradient definition:
1602
1603 // save position
1604 std::vector<beans::PropertyValue> aGradientStop
1605 {
1607 };
1608
1609 OUString sStopColorScheme = rColor.getSchemeColorName();
1610 if( sStopColorScheme.isEmpty() )
1611 {
1612 // save RGB color
1613 aGradientStop.push_back(comphelper::makePropertyValue("RgbClr", rColor.getColor(rGraphicHelper, nFillPhClr)));
1614 // in the case of a RGB color, transformations are already applied to
1615 // the color with the exception of alpha transformations. We only need
1616 // to keep the transparency value to calculate the alpha value later.
1617 if( rColor.hasTransparency() )
1618 aGradientStop.push_back(comphelper::makePropertyValue("Transparency", rColor.getTransparency()));
1619 }
1620 else
1621 {
1622 // save color with scheme name
1623 aGradientStop.push_back(comphelper::makePropertyValue("SchemeClr", sStopColorScheme));
1624 // save all color transformations
1625 aGradientStop.push_back(comphelper::makePropertyValue("Transformations", rColor.getTransformations()));
1626 }
1627
1628 aGradientStops.push_back(comphelper::makePropertyValue(OUString::number(i), comphelper::containerToSequence(aGradientStop)));
1629 ++i;
1630 }
1631 // If getFillProperties.moFillType is unused that means gradient is defined by a theme
1632 // which is already saved into StyleFillRef property, so no need to save the explicit values too
1633 if( getFillProperties().moFillType.has_value() )
1634 putPropertyToGrabBag( "GradFillDefinition", uno::Any(comphelper::containerToSequence(aGradientStops)));
1635 putPropertyToGrabBag( "OriginalGradFill", aShapeProps.getProperty(PROP_FillGradient) );
1636 }
1637
1638 // store unsupported effect attributes in the grab bag
1639 if (!aEffectProperties.m_Effects.empty())
1640 {
1641 std::vector<beans::PropertyValue> aEffects;
1642 for (auto const& it : aEffectProperties.m_Effects)
1643 {
1644 PropertyValue aEffect = it->getEffect();
1645 if( !aEffect.Name.isEmpty() )
1646 {
1647 std::vector<beans::PropertyValue> aEffectsGrabBag
1648 {
1649 comphelper::makePropertyValue("Attribs", aEffect.Value)
1650 };
1651
1652 Color& aColor( it->moColor );
1653 OUString sColorScheme = aColor.getSchemeColorName();
1654 if( sColorScheme.isEmpty() )
1655 {
1656 // RGB color and transparency value
1657 aEffectsGrabBag.push_back(comphelper::makePropertyValue("RgbClr", aColor.getColor(rGraphicHelper, nFillPhClr)));
1658 aEffectsGrabBag.push_back(comphelper::makePropertyValue("RgbClrTransparency", aColor.getTransparency()));
1659 }
1660 else
1661 {
1662 // scheme color with name and transformations
1663 aEffectsGrabBag.push_back(comphelper::makePropertyValue("SchemeClr", sColorScheme));
1664 aEffectsGrabBag.push_back(comphelper::makePropertyValue("SchemeClrTransformations", aColor.getTransformations()));
1665 }
1666 aEffects.push_back(comphelper::makePropertyValue(aEffect.Name, comphelper::containerToSequence(aEffectsGrabBag)));
1667 }
1668 }
1669 putPropertyToGrabBag("EffectProperties", uno::Any(comphelper::containerToSequence(aEffects)));
1670 }
1671
1672 // add 3D effects if any
1675 Sequence< PropertyValue > aShape3DEffects = get3DProperties().getShape3DAttributes( rGraphicHelper, nFillPhClr );
1676 if( aCamera3DEffects.hasElements() || aLightRig3DEffects.hasElements() || aShape3DEffects.hasElements() )
1677 {
1678 uno::Sequence<beans::PropertyValue> a3DEffectsGrabBag = comphelper::InitPropertySequence(
1679 {
1680 {"Camera", uno::Any(aCamera3DEffects)},
1681 {"LightRig", uno::Any(aLightRig3DEffects)},
1682 {"Shape3D", uno::Any(aShape3DEffects)}
1683 });
1684 putPropertyToGrabBag( "3DEffectProperties", Any( a3DEffectsGrabBag ) );
1685 }
1686
1687 if( bIsCustomShape && getTextBody())
1688 {
1689
1690 Sequence< PropertyValue > aTextCamera3DEffects = getTextBody()->get3DProperties().getCameraAttributes();
1691 Sequence< PropertyValue > aTextLightRig3DEffects = getTextBody()->get3DProperties().getLightRigAttributes();
1692 Sequence< PropertyValue > aTextShape3DEffects = getTextBody()->get3DProperties().getShape3DAttributes( rGraphicHelper, nFillPhClr );
1693 if( aTextCamera3DEffects.hasElements() || aTextLightRig3DEffects.hasElements() || aTextShape3DEffects.hasElements() )
1694 {
1695 uno::Sequence<beans::PropertyValue> aText3DEffectsGrabBag = comphelper::InitPropertySequence(
1696 {
1697 {"Camera", uno::Any(aTextCamera3DEffects)},
1698 {"LightRig", uno::Any(aTextLightRig3DEffects)},
1699 {"Shape3D", uno::Any(aTextShape3DEffects)}
1700 });
1701 putPropertyToGrabBag( "Text3DEffectProperties", Any( aText3DEffectsGrabBag ) );
1702 }
1703 }
1704
1705 // store bitmap artistic effects in the grab bag
1706 if( !mpGraphicPropertiesPtr->maBlipProps.maEffect.isEmpty() )
1707 putPropertyToGrabBag( "ArtisticEffectProperties",
1708 Any( mpGraphicPropertiesPtr->maBlipProps.maEffect.getEffect() ) );
1709 }
1710
1711 else if( mbLockedCanvas )
1712 {
1713 //If we have aServiceName as "com.sun.star.drawing.GroupShape" and lockedCanvas
1714 putPropertyToGrabBag( "LockedCanvas", Any( true ) );
1715 }
1716
1717 // These can have a custom geometry, so position should be set here,
1718 // after creation but before custom shape handling, using the position
1719 // we got from the caller.
1720 if (mbWps && aServiceName == "com.sun.star.drawing.LineShape" && !pParentGroupShape)
1721 mxShape->setPosition(maPosition);
1722
1723 if (bIsConnectorShape)
1724 {
1725 OUString sConnectorShapePresetTypeName(
1726 reinterpret_cast<const char*>(
1727 mpCustomShapePropertiesPtr->getShapePresetTypeName().getConstArray()),
1728 mpCustomShapePropertiesPtr->getShapePresetTypeName().getLength(),
1729 RTL_TEXTENCODING_UTF8);
1730 msConnectorName = sConnectorShapePresetTypeName;
1731
1732 auto aAdjustmentList = mpCustomShapePropertiesPtr->getAdjustmentGuideList();
1733 for (size_t i = 0; i < aAdjustmentList.size(); i++)
1734 maConnectorAdjustmentList.push_back(aAdjustmentList[i].maFormula);
1735
1736 sal_Int32 nType = mpCustomShapePropertiesPtr->getShapePresetType();
1737 switch (nType)
1738 {
1739 case XML_line:
1740 case XML_straightConnector1:
1741 xSet->setPropertyValue("EdgeKind", Any(ConnectorType_LINE));
1742 break;
1743 case XML_bentConnector2:
1744 case XML_bentConnector3:
1745 case XML_bentConnector4:
1746 case XML_bentConnector5:
1747 xSet->setPropertyValue("EdgeKind", Any(ConnectorType_STANDARD));
1748 break;
1749 case XML_curvedConnector2:
1750 case XML_curvedConnector3:
1751 case XML_curvedConnector4:
1752 case XML_curvedConnector5:
1753 xSet->setPropertyValue("EdgeKind", Any(ConnectorType_CURVE));
1754 break;
1755 default:
1756 break;
1757 }
1758 }
1759
1760 if( bIsCustomShape )
1761 {
1762 if ( mbFlipH )
1763 mpCustomShapePropertiesPtr->setMirroredX( true );
1764 if ( mbFlipV )
1765 mpCustomShapePropertiesPtr->setMirroredY( true );
1766 if( getTextBody() )
1767 {
1768 sal_Int32 nTextCameraZRotation = getTextBody()->get3DProperties().maCameraRotation.mnRevolution.value_or(0);
1769 mpCustomShapePropertiesPtr->setTextCameraZRotateAngle( nTextCameraZRotation / 60000 );
1770
1771 // TextPreRotateAngle. Text rotates inside the text area. Might be used for diagram layout 'upr' and 'grav'.
1772 sal_Int32 nTextPreRotateAngle = static_cast< sal_Int32 >( getTextBody()->getTextProperties().moTextPreRotation.value_or( 0 ) );
1773
1774 nTextPreRotateAngle -= mnDiagramRotation; // Use of mnDiagramRotation is unclear. It seems to be always 0 here.
1775
1776 // TextRotateAngle. The text area rotates.
1777 sal_Int32 nTextAreaRotateAngle = getTextBody()->getTextProperties().moTextAreaRotation.value_or(0);
1778 if (getTextBody()->getTextProperties().moUpright)
1779 {
1780 // When upright is set, any text area transformation and shape rotation is ignored
1781 // in MS Office. To simulate this behaviour, we rotate the text area into the
1782 // opposite direction of the shape rotation by as much as the shape was rotated
1783 // and so compensate the shape rotation, which is added in rendering.
1784 nTextAreaRotateAngle = -mnRotation;
1785 // If 45° <= shape rotation < 135° or 225° <= shape rotation < 315°,
1786 // then MS Office adds an additional 90° rotation to the text area.
1787 const sal_Int32 nDeg(mnRotation / 60000);
1788 if ((nDeg >= 45 && nDeg < 135) || (nDeg >= 225 && nDeg < 315))
1789 {
1790 nTextAreaRotateAngle += 5400000;
1791 nTextPreRotateAngle -= 5400000; // compensate the additional text area rotation
1792 }
1793 putPropertyToGrabBag("Upright", Any(true));
1794 }
1795 /* OOX measures text rotation clockwise in 1/60000th degrees,
1796 relative to the containing shape. set*Angle wants degrees counter-clockwise. */
1797 mpCustomShapePropertiesPtr->setTextPreRotateAngle(-nTextPreRotateAngle / 60000);
1798 if (nTextAreaRotateAngle != 0)
1799 mpCustomShapePropertiesPtr->setTextAreaRotateAngle(-nTextAreaRotateAngle / 60000);
1800
1801 auto sHorzOverflow = getTextBody()->getTextProperties().msHorzOverflow;
1802 if (!sHorzOverflow.isEmpty())
1803 putPropertyToGrabBag("horzOverflow", uno::Any(getTextBody()->getTextProperties().msHorzOverflow));
1804 if (XML_ellipsis == getTextBody()->getTextProperties().moVertOverflow)
1805 putPropertyToGrabBag("vertOverflow", uno::Any(OUString{"ellipsis"}));
1806 }
1807
1808 // Note that the script oox/source/drawingml/customshapes/generatePresetsData.pl looks
1809 // for these ==cscode== and ==csdata== markers, so don't "clean up" these SAL_INFOs
1810 SAL_INFO("oox.cscode", "==cscode== shape name: '" << msName << "'");
1811 SAL_INFO("oox.csdata", "==csdata== shape name: '" << msName << "'");
1812
1813 mpCustomShapePropertiesPtr->pushToPropSet(xSet, maSize);
1814
1815 // Consider WordArt
1816 if (mpTextBody && !mpTextBody->getTextProperties().msPrst.isEmpty()
1817 && mpTextBody->getTextProperties().msPrst != u"textNoShape")
1818 {
1819 bool bFromWordArt(aShapeProps.hasProperty(PROP_FromWordArt)
1820 ? aShapeProps.getProperty(PROP_FromWordArt).get<bool>()
1821 : false);
1823 mxShape, mpCustomShapePropertiesPtr, mpTextBody->getTextProperties().msPrst,
1824 bFromWordArt);
1825 }
1826 }
1827 else if( getTextBody() )
1828 getTextBody()->getTextProperties().pushVertSimulation();
1829
1830 // tdf#133037: a bit hackish: force Shape to rotate in the opposite direction the camera would rotate
1831 PropertySet aPropertySet(mxShape);
1832 if ( !bUseRotationTransform && (mnRotation != 0 || nCameraRotation != 0) )
1833 {
1834 // use the same logic for rotation from VML exporter (SimpleShape::implConvertAndInsert at vmlshape.cxx)
1835 Degree100 nAngle = NormAngle36000( Degree100((mnRotation - nCameraRotation) / -600) );
1836 aPropertySet.setAnyProperty( PROP_RotateAngle, Any( sal_Int32( nAngle.get() ) ) );
1839 }
1840
1841 // in some cases, we don't have any text body.
1842 if( mpTextBody && ( !bDoNotInsertEmptyTextBody || !mpTextBody->isEmpty() ) )
1843 {
1844 Reference < XText > xText( mxShape, UNO_QUERY );
1845 if ( xText.is() ) // not every shape is supporting an XText interface (e.g. GroupShape)
1846 {
1847 TextCharacterProperties aCharStyleProperties;
1848 if( const ShapeStyleRef* pFontRef = getShapeStyleRef( XML_fontRef ) )
1849 {
1850 if( pFontRef->mnThemedIdx != 0 )
1851 {
1852 if( pTheme )
1853 if( const TextCharacterProperties* pCharProps = pTheme->getFontStyle( pFontRef->mnThemedIdx ) )
1854 aCharStyleProperties.assignUsed( *pCharProps );
1855 SAL_INFO("oox.drawingml", "Shape::createAndInsert: use font color");
1856 if ( pFontRef->maPhClr.isUsed() )
1857 {
1858 aCharStyleProperties.maFillProperties.maFillColor = pFontRef->maPhClr;
1859 aCharStyleProperties.maFillProperties.moFillType = XML_solidFill;
1860 }
1861 }
1862 }
1863 xText->setString("");
1864 Reference < XTextCursor > xAt = xText->createTextCursor();
1865 getTextBody()->insertAt( rFilterBase, xText, xAt, aCharStyleProperties, mpMasterTextListStyle );
1866
1867 const TextParagraphVector& rParagraphs = getTextBody()->getParagraphs();
1868 if (!rParagraphs.empty())
1869 {
1870 const std::shared_ptr<TextParagraph>& pParagraph = rParagraphs[0];
1871 if (pParagraph->getProperties().getParaAdjust())
1872 {
1873 style::ParagraphAdjust eAdjust = *pParagraph->getProperties().getParaAdjust();
1874 if (eAdjust == style::ParagraphAdjust_CENTER)
1875 {
1876 // If the first paragraph is centered, then set the para adjustment of
1877 // the shape itself to centered as well.
1878 aPropertySet.setAnyProperty(PROP_ParaAdjust, uno::Any(eAdjust));
1879 }
1880 }
1881
1882 // tdf#144092 For empty textboxes push character styles &
1883 // endParaRPr into the Shape's properties
1884 if (rParagraphs.size() == 1 && pParagraph->getRuns().empty())
1885 {
1886 TextCharacterProperties aTextCharacterProps{ pParagraph->getCharacterStyle(
1887 aCharStyleProperties, *mpMasterTextListStyle,
1888 getTextBody()->getTextListStyle()) };
1889 aTextCharacterProps.assignUsed(pParagraph->getEndProperties());
1890 aTextCharacterProps.pushToPropSet(aPropertySet, rFilterBase);
1891 }
1892 }
1893
1894 // MS Office has e.g. fill and stroke of WordArt in the character properties,
1895 // LibreOffice uses shape properties.
1896 if (!mpTextBody->getTextProperties().msPrst.isEmpty()
1897 && mpTextBody->getTextProperties().msPrst != u"textNoShape")
1898 {
1900 }
1901 }
1902 }
1903 else if (mbTextBox)
1904 {
1905 // No drawingML text, but WPS text is expected: save the theme
1906 // character color on the shape, then.
1907 if(const ShapeStyleRef* pFontRef = getShapeStyleRef(XML_fontRef))
1908 {
1909 ::Color nCharColor = pFontRef->maPhClr.getColor(rGraphicHelper);
1910 aPropertySet.setAnyProperty(PROP_CharColor, uno::Any(nCharColor));
1911 }
1912 }
1913
1914 // Set glow effect properties
1915 if ( aEffectProperties.maGlow.moGlowRad.has_value() )
1916 {
1917 uno::Reference<beans::XPropertySet> propertySet (mxShape, uno::UNO_QUERY);
1918 propertySet->setPropertyValue("GlowEffectRadius", Any(convertEmuToHmm(aEffectProperties.maGlow.moGlowRad.value())));
1919 propertySet->setPropertyValue("GlowEffectColor", Any(aEffectProperties.maGlow.moGlowColor.getColor(rGraphicHelper)));
1920 propertySet->setPropertyValue("GlowEffectTransparency", Any(aEffectProperties.maGlow.moGlowColor.getTransparency()));
1921 }
1922
1923 // Set soft edge effect properties
1924 if (aEffectProperties.maSoftEdge.moRad.has_value())
1925 {
1926 uno::Reference<beans::XPropertySet> propertySet(mxShape, uno::UNO_QUERY);
1927 propertySet->setPropertyValue(
1928 "SoftEdgeRadius", Any(convertEmuToHmm(aEffectProperties.maSoftEdge.moRad.value())));
1929 }
1930
1931 // Set the stroke and fill-color properties of the OLE shape
1932 if (aServiceName == "com.sun.star.drawing.OLE2Shape" && mxOleObjectInfo
1933 && !mxOleObjectInfo->maShapeId.isEmpty())
1934 if (::oox::vml::Drawing* pVmlDrawing = rFilterBase.getVmlDrawing())
1935 if (const ::oox::vml::ShapeBase* pVmlShape
1936 = pVmlDrawing->getShapes().getShapeById(mxOleObjectInfo->maShapeId))
1937 {
1938 // Apply stroke props from the type model of the related VML shape.
1939 ShapePropertyMap aPropMap(rFilterBase.getModelObjectHelper());
1940 pVmlShape->getTypeModel().maStrokeModel.pushToPropMap(
1941 aPropMap, rFilterBase.getGraphicHelper());
1942 // And, fill-color properties as well...
1943 pVmlShape->getTypeModel().maFillModel.pushToPropMap(
1944 aPropMap, rFilterBase.getGraphicHelper());
1945 PropertySet(xSet).setProperties(aPropMap);
1946 }
1947 }
1948
1949 if (mxShape.is())
1950 {
1951 finalizeXShape( rFilterBase, rxShapes );
1952
1953 if (mpTextBody)
1954 {
1955 // tdf#151518. The method readjustTextDistances is fix for tdf#148321, but conflicts with
1956 // text position in some of the SmartArt types in Writer. So exclude Writer here.
1957 OUString sDocumentService;
1959 if (sDocumentService != u"com.sun.star.text.TextDocument")
1960 mpTextBody->getTextProperties().readjustTextDistances(mxShape);
1961 }
1962 }
1963 return mxShape;
1964}
1965
1966void Shape::keepDiagramDrawing(XmlFilterBase& rFilterBase, const OUString& rFragmentPath)
1967{
1968
1969 sal_Int32 length = maDiagramDoms.getLength();
1970 maDiagramDoms.realloc(length + 1);
1971
1972 // drawingValue[0] => dom, drawingValue[1] => Sequence of associated relationships
1973 uno::Sequence<uno::Any> diagramDrawing{
1974 uno::Any(rFilterBase.importFragment(rFragmentPath)),
1975 uno::Any(resolveRelationshipsOfTypeFromOfficeDoc(rFilterBase, rFragmentPath, u"image"))
1976 };
1977
1978 beans::PropertyValue* pValue = maDiagramDoms.getArray();
1979 pValue[length].Name = "OOXDrawing";
1980 pValue[length].Value <<= diagramDrawing;
1981}
1982
1984{
1985 try
1986 {
1987 if( !maDiagramDoms.hasElements() )
1988 return;
1989
1990 Reference < XPropertySet > xSet( mxShape, UNO_QUERY_THROW );
1991 Reference < XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() );
1992 if ( !xSetInfo.is() )
1993 return;
1994
1995 const OUString aGrabBagPropName = UNO_NAME_MISC_OBJ_INTEROPGRABBAG;
1996 if( !xSetInfo->hasPropertyByName( aGrabBagPropName ) )
1997 return;
1998
2000 xSet->getPropertyValue( aGrabBagPropName ) >>= aGrabBag;
2001
2002 // We keep the previous items, if present
2003 if ( aGrabBag.hasElements() )
2004 xSet->setPropertyValue( aGrabBagPropName, Any( comphelper::concatSequences(aGrabBag, maDiagramDoms) ) );
2005 else
2006 xSet->setPropertyValue( aGrabBagPropName, Any( maDiagramDoms ) );
2007 }
2008 catch( const Exception& )
2009 {
2010 TOOLS_WARN_EXCEPTION( "oox.drawingml", "Shape::keepDiagramCompatibilityInfo" );
2011 }
2012}
2013
2015{
2016 try
2017 {
2018 Reference<XPropertySet> xSet(mxShape, UNO_QUERY_THROW);
2019
2020 xSet->setPropertyValue("MoveProtect", Any(true));
2021 xSet->setPropertyValue("SizeProtect", Any(true));
2022
2023 // Replace existing shapes with a new Graphic Object rendered
2024 // from them
2025 Reference<XShape> xShape(renderDiagramToGraphic(rFilterBase));
2026 Reference<XShapes> xShapes(mxShape, UNO_QUERY_THROW);
2027 tools::Rectangle aBackgroundRect
2029 Reference<XShape>(xShapes->getByIndex(0), UNO_QUERY_THROW))
2030 ->GetLogicRect();
2031 while (xShapes->hasElements())
2032 xShapes->remove(Reference<XShape>(xShapes->getByIndex(0), UNO_QUERY_THROW));
2033 xShapes->add(xShape);
2035 Reference<XShape>(xShapes->getByIndex(0), UNO_QUERY_THROW))
2036 ->NbcSetLogicRect(aBackgroundRect);
2037 }
2038 catch (const Exception&)
2039 {
2040 TOOLS_WARN_EXCEPTION("oox.drawingml", "Shape::convertSmartArtToMetafile");
2041 }
2042}
2043
2045{
2046 Reference< XShape > xShape;
2047
2048 try
2049 {
2050 if( !maDiagramDoms.hasElements() )
2051 return xShape;
2052
2053 // Stream in which to place the rendered shape
2054 SvMemoryStream aTempStream;
2056 Reference < io::XOutputStream > xOutputStream( xStream->getOutputStream() );
2057
2058 // Size of the rendering
2059 awt::Size aActualSize = mxShape->getSize();
2060 Size aResolution(Application::GetDefaultDevice()->LogicToPixel(Size(100, 100), MapMode(MapUnit::MapCM)));
2061 double fPixelsPer100thmm = static_cast < double > ( aResolution.Width() ) / 100000.0;
2062 awt::Size aSize( static_cast < sal_Int32 > ( ( fPixelsPer100thmm * aActualSize.Width ) + 0.5 ),
2063 static_cast < sal_Int32 > ( ( fPixelsPer100thmm * aActualSize.Height ) + 0.5 ) );
2064
2065 Sequence< PropertyValue > aFilterData{
2066 comphelper::makePropertyValue("PixelWidth", aSize.Width),
2067 comphelper::makePropertyValue("PixelHeight", aSize.Height),
2068 comphelper::makePropertyValue("LogicalWidth", aActualSize.Width),
2069 comphelper::makePropertyValue("LogicalHeight", aActualSize.Height)
2070 };
2071
2072 Sequence < PropertyValue > aDescriptor{
2073 comphelper::makePropertyValue("OutputStream", xOutputStream),
2074 comphelper::makePropertyValue("FilterName", OUString("SVM")), // Rendering format
2075 comphelper::makePropertyValue("FilterData", aFilterData)
2076 };
2077
2078 Reference < lang::XComponent > xSourceDoc( mxShape, UNO_QUERY_THROW );
2079 Reference < XGraphicExportFilter > xGraphicExporter = GraphicExportFilter::create( rFilterBase.getComponentContext() );
2080 xGraphicExporter->setSourceDocument( xSourceDoc );
2081 xGraphicExporter->filter( aDescriptor );
2082
2083 aTempStream.Seek( STREAM_SEEK_TO_BEGIN );
2084
2085 Graphic aGraphic;
2086 GraphicFilter aFilter( false );
2087 if ( aFilter.ImportGraphic( aGraphic, u"", aTempStream, GRFILTER_FORMAT_NOTFOUND, nullptr, GraphicFilterImportFlags::NONE ) != ERRCODE_NONE )
2088 {
2089 SAL_WARN( "oox.drawingml", "Shape::renderDiagramToGraphic: Unable to import rendered stream into graphic object" );
2090 return xShape;
2091 }
2092
2093 Reference < graphic::XGraphic > xGraphic( aGraphic.GetXGraphic() );
2094 Reference < lang::XMultiServiceFactory > xServiceFact( rFilterBase.getModel(), UNO_QUERY_THROW );
2095 xShape.set( xServiceFact->createInstance( "com.sun.star.drawing.GraphicObjectShape" ), UNO_QUERY_THROW );
2096 Reference < XPropertySet > xPropSet( xShape, UNO_QUERY_THROW );
2097 xPropSet->setPropertyValue( "Graphic", Any( xGraphic ) );
2098 xPropSet->setPropertyValue( "MoveProtect", Any( true ) );
2099 xPropSet->setPropertyValue( "SizeProtect", Any( true ) );
2100 xPropSet->setPropertyValue( "Name", Any( OUString( "RenderedShapes" ) ) );
2101 }
2102 catch( const Exception& )
2103 {
2104 TOOLS_WARN_EXCEPTION( "oox.drawingml", "Shape::renderDiagramToGraphic" );
2105 }
2106
2107 return xShape;
2108}
2109
2110void Shape::setTextBody(const TextBodyPtr & pTextBody)
2111{
2112 mpTextBody = pTextBody;
2113}
2114
2115void Shape::setMasterTextListStyle( const TextListStylePtr& pMasterTextListStyle )
2116{
2117 SAL_INFO("oox.drawingml", "Shape::setMasterTextListStyle: Set master text list style to shape id='" << msId << "'");
2118
2119 mpMasterTextListStyle = pMasterTextListStyle;
2120}
2121
2122OUString Shape::finalizeServiceName( XmlFilterBase& rFilter, const OUString& rServiceName, const awt::Rectangle& rShapeRect )
2123{
2124 OUString aServiceName = rServiceName;
2125 switch( meFrameType )
2126 {
2128 {
2129 awt::Size aOleSize( rShapeRect.Width, rShapeRect.Height );
2131 aServiceName = "com.sun.star.drawing.OLE2Shape";
2132
2133 // get the path to the representation graphic
2134 OUString aGraphicPath;
2135 if( !mxOleObjectInfo->maShapeId.isEmpty() )
2136 if( ::oox::vml::Drawing* pVmlDrawing = rFilter.getVmlDrawing() )
2137 if( const ::oox::vml::ShapeBase* pVmlShape = pVmlDrawing->getShapes().getShapeById( mxOleObjectInfo->maShapeId ) )
2138 aGraphicPath = pVmlShape->getGraphicPath();
2139
2140 // import and store the graphic
2141 if( !aGraphicPath.isEmpty() )
2142 {
2143 // Transfer shape's width and height to graphicsfilter (can be used by WMF/EMF)
2144 WmfExternal aExtHeader;
2145 aExtHeader.mapMode = 8; // MM_ANISOTROPIC
2146 aExtHeader.xExt = rShapeRect.Width;
2147 aExtHeader.yExt = rShapeRect.Height;
2148
2149 Reference< graphic::XGraphic > xGraphic = rFilter.getGraphicHelper().importEmbeddedGraphic( aGraphicPath, &aExtHeader );
2150 if( xGraphic.is() )
2151 maShapeProperties.setProperty(PROP_Graphic, xGraphic);
2152 }
2153 }
2154 break;
2155
2156 default:;
2157 }
2158 return aServiceName;
2159}
2160
2161void Shape::finalizeXShape( XmlFilterBase& rFilter, const Reference< XShapes >& rxShapes )
2162{
2163 switch( meFrameType )
2164 {
2165 case FRAMETYPE_CHART:
2166 {
2167 OSL_ENSURE( !mxChartShapeInfo->maFragmentPath.isEmpty(), "Shape::finalizeXShape - missing chart fragment" );
2168 if( mxShape.is() && !mxChartShapeInfo->maFragmentPath.isEmpty() ) try
2169 {
2170 // set the chart2 OLE class ID at the OLE shape
2171 PropertySet aShapeProp( mxShape );
2172 aShapeProp.setProperty( PROP_CLSID, OUString( "12dcae26-281f-416f-a234-c3086127382e" ) );
2173
2174 // get the XModel interface of the embedded object from the OLE shape
2176 aShapeProp.getProperty( xDocModel, PROP_Model );
2177 Reference< chart2::XChartDocument > xChartDoc( xDocModel, UNO_QUERY_THROW );
2178
2179 // load the chart data from the XML fragment
2180#if ENABLE_WASM_STRIP_CHART
2181 (void) rFilter;
2182 (void) rxShapes;
2183#else
2184 // WASM_CHART change
2185 // TODO: Instead of using convertFromModel an alternative may be
2186 // added to convert not to Chart/OLE SdrObejct, but to GraphicObject
2187 // with the Chart visualization. There should be a preview available
2188 // in the imported chart data
2189 bool bMSO2007Doc = rFilter.isMSO2007Document();
2190 chart::ChartSpaceModel aModel(bMSO2007Doc);
2192 rFilter, mxChartShapeInfo->maFragmentPath, aModel );
2193 const OUString aThemeOverrideFragmentPath( pChartSpaceFragment->
2194 getFragmentPathFromFirstTypeFromOfficeDoc(u"themeOverride") );
2195 rFilter.importFragment( pChartSpaceFragment );
2196 ::oox::ppt::PowerPointImport *pPowerPointImport =
2197 dynamic_cast< ::oox::ppt::PowerPointImport* >(&rFilter);
2198
2199 // The original theme.
2200 ThemePtr pTheme;
2201
2202 if (!aThemeOverrideFragmentPath.isEmpty() && pPowerPointImport)
2203 {
2204 // Handle theme override.
2205 uno::Reference< xml::sax::XFastSAXSerializable > xDoc(
2206 rFilter.importFragment(aThemeOverrideFragmentPath), uno::UNO_QUERY_THROW);
2207 pTheme = pPowerPointImport->getActualSlidePersist()->getTheme();
2208 auto pThemeOverride = std::make_shared<Theme>(*pTheme);
2209 rFilter.importFragment(
2210 new ThemeOverrideFragmentHandler(rFilter, aThemeOverrideFragmentPath, *pThemeOverride, *pThemeOverride->getTheme()),
2211 xDoc);
2212 pPowerPointImport->getActualSlidePersist()->setTheme(pThemeOverride);
2213 }
2214
2215 // convert imported chart model to chart document
2216 Reference< drawing::XShapes > xExternalPage;
2217 if( !mxChartShapeInfo->mbEmbedShapes )
2218 xExternalPage = rxShapes;
2219 if( rFilter.getChartConverter() )
2220 {
2221 rFilter.getChartConverter()->convertFromModel( rFilter, aModel, xChartDoc, xExternalPage, mxShape->getPosition(), mxShape->getSize() );
2222 if( !xChartDoc->hasInternalDataProvider() )
2223 {
2224 Reference< chart2::data::XDataReceiver > xDataRec( xChartDoc, UNO_QUERY );
2225 Reference< chart2::data::XDataSource > xData = xDataRec->getUsedData();
2226 if( !xData->getDataSequences().hasElements() || !xData->getDataSequences()[0]->getValues().is() ||
2227 !xData->getDataSequences()[0]->getValues()->getData().hasElements() )
2228 {
2229 rFilter.useInternalChartDataTable( true );
2230 rFilter.getChartConverter()->convertFromModel( rFilter, aModel, xChartDoc, xExternalPage, mxShape->getPosition(), mxShape->getSize() );
2231 rFilter.useInternalChartDataTable( false );
2232 }
2233 }
2234
2235 }
2236
2237 if (!aThemeOverrideFragmentPath.isEmpty() && pPowerPointImport)
2238 {
2239 // Restore the original theme.
2240 pPowerPointImport->getActualSlidePersist()->setTheme(pTheme);
2241 }
2242#endif
2243 }
2244 catch( Exception& )
2245 {
2246 }
2247 }
2248 break;
2249
2250 default:;
2251 }
2252}
2253
2254void Shape::putPropertyToGrabBag( const OUString& sPropertyName, const Any& aPropertyValue )
2255{
2256 PropertyValue aNewProperty;
2257 aNewProperty.Name = sPropertyName;
2258 aNewProperty.Value = aPropertyValue;
2259 putPropertyToGrabBag( aNewProperty );
2260}
2261
2262void Shape::putPropertyToGrabBag( const PropertyValue& pProperty )
2263{
2264 Reference< XPropertySet > xSet( mxShape, UNO_QUERY );
2265 Reference< XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() );
2266 const OUString aGrabBagPropName = UNO_NAME_MISC_OBJ_INTEROPGRABBAG;
2267 if( mxShape.is() && xSet.is() && xSetInfo.is() && xSetInfo->hasPropertyByName( aGrabBagPropName ) )
2268 {
2269 Sequence< PropertyValue > aGrabBag;
2270 xSet->getPropertyValue( aGrabBagPropName ) >>= aGrabBag;
2271
2272 sal_Int32 length = aGrabBag.getLength();
2273 aGrabBag.realloc( length + 1 );
2274 aGrabBag.getArray()[length] = pProperty;
2275
2276 xSet->setPropertyValue( aGrabBagPropName, Any( aGrabBag ) );
2277 }
2278}
2279
2281{
2282 Reference< XPropertySet > xSet( mxShape, UNO_QUERY );
2283 Reference< XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() );
2284 const OUString aGrabBagPropName = UNO_NAME_MISC_OBJ_INTEROPGRABBAG;
2285 if( !(mxShape.is() && xSet.is() && xSetInfo.is() && xSetInfo->hasPropertyByName( aGrabBagPropName )) )
2286 return;
2287
2288 // get existing grab bag
2290 xSet->getPropertyValue( aGrabBagPropName ) >>= aGrabBag;
2291
2292 std::vector<PropertyValue> aVec;
2293 aVec.reserve(aProperties.getLength());
2294
2295 // put the new items
2296 std::transform(aProperties.begin(), aProperties.end(), std::back_inserter(aVec),
2297 [](const PropertyValue& rProp) {
2298 PropertyValue aProp;
2299 aProp.Name = rProp.Name;
2300 aProp.Value = rProp.Value;
2301 return aProp;
2302 });
2303
2304 // put it back to the shape
2305 xSet->setPropertyValue( aGrabBagPropName, Any( comphelper::concatSequences(aGrabBag, aVec) ) );
2306}
2307
2308FillProperties Shape::getActualFillProperties(const Theme* pTheme, const FillProperties* pParentShapeFillProps) const
2309{
2310 FillProperties aFillProperties;
2311 aFillProperties.moFillType = XML_noFill;
2312
2313 // Reference shape properties
2314 aFillProperties.assignUsed( *mpShapeRefFillPropPtr );
2315
2316 // Theme
2317 if( pTheme != nullptr )
2318 {
2319 if( const ShapeStyleRef* pFillRef = getShapeStyleRef( XML_fillRef ) )
2320 {
2321 if( const FillProperties* pFillProps = pTheme->getFillStyle( pFillRef->mnThemedIdx ) )
2322 aFillProperties.assignUsed( *pFillProps );
2323 }
2324 }
2325
2326 // Properties specified directly for this shape
2327 aFillProperties.assignUsed(getFillProperties());
2328
2329 // Parent shape's properties
2330 if ( pParentShapeFillProps != nullptr)
2331 if( getFillProperties().moFillType.has_value() && getFillProperties().moFillType.value() == XML_grpFill )
2332 aFillProperties.assignUsed( *pParentShapeFillProps );
2333
2334 return aFillProperties;
2335}
2336
2338{
2339 LineProperties aLineProperties;
2340 aLineProperties.maLineFill.moFillType = XML_noFill;
2341
2342 // Reference shape properties
2343 aLineProperties.assignUsed( *mpShapeRefLinePropPtr );
2344
2345 // Theme
2346 if( pTheme != nullptr )
2347 {
2348 if( const ShapeStyleRef* pLineRef = getShapeStyleRef( XML_lnRef ) )
2349 {
2350 if( const LineProperties* pLineProps = pTheme->getLineStyle( pLineRef->mnThemedIdx ) )
2351 aLineProperties.assignUsed( *pLineProps );
2352 }
2353 }
2354
2355 // Properties specified directly for this shape
2356 aLineProperties.assignUsed( getLineProperties() );
2357
2358 return aLineProperties;
2359}
2360
2362{
2363 EffectProperties aEffectProperties;
2364
2365 // Reference shape properties
2366 aEffectProperties.assignUsed( *mpShapeRefEffectPropPtr );
2367
2368 // Theme
2369 if( pTheme != nullptr )
2370 {
2371 if( const ShapeStyleRef* pEffectRef = getShapeStyleRef( XML_effectRef ) )
2372 {
2373 if( const EffectProperties* pEffectProps = pTheme->getEffectStyle( pEffectRef->mnThemedIdx ) )
2374 aEffectProperties.assignUsed( *pEffectProps );
2375 }
2376 }
2377
2378 // Properties specified directly for this shape
2379 aEffectProperties.assignUsed ( getEffectProperties() );
2380
2381 return aEffectProperties;
2382}
2383
2384uno::Sequence< uno::Sequence< uno::Any > > Shape::resolveRelationshipsOfTypeFromOfficeDoc(core::XmlFilterBase& rFilter, const OUString& sFragment, std::u16string_view sType )
2385{
2386 uno::Sequence< uno::Sequence< uno::Any > > xRelListTemp;
2387 sal_Int32 counter = 0;
2388
2389 core::RelationsRef xRels = rFilter.importRelations( sFragment );
2390 if ( xRels )
2391 {
2392 core::RelationsRef xImageRels = xRels->getRelationsFromTypeFromOfficeDoc( sType );
2393 if ( xImageRels )
2394 {
2395 xRelListTemp.realloc( xImageRels->size() );
2396 auto pxRelListTemp = xRelListTemp.getArray();
2397 for (auto const& imageRel : *xImageRels)
2398 {
2399 uno::Sequence< uno::Any > diagramRelTuple (3);
2400 auto pdiagramRelTuple = diagramRelTuple.getArray();
2401 // [0] => RID, [1] => InputStream [2] => extension
2402 OUString sRelId = imageRel.second.maId;
2403
2404 pdiagramRelTuple[0] <<= sRelId;
2405 OUString sTarget = xImageRels->getFragmentPathFromRelId( sRelId );
2406
2407 uno::Reference< io::XInputStream > xImageInputStrm( rFilter.openInputStream( sTarget ), uno::UNO_SET_THROW );
2408 StreamDataSequence dataSeq;
2409 if ( rFilter.importBinaryData( dataSeq, sTarget ) )
2410 {
2411 pdiagramRelTuple[1] <<= dataSeq;
2412 }
2413
2414 pdiagramRelTuple[2] <<= sTarget.copy( sTarget.lastIndexOf(".") );
2415
2416 pxRelListTemp[counter] = diagramRelTuple;
2417 ++counter;
2418 }
2419 xRelListTemp.realloc(counter);
2420
2421 }
2422 }
2423 return xRelListTemp;
2424}
2425
2427{
2428 auto pFillProperties = std::make_shared<FillProperties>();
2429 pFillProperties->assignUsed(*mpFillPropertiesPtr);
2430 mpFillPropertiesPtr = pFillProperties;
2431}
2432}
2433
2434/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OptionalString sType
geometry::RealPoint2D maPosition
geometry::RealSize2D maSize
PropertiesInfo aProperties
Reference< XInputStream > xStream
constexpr OUStringLiteral sServiceName
constexpr OUStringLiteral sDocumentService
static OutputDevice * GetDefaultDevice()
ErrCode ImportGraphic(Graphic &rGraphic, const INetURLObject &rPath, sal_uInt16 nFormat=GRFILTER_FORMAT_DONTKNOW, sal_uInt16 *pDeterminedFormat=nullptr, GraphicFilterImportFlags nImportFlags=GraphicFilterImportFlags::NONE)
css::uno::Reference< css::graphic::XGraphic > GetXGraphic() const
LanguageType getLanguageType(bool bResolveSystem=true) const
const css::lang::Locale & getLocale(bool bResolveSystem=true) const
static sal_Int16 getScriptType(LanguageType nLang)
static SdrObject * getSdrObjectFromXShape(const css::uno::Reference< css::uno::XInterface > &xInt)
virtual void NbcSetLogicRect(const tools::Rectangle &rRect)
void SetMergedItem(const SfxPoolItem &rItem)
virtual const tools::Rectangle & GetLogicRect() const
constexpr tools::Long Width() const
sal_uInt64 Seek(sal_uInt64 nPos)
static SvtFilterOptions & Get()
bool IsSmartArt2Shape() const
bool decompose(B2DTuple &rScale, B2DTuple &rTranslate, double &rRotate, double &rShearX) const
void set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue)
void rotate(double fRadiant)
void translate(double fX, double fY)
double get(sal_uInt16 nRow, sal_uInt16 nColumn) const
void scale(double fX, double fY)
void insert(sal_uInt32 nIndex, const basegfx::B2DPoint &rPoint, sal_uInt32 nCount=1)
basegfx::B2DPoint const & getB2DPoint(sal_uInt32 nIndex) const
void transform(const basegfx::B2DHomMatrix &rMatrix)
sal_uInt32 count() const
bool equalZero() const
TYPE getX() const
void setY(TYPE fY)
TYPE getY() const
void setX(TYPE fX)
#define SO3_SM_CLASSID
Provides helper functions for colors, device measurement conversion, graphics, and graphic objects ha...
css::uno::Reference< css::graphic::XGraphic > importEmbeddedGraphic(const OUString &rStreamName, const WmfExternal *pExtHeader=nullptr) const
Imports a graphic from the storage stream with the passed path and name.
css::uno::Reference< css::awt::XBitmap > getFillBitmap(OUString const &rGraphicName)
void assignUsed(const PropertyMap &rPropMap)
Inserts all properties contained in the passed property map.
void erase(sal_Int32 nPropId)
css::uno::Any getProperty(sal_Int32 nPropId)
bool hasProperty(sal_Int32 nPropId) const
Returns true, if the map contains a property with the passed identifier.
static const OUString & getPropertyName(sal_Int32 nPropId)
Returns the name of the passed property identifier.
css::uno::Sequence< css::beans::PropertyValue > makePropertyValueSequence() const
Returns a sequence of property values, filled with all contained properties.
bool setProperty(sal_Int32 nPropId, Type &&rValue)
Sets the specified property to the passed value.
Definition: propertymap.hxx:72
A wrapper for a UNO property set.
Definition: propertyset.hxx:58
void setProperties(const css::uno::Sequence< OUString > &rPropNames, const css::uno::Sequence< css::uno::Any > &rValues)
Puts the passed properties into the property set.
bool setAnyProperty(sal_Int32 nPropId, const css::uno::Any &rValue)
Puts the passed any into the property set.
Definition: propertyset.cxx:70
bool importBinaryData(StreamDataSequence &orDataSeq, const OUString &rStreamName)
Imports the raw binary data from the specified stream.
Definition: filterbase.cxx:382
utl::MediaDescriptor & getMediaDescriptor() const
Returns the media descriptor.
Definition: filterbase.cxx:240
const css::uno::Reference< css::frame::XModel > & getModel() const
Returns the document model (always existing).
Definition: filterbase.cxx:220
css::uno::Reference< css::io::XInputStream > openInputStream(const OUString &rStreamName) const
Opens and returns the specified input stream from the base storage.
Definition: filterbase.cxx:327
::oox::ole::OleObjectHelper & getOleObjectHelper() const
Returns a helper for the handling of OLE objects.
Definition: filterbase.cxx:368
GraphicHelper & getGraphicHelper() const
Returns a helper for the handling of graphics and graphic objects.
Definition: filterbase.cxx:346
ModelObjectHelper & getModelObjectHelper() const
Returns a helper with containers for various named drawing objects for the imported document.
Definition: filterbase.cxx:353
const css::uno::Reference< css::uno::XComponentContext > & getComponentContext() const
Returns the component context passed in the filter constructor (always existing).
Definition: filterbase.cxx:215
virtual ::oox::vml::Drawing * getVmlDrawing()=0
Has to be implemented by each filter to return the collection of VML shapes.
RelationsRef importRelations(const OUString &rFragmentPath)
Imports the relations fragment associated with the specified fragment.
NamedShapePairs * getDiagramFontHeights()
virtual ::oox::drawingml::chart::ChartConverter * getChartConverter()=0
Has to be implemented by each filter, returns a filter-specific chart converter object,...
bool importFragment(const rtl::Reference< FragmentHandler > &rxHandler)
Imports a fragment using the passed fragment handler, which contains the full path to the fragment st...
virtual void useInternalChartDataTable(bool)
Helper to switch chart data table - specifically for xlsx imports.
bool isPlaceHolder() const
Returns true, if the color is a placeholder color in theme style lists.
Definition: color.hxx:94
const OUString & getSchemeColorName() const
Returns the scheme name from the a:schemeClr element for interoperability purposes.
Definition: color.hxx:105
sal_Int16 getTransparency() const
Returns the transparency of the color (0 = opaque, 100 = full transparent).
Definition: color.cxx:804
void setSchemeClr(sal_Int32 nToken)
Sets a scheme color from the a:schemeClr element.
Definition: color.cxx:384
void clearTransformations()
Removes all color transformations.
Definition: color.cxx:451
bool isUsed() const
Returns true, if the color is initialized.
Definition: color.hxx:92
const css::uno::Sequence< css::beans::PropertyValue > & getTransformations() const
Returns the unaltered list of transformations for interoperability purposes.
Definition: color.hxx:119
::Color getColor(const GraphicHelper &rGraphicHelper, ::Color nPhClr=API_RGB_TRANSPARENT) const
Returns the final RGB color value.
Definition: color.cxx:644
bool setProperty(ShapeProperty ePropId, const Type &rValue)
Sets the specified shape property to the passed value.
bool setAnyProperty(ShapeProperty ePropId, const css::uno::Any &rValue)
Sets the specified shape property to the passed value.
bool mbLockedCanvas
Is this shape part of a locked canvas?
Definition: shape.hxx:391
ChartShapeInfo & setChartType(bool bEmbedShapes)
Definition: shape.cxx:308
void setTextBox(bool bTextBox)
Definition: shape.cxx:477
FrameType meFrameType
Type for graphic frame shapes.
Definition: shape.hxx:371
const OUString & getInternalName() const
Definition: shape.hxx:173
FillProperties getActualFillProperties(const Theme *pTheme, const FillProperties *pParentShapeFillProps) const
Definition: shape.cxx:2308
void putPropertyToGrabBag(const OUString &sPropertyName, const css::uno::Any &aPropertyValue)
void setServiceName(const char *pServiceName)
Definition: shape.cxx:336
const ShapeStyleRef * getShapeStyleRef(sal_Int32 nRefType) const
Definition: shape.cxx:342
svx::diagram::IDiagramHelper * mpDiagramHelper
Definition: shape.hxx:419
PropertyMap maShapeProperties
Definition: shape.hxx:348
PropertyMap & getShapeProperties()
Definition: shape.hxx:126
LinePropertiesPtr mpShapeRefLinePropPtr
Definition: shape.hxx:339
void keepDiagramDrawing(::oox::core::XmlFilterBase &rFilterBase, const OUString &rFragmentPath)
Definition: shape.cxx:1966
css::uno::Sequence< css::beans::PropertyValue > maDiagramDoms
Definition: shape.hxx:397
void applyShapeReference(const Shape &rReferencedShape, bool bUseText=true)
Definition: shape.cxx:482
void putPropertiesToGrabBag(const css::uno::Sequence< css::beans::PropertyValue > &aProperties)
Definition: shape.cxx:2280
void propagateDiagramHelper()
Definition: shape.cxx:227
LineProperties & getLineProperties()
Definition: shape.hxx:128
css::uno::Reference< css::drawing::XShape > renderDiagramToGraphic(::oox::core::XmlFilterBase const &rFilterBase)
Definition: shape.cxx:2044
PropertyMap maDefaultShapeProperties
Definition: shape.hxx:349
const css::awt::Size & getSize() const
Definition: shape.hxx:159
css::uno::Sequence< css::uno::Sequence< css::uno::Any > > resolveRelationshipsOfTypeFromOfficeDoc(core::XmlFilterBase &rFilter, const OUString &sFragment, std::u16string_view sType)
Definition: shape.cxx:2384
OUString msDescription
Definition: shape.hxx:359
GraphicPropertiesPtr mpGraphicPropertiesPtr
Definition: shape.hxx:342
void cloneFillProperties()
Changes reference semantics to value semantics for fill properties.
Definition: shape.cxx:2426
void setWPGChild(bool bWPG)
Definition: shape.cxx:467
OUString finalizeServiceName(::oox::core::XmlFilterBase &rFilter, const OUString &rServiceName, const css::awt::Rectangle &rShapeRect)
Definition: shape.cxx:2122
bool mbTextBox
This shape has a textbox.
Definition: shape.hxx:393
ShapeStyleRefMap maShapeStyleRefs
Definition: shape.hxx:364
EffectProperties & getEffectProperties() const
Definition: shape.hxx:150
void setMasterTextListStyle(const TextListStylePtr &pMasterTextListStyle)
Definition: shape.cxx:2115
bool isWPGChild() const
Definition: shape.hxx:227
const LinkedTxbxAttr & getLinkedTxbxAttributes() const
Definition: shape.hxx:238
Shape3DProperties & get3DProperties()
Definition: shape.hxx:145
void convertSmartArtToMetafile(::oox::core::XmlFilterBase const &rFilterBase)
Definition: shape.cxx:2014
void setLockedCanvas(bool bLockedCanvas)
Definition: shape.cxx:462
FillPropertiesPtr mpShapeRefFillPropPtr
Definition: shape.hxx:341
EffectProperties getActualEffectProperties(const Theme *pTheme) const
Definition: shape.cxx:2361
@ FRAMETYPE_GENERIC
Generic shape, no special type.
Definition: shape.hxx:277
@ FRAMETYPE_TABLE
A table embedded in a shape.
Definition: shape.hxx:281
@ FRAMETYPE_OLEOBJECT
OLE object embedded in a shape.
Definition: shape.hxx:278
@ FRAMETYPE_CHART
Chart embedded in a shape.
Definition: shape.hxx:279
@ FRAMETYPE_DIAGRAM
Complex diagram drawing shape.
Definition: shape.hxx:280
Shape(const char *pServiceType=nullptr, bool bDefaultHeight=true)
Definition: shape.cxx:128
void addChildren(::oox::core::XmlFilterBase &rFilterBase, Shape &rMaster, const Theme *pTheme, const css::uno::Reference< css::drawing::XShapes > &rxShapes, ShapeIdMap *pShapeMap, const basegfx::B2DHomMatrix &aTransformation)
Definition: shape.cxx:530
ChartShapeInfoRef mxChartShapeInfo
Additional data for chart shapes.
Definition: shape.hxx:379
css::awt::Point maPosition
Definition: shape.hxx:367
void setWps(bool bWps)
Definition: shape.cxx:472
TextListStylePtr mpMasterTextListStyle
Definition: shape.hxx:350
table::TablePropertiesPtr mpTablePropertiesPtr
Definition: shape.hxx:344
virtual ~Shape()
Definition: shape.cxx:206
table::TablePropertiesPtr const & getTableProperties()
Definition: shape.cxx:278
void keepDiagramCompatibilityInfo()
Definition: shape.cxx:1983
FillPropertiesPtr mpFillPropertiesPtr
Definition: shape.hxx:340
CustomShapePropertiesPtr mpCustomShapePropertiesPtr
Definition: shape.hxx:343
OleObjectInfoRef mxOleObjectInfo
Additional data for OLE objects.
Definition: shape.hxx:378
FillProperties & getFillProperties()
Definition: shape.hxx:131
css::awt::Size maSize
Definition: shape.hxx:366
void prepareDiagramHelper(const std::shared_ptr< Diagram > &rDiagramPtr, const std::shared_ptr<::oox::drawingml::Theme > &rTheme)
Definition: shape.cxx:213
void setDefaults(bool bHeight)
Definition: shape.cxx:285
bool mbWps
Is this a wps shape?
Definition: shape.hxx:392
OUString msConnectorName
Definition: shape.hxx:354
virtual void finalizeXShape(::oox::core::XmlFilterBase &rFilter, const css::uno::Reference< css::drawing::XShapes > &rxShapes)
void migrateDiagramHelperToNewShape(const ShapePtr &pTarget)
Definition: shape.cxx:251
sal_Int32 mnSubType
Definition: shape.hxx:361
std::vector< ShapePtr > maChildren
Definition: shape.hxx:331
EffectPropertiesPtr mpShapeRefEffectPropPtr
Definition: shape.hxx:347
const TextBodyPtr & getTextBody() const
Definition: shape.hxx:195
TextBodyPtr mpTextBody
Definition: shape.hxx:337
bool isLinkedTxbx() const
Definition: shape.hxx:239
css::uno::Reference< css::drawing::XShape > const & createAndInsert(::oox::core::XmlFilterBase &rFilterBase, const OUString &rServiceName, const Theme *pTheme, const css::uno::Reference< css::drawing::XShapes > &rxShapes, bool bClearText, bool bDoNotInsertEmptyTextBody, basegfx::B2DHomMatrix &aTransformation, const FillProperties &rShapeOrParentShapeFillProps, oox::drawingml::ShapePtr pParentGroupShape=nullptr)
Definition: shape.cxx:826
void addShape(::oox::core::XmlFilterBase &rFilterBase, const Theme *pTheme, const css::uno::Reference< css::drawing::XShapes > &rxShapes, const basegfx::B2DHomMatrix &aTransformation, const FillProperties &rShapeOrParentShapeFillProps, ShapeIdMap *pShapeMap=nullptr, oox::drawingml::ShapePtr pParentGroupShape=nullptr)
Definition: shape.cxx:348
sal_Int32 mnDiagramRotation
Definition: shape.hxx:382
::oox::vml::OleObjectInfo & setOleObjectType()
Definition: shape.cxx:300
css::uno::Reference< css::drawing::XShape > mxShape
Definition: shape.hxx:351
sal_Int32 mnRotation
Definition: shape.hxx:381
std::vector< OUString > maConnectorAdjustmentList
Definition: shape.hxx:335
void setTextBody(const TextBodyPtr &pTextBody)
Definition: shape.cxx:2110
OUString msServiceName
Definition: shape.hxx:355
LineProperties getActualLineProperties(const Theme *pTheme) const
Definition: shape.cxx:2337
carries a CT_TextFont
Definition: textfont.hxx:34
bool getFontData(OUString &rFontName, sal_Int16 &rnFontPitch, sal_Int16 &rnFontFamily, const ::oox::core::XmlFilterBase &rFilter) const
Returns the font name, pitch, and family; tries to resolve theme placeholder names,...
Definition: textfont.cxx:79
const EffectProperties * getEffectStyle(sal_Int32 nIndex) const
Definition: theme.cxx:61
const FillProperties * getFillStyle(sal_Int32 nIndex) const
Returns the fill properties of the passed one-based themed style index.
Definition: theme.cxx:49
const LineProperties * getLineStyle(sal_Int32 nIndex) const
Returns the line properties of the passed one-based themed style index.
Definition: theme.cxx:56
const TextCharacterProperties * getFontStyle(sal_Int32 nSchemeType) const
Returns theme font properties by scheme type (major/minor).
Definition: theme.cxx:66
void convertFromModel(::oox::core::XmlFilterBase &rFilter, ChartSpaceModel &rChartModel, const css::uno::Reference< css::chart2::XChartDocument > &rxChartDoc, const css::uno::Reference< css::drawing::XShapes > &rxExternalPage, const css::awt::Point &rChartPos, const css::awt::Size &rChartSize)
Converts the passed OOXML chart model to the passed chart2 document.
Handler for a chart fragment (c:chartSpace root element).
This class is used for creating XmlStream.
bool importOleObject(PropertyMap &rPropMap, const OleObjectInfo &rOleObject, const css::awt::Size &rObjSize)
const SlidePersistPtr & getActualSlidePersist() const
Definition: pptimport.hxx:68
Represents the collection of VML shapes for a complete draw page.
Definition: vmldrawing.hxx:94
constexpr tools::Long GetHeight() const
static constexpr OUStringLiteral PROP_DOCUMENTSERVICE
ColorTransparency
#define TOOLS_WARN_EXCEPTION(area, stream)
float u
#define ERRCODE_NONE
#define GRFILTER_FORMAT_NOTFOUND
const char * name
OUString msName
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
void putCustomShapeIntoTextPathMode(const css::uno::Reference< css::drawing::XShape > &xShape, const oox::drawingml::CustomShapePropertiesPtr &pCustomShapePropertiesPtr, const OUString &sMSPresetType, const bool bFromWordArt)
Changes the EnhancedCustomShapeGeometry of xShape shape so, that it becomes a LO Fontwork shape corre...
OUString GetFontworkType(std::u16string_view rMsoType)
tools::Long const nBorder
@ Exception
bool hasProperty(const OUString &_rName, const Reference< XPropertySet > &_rxSet)
css::uno::Sequence< T > concatSequences(const css::uno::Sequence< T > &rS1, const Ss &... rSn)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
css::uno::Sequence< css::beans::PropertyValue > InitPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
std::shared_ptr< T > make_shared(Args &&... args)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
constexpr T saturating_add(T a, T b)
std::shared_ptr< Relations > RelationsRef
Definition: relations.hxx:63
std::map< OUString, ShapePairs > NamedShapePairs
std::shared_ptr< TableProperties > TablePropertiesPtr
float GetFontHeight(sal_Int32 nHeight)
static SdrTextHorzAdjust lcl_convertAdjust(ParagraphAdjust eAdjust)
Definition: shape.cxx:545
std::shared_ptr< Shape > ShapePtr
sal_Int32 convertEmuToHmm(sal_Int64 nValue)
Converts the passed 64-bit integer value from EMUs to 1/100 mm.
std::shared_ptr< Theme > ThemePtr
::std::map< OUString, ShapePtr > ShapeIdMap
Definition: shape.hxx:77
static void lcl_copyCharPropsToShape(const uno::Reference< drawing::XShape > &xShape, const TextBodyPtr &pTextBody, const ::oox::core::XmlFilterBase &rFilter)
Definition: shape.cxx:559
std::shared_ptr< TextListStyle > TextListStylePtr
std::shared_ptr< TextBody > TextBodyPtr
css::uno::Sequence< sal_Int8 > StreamDataSequence
const ::Color API_RGB_TRANSPARENT(ColorTransparency, 0xffffffff)
Transparent color for API calls.
QPRO_FUNC_TYPE nType
SdrTextHorzAdjust
SDRTEXTHORZADJUST_LEFT
SDRTEXTHORZADJUST_CENTER
SDRTEXTHORZADJUST_RIGHT
Reference< document::XActionLockable > m_xLockable
Definition: shape.cxx:524
#define STREAM_SEEK_TO_BEGIN
sal_uInt16 yExt
sal_uInt16 mapMode
sal_uInt16 xExt
UNDERLYING_TYPE get() const
Additional information for a chart embedded in a drawing shape.
Definition: shape.hxx:92
std::optional< sal_Int64 > moGlowRad
EffectSoftEdgeProperties maSoftEdge
std::vector< std::unique_ptr< Effect > > m_Effects
Stores all effect properties, including those not supported by core yet.
void assignUsed(const EffectProperties &rSourceProps)
Overwrites all members that are explicitly set in rSourceProps.
void pushToPropMap(PropertyMap &rPropMap, const GraphicHelper &rGraphicHelper) const
Writes the properties to the passed property map.
std::optional< sal_Int64 > moShadowDir
GradientFillProperties maGradientProps
Whether the background is used as fill type.
void pushToPropMap(ShapePropertyMap &rPropMap, const GraphicHelper &rGraphicHelper, sal_Int32 nShapeRotation=0, ::Color nPhClr=API_RGB_TRANSPARENT, const css::awt::Size &rSize={}, sal_Int16 nPhClrTheme=-1, bool bFlipH=false, bool bFlipV=false, bool bIsCustomShape=false) const
Writes the properties to the passed property map.
void assignUsed(const FillProperties &rSourceProps)
Properties for bitmap fills.
Color maFillColor
Fill type (OOXML token).
std::optional< sal_Int32 > moFillType
css::uno::Sequence< css::beans::PropertyValue > getLightRigAttributes()
css::uno::Sequence< css::beans::PropertyValue > getShape3DAttributes(const GraphicHelper &rGraphicHelper, ::Color rPhClr)
css::uno::Sequence< css::beans::PropertyValue > getCameraAttributes()
void assignUsed(const LineProperties &rSourceProps)
Line joint type (OOXML token).
FillProperties maLineFill
End line arrow style.
sal_Int32 getLineWidth() const
Calculates the line width attribute from the internal state of the object.
std::optional< sal_Int32 > moLineWidth
User-defined line dash style.
void pushToPropMap(ShapePropertyMap &rPropMap, const GraphicHelper &rGraphicHelper, ::Color nPhClr=API_RGB_TRANSPARENT, sal_Int16 nPhClrTheme=-1) const
Writes the properties to the passed property map.
css::drawing::LineStyle getLineStyle() const
Calculates the line style attribute from the internal state of the object.
css::drawing::LineCap getLineCap() const
Calculates the line cap attribute from the internal state of the object.
css::drawing::LineJoint getLineJoint() const
Calculates the line joint attribute from the internal state of the object.
std::optional< sal_Int32 > mnRevolution
void assignUsed(const TextCharacterProperties &rSourceProps)
Overwrites all members that are explicitly set in rSourceProps.
std::optional< LineProperties > moTextOutlineProperties
Contains information about an OLE object embedded in a draw page.
Definition: vmldrawing.hxx:63
SVXCORE_DLLPUBLIC Degree100 NormAngle36000(Degree100 a)
constexpr OUStringLiteral UNO_NAME_TEXT_LOWERDIST
constexpr OUStringLiteral UNO_NAME_TEXT_UPPERDIST
constexpr OUStringLiteral UNO_NAME_HYPERLINK
constexpr OUStringLiteral UNO_NAME_LINESTYLE
constexpr OUStringLiteral UNO_NAME_CHAR_POSTURE
constexpr OUStringLiteral UNO_NAME_TEXT_VERTADJUST
constexpr OUStringLiteral UNO_NAME_TEXT_LEFTDIST
constexpr OUStringLiteral UNO_NAME_TEXT_AUTOGROWHEIGHT
constexpr OUStringLiteral UNO_NAME_TEXT_AUTOGROWWIDTH
constexpr OUStringLiteral UNO_NAME_CHAR_HEIGHT
constexpr OUStringLiteral UNO_NAME_MISC_OBJ_INTEROPGRABBAG
constexpr OUStringLiteral UNO_NAME_TEXT_RIGHTDIST
constexpr OUStringLiteral UNO_NAME_CHAR_WEIGHT
constexpr OUStringLiteral PROP_FillTransparence
constexpr OUStringLiteral PROP_TextWordWrap
constexpr OUStringLiteral PROP_Shadow
constexpr OUStringLiteral PROP_RightBorder
constexpr OUStringLiteral PROP_RotateAngle
constexpr OUStringLiteral PROP_TextLeftDistance
constexpr OUStringLiteral PROP_ShadowXDistance
constexpr OUStringLiteral PROP_HoriOrientPosition
constexpr OUStringLiteral PROP_CharHeight
constexpr OUStringLiteral PROP_LineColor
constexpr OUStringLiteral PROP_TextUpperDistance
constexpr OUStringLiteral PROP_BackColor
constexpr OUStringLiteral PROP_FillColor
constexpr OUStringLiteral PROP_BackColorTransparency
constexpr OUStringLiteral PROP_TextContourFrame
constexpr OUStringLiteral PROP_CharColor
constexpr OUStringLiteral PROP_FillBitmapName
constexpr OUStringLiteral PROP_LeftBorder
constexpr OUStringLiteral PROP_GraphicCrop
constexpr OUStringLiteral PROP_ShadowFormat
constexpr OUStringLiteral PROP_BackGraphic
constexpr OUStringLiteral PROP_TextLowerDistance
constexpr OUStringLiteral PROP_TextAutoGrowHeight
constexpr OUStringLiteral PROP_ParaAdjust
constexpr OUStringLiteral PROP_TextRightDistance
constexpr OUStringLiteral PROP_TopBorder
constexpr OUStringLiteral PROP_TextVerticalAdjust
constexpr OUStringLiteral PROP_VertOrientPosition
constexpr OUStringLiteral PROP_ShadowColor
constexpr OUStringLiteral PROP_ShadowYDistance
constexpr OUStringLiteral PROP_BottomBorder
sal_Int32 nLength