21#include <osl/diagnose.hxx>
28#include <com/sun/star/awt/SystemPointer.hpp>
29#include <com/sun/star/drawing/XMasterPageTarget.hpp>
30#include <com/sun/star/beans/XPropertySet.hpp>
31#include <com/sun/star/presentation/ParagraphTarget.hpp>
32#include <com/sun/star/presentation/EffectNodeType.hpp>
63class SlideImpl :
public Slide,
65 public ViewEventHandler,
66 public ::osl::DebugBase<SlideImpl>
69 SlideImpl(
const uno::Reference<drawing::XDrawPage>& xDrawPage,
70 uno::Reference<drawing::XDrawPagesSupplier> xDrawPages,
71 uno::Reference<animations::XAnimationNode> xRootNode,
72 EventQueue& rEventQueue,
73 EventMultiplexer& rEventMultiplexer,
74 ScreenUpdater& rScreenUpdater,
75 ActivitiesQueue& rActivitiesQueue,
76 UserEventQueue& rUserEventQueue,
77 CursorManager& rCursorManager,
78 MediaFileManager& rMediaFileManager,
79 const UnoViewContainer& rViewContainer,
80 const uno::Reference<uno::XComponentContext>& xContext,
84 RGBColor
const& rUserPaintColor,
85 double dUserPaintStrokeWidth,
86 bool bUserPaintEnabled,
87 bool bIntrinsicAnimationsAllowed,
88 bool bDisableAnimationZOrder );
90 virtual ~SlideImpl()
override;
96 virtual void prefetch()
override;
97 virtual void show(
bool )
override;
98 virtual void hide()
override;
101 virtual uno::Reference<drawing::XDrawPage > getXDrawPage()
const override;
102 virtual uno::Reference<animations::XAnimationNode> getXAnimationNode()
const override;
104 virtual void drawPolygons()
const override;
105 virtual bool isPaintOverlayActive()
const override;
106 virtual void enablePaintOverlay()
override;
107 virtual void update_settings(
bool bUserPaintEnabled, RGBColor
const& aUserPaintColor,
double dUserPaintStrokeWidth )
override;
120 virtual void viewsChanged()
override;
123 virtual bool requestCursor( sal_Int16 nCursorShape )
override;
124 virtual void resetCursor()
override;
126 void activatePaintOverlay();
127 void deactivatePaintOverlay();
142 bool applyInitialShapeAttributes(
const css::uno::Reference< css::animations::XAnimationNode >& xRootAnimationNode );
145 void applyShapeAttributes(
146 const css::uno::Reference< css::animations::XAnimationNode >& xRootAnimationNode,
147 bool bInitial)
const;
161 bool implPrefetchShow();
169 enum SlideAnimationState
171 CONSTRUCTING_STATE=0,
175 SlideAnimationState_NUM_ENTRIES=4
178 typedef std::vector< SlideBitmapSharedPtr > VectorOfSlideBitmaps;
186 VectorOfSlideBitmaps > > VectorOfVectorOfSlideBitmaps;
264void slideRenderer( SlideImpl
const * pSlide,
const UnoViewSharedPtr& rView )
272 const ::basegfx::B2DHomMatrix aViewTransform( rView->getTransformation() );
281 pBitmap->move( aOutPosPixel );
286 pBitmap->draw( pDevicePixelCanvas );
290SlideImpl::SlideImpl(
const uno::Reference< drawing::XDrawPage >& xDrawPage,
291 uno::Reference<drawing::XDrawPagesSupplier> xDrawPages,
292 uno::Reference< animations::XAnimationNode > xRootNode,
293 EventQueue& rEventQueue,
294 EventMultiplexer& rEventMultiplexer,
295 ScreenUpdater& rScreenUpdater,
296 ActivitiesQueue& rActivitiesQueue,
297 UserEventQueue& rUserEventQueue,
298 CursorManager& rCursorManager,
299 MediaFileManager& rMediaFileManager,
300 const UnoViewContainer& rViewContainer,
301 const uno::Reference< uno::XComponentContext >& xComponentContext,
305 RGBColor
const& aUserPaintColor,
306 double dUserPaintStrokeWidth,
307 bool bUserPaintEnabled,
308 bool bIntrinsicAnimationsAllowed,
309 bool bDisableAnimationZOrder ) :
315 bDisableAnimationZOrder) ),
325 basegfx::B2DVector(getSlideSizeImpl().getWidth(), getSlideSizeImpl().getHeight()) ) ),
339 basegfx::B2DVector(getSlideSizeImpl().getWidth(), getSlideSizeImpl().getHeight()) ),
359 for(
const auto& rView : rViewContainer )
367void SlideImpl::update_settings(
bool bUserPaintEnabled, RGBColor
const& aUserPaintColor,
double dUserPaintStrokeWidth )
374SlideImpl::~SlideImpl()
388void SlideImpl::prefetch()
395 std::vector<Graphic*> graphics;
403 if( !grafObj->GetGraphic().isAvailable())
404 graphics.push_back(
const_cast<Graphic*
>(&grafObj->GetGraphic()));
406 if(graphics.size() > 1)
412void SlideImpl::show(
bool bSlideBackgroundPainted )
422 if( !applyInitialShapeAttributes(
mxRootNode) )
437 if( !bSlideBackgroundPainted )
439 for(
const auto& rContext :
maContext.mrViewContainer )
440 slideRenderer(
this, rContext );
442 maContext.mrScreenUpdater.notifyUpdate();
447 const bool bIsAnimated( isAnimated() );
464 maContext.mrEventMultiplexer.notifySlideAnimationsEnd();
473 activatePaintOverlay();
480void SlideImpl::hide()
492 deactivatePaintOverlay();
516uno::Reference<drawing::XDrawPage > SlideImpl::getXDrawPage()
const
521uno::Reference<animations::XAnimationNode> SlideImpl::getXAnimationNode()
const
537 VectorOfVectorOfSlideBitmaps::iterator aIter;
538 const VectorOfVectorOfSlideBitmaps::iterator aEnd(
maSlideBitmaps.end() );
542 (
const VectorOfVectorOfSlideBitmaps::value_type& cp )
543 { return rView == cp.first; } ) ) == aEnd )
548 "SlideImpl::getInitialSlideBitmap(): view does not "
549 "match any of the added ones" );
565 if( !
const_cast<SlideImpl*
>(
this)->applyInitialShapeAttributes(
mxRootNode ) )
567 "SlideImpl::getCurrentSlideBitmap(): Cannot "
568 "apply initial attributes");
577 if( !rBitmap || rBitmap->getSize() != rSlideSize )
580 rBitmap = createCurrentSlideBitmap(rView, rSlideSize);
593 VectorOfSlideBitmaps(SlideAnimationState_NUM_ENTRIES) );
604 const VectorOfVectorOfSlideBitmaps::iterator aEnd(
maSlideBitmaps.end() );
609 (
const VectorOfVectorOfSlideBitmaps::value_type& cp )
610 { return rView == cp.first; } ),
622void SlideImpl::viewsChanged()
630bool SlideImpl::requestCursor( sal_Int16 nCursorShape )
636void SlideImpl::resetCursor()
642bool SlideImpl::isAnimated()
645 if( !implPrefetchShow() )
652 const ::basegfx::B2ISize& rBmpSize )
const
655 "SlideImpl::createCurrentSlideBitmap(): Invalid view" );
657 "SlideImpl::createCurrentSlideBitmap(): Invalid layer manager" );
659 "SlideImpl::createCurrentSlideBitmap(): No show loaded" );
678 "SlideImpl::createCurrentSlideBitmap(): Cannot create page bitmap" );
683 "SlideImpl::createCurrentSlideBitmap(): Cannot create page bitmap canvas" );
688 aLinearTransform.set( 0, 2, 0.0 );
689 aLinearTransform.set( 1, 2, 0.0 );
690 pBitmapCanvas->setTransformation( aLinearTransform );
696 return std::make_shared<SlideBitmap>( pBitmap );
699class MainSequenceSearcher
702 MainSequenceSearcher()
705 maSearchKey.Value <<= presentation::EffectNodeType::MAIN_SEQUENCE;
708 void operator()(
const uno::Reference< animations::XAnimationNode >& xChildNode )
710 uno::Sequence< beans::NamedValue > aUserData( xChildNode->getUserData() );
718 const uno::Reference< animations::XAnimationNode >& getMainSequence()
const
728bool SlideImpl::implPrefetchShow()
734 "SlideImpl::implPrefetchShow(): Invalid draw page" );
736 "SlideImpl::implPrefetchShow(): Invalid layer manager" );
753 OSL_FAIL(
"SlideImpl::implPrefetchShow(): have animation nodes, "
754 "but import animations failed." );
769 MainSequenceSearcher aSearcher;
777 catch( uno::RuntimeException& )
781 catch( uno::Exception& )
792void SlideImpl::enablePaintOverlay()
797 activatePaintOverlay();
801void SlideImpl::activatePaintOverlay()
814void SlideImpl::drawPolygons()
const
825bool SlideImpl::isPaintOverlayActive()
const
830void SlideImpl::deactivatePaintOverlay()
839void SlideImpl::applyShapeAttributes(
840 const css::uno::Reference< css::animations::XAnimationNode >& xRootAnimationNode,
843 const uno::Sequence< animations::TargetProperties > aProps(
847 for(
const auto& rProp : aProps )
849 sal_Int16 nParaIndex( -1 );
850 uno::Reference< drawing::XShape > xShape( rProp.Target,
856 presentation::ParagraphTarget aParaTarget;
858 if( rProp.Target >>= aParaTarget )
862 xShape = aParaTarget.Shape;
863 nParaIndex = aParaTarget.Paragraph;
873 OSL_FAIL(
"SlideImpl::applyInitialShapeAttributes(): no shape found for given target" );
878 ::std::dynamic_pointer_cast< AttributableShape >( pShape ) );
882 OSL_FAIL(
"SlideImpl::applyInitialShapeAttributes(): shape found does not "
883 "implement AttributableShape interface" );
887 if( nParaIndex != -1 )
891 const DocTreeNodeSupplier& rNodeSupplier( pAttrShape->getTreeNodeSupplier() );
893 if( rNodeSupplier.getNumberOfTreeNodes(
894 DocTreeNode::NodeType::LogicalParagraph ) <= nParaIndex )
896 OSL_FAIL(
"SlideImpl::applyInitialShapeAttributes(): shape found does not "
897 "provide a subset for requested paragraph index" );
901 pAttrShape = pAttrShape->getSubset(
902 rNodeSupplier.getTreeNode(
904 DocTreeNode::NodeType::LogicalParagraph ) );
908 OSL_FAIL(
"SlideImpl::applyInitialShapeAttributes(): shape found does not "
909 "provide a subset for requested paragraph index" );
914 const uno::Sequence< beans::NamedValue >& rShapeProps( rProp.Properties );
915 for(
const auto& rShapeProp : rShapeProps )
918 if( rShapeProp.Name.equalsIgnoreAsciiCase(
"visibility") &&
924 pAttrShape->setVisibility( bVisible );
928 OSL_FAIL(
"SlideImpl::applyInitialShapeAttributes(): Unexpected "
929 "(and unimplemented) property encountered" );
936bool SlideImpl::applyInitialShapeAttributes(
937 const uno::Reference< animations::XAnimationNode >& xRootAnimationNode )
939 if( !implPrefetchShow() )
942 if( !xRootAnimationNode.is() )
950 applyShapeAttributes(xRootAnimationNode,
true);
957bool SlideImpl::loadShapes()
963 "SlideImpl::loadShapes(): Invalid draw page" );
965 "SlideImpl::loadShapes(): Invalid layer manager" );
971 uno::Reference< drawing::XDrawPage > xMasterPage;
972 uno::Reference< drawing::XShapes > xMasterPageShapes;
973 sal_Int32 nCurrCount(0);
975 uno::Reference< drawing::XMasterPageTarget > xMasterPageTarget(
mxDrawPage,
977 if( xMasterPageTarget.is() )
979 xMasterPage = xMasterPageTarget->getMasterPage();
980 xMasterPageShapes = xMasterPage;
982 if( xMasterPage.is() && xMasterPageShapes.is() )
991 ShapeImporter aMPShapesFunctor( xMasterPage,
999 aMPShapesFunctor.importBackgroundShape() );
1001 while( !aMPShapesFunctor.isImportDone() )
1004 aMPShapesFunctor.importShape() );
1007 rShape->setIsForeground(
false);
1011 addPolygons(aMPShapesFunctor.getPolygons());
1013 nCurrCount =
static_cast<sal_Int32
>(aMPShapesFunctor.getImportedShapesCount());
1015 catch( uno::RuntimeException& )
1019 catch( ShapeLoadFailedException& )
1022 TOOLS_WARN_EXCEPTION(
"slideshow",
"SlideImpl::loadShapes(): caught ShapeLoadFailedException" );
1026 catch( uno::Exception& )
1046 while( !aShapesFunctor.isImportDone() )
1049 aShapesFunctor.importShape() );
1053 addPolygons(aShapesFunctor.getPolygons());
1055 catch( uno::RuntimeException& )
1059 catch( ShapeLoadFailedException& )
1062 TOOLS_WARN_EXCEPTION(
"slideshow",
"SlideImpl::loadShapes(): caught ShapeLoadFailedException" );
1065 catch( uno::Exception& )
1078 uno::Reference< beans::XPropertySet > xPropSet(
1081 sal_Int32 nDocWidth = 0;
1082 sal_Int32 nDocHeight = 0;
1083 xPropSet->getPropertyValue(
"Width") >>= nDocWidth;
1084 xPropSet->getPropertyValue(
"Height") >>= nDocHeight;
1100 CursorManager& rCursorManager,
1108 double dUserPaintStrokeWidth,
1109 bool bUserPaintEnabled,
1110 bool bIntrinsicAnimationsAllowed,
1111 bool bDisableAnimationZOrder )
1113 auto pRet = std::make_shared<SlideImpl>( xDrawPage, xDrawPages, xRootNode, rEventQueue,
1114 rEventMultiplexer, rScreenUpdater,
1115 rActivitiesQueue, rUserEventQueue,
1116 rCursorManager, rMediaFileManager, rViewContainer,
1117 xComponentContext, rShapeListenerMap,
1118 rShapeCursorMap, std::move(rPolyPolygonVector), rUserPaintColor,
1119 dUserPaintStrokeWidth, bUserPaintEnabled,
1120 bIntrinsicAnimationsAllowed,
1121 bDisableAnimationZOrder );
void MakeGraphicsAvailableThreaded(std::vector< Graphic * > &rGraphics)
static GraphicFilter & GetGraphicFilter()
static SdrObject * getSdrObjectFromXShape(const css::uno::Reference< css::uno::XInterface > &xInt)
static BitmapSharedPtr createBitmap(const CanvasSharedPtr &, const ::basegfx::B2ISize &rSize)
This class handles the XSprite updates needed for animations, such as moves, scales etc.
This class multiplexes user-activated and slide-show global events.
void addViewHandler(const ViewEventHandlerWeakPtr &rHandler)
Register an event handler that will be called when views are changed.
This class handles events in a presentation.
This class schedules user-activated events.
#define TOOLS_WARN_EXCEPTION(area, stream)
#define ENSURE_OR_RETURN_FALSE(c, m)
#define ENSURE_OR_THROW(c, m)
::std::shared_ptr< box2DWorld > Box2DWorldSharedPtr
std::shared_ptr< BitmapCanvas > BitmapCanvasSharedPtr
std::shared_ptr< ::cppcanvas::Bitmap > BitmapSharedPtr
std::shared_ptr< Canvas > CanvasSharedPtr
std::shared_ptr< T > make_shared(Args &&... args)
ReturnType extractValue(Type nBitField, sal_uInt8 nStartBit, sal_uInt8 nBitCount)
uno::Sequence< animations::TargetProperties > createTargetProperties(const uno::Reference< animations::XAnimationNode > &rootNode, bool bInitial)
Generate shape property list - set bInitial to true for initial slide state.
::std::shared_ptr< class UserPaintOverlay > UserPaintOverlaySharedPtr
::std::vector< ::cppcanvas::PolyPolygonSharedPtr > PolyPolygonVector
::std::shared_ptr< SlideBitmap > SlideBitmapSharedPtr
::std::shared_ptr< LayerManager > LayerManagerSharedPtr
basegfx::B2IVector getSlideSizePixel(const basegfx::B2DVector &rSlideSize, const UnoViewSharedPtr &pView)
::std::map< css::uno::Reference< css::drawing::XShape >, sal_Int16 > ShapeCursorMap
Maps XShape to mouse cursor.
bool findNamedValue(uno::Sequence< beans::NamedValue > const &rSequence, const beans::NamedValue &rSearchKey)
::std::map< css::uno::Reference< css::drawing::XShape >, std::shared_ptr< ::comphelper::OInterfaceContainerHelper3< css::presentation::XShapeEventListener > > > ShapeEventListenerMap
Maps XShape to shape listener.
SlideSharedPtr createSlide(const uno::Reference< drawing::XDrawPage > &xDrawPage, const uno::Reference< drawing::XDrawPagesSupplier > &xDrawPages, const uno::Reference< animations::XAnimationNode > &xRootNode, EventQueue &rEventQueue, EventMultiplexer &rEventMultiplexer, ScreenUpdater &rScreenUpdater, ActivitiesQueue &rActivitiesQueue, UserEventQueue &rUserEventQueue, CursorManager &rCursorManager, MediaFileManager &rMediaFileManager, const UnoViewContainer &rViewContainer, const uno::Reference< uno::XComponentContext > &xComponentContext, const ShapeEventListenerMap &rShapeListenerMap, const ShapeCursorMap &rShapeCursorMap, PolyPolygonVector &&rPolyPolygonVector, RGBColor const &rUserPaintColor, double dUserPaintStrokeWidth, bool bUserPaintEnabled, bool bIntrinsicAnimationsAllowed, bool bDisableAnimationZOrder)
::std::shared_ptr< Slide > SlideSharedPtr
::std::shared_ptr< AttributableShape > AttributableShapeSharedPtr
void initSlideBackground(const ::cppcanvas::CanvasSharedPtr &rCanvas, const ::basegfx::B2ISize &rSize)
::std::shared_ptr< Shape > ShapeSharedPtr
std::shared_ptr< UnoView > UnoViewSharedPtr
bool for_each_childNode(const css::uno::Reference< css::animations::XAnimationNode > &xNode, Functor &rFunctor)
Apply given functor to every animation node child.
CursorManager & mrCursorManager
parent cursor manager
sal_Int16 mnCurrentCursor
uno::Reference< animations::XAnimationNode > mxRootNode
uno::Reference< drawing::XDrawPage > mxDrawPage
The page model object.
std::shared_ptr< SubsettableShapeManager > mpSubsettableShapeManager
box2d::utils::Box2DWorldSharedPtr mpBox2DWorld
RGBColor maUserPaintColor
const basegfx::B2ISize maSlideSize
LayerManagerSharedPtr mpLayerManager
std::shared_ptr< ShapeManagerImpl > mpShapeManager
SlideAnimationState meAnimationState
bool mbHaveAnimations
True, if this slide is not static.
bool mbFinalStateApplied
When true, final state attributes are already applied to shapes.
VectorOfVectorOfSlideBitmaps maSlideBitmaps
Bitmaps with slide content at various states.
bool mbUserPaintOverlayEnabled
True, when user paint overlay is enabled.
UserPaintOverlaySharedPtr mpPaintOverlay
bool mbMainSequenceFound
True, if this slide has a main animation sequence.
bool mbPaintOverlayActive
When true, enablePaintOverlay was called and mbUserPaintOverlay = true.
bool mbIntrinsicAnimationsAllowed
True, when intrinsic shape animations are allowed.
bool mbShowLoaded
True, if initial load of all animation info succeeded.
bool mbShapesLoaded
True, if initial load of all page shapes succeeded.
bool mbActive
When true, show() was called. Slide hidden otherwise.
PolyPolygonVector maPolygons
double mdUserPaintStrokeWidth
uno::Reference< animations::XAnimationNode > maMainSequence
uno::Reference< drawing::XDrawPagesSupplier > mxDrawPagesSupplier
beans::NamedValue maSearchKey
SlideAnimations maAnimations
Handles the animation and event generation for us.
SlideShowContext maContext
Contains common objects needed throughout the slideshow.