xref: /aoo41x/main/sd/source/ui/inc/framework/Pane.hxx (revision 67e470da)
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 SD_FRAMEWORK_PANE_HXX
25 #define SD_FRAMEWORK_PANE_HXX
26 
27 #include "MutexOwner.hxx"
28 
29 #include <com/sun/star/drawing/framework/XPane.hpp>
30 #include <com/sun/star/drawing/framework/XPane2.hpp>
31 #include <com/sun/star/drawing/framework/TabBarButton.hpp>
32 #include <com/sun/star/lang/XUnoTunnel.hpp>
33 #include <cppuhelper/compbase3.hxx>
34 #include <tools/link.hxx>
35 #include <boost/shared_ptr.hpp>
36 #include <boost/weak_ptr.hpp>
37 
38 class Window;
39 
40 namespace css = ::com::sun::star;
41 namespace cssu = ::com::sun::star::uno;
42 
43 namespace {
44 
45 typedef ::cppu::WeakComponentImplHelper3 <
46     ::com::sun::star::drawing::framework::XPane,
47     ::com::sun::star::drawing::framework::XPane2,
48       ::com::sun::star::lang::XUnoTunnel
49     > PaneInterfaceBase;
50 
51 } // end of anonymous namespace.
52 
53 namespace sd { namespace framework {
54 
55 /** A pane is a wrapper for a window and possibly for a tab bar (for view
56     switching).  Panes are unique resources.
57 
58     This class has two responsibilities:
59     1. It implements the XPane interface.  This is the most important
60     interface of this class for API based views (of which there not that
61     many yet) because it gives access to the XWindow.
62     2. It gives access to the underlying VCL Window by implementing the
63     XUnoTunnel interface.  This is necessary at the moment and in the
64     foreseeable future because many parts of the Draw and Impress views rely
65     on direct access on the Window class.
66 */
67 class Pane
68     : protected MutexOwner,
69       public PaneInterfaceBase
70 {
71 public:
72     /** Create a new Pane object that wrapps the given window.
73         @param rsPaneURL
74             The URL that is used by the configuration to identify the pane.
75             The given URL has to be valid.
76         @param pWindow
77             The VCL Window (usually this really is an sd::Window) that is
78             wrapped by the new Pane object.  The given pointer must not be
79             NULL.
80     */
81 	Pane (
82         const ::com::sun::star::uno::Reference<
83             com::sun::star::drawing::framework::XResourceId>& rxPaneId,
84         ::Window* pWindow)
85         throw ();
86 	virtual ~Pane (void) throw();
87 
88     virtual void SAL_CALL disposing (void);
89 
90     static const ::com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId (void);
91 
92     /** This method is typically used together with the XUnoTunnel to obtain
93         a Window pointer from an XPane object.
94     */
95     virtual ::Window* GetWindow (void);
96 
97 
98     //----- XPane -------------------------------------------------------------
99 
100     /** For a UNO API based implementation of a view this may the most
101         important method of this class because the view is only interested
102         in the window of the pane.
103     */
104     virtual cssu::Reference<css::awt::XWindow>
105         SAL_CALL getWindow (void)
106         throw (cssu::RuntimeException);
107 
108     virtual cssu::Reference<css::rendering::XCanvas>
109         SAL_CALL getCanvas (void)
110         throw (cssu::RuntimeException);
111 
112 
113     //----- XPane2 -------------------------------------------------------------
114 
115     virtual sal_Bool SAL_CALL isVisible (void)
116         throw (cssu::RuntimeException);
117 
118     virtual void SAL_CALL setVisible (sal_Bool bIsVisible)
119         throw (cssu::RuntimeException);
120 
121     virtual cssu::Reference<css::accessibility::XAccessible> SAL_CALL getAccessible (void)
122         throw (cssu::RuntimeException);
123 
124     virtual void SAL_CALL setAccessible (
125         const cssu::Reference<css::accessibility::XAccessible>& rxAccessible)
126         throw (cssu::RuntimeException);
127 
128 
129     //----- XResource ---------------------------------------------------------
130 
131     virtual ::com::sun::star::uno::Reference<com::sun::star::drawing::framework::XResourceId>
132         SAL_CALL getResourceId (void)
133         throw (::com::sun::star::uno::RuntimeException);
134 
135     /** For the typical pane it makes no sense to be dislayed without a
136         view.  Therefore this default implementation returns always <TRUE/>.
137     */
138     virtual sal_Bool SAL_CALL isAnchorOnly (void)
139         throw (com::sun::star::uno::RuntimeException);
140 
141 
142     //----- XUnoTunnel --------------------------------------------------------
143 
144     virtual sal_Int64 SAL_CALL getSomething (const com::sun::star::uno::Sequence<sal_Int8>& rId)
145         throw (com::sun::star::uno::RuntimeException);
146 
147 
148 protected:
149     ::com::sun::star::uno::Reference<com::sun::star::drawing::framework::XResourceId> mxPaneId;
150     ::Window* mpWindow;
151     ::com::sun::star::uno::Reference<com::sun::star::awt::XWindow> mxWindow;
152     ::com::sun::star::uno::Reference<com::sun::star::rendering::XCanvas> mxCanvas;
153 
154     /** Overload this method, not getCanvas(), when you want to provide a
155         different canvas.
156     */
157     virtual ::com::sun::star::uno::Reference<com::sun::star::rendering::XCanvas>
158         CreateCanvas (void)
159         throw (::com::sun::star::uno::RuntimeException);
160 
161     /** Throw DisposedException when the object has already been disposed or
162         is currently being disposed.  Otherwise this method returns
163         normally.
164     */
165     void ThrowIfDisposed (void) const
166         throw (::com::sun::star::lang::DisposedException);
167 };
168 
169 } } // end of namespace sd::framework
170 
171 #endif
172