26#include <com/sun/star/beans/NamedValue.hpp>
27#include <com/sun/star/awt/Rectangle.hpp>
28#include <com/sun/star/animations/ValuePair.hpp>
29#include <com/sun/star/drawing/FillStyle.hpp>
30#include <com/sun/star/drawing/LineStyle.hpp>
31#include <com/sun/star/awt/FontSlant.hpp>
61 class NamedValueComparator
64 explicit NamedValueComparator(
const beans::NamedValue& rKey ) :
69 bool operator()(
const beans::NamedValue& rValue )
const
71 return rValue.Name ==
mrKey.Name && rValue.Value ==
mrKey.Value;
82 const basegfx::B2DSize rSize(rShapeBounds.getRange().getX(), rShapeBounds.getRange().getY());
84 const double nShearX( pAttr->isShearXAngleValid() ?
85 pAttr->getShearXAngle() :
87 const double nShearY( pAttr->isShearYAngleValid() ?
88 pAttr->getShearYAngle() :
90 const double nRotation( pAttr->isRotationAngleValid() ?
100 aTransform.
scale( ::basegfx::pruneScaleValue(
102 ::basegfx::pruneScaleValue(
105 const bool bNeedShearX( !::basegfx::fTools::equalZero(nShearX) );
106 const bool bNeedShearY( !::basegfx::fTools::equalZero(nShearY) );
107 const bool bNeedRotation( !::basegfx::fTools::equalZero(nRotation) );
109 if( bNeedRotation || bNeedShearX || bNeedShearY )
112 aTransform.
shearX( nShearX );
115 aTransform.
shearY( nShearY );
118 aTransform.
rotate( nRotation );
126 aTransform.
translate( rShapeBounds.getCenterX(),
127 rShapeBounds.getCenterY() );
140 const ::basegfx::B2DVector& rSlideBounds )
143 if( rSourceAny >>= o_rValue)
151 if( !(rSourceAny >>= aString) )
161 rShape->getBounds()) ))(0.0);
175 const ::basegfx::B2DVector& )
178 if( rSourceAny >>= o_rValue)
185 drawing::FillStyle eFillStyle;
186 if( rSourceAny >>= eFillStyle )
188 o_rValue = sal::static_int_cast<sal_Int16>(eFillStyle);
194 drawing::LineStyle eLineStyle;
195 if( rSourceAny >>= eLineStyle )
197 o_rValue = sal::static_int_cast<sal_Int16>(eLineStyle);
203 awt::FontSlant eFontSlant;
204 if( rSourceAny >>= eFontSlant )
206 o_rValue = sal::static_int_cast<sal_Int16>(eFontSlant);
220 const ::basegfx::B2DVector& rSlideBounds )
223 if( !
extractValue(aValue,rSourceAny,rShape,rSlideBounds) )
226 if( std::numeric_limits<sal_Int16>::max() < aValue ||
227 std::numeric_limits<sal_Int16>::min() > aValue )
232 o_rValue =
static_cast<sal_Int16
>(aValue);
241 const ::basegfx::B2DVector& )
246 if( rSourceAny >>= nTmp )
248 sal_uInt32 aIntColor(
static_cast< sal_uInt32
>(nTmp) );
261 if( rSourceAny >>= aTmp )
264 "extractValue(): inappropriate length for RGB color value" );
266 o_rValue =
RGBColor( aTmp[0], aTmp[1], aTmp[2] );
276 if( rSourceAny >>= aTmp )
279 "extractValue(): inappropriate length for RGB color value" );
282 o_rValue =
RGBColor( ::cppcanvas::makeColor(
296 if( rSourceAny >>= aTmp )
299 "extractValue(): inappropriate length for RGB color value" );
301 o_rValue =
RGBColor( ::cppcanvas::makeColor( aTmp[0], aTmp[1], aTmp[2], 255 ) );
310 if( !(rSourceAny >>= aString) )
314 o_rValue =
RGBColor( 0.5, 0.5, 0.5 );
323 const ::basegfx::B2DVector& )
328 if( rSourceAny >>= aTmp )
331 "extractValue(): inappropriate length for HSL color value" );
333 o_rValue =
HSLColor( aTmp[0], aTmp[1], aTmp[2] );
343 if( rSourceAny >>= aTmp )
346 "extractValue(): inappropriate length for HSL color value" );
348 o_rValue =
HSLColor( aTmp[0]*360.0/255.0, aTmp[1]/255.0, aTmp[2]/255.0 );
362 const ::basegfx::B2DVector& )
365 return rSourceAny >>= o_rValue;
372 const ::basegfx::B2DVector& )
376 if( rSourceAny >>= bTmp )
386 if( !(rSourceAny >>= aString) )
391 if( aString.equalsIgnoreAsciiCase(
"true") ||
392 aString.equalsIgnoreAsciiCase(
"on") )
397 if( aString.equalsIgnoreAsciiCase(
"false") ||
398 aString.equalsIgnoreAsciiCase(
"off") )
412 const ::basegfx::B2DVector& rSlideBounds )
414 animations::ValuePair aPair;
416 if( !(rSourceAny >>= aPair) )
420 if( !
extractValue( nFirst, aPair.First, rShape, rSlideBounds ) )
424 if( !
extractValue( nSecond, aPair.Second, rShape, rSlideBounds ) )
427 o_rPair.
setX( nFirst );
428 o_rPair.
setY( nSecond );
434 const beans::NamedValue& rSearchKey )
436 return ::std::any_of( rSequence.begin(), rSequence.end(),
437 NamedValueComparator( rSearchKey ) );
462 rShapeBounds.getWidth(), rShapeBounds.getHeight(),
463 rShapeBounds.getMinX(), rShapeBounds.getMinY()));
469 return getAttributedShapeTransformation( rShapeBounds,
475 const ::basegfx::B2DVector& rOrigSize,
482 const double nShearX( pAttr->isShearXAngleValid() ?
483 pAttr->getShearXAngle() :
485 const double nShearY( pAttr->isShearYAngleValid() ?
486 pAttr->getShearYAngle() :
488 const double nRotation( pAttr->isRotationAngleValid() ?
494 aTransform.
translate( -0.5*rPixelSize.getX(),
495 -0.5*rPixelSize.getY() );
497 const ::basegfx::B2DSize aSize(
498 pAttr->isWidthValid() ? pAttr->getWidth() : rOrigSize.getX(),
499 pAttr->isHeightValid() ? pAttr->getHeight() : rOrigSize.getY() );
503 aTransform.
scale( ::basegfx::pruneScaleValue(
505 ::basegfx::pruneScaleValue(
506 rOrigSize.getX() ) ),
507 ::basegfx::pruneScaleValue(
509 ::basegfx::pruneScaleValue(
510 rOrigSize.getY() ) ) );
512 const bool bNeedShearX( !::basegfx::fTools::equalZero(nShearX) );
513 const bool bNeedShearY( !::basegfx::fTools::equalZero(nShearY) );
514 const bool bNeedRotation( !::basegfx::fTools::equalZero(nRotation) );
516 if( bNeedRotation || bNeedShearX || bNeedShearY )
519 aTransform.
shearX( nShearX );
522 aTransform.
shearY( nShearY );
525 aTransform.
rotate( nRotation );
531 aTransform.
translate( 0.5*rPixelSize.getX(),
532 0.5*rPixelSize.getY() );
542 const ::basegfx::B2DHomMatrix& rShapeTransform,
548 pAttr->isCharScaleValid() &&
549 fabs(pAttr->getCharScale()) > 1.0 )
554 const double nCharScale( pAttr->getCharScale() );
558 aTransform.
scale( nCharScale, nCharScale );
562 aTransform *= rShapeTransform;
567 return ::canvas::tools::calcTransformedRectBounds(
574 const ::basegfx::B2DRange& rShapeBounds )
576 return ::basegfx::B2DRectangle(
578 rShapeBounds.getMaxX(),
579 rUnitBounds.getMinX() ),
581 rShapeBounds.getMaxY(),
582 rUnitBounds.getMinY() ),
584 rShapeBounds.getMaxX(),
585 rUnitBounds.getMaxX() ),
587 rShapeBounds.getMaxY(),
588 rUnitBounds.getMaxY() ) );
599 rOrigBounds.isEmpty() )
611 aSize.
setWidth( fabs( pAttr->isWidthValid() ?
613 rOrigBounds.getWidth() ) );
614 aSize.
setHeight( fabs( pAttr->isHeightValid() ?
616 rOrigBounds.getHeight() ) );
619 aPos.
setX( pAttr->isPosXValid() ?
621 rOrigBounds.getCenterX() );
622 aPos.
setY( pAttr->isPosYValid() ?
624 rOrigBounds.getCenterY() );
637 ::cppcanvas::makeColor(
640 static_cast< sal_uInt8 >( nColor >> 16U ),
641 static_cast< sal_uInt8 >( nColor >> 8U ),
643 static_cast< sal_uInt8 >( nColor >> 24U ) ) );
648 return ::cppcanvas::makeColorARGB(
652 ::cppcanvas::getRed(aColor),
653 ::cppcanvas::getGreen(aColor),
654 ::cppcanvas::getBlue(aColor));
657 void fillRect( const ::cppcanvas::CanvasSharedPtr& rCanvas,
658 const ::basegfx::B2DRectangle& rRect,
661 const ::basegfx::B2DPolygon aPoly(
662 ::basegfx::utils::createPolygonFromRect( rRect ));
669 pPolyPoly->setRGBAFillColor( aFillColor );
675 const ::basegfx::B2ISize& rSize )
700 aApplicationDocumentColor.
GetGreen(),
701 aApplicationDocumentColor.
GetBlue(),
714 rSize.getHeight()-1 ),
721 uno::UNO_QUERY_THROW );
723 awt::Rectangle aTmpRect;
724 if( !(xPropSet->getPropertyValue(
"BoundRect") >>= aTmpRect) )
727 "getAPIShapeBounds(): Could not get \"BoundRect\" property from shape" );
730 return ::basegfx::B2DRectangle( aTmpRect.X,
732 aTmpRect.X+aTmpRect.Width,
733 aTmpRect.Y+aTmpRect.Height );
770 pView->getTransformation() );
sal_uInt8 GetBlue() const
sal_uInt8 GetGreen() const
void rotate(double fRadiant)
void translate(double fX, double fY)
void scale(double fX, double fY)
B2DVector getRange() const
void setHeight(TYPE const &rHeight)
void setWidth(TYPE const &rWidth)
static PolyPolygonSharedPtr createPolyPolygon(const CanvasSharedPtr &, const ::basegfx::B2DPolygon &rPoly)
static std::shared_ptr< ExpressionNode > const & parseSmilValue(const OUString &rSmilValue, const ::basegfx::B2DRectangle &rRelativeShapeBounds)
Parse a string containing a SMIL value.
#define ENSURE_OR_THROW(c, m)
ValueType lerp(const ValueType &rFrom, const ValueType &rTo, double t)
B2DHomMatrix createScaleTranslateB2DHomMatrix(double fScaleX, double fScaleY, double fTranslateX, double fTranslateY)
B2IRange fround(const B2DRange &rRange)
constexpr double deg2rad(double v)
std::shared_ptr< PolyPolygon > PolyPolygonSharedPtr
IntSRGBA makeColor(sal_uInt8 nRed, sal_uInt8 nGreen, sal_uInt8 nBlue, sal_uInt8 nAlpha)
std::shared_ptr< Canvas > CanvasSharedPtr
::basegfx::B2DRectangle getShapePosSize(const ::basegfx::B2DRectangle &rOrigBounds, const ShapeAttributeLayerSharedPtr &pAttr)
sal_Int32 RGBAColor2UnoColor(::cppcanvas::IntSRGBA aColor)
::basegfx::B2DRectangle getShapeUpdateArea(const ::basegfx::B2DRectangle &rUnitBounds, const ::basegfx::B2DHomMatrix &rShapeTransform, const ShapeAttributeLayerSharedPtr &pAttr)
::std::shared_ptr< ShapeAttributeLayer > ShapeAttributeLayerSharedPtr
basegfx::B2IVector getSlideSizePixel(const basegfx::B2DVector &rSlideSize, const UnoViewSharedPtr &pView)
::basegfx::B2DHomMatrix getShapeTransformation(const ::basegfx::B2DRectangle &rShapeBounds, const ShapeAttributeLayerSharedPtr &pAttr)
bool findNamedValue(uno::Sequence< beans::NamedValue > const &rSequence, const beans::NamedValue &rSearchKey)
::basegfx::B2DRectangle getAPIShapeBounds(const uno::Reference< drawing::XShape > &xShape)
RGBColor unoColor2RGBColor(sal_Int32)
Convert a plain UNO API 32 bit int to RGBColor.
void fillRect(const ::cppcanvas::CanvasSharedPtr &rCanvas, const ::basegfx::B2DRectangle &rRect, ::cppcanvas::IntSRGBA aFillColor)
void initSlideBackground(const ::cppcanvas::CanvasSharedPtr &rCanvas, const ::basegfx::B2ISize &rSize)
::std::shared_ptr< Shape > ShapeSharedPtr
std::shared_ptr< UnoView > UnoViewSharedPtr
bool extractValue(double &o_rValue, const uno::Any &rSourceAny, const ShapeSharedPtr &rShape, const ::basegfx::B2DVector &rSlideBounds)
extract unary double value from Any
::basegfx::B2DHomMatrix getSpriteTransformation(const ::basegfx::B2DVector &rPixelSize, const ::basegfx::B2DVector &rOrigSize, const ShapeAttributeLayerSharedPtr &pAttr)
basegfx::B2DRange calcRelativeShapeBounds(const basegfx::B2DVector &rPageSize, const basegfx::B2DRange &rShapeBounds)
This exception is thrown, when the SMIL arithmetic expression parser failed to parse a string.