Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "framework/Pane.hxx"
31 : :
32 : : #include <vcl/svapp.hxx>
33 : : #include <osl/mutex.hxx>
34 : : #include <toolkit/helper/vclunohelper.hxx>
35 : : #include <vcl/window.hxx>
36 : : #include <cppcanvas/vclfactory.hxx>
37 : : #include <comphelper/servicehelper.hxx>
38 : :
39 : : using namespace ::com::sun::star;
40 : : using namespace ::com::sun::star::uno;
41 : : using namespace ::com::sun::star::drawing::framework;
42 : :
43 : : using ::rtl::OUString;
44 : :
45 : : namespace sd { namespace framework {
46 : :
47 : 416 : Pane::Pane (
48 : : const Reference<XResourceId>& rxPaneId,
49 : : ::Window* pWindow)
50 : : throw ()
51 : : : PaneInterfaceBase(MutexOwner::maMutex),
52 : : mxPaneId(rxPaneId),
53 : : mpWindow(pWindow),
54 [ + - ]: 416 : mxWindow(VCLUnoHelper::GetInterface(pWindow))
55 : : {
56 : 416 : }
57 : :
58 : :
59 : :
60 : :
61 [ + - ]: 260 : Pane::~Pane (void) throw()
62 : : {
63 [ - + ]: 390 : }
64 : :
65 : :
66 : :
67 : :
68 : 260 : void Pane::disposing (void)
69 : : {
70 : 260 : mxWindow = NULL;
71 : 260 : mpWindow = NULL;
72 : 260 : }
73 : :
74 : :
75 : :
76 : :
77 : 0 : ::Window* Pane::GetWindow (void)
78 : : {
79 [ # # ]: 0 : if (mxWindow.is())
80 : 0 : return mpWindow;
81 : : else
82 : 0 : return NULL;
83 : : }
84 : :
85 : :
86 : :
87 : :
88 : : //----- XPane -----------------------------------------------------------------
89 : :
90 : 1040 : Reference<awt::XWindow> SAL_CALL Pane::getWindow (void)
91 : : throw (RuntimeException)
92 : : {
93 : 1040 : ThrowIfDisposed();
94 : :
95 : 1040 : return mxWindow;
96 : : }
97 : :
98 : :
99 : :
100 : :
101 : 0 : Reference<rendering::XCanvas> SAL_CALL Pane::getCanvas (void)
102 : : throw (RuntimeException)
103 : : {
104 [ # # ]: 0 : ::osl::MutexGuard aGuard (maMutex);
105 [ # # ]: 0 : ThrowIfDisposed();
106 : :
107 [ # # ]: 0 : if ( ! mxCanvas.is())
108 [ # # ][ # # ]: 0 : mxCanvas = CreateCanvas();
109 : :
110 [ # # ]: 0 : return mxCanvas;
111 : : }
112 : :
113 : :
114 : :
115 : :
116 : : //----- XPane2 ----------------------------------------------------------------
117 : :
118 : 0 : sal_Bool SAL_CALL Pane::isVisible (void)
119 : : throw (RuntimeException)
120 : : {
121 : 0 : ThrowIfDisposed();
122 : :
123 : 0 : const ::Window* pWindow = GetWindow();
124 [ # # ]: 0 : if (pWindow != NULL)
125 : 0 : return pWindow->IsVisible();
126 : : else
127 : 0 : return false;
128 : : }
129 : :
130 : :
131 : :
132 : :
133 : 0 : void SAL_CALL Pane::setVisible (sal_Bool bIsVisible)
134 : : throw (RuntimeException)
135 : : {
136 : 0 : ThrowIfDisposed();
137 : :
138 : 0 : ::Window* pWindow = GetWindow();
139 [ # # ]: 0 : if (pWindow != NULL)
140 : 0 : pWindow->Show(bIsVisible);
141 : 0 : }
142 : :
143 : :
144 : :
145 : :
146 : 0 : Reference<accessibility::XAccessible> SAL_CALL Pane::getAccessible (void)
147 : : throw (RuntimeException)
148 : : {
149 : 0 : ThrowIfDisposed();
150 : 0 : ::Window* pWindow = GetWindow();
151 [ # # ]: 0 : if (pWindow != NULL)
152 : 0 : return pWindow->GetAccessible(sal_False);
153 : : else
154 : 0 : return NULL;
155 : : }
156 : :
157 : :
158 : :
159 : :
160 : 0 : void SAL_CALL Pane::setAccessible (
161 : : const Reference<accessibility::XAccessible>& rxAccessible)
162 : : throw (RuntimeException)
163 : : {
164 : 0 : ThrowIfDisposed();
165 : 0 : ::Window* pWindow = GetWindow();
166 [ # # ]: 0 : if (pWindow != NULL)
167 [ # # ]: 0 : pWindow->SetAccessible(rxAccessible);
168 : 0 : }
169 : :
170 : :
171 : :
172 : :
173 : : //----- XResource -------------------------------------------------------------
174 : :
175 : 442 : Reference<XResourceId> SAL_CALL Pane::getResourceId (void)
176 : : throw (RuntimeException)
177 : : {
178 : 442 : ThrowIfDisposed();
179 : :
180 : 442 : return mxPaneId;
181 : : }
182 : :
183 : :
184 : :
185 : :
186 : 515 : sal_Bool SAL_CALL Pane::isAnchorOnly (void)
187 : : throw (RuntimeException)
188 : : {
189 : 515 : return true;
190 : : }
191 : :
192 : :
193 : :
194 : :
195 : : //----- XUnoTunnel ------------------------------------------------------------
196 : :
197 : : namespace
198 : : {
199 : : class thePaneUnoTunnelId : public rtl::Static< UnoTunnelIdInit, thePaneUnoTunnelId > {};
200 : : }
201 : :
202 : 0 : const Sequence<sal_Int8>& Pane::getUnoTunnelId (void)
203 : : {
204 : 0 : return thePaneUnoTunnelId::get().getSeq();
205 : : }
206 : :
207 : 0 : sal_Int64 SAL_CALL Pane::getSomething (const Sequence<sal_Int8>& rId)
208 : : throw (RuntimeException)
209 : : {
210 : 0 : sal_Int64 nResult = 0;
211 : :
212 [ # # # # ]: 0 : if (rId.getLength() == 16
[ # # ]
213 : 0 : && memcmp(getUnoTunnelId().getConstArray(), rId.getConstArray(), 16) == 0)
214 : : {
215 : 0 : nResult = reinterpret_cast<sal_Int64>(this);
216 : : }
217 : :
218 : 0 : return nResult;
219 : : }
220 : :
221 : :
222 : :
223 : :
224 : : //-----------------------------------------------------------------------------
225 : :
226 : 0 : Reference<rendering::XCanvas> Pane::CreateCanvas (void)
227 : : throw (RuntimeException)
228 : : {
229 : 0 : Reference<rendering::XCanvas> xCanvas;
230 : :
231 [ # # ]: 0 : if (mpWindow != NULL)
232 : : {
233 : : ::cppcanvas::SpriteCanvasSharedPtr pCanvas (
234 [ # # ][ # # ]: 0 : ::cppcanvas::VCLFactory::getInstance().createSpriteCanvas(*mpWindow));
235 [ # # ]: 0 : if (pCanvas.get() != NULL)
236 [ # # ][ # # ]: 0 : xCanvas = Reference<rendering::XCanvas>(pCanvas->getUNOSpriteCanvas(), UNO_QUERY);
[ # # ][ # # ]
237 : : }
238 : :
239 : 0 : return xCanvas;
240 : : }
241 : :
242 : :
243 : :
244 : :
245 : 1638 : void Pane::ThrowIfDisposed (void) const
246 : : throw (lang::DisposedException)
247 : : {
248 [ + - ][ - + ]: 1638 : if (rBHelper.bDisposed || rBHelper.bInDispose)
249 : : {
250 : : throw lang::DisposedException ("Pane object has already been disposed",
251 [ # # ][ # # ]: 0 : const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
252 : : }
253 : 1638 : }
254 : :
255 : :
256 : : } } // end of namespace sd::framework
257 : :
258 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|