xref: /aoo41x/main/sd/source/ui/inc/framework/Pane.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef SD_FRAMEWORK_PANE_HXX
29 #define SD_FRAMEWORK_PANE_HXX
30 
31 #include "MutexOwner.hxx"
32 
33 #include <com/sun/star/drawing/framework/XPane.hpp>
34 #include <com/sun/star/drawing/framework/XPane2.hpp>
35 #include <com/sun/star/drawing/framework/TabBarButton.hpp>
36 #include <com/sun/star/lang/XUnoTunnel.hpp>
37 #include <cppuhelper/compbase3.hxx>
38 #include <tools/link.hxx>
39 #include <boost/shared_ptr.hpp>
40 #include <boost/weak_ptr.hpp>
41 
42 class Window;
43 
44 namespace css = ::com::sun::star;
45 namespace cssu = ::com::sun::star::uno;
46 
47 namespace {
48 
49 typedef ::cppu::WeakComponentImplHelper3 <
50     ::com::sun::star::drawing::framework::XPane,
51     ::com::sun::star::drawing::framework::XPane2,
52       ::com::sun::star::lang::XUnoTunnel
53     > PaneInterfaceBase;
54 
55 } // end of anonymous namespace.
56 
57 namespace sd { namespace framework {
58 
59 /** A pane is a wrapper for a window and possibly for a tab bar (for view
60     switching).  Panes are unique resources.
61 
62     This class has two responsibilities:
63     1. It implements the XPane interface.  This is the most important
64     interface of this class for API based views (of which there not that
65     many yet) because it gives access to the XWindow.
66     2. It gives access to the underlying VCL Window by implementing the
67     XUnoTunnel interface.  This is necessary at the moment and in the
68     foreseeable future because many parts of the Draw and Impress views rely
69     on direct access on the Window class.
70 */
71 class Pane
72     : protected MutexOwner,
73       public PaneInterfaceBase
74 {
75 public:
76     /** Create a new Pane object that wrapps the given window.
77         @param rsPaneURL
78             The URL that is used by the configuration to identify the pane.
79             The given URL has to be valid.
80         @param pWindow
81             The VCL Window (usually this really is an sd::Window) that is
82             wrapped by the new Pane object.  The given pointer must not be
83             NULL.
84     */
85 	Pane (
86         const ::com::sun::star::uno::Reference<
87             com::sun::star::drawing::framework::XResourceId>& rxPaneId,
88         ::Window* pWindow)
89         throw ();
90 	virtual ~Pane (void) throw();
91 
92     virtual void SAL_CALL disposing (void);
93 
94     static const ::com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId (void);
95 
96     /** This method is typically used together with the XUnoTunnel to obtain
97         a Window pointer from an XPane object.
98     */
99     virtual ::Window* GetWindow (void);
100 
101 
102     //----- XPane -------------------------------------------------------------
103 
104     /** For a UNO API based implementation of a view this may the most
105         important method of this class because the view is only interested
106         in the window of the pane.
107     */
108     virtual cssu::Reference<css::awt::XWindow>
109         SAL_CALL getWindow (void)
110         throw (cssu::RuntimeException);
111 
112     virtual cssu::Reference<css::rendering::XCanvas>
113         SAL_CALL getCanvas (void)
114         throw (cssu::RuntimeException);
115 
116 
117     //----- XPane2 -------------------------------------------------------------
118 
119     virtual sal_Bool SAL_CALL isVisible (void)
120         throw (cssu::RuntimeException);
121 
122     virtual void SAL_CALL setVisible (sal_Bool bIsVisible)
123         throw (cssu::RuntimeException);
124 
125     virtual cssu::Reference<css::accessibility::XAccessible> SAL_CALL getAccessible (void)
126         throw (cssu::RuntimeException);
127 
128     virtual void SAL_CALL setAccessible (
129         const cssu::Reference<css::accessibility::XAccessible>& rxAccessible)
130         throw (cssu::RuntimeException);
131 
132 
133     //----- XResource ---------------------------------------------------------
134 
135     virtual ::com::sun::star::uno::Reference<com::sun::star::drawing::framework::XResourceId>
136         SAL_CALL getResourceId (void)
137         throw (::com::sun::star::uno::RuntimeException);
138 
139     /** For the typical pane it makes no sense to be dislayed without a
140         view.  Therefore this default implementation returns always <TRUE/>.
141     */
142     virtual sal_Bool SAL_CALL isAnchorOnly (void)
143         throw (com::sun::star::uno::RuntimeException);
144 
145 
146     //----- XUnoTunnel --------------------------------------------------------
147 
148     virtual sal_Int64 SAL_CALL getSomething (const com::sun::star::uno::Sequence<sal_Int8>& rId)
149         throw (com::sun::star::uno::RuntimeException);
150 
151 
152 protected:
153     ::com::sun::star::uno::Reference<com::sun::star::drawing::framework::XResourceId> mxPaneId;
154     ::Window* mpWindow;
155     ::com::sun::star::uno::Reference<com::sun::star::awt::XWindow> mxWindow;
156     ::com::sun::star::uno::Reference<com::sun::star::rendering::XCanvas> mxCanvas;
157 
158     /** Overload this method, not getCanvas(), when you want to provide a
159         different canvas.
160     */
161     virtual ::com::sun::star::uno::Reference<com::sun::star::rendering::XCanvas>
162         CreateCanvas (void)
163         throw (::com::sun::star::uno::RuntimeException);
164 
165     /** Throw DisposedException when the object has already been disposed or
166         is currently being disposed.  Otherwise this method returns
167         normally.
168     */
169     void ThrowIfDisposed (void) const
170         throw (::com::sun::star::lang::DisposedException);
171 };
172 
173 } } // end of namespace sd::framework
174 
175 #endif
176