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