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_NOTES_VIEW2_HXX
25 #define SDEXT_PRESENTER_NOTES_VIEW2_HXX
26 
27 #include "PresenterController.hxx"
28 #include "PresenterToolBar.hxx"
29 #include "PresenterViewFactory.hxx"
30 #include <cppuhelper/basemutex.hxx>
31 #include <cppuhelper/compbase5.hxx>
32 #include <com/sun/star/awt/ActionEvent.hpp>
33 #include <com/sun/star/awt/XActionListener.hpp>
34 #include <com/sun/star/awt/XButton.hpp>
35 #include <com/sun/star/awt/XControl.hpp>
36 #include <com/sun/star/awt/XTextComponent.hpp>
37 #include <com/sun/star/awt/XWindowListener.hpp>
38 #include <com/sun/star/drawing/XDrawPage.hpp>
39 #include <com/sun/star/drawing/XDrawView.hpp>
40 #include <com/sun/star/drawing/framework/XView.hpp>
41 #include <com/sun/star/drawing/framework/XResourceId.hpp>
42 #include <com/sun/star/frame/XController.hpp>
43 #include <rtl/ref.hxx>
44 #include <boost/shared_ptr.hpp>
45 
46 namespace css = ::com::sun::star;
47 
48 namespace {
49     typedef cppu::WeakComponentImplHelper5<
50         css::awt::XWindowListener,
51         css::awt::XPaintListener,
52         css::drawing::framework::XView,
53         css::drawing::XDrawView,
54         css::awt::XKeyListener
55         > PresenterNotesViewInterfaceBase;
56 }
57 
58 namespace sdext { namespace presenter {
59 
60 class PresenterButton;
61 class PresenterScrollBar;
62 class PresenterTextView;
63 
64 
65 /** A drawing framework view of the notes of a slide.  At the moment this is
66     a simple text view that does not show the original formatting of the
67     notes text.
68 */
69 class PresenterNotesView
70     : private ::cppu::BaseMutex,
71       public PresenterNotesViewInterfaceBase,
72       public CachablePresenterView
73 {
74 public:
75     explicit PresenterNotesView (
76         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
77         const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId,
78         const css::uno::Reference<css::frame::XController>& rxController,
79         const ::rtl::Reference<PresenterController>& rpPresenterController);
80     virtual ~PresenterNotesView (void);
81 
82     virtual void SAL_CALL disposing (void);
83 
84     /** Typically called from setCurrentSlide() with the notes page that is
85         associed with the slide given to setCurrentSlide().
86 
87         Iterates over all text shapes on the given notes page and diplays
88         the concatenated text of these.
89     */
90     void SetSlide (
91         const css::uno::Reference<css::drawing::XDrawPage>& rxNotesPage);
92 
93     void ChangeFontSize (const sal_Int32 nSizeChange);
94 
95     ::boost::shared_ptr<PresenterTextView> GetTextView (void) const;
96 
97 
98     // lang::XEventListener
99 
100     virtual void SAL_CALL
101         disposing (const css::lang::EventObject& rEventObject)
102         throw (css::uno::RuntimeException);
103 
104 
105     // XWindowListener
106 
107     virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent)
108         throw (css::uno::RuntimeException);
109 
110     virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent)
111         throw (css::uno::RuntimeException);
112 
113     virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent)
114         throw (css::uno::RuntimeException);
115 
116     virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent)
117         throw (css::uno::RuntimeException);
118 
119 
120     // XPaintListener
121 
122     virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent)
123         throw (css::uno::RuntimeException);
124 
125 
126     // XResourceId
127 
128     virtual css::uno::Reference<css::drawing::framework::XResourceId> SAL_CALL getResourceId (void)
129         throw (css::uno::RuntimeException);
130 
131     virtual sal_Bool SAL_CALL isAnchorOnly (void)
132         throw (com::sun::star::uno::RuntimeException);
133 
134 
135     // XDrawView
136 
137     virtual void SAL_CALL setCurrentPage (
138         const css::uno::Reference<css::drawing::XDrawPage>& rxSlide)
139         throw (css::uno::RuntimeException);
140 
141     virtual css::uno::Reference<css::drawing::XDrawPage> SAL_CALL getCurrentPage (void)
142         throw (css::uno::RuntimeException);
143 
144 
145     // XKeyListener
146 
147     virtual void SAL_CALL keyPressed (const css::awt::KeyEvent& rEvent)
148         throw (css::uno::RuntimeException);
149     virtual void SAL_CALL keyReleased (const css::awt::KeyEvent& rEvent)
150         throw (css::uno::RuntimeException);
151 
152 private:
153     css::uno::Reference<css::drawing::framework::XResourceId> mxViewId;
154     ::rtl::Reference<PresenterController> mpPresenterController;
155     css::uno::Reference<css::awt::XWindow> mxParentWindow;
156     css::uno::Reference<css::rendering::XCanvas> mxCanvas;
157     css::uno::Reference<css::drawing::XDrawPage> mxCurrentNotesPage;
158     ::rtl::Reference<PresenterScrollBar> mpScrollBar;
159     css::uno::Reference<css::awt::XWindow> mxToolBarWindow;
160     css::uno::Reference<css::rendering::XCanvas> mxToolBarCanvas;
161     ::rtl::Reference<PresenterToolBar> mpToolBar;
162     ::rtl::Reference<PresenterButton> mpCloseButton;
163     css::util::Color maSeparatorColor;
164     sal_Int32 mnSeparatorYLocation;
165     css::geometry::RealRectangle2D maTextBoundingBox;
166     SharedBitmapDescriptor mpBackground;
167     double mnTop;
168     PresenterTheme::SharedFontDescriptor mpFont;
169     ::boost::shared_ptr<PresenterTextView> mpTextView;
170 
171     void CreateToolBar (
172         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
173         const ::rtl::Reference<PresenterController>& rpPresenterController);
174     void Layout (void);
175     void Paint (const css::awt::Rectangle& rUpdateBox);
176     void PaintToolBar (const css::awt::Rectangle& rUpdateBox);
177     void PaintText (const css::awt::Rectangle& rUpdateBox);
178     void Invalidate (void);
179     void Scroll (const double nDistance);
180     void SetTop (const double nTop);
181     void UpdateScrollBar (void);
182     void MoveCaret (const sal_Int32 nDistance);
183 
184     /** This method throws a DisposedException when the object has already been
185         disposed.
186     */
187     void ThrowIfDisposed (void)
188         throw (css::lang::DisposedException);
189 };
190 
191 } } // end of namespace ::sdext::presenter
192 
193 #endif
194