1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef SD_PRESENTER_CANVAS_UPDATE_REQUESTER_HEADER
29 #define SD_PRESENTER_CANVAS_UPDATE_REQUESTER_HEADER
30 
31 #include "precompiled_sd.hxx"
32 
33 #include <com/sun/star/rendering/XSpriteCanvas.hpp>
34 #include <boost/noncopyable.hpp>
35 #include <boost/shared_ptr.hpp>
36 #include <sal/types.h>
37 #include <tools/solar.h>
38 #include <tools/link.hxx>
39 #include <vector>
40 
41 namespace css = ::com::sun::star;
42 
43 namespace sd { namespace presenter {
44 
45 /** Each UpdateRequester handles update requests (calls to
46     XCanvas::updateScreen()) for one shared canvas (a canvas that has one or
47     more PresenterCanvas wrappers).  Multiple calls are collected and lead
48     to a single call to updateScreen.
49 */
50 class CanvasUpdateRequester : private ::boost::noncopyable
51 {
52 public:
53     /** Return the Canvas UpdateRequester object for the given shared
54         canvas.  A new object is created when it does not already exist.
55     */
56     static ::boost::shared_ptr<CanvasUpdateRequester> Instance (
57         const css::uno::Reference<css::rendering::XSpriteCanvas>& rxCanvas);
58 
59     void RequestUpdate (const sal_Bool bUpdateAll);
60 
61 private:
62     CanvasUpdateRequester (const css::uno::Reference<css::rendering::XSpriteCanvas>& rxCanvas);
63     ~CanvasUpdateRequester (void);
64     class Deleter; friend class Deleter;
65 
66     typedef ::std::vector<
67         ::std::pair<
68             css::uno::Reference<css::rendering::XSpriteCanvas>,
69            ::boost::shared_ptr<CanvasUpdateRequester> > > RequesterMap;
70     static RequesterMap maRequesterMap;
71 
72     css::uno::Reference<css::rendering::XSpriteCanvas> mxCanvas;
73     sal_uLong mnUserEventId;
74     sal_Bool mbUpdateFlag;
75     DECL_LINK(Callback, void*);
76 };
77 
78 } } // end of namespace ::sd::presenter
79 
80 #endif
81