xref: /trunk/main/sdext/source/presenter/PresenterSlidePreview.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SDEXT_PRESENTER_SLIDE_PREVIEW_HXX
25 #define SDEXT_PRESENTER_SLIDE_PREVIEW_HXX
26 
27 #include "PresenterController.hxx"
28 
29 #include <boost/noncopyable.hpp>
30 #include <com/sun/star/awt/XBitmap.hpp>
31 #include <com/sun/star/awt/XDisplayBitmap.hpp>
32 #include <com/sun/star/awt/XPaintListener.hpp>
33 #include <com/sun/star/awt/XWindowListener.hpp>
34 #include <com/sun/star/drawing/XDrawPage.hpp>
35 #include <com/sun/star/drawing/XDrawView.hpp>
36 #include <com/sun/star/drawing/XSlideRenderer.hpp>
37 #include <com/sun/star/drawing/framework/XPane.hpp>
38 #include <com/sun/star/drawing/framework/XView.hpp>
39 #include <com/sun/star/lang/DisposedException.hpp>
40 #include <com/sun/star/uno/XComponentContext.hpp>
41 #include <cppuhelper/basemutex.hxx>
42 #include <cppuhelper/compbase4.hxx>
43 #include <rtl/ref.hxx>
44 
45 namespace css = ::com::sun::star;
46 
47 namespace sdext { namespace presenter {
48 
49 namespace {
50     typedef ::cppu::WeakComponentImplHelper4 <
51         css::drawing::framework::XView,
52         css::drawing::XDrawView,
53         css::awt::XPaintListener,
54         css::awt::XWindowListener
55     > PresenterSlidePreviewInterfaceBase;
56 }
57 
58 
59 /** Static preview of a slide.  Typically used for the preview of the next
60     slide.
61     This implementation shows a preview of the slide given to the
62     setCurrentSlide.  For showing the next slide the PresenterViewFactory
63     uses a derived class that overloads the setCurrentSlide() method.
64 */
65 class PresenterSlidePreview
66     : private ::boost::noncopyable,
67       private ::cppu::BaseMutex,
68       public PresenterSlidePreviewInterfaceBase
69 {
70 public:
71     PresenterSlidePreview (
72         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
73         const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId,
74         const css::uno::Reference<css::drawing::framework::XPane>& rxAnchorPane,
75         const ::rtl::Reference<PresenterController>& rpPresenterController);
76     virtual ~PresenterSlidePreview (void);
77     virtual void SAL_CALL disposing (void);
78 
79 
80     // XResourceId
81 
82     virtual css::uno::Reference<css::drawing::framework::XResourceId> SAL_CALL getResourceId (void);
83 
84     virtual sal_Bool SAL_CALL isAnchorOnly (void);
85 
86     // XWindowListener
87 
88     virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent);
89 
90     virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent);
91 
92     virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent);
93 
94     virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent);
95 
96 
97     // XPaintListener
98 
99     virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent);
100 
101 
102     // lang::XEventListener
103     virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent);
104 
105 
106     // XDrawView
107 
108     virtual void SAL_CALL setCurrentPage (
109         const css::uno::Reference<css::drawing::XDrawPage>& rxSlide);
110 
111     virtual css::uno::Reference<css::drawing::XDrawPage> SAL_CALL getCurrentPage (void);
112 
113 protected:
114     ::rtl::Reference<PresenterController> mpPresenterController;
115 
116 private:
117     css::uno::Reference<css::drawing::framework::XPane> mxPane;
118     css::uno::Reference<css::drawing::framework::XResourceId> mxViewId;
119     css::uno::Reference<css::drawing::XSlideRenderer> mxPreviewRenderer;
120 
121     /** This Image holds the preview of the current slide.  After resize
122         requests the image may be empty.  This results eventually in a call
123         to ProvideSlide() in order to created a preview in the correct new
124         size.
125     */
126     css::uno::Reference<css::rendering::XBitmap> mxPreview;
127 
128     /**  The current slide for which a preview is displayed.  This may or
129         may not be the same as the current slide of the PresenterView.
130     */
131     css::uno::Reference<css::drawing::XDrawPage> mxCurrentSlide;
132     double mnSlideAspectRatio;
133 
134     css::uno::Reference<css::awt::XWindow> mxWindow;
135     css::uno::Reference<css::rendering::XCanvas> mxCanvas;
136 
137     /** Set the given slide as the current slide of the called PresenterSlidePreview
138         object.
139     */
140     void SetSlide (const css::uno::Reference<css::drawing::XDrawPage>& rxPage);
141 
142     /** Paint the preview of the current slide centered in the window of the
143         anchor pane.
144     */
145     void Paint (const css::awt::Rectangle& rBoundingBox);
146 
147     /** React to a resize of the anchor pane.
148     */
149     void Resize (void);
150 
151     /** This method throws a DisposedException when the object has already been
152         disposed.
153     */
154     void ThrowIfDisposed (void);
155 };
156 
157 } } // end of namespace ::sd::presenter
158 
159 #endif
160