[Libreoffice-commits] core.git: Branch 'feature/slideshow_onlySprites' - slideshow/source
Michael Jaumann
meta_dev at yahoo.com
Fri Mar 6 04:40:02 PST 2015
slideshow/source/engine/slide/shapemanagerimpl.cxx | 98 ++++++++++++++++++++-
slideshow/source/engine/slide/shapemanagerimpl.hxx | 22 ++++
slideshow/source/engine/slide/slideimpl.cxx | 7 +
3 files changed, 122 insertions(+), 5 deletions(-)
New commits:
commit 42322e7f428a96eb1b2b10c81221e088613e8d1b
Author: Michael Jaumann <meta_dev at yahoo.com>
Date: Fri Mar 6 12:36:44 2015 +0000
views for shapeManager
Change-Id: I9ff223f03d7edb76092e1c38f56946e35c94f229
diff --git a/slideshow/source/engine/slide/shapemanagerimpl.cxx b/slideshow/source/engine/slide/shapemanagerimpl.cxx
index a2e68b0..47d12bf 100644
--- a/slideshow/source/engine/slide/shapemanagerimpl.cxx
+++ b/slideshow/source/engine/slide/shapemanagerimpl.cxx
@@ -36,13 +36,15 @@ using namespace com::sun::star;
namespace slideshow {
namespace internal {
-ShapeManagerImpl::ShapeManagerImpl( EventMultiplexer& rMultiplexer,
+ShapeManagerImpl::ShapeManagerImpl( const UnoViewContainer& rViews,
+ EventMultiplexer& rMultiplexer,
CursorManager& rCursorManager,
const ShapeEventListenerMap& rGlobalListenersMap,
const ShapeCursorMap& rGlobalCursorMap ):
maXShapeHash( 101 ),
maAllShapes(),
maUpdateShapes(),
+ mrViews(rViews),
mrMultiplexer(rMultiplexer),
mrCursorManager(rCursorManager),
mrGlobalListenersMap(rGlobalListenersMap),
@@ -54,6 +56,31 @@ ShapeManagerImpl::ShapeManagerImpl( EventMultiplexer& rMultiplexer,
{
}
+template<typename LayerFunc,
+ typename ShapeFunc> void ShapeManagerImpl::manageViews(
+ LayerFunc layerFunc,
+ ShapeFunc shapeFunc )
+{
+ LayerSharedPtr pCurrLayer;
+ ViewLayerSharedPtr pCurrViewLayer;
+ LayerShapeMap::const_iterator aIter( maAllShapes.begin() );
+ const LayerShapeMap::const_iterator aEnd ( maAllShapes.end() );
+ while( aIter != aEnd )
+ {
+ LayerSharedPtr pLayer = aIter->second.lock();
+ if( pLayer && pLayer != pCurrLayer )
+ {
+ pCurrLayer = pLayer;
+ pCurrViewLayer = layerFunc(pCurrLayer);
+ }
+
+ if( pCurrViewLayer )
+ shapeFunc(aIter->first,pCurrViewLayer);
+
+ ++aIter;
+ }
+}
+
void ShapeManagerImpl::activate( bool bSlideBackgoundPainted )
{
if( !mbEnabled )
@@ -245,6 +272,75 @@ bool ShapeManagerImpl::handleMouseMoved( const awt::MouseEvent& e )
// handler should see it, too.
}
+void ShapeManagerImpl::viewAdded( const UnoViewSharedPtr& rView )
+{
+ // view must be member of mrViews container
+ OSL_ASSERT( std::find(mrViews.begin(),
+ mrViews.end(),
+ rView) != mrViews.end() );
+
+ // init view content
+ rView->clearAll();
+
+ // add View to all registered shapes
+ manageViews(
+ boost::bind(&Layer::addView,
+ _1,
+ boost::cref(rView)),
+ // repaint on view add
+ boost::bind(&Shape::addViewLayer,
+ _1,
+ _2,
+ true) );
+}
+
+void ShapeManagerImpl::viewRemoved( const UnoViewSharedPtr& rView )
+{
+ // view must not be member of mrViews container anymore
+ OSL_ASSERT( std::find(mrViews.begin(),
+ mrViews.end(),
+ rView) == mrViews.end() );
+
+ // remove View from all registered shapes
+ manageViews(
+ boost::bind(&Layer::removeView,
+ _1,
+ boost::cref(rView)),
+ boost::bind(&Shape::removeViewLayer,
+ _1,
+ _2) );
+}
+
+void ShapeManagerImpl::viewChanged( const UnoViewSharedPtr& rView )
+{
+ (void)rView;
+
+ // view must be member of mrViews container
+ OSL_ASSERT( std::find(mrViews.begin(),
+ mrViews.end(),
+ rView) != mrViews.end() );
+
+ // TODO(P2): selectively update only changed view
+ viewsChanged();
+}
+
+void ShapeManagerImpl::viewsChanged()
+{
+
+ // clear view area
+ ::std::for_each( mrViews.begin(),
+ mrViews.end(),
+ ::boost::mem_fn(&View::clearAll) );
+
+ // TODO(F3): resize and repaint all layers
+
+ // render all shapes
+ std::for_each( maAllShapes.begin(),
+ maAllShapes.end(),
+ boost::bind(&Shape::render,
+ boost::bind( ::o3tl::select1st<LayerShapeMap::value_type>(), _1)) );
+}
+
bool ShapeManagerImpl::update()
{
//if( mbEnabled)
diff --git a/slideshow/source/engine/slide/shapemanagerimpl.hxx b/slideshow/source/engine/slide/shapemanagerimpl.hxx
index 108e58a..ab98c6a 100644
--- a/slideshow/source/engine/slide/shapemanagerimpl.hxx
+++ b/slideshow/source/engine/slide/shapemanagerimpl.hxx
@@ -64,7 +64,8 @@ public:
The slideshow-global event source, where this class
registeres its event handlers.
*/
- ShapeManagerImpl( EventMultiplexer& rMultiplexer,
+ ShapeManagerImpl( const UnoViewContainer& rViews,
+ EventMultiplexer& rMultiplexer,
CursorManager& rCursorManager,
const ShapeEventListenerMap& rGlobalListenersMap,
const ShapeCursorMap& rGlobalCursorMap );
@@ -96,6 +97,12 @@ public:
virtual ShapeSharedPtr lookupShape(
::com::sun::star::uno::Reference<
::com::sun::star::drawing::XShape > const & xShape ) const SAL_OVERRIDE;
+ /// Notify new view added to UnoViewContainer
+ void viewAdded( const UnoViewSharedPtr& rView );
+ /// Notify view removed from UnoViewContainer
+ void viewRemoved( const UnoViewSharedPtr& rView );
+ void viewChanged( const UnoViewSharedPtr& rView );
+ void viewsChanged();
private:
@@ -132,6 +139,16 @@ private:
virtual bool needsUpdate() const SAL_OVERRIDE;
+ /** Add or remove views
+
+ Sharing duplicate code from viewAdded and viewRemoved
+ method. The only point of variation at those places
+ are removal vs. adding.
+ */
+ template<typename LayerFunc,
+ typename ShapeFunc> void manageViews( LayerFunc layerFunc,
+ ShapeFunc shapeFunc );
+
// ShapeManager interface
@@ -189,7 +206,6 @@ private:
*/
void implRemoveShape( const ShapeSharedPtr& rShape );
-
OUString checkForHyperlink( ::basegfx::B2DPoint const& hitPos )const;
@@ -235,6 +251,8 @@ private:
*/
ShapeUpdateSet maUpdateShapes;
+ /// Registered views
+ const UnoViewContainer& mrViews;
EventMultiplexer& mrMultiplexer;
CursorManager& mrCursorManager;
const ShapeEventListenerMap& mrGlobalListenersMap;
diff --git a/slideshow/source/engine/slide/slideimpl.cxx b/slideshow/source/engine/slide/slideimpl.cxx
index 7d7ef62..c27ab9e 100644
--- a/slideshow/source/engine/slide/slideimpl.cxx
+++ b/slideshow/source/engine/slide/slideimpl.cxx
@@ -349,6 +349,7 @@ SlideImpl::SlideImpl( const uno::Reference< drawing::XDrawPage >& xDra
mxDrawPagesSupplier( xDrawPages ),
mxRootNode( xRootNode ),
mpShapeManager( new ShapeManagerImpl(
+ rViewContainer,
rEventMultiplexer,
rCursorManager,
rShapeListenerMap,
@@ -631,11 +632,12 @@ void SlideImpl::viewAdded( const UnoViewSharedPtr& rView )
maSlideBitmaps.push_back(
std::make_pair( rView,
VectorOfSlideBitmaps(SlideAnimationState_NUM_ENTRIES) ));
+ mpShapeManager->viewAdded(rView);
}
void SlideImpl::viewRemoved( const UnoViewSharedPtr& rView )
{
-
+ mpShapeManager->viewRemoved(rView);
const VectorOfVectorOfSlideBitmaps::iterator aEnd( maSlideBitmaps.end() );
maSlideBitmaps.erase(
std::remove_if( maSlideBitmaps.begin(),
@@ -654,13 +656,14 @@ void SlideImpl::viewChanged( const UnoViewSharedPtr& rView )
{
// nothing to do for the Slide - getCurrentSlideBitmap() lazily
// handles bitmap resizes
+ mpShapeManager->viewChanged(rView);
}
void SlideImpl::viewsChanged()
{
// nothing to do for the Slide - getCurrentSlideBitmap() lazily
// handles bitmap resizes
- if( mbActive);
+ mpShapeManager->viewsChanged();
}
bool SlideImpl::requestCursor( sal_Int16 nCursorShape )
More information about the Libreoffice-commits
mailing list