xref: /trunk/main/sdext/source/presenter/PresenterNotesView.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_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         associated with the slide given to setCurrentSlide().
86 
87         Iterates over all text shapes on the given notes page and displays
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 
103 
104     // XWindowListener
105 
106     virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent);
107 
108     virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent);
109 
110     virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent);
111 
112     virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent);
113 
114 
115     // XPaintListener
116 
117     virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent);
118 
119 
120     // XResourceId
121 
122     virtual css::uno::Reference<css::drawing::framework::XResourceId> SAL_CALL getResourceId (void);
123 
124     virtual sal_Bool SAL_CALL isAnchorOnly (void);
125 
126 
127     // XDrawView
128 
129     virtual void SAL_CALL setCurrentPage (
130         const css::uno::Reference<css::drawing::XDrawPage>& rxSlide);
131 
132     virtual css::uno::Reference<css::drawing::XDrawPage> SAL_CALL getCurrentPage (void);
133 
134 
135     // XKeyListener
136 
137     virtual void SAL_CALL keyPressed (const css::awt::KeyEvent& rEvent);
138     virtual void SAL_CALL keyReleased (const css::awt::KeyEvent& rEvent);
139 
140 private:
141     css::uno::Reference<css::drawing::framework::XResourceId> mxViewId;
142     ::rtl::Reference<PresenterController> mpPresenterController;
143     css::uno::Reference<css::awt::XWindow> mxParentWindow;
144     css::uno::Reference<css::rendering::XCanvas> mxCanvas;
145     css::uno::Reference<css::drawing::XDrawPage> mxCurrentNotesPage;
146     ::rtl::Reference<PresenterScrollBar> mpScrollBar;
147     css::uno::Reference<css::awt::XWindow> mxToolBarWindow;
148     css::uno::Reference<css::rendering::XCanvas> mxToolBarCanvas;
149     ::rtl::Reference<PresenterToolBar> mpToolBar;
150     ::rtl::Reference<PresenterButton> mpCloseButton;
151     css::util::Color maSeparatorColor;
152     sal_Int32 mnSeparatorYLocation;
153     css::geometry::RealRectangle2D maTextBoundingBox;
154     SharedBitmapDescriptor mpBackground;
155     double mnTop;
156     PresenterTheme::SharedFontDescriptor mpFont;
157     ::boost::shared_ptr<PresenterTextView> mpTextView;
158 
159     void CreateToolBar (
160         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
161         const ::rtl::Reference<PresenterController>& rpPresenterController);
162     void Layout (void);
163     void Paint (const css::awt::Rectangle& rUpdateBox);
164     void PaintToolBar (const css::awt::Rectangle& rUpdateBox);
165     void PaintText (const css::awt::Rectangle& rUpdateBox);
166     void Invalidate (void);
167     void Scroll (const double nDistance);
168     void SetTop (const double nTop);
169     void UpdateScrollBar (void);
170     void MoveCaret (const sal_Int32 nDistance);
171 
172     /** This method throws a DisposedException when the object has already been
173         disposed.
174     */
175     void ThrowIfDisposed (void);
176 };
177 
178 } } // end of namespace ::sdext::presenter
179 
180 #endif
181