xref: /AOO41X/main/slideshow/source/engine/slideview.cxx (revision 70f497fb4451dd853e622598505702a3cb5381a8)
1*70f497fbSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*70f497fbSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*70f497fbSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*70f497fbSAndrew Rist  * distributed with this work for additional information
6*70f497fbSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*70f497fbSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*70f497fbSAndrew Rist  * "License"); you may not use this file except in compliance
9*70f497fbSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*70f497fbSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*70f497fbSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*70f497fbSAndrew Rist  * software distributed under the License is distributed on an
15*70f497fbSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*70f497fbSAndrew Rist  * KIND, either express or implied.  See the License for the
17*70f497fbSAndrew Rist  * specific language governing permissions and limitations
18*70f497fbSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*70f497fbSAndrew Rist  *************************************************************/
21*70f497fbSAndrew Rist 
22*70f497fbSAndrew Rist 
23cdf0e10cSrcweir #include "precompiled_slideshow.hxx"
24cdf0e10cSrcweir 
25cdf0e10cSrcweir #include <canvas/debug.hxx>
26cdf0e10cSrcweir #include <tools/diagnose_ex.h>
27cdf0e10cSrcweir #include <canvas/canvastools.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include "eventqueue.hxx"
30cdf0e10cSrcweir #include "eventmultiplexer.hxx"
31cdf0e10cSrcweir #include "slideview.hxx"
32cdf0e10cSrcweir #include "delayevent.hxx"
33cdf0e10cSrcweir #include "unoview.hxx"
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include <rtl/instance.hxx>
36cdf0e10cSrcweir #include <cppuhelper/basemutex.hxx>
37cdf0e10cSrcweir #include <cppuhelper/compbase2.hxx>
38cdf0e10cSrcweir #include <cppuhelper/implementationentry.hxx>
39cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.h>
40cdf0e10cSrcweir #include <comphelper/make_shared_from_uno.hxx>
41cdf0e10cSrcweir 
42cdf0e10cSrcweir #include <cppcanvas/spritecanvas.hxx>
43cdf0e10cSrcweir #include <cppcanvas/customsprite.hxx>
44cdf0e10cSrcweir #include <cppcanvas/vclfactory.hxx>
45cdf0e10cSrcweir #include <cppcanvas/basegfxfactory.hxx>
46cdf0e10cSrcweir 
47cdf0e10cSrcweir #include <tools/debug.hxx>
48cdf0e10cSrcweir 
49cdf0e10cSrcweir #include <basegfx/range/b1drange.hxx>
50cdf0e10cSrcweir #include <basegfx/range/b2drange.hxx>
51cdf0e10cSrcweir #include <basegfx/range/b2irange.hxx>
52cdf0e10cSrcweir #include <basegfx/point/b2dpoint.hxx>
53cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx>
54cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx>
55cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx>
56cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygontools.hxx>
57cdf0e10cSrcweir #include <basegfx/tools/canvastools.hxx>
58cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygonclipper.hxx>
59cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygoncutter.hxx>
60cdf0e10cSrcweir 
61cdf0e10cSrcweir #include <com/sun/star/presentation/XSlideShow.hpp>
62cdf0e10cSrcweir 
63cdf0e10cSrcweir #include <boost/noncopyable.hpp>
64cdf0e10cSrcweir #include <boost/bind.hpp>
65cdf0e10cSrcweir #include <boost/weak_ptr.hpp>
66cdf0e10cSrcweir 
67cdf0e10cSrcweir #include <vector>
68cdf0e10cSrcweir #include <iterator>
69cdf0e10cSrcweir #include <algorithm>
70cdf0e10cSrcweir 
71cdf0e10cSrcweir using namespace com::sun::star;
72cdf0e10cSrcweir 
73cdf0e10cSrcweir namespace slideshow {
74cdf0e10cSrcweir namespace internal {
75cdf0e10cSrcweir 
76cdf0e10cSrcweir namespace {
77cdf0e10cSrcweir 
78cdf0e10cSrcweir struct StaticUnitRectPoly : public rtl::StaticWithInit<basegfx::B2DPolygon, StaticUnitRectPoly>
79cdf0e10cSrcweir {
80cdf0e10cSrcweir     basegfx::B2DPolygon operator()()
81cdf0e10cSrcweir     {
82cdf0e10cSrcweir         return basegfx::tools::createUnitPolygon();
83cdf0e10cSrcweir     }
84cdf0e10cSrcweir };
85cdf0e10cSrcweir 
86cdf0e10cSrcweir /** Sprite entry, to store sprite plus priority
87cdf0e10cSrcweir 
88cdf0e10cSrcweir     The operator<() defines a strict weak ordering of sprites, sort
89cdf0e10cSrcweir     key is the sprite priority.
90cdf0e10cSrcweir  */
91cdf0e10cSrcweir struct SpriteEntry
92cdf0e10cSrcweir {
93cdf0e10cSrcweir     SpriteEntry( const cppcanvas::CustomSpriteSharedPtr& rSprite,
94cdf0e10cSrcweir                  double                                  nPrio ) :
95cdf0e10cSrcweir         mpSprite( rSprite ),
96cdf0e10cSrcweir         mnPriority( nPrio )
97cdf0e10cSrcweir     {
98cdf0e10cSrcweir     }
99cdf0e10cSrcweir 
100cdf0e10cSrcweir     bool operator<(const SpriteEntry& rRHS) const
101cdf0e10cSrcweir     {
102cdf0e10cSrcweir         return mnPriority < rRHS.mnPriority;
103cdf0e10cSrcweir     }
104cdf0e10cSrcweir 
105cdf0e10cSrcweir     boost::weak_ptr< cppcanvas::CustomSprite > mpSprite;
106cdf0e10cSrcweir     double                                     mnPriority;
107cdf0e10cSrcweir };
108cdf0e10cSrcweir 
109cdf0e10cSrcweir typedef std::vector< SpriteEntry > SpriteVector;
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 
112cdf0e10cSrcweir /** Create a clip polygon for slide views
113cdf0e10cSrcweir 
114cdf0e10cSrcweir     @param rClip
115cdf0e10cSrcweir     Clip to set (can be empty)
116cdf0e10cSrcweir 
117cdf0e10cSrcweir     @param rCanvas
118cdf0e10cSrcweir     Canvas to create the clip polygon for
119cdf0e10cSrcweir 
120cdf0e10cSrcweir     @param rUserSize
121cdf0e10cSrcweir     The size of the view. Note that the returned clip will
122cdf0e10cSrcweir     <em>always</em> clip to at least the rect defined herein.
123cdf0e10cSrcweir 
124cdf0e10cSrcweir     @return the view clip polygon, in view coordinates, which is
125cdf0e10cSrcweir     guaranteed to at least clip to the view size.
126cdf0e10cSrcweir  */
127cdf0e10cSrcweir basegfx::B2DPolyPolygon createClipPolygon( const basegfx::B2DPolyPolygon&    rClip,
128cdf0e10cSrcweir                                            const cppcanvas::CanvasSharedPtr& /*rCanvas*/,
129cdf0e10cSrcweir                                            const basegfx::B2DSize&           rUserSize )
130cdf0e10cSrcweir {
131cdf0e10cSrcweir     // setup canvas clipping
132cdf0e10cSrcweir     // =====================
133cdf0e10cSrcweir 
134cdf0e10cSrcweir     // AW: Simplified
135cdf0e10cSrcweir 	const basegfx::B2DRange aClipRange(0, 0, rUserSize.getX(), rUserSize.getY());
136cdf0e10cSrcweir 
137cdf0e10cSrcweir     if(rClip.count())
138cdf0e10cSrcweir     {
139cdf0e10cSrcweir     	return basegfx::tools::clipPolyPolygonOnRange(rClip, aClipRange, true, false);
140cdf0e10cSrcweir     }
141cdf0e10cSrcweir     else
142cdf0e10cSrcweir     {
143cdf0e10cSrcweir         return basegfx::B2DPolyPolygon(basegfx::tools::createPolygonFromRect(aClipRange));
144cdf0e10cSrcweir     }
145cdf0e10cSrcweir }
146cdf0e10cSrcweir 
147cdf0e10cSrcweir /** Prepare given clip polygon to be stored as the current clip
148cdf0e10cSrcweir 
149cdf0e10cSrcweir     Note that this is separate from createClipPolygon(), to allow
150cdf0e10cSrcweir     SlideView implementations to store this intermediate result
151cdf0e10cSrcweir     (createClipPolygon() has to be called every time the view size
152cdf0e10cSrcweir     changes)
153cdf0e10cSrcweir  */
154cdf0e10cSrcweir basegfx::B2DPolyPolygon prepareClip( const basegfx::B2DPolyPolygon& rClip )
155cdf0e10cSrcweir {
156cdf0e10cSrcweir     basegfx::B2DPolyPolygon aClip( rClip );
157cdf0e10cSrcweir 
158cdf0e10cSrcweir     // TODO(P2): unnecessary, once XCanvas is correctly handling this
159cdf0e10cSrcweir     // AW: Should be no longer necessary; tools are now bezier-safe
160cdf0e10cSrcweir     if( aClip.areControlPointsUsed() )
161cdf0e10cSrcweir         aClip = basegfx::tools::adaptiveSubdivideByAngle( aClip );
162cdf0e10cSrcweir 
163cdf0e10cSrcweir     // normalize polygon, preparation for clipping
164cdf0e10cSrcweir     // in updateCanvas()
165cdf0e10cSrcweir     aClip = basegfx::tools::correctOrientations(aClip);
166cdf0e10cSrcweir     aClip = basegfx::tools::solveCrossovers(aClip);
167cdf0e10cSrcweir     aClip = basegfx::tools::stripNeutralPolygons(aClip);
168cdf0e10cSrcweir     aClip = basegfx::tools::stripDispensablePolygons(aClip, false);
169cdf0e10cSrcweir 
170cdf0e10cSrcweir     return aClip;
171cdf0e10cSrcweir }
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 
174cdf0e10cSrcweir void clearRect( ::cppcanvas::CanvasSharedPtr const& pCanvas,
175cdf0e10cSrcweir                 basegfx::B2IRange const&            rArea )
176cdf0e10cSrcweir {
177cdf0e10cSrcweir     // convert clip polygon to device coordinate system
178cdf0e10cSrcweir     ::basegfx::B2DPolyPolygon const* pClipPoly( pCanvas->getClip() );
179cdf0e10cSrcweir     if( pClipPoly )
180cdf0e10cSrcweir     {
181cdf0e10cSrcweir         ::basegfx::B2DPolyPolygon aClipPoly( *pClipPoly );
182cdf0e10cSrcweir         aClipPoly.transform( pCanvas->getTransformation() );
183cdf0e10cSrcweir         pCanvas->setClip( aClipPoly );
184cdf0e10cSrcweir     }
185cdf0e10cSrcweir 
186cdf0e10cSrcweir     // set transformation to identitiy (->device pixel)
187cdf0e10cSrcweir     pCanvas->setTransformation( ::basegfx::B2DHomMatrix() );
188cdf0e10cSrcweir 
189cdf0e10cSrcweir     // #i42440# Fill the _full_ background in
190cdf0e10cSrcweir     // black. Since we had to extend the bitmap by one
191cdf0e10cSrcweir     // pixel, and the bitmap is initialized white,
192cdf0e10cSrcweir     // depending on the slide content a one pixel wide
193cdf0e10cSrcweir     // line will show to the bottom and the right.
194cdf0e10cSrcweir     const ::basegfx::B2DPolygon aPoly(
195cdf0e10cSrcweir         ::basegfx::tools::createPolygonFromRect(
196cdf0e10cSrcweir             basegfx::B2DRange(rArea)));
197cdf0e10cSrcweir 
198cdf0e10cSrcweir     ::cppcanvas::PolyPolygonSharedPtr pPolyPoly(
199cdf0e10cSrcweir         ::cppcanvas::BaseGfxFactory::getInstance().createPolyPolygon( pCanvas,
200cdf0e10cSrcweir                                                                       aPoly ) );
201cdf0e10cSrcweir 
202cdf0e10cSrcweir     if( pPolyPoly )
203cdf0e10cSrcweir     {
204cdf0e10cSrcweir         pPolyPoly->setCompositeOp( cppcanvas::CanvasGraphic::SOURCE );
205cdf0e10cSrcweir         pPolyPoly->setRGBAFillColor( 0x00000000U );
206cdf0e10cSrcweir         pPolyPoly->draw();
207cdf0e10cSrcweir     }
208cdf0e10cSrcweir 
209cdf0e10cSrcweir #if defined(VERBOSE) && defined(DBG_UTIL)
210cdf0e10cSrcweir     ::cppcanvas::CanvasSharedPtr pCliplessCanvas( pCanvas->clone() );
211cdf0e10cSrcweir     pCliplessCanvas->setClip();
212cdf0e10cSrcweir 
213cdf0e10cSrcweir     if( pCanvas->getClip() )
214cdf0e10cSrcweir     {
215cdf0e10cSrcweir         ::cppcanvas::PolyPolygonSharedPtr pPolyPoly2(
216cdf0e10cSrcweir             ::cppcanvas::BaseGfxFactory::getInstance().createPolyPolygon( pCliplessCanvas,
217cdf0e10cSrcweir                                                                           *(pCanvas->getClip()) ));
218cdf0e10cSrcweir         if( pPolyPoly2 )
219cdf0e10cSrcweir         {
220cdf0e10cSrcweir             pPolyPoly2->setRGBALineColor( 0x008000FFU );
221cdf0e10cSrcweir             pPolyPoly2->draw();
222cdf0e10cSrcweir         }
223cdf0e10cSrcweir     }
224cdf0e10cSrcweir #endif
225cdf0e10cSrcweir }
226cdf0e10cSrcweir 
227cdf0e10cSrcweir /** Get bounds in pixel
228cdf0e10cSrcweir 
229cdf0e10cSrcweir     @param rLayerBounds
230cdf0e10cSrcweir     Bound rect, in user space coordinates
231cdf0e10cSrcweir 
232cdf0e10cSrcweir     @param rTransformation
233cdf0e10cSrcweir     User space to device pixel transformation
234cdf0e10cSrcweir 
235cdf0e10cSrcweir     @return the layer bounds in pixel, extended by one pixel to the
236cdf0e10cSrcweir     right and bottom
237cdf0e10cSrcweir  */
238cdf0e10cSrcweir basegfx::B2IRange getLayerBoundsPixel( basegfx::B2DRange const&     rLayerBounds,
239cdf0e10cSrcweir                                        basegfx::B2DHomMatrix const& rTransformation )
240cdf0e10cSrcweir {
241cdf0e10cSrcweir     ::basegfx::B2DRange aTmpRect;
242cdf0e10cSrcweir     ::canvas::tools::calcTransformedRectBounds( aTmpRect,
243cdf0e10cSrcweir                                                 rLayerBounds,
244cdf0e10cSrcweir                                                 rTransformation );
245cdf0e10cSrcweir 
246cdf0e10cSrcweir     if( aTmpRect.isEmpty() )
247cdf0e10cSrcweir         return ::basegfx::B2IRange();
248cdf0e10cSrcweir 
249cdf0e10cSrcweir     // #i42440# Returned layer size is one pixel too small, as
250cdf0e10cSrcweir     // rendering happens one pixel to the right and below the
251cdf0e10cSrcweir     // actual bound rect.
252cdf0e10cSrcweir     return ::basegfx::B2IRange( ::basegfx::fround(aTmpRect.getMinX()),
253cdf0e10cSrcweir                                 ::basegfx::fround(aTmpRect.getMinY()),
254cdf0e10cSrcweir                                 ::basegfx::fround(aTmpRect.getMaxX()) + 1,
255cdf0e10cSrcweir                                 ::basegfx::fround(aTmpRect.getMaxY()) + 1 );
256cdf0e10cSrcweir }
257cdf0e10cSrcweir 
258cdf0e10cSrcweir 
259cdf0e10cSrcweir // ----------------------------------------------------------------
260cdf0e10cSrcweir 
261cdf0e10cSrcweir /** Container class for sprites issued by a ViewLayer
262cdf0e10cSrcweir 
263cdf0e10cSrcweir     This class handles the sprite prioritization issues, that are
264cdf0e10cSrcweir     needed for layer sprites (e.g. the need to re-prioritize sprites
265cdf0e10cSrcweir     when the layer changes prio).
266cdf0e10cSrcweir  */
267cdf0e10cSrcweir class LayerSpriteContainer
268cdf0e10cSrcweir {
269cdf0e10cSrcweir     /** Max fill level of maSprites, before we try to prune it from
270cdf0e10cSrcweir         deceased sprites
271cdf0e10cSrcweir     */
272cdf0e10cSrcweir     enum{ SPRITE_ULLAGE=256 };
273cdf0e10cSrcweir 
274cdf0e10cSrcweir     /** All sprites that have been issued by this container (pruned
275cdf0e10cSrcweir         from time to time, for invalid references). This vector is
276cdf0e10cSrcweir         kept sorted with increasing sprite priority.
277cdf0e10cSrcweir     */
278cdf0e10cSrcweir     SpriteVector       maSprites;
279cdf0e10cSrcweir 
280cdf0e10cSrcweir     /// Priority of this layer, relative to other view layers
281cdf0e10cSrcweir     basegfx::B1DRange  maLayerPrioRange;
282cdf0e10cSrcweir 
283cdf0e10cSrcweir     double getSpritePriority( std::size_t nSpriteNum ) const
284cdf0e10cSrcweir     {
285cdf0e10cSrcweir         // divide the available layer range equally between all
286cdf0e10cSrcweir         // sprites, assign upper bound of individual sprite range as
287cdf0e10cSrcweir         // sprite prio (the layer itself gets assigned the lower bound
288cdf0e10cSrcweir         // of sprite 0's individual range):
289cdf0e10cSrcweir         //
290cdf0e10cSrcweir         // | layer 0                    | layer 1                    | ...
291cdf0e10cSrcweir         // |    sprite 0 |    sprite 1  |    sprite 0 |    sprite 1  | ...
292cdf0e10cSrcweir         return maLayerPrioRange.getMinimum() + maLayerPrioRange.getRange()*(nSpriteNum+1)/(maSprites.size()+1);
293cdf0e10cSrcweir     }
294cdf0e10cSrcweir 
295cdf0e10cSrcweir     /** Rescan sprite vector, and remove deceased sprites (and reset
296cdf0e10cSrcweir         sprite prio)
297cdf0e10cSrcweir 
298cdf0e10cSrcweir         @param aBegin
299cdf0e10cSrcweir         Iterator to the first entry to rescan
300cdf0e10cSrcweir      */
301cdf0e10cSrcweir     void updateSprites()
302cdf0e10cSrcweir     {
303cdf0e10cSrcweir         SpriteVector aValidSprites;
304cdf0e10cSrcweir 
305cdf0e10cSrcweir         // check all sprites for validity and set new priority
306cdf0e10cSrcweir         SpriteVector::iterator       aCurrSprite( maSprites.begin() );
307cdf0e10cSrcweir         const SpriteVector::iterator aEnd( maSprites.end() );
308cdf0e10cSrcweir         while( aCurrSprite != aEnd )
309cdf0e10cSrcweir         {
310cdf0e10cSrcweir             cppcanvas::CustomSpriteSharedPtr pCurrSprite( aCurrSprite->mpSprite.lock() );
311cdf0e10cSrcweir 
312cdf0e10cSrcweir             if( pCurrSprite )
313cdf0e10cSrcweir             {
314cdf0e10cSrcweir                 // only copy still valid sprites over to the refreshed
315cdf0e10cSrcweir                 // sprite vector.
316cdf0e10cSrcweir                 aValidSprites.push_back( *aCurrSprite );
317cdf0e10cSrcweir 
318cdf0e10cSrcweir                 pCurrSprite->setPriority(
319cdf0e10cSrcweir                     getSpritePriority( aValidSprites.size()-1 ));
320cdf0e10cSrcweir             }
321cdf0e10cSrcweir 
322cdf0e10cSrcweir             ++aCurrSprite;
323cdf0e10cSrcweir         }
324cdf0e10cSrcweir 
325cdf0e10cSrcweir         // replace sprite list with pruned one
326cdf0e10cSrcweir         maSprites.swap( aValidSprites );
327cdf0e10cSrcweir     }
328cdf0e10cSrcweir 
329cdf0e10cSrcweir public:
330cdf0e10cSrcweir     LayerSpriteContainer() :
331cdf0e10cSrcweir         maSprites(),
332cdf0e10cSrcweir         maLayerPrioRange()
333cdf0e10cSrcweir     {
334cdf0e10cSrcweir     }
335cdf0e10cSrcweir 
336cdf0e10cSrcweir     basegfx::B1DRange getLayerPriority() const
337cdf0e10cSrcweir     {
338cdf0e10cSrcweir         return maLayerPrioRange;
339cdf0e10cSrcweir     }
340cdf0e10cSrcweir 
341cdf0e10cSrcweir     void setLayerPriority( const basegfx::B1DRange& rRange )
342cdf0e10cSrcweir     {
343cdf0e10cSrcweir         if( rRange != maLayerPrioRange )
344cdf0e10cSrcweir         {
345cdf0e10cSrcweir             maLayerPrioRange = rRange;
346cdf0e10cSrcweir 
347cdf0e10cSrcweir             // prune and recalc sprite prios
348cdf0e10cSrcweir             updateSprites();
349cdf0e10cSrcweir         }
350cdf0e10cSrcweir     }
351cdf0e10cSrcweir 
352cdf0e10cSrcweir     void addSprite( const cppcanvas::CustomSpriteSharedPtr& pSprite,
353cdf0e10cSrcweir                     double                                  nPriority )
354cdf0e10cSrcweir     {
355cdf0e10cSrcweir         if( !pSprite )
356cdf0e10cSrcweir             return;
357cdf0e10cSrcweir 
358cdf0e10cSrcweir         SpriteEntry aEntry( pSprite,nPriority );
359cdf0e10cSrcweir 
360cdf0e10cSrcweir         // insert new sprite, such that vector stays sorted
361cdf0e10cSrcweir         SpriteVector::iterator aInsertPos(
362cdf0e10cSrcweir             maSprites.insert(
363cdf0e10cSrcweir                 std::lower_bound( maSprites.begin(),
364cdf0e10cSrcweir                                   maSprites.end(),
365cdf0e10cSrcweir                                   aEntry ),
366cdf0e10cSrcweir                 aEntry ));
367cdf0e10cSrcweir 
368cdf0e10cSrcweir         const std::size_t nNumSprites( maSprites.size() );
369cdf0e10cSrcweir         if( nNumSprites > SPRITE_ULLAGE ||
370cdf0e10cSrcweir             maSprites.end() - aInsertPos > 1 )
371cdf0e10cSrcweir         {
372cdf0e10cSrcweir             // updateSprites() also updates all sprite prios
373cdf0e10cSrcweir             updateSprites();
374cdf0e10cSrcweir         }
375cdf0e10cSrcweir         else
376cdf0e10cSrcweir         {
377cdf0e10cSrcweir             // added sprite to the end, and not too many sprites in
378cdf0e10cSrcweir             // vector - perform optimized update (only need to set
379cdf0e10cSrcweir             // prio). This basically caters for the common case of
380cdf0e10cSrcweir             // iterated character animations, which generate lots of
381cdf0e10cSrcweir             // sprites, all added to the end.
382cdf0e10cSrcweir             pSprite->setPriority(
383cdf0e10cSrcweir                 getSpritePriority( nNumSprites-1 ));
384cdf0e10cSrcweir         }
385cdf0e10cSrcweir     }
386cdf0e10cSrcweir 
387cdf0e10cSrcweir     void clear()
388cdf0e10cSrcweir     {
389cdf0e10cSrcweir         maSprites.clear();
390cdf0e10cSrcweir     }
391cdf0e10cSrcweir };
392cdf0e10cSrcweir 
393cdf0e10cSrcweir 
394cdf0e10cSrcweir // ----------------------------------------------------------------
395cdf0e10cSrcweir 
396cdf0e10cSrcweir 
397cdf0e10cSrcweir /** This class provides layers for a slide view
398cdf0e10cSrcweir 
399cdf0e10cSrcweir     Layers are used to render animations with the correct z order -
400cdf0e10cSrcweir     because sprites are always in front of the static canvas
401cdf0e10cSrcweir     background, shapes that must appear <em<before</em> an animation
402cdf0e10cSrcweir     must also be displayed as a sprite.
403cdf0e10cSrcweir 
404cdf0e10cSrcweir     Each layer has a priority assigned to it (valid range [0,1]), which
405cdf0e10cSrcweir     also affects all sprites created for this specific layer - i.e. if
406cdf0e10cSrcweir     the layer priority changes, the sprites change z order together
407cdf0e10cSrcweir     with their parent.
408cdf0e10cSrcweir  */
409cdf0e10cSrcweir class SlideViewLayer : public ViewLayer,
410cdf0e10cSrcweir                        private boost::noncopyable
411cdf0e10cSrcweir {
412cdf0e10cSrcweir     /// Smart container for all sprites issued by this layer
413cdf0e10cSrcweir     mutable LayerSpriteContainer             maSpriteContainer;
414cdf0e10cSrcweir 
415cdf0e10cSrcweir     /// Bounds of this layer in user space coordinates
416cdf0e10cSrcweir     basegfx::B2DRange                        maLayerBounds;
417cdf0e10cSrcweir 
418cdf0e10cSrcweir     /// Bounds of this layer in device pixel
419cdf0e10cSrcweir     mutable basegfx::B2IRange                maLayerBoundsPixel;
420cdf0e10cSrcweir 
421cdf0e10cSrcweir     /// Current clip polygon in user coordinates
422cdf0e10cSrcweir     basegfx::B2DPolyPolygon                  maClip;
423cdf0e10cSrcweir 
424cdf0e10cSrcweir     /// Current size of the view in user coordinates
425cdf0e10cSrcweir     basegfx::B2DSize                         maUserSize;
426cdf0e10cSrcweir 
427cdf0e10cSrcweir     /// Current overall view transformation
428cdf0e10cSrcweir     basegfx::B2DHomMatrix                    maTransformation;
429cdf0e10cSrcweir 
430cdf0e10cSrcweir     /// 'parent' canvas, this viewlayer is associated with
431cdf0e10cSrcweir     const cppcanvas::SpriteCanvasSharedPtr   mpSpriteCanvas;
432cdf0e10cSrcweir 
433cdf0e10cSrcweir     /** output surface (necessarily a sprite, won't otherwise be able
434cdf0e10cSrcweir         to display anything <em>before</em> other sprites)
435cdf0e10cSrcweir     */
436cdf0e10cSrcweir     mutable cppcanvas::CustomSpriteSharedPtr mpSprite;
437cdf0e10cSrcweir 
438cdf0e10cSrcweir     /// actual output canvas retrieved from a sprite
439cdf0e10cSrcweir     mutable cppcanvas::CanvasSharedPtr       mpOutputCanvas;
440cdf0e10cSrcweir 
441cdf0e10cSrcweir     /// ptr back to owning view. needed for isOnView() method
442cdf0e10cSrcweir     View const* const                        mpParentView;
443cdf0e10cSrcweir 
444cdf0e10cSrcweir public:
445cdf0e10cSrcweir     /** Create a new layer
446cdf0e10cSrcweir 
447cdf0e10cSrcweir         @param pCanvas
448cdf0e10cSrcweir         Sprite canvas to create the layer on
449cdf0e10cSrcweir 
450cdf0e10cSrcweir         @param rTransform
451cdf0e10cSrcweir         Initial overall canvas transformation
452cdf0e10cSrcweir 
453cdf0e10cSrcweir         @param rLayerBounds
454cdf0e10cSrcweir         Initial layer bounds, in view coordinate system
455cdf0e10cSrcweir      */
456cdf0e10cSrcweir     SlideViewLayer( const cppcanvas::SpriteCanvasSharedPtr& pCanvas,
457cdf0e10cSrcweir                     const basegfx::B2DHomMatrix&            rTransform,
458cdf0e10cSrcweir                     const basegfx::B2DRange&                rLayerBounds,
459cdf0e10cSrcweir                     const basegfx::B2DSize&                 rUserSize,
460cdf0e10cSrcweir                     View const* const                       pParentView) :
461cdf0e10cSrcweir         maSpriteContainer(),
462cdf0e10cSrcweir         maLayerBounds(rLayerBounds),
463cdf0e10cSrcweir         maLayerBoundsPixel(),
464cdf0e10cSrcweir         maClip(),
465cdf0e10cSrcweir         maUserSize(rUserSize),
466cdf0e10cSrcweir         maTransformation(rTransform),
467cdf0e10cSrcweir         mpSpriteCanvas(pCanvas),
468cdf0e10cSrcweir         mpSprite(),
469cdf0e10cSrcweir         mpOutputCanvas(),
470cdf0e10cSrcweir         mpParentView(pParentView)
471cdf0e10cSrcweir     {
472cdf0e10cSrcweir     }
473cdf0e10cSrcweir 
474cdf0e10cSrcweir     void updateView( const basegfx::B2DHomMatrix& rMatrix,
475cdf0e10cSrcweir                      const basegfx::B2DSize&      rUserSize )
476cdf0e10cSrcweir     {
477cdf0e10cSrcweir         maTransformation = rMatrix;
478cdf0e10cSrcweir         maUserSize = rUserSize;
479cdf0e10cSrcweir 
480cdf0e10cSrcweir         // limit layer bounds to visible screen
481cdf0e10cSrcweir         maLayerBounds.intersect( basegfx::B2DRange(0.0,
482cdf0e10cSrcweir                                                    0.0,
483cdf0e10cSrcweir                                                    maUserSize.getX(),
484cdf0e10cSrcweir                                                    maUserSize.getY()) );
485cdf0e10cSrcweir 
486cdf0e10cSrcweir         basegfx::B2IRange const& rNewLayerPixel(
487cdf0e10cSrcweir             getLayerBoundsPixel(maLayerBounds,
488cdf0e10cSrcweir                                 maTransformation) );
489cdf0e10cSrcweir         if( rNewLayerPixel != maLayerBoundsPixel )
490cdf0e10cSrcweir         {
491cdf0e10cSrcweir             // re-gen sprite with new size
492cdf0e10cSrcweir             mpOutputCanvas.reset();
493cdf0e10cSrcweir             mpSprite.reset();
494cdf0e10cSrcweir         }
495cdf0e10cSrcweir     }
496cdf0e10cSrcweir 
497cdf0e10cSrcweir private:
498cdf0e10cSrcweir     // ViewLayer interface
499cdf0e10cSrcweir     // ----------------------------------------------
500cdf0e10cSrcweir 
501cdf0e10cSrcweir     virtual cppcanvas::CustomSpriteSharedPtr createSprite(
502cdf0e10cSrcweir         const ::basegfx::B2DSize& rSpriteSizePixel,
503cdf0e10cSrcweir         double                    nPriority ) const
504cdf0e10cSrcweir     {
505cdf0e10cSrcweir         cppcanvas::CustomSpriteSharedPtr pSprite(
506cdf0e10cSrcweir             mpSpriteCanvas->createCustomSprite( rSpriteSizePixel ) );
507cdf0e10cSrcweir 
508cdf0e10cSrcweir         maSpriteContainer.addSprite( pSprite,
509cdf0e10cSrcweir                                      nPriority );
510cdf0e10cSrcweir 
511cdf0e10cSrcweir         return pSprite;
512cdf0e10cSrcweir     }
513cdf0e10cSrcweir 
514cdf0e10cSrcweir     virtual void setPriority( const basegfx::B1DRange& rRange )
515cdf0e10cSrcweir     {
516cdf0e10cSrcweir         OSL_ENSURE( !rRange.isEmpty() &&
517cdf0e10cSrcweir                     rRange.getMinimum() >= 1.0,
518cdf0e10cSrcweir                     "SlideViewLayer::setPriority(): prio MUST be larger than 1.0 (because "
519cdf0e10cSrcweir                     "the background layer already lies there)" );
520cdf0e10cSrcweir 
521cdf0e10cSrcweir         maSpriteContainer.setLayerPriority( rRange );
522cdf0e10cSrcweir 
523cdf0e10cSrcweir         if( mpSprite )
524cdf0e10cSrcweir             mpSprite->setPriority( rRange.getMinimum() );
525cdf0e10cSrcweir     }
526cdf0e10cSrcweir 
527cdf0e10cSrcweir     virtual basegfx::B2DHomMatrix getTransformation() const
528cdf0e10cSrcweir     {
529cdf0e10cSrcweir         // Offset given transformation by left, top border of given
530cdf0e10cSrcweir         // range (after transformation through given transformation)
531cdf0e10cSrcweir         basegfx::B2DRectangle aTmpRect;
532cdf0e10cSrcweir         canvas::tools::calcTransformedRectBounds( aTmpRect,
533cdf0e10cSrcweir                                                   maLayerBounds,
534cdf0e10cSrcweir                                                   maTransformation );
535cdf0e10cSrcweir 
536cdf0e10cSrcweir         basegfx::B2DHomMatrix aMatrix( maTransformation );
537cdf0e10cSrcweir 
538cdf0e10cSrcweir         // Add translation according to the origin of aTmpRect.  Ignore the
539cdf0e10cSrcweir         // translation when aTmpRect was not properly initialized.
540cdf0e10cSrcweir         if ( ! aTmpRect.isEmpty())
541cdf0e10cSrcweir         {
542cdf0e10cSrcweir             aMatrix.translate( -basegfx::fround(aTmpRect.getMinX()),
543cdf0e10cSrcweir                                -basegfx::fround(aTmpRect.getMinY()) );
544cdf0e10cSrcweir         }
545cdf0e10cSrcweir 
546cdf0e10cSrcweir         return aMatrix;
547cdf0e10cSrcweir     }
548cdf0e10cSrcweir 
549cdf0e10cSrcweir     virtual basegfx::B2DHomMatrix getSpriteTransformation() const
550cdf0e10cSrcweir     {
551cdf0e10cSrcweir         return maTransformation;
552cdf0e10cSrcweir     }
553cdf0e10cSrcweir 
554cdf0e10cSrcweir     virtual void clear() const
555cdf0e10cSrcweir     {
556cdf0e10cSrcweir         // keep layer clip
557cdf0e10cSrcweir         clearRect(getCanvas()->clone(),
558cdf0e10cSrcweir                   maLayerBoundsPixel);
559cdf0e10cSrcweir     }
560cdf0e10cSrcweir 
561cdf0e10cSrcweir     virtual void clearAll() const
562cdf0e10cSrcweir     {
563cdf0e10cSrcweir         ::cppcanvas::CanvasSharedPtr pCanvas( getCanvas()->clone() );
564cdf0e10cSrcweir 
565cdf0e10cSrcweir         // clear layer clip, to clear whole area
566cdf0e10cSrcweir         pCanvas->setClip();
567cdf0e10cSrcweir 
568cdf0e10cSrcweir         clearRect(pCanvas,
569cdf0e10cSrcweir                   maLayerBoundsPixel);
570cdf0e10cSrcweir     }
571cdf0e10cSrcweir 
572cdf0e10cSrcweir     virtual bool isOnView(boost::shared_ptr<View> const& rView) const
573cdf0e10cSrcweir     {
574cdf0e10cSrcweir         return rView.get() == mpParentView;
575cdf0e10cSrcweir     }
576cdf0e10cSrcweir 
577cdf0e10cSrcweir     virtual cppcanvas::CanvasSharedPtr getCanvas() const
578cdf0e10cSrcweir     {
579cdf0e10cSrcweir         if( !mpOutputCanvas )
580cdf0e10cSrcweir         {
581cdf0e10cSrcweir             if( !mpSprite )
582cdf0e10cSrcweir             {
583cdf0e10cSrcweir                 maLayerBoundsPixel = getLayerBoundsPixel(maLayerBounds,
584cdf0e10cSrcweir                                                          maTransformation);
585cdf0e10cSrcweir 
586cdf0e10cSrcweir                 // HACK: ensure at least 1x1 pixel size. clients might
587cdf0e10cSrcweir                 // need an actual canvas (e.g. for bound rect
588cdf0e10cSrcweir                 // calculations) without rendering anything. Better
589cdf0e10cSrcweir                 // solution: introduce something like a reference
590cdf0e10cSrcweir                 // canvas for ViewLayers, which is always available.
591cdf0e10cSrcweir                 if( maLayerBoundsPixel.isEmpty() )
592cdf0e10cSrcweir                     maLayerBoundsPixel = basegfx::B2IRange(0,0,1,1);
593cdf0e10cSrcweir 
594cdf0e10cSrcweir                 const basegfx::B2I64Tuple& rSpriteSize(maLayerBoundsPixel.getRange());
595cdf0e10cSrcweir                 mpSprite = mpSpriteCanvas->createCustomSprite(
596cdf0e10cSrcweir                     basegfx::B2DVector(sal::static_int_cast<sal_Int32>(rSpriteSize.getX()),
597cdf0e10cSrcweir                                        sal::static_int_cast<sal_Int32>(rSpriteSize.getY())) );
598cdf0e10cSrcweir 
599cdf0e10cSrcweir                 mpSprite->setPriority(
600cdf0e10cSrcweir                     maSpriteContainer.getLayerPriority().getMinimum() );
601cdf0e10cSrcweir 
602cdf0e10cSrcweir #if defined(VERBOSE) && defined(DBG_UTIL)
603cdf0e10cSrcweir                 mpSprite->movePixel(
604cdf0e10cSrcweir                     basegfx::B2DPoint(maLayerBoundsPixel.getMinimum()) +
605cdf0e10cSrcweir                     basegfx::B2DPoint(10,10) );
606cdf0e10cSrcweir 
607cdf0e10cSrcweir                 mpSprite->setAlpha(0.5);
608cdf0e10cSrcweir #else
609cdf0e10cSrcweir                 mpSprite->movePixel(
610cdf0e10cSrcweir                     basegfx::B2DPoint(maLayerBoundsPixel.getMinimum()) );
611cdf0e10cSrcweir 
612cdf0e10cSrcweir                 mpSprite->setAlpha(1.0);
613cdf0e10cSrcweir #endif
614cdf0e10cSrcweir                 mpSprite->show();
615cdf0e10cSrcweir             }
616cdf0e10cSrcweir 
617cdf0e10cSrcweir             ENSURE_OR_THROW( mpSprite,
618cdf0e10cSrcweir                               "SlideViewLayer::getCanvas(): no layer sprite" );
619cdf0e10cSrcweir 
620cdf0e10cSrcweir             mpOutputCanvas = mpSprite->getContentCanvas();
621cdf0e10cSrcweir 
622cdf0e10cSrcweir             ENSURE_OR_THROW( mpOutputCanvas,
623cdf0e10cSrcweir                               "SlideViewLayer::getCanvas(): sprite doesn't yield a canvas" );
624cdf0e10cSrcweir 
625cdf0e10cSrcweir             // new canvas retrieved - setup transformation and clip
626cdf0e10cSrcweir             mpOutputCanvas->setTransformation( getTransformation() );
627cdf0e10cSrcweir             mpOutputCanvas->setClip(
628cdf0e10cSrcweir                 createClipPolygon( maClip,
629cdf0e10cSrcweir                                    mpOutputCanvas,
630cdf0e10cSrcweir                                    maUserSize ));
631cdf0e10cSrcweir         }
632cdf0e10cSrcweir 
633cdf0e10cSrcweir         return mpOutputCanvas;
634cdf0e10cSrcweir     }
635cdf0e10cSrcweir 
636cdf0e10cSrcweir     virtual void setClip( const basegfx::B2DPolyPolygon& rClip )
637cdf0e10cSrcweir     {
638cdf0e10cSrcweir         basegfx::B2DPolyPolygon aNewClip = prepareClip( rClip );
639cdf0e10cSrcweir 
640cdf0e10cSrcweir         if( aNewClip != maClip )
641cdf0e10cSrcweir         {
642cdf0e10cSrcweir             maClip = aNewClip;
643cdf0e10cSrcweir 
644cdf0e10cSrcweir             if(mpOutputCanvas )
645cdf0e10cSrcweir                 mpOutputCanvas->setClip(
646cdf0e10cSrcweir                     createClipPolygon( maClip,
647cdf0e10cSrcweir                                        mpOutputCanvas,
648cdf0e10cSrcweir                                        maUserSize ));
649cdf0e10cSrcweir         }
650cdf0e10cSrcweir     }
651cdf0e10cSrcweir 
652cdf0e10cSrcweir     virtual bool resize( const ::basegfx::B2DRange& rArea )
653cdf0e10cSrcweir     {
654cdf0e10cSrcweir         const bool bRet( maLayerBounds != rArea );
655cdf0e10cSrcweir         maLayerBounds = rArea;
656cdf0e10cSrcweir         updateView( maTransformation,
657cdf0e10cSrcweir                     maUserSize );
658cdf0e10cSrcweir 
659cdf0e10cSrcweir         return bRet;
660cdf0e10cSrcweir     }
661cdf0e10cSrcweir };
662cdf0e10cSrcweir 
663cdf0e10cSrcweir 
664cdf0e10cSrcweir // ---------------------------------------------------------
665cdf0e10cSrcweir 
666cdf0e10cSrcweir typedef cppu::WeakComponentImplHelper2<
667cdf0e10cSrcweir     ::com::sun::star::util::XModifyListener,
668cdf0e10cSrcweir       ::com::sun::star::awt::XPaintListener> SlideViewBase;
669cdf0e10cSrcweir 
670cdf0e10cSrcweir /** SlideView class
671cdf0e10cSrcweir 
672cdf0e10cSrcweir     This class implements the View interface, encapsulating
673cdf0e10cSrcweir     <em>one</em> view a slideshow is displayed on.
674cdf0e10cSrcweir  */
675cdf0e10cSrcweir class SlideView : private cppu::BaseMutex,
676cdf0e10cSrcweir                   public SlideViewBase,
677cdf0e10cSrcweir                   public UnoView
678cdf0e10cSrcweir {
679cdf0e10cSrcweir public:
680cdf0e10cSrcweir     SlideView( const uno::Reference<presentation::XSlideShowView>& xView,
681cdf0e10cSrcweir                EventQueue&                                         rEventQueue,
682cdf0e10cSrcweir                EventMultiplexer&                                   rEventMultiplexer );
683cdf0e10cSrcweir     void updateCanvas();
684cdf0e10cSrcweir 
685cdf0e10cSrcweir private:
686cdf0e10cSrcweir     // View:
687cdf0e10cSrcweir     virtual ViewLayerSharedPtr createViewLayer( const basegfx::B2DRange& rLayerBounds ) const;
688cdf0e10cSrcweir     virtual bool updateScreen() const;
689cdf0e10cSrcweir     virtual bool paintScreen() const;
690cdf0e10cSrcweir     virtual void setViewSize( const ::basegfx::B2DSize& );
691cdf0e10cSrcweir     virtual void setCursorShape( sal_Int16 nPointerShape );
692cdf0e10cSrcweir 
693cdf0e10cSrcweir     // ViewLayer interface
694cdf0e10cSrcweir     virtual bool isOnView(boost::shared_ptr<View> const& rView) const;
695cdf0e10cSrcweir     virtual void clear() const;
696cdf0e10cSrcweir     virtual void clearAll() const;
697cdf0e10cSrcweir     virtual cppcanvas::CanvasSharedPtr getCanvas() const;
698cdf0e10cSrcweir     virtual cppcanvas::CustomSpriteSharedPtr createSprite( const ::basegfx::B2DSize& rSpriteSizePixel,
699cdf0e10cSrcweir                                                            double                    nPriority ) const;
700cdf0e10cSrcweir     virtual void setPriority( const basegfx::B1DRange& rRange );
701cdf0e10cSrcweir     virtual ::basegfx::B2DHomMatrix getTransformation() const;
702cdf0e10cSrcweir     virtual basegfx::B2DHomMatrix getSpriteTransformation() const;
703cdf0e10cSrcweir     virtual void setClip( const ::basegfx::B2DPolyPolygon& rClip );
704cdf0e10cSrcweir     virtual bool resize( const ::basegfx::B2DRange& rArea );
705cdf0e10cSrcweir 
706cdf0e10cSrcweir     // UnoView:
707cdf0e10cSrcweir     virtual void _dispose();
708cdf0e10cSrcweir     virtual uno::Reference<presentation::XSlideShowView> getUnoView()const;
709cdf0e10cSrcweir     virtual void setIsSoundEnabled (const bool bValue);
710cdf0e10cSrcweir     virtual bool isSoundEnabled (void) const;
711cdf0e10cSrcweir 
712cdf0e10cSrcweir     // XEventListener:
713cdf0e10cSrcweir     virtual void SAL_CALL disposing( lang::EventObject const& evt )
714cdf0e10cSrcweir         throw (uno::RuntimeException);
715cdf0e10cSrcweir     // XModifyListener:
716cdf0e10cSrcweir     virtual void SAL_CALL modified( const lang::EventObject& aEvent )
717cdf0e10cSrcweir         throw (uno::RuntimeException);
718cdf0e10cSrcweir     // XPaintListener:
719cdf0e10cSrcweir     virtual void SAL_CALL windowPaint( const awt::PaintEvent& e )
720cdf0e10cSrcweir         throw (uno::RuntimeException);
721cdf0e10cSrcweir 
722cdf0e10cSrcweir     // WeakComponentImplHelperBase:
723cdf0e10cSrcweir     virtual void SAL_CALL disposing();
724cdf0e10cSrcweir 
725cdf0e10cSrcweir     void updateClip();
726cdf0e10cSrcweir 
727cdf0e10cSrcweir private:
728cdf0e10cSrcweir     typedef std::vector< boost::weak_ptr<SlideViewLayer> > ViewLayerVector;
729cdf0e10cSrcweir 
730cdf0e10cSrcweir     /// Prune viewlayers from deceased ones, optionally update them
731cdf0e10cSrcweir     void pruneLayers( bool bWithViewLayerUpdate=false ) const;
732cdf0e10cSrcweir 
733cdf0e10cSrcweir     /** Max fill level of maViewLayers, before we try to prune it from
734cdf0e10cSrcweir         deceased layers
735cdf0e10cSrcweir     */
736cdf0e10cSrcweir     enum{ LAYER_ULLAGE=8 };
737cdf0e10cSrcweir 
738cdf0e10cSrcweir     uno::Reference<presentation::XSlideShowView>              mxView;
739cdf0e10cSrcweir     cppcanvas::SpriteCanvasSharedPtr                          mpCanvas;
740cdf0e10cSrcweir 
741cdf0e10cSrcweir     EventMultiplexer&                                         mrEventMultiplexer;
742cdf0e10cSrcweir     EventQueue&                                               mrEventQueue;
743cdf0e10cSrcweir 
744cdf0e10cSrcweir     mutable LayerSpriteContainer                              maSprites;
745cdf0e10cSrcweir     mutable ViewLayerVector                                   maViewLayers;
746cdf0e10cSrcweir 
747cdf0e10cSrcweir     basegfx::B2DPolyPolygon                                   maClip;
748cdf0e10cSrcweir 
749cdf0e10cSrcweir     basegfx::B2DHomMatrix                                     maViewTransform;
750cdf0e10cSrcweir     basegfx::B2DSize                                          maUserSize;
751cdf0e10cSrcweir     bool mbIsSoundEnabled;
752cdf0e10cSrcweir };
753cdf0e10cSrcweir 
754cdf0e10cSrcweir 
755cdf0e10cSrcweir SlideView::SlideView( const uno::Reference<presentation::XSlideShowView>& xView,
756cdf0e10cSrcweir                       EventQueue&                                         rEventQueue,
757cdf0e10cSrcweir                       EventMultiplexer&                                   rEventMultiplexer ) :
758cdf0e10cSrcweir     SlideViewBase( m_aMutex ),
759cdf0e10cSrcweir     mxView( xView ),
760cdf0e10cSrcweir     mpCanvas(),
761cdf0e10cSrcweir     mrEventMultiplexer( rEventMultiplexer ),
762cdf0e10cSrcweir     mrEventQueue( rEventQueue ),
763cdf0e10cSrcweir     maSprites(),
764cdf0e10cSrcweir     maViewLayers(),
765cdf0e10cSrcweir     maClip(),
766cdf0e10cSrcweir     maViewTransform(),
767cdf0e10cSrcweir     maUserSize( 1.0, 1.0 ), // default size: one-by-one rectangle
768cdf0e10cSrcweir     mbIsSoundEnabled(true)
769cdf0e10cSrcweir {
770cdf0e10cSrcweir     // take care not constructing any UNO references to this _inside_
771cdf0e10cSrcweir     // ctor, shift that code to createSlideView()!
772cdf0e10cSrcweir     ENSURE_OR_THROW( mxView.is(),
773cdf0e10cSrcweir                       "SlideView::SlideView(): Invalid view" );
774cdf0e10cSrcweir 
775cdf0e10cSrcweir     mpCanvas = cppcanvas::VCLFactory::getInstance().createSpriteCanvas(
776cdf0e10cSrcweir         xView->getCanvas() );
777cdf0e10cSrcweir     ENSURE_OR_THROW( mpCanvas,
778cdf0e10cSrcweir                       "Could not create cppcanvas" );
779cdf0e10cSrcweir 
780cdf0e10cSrcweir     geometry::AffineMatrix2D aViewTransform(
781cdf0e10cSrcweir         xView->getTransformation() );
782cdf0e10cSrcweir 
783cdf0e10cSrcweir     if( basegfx::fTools::equalZero(
784cdf0e10cSrcweir             basegfx::B2DVector(aViewTransform.m00,
785cdf0e10cSrcweir                                aViewTransform.m10).getLength()) ||
786cdf0e10cSrcweir         basegfx::fTools::equalZero(
787cdf0e10cSrcweir             basegfx::B2DVector(aViewTransform.m01,
788cdf0e10cSrcweir                                aViewTransform.m11).getLength()) )
789cdf0e10cSrcweir     {
790cdf0e10cSrcweir         OSL_ENSURE( false,
791cdf0e10cSrcweir                     "SlideView::SlideView(): Singular matrix!" );
792cdf0e10cSrcweir 
793cdf0e10cSrcweir         canvas::tools::setIdentityAffineMatrix2D(aViewTransform);
794cdf0e10cSrcweir     }
795cdf0e10cSrcweir 
796cdf0e10cSrcweir     basegfx::unotools::homMatrixFromAffineMatrix(
797cdf0e10cSrcweir         maViewTransform, aViewTransform );
798cdf0e10cSrcweir 
799cdf0e10cSrcweir     // once and forever: set fixed prio to this 'layer' (we're always
800cdf0e10cSrcweir     // the background layer)
801cdf0e10cSrcweir     maSprites.setLayerPriority( basegfx::B1DRange(0.0,1.0) );
802cdf0e10cSrcweir }
803cdf0e10cSrcweir 
804cdf0e10cSrcweir void SlideView::disposing()
805cdf0e10cSrcweir {
806cdf0e10cSrcweir     osl::MutexGuard aGuard( m_aMutex );
807cdf0e10cSrcweir 
808cdf0e10cSrcweir     maViewLayers.clear();
809cdf0e10cSrcweir     maSprites.clear();
810cdf0e10cSrcweir     mpCanvas.reset();
811cdf0e10cSrcweir 
812cdf0e10cSrcweir     // additionally, also de-register from XSlideShowView
813cdf0e10cSrcweir     if (mxView.is())
814cdf0e10cSrcweir     {
815cdf0e10cSrcweir         mxView->removeTransformationChangedListener( this );
816cdf0e10cSrcweir         mxView->removePaintListener( this );
817cdf0e10cSrcweir         mxView.clear();
818cdf0e10cSrcweir     }
819cdf0e10cSrcweir }
820cdf0e10cSrcweir 
821cdf0e10cSrcweir ViewLayerSharedPtr SlideView::createViewLayer( const basegfx::B2DRange& rLayerBounds ) const
822cdf0e10cSrcweir {
823cdf0e10cSrcweir     osl::MutexGuard aGuard( m_aMutex );
824cdf0e10cSrcweir 
825cdf0e10cSrcweir     ENSURE_OR_THROW( mpCanvas,
826cdf0e10cSrcweir                       "SlideView::createViewLayer(): Disposed" );
827cdf0e10cSrcweir 
828cdf0e10cSrcweir     const std::size_t nNumLayers( maViewLayers.size() );
829cdf0e10cSrcweir 
830cdf0e10cSrcweir     // avoid filling up layer vector with lots of deceased layer weak
831cdf0e10cSrcweir     // ptrs
832cdf0e10cSrcweir     if( nNumLayers > LAYER_ULLAGE )
833cdf0e10cSrcweir         pruneLayers();
834cdf0e10cSrcweir 
835cdf0e10cSrcweir     boost::shared_ptr<SlideViewLayer> pViewLayer( new SlideViewLayer(mpCanvas,
836cdf0e10cSrcweir                                                                      getTransformation(),
837cdf0e10cSrcweir                                                                      rLayerBounds,
838cdf0e10cSrcweir                                                                      maUserSize,
839cdf0e10cSrcweir                                                                      this) );
840cdf0e10cSrcweir     maViewLayers.push_back( pViewLayer );
841cdf0e10cSrcweir 
842cdf0e10cSrcweir     return pViewLayer;
843cdf0e10cSrcweir }
844cdf0e10cSrcweir 
845cdf0e10cSrcweir bool SlideView::updateScreen() const
846cdf0e10cSrcweir {
847cdf0e10cSrcweir     osl::MutexGuard aGuard( m_aMutex );
848cdf0e10cSrcweir 
849cdf0e10cSrcweir     ENSURE_OR_RETURN_FALSE( mpCanvas.get(),
850cdf0e10cSrcweir                        "SlideView::updateScreen(): Disposed" );
851cdf0e10cSrcweir 
852cdf0e10cSrcweir     return mpCanvas->updateScreen( false );
853cdf0e10cSrcweir }
854cdf0e10cSrcweir 
855cdf0e10cSrcweir bool SlideView::paintScreen() const
856cdf0e10cSrcweir {
857cdf0e10cSrcweir     osl::MutexGuard aGuard( m_aMutex );
858cdf0e10cSrcweir 
859cdf0e10cSrcweir     ENSURE_OR_RETURN_FALSE( mpCanvas.get(),
860cdf0e10cSrcweir                        "SlideView::paintScreen(): Disposed" );
861cdf0e10cSrcweir 
862cdf0e10cSrcweir     return mpCanvas->updateScreen( true );
863cdf0e10cSrcweir }
864cdf0e10cSrcweir 
865cdf0e10cSrcweir void SlideView::clear() const
866cdf0e10cSrcweir {
867cdf0e10cSrcweir     osl::MutexGuard aGuard( m_aMutex );
868cdf0e10cSrcweir 
869cdf0e10cSrcweir     OSL_ENSURE( mxView.is() && mpCanvas,
870cdf0e10cSrcweir                 "SlideView::clear(): Disposed" );
871cdf0e10cSrcweir     if( !mxView.is() || !mpCanvas )
872cdf0e10cSrcweir         return;
873cdf0e10cSrcweir 
874cdf0e10cSrcweir     // keep layer clip
875cdf0e10cSrcweir     clearRect(getCanvas()->clone(),
876cdf0e10cSrcweir               getLayerBoundsPixel(
877cdf0e10cSrcweir                   basegfx::B2DRange(0,0,
878cdf0e10cSrcweir                                     maUserSize.getX(),
879cdf0e10cSrcweir                                     maUserSize.getY()),
880cdf0e10cSrcweir                   getTransformation()));
881cdf0e10cSrcweir }
882cdf0e10cSrcweir 
883cdf0e10cSrcweir void SlideView::clearAll() const
884cdf0e10cSrcweir {
885cdf0e10cSrcweir     osl::MutexGuard aGuard( m_aMutex );
886cdf0e10cSrcweir 
887cdf0e10cSrcweir     OSL_ENSURE( mxView.is() && mpCanvas,
888cdf0e10cSrcweir                 "SlideView::clear(): Disposed" );
889cdf0e10cSrcweir     if( !mxView.is() || !mpCanvas )
890cdf0e10cSrcweir         return;
891cdf0e10cSrcweir 
892cdf0e10cSrcweir     // clear whole view
893cdf0e10cSrcweir     mxView->clear();
894cdf0e10cSrcweir }
895cdf0e10cSrcweir 
896cdf0e10cSrcweir void SlideView::setViewSize( const basegfx::B2DSize& rSize )
897cdf0e10cSrcweir {
898cdf0e10cSrcweir     osl::MutexGuard aGuard( m_aMutex );
899cdf0e10cSrcweir 
900cdf0e10cSrcweir     maUserSize = rSize;
901cdf0e10cSrcweir     updateCanvas();
902cdf0e10cSrcweir }
903cdf0e10cSrcweir 
904cdf0e10cSrcweir void SlideView::setCursorShape( sal_Int16 nPointerShape )
905cdf0e10cSrcweir {
906cdf0e10cSrcweir     osl::MutexGuard const guard( m_aMutex );
907cdf0e10cSrcweir 
908cdf0e10cSrcweir     if (mxView.is())
909cdf0e10cSrcweir         mxView->setMouseCursor( nPointerShape );
910cdf0e10cSrcweir }
911cdf0e10cSrcweir 
912cdf0e10cSrcweir bool SlideView::isOnView(boost::shared_ptr<View> const& rView) const
913cdf0e10cSrcweir {
914cdf0e10cSrcweir     return rView.get() == this;
915cdf0e10cSrcweir }
916cdf0e10cSrcweir 
917cdf0e10cSrcweir cppcanvas::CanvasSharedPtr SlideView::getCanvas() const
918cdf0e10cSrcweir {
919cdf0e10cSrcweir     osl::MutexGuard aGuard( m_aMutex );
920cdf0e10cSrcweir 
921cdf0e10cSrcweir     ENSURE_OR_THROW( mpCanvas,
922cdf0e10cSrcweir                       "SlideView::getCanvas(): Disposed" );
923cdf0e10cSrcweir 
924cdf0e10cSrcweir     return mpCanvas;
925cdf0e10cSrcweir }
926cdf0e10cSrcweir 
927cdf0e10cSrcweir cppcanvas::CustomSpriteSharedPtr SlideView::createSprite(
928cdf0e10cSrcweir     const basegfx::B2DSize& rSpriteSizePixel,
929cdf0e10cSrcweir     double                  nPriority ) const
930cdf0e10cSrcweir {
931cdf0e10cSrcweir     osl::MutexGuard aGuard( m_aMutex );
932cdf0e10cSrcweir 
933cdf0e10cSrcweir     ENSURE_OR_THROW( mpCanvas, "SlideView::createSprite(): Disposed" );
934cdf0e10cSrcweir 
935cdf0e10cSrcweir     cppcanvas::CustomSpriteSharedPtr pSprite(
936cdf0e10cSrcweir         mpCanvas->createCustomSprite( rSpriteSizePixel ) );
937cdf0e10cSrcweir 
938cdf0e10cSrcweir     maSprites.addSprite( pSprite,
939cdf0e10cSrcweir                          nPriority );
940cdf0e10cSrcweir 
941cdf0e10cSrcweir     return pSprite;
942cdf0e10cSrcweir }
943cdf0e10cSrcweir 
944cdf0e10cSrcweir void SlideView::setPriority( const basegfx::B1DRange& /*rRange*/ )
945cdf0e10cSrcweir {
946cdf0e10cSrcweir     osl::MutexGuard aGuard( m_aMutex );
947cdf0e10cSrcweir 
948cdf0e10cSrcweir     OSL_ENSURE( false,
949cdf0e10cSrcweir                 "SlideView::setPriority() is a NOOP for slide view - "
950cdf0e10cSrcweir                 "content will always be shown in the background" );
951cdf0e10cSrcweir }
952cdf0e10cSrcweir 
953cdf0e10cSrcweir basegfx::B2DHomMatrix SlideView::getTransformation() const
954cdf0e10cSrcweir {
955cdf0e10cSrcweir     osl::MutexGuard aGuard( m_aMutex );
956cdf0e10cSrcweir 
957cdf0e10cSrcweir     basegfx::B2DHomMatrix aMatrix;
958cdf0e10cSrcweir     aMatrix.scale( 1.0/maUserSize.getX(), 1.0/maUserSize.getY() );
959cdf0e10cSrcweir 
960cdf0e10cSrcweir     return maViewTransform * aMatrix;
961cdf0e10cSrcweir }
962cdf0e10cSrcweir 
963cdf0e10cSrcweir basegfx::B2DHomMatrix SlideView::getSpriteTransformation() const
964cdf0e10cSrcweir {
965cdf0e10cSrcweir     return getTransformation();
966cdf0e10cSrcweir }
967cdf0e10cSrcweir 
968cdf0e10cSrcweir void SlideView::setClip( const basegfx::B2DPolyPolygon& rClip )
969cdf0e10cSrcweir {
970cdf0e10cSrcweir     osl::MutexGuard aGuard( m_aMutex );
971cdf0e10cSrcweir 
972cdf0e10cSrcweir     basegfx::B2DPolyPolygon aNewClip = prepareClip( rClip );
973cdf0e10cSrcweir 
974cdf0e10cSrcweir     if( aNewClip != maClip )
975cdf0e10cSrcweir     {
976cdf0e10cSrcweir         maClip = aNewClip;
977cdf0e10cSrcweir 
978cdf0e10cSrcweir         updateClip();
979cdf0e10cSrcweir     }
980cdf0e10cSrcweir }
981cdf0e10cSrcweir 
982cdf0e10cSrcweir bool SlideView::resize( const ::basegfx::B2DRange& /*rArea*/ )
983cdf0e10cSrcweir {
984cdf0e10cSrcweir     osl::MutexGuard aGuard( m_aMutex );
985cdf0e10cSrcweir 
986cdf0e10cSrcweir     OSL_ENSURE( false,
987cdf0e10cSrcweir                 "SlideView::resize(): ignored for the View, can't change size "
988cdf0e10cSrcweir                 "effectively, anyway" );
989cdf0e10cSrcweir 
990cdf0e10cSrcweir     return false;
991cdf0e10cSrcweir }
992cdf0e10cSrcweir 
993cdf0e10cSrcweir uno::Reference<presentation::XSlideShowView> SlideView::getUnoView() const
994cdf0e10cSrcweir {
995cdf0e10cSrcweir     osl::MutexGuard aGuard( m_aMutex );
996cdf0e10cSrcweir     return mxView;
997cdf0e10cSrcweir }
998cdf0e10cSrcweir 
999cdf0e10cSrcweir void SlideView::setIsSoundEnabled (const bool bValue)
1000cdf0e10cSrcweir {
1001cdf0e10cSrcweir     mbIsSoundEnabled = bValue;
1002cdf0e10cSrcweir }
1003cdf0e10cSrcweir 
1004cdf0e10cSrcweir bool SlideView::isSoundEnabled (void) const
1005cdf0e10cSrcweir {
1006cdf0e10cSrcweir     return mbIsSoundEnabled;
1007cdf0e10cSrcweir }
1008cdf0e10cSrcweir 
1009cdf0e10cSrcweir void SlideView::_dispose()
1010cdf0e10cSrcweir {
1011cdf0e10cSrcweir     dispose();
1012cdf0e10cSrcweir }
1013cdf0e10cSrcweir 
1014cdf0e10cSrcweir // XEventListener
1015cdf0e10cSrcweir void SlideView::disposing( lang::EventObject const& evt )
1016cdf0e10cSrcweir     throw (uno::RuntimeException)
1017cdf0e10cSrcweir {
1018cdf0e10cSrcweir     (void)evt;
1019cdf0e10cSrcweir 
1020cdf0e10cSrcweir     // no deregistration necessary anymore, XView has left:
1021cdf0e10cSrcweir     osl::MutexGuard const guard( m_aMutex );
1022cdf0e10cSrcweir 
1023cdf0e10cSrcweir     if (mxView.is())
1024cdf0e10cSrcweir     {
1025cdf0e10cSrcweir         OSL_ASSERT( evt.Source == mxView );
1026cdf0e10cSrcweir         mxView.clear();
1027cdf0e10cSrcweir     }
1028cdf0e10cSrcweir 
1029cdf0e10cSrcweir     dispose();
1030cdf0e10cSrcweir }
1031cdf0e10cSrcweir 
1032cdf0e10cSrcweir // XModifyListener
1033cdf0e10cSrcweir void SlideView::modified( const lang::EventObject& /*aEvent*/ )
1034cdf0e10cSrcweir     throw (uno::RuntimeException)
1035cdf0e10cSrcweir {
1036cdf0e10cSrcweir     osl::MutexGuard const guard( m_aMutex );
1037cdf0e10cSrcweir 
1038cdf0e10cSrcweir     OSL_ENSURE( mxView.is(), "SlideView::modified(): "
1039cdf0e10cSrcweir                 "Disposed, but event received from XSlideShowView?!");
1040cdf0e10cSrcweir 
1041cdf0e10cSrcweir     if( !mxView.is() )
1042cdf0e10cSrcweir         return;
1043cdf0e10cSrcweir 
1044cdf0e10cSrcweir     geometry::AffineMatrix2D aViewTransform(
1045cdf0e10cSrcweir         mxView->getTransformation() );
1046cdf0e10cSrcweir 
1047cdf0e10cSrcweir     if( basegfx::fTools::equalZero(
1048cdf0e10cSrcweir             basegfx::B2DVector(aViewTransform.m00,
1049cdf0e10cSrcweir                                aViewTransform.m10).getLength()) ||
1050cdf0e10cSrcweir         basegfx::fTools::equalZero(
1051cdf0e10cSrcweir             basegfx::B2DVector(aViewTransform.m01,
1052cdf0e10cSrcweir                                aViewTransform.m11).getLength()) )
1053cdf0e10cSrcweir     {
1054cdf0e10cSrcweir         OSL_ENSURE( false,
1055cdf0e10cSrcweir                     "SlideView::modified(): Singular matrix!" );
1056cdf0e10cSrcweir 
1057cdf0e10cSrcweir         canvas::tools::setIdentityAffineMatrix2D(aViewTransform);
1058cdf0e10cSrcweir     }
1059cdf0e10cSrcweir 
1060cdf0e10cSrcweir     // view transformation really changed?
1061cdf0e10cSrcweir     basegfx::B2DHomMatrix aNewTransform;
1062cdf0e10cSrcweir     basegfx::unotools::homMatrixFromAffineMatrix(
1063cdf0e10cSrcweir         aNewTransform,
1064cdf0e10cSrcweir         aViewTransform );
1065cdf0e10cSrcweir 
1066cdf0e10cSrcweir     if( aNewTransform == maViewTransform )
1067cdf0e10cSrcweir         return; // No change, nothing to do
1068cdf0e10cSrcweir 
1069cdf0e10cSrcweir     maViewTransform = aNewTransform;
1070cdf0e10cSrcweir 
1071cdf0e10cSrcweir     updateCanvas();
1072cdf0e10cSrcweir 
1073cdf0e10cSrcweir     // notify view change. Don't call EventMultiplexer directly, this
1074cdf0e10cSrcweir     // might not be the main thread!
1075cdf0e10cSrcweir     mrEventQueue.addEvent(
1076cdf0e10cSrcweir         makeEvent( boost::bind( (bool (EventMultiplexer::*)(
1077cdf0e10cSrcweir                                      const uno::Reference<presentation::XSlideShowView>&))
1078cdf0e10cSrcweir                                 &EventMultiplexer::notifyViewChanged,
1079cdf0e10cSrcweir                                 boost::ref(mrEventMultiplexer), mxView ),
1080cdf0e10cSrcweir                    "EventMultiplexer::notifyViewChanged"));
1081cdf0e10cSrcweir }
1082cdf0e10cSrcweir 
1083cdf0e10cSrcweir // XPaintListener
1084cdf0e10cSrcweir void SlideView::windowPaint( const awt::PaintEvent& /*e*/ )
1085cdf0e10cSrcweir     throw (uno::RuntimeException)
1086cdf0e10cSrcweir {
1087cdf0e10cSrcweir     osl::MutexGuard aGuard( m_aMutex );
1088cdf0e10cSrcweir 
1089cdf0e10cSrcweir     OSL_ENSURE( mxView.is() && mpCanvas, "Disposed, but event received?!" );
1090cdf0e10cSrcweir 
1091cdf0e10cSrcweir     // notify view clobbering. Don't call EventMultiplexer directly,
1092cdf0e10cSrcweir     // this might not be the main thread!
1093cdf0e10cSrcweir     mrEventQueue.addEvent(
1094cdf0e10cSrcweir         makeEvent( boost::bind( &EventMultiplexer::notifyViewClobbered,
1095cdf0e10cSrcweir                                 boost::ref(mrEventMultiplexer), mxView ),
1096cdf0e10cSrcweir                    "EventMultiplexer::notifyViewClobbered") );
1097cdf0e10cSrcweir }
1098cdf0e10cSrcweir 
1099cdf0e10cSrcweir void SlideView::updateCanvas()
1100cdf0e10cSrcweir {
1101cdf0e10cSrcweir     OSL_ENSURE( mpCanvas,
1102cdf0e10cSrcweir                 "SlideView::updateCanvasTransform(): Disposed" );
1103cdf0e10cSrcweir 
1104cdf0e10cSrcweir     if( !mpCanvas || !mxView.is())
1105cdf0e10cSrcweir         return;
1106cdf0e10cSrcweir 
1107cdf0e10cSrcweir     mpCanvas->clear(); // this is unnecessary, strictly speaking. but
1108cdf0e10cSrcweir                        // it makes the SlideView behave exactly like a
1109cdf0e10cSrcweir                        // sprite-based SlideViewLayer, because those
1110cdf0e10cSrcweir                        // are created from scratch after a resize
1111cdf0e10cSrcweir     clearAll();
1112cdf0e10cSrcweir     mpCanvas->setTransformation( getTransformation() );
1113cdf0e10cSrcweir     mpCanvas->setClip(
1114cdf0e10cSrcweir         createClipPolygon( maClip,
1115cdf0e10cSrcweir                            mpCanvas,
1116cdf0e10cSrcweir                            maUserSize ));
1117cdf0e10cSrcweir 
1118cdf0e10cSrcweir     // forward update to viewlayers
1119cdf0e10cSrcweir     pruneLayers( true );
1120cdf0e10cSrcweir }
1121cdf0e10cSrcweir 
1122cdf0e10cSrcweir void SlideView::updateClip()
1123cdf0e10cSrcweir {
1124cdf0e10cSrcweir     OSL_ENSURE( mpCanvas,
1125cdf0e10cSrcweir                 "SlideView::updateClip(): Disposed" );
1126cdf0e10cSrcweir 
1127cdf0e10cSrcweir     if( !mpCanvas )
1128cdf0e10cSrcweir         return;
1129cdf0e10cSrcweir 
1130cdf0e10cSrcweir     mpCanvas->setClip(
1131cdf0e10cSrcweir         createClipPolygon( maClip,
1132cdf0e10cSrcweir                            mpCanvas,
1133cdf0e10cSrcweir                            maUserSize ));
1134cdf0e10cSrcweir 
1135cdf0e10cSrcweir     pruneLayers( false );
1136cdf0e10cSrcweir }
1137cdf0e10cSrcweir 
1138cdf0e10cSrcweir void SlideView::pruneLayers( bool bWithViewLayerUpdate ) const
1139cdf0e10cSrcweir {
1140cdf0e10cSrcweir     ViewLayerVector aValidLayers;
1141cdf0e10cSrcweir 
1142cdf0e10cSrcweir     const basegfx::B2DHomMatrix& rCurrTransform(
1143cdf0e10cSrcweir         getTransformation() );
1144cdf0e10cSrcweir 
1145cdf0e10cSrcweir     // check all layers for validity, and retain only the live ones
1146cdf0e10cSrcweir     ViewLayerVector::const_iterator       aCurr( maViewLayers.begin() );
1147cdf0e10cSrcweir     const ViewLayerVector::const_iterator aEnd( maViewLayers.end() );
1148cdf0e10cSrcweir     while( aCurr != aEnd )
1149cdf0e10cSrcweir     {
1150cdf0e10cSrcweir         boost::shared_ptr< SlideViewLayer > pCurrLayer( aCurr->lock() );
1151cdf0e10cSrcweir 
1152cdf0e10cSrcweir         if( pCurrLayer )
1153cdf0e10cSrcweir         {
1154cdf0e10cSrcweir             aValidLayers.push_back( pCurrLayer );
1155cdf0e10cSrcweir 
1156cdf0e10cSrcweir             if( bWithViewLayerUpdate )
1157cdf0e10cSrcweir                 pCurrLayer->updateView( rCurrTransform,
1158cdf0e10cSrcweir                                         maUserSize );
1159cdf0e10cSrcweir         }
1160cdf0e10cSrcweir 
1161cdf0e10cSrcweir         ++aCurr;
1162cdf0e10cSrcweir     }
1163cdf0e10cSrcweir 
1164cdf0e10cSrcweir     // replace layer list with pruned one
1165cdf0e10cSrcweir     maViewLayers.swap( aValidLayers );
1166cdf0e10cSrcweir }
1167cdf0e10cSrcweir 
1168cdf0e10cSrcweir } // anonymous namespace
1169cdf0e10cSrcweir 
1170cdf0e10cSrcweir UnoViewSharedPtr createSlideView( uno::Reference< presentation::XSlideShowView> const& xView,
1171cdf0e10cSrcweir                                   EventQueue&                                          rEventQueue,
1172cdf0e10cSrcweir                                   EventMultiplexer&                                    rEventMultiplexer )
1173cdf0e10cSrcweir {
1174cdf0e10cSrcweir     boost::shared_ptr<SlideView> const that(
1175cdf0e10cSrcweir         comphelper::make_shared_from_UNO(
1176cdf0e10cSrcweir             new SlideView(xView,
1177cdf0e10cSrcweir                           rEventQueue,
1178cdf0e10cSrcweir                           rEventMultiplexer)));
1179cdf0e10cSrcweir 
1180cdf0e10cSrcweir     // register listeners with XSlideShowView
1181cdf0e10cSrcweir     xView->addTransformationChangedListener( that.get() );
1182cdf0e10cSrcweir     xView->addPaintListener( that.get() );
1183cdf0e10cSrcweir 
1184cdf0e10cSrcweir     // set new transformation
1185cdf0e10cSrcweir     that->updateCanvas();
1186cdf0e10cSrcweir 
1187cdf0e10cSrcweir     return that;
1188cdf0e10cSrcweir }
1189cdf0e10cSrcweir 
1190cdf0e10cSrcweir } // namespace internal
1191cdf0e10cSrcweir } // namespace slideshow
1192cdf0e10cSrcweir 
1193