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_HELP_VIEW_HXX
25 #define SDEXT_PRESENTER_HELP_VIEW_HXX
26 
27 #include "PresenterController.hxx"
28 #include <cppuhelper/basemutex.hxx>
29 #include <cppuhelper/compbase3.hxx>
30 #include <com/sun/star/awt/XPaintListener.hpp>
31 #include <com/sun/star/awt/XWindowListener.hpp>
32 #include <com/sun/star/drawing/framework/XView.hpp>
33 #include <com/sun/star/drawing/framework/XResourceId.hpp>
34 #include <com/sun/star/frame/XController.hpp>
35 #include <com/sun/star/rendering/XSpriteCanvas.hpp>
36 
37 namespace css = ::com::sun::star;
38 
39 namespace {
40     typedef cppu::WeakComponentImplHelper3<
41         css::drawing::framework::XView,
42         css::awt::XWindowListener,
43         css::awt::XPaintListener
44         > PresenterHelpViewInterfaceBase;
45 }
46 
47 namespace sdext { namespace presenter {
48 
49 class PresenterButton;
50 
51 /** Show help text that describes the defined keys.
52 */
53 class PresenterHelpView
54     : private ::cppu::BaseMutex,
55       public PresenterHelpViewInterfaceBase
56 {
57 public:
58     explicit PresenterHelpView (
59         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
60         const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId,
61         const css::uno::Reference<css::frame::XController>& rxController,
62         const ::rtl::Reference<PresenterController>& rpPresenterController);
63     virtual ~PresenterHelpView (void);
64 
65     virtual void SAL_CALL disposing (void);
66 
67     // lang::XEventListener
68 
69     virtual void SAL_CALL
70         disposing (const css::lang::EventObject& rEventObject)
71         throw (css::uno::RuntimeException);
72 
73 
74     // XWindowListener
75 
76     virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent)
77         throw (css::uno::RuntimeException);
78 
79     virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent)
80         throw (css::uno::RuntimeException);
81 
82     virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent)
83         throw (css::uno::RuntimeException);
84 
85     virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent)
86         throw (css::uno::RuntimeException);
87 
88 
89     // XPaintListener
90 
91     virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent)
92         throw (css::uno::RuntimeException);
93 
94 
95     // XResourceId
96 
97     virtual css::uno::Reference<css::drawing::framework::XResourceId> SAL_CALL getResourceId (void)
98         throw (css::uno::RuntimeException);
99 
100     virtual sal_Bool SAL_CALL isAnchorOnly (void)
101         throw (com::sun::star::uno::RuntimeException);
102 
103 private:
104     class TextContainer;
105 
106     css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
107     css::uno::Reference<css::drawing::framework::XResourceId> mxViewId;
108     css::uno::Reference<css::drawing::framework::XPane> mxPane;
109     css::uno::Reference<css::awt::XWindow> mxWindow;
110     css::uno::Reference<css::rendering::XCanvas> mxCanvas;
111     ::rtl::Reference<PresenterController> mpPresenterController;
112     PresenterTheme::SharedFontDescriptor mpFont;
113     ::boost::scoped_ptr<TextContainer> mpTextContainer;
114     ::rtl::Reference<PresenterButton> mpCloseButton;
115     sal_Int32 mnSeparatorY;
116     sal_Int32 mnMaximalWidth;
117 
118     void ProvideCanvas (void);
119     void Resize (void);
120     void Paint (const css::awt::Rectangle& rRedrawArea);
121     void ReadHelpStrings (void);
122     void ProcessString (
123         const css::uno::Reference<css::beans::XPropertySet>& rsProperties);
124 
125     /** Find a font size, so that all text can be displayed at the same
126         time.
127     */
128     void CheckFontSize (void);
129 
130     /** This method throws a DisposedException when the object has already been
131         disposed.
132     */
133     void ThrowIfDisposed (void)
134         throw (css::lang::DisposedException);
135 };
136 
137 } } // end of namespace ::sdext::presenter
138 
139 #endif
140