23#include <com/sun/star/beans/XPropertySet.hpp>
33#include <com/sun/star/drawing/TextAnimationKind.hpp>
72 mpCurrMtf = std::make_shared<GDIMetaFile>();
87 "DrawShape::forceScrollTextMetaFile(): Could "
88 "not extract scroll anim rectangles from mtf" );
93 if( aScrollRect.
isInside( aPaintRect ) )
130 SAL_INFO(
"slideshow",
"::presentation::internal::DrawShape::implRender()" );
131 SAL_INFO(
"slideshow",
"::presentation::internal::DrawShape: 0x" << std::hex <<
this );
139 "DrawShape::implRender(): render called on DrawShape without views" );
153 [
this, &
bVisible, &renderArgs, &nUpdateFlags]
155 { return pShape->update( this->mpCurrMtf,
234 "DrawShape::getActualUnitShapeBounds(): called on DrawShape without views" );
239 const ::basegfx::B2DRectangle aDefaultBounds( 0.0,0.0,1.0,1.0 );
242 if( rSubsets.empty() )
248 return aDefaultBounds;
252 OSL_ENSURE( rSubsets.size() != 1 ||
253 !rSubsets.front().isEmpty(),
254 "DrawShape::getActualUnitShapeBounds() expects a "
255 "_non-empty_ subset vector for a subsetted shape!" );
294 pDestinationCanvas->setTransformation( aEmptyTransformation );
295 pRenderer->setTransformation( aEmptyTransformation );
298 const ::comphelper::ScopeGuard aGuard(
299 [&pDestinationCanvas, &aOldTransform]()
300 {
return pDestinationCanvas->setTransformation( aOldTransform ); } );
310 for(
const auto& rDocTreeNode : rSubsets )
311 aTotalBounds.
expand( pRenderer->getSubsetArea(
312 rDocTreeNode.getStartIndex(),
313 rDocTreeNode.getEndIndex() ) );
315 OSL_ENSURE( aTotalBounds.getMinX() >= -0.1 &&
316 aTotalBounds.getMinY() >= -0.1 &&
317 aTotalBounds.getMaxX() <= 1.1 &&
318 aTotalBounds.getMaxY() <= 1.1,
319 "DrawShape::getActualUnitShapeBounds(): bounds noticeably larger than original shape - clipping!" );
325 aTotalBounds.intersect(
343 mxPage( xContainingPage ),
347 mnCurrMtfLoadFlags( bForeignSource
349 maCurrentShapeUnitBounds(),
353 mpIntrinsicAnimationActivity(),
354 mnAttributeTransformationState(0),
355 mnAttributeClipState(0),
356 mnAttributeAlphaState(0),
357 mnAttributePositionState(0),
358 mnAttributeContentState(0),
359 mnAttributeVisibilityState(0),
362 maHyperlinkIndices(),
363 maHyperlinkRegions(),
365 mnIsAnimatedCount(0),
366 mnAnimationLoopCount(0),
368 mbForceUpdate( false ),
369 mbAttributeLayerRevoked( false ),
370 mbDrawingLayerAnim( false ),
371 mbContainsPageField( false )
377 drawing::TextAnimationKind eKind = drawing::TextAnimationKind_NONE;
382 "TextAnimationKind" );
391 mpCurrMtf = std::make_shared<GDIMetaFile>();
408 if(fWidthDiff > 1.0 || fHeightDiff > 1.0)
419 uno::Reference< drawing::XDrawPage > xContainingPage,
422 const SlideShowContext& rContext ) :
424 mxPage(
std::move( xContainingPage )),
429 maCurrentShapeUnitBounds(),
433 mpIntrinsicAnimationActivity(),
434 mnAttributeTransformationState(0),
435 mnAttributeClipState(0),
436 mnAttributeAlphaState(0),
437 mnAttributePositionState(0),
438 mnAttributeContentState(0),
439 mnAttributeVisibilityState(0),
442 maHyperlinkIndices(),
443 maHyperlinkRegions(),
445 mnIsAnimatedCount(0),
446 mnAnimationLoopCount(0),
448 mbForceUpdate( false ),
449 mbAttributeLayerRevoked( false ),
450 mbDrawingLayerAnim( false ),
451 mbContainsPageField( false )
454 "DrawShape::DrawShape(): Graphic is no animation" );
462 "DrawShape::DrawShape(): " );
474 mxPage( rSrc.mxPage ),
478 mpCurrMtf( rSrc.mpCurrMtf ),
479 mnCurrMtfLoadFlags( rSrc.mnCurrMtfLoadFlags ),
480 maCurrentShapeUnitBounds(),
484 mpIntrinsicAnimationActivity(),
485 mnAttributeTransformationState(0),
486 mnAttributeClipState(0),
487 mnAttributeAlphaState(0),
488 mnAttributePositionState(0),
489 mnAttributeContentState(0),
490 mnAttributeVisibilityState(0),
493 maHyperlinkIndices(),
494 maHyperlinkRegions(),
495 maSubsetting( rTreeNode, mpCurrMtf ),
496 mnIsAnimatedCount(0),
497 mnAnimationLoopCount(0),
498 mbIsVisible( rSrc.mbIsVisible ),
499 mbForceUpdate( false ),
500 mbAttributeLayerRevoked( false ),
501 mbDrawingLayerAnim( false ),
502 mbContainsPageField( false )
530 if( pShape->hasIntrinsicAnimation() )
532 OSL_ASSERT( pShape->maAnimationFrames.empty() );
533 if( pShape->getNumberOfTreeNodes(
536 pShape->mpIntrinsicAnimationActivity =
543 if( pShape->hasHyperlinks() )
550 const uno::Reference< drawing::XShape >& xShape,
551 const uno::Reference< drawing::XDrawPage >& xContainingPage,
554 const SlideShowContext& rContext )
562 if( pShape->hasIntrinsicAnimation() )
564 OSL_ASSERT( !pShape->maAnimationFrames.empty() );
566 std::vector<double> aTimeout;
568 pShape->maAnimationFrames.begin(),
569 pShape->maAnimationFrames.end(),
570 std::back_insert_iterator< std::vector<double> >( aTimeout ),
574 std::make_shared<WakeupEvent>( rContext.mrEventQueue.getTimer(),
575 rContext.mrActivitiesQueue );
583 pShape->mnAnimationLoopCount);
585 pWakeupEvent->setActivity( pActivity );
586 pShape->mpIntrinsicAnimationActivity = pActivity;
589 OSL_ENSURE( !pShape->hasHyperlinks(),
590 "DrawShape::create(): graphic-only shapes must not have hyperlinks!" );
603 pActivity->dispose();
605 catch (uno::Exception
const &)
624 { return rNewLayer == pShape->getViewLayer(); } ) )
638 pNewShape->enterAnimationMode();
653 const ViewShapeVector::iterator aEnd(
maViewShapes.end() );
659 { return rLayer == pShape->getViewLayer(); } ) < 2,
660 "DrawShape::removeViewLayer(): Duplicate ViewLayer entries!" );
662 ViewShapeVector::iterator aIter;
668 { return rLayer == pShape->getViewLayer(); } ) ) == aEnd )
773 const ::basegfx::B2DSize rShapeBorder( rViewShape->getAntialiasingBorder() );
776 rShapeBorder.getWidth(),
779 rShapeBorder.getHeight(),
837 "DrawShape::setIntrinsicAnimationFrame(): frame index out of bounds" );
858 pCurrAct !=
nullptr; pCurrAct =
mpCurrMtf->NextAction() )
860 if (pCurrAct->GetType() == MetaActionType::COMMENT) {
864 if (pAct->
GetComment().equalsIgnoreAsciiCase(
"FIELD_SEQ_BEGIN") &&
873 SAL_WARN(
"slideshow",
"### pending FIELD_SEQ_END!" );
887 else if (pAct->
GetComment().equalsIgnoreAsciiCase(
"FIELD_SEQ_END") &&
894 else if (pAct->
GetComment().equalsIgnoreAsciiCase(
"FIELD_SEQ_BEGIN;PageField"))
905 SAL_WARN(
"slideshow",
"### pending FIELD_SEQ_END!" );
936 pViewShape->getViewLayer()->getCanvas() );
940 pViewShape->getRenderer(
943 OSL_ASSERT( pRenderer );
948 pCanvas->getTransformation() );
950 pCanvas->setTransformation( aTransform );
955 [&aOldTransform, &pTmpCanvas]()
960 pRenderer->setTransformation( aTransform );
961 pRenderer->setClip();
968 pRenderer->getSubsetArea( rIndices.first,
987 aTranslatedRegions.emplace_back(
994 return aTranslatedRegions;
1009 "DrawShape::enterAnimationMode(): called on DrawShape without views" );
1016 rViewShape->enterAnimationMode();
1025 "DrawShape::leaveAnimationMode(): called on DrawShape without views" );
1034 rViewShape->leaveAnimationMode();
1120 bool bNewlyCreated(
false );
1124 o_rSubset = pSubset;
1141 bNewlyCreated =
true;
1151 return bNewlyCreated;
1177 rShape->getTopmostAttributeLayer() );
1179 rAttrLayer->isVisibilityValid() &&
1180 rAttrLayer->getVisibility() !=
isVisible() )
1182 const bool bVisibility( rAttrLayer->getVisibility() );
1201 return maSubsetting.getNumberOfTreeNodes( eNodeType );
1207 if ( hasHyperlinks())
1209 prepareHyperlinkIndices();
1212 return maSubsetting.getTreeNode( nNodeIndex, eNodeType );
1218 return maSubsetting.getNumberOfSubsetTreeNodes( rParentNode, eNodeType );
1222 sal_Int32 nNodeIndex,
1225 return maSubsetting.getSubsetTreeNode( rParentNode, nNodeIndex, eNodeType );
css::uno::Reference< css::uno::XComponentContext > mxComponentContext
::basegfx::B2DRectangle maBounds
ViewBackgroundShapeVector maViewShapes
void scale(double fX, double fY)
B2DPoint getMaximum() const
B2DPoint getMinimum() const
void expand(const Tuple2D< TYPE > &rTuple)
bool isInside(const Tuple2D< TYPE > &rTuple) const
void setWidth(TYPE const &rWidth)
virtual void setTransformation(const ::basegfx::B2DHomMatrix &rMatrix)=0
Interface to retrieve DocTreeNodes from subsettable shapes.
This class represents kind of a DOM tree node for shape text.
sal_Int32 getStartIndex() const
NodeType
Type of shape entity represented by this node.
@ LogicalParagraph
This node represents a paragraph.
void addSubsetShape(const AttributableShapeSharedPtr &rShape)
Add child subset shape (or increase use count, if already existent)
const DocTreeNode & getSubsetNode() const
Return subset node for this shape.
void reset(const ::std::shared_ptr< GDIMetaFile > &rMtf)
Reset metafile.
bool revokeSubsetShape(const AttributableShapeSharedPtr &rShape)
Revoke subset shape.
AttributableShapeSharedPtr getSubsetShape(const DocTreeNode &rTreeNode) const
Get subset shape for given node, if any.
const VectorOfDocTreeNodes & getActiveSubsets() const
Return a vector of currently active subsets.
This class is the representation of a draw document's XShape, and implements the Shape,...
State::StateId mnAttributeClipState
HyperlinkIndexPairVector maHyperlinkIndices
virtual bool revokeSubset(const AttributableShapeSharedPtr &rShape) override
Revoke a previously generated shape subset.
css::uno::Reference< css::drawing::XDrawPage > mxPage
::basegfx::B2DRectangle getActualUnitShapeBounds() const
virtual bool isContentChanged() const override
Query whether shape content changed.
virtual void addViewLayer(const ViewLayerSharedPtr &rNewLayer, bool bRedrawLayer) override
Add a new view layer.
virtual void leaveAnimationMode() override
Notify the Shape that it is no longer animated.
void setIntrinsicAnimationFrame(::std::size_t nCurrFrame)
Display next frame of an intrinsic animation.
sal_uInt32 mnAnimationLoopCount
Number of times the bitmap animation shall loop.
bool mbDrawingLayerAnim
whether a drawing layer animation has to be performed
int mnIsAnimatedCount
Whether this shape is currently in animation mode (value != 0)
State::StateId mnAttributePositionState
bool implRender(UpdateFlags nUpdateFlags) const
virtual bool update() const override
Update the shape.
static DrawShapeSharedPtr create(const css::uno::Reference< css::drawing::XShape > &xShape, const css::uno::Reference< css::drawing::XDrawPage > &xContainingPage, double nPrio, bool bForeignSource, const SlideShowContext &rContext)
Create a shape for the given XShape.
State::StateId mnAttributeAlphaState
virtual bool isVisible() const override
Query whether the shape is visible at all.
virtual double getPriority() const override
Get the shape priority.
virtual void clearAllViewLayers() override
Withdraw all view layers at once.
GDIMetaFileSharedPtr const & forceScrollTextMetaFile()
forces the drawshape to load and return a specially crafted metafile, usable to display drawing layer...
virtual ShapeAttributeLayerSharedPtr createAttributeLayer() override
Create a new shape attribute layer.
virtual ::basegfx::B2DRectangle getUpdateArea() const override
Get the current shape update area.
ViewShapeVector maViewShapes
DrawShape(const css::uno::Reference< css::drawing::XShape > &xShape, const css::uno::Reference< css::drawing::XDrawPage > &xContainingPage, double nPrio, bool bForeignSource, const SlideShowContext &rContext)
Create a shape for the given XShape.
virtual DocTreeNode getTreeNode(sal_Int32 nNodeIndex, DocTreeNode::NodeType eNodeType) const override
Create DocTreeNode from shape.
mutable ::std::optional< basegfx::B2DRectangle > maCurrentShapeUnitBounds
Contains the current shape bounds, in unit rect space.
::std::pair< sal_Int32, sal_Int32 > HyperlinkIndexPair
hyperlink support
std::weak_ptr< Activity > mpIntrinsicAnimationActivity
virtual ::basegfx::B2DRectangle getDomBounds() const override
Get the DOM position and size of the shape.
GDIMetaFileSharedPtr mpCurrMtf
Metafile of currently active frame (static for shapes w/o intrinsic animation)
virtual void enterAnimationMode() override
Notify the Shape that an animation starts now.
bool mbIsVisible
Whether shape is visible (without attribute layers)
virtual double getHyperlinkPriority() const override
Retrieve priority of link area.
virtual const DocTreeNodeSupplier & getTreeNodeSupplier() const override
Retrieve interface for DocTreeNode creation.
virtual bool render() const override
Render the shape.
virtual DocTreeNode getSubsetTreeNode(const DocTreeNode &rParentNode, sal_Int32 nNodeIndex, DocTreeNode::NodeType eNodeType) const override
Create DocTreeNode from shape subset.
ShapeAttributeLayerSharedPtr mpAttributeLayer
int mnCurrMtfLoadFlags
loadflags of current meta file
::std::size_t mnCurrFrame
bool mbAttributeLayerRevoked
Whether attribute layer was revoked (making a redraw necessary)
UpdateFlags getUpdateFlags() const
DrawShapeSubsetting maSubsetting
Delegated subset handling.
virtual bool createSubset(AttributableShapeSharedPtr &o_rSubset, const DocTreeNode &rTreeNode) override
Create a subset Shape.
VectorOfMtfAnimationFrames maAnimationFrames
A vector of metafiles actually representing the Shape.
void updateStateIds() const
bool hasIntrinsicAnimation() const
State::StateId mnAttributeTransformationState
virtual bool revokeAttributeLayer(const ShapeAttributeLayerSharedPtr &rLayer) override
Revoke a previously generated attribute layer.
virtual HyperlinkRegions getHyperlinkRegions() const override
Request hyperlink-sensitive areas.
State::StateId mnAttributeVisibilityState
virtual DocTreeNode getSubsetNode() const override
Query the subset this shape displays.
css::uno::Reference< css::drawing::XShape > mxShape
The associated XShape.
virtual void setVisibility(bool bVisible) override
Change default shape visibility.
ViewShape::RenderArgs getViewRenderArgs() const
virtual AttributableShapeSharedPtr getSubset(const DocTreeNode &rTreeNode) const override
Query a subset Shape, if already existent at this object.
::basegfx::B2DRectangle maBounds
virtual css::uno::Reference< css::drawing::XShape > getXShape() const override
Get the associated XShape of this shape.
HyperlinkRegions maHyperlinkRegions
virtual bool isBackgroundDetached() const override
Query whether the Shape is currently detached from the background.
virtual ShapeAttributeLayerSharedPtr getTopmostAttributeLayer() const override
Get the topmost shape attribute layer (if any).
State::StateId mnAttributeContentState
css::uno::Reference< css::uno::XComponentContext > mxComponentContext
virtual sal_Int32 getNumberOfTreeNodes(DocTreeNode::NodeType eNodeType) const override
Query number of tree nodes of the given type this shape contains.
bool mbForceUpdate
Whether redraw is necessary, regardless of state ids.
virtual bool removeViewLayer(const ViewLayerSharedPtr &rNewLayer) override
Withdraw the shape from a view layer.
bool mbContainsPageField
tdf#150402 whether mpCurrMtf contains any Text with a PageField ("FIELD_SEQ_BEGIN;PageField")
virtual ~DrawShape() override
void prepareHyperlinkIndices() const
bool hasHyperlinks() const
virtual sal_Int32 getNumberOfSubsetTreeNodes(const DocTreeNode &rParentNode, DocTreeNode::NodeType eNodeType) const override
Query number of tree nodes of the given type this subset contains.
virtual ::basegfx::B2DRectangle getBounds() const override
Get the current shape position and size.
std::vector< HyperlinkRegion > HyperlinkRegions
#define ENSURE_OR_RETURN_FALSE(c, m)
#define ENSURE_OR_THROW(c, m)
#define DBG_UNHANDLED_EXCEPTION(...)
#define ENSURE_OR_RETURN_VOID(c, m)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
std::shared_ptr< ::cppcanvas::Renderer > RendererSharedPtr
std::shared_ptr< Canvas > CanvasSharedPtr
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
::basegfx::B2DRectangle getShapePosSize(const ::basegfx::B2DRectangle &rOrigBounds, const ShapeAttributeLayerSharedPtr &pAttr)
@ MTF_LOAD_FOREIGN_SOURCE
the source of the metafile might be a foreign application.
@ MTF_LOAD_SCROLL_TEXT_MTF
retrieve the drawing layer scroll text metafile
::std::shared_ptr< ViewShape > ViewShapeSharedPtr
::basegfx::B2DRectangle getShapeUpdateArea(const ::basegfx::B2DRectangle &rUnitBounds, const ::basegfx::B2DHomMatrix &rShapeTransform, const ShapeAttributeLayerSharedPtr &pAttr)
::std::shared_ptr< ShapeAttributeLayer > ShapeAttributeLayerSharedPtr
ActivitySharedPtr createIntrinsicAnimationActivity(const SlideShowContext &rContext, const DrawShapeSharedPtr &rDrawShape, const WakeupEventSharedPtr &rWakeupEvent, ::std::vector< double > &&rTimeouts, sal_uInt32 nNumLoops)
Create an IntrinsicAnimationActivity.
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)
::std::vector< DocTreeNode > VectorOfDocTreeNodes
::std::shared_ptr< Activity > ActivitySharedPtr
std::shared_ptr< ViewLayer > ViewLayerSharedPtr
::basegfx::B2DHomMatrix getShapeTransformation(const ::basegfx::B2DRectangle &rShapeBounds, const ShapeAttributeLayerSharedPtr &pAttr)
::std::shared_ptr< DrawShape > DrawShapeSharedPtr
std::shared_ptr< Activity > createDrawingLayerAnimActivity(SlideShowContext const &rContext, std::shared_ptr< DrawShape > const &pDrawShape)
::basegfx::B2DRectangle getAPIShapeBounds(const uno::Reference< drawing::XShape > &xShape)
std::shared_ptr< GDIMetaFile > GDIMetaFileSharedPtr
bool getRectanglesFromScrollMtf(::basegfx::B2DRectangle &o_rScrollRect, ::basegfx::B2DRectangle &o_rPaintRect, const GDIMetaFileSharedPtr &rMtf)
Retrieve scroll text animation rectangles from given metafile.
bool getAnimationFromGraphic(VectorOfMtfAnimationFrames &o_rFrames, sal_uInt32 &o_rLoopCount, const Graphic &rGraphic)
Extract a vector of animation frames from given Graphic.
GDIMetaFileSharedPtr getMetaFile(const uno::Reference< lang::XComponent > &xSource, const uno::Reference< drawing::XDrawPage > &xContainingPage, int mtfLoadFlags, const uno::Reference< uno::XComponentContext > &rxContext)
sal_Int32 getNextActionOffset(MetaAction *pCurrAct)
Gets the next action offset for iterating meta actions which is most often returns 1.
::std::shared_ptr< AttributableShape > AttributableShapeSharedPtr
::std::shared_ptr< WakeupEvent > WakeupEventSharedPtr
uno::Reference< drawing::XShape > const mxShape
double getDuration() const
Enables STL algos to be used for duration extraction.
Common arguments for slideshow objects.
std::shared_ptr< SubsettableShapeManager > & mpSubsettableShapeManager