1*06bcd5d2SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*06bcd5d2SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*06bcd5d2SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*06bcd5d2SAndrew Rist  * distributed with this work for additional information
6*06bcd5d2SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*06bcd5d2SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*06bcd5d2SAndrew Rist  * "License"); you may not use this file except in compliance
9*06bcd5d2SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*06bcd5d2SAndrew Rist  *
11*06bcd5d2SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*06bcd5d2SAndrew Rist  *
13*06bcd5d2SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*06bcd5d2SAndrew Rist  * software distributed under the License is distributed on an
15*06bcd5d2SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*06bcd5d2SAndrew Rist  * KIND, either express or implied.  See the License for the
17*06bcd5d2SAndrew Rist  * specific language governing permissions and limitations
18*06bcd5d2SAndrew Rist  * under the License.
19*06bcd5d2SAndrew Rist  *
20*06bcd5d2SAndrew Rist  *************************************************************/
21*06bcd5d2SAndrew Rist 
22*06bcd5d2SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef SDEXT_PRESENTER_PRESENTER_SLIDE_SORTER_HXX
25cdf0e10cSrcweir #define SDEXT_PRESENTER_PRESENTER_SLIDE_SORTER_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "PresenterController.hxx"
28cdf0e10cSrcweir #include "PresenterPaneContainer.hxx"
29cdf0e10cSrcweir #include "PresenterViewFactory.hxx"
30cdf0e10cSrcweir #include <cppuhelper/basemutex.hxx>
31cdf0e10cSrcweir #include <cppuhelper/compbase8.hxx>
32cdf0e10cSrcweir #include <com/sun/star/awt/XPaintListener.hpp>
33cdf0e10cSrcweir #include <com/sun/star/awt/XWindowListener.hpp>
34cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyChangeListener.hpp>
35cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawView.hpp>
36cdf0e10cSrcweir #include <com/sun/star/drawing/XSlidePreviewCache.hpp>
37cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XView.hpp>
38cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XResourceId.hpp>
39cdf0e10cSrcweir #include <com/sun/star/frame/XController.hpp>
40cdf0e10cSrcweir #include <com/sun/star/geometry/RealRectangle2D.hpp>
41cdf0e10cSrcweir #include <com/sun/star/rendering/XPolyPolygon2D.hpp>
42cdf0e10cSrcweir #include <com/sun/star/rendering/XSprite.hpp>
43cdf0e10cSrcweir #include <com/sun/star/rendering/XSpriteCanvas.hpp>
44cdf0e10cSrcweir 
45cdf0e10cSrcweir namespace css = ::com::sun::star;
46cdf0e10cSrcweir 
47cdf0e10cSrcweir namespace {
48cdf0e10cSrcweir     typedef cppu::WeakComponentImplHelper8<
49cdf0e10cSrcweir         css::drawing::framework::XView,
50cdf0e10cSrcweir         css::awt::XWindowListener,
51cdf0e10cSrcweir         css::awt::XPaintListener,
52cdf0e10cSrcweir         css::beans::XPropertyChangeListener,
53cdf0e10cSrcweir         css::drawing::XSlidePreviewCacheListener,
54cdf0e10cSrcweir         css::awt::XMouseListener,
55cdf0e10cSrcweir         css::awt::XMouseMotionListener,
56cdf0e10cSrcweir         css::drawing::XDrawView
57cdf0e10cSrcweir         > PresenterSlideSorterInterfaceBase;
58cdf0e10cSrcweir }
59cdf0e10cSrcweir 
60cdf0e10cSrcweir namespace sdext { namespace presenter {
61cdf0e10cSrcweir 
62cdf0e10cSrcweir class PresenterButton;
63cdf0e10cSrcweir class PresenterScrollBar;
64cdf0e10cSrcweir 
65cdf0e10cSrcweir /** A simple slide sorter for the presenter screen.  It uses a preview cache
66cdf0e10cSrcweir     to create the slide previews.  Painting is done via a canvas.
67cdf0e10cSrcweir */
68cdf0e10cSrcweir class PresenterSlideSorter
69cdf0e10cSrcweir     : private ::cppu::BaseMutex,
70cdf0e10cSrcweir       public PresenterSlideSorterInterfaceBase,
71cdf0e10cSrcweir       public CachablePresenterView
72cdf0e10cSrcweir {
73cdf0e10cSrcweir public:
74cdf0e10cSrcweir     PresenterSlideSorter (
75cdf0e10cSrcweir         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
76cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId,
77cdf0e10cSrcweir         const css::uno::Reference<css::frame::XController>& rxController,
78cdf0e10cSrcweir         const ::rtl::Reference<PresenterController>& rpPresenterController);
79cdf0e10cSrcweir     virtual ~PresenterSlideSorter (void);
80cdf0e10cSrcweir 
81cdf0e10cSrcweir     virtual void SAL_CALL disposing (void);
82cdf0e10cSrcweir 
83cdf0e10cSrcweir     void SetActiveState (const bool bIsActive);
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     // lang::XEventListener
87cdf0e10cSrcweir 
88cdf0e10cSrcweir     virtual void SAL_CALL
89cdf0e10cSrcweir         disposing (const css::lang::EventObject& rEventObject)
90cdf0e10cSrcweir         throw (css::uno::RuntimeException);
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 
93cdf0e10cSrcweir     // XWindowListener
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent)
96cdf0e10cSrcweir         throw (css::uno::RuntimeException);
97cdf0e10cSrcweir 
98cdf0e10cSrcweir     virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent)
99cdf0e10cSrcweir         throw (css::uno::RuntimeException);
100cdf0e10cSrcweir 
101cdf0e10cSrcweir     virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent)
102cdf0e10cSrcweir         throw (css::uno::RuntimeException);
103cdf0e10cSrcweir 
104cdf0e10cSrcweir     virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent)
105cdf0e10cSrcweir         throw (css::uno::RuntimeException);
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     // XPaintListener
109cdf0e10cSrcweir 
110cdf0e10cSrcweir     virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent)
111cdf0e10cSrcweir         throw (css::uno::RuntimeException);
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 
114cdf0e10cSrcweir     // XMouseListener
115cdf0e10cSrcweir 
116cdf0e10cSrcweir     virtual void SAL_CALL mousePressed (const css::awt::MouseEvent& rEvent)
117cdf0e10cSrcweir         throw(css::uno::RuntimeException);
118cdf0e10cSrcweir 
119cdf0e10cSrcweir     virtual void SAL_CALL mouseReleased (const css::awt::MouseEvent& rEvent)
120cdf0e10cSrcweir         throw(css::uno::RuntimeException);
121cdf0e10cSrcweir 
122cdf0e10cSrcweir     virtual void SAL_CALL mouseEntered (const css::awt::MouseEvent& rEvent)
123cdf0e10cSrcweir         throw(css::uno::RuntimeException);
124cdf0e10cSrcweir 
125cdf0e10cSrcweir     virtual void SAL_CALL mouseExited (const css::awt::MouseEvent& rEvent)
126cdf0e10cSrcweir         throw(css::uno::RuntimeException);
127cdf0e10cSrcweir 
128cdf0e10cSrcweir 
129cdf0e10cSrcweir     // XMouseMotionListener
130cdf0e10cSrcweir 
131cdf0e10cSrcweir     virtual void SAL_CALL mouseMoved (const css::awt::MouseEvent& rEvent)
132cdf0e10cSrcweir         throw (css::uno::RuntimeException);
133cdf0e10cSrcweir 
134cdf0e10cSrcweir     virtual void SAL_CALL mouseDragged (const css::awt::MouseEvent& rEvent)
135cdf0e10cSrcweir         throw (css::uno::RuntimeException);
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 
138cdf0e10cSrcweir     // XResourceId
139cdf0e10cSrcweir 
140cdf0e10cSrcweir     virtual css::uno::Reference<css::drawing::framework::XResourceId> SAL_CALL getResourceId (void)
141cdf0e10cSrcweir         throw (css::uno::RuntimeException);
142cdf0e10cSrcweir 
143cdf0e10cSrcweir     virtual sal_Bool SAL_CALL isAnchorOnly (void)
144cdf0e10cSrcweir         throw (com::sun::star::uno::RuntimeException);
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 
147cdf0e10cSrcweir     // XPropertyChangeListener
148cdf0e10cSrcweir 
149cdf0e10cSrcweir     virtual void SAL_CALL propertyChange (
150cdf0e10cSrcweir         const css::beans::PropertyChangeEvent& rEvent)
151cdf0e10cSrcweir         throw(css::uno::RuntimeException);
152cdf0e10cSrcweir 
153cdf0e10cSrcweir 
154cdf0e10cSrcweir     // XSlidePreviewCacheListener
155cdf0e10cSrcweir 
156cdf0e10cSrcweir     virtual void SAL_CALL notifyPreviewCreation (
157cdf0e10cSrcweir         sal_Int32 nSlideIndex)
158cdf0e10cSrcweir         throw(css::uno::RuntimeException);
159cdf0e10cSrcweir 
160cdf0e10cSrcweir 
161cdf0e10cSrcweir     // XDrawView
162cdf0e10cSrcweir 
163cdf0e10cSrcweir     virtual void SAL_CALL setCurrentPage (
164cdf0e10cSrcweir         const css::uno::Reference<css::drawing::XDrawPage>& rxSlide)
165cdf0e10cSrcweir         throw (css::uno::RuntimeException);
166cdf0e10cSrcweir 
167cdf0e10cSrcweir     virtual css::uno::Reference<css::drawing::XDrawPage> SAL_CALL getCurrentPage (void)
168cdf0e10cSrcweir         throw (css::uno::RuntimeException);
169cdf0e10cSrcweir 
170cdf0e10cSrcweir private:
171cdf0e10cSrcweir     css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
172cdf0e10cSrcweir     css::uno::Reference<css::drawing::framework::XResourceId> mxViewId;
173cdf0e10cSrcweir     css::uno::Reference<css::drawing::framework::XPane> mxPane;
174cdf0e10cSrcweir     css::uno::Reference<css::rendering::XCanvas> mxCanvas;
175cdf0e10cSrcweir     css::uno::Reference<css::awt::XWindow> mxWindow;
176cdf0e10cSrcweir     ::rtl::Reference<PresenterController> mpPresenterController;
177cdf0e10cSrcweir     css::uno::Reference<css::presentation::XSlideShowController> mxSlideShowController;
178cdf0e10cSrcweir     css::uno::Reference<css::drawing::XSlidePreviewCache> mxPreviewCache;
179cdf0e10cSrcweir     bool mbIsPaintPending;
180cdf0e10cSrcweir     bool mbIsLayoutPending;
181cdf0e10cSrcweir     class Layout;
182cdf0e10cSrcweir     ::boost::shared_ptr<Layout> mpLayout;
183cdf0e10cSrcweir     ::rtl::Reference<PresenterScrollBar> mpHorizontalScrollBar;
184cdf0e10cSrcweir     ::rtl::Reference<PresenterScrollBar> mpVerticalScrollBar;
185cdf0e10cSrcweir     ::rtl::Reference<PresenterButton> mpCloseButton;
186cdf0e10cSrcweir     class MouseOverManager;
187cdf0e10cSrcweir     ::boost::scoped_ptr<MouseOverManager> mpMouseOverManager;
188cdf0e10cSrcweir     sal_Int32 mnSlideIndexMousePressed;
189cdf0e10cSrcweir     sal_Int32 mnCurrentSlideIndex;
190cdf0e10cSrcweir     sal_Int32 mnSeparatorY;
191cdf0e10cSrcweir     css::util::Color maSeparatorColor;
192cdf0e10cSrcweir     css::awt::Point maCloseButtonCenter;
193cdf0e10cSrcweir     css::awt::Rectangle maCurrentSlideFrameBoundingBox;
194cdf0e10cSrcweir     class CurrentSlideFrameRenderer;
195cdf0e10cSrcweir     ::boost::shared_ptr<CurrentSlideFrameRenderer> mpCurrentSlideFrameRenderer;
196cdf0e10cSrcweir     css::uno::Reference<css::rendering::XPolyPolygon2D> mxPreviewFrame;
197cdf0e10cSrcweir 
198cdf0e10cSrcweir     void UpdateLayout (void);
199cdf0e10cSrcweir     css::geometry::RealRectangle2D PlaceScrollBars (
200cdf0e10cSrcweir         const css::geometry::RealRectangle2D& rUpperBox);
201cdf0e10cSrcweir     void PlaceCloseButton (
202cdf0e10cSrcweir         const PresenterPaneContainer::SharedPaneDescriptor& rpPane,
203cdf0e10cSrcweir         const css::awt::Rectangle& rCenterBox,
204cdf0e10cSrcweir     const sal_Int32 nLeftFrameWidth);
205cdf0e10cSrcweir     void ClearBackground (
206cdf0e10cSrcweir         const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
207cdf0e10cSrcweir         const css::awt::Rectangle& rRedrawArea);
208cdf0e10cSrcweir     double GetSlideAspectRatio (void) const;
209cdf0e10cSrcweir     css::uno::Reference<css::rendering::XBitmap> GetPreview (const sal_Int32 nSlideIndex);
210cdf0e10cSrcweir     void PaintPreview (
211cdf0e10cSrcweir         const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
212cdf0e10cSrcweir         const css::awt::Rectangle& rUpdateBox,
213cdf0e10cSrcweir         const sal_Int32 nSlideIndex);
214cdf0e10cSrcweir     void Paint (const css::awt::Rectangle& rUpdateBox);
215cdf0e10cSrcweir     void SetHorizontalOffset (const double nXOffset);
216cdf0e10cSrcweir     void SetVerticalOffset (const double nYOffset);
217cdf0e10cSrcweir     void GotoSlide (const sal_Int32 nSlideIndex);
218cdf0e10cSrcweir     bool ProvideCanvas (void);
219cdf0e10cSrcweir 
220cdf0e10cSrcweir     /** This method throws a DisposedException when the object has already been
221cdf0e10cSrcweir         disposed.
222cdf0e10cSrcweir     */
223cdf0e10cSrcweir     void ThrowIfDisposed (void)
224cdf0e10cSrcweir         throw (css::lang::DisposedException);
225cdf0e10cSrcweir };
226cdf0e10cSrcweir 
227cdf0e10cSrcweir } } // end of namespace ::sdext::presenter
228cdf0e10cSrcweir 
229cdf0e10cSrcweir #endif
230