diff options
author | sb <sb@openoffice.org> | 2010-02-08 09:18:14 +0100 |
---|---|---|
committer | sb <sb@openoffice.org> | 2010-02-08 09:18:14 +0100 |
commit | 42ddf8a3465d0c05ab4a3daeb7ab8781dad6d2cd (patch) | |
tree | a5c70bb4d818856edc73a2ded89f38fb4e62b68e /slideshow | |
parent | 20001a2598d53b38ddb551851d31f1d536e6c3d0 (diff) | |
parent | 02f1b698feb68c70166be96eae9f557fbf076ac2 (diff) |
sb118: merged in DEV300_m71
Diffstat (limited to 'slideshow')
-rw-r--r-- | slideshow/source/engine/color.cxx | 13 | ||||
-rw-r--r-- | slideshow/source/engine/eventmultiplexer.cxx | 39 | ||||
-rw-r--r-- | slideshow/source/engine/makefile.mk | 4 | ||||
-rw-r--r-- | slideshow/source/engine/shapes/shapeimporter.cxx | 120 | ||||
-rw-r--r-- | slideshow/source/engine/slide/slideimpl.cxx | 89 | ||||
-rw-r--r-- | slideshow/source/engine/slide/userpaintoverlay.cxx | 303 | ||||
-rw-r--r-- | slideshow/source/engine/slide/userpaintoverlay.hxx | 20 | ||||
-rw-r--r-- | slideshow/source/engine/slideshowimpl.cxx | 343 | ||||
-rw-r--r-- | slideshow/source/engine/tools.cxx | 48 | ||||
-rw-r--r-- | slideshow/source/inc/eventmultiplexer.hxx | 27 | ||||
-rw-r--r-- | slideshow/source/inc/rgbcolor.hxx | 3 | ||||
-rw-r--r-- | slideshow/source/inc/shapeimporter.hxx | 22 | ||||
-rw-r--r-- | slideshow/source/inc/slide.hxx | 47 | ||||
-rw-r--r-- | slideshow/source/inc/tools.hxx | 3 | ||||
-rw-r--r-- | slideshow/source/inc/userpainteventhandler.hxx | 6 |
15 files changed, 985 insertions, 102 deletions
diff --git a/slideshow/source/engine/color.cxx b/slideshow/source/engine/color.cxx index a7a7088a302f..a6ffbb492066 100644 --- a/slideshow/source/engine/color.cxx +++ b/slideshow/source/engine/color.cxx @@ -268,6 +268,19 @@ namespace slideshow return RGBColor( aColor.mnRed, aColor.mnGreen, aColor.mnBlue ); } + RGBColor::RGBColor(const RGBColor& rLHS) + { + RGBColor(rLHS.getRed(), rLHS.getGreen(), rLHS.getBlue()); + } + + RGBColor& RGBColor::operator=( const RGBColor& rLHS ){ + + maRGBTriple.mnRed = rLHS.getRed(); + maRGBTriple.mnGreen = rLHS.getGreen(); + maRGBTriple.mnBlue = rLHS.getBlue(); + return *this; + } + HSLColor operator+( const HSLColor& rLHS, const HSLColor& rRHS ) { return HSLColor( rLHS.getHue() + rRHS.getHue(), diff --git a/slideshow/source/engine/eventmultiplexer.cxx b/slideshow/source/engine/eventmultiplexer.cxx index d62a7946d3c7..0d3579f7be48 100644 --- a/slideshow/source/engine/eventmultiplexer.cxx +++ b/slideshow/source/engine/eventmultiplexer.cxx @@ -262,8 +262,7 @@ struct EventMultiplexerImpl std::vector<ShapeCursorEventHandlerSharedPtr> > ImplShapeCursorHandlers; typedef ThreadUnsafeListenerContainer< PrioritizedHandlerEntry<HyperlinkHandler>, - std::vector< - PrioritizedHandlerEntry<HyperlinkHandler> > > ImplHyperLinkHandlers; + std::vector<PrioritizedHandlerEntry<HyperlinkHandler> > > ImplHyperLinkHandlers; template <typename XSlideShowViewFunc> void forEachView( XSlideShowViewFunc pViewMethod ); @@ -1078,12 +1077,48 @@ bool EventMultiplexer::notifyUserPaintColor( RGBColor const& rUserColor ) boost::cref(rUserColor))); } +bool EventMultiplexer::notifyUserPaintStrokeWidth( double rUserStrokeWidth ) +{ + return mpImpl->maUserPaintEventHandlers.applyAll( + boost::bind(&UserPaintEventHandler::widthChanged, + _1, + rUserStrokeWidth)); +} + bool EventMultiplexer::notifyUserPaintDisabled() { return mpImpl->maUserPaintEventHandlers.applyAll( boost::mem_fn(&UserPaintEventHandler::disable)); } +bool EventMultiplexer::notifySwitchPenMode(){ + return mpImpl->maUserPaintEventHandlers.applyAll( + boost::mem_fn(&UserPaintEventHandler::switchPenMode)); +} + +bool EventMultiplexer::notifySwitchEraserMode(){ + return mpImpl->maUserPaintEventHandlers.applyAll( + boost::mem_fn(&UserPaintEventHandler::switchEraserMode)); +} + +//adding erasing all ink features with UserPaintOverlay +bool EventMultiplexer::notifyEraseAllInk( bool const& rEraseAllInk ) +{ + return mpImpl->maUserPaintEventHandlers.applyAll( + boost::bind(&UserPaintEventHandler::eraseAllInkChanged, + _1, + boost::cref(rEraseAllInk))); +} + +//adding erasing features with UserPaintOverlay +bool EventMultiplexer::notifyEraseInkWidth( sal_Int32 rEraseInkSize ) +{ + return mpImpl->maUserPaintEventHandlers.applyAll( + boost::bind(&UserPaintEventHandler::eraseInkWidthChanged, + _1, + boost::cref(rEraseInkSize))); +} + bool EventMultiplexer::notifyNextEffect() { return mpImpl->notifyNextEffect(); diff --git a/slideshow/source/engine/makefile.mk b/slideshow/source/engine/makefile.mk index 84afa7fb657e..2b640b6e8a39 100644 --- a/slideshow/source/engine/makefile.mk +++ b/slideshow/source/engine/makefile.mk @@ -41,6 +41,10 @@ ENABLE_EXCEPTIONS=TRUE .INCLUDE : settings.mk .INCLUDE : $(PRJ)$/util$/makefile.pmk +.IF "$(ENABLE_PRESENTER_EXTRA_UI)"=="YES" +CDEFS+=-DENABLE_PRESENTER_EXTRA_UI +.ENDIF + # --- Common ---------------------------------------------------------- ENVCFLAGS += -DBOOST_SPIRIT_USE_OLD_NAMESPACE diff --git a/slideshow/source/engine/shapes/shapeimporter.cxx b/slideshow/source/engine/shapes/shapeimporter.cxx index 61f4d30fe2fc..a524aa697935 100644 --- a/slideshow/source/engine/shapes/shapeimporter.cxx +++ b/slideshow/source/engine/shapes/shapeimporter.cxx @@ -39,9 +39,22 @@ #include <goodies/grfmgr.hxx> #include <unotools/ucbstreamhelper.hxx> #include <unotools/streamwrap.hxx> +#include <basegfx/point/b2dpoint.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> +#include <cppcanvas/basegfxfactory.hxx> +#include <cppcanvas/polypolygon.hxx> #include <com/sun/star/awt/Rectangle.hpp> #include <com/sun/star/drawing/ColorMode.hpp> #include <com/sun/star/text/GraphicCrop.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/drawing/PointSequenceSequence.hpp> +#include <com/sun/star/drawing/PointSequence.hpp> +#include <com/sun/star/lang/XMultiComponentFactory.hpp> +#include <com/sun/star/drawing/XLayerSupplier.hpp> +#include <com/sun/star/drawing/XLayerManager.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/drawing/XDrawPagesSupplier.hpp> #include "drawshapesubsetting.hxx" #include "drawshape.hxx" @@ -52,11 +65,13 @@ #include "slideshowexceptions.hxx" #include "gdimtftools.hxx" #include "tools.hxx" +#include "slideshowcontext.hxx" #include <boost/shared_ptr.hpp> #include <boost/scoped_ptr.hpp> using namespace com::sun::star; +using namespace ::comphelper; namespace slideshow { namespace internal { @@ -436,7 +451,8 @@ ShapeSharedPtr ShapeImporter::createShape( bool ShapeImporter::isSkip( uno::Reference<beans::XPropertySet> const& xPropSet, - rtl::OUString const& shapeType ) const + rtl::OUString const& shapeType, + uno::Reference< drawing::XLayer> const& xLayer ) { // skip empty presentation objects: bool bEmpty = false; @@ -448,6 +464,26 @@ bool ShapeImporter::isSkip( return true; } + //skip shapes which corresponds to annotations + if(xLayer.is()) + { + rtl::OUString layerName; + uno::Reference<beans::XPropertySet> xPropLayerSet( + xLayer, uno::UNO_QUERY ); + const uno::Any& a(xPropLayerSet->getPropertyValue(rtl::OUString::createFromAscii("Name")) ); + bool const bRet = (a >>= layerName); + if(bRet) + { + if( layerName.equals(rtl::OUString::createFromAscii("DrawnInSlideshow"))) + { + //Transform shapes into PolyPolygons + importPolygons(xPropSet); + + return true; + } + } + } + // don't export presentation placeholders on masterpage // they can be non empty when user edits the default texts if(mbConvertingMasterPage) @@ -465,6 +501,46 @@ bool ShapeImporter::isSkip( return false; } + +void ShapeImporter::importPolygons(uno::Reference<beans::XPropertySet> const& xPropSet) { + + drawing::PointSequenceSequence aRetval; + sal_Int32 nLineColor=0; + double fLineWidth; + getPropertyValue( aRetval, xPropSet, OUSTR("PolyPolygon") ); + getPropertyValue( nLineColor, xPropSet, OUSTR("LineColor") ); + getPropertyValue( fLineWidth, xPropSet, OUSTR("LineWidth") ); + + drawing::PointSequence* pOuterSequence = aRetval.getArray(); + awt::Point* pInnerSequence = pOuterSequence->getArray(); + + ::basegfx::B2DPolygon aPoly; + basegfx::B2DPoint aPoint; + for( sal_Int32 nCurrPoly=0; nCurrPoly<pOuterSequence->getLength(); ++nCurrPoly ) + { + aPoint.setX((*pInnerSequence).X); + aPoint.setY((*pInnerSequence).Y); + aPoly.append( aPoint ); + *pInnerSequence++; + } + UnoViewVector::const_iterator aIter=(mrContext.mrViewContainer).begin(); + UnoViewVector::const_iterator aEnd=(mrContext.mrViewContainer).end(); + while(aIter != aEnd) + { + ::cppcanvas::PolyPolygonSharedPtr pPolyPoly( + ::cppcanvas::BaseGfxFactory::getInstance().createPolyPolygon( (*aIter)->getCanvas(), + aPoly ) ); + if( pPolyPoly ) + { + pPolyPoly->setRGBALineColor( unoColor2RGBColor( nLineColor ).getIntegerColor() ); + pPolyPoly->setStrokeWidth(fLineWidth); + pPolyPoly->draw(); + maPolygons.push_back(pPolyPoly); + } + aIter++; + } +} + ShapeSharedPtr ShapeImporter::importBackgroundShape() // throw (ShapeLoadFailedException) { if( maShapesStack.empty() ) @@ -506,10 +582,23 @@ ShapeSharedPtr ShapeImporter::importShape() // throw (ShapeLoadFailedException) throw ShapeLoadFailedException(); } - rtl::OUString const shapeType( xCurrShape->getShapeType() ); + //Retrieve the layer for the current shape + uno::Reference< drawing::XLayer > xDrawnInSlideshow; + + uno::Reference< drawing::XLayerSupplier > xLayerSupplier(mxPagesSupplier, uno::UNO_QUERY); + if(xLayerSupplier.is()) + { + uno::Reference< container::XNameAccess > xNameAccess = xLayerSupplier->getLayerManager(); + + uno::Reference< drawing::XLayerManager > xLayerManager(xNameAccess, uno::UNO_QUERY); + + xDrawnInSlideshow = xLayerManager->getLayerForShape(xCurrShape); + } + + rtl::OUString const shapeType( xCurrShape->getShapeType()); // is this shape presentation-invisible? - if( !isSkip(xPropSet, shapeType) ) + if( !isSkip(xPropSet, shapeType, xDrawnInSlideshow) ) { bIsGroupShape = shapeType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( @@ -549,17 +638,32 @@ bool ShapeImporter::isImportDone() const return maShapesStack.empty(); } -ShapeImporter::ShapeImporter( uno::Reference<drawing::XDrawPage> const& xPage, - uno::Reference<drawing::XDrawPage> const& xActualPage, - const SlideShowContext& rContext, - sal_Int32 nOrdNumStart, - bool bConvertingMasterPage ) : +PolyPolygonVector ShapeImporter::getPolygons() +{ + return maPolygons; +} + +ShapeImporter::ShapeImporter( uno::Reference<drawing::XDrawPage> const& xPage, + uno::Reference<drawing::XDrawPage> const& xActualPage, + uno::Reference<drawing::XDrawPagesSupplier> const& xPagesSupplier, + const SlideShowContext& rContext, + sal_Int32 nOrdNumStart, + bool bConvertingMasterPage ) : mxPage( xActualPage ), +#ifdef ENABLE_PRESENTER_EXTRA_UI + mxPagesSupplier( xPagesSupplier ), +#else + mxPagesSupplier( NULL ), +#endif mrContext( rContext ), + maPolygons(), maShapesStack(), mnAscendingPrio( nOrdNumStart ), mbConvertingMasterPage( bConvertingMasterPage ) { +#ifndef ENABLE_PRESENTER_EXTRA_UI + (void)xPagesSupplier; +#endif uno::Reference<drawing::XShapes> const xShapes( xPage, uno::UNO_QUERY_THROW ); maShapesStack.push( XShapesEntry(xShapes) ); diff --git a/slideshow/source/engine/slide/slideimpl.cxx b/slideshow/source/engine/slide/slideimpl.cxx index 84b6ad7b4305..b036c9373fc7 100644 --- a/slideshow/source/engine/slide/slideimpl.cxx +++ b/slideshow/source/engine/slide/slideimpl.cxx @@ -81,7 +81,7 @@ #include <iterator> #include <algorithm> #include <functional> - +#include <iostream> using namespace ::com::sun::star; @@ -101,6 +101,7 @@ class SlideImpl : public Slide, { public: SlideImpl( const uno::Reference<drawing::XDrawPage>& xDrawPage, + const uno::Reference<drawing::XDrawPagesSupplier>& xDrawPages, const uno::Reference<animations::XAnimationNode>& xRootNode, EventQueue& rEventQueue, EventMultiplexer& rEventMultiplexer, @@ -112,7 +113,9 @@ public: const uno::Reference<uno::XComponentContext>& xContext, const ShapeEventListenerMap& rShapeListenerMap, const ShapeCursorMap& rShapeCursorMap, + const PolyPolygonVector& rPolyPolygonVector, RGBColor const& rUserPaintColor, + double dUserPaintStrokeWidth, bool bUserPaintEnabled, bool bIntrinsicAnimationsAllowed, bool bDisableAnimationZOrder ); @@ -136,6 +139,9 @@ public: virtual basegfx::B2ISize getSlideSize() const; virtual uno::Reference<drawing::XDrawPage > getXDrawPage() const; virtual uno::Reference<animations::XAnimationNode> getXAnimationNode() const; + virtual PolyPolygonVector getPolygons(); + virtual void drawPolygons() const; + virtual bool isPaintOverlayActive() const; // TODO(F2): Rework SlideBitmap to no longer be based on XBitmap, // but on canvas-independent basegfx bitmaps @@ -201,6 +207,8 @@ private: /// End GIF and other intrinsic shape animations void startIntrinsicAnimations(); + /// Add Polygons to the member maPolygons + void addPolygons(PolyPolygonVector aPolygons); // Types // ===== @@ -230,6 +238,7 @@ private: /// The page model object uno::Reference< drawing::XDrawPage > mxDrawPage; + uno::Reference< drawing::XDrawPagesSupplier > mxDrawPagesSupplier; uno::Reference< animations::XAnimationNode > mxRootNode; LayerManagerSharedPtr mpLayerManager; @@ -244,8 +253,10 @@ private: /// Handles the animation and event generation for us SlideAnimations maAnimations; + PolyPolygonVector maPolygons; RGBColor maUserPaintColor; + double mdUserPaintStrokeWidth; UserPaintOverlaySharedPtr mpPaintOverlay; /// Bitmaps with slide content at various states @@ -287,6 +298,9 @@ private: /// When true, show() was called. Slide hidden oherwise. bool mbActive; + + ///When true, enablePaintOverlay was called and mbUserPaintOverlay = true + bool mbPaintOverlayActive; }; @@ -335,6 +349,7 @@ private: SlideImpl::SlideImpl( const uno::Reference< drawing::XDrawPage >& xDrawPage, + const uno::Reference<drawing::XDrawPagesSupplier>& xDrawPages, const uno::Reference< animations::XAnimationNode >& xRootNode, EventQueue& rEventQueue, EventMultiplexer& rEventMultiplexer, @@ -346,11 +361,14 @@ SlideImpl::SlideImpl( const uno::Reference< drawing::XDrawPage >& xDra const uno::Reference< uno::XComponentContext >& xComponentContext, const ShapeEventListenerMap& rShapeListenerMap, const ShapeCursorMap& rShapeCursorMap, + const PolyPolygonVector& rPolyPolygonVector, RGBColor const& aUserPaintColor, + double dUserPaintStrokeWidth, bool bUserPaintEnabled, bool bIntrinsicAnimationsAllowed, bool bDisableAnimationZOrder ) : mxDrawPage( xDrawPage ), + mxDrawPagesSupplier( xDrawPages ), mxRootNode( xRootNode ), mpLayerManager( new LayerManager( rViewContainer, @@ -375,7 +393,9 @@ SlideImpl::SlideImpl( const uno::Reference< drawing::XDrawPage >& xDra mrCursorManager( rCursorManager ), maAnimations( maContext, getSlideSizeImpl() ), + maPolygons(rPolyPolygonVector), maUserPaintColor(aUserPaintColor), + mdUserPaintStrokeWidth(dUserPaintStrokeWidth), mpPaintOverlay(), maSlideBitmaps(), meAnimationState( CONSTRUCTING_STATE ), @@ -387,7 +407,8 @@ SlideImpl::SlideImpl( const uno::Reference< drawing::XDrawPage >& xDra mbShowLoaded( false ), mbHaveAnimations( false ), mbMainSequenceFound( false ), - mbActive( false ) + mbActive( false ), + mbPaintOverlayActive( false ) { // clone already existing views for slide bitmaps std::for_each( rViewContainer.begin(), @@ -436,6 +457,9 @@ void SlideImpl::dispose() mpShapeManager.reset(); mxRootNode.clear(); mxDrawPage.clear(); +#ifndef ENABLE_PRESENTER_EXTRA_UI + mxDrawPagesSupplier.clear(); +#endif } bool SlideImpl::prefetch() @@ -583,6 +607,12 @@ uno::Reference<animations::XAnimationNode> SlideImpl::getXAnimationNode() const return mxRootNode; } +PolyPolygonVector SlideImpl::getPolygons() +{ + if(mbPaintOverlayActive) + maPolygons = mpPaintOverlay->getPolygons(); + return maPolygons; +} SlideBitmapSharedPtr SlideImpl::getCurrentSlideBitmap( const UnoViewSharedPtr& rView ) const { @@ -862,14 +892,47 @@ bool SlideImpl::implPrefetchShow() void SlideImpl::enablePaintOverlay() { if( mbUserPaintOverlayEnabled ) + { mpPaintOverlay = UserPaintOverlay::create( maUserPaintColor, - 2.0, - maContext ); + mdUserPaintStrokeWidth, + maContext, + maPolygons ); + mbPaintOverlayActive = true; + } +} + +void SlideImpl::drawPolygons() const +{ + if( mbUserPaintOverlayEnabled ) + mpPaintOverlay->drawPolygons(); +} + +void SlideImpl::addPolygons(PolyPolygonVector aPolygons) +{ + if(!aPolygons.empty()) + { + for( PolyPolygonVector::iterator aIter=aPolygons.begin(), + aEnd=aPolygons.end(); + aIter!=aEnd; + ++aIter ) + { + maPolygons.push_back(*aIter); + } + } +} + +bool SlideImpl::isPaintOverlayActive() const +{ + return mbPaintOverlayActive; } void SlideImpl::disablePaintOverlay() { + if(mbPaintOverlayActive) + maPolygons = mpPaintOverlay->getPolygons(); + mpPaintOverlay.reset(); + mbPaintOverlayActive = false; } ::basegfx::B2DRectangle SlideImpl::getSlideRect() const @@ -1073,6 +1136,7 @@ bool SlideImpl::loadShapes() // ------------------------------------------------------------------------- ShapeImporter aMPShapesFunctor( xMasterPage, mxDrawPage, + mxDrawPagesSupplier, maContext, 0, /* shape num starts at 0 */ true ); @@ -1087,6 +1151,7 @@ bool SlideImpl::loadShapes() if( rShape ) mpLayerManager->addShape( rShape ); } + addPolygons(aMPShapesFunctor.getPolygons()); nCurrCount = xMasterPageShapes->getCount() + 1; } @@ -1121,6 +1186,7 @@ bool SlideImpl::loadShapes() ShapeImporter aShapesFunctor( mxDrawPage, mxDrawPage, + mxDrawPagesSupplier, maContext, nCurrCount, false ); @@ -1132,6 +1198,7 @@ bool SlideImpl::loadShapes() if( rShape ) mpLayerManager->addShape( rShape ); } + addPolygons(aShapesFunctor.getPolygons()); } catch( uno::RuntimeException& ) { @@ -1176,6 +1243,7 @@ basegfx::B2ISize SlideImpl::getSlideSizeImpl() const SlideSharedPtr createSlide( const uno::Reference< drawing::XDrawPage >& xDrawPage, + const uno::Reference<drawing::XDrawPagesSupplier>& xDrawPages, const uno::Reference< animations::XAnimationNode >& xRootNode, EventQueue& rEventQueue, EventMultiplexer& rEventMultiplexer, @@ -1187,18 +1255,25 @@ SlideSharedPtr createSlide( const uno::Reference< drawing::XDrawPage >& const uno::Reference< uno::XComponentContext >& xComponentContext, const ShapeEventListenerMap& rShapeListenerMap, const ShapeCursorMap& rShapeCursorMap, + const PolyPolygonVector& rPolyPolygonVector, RGBColor const& rUserPaintColor, + double dUserPaintStrokeWidth, bool bUserPaintEnabled, bool bIntrinsicAnimationsAllowed, bool bDisableAnimationZOrder ) { - boost::shared_ptr<SlideImpl> pRet( new SlideImpl( xDrawPage, xRootNode, rEventQueue, +#ifdef ENABLE_PRESENTER_EXTRA_UI + boost::shared_ptr<SlideImpl> pRet( new SlideImpl( xDrawPage, xDrawPages, xRootNode, rEventQueue, +#else + (void)xDrawPages; + boost::shared_ptr<SlideImpl> pRet( new SlideImpl( xDrawPage, NULL, xRootNode, rEventQueue, +#endif rEventMultiplexer, rScreenUpdater, rActivitiesQueue, rUserEventQueue, rCursorManager, rViewContainer, xComponentContext, rShapeListenerMap, - rShapeCursorMap, rUserPaintColor, - bUserPaintEnabled, + rShapeCursorMap, rPolyPolygonVector, rUserPaintColor, + dUserPaintStrokeWidth, bUserPaintEnabled, bIntrinsicAnimationsAllowed, bDisableAnimationZOrder )); diff --git a/slideshow/source/engine/slide/userpaintoverlay.cxx b/slideshow/source/engine/slide/userpaintoverlay.cxx index 5cdfbddc1193..cfcb6a1918dc 100644 --- a/slideshow/source/engine/slide/userpaintoverlay.cxx +++ b/slideshow/source/engine/slide/userpaintoverlay.cxx @@ -54,7 +54,8 @@ #include <boost/bind.hpp> #include <boost/noncopyable.hpp> - +#include "slide.hxx" +#include "cursormanager.hxx" using namespace ::com::sun::star; @@ -63,29 +64,40 @@ namespace slideshow namespace internal { class PaintOverlayHandler : public MouseEventHandler, - public ViewEventHandler + public ViewEventHandler, + public UserPaintEventHandler { public: - PaintOverlayHandler( const RGBColor& rStrokeColor, - double nStrokeWidth, - ActivitiesQueue& rActivitiesQueue, - ScreenUpdater& rScreenUpdater, - const UnoViewContainer& rViews ) : + PaintOverlayHandler( const RGBColor& rStrokeColor, + double nStrokeWidth, + ActivitiesQueue& rActivitiesQueue, + ScreenUpdater& rScreenUpdater, + const UnoViewContainer& rViews, + Slide& rSlide, + const PolyPolygonVector& rPolygons ) : mrActivitiesQueue( rActivitiesQueue ), mrScreenUpdater( rScreenUpdater ), maViews(), + maPolygons( rPolygons ), maStrokeColor( rStrokeColor ), mnStrokeWidth( nStrokeWidth ), maLastPoint(), maLastMouseDownPos(), mbIsLastPointValid( false ), - mbIsLastMouseDownPosValid( false ) + mbIsLastMouseDownPosValid( false ), + //handle the "remove all ink from slide" mode of erasing + mbIsEraseAllModeActivated( false ), + //handle the "remove stroke by stroke" mode of erasing + mbIsEraseModeActivated( false ), + mrSlide(rSlide), + mnSize(100) { std::for_each( rViews.begin(), rViews.end(), boost::bind( &PaintOverlayHandler::viewAdded, this, _1 )); + drawPolygons(); } virtual void dispose() @@ -118,9 +130,120 @@ namespace slideshow // polygon and repaint here. } + bool colorChanged( RGBColor const& rUserColor ) + { + this->maStrokeColor = rUserColor; + this->mbIsEraseModeActivated = false; + return true; + } + + bool widthChanged( double nUserStrokeWidth ) + { + this->mnStrokeWidth = nUserStrokeWidth; + mbIsEraseModeActivated = false; + return true; + } + + bool eraseAllInkChanged( bool const& rEraseAllInk ) + { + this->mbIsEraseAllModeActivated= rEraseAllInk; + // if the erase all mode is activated it will remove all ink from slide, + // therefor destroy all the polygons stored + if(mbIsEraseAllModeActivated) + { + // The Erase Mode should be desactivated + mbIsEraseModeActivated = false; + // must get access to the instance to erase all polygon + for( UnoViewVector::iterator aIter=maViews.begin(), aEnd=maViews.end(); + aIter!=aEnd; + ++aIter ) + { + // fully clear view content to background color + (*aIter)->getCanvas()->clear(); + + //get via SlideImpl instance the bitmap of the slide unmodified to redraw it + SlideBitmapSharedPtr pBitmap( mrSlide.getCurrentSlideBitmap( (*aIter) ) ); + ::cppcanvas::CanvasSharedPtr pCanvas( (*aIter)->getCanvas() ); + + const ::basegfx::B2DHomMatrix aViewTransform( (*aIter)->getTransformation() ); + const ::basegfx::B2DPoint aOutPosPixel( aViewTransform * ::basegfx::B2DPoint() ); + + // setup a canvas with device coordinate space, the slide + // bitmap already has the correct dimension. + ::cppcanvas::CanvasSharedPtr pDevicePixelCanvas( pCanvas->clone() ); + + pDevicePixelCanvas->setTransformation( ::basegfx::B2DHomMatrix() ); + + // render at given output position + pBitmap->move( aOutPosPixel ); + + // clear clip (might have been changed, e.g. from comb + // transition) + pBitmap->clip( ::basegfx::B2DPolyPolygon() ); + pBitmap->draw( pDevicePixelCanvas ); + + mrScreenUpdater.notifyUpdate(*aIter,true); + } + maPolygons.clear(); + } + mbIsEraseAllModeActivated=false; + return true; + } + + bool eraseInkWidthChanged( sal_Int32 rEraseInkSize ) + { + // Change the size + this->mnSize=rEraseInkSize; + // Changed to mode Erase + this->mbIsEraseModeActivated = true; + return true; + } + + bool switchPenMode() + { + this->mbIsEraseModeActivated = false; + return true; + } + + bool switchEraserMode() + { + this->mbIsEraseModeActivated = true; + return true; + } + + bool disable() + { + return true; + } + + //Draw all registered polygons. + void drawPolygons() + { + for( PolyPolygonVector::iterator aIter=maPolygons.begin(), aEnd=maPolygons.end(); + aIter!=aEnd; + ++aIter ) + { + (*aIter)->draw(); + } + // screen update necessary to show painting + mrScreenUpdater.notifyUpdate(); + } + + //Retrieve all registered polygons. + PolyPolygonVector getPolygons() + { + return maPolygons; + } + // MouseEventHandler methods virtual bool handleMousePressed( const awt::MouseEvent& e ) { + if (e.Buttons == awt::MouseButton::RIGHT) + { + mbIsLastPointValid = false; + return false; + } + if (e.Buttons != awt::MouseButton::LEFT) return false; @@ -135,6 +258,12 @@ namespace slideshow virtual bool handleMouseReleased( const awt::MouseEvent& e ) { + if (e.Buttons == awt::MouseButton::RIGHT) + { + mbIsLastPointValid = false; + return false; + } + if (e.Buttons != awt::MouseButton::LEFT) return false; @@ -180,42 +309,110 @@ namespace slideshow virtual bool handleMouseDragged( const awt::MouseEvent& e ) { - if( !mbIsLastPointValid ) - { - mbIsLastPointValid = true; - maLastPoint.setX( e.X ); - maLastPoint.setY( e.Y ); - } - else + if(mbIsEraseModeActivated) { + //define the last point as an object + //we suppose that there's no way this point could be valid ::basegfx::B2DPolygon aPoly; + + maLastPoint.setX( e.X-mnSize ); + maLastPoint.setY( e.Y-mnSize ); + aPoly.append( maLastPoint ); - maLastPoint.setX( e.X ); - maLastPoint.setY( e.Y ); + maLastPoint.setX( e.X-mnSize ); + maLastPoint.setY( e.Y+mnSize ); aPoly.append( maLastPoint ); + maLastPoint.setX( e.X+mnSize ); + maLastPoint.setY( e.Y+mnSize ); - // paint to all views - for( UnoViewVector::iterator aIter=maViews.begin(), aEnd=maViews.end(); - aIter!=aEnd; - ++aIter ) + aPoly.append( maLastPoint ); + maLastPoint.setX( e.X+mnSize ); + maLastPoint.setY( e.Y-mnSize ); + + aPoly.append( maLastPoint ); + maLastPoint.setX( e.X-mnSize ); + maLastPoint.setY( e.Y-mnSize ); + + aPoly.append( maLastPoint ); + + //now we have defined a Polygon that is closed + + //The point is to redraw the LastPoint the way it was originally on the bitmap, + //of the slide + for( UnoViewVector::iterator aIter=maViews.begin(), aEnd=maViews.end(); + aIter!=aEnd; + ++aIter ) { - ::cppcanvas::PolyPolygonSharedPtr pPolyPoly( - ::cppcanvas::BaseGfxFactory::getInstance().createPolyPolygon( (*aIter)->getCanvas(), - aPoly ) ); - if( pPolyPoly ) + //get via SlideImpl instance the bitmap of the slide unmodified to redraw it + SlideBitmapSharedPtr pBitmap( mrSlide.getCurrentSlideBitmap( (*aIter) ) ); + ::cppcanvas::CanvasSharedPtr pCanvas( (*aIter)->getCanvas() ); + + ::basegfx::B2DHomMatrix aViewTransform( (*aIter)->getTransformation() ); + const ::basegfx::B2DPoint aOutPosPixel( aViewTransform * ::basegfx::B2DPoint() ); + + // setup a canvas with device coordinate space, the slide + // bitmap already has the correct dimension. + ::cppcanvas::CanvasSharedPtr pDevicePixelCanvas( pCanvas->clone() ); + + pDevicePixelCanvas->setTransformation( ::basegfx::B2DHomMatrix() ); + + // render at given output position + pBitmap->move( aOutPosPixel ); + + ::basegfx::B2DPolyPolygon aPolyPoly=::basegfx::B2DPolyPolygon(aPoly); + aViewTransform.translate(-aOutPosPixel.getX(), -aOutPosPixel.getY()); + aPolyPoly.transform(aViewTransform); + // set clip so that we just redraw a part of the canvas + pBitmap->clip(aPolyPoly); + pBitmap->draw( pDevicePixelCanvas ); + + mrScreenUpdater.notifyUpdate(*aIter,true); + } + + } + else + { + if( !mbIsLastPointValid ) + { + mbIsLastPointValid = true; + maLastPoint.setX( e.X ); + maLastPoint.setY( e.Y ); + } + else + { + ::basegfx::B2DPolygon aPoly; + aPoly.append( maLastPoint ); + + maLastPoint.setX( e.X ); + maLastPoint.setY( e.Y ); + + aPoly.append( maLastPoint ); + + // paint to all views + for( UnoViewVector::iterator aIter=maViews.begin(), aEnd=maViews.end(); + aIter!=aEnd; + ++aIter ) { - pPolyPoly->setRGBALineColor( maStrokeColor.getIntegerColor() ); - pPolyPoly->draw(); + ::cppcanvas::PolyPolygonSharedPtr pPolyPoly( + ::cppcanvas::BaseGfxFactory::getInstance().createPolyPolygon( (*aIter)->getCanvas(), + aPoly ) ); + + if( pPolyPoly ) + { + pPolyPoly->setStrokeWidth(mnStrokeWidth); + pPolyPoly->setRGBALineColor( maStrokeColor.getIntegerColor() ); + pPolyPoly->draw(); + maPolygons.push_back(pPolyPoly); + } } - } - // screen update necessary to show painting - mrScreenUpdater.notifyUpdate(); + // screen update necessary to show painting + mrScreenUpdater.notifyUpdate(); + } } - // mouse events captured return true; } @@ -226,42 +423,67 @@ namespace slideshow return false; // did not handle the event } + + private: ActivitiesQueue& mrActivitiesQueue; ScreenUpdater& mrScreenUpdater; UnoViewVector maViews; + PolyPolygonVector maPolygons; RGBColor maStrokeColor; double mnStrokeWidth; basegfx::B2DPoint maLastPoint; basegfx::B2DPoint maLastMouseDownPos; bool mbIsLastPointValid; bool mbIsLastMouseDownPosValid; + // added bool for erasing purpose : + bool mbIsEraseAllModeActivated; + bool mbIsEraseModeActivated; + Slide& mrSlide; + sal_Int32 mnSize; }; - UserPaintOverlaySharedPtr UserPaintOverlay::create( const RGBColor& rStrokeColor, - double nStrokeWidth, - const SlideShowContext& rContext ) + UserPaintOverlaySharedPtr UserPaintOverlay::create( const RGBColor& rStrokeColor, + double nStrokeWidth, + const SlideShowContext& rContext, + const PolyPolygonVector& rPolygons ) { UserPaintOverlaySharedPtr pRet( new UserPaintOverlay( rStrokeColor, nStrokeWidth, - rContext )); + rContext, + rPolygons )); return pRet; } - UserPaintOverlay::UserPaintOverlay( const RGBColor& rStrokeColor, - double nStrokeWidth, - const SlideShowContext& rContext ) : + UserPaintOverlay::UserPaintOverlay( const RGBColor& rStrokeColor, + double nStrokeWidth, + const SlideShowContext& rContext, + const PolyPolygonVector& rPolygons ) : mpHandler( new PaintOverlayHandler( rStrokeColor, nStrokeWidth, rContext.mrActivitiesQueue, rContext.mrScreenUpdater, - rContext.mrViewContainer )), + rContext.mrViewContainer, + //adding a link to Slide + dynamic_cast<Slide&>(rContext.mrCursorManager), + rPolygons )), mrMultiplexer( rContext.mrEventMultiplexer ) { mrMultiplexer.addClickHandler( mpHandler, 3.0 ); mrMultiplexer.addMouseMoveHandler( mpHandler, 3.0 ); mrMultiplexer.addViewHandler( mpHandler ); + mrMultiplexer.addUserPaintHandler(mpHandler); + } + + PolyPolygonVector UserPaintOverlay::getPolygons() + { + return mpHandler->getPolygons(); + } + + void UserPaintOverlay::drawPolygons() + { + mpHandler->drawPolygons(); } UserPaintOverlay::~UserPaintOverlay() @@ -273,7 +495,8 @@ namespace slideshow mrMultiplexer.removeViewHandler( mpHandler ); mpHandler->dispose(); } - catch (uno::Exception &) { + catch (uno::Exception &) + { OSL_ENSURE( false, rtl::OUStringToOString( comphelper::anyToString( cppu::getCaughtException() ), diff --git a/slideshow/source/engine/slide/userpaintoverlay.hxx b/slideshow/source/engine/slide/userpaintoverlay.hxx index 34a171f1740c..bc85ff649adb 100644 --- a/slideshow/source/engine/slide/userpaintoverlay.hxx +++ b/slideshow/source/engine/slide/userpaintoverlay.hxx @@ -38,7 +38,7 @@ #include <boost/utility.hpp> #include <boost/shared_ptr.hpp> - +#include <vector> /* Definition of UserPaintOverlay class */ @@ -51,7 +51,7 @@ namespace slideshow class PaintOverlayHandler; typedef ::boost::shared_ptr< class UserPaintOverlay > UserPaintOverlaySharedPtr; - + typedef ::std::vector< ::cppcanvas::PolyPolygonSharedPtr> PolyPolygonVector; /** Slide overlay, which can be painted into by the user. This class registers itself at the EventMultiplexer, @@ -69,15 +69,19 @@ namespace slideshow @param nStrokeWidth Width of the stroked path */ - static UserPaintOverlaySharedPtr create( const RGBColor& rStrokeColor, - double nStrokeWidth, - const SlideShowContext& rContext ); + static UserPaintOverlaySharedPtr create( const RGBColor& rStrokeColor, + double nStrokeWidth, + const SlideShowContext& rContext, + const PolyPolygonVector& rPolygons ); ~UserPaintOverlay(); + PolyPolygonVector getPolygons(); + void drawPolygons(); private: - UserPaintOverlay( const RGBColor& rStrokeColor, - double nStrokeWidth, - const SlideShowContext& rContext ); + UserPaintOverlay( const RGBColor& rStrokeColor, + double nStrokeWidth, + const SlideShowContext& rContext, + const PolyPolygonVector& rPolygons ); ::boost::shared_ptr<PaintOverlayHandler> mpHandler; EventMultiplexer& mrMultiplexer; diff --git a/slideshow/source/engine/slideshowimpl.cxx b/slideshow/source/engine/slideshowimpl.cxx index 109e64ca63c1..0491b25a8a56 100644 --- a/slideshow/source/engine/slideshowimpl.cxx +++ b/slideshow/source/engine/slideshowimpl.cxx @@ -47,6 +47,7 @@ #include <comphelper/scopeguard.hxx> #include <comphelper/optional.hxx> #include <comphelper/servicedecl.hxx> +#include <comphelper/namecontainer.hxx> #include <cppcanvas/spritecanvas.hxx> #include <cppcanvas/vclfactory.hxx> @@ -62,6 +63,7 @@ #include <basegfx/tools/canvastools.hxx> #include <vcl/font.hxx> +#include "rtl/ref.hxx" #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/util/XModifyListener.hpp> @@ -74,6 +76,16 @@ #include <com/sun/star/presentation/XSlideShowListener.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XServiceName.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/drawing/PointSequenceSequence.hpp> +#include <com/sun/star/drawing/PointSequence.hpp> +#include <com/sun/star/drawing/XLayer.hpp> +#include <com/sun/star/drawing/XLayerSupplier.hpp> +#include <com/sun/star/drawing/XLayerManager.hpp> +#include <com/sun/star/container/XNameAccess.hpp> + +#include "com/sun/star/uno/Reference.hxx" #include <com/sun/star/loader/CannotActivateFactoryException.hpp> #include "unoviewcontainer.hxx" @@ -103,8 +115,10 @@ #include <map> #include <vector> #include <iterator> +#include <string> #include <algorithm> #include <stdio.h> +#include <iostream> using namespace com::sun::star; using namespace ::slideshow::internal; @@ -213,6 +227,13 @@ private: typedef cppu::WeakComponentImplHelper1<presentation::XSlideShow> SlideShowImplBase; +typedef ::std::vector< ::cppcanvas::PolyPolygonSharedPtr> PolyPolygonVector; + +/// Maps XDrawPage for annotations persistence +typedef ::std::map< ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XDrawPage>, + PolyPolygonVector> PolygonMap; + class SlideShowImpl : private cppu::BaseMutex, public CursorManager, public SlideShowImplBase @@ -293,9 +314,11 @@ private: throw (uno::RuntimeException); virtual void SAL_CALL displaySlide( uno::Reference<drawing::XDrawPage> const& xSlide, + uno::Reference<drawing::XDrawPagesSupplier> const& xDrawPages, uno::Reference<animations::XAnimationNode> const& xRootNode, uno::Sequence<beans::PropertyValue> const& rProperties ) throw (uno::RuntimeException); + virtual void SAL_CALL registerUserPaintPolygons( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xDocFactory ) throw (::com::sun::star::uno::RuntimeException); virtual sal_Bool SAL_CALL setProperty( beans::PropertyValue const& rProperty ) throw (uno::RuntimeException); virtual sal_Bool SAL_CALL addView( @@ -354,9 +377,13 @@ private: /// Stop currently running show. void stopShow(); + ///Find a polygons vector in maPolygons (map) + PolygonMap::iterator findPolygons( uno::Reference<drawing::XDrawPage> const& xDrawPage); + /// Creates a new slide. SlideSharedPtr makeSlide( uno::Reference<drawing::XDrawPage> const& xDrawPage, + uno::Reference<drawing::XDrawPagesSupplier> const& xDrawPages, uno::Reference<animations::XAnimationNode> const& xRootNode ); /// Checks whether the given slide/animation node matches mpPrefetchSlide @@ -429,8 +456,20 @@ private: /// map of sal_Int16 values, specifying the mouse cursor for every shape ShapeCursorMap maShapeCursors; + //map of vector of Polygons, containing polygons drawn on each slide. + PolygonMap maPolygons; + boost::optional<RGBColor> maUserPaintColor; + boost::optional<double> maUserPaintStrokeWidth; + + //changed for the eraser project + boost::optional<bool> maEraseAllInk; + boost::optional<bool> maSwitchPenMode; + boost::optional<bool> maSwitchEraserMode; + boost::optional<sal_Int32> maEraseInk; + //end changed + boost::shared_ptr<canvas::tools::ElapsedTime> mpPresTimer; ScreenUpdater maScreenUpdater; EventQueue maEventQueue; @@ -459,6 +498,8 @@ private: SlideSharedPtr mpPrefetchSlide; /// slide to be prefetched: best candidate for upcoming slide uno::Reference<drawing::XDrawPage> mxPrefetchSlide; + /// save the XDrawPagesSupplier to retieve polygons + uno::Reference<drawing::XDrawPagesSupplier> mxDrawPagesSupplier; /// slide animation to be prefetched: uno::Reference<animations::XAnimationNode> mxPrefetchAnimationNode; @@ -550,6 +591,7 @@ SlideShowImpl::SlideShowImpl( maShapeEventListeners(), maShapeCursors(), maUserPaintColor(), + maUserPaintStrokeWidth(4.0), mpPresTimer( new canvas::tools::ElapsedTime ), maScreenUpdater(maViewContainer), maEventQueue( mpPresTimer ), @@ -569,6 +611,7 @@ SlideShowImpl::SlideShowImpl( mpCurrentSlide(), mpPrefetchSlide(), mxPrefetchSlide(), + mxDrawPagesSupplier(), mxPrefetchAnimationNode(), mnCurrentCursor(awt::SystemPointer::ARROW), mnWaitSymbolRequestCount(0), @@ -865,14 +908,38 @@ ActivitySharedPtr SlideShowImpl::createSlideTransition( true )); } +PolygonMap::iterator SlideShowImpl::findPolygons( uno::Reference<drawing::XDrawPage> const& xDrawPage) +{ + // TODO(P2) : Optimze research in the map. + bool bFound = false; + PolygonMap::iterator aIter=maPolygons.begin(); + + + while(aIter!=maPolygons.end() && !bFound) + { + if(aIter->first == xDrawPage) + bFound = true; + else + aIter++; + } + + return aIter; +} + SlideSharedPtr SlideShowImpl::makeSlide( - uno::Reference<drawing::XDrawPage> const& xDrawPage, - uno::Reference<animations::XAnimationNode> const& xRootNode ) + uno::Reference<drawing::XDrawPage> const& xDrawPage, + uno::Reference<drawing::XDrawPagesSupplier> const& xDrawPages, + uno::Reference<animations::XAnimationNode> const& xRootNode ) { - if (! xDrawPage.is()) + if( !xDrawPage.is() ) return SlideSharedPtr(); + //Retrieve polygons for the current slide + PolygonMap::iterator aIter; + aIter = findPolygons(xDrawPage); + const SlideSharedPtr pSlide( createSlide(xDrawPage, + xDrawPages, xRootNode, maEventQueue, maEventMultiplexer, @@ -884,7 +951,9 @@ SlideSharedPtr SlideShowImpl::makeSlide( mxComponentContext, maShapeEventListeners, maShapeCursors, + (aIter != maPolygons.end()) ? aIter->second : PolyPolygonVector(), maUserPaintColor ? *maUserPaintColor : RGBColor(), + *maUserPaintStrokeWidth, !!maUserPaintColor, mbImageAnimationsAllowed, mbDisableAnimationZOrder) ); @@ -949,7 +1018,14 @@ void SlideShowImpl::stopShow() // Force-end running animation // =========================== if (mpCurrentSlide) + { mpCurrentSlide->hide(); + //Register polygons in the map + if(findPolygons(mpCurrentSlide->getXDrawPage()) != maPolygons.end()) + maPolygons.erase(mpCurrentSlide->getXDrawPage()); + + maPolygons.insert(make_pair(mpCurrentSlide->getXDrawPage(),mpCurrentSlide->getPolygons())); + } // clear all queues maEventQueue.clear(); @@ -1024,6 +1100,7 @@ private: void SlideShowImpl::displaySlide( uno::Reference<drawing::XDrawPage> const& xSlide, + uno::Reference<drawing::XDrawPagesSupplier> const& xDrawPages, uno::Reference<animations::XAnimationNode> const& xRootNode, uno::Sequence<beans::PropertyValue> const& rProperties ) throw (uno::RuntimeException) @@ -1038,6 +1115,12 @@ void SlideShowImpl::displaySlide( // precondition: must only be called from the main thread! DBG_TESTSOLARMUTEX(); +#ifdef ENABLE_PRESENTER_EXTRA_UI + mxDrawPagesSupplier = xDrawPages; +#else + mxDrawPagesSupplier = NULL; +#endif + stopShow(); // MUST call that: results in // maUserEventQueue.clear(). What's more, // stopShow()'s currSlide->hide() call is @@ -1070,9 +1153,7 @@ void SlideShowImpl::displaySlide( mpCurrentSlide = mpPrefetchSlide; } else - { - mpCurrentSlide = makeSlide( xSlide, xRootNode ); - } + mpCurrentSlide = makeSlide( xSlide, xDrawPages, xRootNode ); OSL_ASSERT( mpCurrentSlide ); if (mpCurrentSlide) @@ -1382,6 +1463,129 @@ sal_Bool SlideShowImpl::removeView( return true; } +void SlideShowImpl::registerUserPaintPolygons( const uno::Reference< lang::XMultiServiceFactory >& xDocFactory ) throw (uno::RuntimeException) +{ + //Retrieve Polygons if user ends presentation by context menu + if (mpCurrentSlide) + { + if(findPolygons(mpCurrentSlide->getXDrawPage()) != maPolygons.end()) + maPolygons.erase(mpCurrentSlide->getXDrawPage()); + + maPolygons.insert(make_pair(mpCurrentSlide->getXDrawPage(),mpCurrentSlide->getPolygons())); + } + + //Creating the layer for shapes + // query for the XLayerManager + uno::Reference< drawing::XLayerSupplier > xLayerSupplier(xDocFactory, uno::UNO_QUERY); + uno::Reference< container::XNameAccess > xNameAccess = xLayerSupplier->getLayerManager(); + + uno::Reference< drawing::XLayerManager > xLayerManager(xNameAccess, uno::UNO_QUERY); + // create a layer and set its properties + uno::Reference< drawing::XLayer > xDrawnInSlideshow = xLayerManager->insertNewByIndex(xLayerManager->getCount()); + uno::Reference< beans::XPropertySet > xLayerPropSet(xDrawnInSlideshow, uno::UNO_QUERY); + + //Layer Name which enables to catch annotations + rtl::OUString layerName = rtl::OUString::createFromAscii("DrawnInSlideshow"); + uno::Any aPropLayer; + + aPropLayer <<= layerName; + xLayerPropSet->setPropertyValue(rtl::OUString::createFromAscii("Name"), aPropLayer); + + aPropLayer <<= true; + xLayerPropSet->setPropertyValue(rtl::OUString::createFromAscii("IsVisible"), aPropLayer); + + aPropLayer <<= false; + xLayerPropSet->setPropertyValue(rtl::OUString::createFromAscii("IsLocked"), aPropLayer); + + PolygonMap::iterator aIter=maPolygons.begin(); + + PolyPolygonVector aPolygons; + ::cppcanvas::PolyPolygonSharedPtr pPolyPoly; + ::basegfx::B2DPolyPolygon b2DPolyPoly; + + //Register polygons for each slide + while(aIter!=maPolygons.end()) + { + aPolygons = aIter->second; + //Get shapes for the slide + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > Shapes(aIter->first, ::com::sun::star::uno::UNO_QUERY); + //Retrieve polygons for one slide + for( PolyPolygonVector::iterator aIterPoly=aPolygons.begin(), + aEnd=aPolygons.end(); + aIterPoly!=aEnd; ++aIterPoly ) + { + pPolyPoly = (*aIterPoly); + b2DPolyPoly = ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(pPolyPoly->getUNOPolyPolygon()); + + //Normally there is only one polygon + for(sal_uInt32 i=0; i< b2DPolyPoly.count();i++) + { + const ::basegfx::B2DPolygon& aPoly = b2DPolyPoly.getB2DPolygon(i); + sal_uInt32 nPoints = aPoly.count(); + + if( nPoints > 1) + { + //create the PolyLineShape + uno::Reference< uno::XInterface > polyshape(xDocFactory->createInstance( + rtl::OUString::createFromAscii("com.sun.star.drawing.PolyLineShape") ) ); + uno::Reference< drawing::XShape > rPolyShape(polyshape, uno::UNO_QUERY); + + //Add the shape to the slide + Shapes->add(rPolyShape); + + //Retrieve shape properties + uno::Reference< beans::XPropertySet > aXPropSet = uno::Reference< beans::XPropertySet >( rPolyShape, uno::UNO_QUERY ); + //Construct a sequence of points sequence + drawing::PointSequenceSequence aRetval; + //Create only one sequence for one polygon + aRetval.realloc( 1 ); + // Retrieve the sequence of points from aRetval + drawing::PointSequence* pOuterSequence = aRetval.getArray(); + // Create 2 points in this sequence + pOuterSequence->realloc(nPoints); + // Get these points which are in an array + awt::Point* pInnerSequence = pOuterSequence->getArray(); + for( sal_uInt32 n = 0; n < nPoints; n++ ) + { + //Create a point from the polygon + *pInnerSequence++ = awt::Point( aPoly.getB2DPoint(n).getX(), aPoly.getB2DPoint(n).getY()); + } + + //Fill the properties + //Give the built PointSequenceSequence. + uno::Any aParam; + aParam <<= aRetval; + aXPropSet->setPropertyValue( rtl::OUString::createFromAscii("PolyPolygon"), aParam ); + + //LineStyle : SOLID by default + uno::Any aAny; + drawing::LineStyle eLS; + eLS = drawing::LineStyle_SOLID; + aAny <<= eLS; + aXPropSet->setPropertyValue( rtl::OUString::createFromAscii("LineStyle"), aAny ); + + //LineColor + sal_uInt32 nLineColor; + nLineColor = pPolyPoly->getRGBALineColor(); + //Transform polygon color from RRGGBBAA to AARRGGBB + aAny <<= RGBAColor2UnoColor(nLineColor); + aXPropSet->setPropertyValue( rtl::OUString::createFromAscii("LineColor"), aAny ); + + //LineWidth + double fLineWidth; + fLineWidth = pPolyPoly->getStrokeWidth(); + aAny <<= (sal_Int32)fLineWidth; + aXPropSet->setPropertyValue( rtl::OUString::createFromAscii("LineWidth"), aAny ); + + // make polygons special + xLayerManager->attachShapeToLayer(rPolyShape, xDrawnInSlideshow); + } + } + } + ++aIter; + } +} + sal_Bool SlideShowImpl::setProperty( beans::PropertyValue const& rProperty ) throw (uno::RuntimeException) { @@ -1432,6 +1636,126 @@ sal_Bool SlideShowImpl::setProperty( beans::PropertyValue const& rProperty ) return true; } + //adding support for erasing features in UserPaintOverlay + if (rProperty.Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("EraseAllInk") )) + { + bool nEraseAllInk(false); + if (rProperty.Value >>= nEraseAllInk) + { + OSL_ENSURE( mbMouseVisible, + "setProperty(): User paint overrides invisible mouse" ); + + // enable user paint + maEraseAllInk.reset( nEraseAllInk ); + maEventMultiplexer.notifyEraseAllInk( *maEraseAllInk ); + } + else + { + // disable user paint + maEraseAllInk.reset(); + maEventMultiplexer.notifyUserPaintDisabled(); + } + + if( mnCurrentCursor == awt::SystemPointer::ARROW ) + resetCursor(); + + return true; + } + + if (rProperty.Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("SwitchPenMode") )) + { + bool nSwitchPenMode(false); + if (rProperty.Value >>= nSwitchPenMode) + { + OSL_ENSURE( mbMouseVisible, + "setProperty(): User paint overrides invisible mouse" ); + + if(nSwitchPenMode == true){ + // Switch to Pen Mode + maSwitchPenMode.reset( nSwitchPenMode ); + maEventMultiplexer.notifySwitchPenMode(); + } + } + + if( mnCurrentCursor == awt::SystemPointer::ARROW ) + resetCursor(); + return true; + } + + + if (rProperty.Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("SwitchEraserMode") )) + { + bool nSwitchEraserMode(false); + if (rProperty.Value >>= nSwitchEraserMode) + { + OSL_ENSURE( mbMouseVisible, + "setProperty(): User paint overrides invisible mouse" ); + if(nSwitchEraserMode == true){ + // switch to Eraser mode + maSwitchEraserMode.reset( nSwitchEraserMode ); + maEventMultiplexer.notifySwitchEraserMode(); + } + } + + if( mnCurrentCursor == awt::SystemPointer::ARROW ) + resetCursor(); + return true; + } + + + + if (rProperty.Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("EraseInk") )) + { + sal_Int32 nEraseInk(100); + if (rProperty.Value >>= nEraseInk) + { + OSL_ENSURE( mbMouseVisible, + "setProperty(): User paint overrides invisible mouse" ); + + // enable user paint + maEraseInk.reset( nEraseInk ); + maEventMultiplexer.notifyEraseInkWidth( *maEraseInk ); + } + else + { + // disable user paint + maEraseInk.reset(); + maEventMultiplexer.notifyUserPaintDisabled(); + } + + if( mnCurrentCursor == awt::SystemPointer::ARROW ) + resetCursor(); + + return true; + } + + // new Property for pen's width + if (rProperty.Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("UserPaintStrokeWidth") )) + { + double nWidth(4.0); + if (rProperty.Value >>= nWidth) + { + OSL_ENSURE( mbMouseVisible,"setProperty(): User paint overrides invisible mouse" ); + // enable user paint stroke width + maUserPaintStrokeWidth.reset( nWidth ); + maEventMultiplexer.notifyUserPaintStrokeWidth( *maUserPaintStrokeWidth ); + } + else + { + // disable user paint stroke width + maUserPaintStrokeWidth.reset(); + maEventMultiplexer.notifyUserPaintDisabled(); + } + if( mnCurrentCursor == awt::SystemPointer::ARROW ) + resetCursor(); + return true; + } + if (rProperty.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("AdvanceOnClick") )) { @@ -1940,6 +2264,9 @@ void SlideShowImpl::notifySlideAnimationsEnded() { osl::MutexGuard const guard( m_aMutex ); + //Draw polygons above animations + mpCurrentSlide->drawPolygons(); + OSL_ENSURE( !isDisposed(), "### already disposed!" ); // This struct will receive the (interruptable) event, @@ -2023,7 +2350,7 @@ void SlideShowImpl::notifySlideAnimationsEnded() if (! matches( mpPrefetchSlide, mxPrefetchSlide, mxPrefetchAnimationNode )) { - mpPrefetchSlide = makeSlide( mxPrefetchSlide, + mpPrefetchSlide = makeSlide( mxPrefetchSlide, mxDrawPagesSupplier, mxPrefetchAnimationNode ); } if (mpPrefetchSlide) @@ -2121,6 +2448,8 @@ bool SlideShowImpl::handleAnimationEvent( const AnimationNodeSharedPtr& rNode ) boost::bind( &animations::XAnimationListener::endEvent, _1, boost::cref(xNode) )); + if(mpCurrentSlide->isPaintOverlayActive()) + mpCurrentSlide->drawPolygons(); break; default: break; diff --git a/slideshow/source/engine/tools.cxx b/slideshow/source/engine/tools.cxx index 136e70743916..9d214ad0fd0b 100644 --- a/slideshow/source/engine/tools.cxx +++ b/slideshow/source/engine/tools.cxx @@ -164,10 +164,10 @@ namespace slideshow // ========================= /// extract unary double value from Any - bool extractValue( double& o_rValue, - const uno::Any& rSourceAny, - const ShapeSharedPtr& rShape, - const ::basegfx::B2DVector& rSlideBounds ) + bool extractValue( double& o_rValue, + const uno::Any& rSourceAny, + const ShapeSharedPtr& rShape, + const ::basegfx::B2DVector& rSlideBounds ) { // try to extract numeric value (double, or smaller POD, like float or int) if( (rSourceAny >>= o_rValue) ) @@ -710,6 +710,38 @@ namespace slideshow static_cast< sal_uInt8 >( nColor >> 24U ) ) ); } + sal_Int32 RGBAColor2UnoColor( ::cppcanvas::Color::IntSRGBA aColor ) + { + return ::cppcanvas::makeColorARGB( + // convert from IntSRGBA color to API color + // (0xRRGGBBAA -> 0xAARRGGBB) + static_cast< sal_uInt8 >(0), + ::cppcanvas::getRed(aColor), + ::cppcanvas::getGreen(aColor), + ::cppcanvas::getBlue(aColor)); + } + + /*sal_Int32 RGBAColor2UnoColor( ::cppcanvas::Color::IntSRGBA aColor ) + { + return ::cppcanvas::unMakeColor( + // convert from IntSRGBA color to API color + // (0xRRGGBBAA -> 0xAARRGGBB) + static_cast< sal_uInt8 >(0), + ::cppcanvas::getRed(aColor), + ::cppcanvas::getGreen(aColor), + ::cppcanvas::getBlue(aColor)); + }*/ + + sal_Int8 unSignedToSigned(sal_Int8 nInt) + { + if(nInt < 0 ){ + sal_Int8 nInt2 = nInt >> 1U; + return nInt2; + }else{ + return nInt; + } + } + void fillRect( const ::cppcanvas::CanvasSharedPtr& rCanvas, const ::basegfx::B2DRectangle& rRect, ::cppcanvas::Color::IntSRGBA aFillColor ) @@ -806,12 +838,12 @@ namespace slideshow // determine transformed page bounds const basegfx::B2DRange aRect( 0,0, - rSlideSize.getX(), - rSlideSize.getY() ); + rSlideSize.getX(), + rSlideSize.getY() ); basegfx::B2DRange aTmpRect; canvas::tools::calcTransformedRectBounds( aTmpRect, - aRect, - pView->getTransformation() ); + aRect, + pView->getTransformation() ); // #i42440# Returned slide size is one pixel too small, as // rendering happens one pixel to the right and below the diff --git a/slideshow/source/inc/eventmultiplexer.hxx b/slideshow/source/inc/eventmultiplexer.hxx index 303ae4dda898..a1c932252d7b 100644 --- a/slideshow/source/inc/eventmultiplexer.hxx +++ b/slideshow/source/inc/eventmultiplexer.hxx @@ -486,6 +486,33 @@ public: */ bool notifyUserPaintColor( RGBColor const& rUserColor ); + /** Notify a new user paint width + + Sending this notification also implies that user paint is + enabled. . + + @return true, if this event was processed by + anybody. If false is returned, no handler processed + this event (and probably, nothing will happen at all) + */ + bool notifyUserPaintStrokeWidth( double rUserStrokeWidth ); + + + /** Notify a new user paint erase all ink mode + + Sending this notification also implies that user paint is + enabled. User paint denotes the feature to draw colored lines + on top of the slide content. + + @return true, if this event was processed by + anybody. If false is returned, no handler processed + this event (and probably, nothing will happen at all) + */ + bool notifyEraseAllInk( bool const& rEraseAllInk ); + bool notifySwitchPenMode(); + bool notifySwitchEraserMode(); + bool notifyEraseInkWidth( sal_Int32 rEraseInkSize ); + /** Notify that user paint is disabled User paint denotes the feature to draw colored lines on top of diff --git a/slideshow/source/inc/rgbcolor.hxx b/slideshow/source/inc/rgbcolor.hxx index 1ea168ee80c3..73f14558b494 100644 --- a/slideshow/source/inc/rgbcolor.hxx +++ b/slideshow/source/inc/rgbcolor.hxx @@ -90,6 +90,9 @@ namespace slideshow */ ::cppcanvas::Color::IntSRGBA getIntegerColor() const; + RGBColor(const RGBColor& rLHS); + RGBColor& operator=( const RGBColor& rLHS); + struct RGBTriple { RGBTriple(); diff --git a/slideshow/source/inc/shapeimporter.hxx b/slideshow/source/inc/shapeimporter.hxx index d5e95ac45568..6b3ff7eb2057 100644 --- a/slideshow/source/inc/shapeimporter.hxx +++ b/slideshow/source/inc/shapeimporter.hxx @@ -33,6 +33,9 @@ #include <com/sun/star/drawing/XDrawPage.hpp> #include <com/sun/star/drawing/XShapes.hpp> #include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/drawing/XLayer.hpp> +#include "unoviewcontainer.hxx" +#include "unoview.hxx" #include "shape.hxx" @@ -43,6 +46,10 @@ namespace internal { struct SlideShowContext; +typedef ::std::vector< ::cppcanvas::PolyPolygonSharedPtr> PolyPolygonVector; +typedef ::boost::shared_ptr< UnoView > UnoViewSharedPtr; +typedef ::std::vector< UnoViewSharedPtr > UnoViewVector; + /** This class imports all shapes from a given XShapes object */ class ShapeImporter @@ -75,6 +82,8 @@ public: ::com::sun::star::drawing::XDrawPage >& xPage, const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xActualPage, + const ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XDrawPagesSupplier>& xPagesSupplier, const SlideShowContext& rContext, sal_Int32 nOrdNumStart, bool bConvertingMasterPage ); @@ -95,11 +104,13 @@ public: importShape() call. */ bool isImportDone() const; - + PolyPolygonVector getPolygons(); private: bool isSkip( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> const& xPropSet, - ::rtl::OUString const& shapeType ) const; + ::rtl::OUString const& shapeType, + ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XLayer> const& xLayer); ShapeSharedPtr createShape( ::com::sun::star::uno::Reference< @@ -108,6 +119,8 @@ private: ::com::sun::star::beans::XPropertySet> const& xPropSet, ::rtl::OUString const& shapeType ) const; + void importPolygons(::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > const& xPropSet) ; + struct XShapesEntry { ShapeSharedPtr const mpGroupShape; @@ -130,10 +143,11 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage> mxPage; + ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XDrawPagesSupplier> mxPagesSupplier; const SlideShowContext& mrContext; - + PolyPolygonVector maPolygons; XShapesStack maShapesStack; - double mnAscendingPrio; bool mbConvertingMasterPage; }; diff --git a/slideshow/source/inc/slide.hxx b/slideshow/source/inc/slide.hxx index 90cc7cf6d1b1..9a467c164a96 100644 --- a/slideshow/source/inc/slide.hxx +++ b/slideshow/source/inc/slide.hxx @@ -42,6 +42,7 @@ namespace com { namespace sun { namespace star { namespace drawing { class XDrawPage; + class XDrawPagesSupplier; } namespace uno { class XComponentContext; @@ -63,7 +64,7 @@ namespace slideshow { class RGBColor; class ScreenUpdater; - + typedef ::std::vector< ::cppcanvas::PolyPolygonSharedPtr> PolyPolygonVector; class Slide { public: @@ -117,6 +118,14 @@ namespace slideshow virtual ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode > getXAnimationNode() const = 0; + ///Gets the slide Polygons + virtual PolyPolygonVector getPolygons() = 0; + + ///Draw the slide Polygons + virtual void drawPolygons() const = 0; + + ///Check if slide is already active + virtual bool isPaintOverlayActive() const = 0; // Slide bitmaps // ------------------------------------------------------------------- @@ -183,24 +192,28 @@ namespace slideshow UserEeventQueue */ SlideSharedPtr createSlide( const ::com::sun::star::uno::Reference< - ::com::sun::star::drawing::XDrawPage >& xDrawPage, + ::com::sun::star::drawing::XDrawPage >& xDrawPage, + const ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XDrawPagesSupplier >& xDrawPages, const ::com::sun::star::uno::Reference< - ::com::sun::star::animations::XAnimationNode >& xRootNode, - EventQueue& rEventQueue, - EventMultiplexer& rEventMultiplexer, - ScreenUpdater& rScreenUpdater, - ActivitiesQueue& rActivitiesQueue, - UserEventQueue& rUserEventQueue, - CursorManager& rCursorManager, - const UnoViewContainer& rViewContainer, + ::com::sun::star::animations::XAnimationNode >& xRootNode, + EventQueue& rEventQueue, + EventMultiplexer& rEventMultiplexer, + ScreenUpdater& rScreenUpdater, + ActivitiesQueue& rActivitiesQueue, + UserEventQueue& rUserEventQueue, + CursorManager& rCursorManager, + const UnoViewContainer& rViewContainer, const ::com::sun::star::uno::Reference< - ::com::sun::star::uno::XComponentContext >& xContext, - const ShapeEventListenerMap& rShapeListenerMap, - const ShapeCursorMap& rShapeCursorMap, - RGBColor const& aUserPaintColor, - bool bUserPaintEnabled, - bool bIntrinsicAnimationsAllowed, - bool bDisableAnimationZOrder ); + ::com::sun::star::uno::XComponentContext >& xContext, + const ShapeEventListenerMap& rShapeListenerMap, + const ShapeCursorMap& rShapeCursorMap, + const PolyPolygonVector& rPolyPolygonVector, + RGBColor const& aUserPaintColor, + double dUserPaintStrokeWidth, + bool bUserPaintEnabled, + bool bIntrinsicAnimationsAllowed, + bool bDisableAnimationZOrder ); } } diff --git a/slideshow/source/inc/tools.hxx b/slideshow/source/inc/tools.hxx index bb10864419cb..71d2aae74fc1 100644 --- a/slideshow/source/inc/tools.hxx +++ b/slideshow/source/inc/tools.hxx @@ -289,6 +289,9 @@ namespace slideshow /** Convert a plain UNO API 32 bit int to RGBColor */ RGBColor unoColor2RGBColor( sal_Int32 ); + /** Convert an IntSRGBA to plain UNO API 32 bit int + */ + sal_Int32 RGBAColor2UnoColor( cppcanvas::Color::IntSRGBA ); /** Fill a plain rectangle on the given canvas with the given color */ diff --git a/slideshow/source/inc/userpainteventhandler.hxx b/slideshow/source/inc/userpainteventhandler.hxx index c688af984197..01919e0ae7e0 100644 --- a/slideshow/source/inc/userpainteventhandler.hxx +++ b/slideshow/source/inc/userpainteventhandler.hxx @@ -51,8 +51,12 @@ namespace slideshow { public: virtual ~UserPaintEventHandler() {} - virtual bool colorChanged( RGBColor const& rUserColor ) = 0; + virtual bool widthChanged( double nUserStrokeWidth ) = 0; + virtual bool eraseAllInkChanged(bool const& rEraseAllInk) =0; + virtual bool eraseInkWidthChanged(sal_Int32 rEraseInkSize) =0; + virtual bool switchEraserMode() = 0; + virtual bool switchPenMode() = 0; virtual bool disable() = 0; }; |