Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include "framework/Pane.hxx"
22 :
23 : #include <vcl/svapp.hxx>
24 : #include <osl/mutex.hxx>
25 : #include <toolkit/helper/vclunohelper.hxx>
26 : #include <vcl/window.hxx>
27 : #include <cppcanvas/vclfactory.hxx>
28 : #include <comphelper/servicehelper.hxx>
29 :
30 : using namespace ::com::sun::star;
31 : using namespace ::com::sun::star::uno;
32 : using namespace ::com::sun::star::drawing::framework;
33 :
34 :
35 : namespace sd { namespace framework {
36 :
37 208 : Pane::Pane (
38 : const Reference<XResourceId>& rxPaneId,
39 : ::Window* pWindow)
40 : throw ()
41 : : PaneInterfaceBase(MutexOwner::maMutex),
42 : mxPaneId(rxPaneId),
43 : mpWindow(pWindow),
44 208 : mxWindow(VCLUnoHelper::GetInterface(pWindow))
45 : {
46 208 : }
47 :
48 :
49 :
50 :
51 195 : Pane::~Pane (void)
52 : {
53 195 : }
54 :
55 :
56 :
57 :
58 130 : void Pane::disposing (void)
59 : {
60 130 : mxWindow = NULL;
61 130 : mpWindow = NULL;
62 130 : }
63 :
64 :
65 :
66 :
67 0 : ::Window* Pane::GetWindow (void)
68 : {
69 0 : if (mxWindow.is())
70 0 : return mpWindow;
71 : else
72 0 : return NULL;
73 : }
74 :
75 :
76 :
77 :
78 0 : void Pane::SetWindow (::Window* pWindow)
79 : {
80 : OSL_TRACE("setting Pane::mpWindow to %x", pWindow);
81 0 : mpWindow = pWindow;
82 0 : mxWindow = VCLUnoHelper::GetInterface(mpWindow);
83 0 : }
84 :
85 :
86 :
87 :
88 : //----- XPane -----------------------------------------------------------------
89 :
90 520 : Reference<awt::XWindow> SAL_CALL Pane::getWindow (void)
91 : throw (RuntimeException)
92 : {
93 520 : ThrowIfDisposed();
94 :
95 520 : 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<css::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<css::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 221 : Reference<XResourceId> SAL_CALL Pane::getResourceId (void)
176 : throw (RuntimeException)
177 : {
178 221 : ThrowIfDisposed();
179 :
180 221 : return mxPaneId;
181 : }
182 :
183 :
184 :
185 :
186 266 : sal_Bool SAL_CALL Pane::isAnchorOnly (void)
187 : throw (RuntimeException)
188 : {
189 266 : 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 819 : void Pane::ThrowIfDisposed (void) const
246 : throw (lang::DisposedException)
247 : {
248 819 : 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 819 : }
254 :
255 :
256 33 : } } // end of namespace sd::framework
257 :
258 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|