28#include <com/sun/star/beans/XPropertySet.hpp>
29#include <com/sun/star/awt/Gradient.hpp>
30#include <com/sun/star/text/GraphicCrop.hpp>
31#include <com/sun/star/awt/Size.hpp>
32#include <com/sun/star/drawing/BitmapMode.hpp>
33#include <com/sun/star/drawing/ColorMode.hpp>
34#include <com/sun/star/drawing/FillStyle.hpp>
35#include <com/sun/star/drawing/RectanglePoint.hpp>
36#include <com/sun/star/graphic/XGraphicTransformer.hpp>
41#include <oox/token/namespaces.hxx>
42#include <oox/token/properties.hxx>
43#include <oox/token/tokens.hxx>
44#include <osl/diagnose.h>
51using ::com::sun::star::uno::Reference;
52using ::com::sun::star::uno::Exception;
53using ::com::sun::star::uno::UNO_QUERY_THROW;
54using ::com::sun::star::geometry::IntegerRectangle2D;
60Reference< XGraphic > lclCheckAndApplyDuotoneTransform(
const BlipFillProperties& aBlipProps, uno::Reference<graphic::XGraphic>
const & xGraphic,
63 if (aBlipProps.maDuotoneColors[0].isUsed() && aBlipProps.maDuotoneColors[1].isUsed())
65 ::Color nColor1 = aBlipProps.maDuotoneColors[0].getColor( rGraphicHelper, nPhClr );
66 ::Color nColor2 = aBlipProps.maDuotoneColors[1].getColor( rGraphicHelper, nPhClr );
68 uno::Reference<graphic::XGraphicTransformer> xTransformer(aBlipProps.mxFillGraphic, uno::UNO_QUERY);
69 if (xTransformer.is())
70 return xTransformer->applyDuotone(xGraphic, sal_Int32(nColor1), sal_Int32(nColor2));
75Reference< XGraphic > lclRotateGraphic(uno::Reference<graphic::XGraphic>
const & xGraphic,
Degree10 nRotation)
80 assert (aGraphic.GetType() == GraphicType::Bitmap);
82 BitmapEx aBitmapEx(aGraphic.GetBitmapEx());
83 const ::Color& aColor =
::Color(0x00);
84 aBitmapEx.Rotate(nRotation, aColor);
91using Quotients = std::tuple<double, double, double, double>;
92Quotients getQuotients(geometry::IntegerRectangle2D aRelRect,
double hDiv,
double vDiv)
94 return { aRelRect.X1 / hDiv, aRelRect.Y1 / vDiv, aRelRect.X2 / hDiv, aRelRect.Y2 / vDiv };
98std::optional<Quotients> CropQuotientsFromSrcRect(geometry::IntegerRectangle2D aSrcRect)
100 aSrcRect.X1 = std::max(aSrcRect.X1, sal_Int32(0));
101 aSrcRect.X2 = std::max(aSrcRect.X2, sal_Int32(0));
102 aSrcRect.Y1 = std::max(aSrcRect.Y1, sal_Int32(0));
103 aSrcRect.Y2 = std::max(aSrcRect.Y2, sal_Int32(0));
104 if (aSrcRect.X1 + aSrcRect.X2 >= 100'000 || aSrcRect.Y1 + aSrcRect.Y2 >= 100'000)
106 return getQuotients(aSrcRect, 100'000.0, 100'000.0);
110std::optional<Quotients> CropQuotientsFromFillRect(geometry::IntegerRectangle2D aFillRect)
112 aFillRect.X1 = std::min(aFillRect.X1, sal_Int32(0));
113 aFillRect.X2 = std::min(aFillRect.X2, sal_Int32(0));
114 aFillRect.Y1 = std::min(aFillRect.Y1, sal_Int32(0));
115 aFillRect.Y2 = std::min(aFillRect.Y2, sal_Int32(0));
117 return getQuotients(aFillRect, -100'000.0 + aFillRect.X1 + aFillRect.X2,
118 -100'000.0 + aFillRect.Y1 + aFillRect.Y2);
122Reference<XGraphic> lclCropGraphic(uno::Reference<graphic::XGraphic>
const& xGraphic,
123 std::optional<Quotients> quotients)
126 assert (aGraphic.GetType() == GraphicType::Bitmap);
131 aBitmapEx = aGraphic.GetBitmapEx();
134 const auto& [qx1, qy1, qx2, qy2] = *quotients;
140 aBitmapEx.
Crop({ l,
t, bmpSize.
Width() - r - 1, bmpSize.
Height() - b - 1 });
149Reference< XGraphic > lclMirrorGraphic(uno::Reference<graphic::XGraphic>
const & xGraphic,
bool bFlipH,
bool bFlipV)
154 assert (aGraphic.GetType() == GraphicType::Bitmap);
156 BitmapEx aBitmapEx(aGraphic.GetBitmapEx());
160 nMirrorFlags |= BmpMirrorFlags::Horizontal;
162 nMirrorFlags |= BmpMirrorFlags::Vertical;
164 aBitmapEx.
Mirror(nMirrorFlags);
172Reference< XGraphic > lclGreysScaleGraphic(uno::Reference<graphic::XGraphic>
const & xGraphic)
177 assert (aGraphic.GetType() == GraphicType::Bitmap);
179 BitmapEx aBitmapEx(aGraphic.GetBitmapEx());
180 aBitmapEx.
Convert(BmpConversion::N8BitGreys);
188Reference< XGraphic > lclCheckAndApplyChangeColorTransform(
const BlipFillProperties &aBlipProps, uno::Reference<graphic::XGraphic>
const & xGraphic,
191 if( aBlipProps.maColorChangeFrom.isUsed() && aBlipProps.maColorChangeTo.isUsed() )
193 ::Color nFromColor = aBlipProps.maColorChangeFrom.getColor( rGraphicHelper, nPhClr );
194 ::Color nToColor = aBlipProps.maColorChangeTo.getColor( rGraphicHelper, nPhClr );
195 if ( (nFromColor != nToColor) || aBlipProps.maColorChangeTo.hasTransparency() )
197 sal_Int16 nToTransparence = aBlipProps.maColorChangeTo.getTransparency();
198 sal_Int8 nToAlpha =
static_cast< sal_Int8 >( (100 - nToTransparence) * 2.55 );
200 uno::Reference<graphic::XGraphicTransformer> xTransformer(aBlipProps.mxFillGraphic, uno::UNO_QUERY);
201 if (xTransformer.is())
202 return xTransformer->colorChange(xGraphic, sal_Int32(nFromColor), 9, sal_Int32(nToColor), nToAlpha);
208uno::Reference<graphic::XGraphic> applyBrightnessContrast(uno::Reference<graphic::XGraphic>
const & xGraphic, sal_Int32 brightness, sal_Int32 contrast)
210 uno::Reference<graphic::XGraphicTransformer> xTransformer(xGraphic, uno::UNO_QUERY);
211 if (xTransformer.is())
212 return xTransformer->applyBrightnessContrast(xGraphic, brightness, contrast,
true);
216BitmapMode lclGetBitmapMode( sal_Int32 nToken )
218 OSL_ASSERT((nToken & sal_Int32(0xFFFF0000))==0);
221 case XML_tile:
return BitmapMode_REPEAT;
222 case XML_stretch:
return BitmapMode_STRETCH;
226 return BitmapMode_REPEAT;
229RectanglePoint lclGetRectanglePoint( sal_Int32 nToken )
231 OSL_ASSERT((nToken & sal_Int32(0xFFFF0000))==0);
234 case XML_tl:
return RectanglePoint_LEFT_TOP;
235 case XML_t:
return RectanglePoint_MIDDLE_TOP;
236 case XML_tr:
return RectanglePoint_RIGHT_TOP;
237 case XML_l:
return RectanglePoint_LEFT_MIDDLE;
238 case XML_ctr:
return RectanglePoint_MIDDLE_MIDDLE;
239 case XML_r:
return RectanglePoint_RIGHT_MIDDLE;
240 case XML_bl:
return RectanglePoint_LEFT_BOTTOM;
241 case XML_b:
return RectanglePoint_MIDDLE_BOTTOM;
242 case XML_br:
return RectanglePoint_RIGHT_BOTTOM;
244 return RectanglePoint_LEFT_TOP;
247awt::Size lclGetOriginalSize(
const GraphicHelper& rGraphicHelper,
const Reference< XGraphic >& rxGraphic )
249 awt::Size aSizeHmm( 0, 0 );
252 Reference< beans::XPropertySet > xGraphicPropertySet( rxGraphic, UNO_QUERY_THROW );
253 if( xGraphicPropertySet->getPropertyValue(
"Size100thMM" ) >>= aSizeHmm )
255 if( !aSizeHmm.Width && !aSizeHmm.Height )
257 awt::Size aSourceSizePixel( 0, 0 );
258 if( xGraphicPropertySet->getPropertyValue(
"SizePixel" ) >>= aSourceSizePixel )
273void extractGradientBorderFromStops(
const GradientFillProperties& rGradientProps,
275 awt::Gradient& rGradient)
277 if (rGradientProps.maGradientStops.size() <= 1)
280 auto it = rGradientProps.maGradientStops.rbegin();
281 double fLastPos = it->first;
282 Color aLastColor = it->second;
284 double fLastButOnePos = it->first;
285 Color aLastButOneColor = it->second;
286 if (!aLastColor.equals(aLastButOneColor, rGraphicHelper, nPhClr))
290 rGradient.Border = rtl::math::round((fLastPos - fLastButOnePos) * 100);
360 GradientFillProperties::GradientStopMap::const_iterator aGradientStop =
364 aSolidColor = aGradientStop->second;
375 const GraphicHelper& rGraphicHelper, sal_Int32 nShapeRotation,
::Color nPhClr, sal_Int16 nPhClrTheme,
376 bool bFlipH,
bool bFlipV,
bool bIsCustomShape)
const
382 OSL_ASSERT((
moFillType.value() & sal_Int32(0xFFFF0000))==0);
387 eFillStyle = FillStyle_NONE;
400 if (aFillColor == nPhClr)
402 rPropMap.
setProperty(PROP_FillColorTheme, nPhClrTheme);
411 eFillStyle = FillStyle_SOLID;
419 sal_Int32 nEndTrans = 0;
420 sal_Int32 nStartTrans = 0;
421 awt::Gradient aGradient;
422 aGradient.Angle = 900;
423 aGradient.StartIntensity = 100;
424 aGradient.EndIntensity = 100;
444 sal_Int32 nCenterX = (
MAX_PERCENT + aFillToRect.X1 - aFillToRect.X2) / 2;
445 aGradient.XOffset = getLimitedValue<sal_Int16, sal_Int32>(
447 sal_Int32 nCenterY = (
MAX_PERCENT + aFillToRect.Y1 - aFillToRect.Y2) / 2;
448 aGradient.YOffset = getLimitedValue<sal_Int16, sal_Int32>(
455 aGradient.Style = awt::GradientStyle_LINEAR;
456 if( aGradient.XOffset == 100 && aGradient.YOffset == 100 )
457 aGradient.Angle = 450;
458 else if( aGradient.XOffset == 0 && aGradient.YOffset == 100 )
459 aGradient.Angle = 3150;
460 else if( aGradient.XOffset == 100 && aGradient.YOffset == 0 )
461 aGradient.Angle = 1350;
462 else if( aGradient.XOffset == 0 && aGradient.YOffset == 0 )
463 aGradient.Angle = 2250;
465 aGradient.Style = awt::GradientStyle_RADIAL;
469 aGradient.Style = awt::GradientStyle_RECT;
472 ::std::swap( aGradient.StartColor, aGradient.EndColor );
473 ::std::swap( nStartTrans, nEndTrans );
475 extractGradientBorderFromStops(
maGradientProps, rGraphicHelper, nPhClr,
485 auto a0 = aGradientStops.find( 0.0 );
486 if( a0 == aGradientStops.end() )
489 Color aFirstColor(aGradientStops.begin()->second);
490 aGradientStops.emplace( 0.0, aFirstColor );
493 auto a1 = aGradientStops.find( 1.0 );
494 if( a1 == aGradientStops.end() )
497 Color aLastColor(aGradientStops.rbegin()->second);
498 aGradientStops.emplace( 1.0, aLastColor );
502 bool bSymmetric(
true);
504 GradientFillProperties::GradientStopMap::const_iterator aItA( aGradientStops.begin() );
505 GradientFillProperties::GradientStopMap::const_iterator aItZ(std::prev(aGradientStops.end()));
506 assert(aItZ != aGradientStops.end());
507 while( bSymmetric && aItA->first < aItZ->first )
509 if (!aItA->second.equals(aItZ->second, rGraphicHelper, nPhClr))
514 aItZ = std::prev(aItZ);
518 if( bSymmetric && aItA == aItZ && aItA->first != 0.5 )
526 if( aItA->first != aItZ->first )
528 Color aMiddleColor = aItZ->second;
529 auto a05 = aGradientStops.find( 0.5 );
531 if( a05 != aGradientStops.end() )
532 a05->second = aMiddleColor;
534 aGradientStops.emplace( 0.5, aMiddleColor );
537 while( aGradientStops.rbegin()->first > 0.5 )
538 aGradientStops.erase( aGradientStops.rbegin()->first );
542 SAL_INFO(
"oox.drawingml.gradient",
"symmetric: " << (bSymmetric ?
"YES" :
"NO") <<
543 ", number of stops: " << aGradientStops.size());
545 for (
auto const& gradientStop : aGradientStops)
547 gradientStop.first <<
": " <<
548 std::hex << sal_Int32(gradientStop.second.getColor( rGraphicHelper, nPhClr )) << std::dec <<
549 "@" << (100 - gradientStop.second.getTransparency()) <<
"%");
555 GradientFillProperties::GradientStopMap::iterator aIt(aGradientStops.begin());
556 double nWidestWidth = -1;
557 GradientFillProperties::GradientStopMap::iterator aWidestSegmentStart;
559 while( aIt != aGradientStops.end() )
561 if (aIt->first - std::prev(aIt)->first > nWidestWidth)
563 nWidestWidth = aIt->first - std::prev(aIt)->first;
564 aWidestSegmentStart = std::prev(aIt);
568 assert( nWidestWidth > 0 );
576 if( aGradientStops.size() == 3 &&
577 aGradientStops.begin()->second.getColor(rGraphicHelper, nPhClr) == std::next(aGradientStops.begin())->second.getColor(rGraphicHelper, nPhClr) &&
578 aGradientStops.begin()->second.getTransparency() == std::next(aGradientStops.begin())->second.getTransparency())
581 SAL_INFO(
"oox.drawingml.gradient",
"two segments, first is uniformly coloured");
582 nBorder = std::next(aGradientStops.begin())->first - aGradientStops.begin()->first;
583 aGradientStops.erase(aGradientStops.begin());
584 aWidestSegmentStart = aGradientStops.begin();
586 else if( !bSymmetric &&
587 aGradientStops.size() == 3 &&
588 std::next(aGradientStops.begin())->second.getColor(rGraphicHelper, nPhClr) == std::prev(aGradientStops.end())->second.getColor(rGraphicHelper, nPhClr) &&
589 std::next(aGradientStops.begin())->second.getTransparency() == std::prev(aGradientStops.end())->second.getTransparency())
592 SAL_INFO(
"oox.drawingml.gradient",
"two segments, second is uniformly coloured");
593 auto aNext = std::next(aGradientStops.begin());
594 auto aPrev = std::prev(aGradientStops.end());
595 assert(aPrev != aGradientStops.end());
596 nBorder = aPrev->first - aNext->first;
597 aGradientStops.erase(aNext);
598 aWidestSegmentStart = aGradientStops.begin();
600 nShapeRotation = 180*60000 - nShapeRotation;
602 else if( !bSymmetric &&
603 aGradientStops.size() >= 4 &&
604 aWidestSegmentStart->second.getColor( rGraphicHelper, nPhClr ) == std::next(aWidestSegmentStart)->second.getColor(rGraphicHelper, nPhClr) &&
605 aWidestSegmentStart->second.getTransparency() == std::next(aWidestSegmentStart)->second.getTransparency() &&
606 ( aWidestSegmentStart == aGradientStops.begin() ||
607 std::next(aWidestSegmentStart) == std::prev(aGradientStops.end())))
610 SAL_INFO(
"oox.drawingml.gradient",
"first or last segment is widest and is uniformly coloured");
611 nBorder = std::next(aWidestSegmentStart)->first - aWidestSegmentStart->first;
615 if (std::next(aWidestSegmentStart) == std::prev(aGradientStops.end()))
618 nShapeRotation = 180*60000 - nShapeRotation;
621 aGradientStops.erase( aWidestSegmentStart++ );
624 aIt = std::next(aGradientStops.begin());
626 while( aIt != aGradientStops.end() )
628 if (aIt->first - std::prev(aIt)->first > nWidestWidth)
630 nWidestWidth = aIt->first - std::prev(aIt)->first;
631 aWidestSegmentStart = std::prev(aIt);
636 SAL_INFO(
"oox.drawingml.gradient",
"widest segment start: " << aWidestSegmentStart->first <<
", border: " <<
nBorder);
637 assert( (!bSymmetric && !bSwap) || !(bSymmetric && bSwap) );
641 aGradient.Style = bSymmetric ? awt::GradientStyle_AXIAL : awt::GradientStyle_LINEAR;
645 nShadeAngle = 180*60000 - nShadeAngle;
647 nShadeAngle = -nShadeAngle;
648 sal_Int32 nDmlAngle = nShadeAngle + nShapeRotation;
650 aGradient.Angle =
static_cast< sal_Int16
>( (8100 - (nDmlAngle / (
PER_DEGREE / 10))) % 3600 );
651 Color aStartColor, aEndColor;
654 auto aWidestSegmentEnd = std::next(aWidestSegmentStart);
658 while (aWidestSegmentStart != aGradientStops.begin())
660 auto it = std::prev(aWidestSegmentStart);
661 if (it->second.getColor(rGraphicHelper, nPhClr)
662 != aWidestSegmentStart->second.getColor(rGraphicHelper, nPhClr))
667 aWidestSegmentStart = it;
672 while (aWidestSegmentEnd != std::prev(aGradientStops.end()))
674 auto it = std::next(aWidestSegmentEnd);
675 if (it->second.getColor(rGraphicHelper, nPhClr)
676 != aWidestSegmentEnd->second.getColor(rGraphicHelper, nPhClr))
681 aWidestSegmentEnd = it;
684 assert(aWidestSegmentEnd != aGradientStops.end());
688 aStartColor = aWidestSegmentEnd->second;
689 aEndColor = aWidestSegmentStart->second;
694 aStartColor = aWidestSegmentEnd->second;
695 aEndColor = aWidestSegmentStart->second;
699 aStartColor = aWidestSegmentStart->second;
700 aEndColor = aWidestSegmentEnd->second;
703 SAL_INFO(
"oox.drawingml.gradient",
"start color: " << std::hex << sal_Int32(aStartColor.
getColor( rGraphicHelper, nPhClr )) << std::dec <<
705 ", end color: " << std::hex << sal_Int32(aEndColor.
getColor( rGraphicHelper, nPhClr )) << std::dec <<
708 aGradient.StartColor = sal_Int32(aStartColor.
getColor( rGraphicHelper, nPhClr ));
709 aGradient.EndColor = sal_Int32(aEndColor.
getColor( rGraphicHelper, nPhClr ));
714 aGradient.Border = rtl::math::round(100*
nBorder);
719 eFillStyle = FillStyle_GRADIENT;
722 if( nStartTrans != 0 || nEndTrans != 0 )
724 awt::Gradient aGrad(aGradient);
726 aGrad.EndColor =
static_cast<sal_Int32
>( nEndTrans | nEndTrans << 8 | nEndTrans << 16 );
727 aGrad.StartColor =
static_cast<sal_Int32
>( nStartTrans | nStartTrans << 8 | nStartTrans << 16 );
745 xGraphic = lclGreysScaleGraphic(xGraphic);
750 eFillStyle = FillStyle_BITMAP;
754 eFillStyle = FillStyle_BITMAP;
759 if( eFillStyle == FillStyle_BITMAP )
766 if( eBitmapMode == BitmapMode_REPEAT )
773 if( (aOriginalSize.Width > 0) && (aOriginalSize.Height > 0) )
777 sal_Int32 nFillBmpSizeX = getLimitedValue< sal_Int32, double >( aOriginalSize.Width * fScaleX, 1,
SAL_MAX_INT32 );
780 sal_Int32 nFillBmpSizeY = getLimitedValue< sal_Int32, double >( aOriginalSize.Height * fScaleY, 1,
SAL_MAX_INT32 );
784 sal_Int16 nTileOffsetX = getDoubleIntervalValue< sal_Int16 >(
maBlipProps.
moTileOffsetX.value_or( 0 ) / 3.6 / aOriginalSize.Width, 0, 100 );
786 sal_Int16 nTileOffsetY = getDoubleIntervalValue< sal_Int16 >(
maBlipProps.
moTileOffsetY.value_or( 0 ) / 3.6 / aOriginalSize.Height, 0, 100 );
794 if ( aOriginalSize.Width && aOriginalSize.Height )
796 text::GraphicCrop aGraphCrop( 0, 0, 0, 0 );
798 aGraphCrop.Left =
static_cast< sal_Int32
>( (
static_cast< double >( aOriginalSize.Width ) * aFillRect.X1 ) / 100000 );
800 aGraphCrop.Top =
static_cast< sal_Int32
>( (
static_cast< double >( aOriginalSize.Height ) * aFillRect.Y1 ) / 100000 );
802 aGraphCrop.Right =
static_cast< sal_Int32
>( (
static_cast< double >( aOriginalSize.Width ) * aFillRect.X2 ) / 100000 );
804 aGraphCrop.Bottom =
static_cast< sal_Int32
>( (
static_cast< double >( aOriginalSize.Height ) * aFillRect.Y2 ) / 100000 );
805 rPropMap.
setProperty(PROP_GraphicCrop, aGraphCrop);
807 bool bHasCropValues = aGraphCrop.Left != 0 || aGraphCrop.Right !=0 || aGraphCrop.Top != 0 || aGraphCrop.Bottom != 0;
809 bool bNeedCrop = aGraphCrop.Left <= 0 && aGraphCrop.Right <= 0 && aGraphCrop.Top <= 0 && aGraphCrop.Bottom <= 0;
811 if(bIsCustomShape && bHasCropValues && bNeedCrop)
813 xGraphic = lclCropGraphic(xGraphic, CropQuotientsFromFillRect(aFillRect));
832 eFillStyle = FillStyle_HATCH;
851 eFillStyle = FillStyle_SOLID;
859 eFillStyle = FillStyle_NONE;
871 ColorMode eColorMode = ColorMode_STANDARD;
875 case XML_biLevel: eColorMode = ColorMode_MONO;
break;
876 case XML_grayscl: eColorMode = ColorMode_GREYS;
break;
885 if (eColorMode == ColorMode_STANDARD && nBrightness == 70 && nContrast == -70)
888 eColorMode = ColorMode_WATERMARK;
892 else if( nBrightness != 0 && nContrast != 0 )
898 xGraphic = applyBrightnessContrast( xGraphic, nBrightness, nContrast );
908 if ( aOriginalSize.Width && aOriginalSize.Height )
910 text::GraphicCrop aGraphCrop( 0, 0, 0, 0 );
912 aGraphCrop.Left = rtl::math::round( (
static_cast< double >( aOriginalSize.Width ) * oClipRect.X1 ) / 100000 );
914 aGraphCrop.Top = rtl::math::round( (
static_cast< double >( aOriginalSize.Height ) * oClipRect.Y1 ) / 100000 );
916 aGraphCrop.Right = rtl::math::round( (
static_cast< double >( aOriginalSize.Width ) * oClipRect.X2 ) / 100000 );
918 aGraphCrop.Bottom = rtl::math::round( (
static_cast< double >( aOriginalSize.Height ) * oClipRect.Y2 ) / 100000 );
919 rPropMap.
setProperty(PROP_GraphicCrop, aGraphCrop);
921 bool bHasCropValues = aGraphCrop.Left != 0 || aGraphCrop.Right !=0 || aGraphCrop.Top != 0 || aGraphCrop.Bottom != 0;
923 bool bNeedCrop = aGraphCrop.Left >= 0 && aGraphCrop.Right >= 0 && aGraphCrop.Top >= 0 && aGraphCrop.Bottom >= 0;
927 xGraphic = lclCropGraphic(xGraphic, CropQuotientsFromSrcRect(oClipRect));
935 rPropMap.
setProperty(PROP_FillStyle, FillStyle_BITMAP);
936 rPropMap.
setProperty(PROP_FillBitmapMode, BitmapMode_STRETCH);
943 xGraphic = lclRotateGraphic(xGraphic,
Degree10(nAngle/10) );
949 xGraphic = lclMirrorGraphic(xGraphic, bFlipH, bFlipV );
951 if(eColorMode == ColorMode_GREYS)
952 xGraphic = lclGreysScaleGraphic( xGraphic );
965 rPropMap.
setProperty(PROP_GraphicColorMode, eColorMode);
968 if( nBrightness != 0 )
969 rPropMap.
setProperty(PROP_AdjustLuminance, nBrightness);
971 rPropMap.
setProperty(PROP_AdjustContrast, nContrast);
989 css::beans::PropertyValue aRet;
993 css::uno::Sequence< css::beans::PropertyValue >
aSeq(
maAttribs.size() + 1 );
994 auto pSeq =
aSeq.getArray();
998 pSeq[
i].Name = attrib.first;
999 pSeq[
i].Value = attrib.second;
1005 css::uno::Sequence< css::beans::PropertyValue > aGraphicSeq{
1010 pSeq[
i].Name =
"OriginalGraphic";
1011 pSeq[
i].Value <<= aGraphicSeq;
1015 aRet.Value <<=
aSeq;
1034 case OOX_TOKEN( a14, artisticBlur ):
return "artisticBlur";
1035 case OOX_TOKEN( a14, artisticCement ):
return "artisticCement";
1036 case OOX_TOKEN( a14, artisticChalkSketch ):
return "artisticChalkSketch";
1037 case OOX_TOKEN( a14, artisticCrisscrossEtching ):
return "artisticCrisscrossEtching";
1038 case OOX_TOKEN( a14, artisticCutout ):
return "artisticCutout";
1039 case OOX_TOKEN( a14, artisticFilmGrain ):
return "artisticFilmGrain";
1040 case OOX_TOKEN( a14, artisticGlass ):
return "artisticGlass";
1041 case OOX_TOKEN( a14, artisticGlowDiffused ):
return "artisticGlowDiffused";
1042 case OOX_TOKEN( a14, artisticGlowEdges ):
return "artisticGlowEdges";
1043 case OOX_TOKEN( a14, artisticLightScreen ):
return "artisticLightScreen";
1044 case OOX_TOKEN( a14, artisticLineDrawing ):
return "artisticLineDrawing";
1045 case OOX_TOKEN( a14, artisticMarker ):
return "artisticMarker";
1046 case OOX_TOKEN( a14, artisticMosiaicBubbles ):
return "artisticMosiaicBubbles";
1047 case OOX_TOKEN( a14, artisticPaintStrokes ):
return "artisticPaintStrokes";
1048 case OOX_TOKEN( a14, artisticPaintBrush ):
return "artisticPaintBrush";
1049 case OOX_TOKEN( a14, artisticPastelsSmooth ):
return "artisticPastelsSmooth";
1050 case OOX_TOKEN( a14, artisticPencilGrayscale ):
return "artisticPencilGrayscale";
1051 case OOX_TOKEN( a14, artisticPencilSketch ):
return "artisticPencilSketch";
1052 case OOX_TOKEN( a14, artisticPhotocopy ):
return "artisticPhotocopy";
1053 case OOX_TOKEN( a14, artisticPlasticWrap ):
return "artisticPlasticWrap";
1054 case OOX_TOKEN( a14, artisticTexturizer ):
return "artisticTexturizer";
1055 case OOX_TOKEN( a14, artisticWatercolorSponge ):
return "artisticWatercolorSponge";
1056 case OOX_TOKEN( a14, brightnessContrast ):
return "brightnessContrast";
1057 case OOX_TOKEN( a14, colorTemperature ):
return "colorTemperature";
1058 case OOX_TOKEN( a14, saturation ):
return "saturation";
1059 case OOX_TOKEN( a14, sharpenSoften ):
return "sharpenSoften";
1062 case XML_visible:
return "visible";
1063 case XML_trans:
return "trans";
1064 case XML_crackSpacing:
return "crackSpacing";
1065 case XML_pressure:
return "pressure";
1066 case XML_numberOfShades:
return "numberOfShades";
1067 case XML_grainSize:
return "grainSize";
1068 case XML_intensity:
return "intensity";
1069 case XML_smoothness:
return "smoothness";
1070 case XML_gridSize:
return "gridSize";
1071 case XML_pencilSize:
return "pencilSize";
1072 case XML_size:
return "size";
1073 case XML_brushSize:
return "brushSize";
1074 case XML_scaling:
return "scaling";
1075 case XML_detail:
return "detail";
1076 case XML_bright:
return "bright";
1077 case XML_contrast:
return "contrast";
1078 case XML_colorTemp:
return "colorTemp";
1079 case XML_sat:
return "sat";
1080 case XML_amount:
return "amount";
1082 SAL_WARN(
"oox.drawingml",
"ArtisticEffectProperties::getEffectString: unexpected token " <<
nToken );
1089 if(
sName ==
"artisticBlur" )
1090 return XML_artisticBlur;
1091 else if(
sName ==
"artisticCement" )
1092 return XML_artisticCement;
1093 else if(
sName ==
"artisticChalkSketch" )
1094 return XML_artisticChalkSketch;
1095 else if(
sName ==
"artisticCrisscrossEtching" )
1096 return XML_artisticCrisscrossEtching;
1097 else if(
sName ==
"artisticCutout" )
1098 return XML_artisticCutout;
1099 else if(
sName ==
"artisticFilmGrain" )
1100 return XML_artisticFilmGrain;
1101 else if(
sName ==
"artisticGlass" )
1102 return XML_artisticGlass;
1103 else if(
sName ==
"artisticGlowDiffused" )
1104 return XML_artisticGlowDiffused;
1105 else if(
sName ==
"artisticGlowEdges" )
1106 return XML_artisticGlowEdges;
1107 else if(
sName ==
"artisticLightScreen" )
1108 return XML_artisticLightScreen;
1109 else if(
sName ==
"artisticLineDrawing" )
1110 return XML_artisticLineDrawing;
1111 else if(
sName ==
"artisticMarker" )
1112 return XML_artisticMarker;
1113 else if(
sName ==
"artisticMosiaicBubbles" )
1114 return XML_artisticMosiaicBubbles;
1115 else if(
sName ==
"artisticPaintStrokes" )
1116 return XML_artisticPaintStrokes;
1117 else if(
sName ==
"artisticPaintBrush" )
1118 return XML_artisticPaintBrush;
1119 else if(
sName ==
"artisticPastelsSmooth" )
1120 return XML_artisticPastelsSmooth;
1121 else if(
sName ==
"artisticPencilGrayscale" )
1122 return XML_artisticPencilGrayscale;
1123 else if(
sName ==
"artisticPencilSketch" )
1124 return XML_artisticPencilSketch;
1125 else if(
sName ==
"artisticPhotocopy" )
1126 return XML_artisticPhotocopy;
1127 else if(
sName ==
"artisticPlasticWrap" )
1128 return XML_artisticPlasticWrap;
1129 else if(
sName ==
"artisticTexturizer" )
1130 return XML_artisticTexturizer;
1131 else if(
sName ==
"artisticWatercolorSponge" )
1132 return XML_artisticWatercolorSponge;
1133 else if(
sName ==
"brightnessContrast" )
1134 return XML_brightnessContrast;
1135 else if(
sName ==
"colorTemperature" )
1136 return XML_colorTemperature;
1137 else if(
sName ==
"saturation" )
1138 return XML_saturation;
1139 else if(
sName ==
"sharpenSoften" )
1140 return XML_sharpenSoften;
1143 else if(
sName ==
"visible" )
1145 else if(
sName ==
"trans" )
1147 else if(
sName ==
"crackSpacing" )
1148 return XML_crackSpacing;
1149 else if(
sName ==
"pressure" )
1150 return XML_pressure;
1151 else if(
sName ==
"numberOfShades" )
1152 return XML_numberOfShades;
1153 else if(
sName ==
"grainSize" )
1154 return XML_grainSize;
1155 else if(
sName ==
"intensity" )
1156 return XML_intensity;
1157 else if(
sName ==
"smoothness" )
1158 return XML_smoothness;
1159 else if(
sName ==
"gridSize" )
1160 return XML_gridSize;
1161 else if(
sName ==
"pencilSize" )
1162 return XML_pencilSize;
1163 else if(
sName ==
"size" )
1165 else if(
sName ==
"brushSize" )
1166 return XML_brushSize;
1167 else if(
sName ==
"scaling" )
1169 else if(
sName ==
"detail" )
1171 else if(
sName ==
"bright" )
1173 else if(
sName ==
"contrast" )
1174 return XML_contrast;
1175 else if(
sName ==
"colorTemp" )
1176 return XML_colorTemp;
1177 else if(
sName ==
"sat" )
1179 else if(
sName ==
"amount" )
1182 SAL_WARN(
"oox.drawingml",
"ArtisticEffectProperties::getEffectToken - unexpected token name: " <<
sName );
bool Convert(BmpConversion eConversion)
bool Mirror(BmpMirrorFlags nMirrorFlags)
bool Crop(const tools::Rectangle &rRectPixel)
const Size & GetSizePixel() const
css::uno::Reference< css::graphic::XGraphic > GetXGraphic() const
void setOriginURL(OUString const &rOriginURL)
constexpr tools::Long Height() const
constexpr tools::Long Width() const
Provides helper functions for colors, device measurement conversion, graphics, and graphic objects ha...
css::awt::Size getOriginalSize(const css::uno::Reference< css::graphic::XGraphic > &rxGraphic) const
calculates the original size of a graphic which is necessary to be able to calculate cropping values
css::awt::Size convertScreenPixelToHmm(const css::awt::Size &rPixel) const
Converts the passed size from screen pixels to 1/100 mm.
A helper that maps property identifiers to property values.
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.
bool setProperty(sal_Int32 nPropId, Type &&rValue)
Sets the specified property to the passed value.
sal_Int16 getTintOrShade() const
sal_Int16 getLumMod() const
sal_Int16 getTransparency() const
Returns the transparency of the color (0 = opaque, 100 = full transparent).
void assignIfUsed(const Color &rColor)
Overwrites this color with the passed color, if it is used.
sal_Int16 getLumOff() const
bool isUsed() const
Returns true, if the color is initialized.
bool hasTransparency() const
Returns true, if the color is transparent.
sal_Int16 getSchemeColorIndex() const
::Color getColor(const GraphicHelper &rGraphicHelper, ::Color nPhClr=API_RGB_TRANSPARENT) const
Returns the final RGB color value.
bool setProperty(ShapeProperty ePropId, const Type &rValue)
Sets the specified shape property to the passed value.
bool supportsProperty(ShapeProperty ePropId) const
Returns true, if the specified property is supported.
static drawing::Hatch createHatch(sal_Int32 nHatchToken, ::Color nColor)
Sequence< sal_Int8 > aSeq
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
tools::Long const nBorder
enum SAL_DLLPUBLIC_RTTI FillStyle
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
@ FillBitmap
Explicit fill bitmap or name of a fill bitmap stored in a global container.
@ FillBitmapRectanglePoint
@ FillGradient
Explicit fill gradient or name of a fill gradient stored in a global container.
@ FillHatch
Explicit fill hatch or name of a fill hatch stored in a global container.
const sal_Int32 MAX_PERCENT
const sal_Int32 PER_DEGREE
const sal_Int32 PER_PERCENT
void assignIfUsed(std::optional< Type > &rDestValue, const std::optional< Type > &rSourceValue)
const ::Color API_RGB_TRANSPARENT(ColorTransparency, 0xffffffff)
Transparent color for API calls.
bool isEmpty() const
The original graphic as embedded object.
css::beans::PropertyValue getEffect()
Returns the struct as a PropertyValue with Name = msName and Value = maAttribs as a Sequence< Propert...
void assignUsed(const ArtisticEffectProperties &rSourceProps)
Overwrites all members that are explicitly set in rSourceProps.
::oox::ole::OleObjectInfo mrOleObjectInfo
std::map< OUString, css::uno::Any > maAttribs
static OUString getEffectString(sal_Int32 nToken)
Translate effect tokens to strings.
static sal_Int32 getEffectToken(const OUString &sName)
Translate effect strings to tokens.
std::optional< css::geometry::IntegerRectangle2D > moClipRect
Stretch fill offsets.
Color maColorChangeTo
Start color of color transformation.
std::optional< css::geometry::IntegerRectangle2D > moFillRect
Bitmap tile or stretch.
std::optional< sal_Int32 > moColorEffect
True = rotate bitmap with shape.
std::optional< sal_Int32 > moBitmapMode
The fill graphic.
std::optional< sal_Int32 > moTileFlip
Anchor point inside bitmap.
Color maDuotoneColors[2]
Destination color of color transformation.
std::optional< sal_Int32 > moAlphaModFix
Artistic effect, not supported by core.
std::optional< sal_Int32 > moTileScaleY
Horizontal scaling of bitmap tiles (1/1000 percent).
std::optional< sal_Int32 > moTileOffsetY
Width of bitmap tiles (EMUs).
std::optional< sal_Int32 > moBrightness
XML token for a color effect.
Color maColorChangeFrom
Contrast in the range [-100000,100000].
std::optional< bool > moRotateWithShape
Flip mode of bitmap tiles.
css::uno::Reference< css::graphic::XGraphic > mxFillGraphic
ArtisticEffectProperties maEffect
Duotone Colors.
void assignUsed(const BlipFillProperties &rSourceProps)
Overwrites all members that are explicitly set in rSourceProps.
std::optional< sal_Int32 > moTileAlign
Vertical scaling of bitmap tiles (1/1000 percent).
std::optional< sal_Int32 > moTileScaleX
Height of bitmap tiles (EMUs).
std::optional< sal_Int32 > moTileOffsetX
std::optional< sal_Int32 > moContrast
Brightness in the range [-100000,100000].
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.
PatternFillProperties maPatternProps
Properties for gradient fills.
GradientFillProperties maGradientProps
Whether the background is used as fill type.
BlipFillProperties maBlipProps
Properties for pattern fills.
void assignUsed(const FillProperties &rSourceProps)
Properties for bitmap fills.
Color getBestSolidColor() const
Tries to resolve current settings to a solid color, e.g.
std::optional< bool > moUseBgFill
Solid fill color and transparence.
Color maFillColor
Fill type (OOXML token).
std::optional< sal_Int32 > moFillType
std::optional< css::geometry::IntegerRectangle2D > moFillToRect
Gradient stops (colors/transparence).
std::optional< sal_Int32 > moShadeFlip
Rotation angle of linear gradients.
std::optional< bool > moRotateWithShape
True = scale gradient into shape.
std::optional< sal_Int32 > moGradientPath
void assignUsed(const GradientFillProperties &rSourceProps)
True = rotate gradient with shape.
std::optional< css::geometry::IntegerRectangle2D > moTileRect
std::optional< bool > moShadeScaled
Flip mode of gradient, if not stretched to shape.
std::optional< sal_Int32 > moShadeAngle
If set, gradient follows rectangle, circle, or shape.
GradientStopMap maGradientStops
::std::multimap< double, Color > GradientStopMap
OUString m_sMediaPackageURL
Audio/Video URL.
css::uno::Reference< css::io::XInputStream > m_xMediaStream
Audio/Video input stream.
void pushToPropMap(PropertyMap &rPropMap, const GraphicHelper &rGraphicHelper, bool bFlipH=false, bool bFlipV=false) const
Writes the properties to the passed property map.
BlipFillProperties maBlipProps
Properties for the graphic.
Color maPattBgColor
Pattern foreground color.
std::optional< sal_Int32 > moPattPreset
Pattern background color.
void assignUsed(const PatternFillProperties &rSourceProps)
Preset pattern type.
StreamDataSequence maEmbeddedData
Data of an embedded OLE object.