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 : #include "sal/config.h"
21 :
22 : #include <cstddef>
23 :
24 : #include "PresenterHelper.hxx"
25 : #include "CanvasUpdateRequester.hxx"
26 : #include "PresenterCanvas.hxx"
27 : #include "facreg.hxx"
28 : #include <cppcanvas/vclfactory.hxx>
29 : #include <com/sun/star/awt/WindowAttribute.hpp>
30 : #include <com/sun/star/awt/WindowClass.hpp>
31 : #include <com/sun/star/awt/WindowDescriptor.hpp>
32 : #include <toolkit/helper/vclunohelper.hxx>
33 : #include <vcl/svapp.hxx>
34 : #include <vcl/window.hxx>
35 : #include <vcl/wrkwin.hxx>
36 :
37 : #include "res_bmp.hrc"
38 : #include "sdresid.hxx"
39 :
40 : using namespace ::com::sun::star;
41 : using namespace ::com::sun::star::uno;
42 :
43 : namespace sd { namespace presenter {
44 :
45 : //===== Service ===============================================================
46 :
47 0 : Reference<XInterface> SAL_CALL PresenterHelperService_createInstance (
48 : const Reference<XComponentContext>& rxContext) throw (css::uno::Exception)
49 : {
50 0 : return Reference<XInterface>(static_cast<XWeak*>(new PresenterHelper(rxContext)));
51 : }
52 :
53 34 : OUString PresenterHelperService_getImplementationName (void)
54 : throw(RuntimeException)
55 : {
56 34 : return OUString("com.sun.star.comp.Draw.PresenterHelper");
57 : }
58 :
59 0 : Sequence<OUString> SAL_CALL PresenterHelperService_getSupportedServiceNames (void)
60 : throw (RuntimeException)
61 : {
62 0 : static const OUString sServiceName("com.sun.star.drawing.PresenterHelper");
63 0 : return Sequence<OUString>(&sServiceName, 1);
64 : }
65 :
66 : //===== PresenterHelper =======================================================
67 :
68 0 : PresenterHelper::PresenterHelper (
69 : const Reference<XComponentContext>& rxContext)
70 : : PresenterHelperInterfaceBase(m_aMutex),
71 0 : mxComponentContext(rxContext)
72 : {
73 0 : }
74 :
75 0 : PresenterHelper::~PresenterHelper (void)
76 : {
77 0 : }
78 :
79 : //----- XInitialize -----------------------------------------------------------
80 :
81 0 : void SAL_CALL PresenterHelper::initialize (const Sequence<Any>& rArguments)
82 : throw(Exception,RuntimeException, std::exception)
83 : {
84 : (void)rArguments;
85 0 : }
86 :
87 : //----- XPaneHelper ----------------------------------------------------
88 :
89 0 : Reference<awt::XWindow> SAL_CALL PresenterHelper::createWindow (
90 : const Reference<awt::XWindow>& rxParentWindow,
91 : sal_Bool bCreateSystemChildWindow,
92 : sal_Bool bInitiallyVisible,
93 : sal_Bool bEnableChildTransparentMode,
94 : sal_Bool bEnableParentClip)
95 : throw (css::uno::RuntimeException, std::exception)
96 : {
97 0 : vcl::Window* pParentWindow = VCLUnoHelper::GetWindow(rxParentWindow);
98 :
99 : // Create a new window.
100 0 : vcl::Window* pWindow = NULL;
101 0 : if (bCreateSystemChildWindow)
102 : {
103 0 : pWindow = new WorkWindow(pParentWindow, WB_SYSTEMCHILDWINDOW);
104 : }
105 : else
106 : {
107 0 : pWindow = new vcl::Window(pParentWindow);
108 : }
109 0 : Reference<awt::XWindow> xWindow (pWindow->GetComponentInterface(), UNO_QUERY);
110 :
111 0 : if (bEnableChildTransparentMode)
112 : {
113 : // Make the frame window transparent and make the parent able to
114 : // draw behind it.
115 0 : if (pParentWindow != NULL)
116 0 : pParentWindow->EnableChildTransparentMode(true);
117 : }
118 :
119 0 : pWindow->Show(bInitiallyVisible);
120 :
121 0 : pWindow->SetMapMode(MAP_PIXEL);
122 0 : pWindow->SetBackground();
123 0 : if ( ! bEnableParentClip)
124 : {
125 0 : pWindow->SetParentClipMode(PARENTCLIPMODE_NOCLIP);
126 0 : pWindow->SetPaintTransparent(true);
127 : }
128 : else
129 : {
130 0 : pWindow->SetParentClipMode(PARENTCLIPMODE_CLIP);
131 0 : pWindow->SetPaintTransparent(false);
132 : }
133 :
134 0 : return xWindow;
135 : }
136 :
137 0 : Reference<rendering::XCanvas> SAL_CALL PresenterHelper::createSharedCanvas (
138 : const Reference<rendering::XSpriteCanvas>& rxUpdateCanvas,
139 : const Reference<awt::XWindow>& rxUpdateWindow,
140 : const Reference<rendering::XCanvas>& rxSharedCanvas,
141 : const Reference<awt::XWindow>& rxSharedWindow,
142 : const Reference<awt::XWindow>& rxWindow)
143 : throw (css::uno::RuntimeException, std::exception)
144 : {
145 0 : if ( ! rxSharedCanvas.is()
146 0 : || ! rxSharedWindow.is()
147 0 : || ! rxWindow.is())
148 : {
149 0 : throw RuntimeException("illegal argument", static_cast<XWeak*>(this));
150 : }
151 :
152 0 : if (rxWindow == rxSharedWindow)
153 0 : return rxSharedCanvas;
154 : else
155 : return new PresenterCanvas(
156 : rxUpdateCanvas,
157 : rxUpdateWindow,
158 : rxSharedCanvas,
159 : rxSharedWindow,
160 0 : rxWindow);
161 : }
162 :
163 0 : Reference<rendering::XCanvas> SAL_CALL PresenterHelper::createCanvas (
164 : const Reference<awt::XWindow>& rxWindow,
165 : sal_Int16 nRequestedCanvasFeatures,
166 : const OUString& rsOptionalCanvasServiceName)
167 : throw (css::uno::RuntimeException, std::exception)
168 : {
169 : (void)nRequestedCanvasFeatures;
170 :
171 : // No shared window is given or an explicit canvas service name is
172 : // specified. Create a new canvas.
173 0 : vcl::Window* pWindow = VCLUnoHelper::GetWindow(rxWindow);
174 0 : if (pWindow != NULL)
175 : {
176 0 : Sequence<Any> aArg (5);
177 :
178 : // common: first any is VCL pointer to window (for VCL canvas)
179 0 : aArg[0] = makeAny(reinterpret_cast<sal_Int64>(pWindow));
180 0 : aArg[1] = Any();
181 0 : aArg[2] = makeAny(::com::sun::star::awt::Rectangle());
182 0 : aArg[3] = makeAny(sal_False);
183 0 : aArg[4] = makeAny(rxWindow);
184 :
185 : Reference<lang::XMultiServiceFactory> xFactory (
186 0 : mxComponentContext->getServiceManager(), UNO_QUERY_THROW);
187 : return Reference<rendering::XCanvas>(
188 0 : xFactory->createInstanceWithArguments(
189 0 : !rsOptionalCanvasServiceName.isEmpty()
190 : ? rsOptionalCanvasServiceName
191 : : OUString("com.sun.star.rendering.Canvas.VCL"),
192 0 : aArg),
193 0 : UNO_QUERY);
194 : }
195 : else
196 0 : throw RuntimeException();
197 : }
198 :
199 0 : void SAL_CALL PresenterHelper::toTop (
200 : const Reference<awt::XWindow>& rxWindow)
201 : throw (css::uno::RuntimeException, std::exception)
202 : {
203 0 : vcl::Window* pWindow = VCLUnoHelper::GetWindow(rxWindow);
204 0 : if (pWindow != NULL)
205 : {
206 0 : pWindow->ToTop();
207 0 : pWindow->SetZOrder(NULL, WINDOW_ZORDER_LAST);
208 : }
209 0 : }
210 :
211 : namespace {
212 :
213 : struct IdMapEntry {
214 : char const * sid;
215 : sal_uInt32 nid;
216 : };
217 :
218 : }
219 :
220 0 : Reference<rendering::XBitmap> SAL_CALL PresenterHelper::loadBitmap (
221 : const OUString& id,
222 : const Reference<rendering::XCanvas>& rxCanvas)
223 : throw (RuntimeException, std::exception)
224 : {
225 0 : if ( ! rxCanvas.is())
226 0 : return NULL;
227 :
228 : static IdMapEntry const map[] = {
229 : { "bitmaps/Background.png", BMP_PRESENTERSCREEN_BACKGROUND },
230 : { "bitmaps/Animation.png",
231 : BMP_PRESENTERSCREEN_ANIMATION },
232 : { "bitmaps/Transition.png",
233 : BMP_PRESENTERSCREEN_TRANSITION },
234 : { "bitmaps/BorderActiveBottom.png",
235 : BMP_PRESENTERSCREEN_BORDER_ACTIVE_BOTTOM },
236 : { "bitmaps/BorderActiveBottomCallout.png",
237 : BMP_PRESENTERSCREEN_BORDER_ACTIVE_BOTTOM_CALLOUT },
238 : { "bitmaps/BorderActiveBottomLeft.png",
239 : BMP_PRESENTERSCREEN_BORDER_ACTIVE_BOTTOM_LEFT },
240 : { "bitmaps/BorderActiveBottomRight.png",
241 : BMP_PRESENTERSCREEN_BORDER_ACTIVE_BOTTOM_RIGHT },
242 : { "bitmaps/BorderActiveLeft.png",
243 : BMP_PRESENTERSCREEN_BORDER_ACTIVE_LEFT },
244 : { "bitmaps/BorderActiveRight.png",
245 : BMP_PRESENTERSCREEN_BORDER_ACTIVE_RIGHT },
246 : { "bitmaps/BorderActiveTop.png",
247 : BMP_PRESENTERSCREEN_BORDER_ACTIVE_TOP },
248 : { "bitmaps/BorderActiveTopLeft.png",
249 : BMP_PRESENTERSCREEN_BORDER_ACTIVE_TOP_LEFT },
250 : { "bitmaps/BorderActiveTopRight.png",
251 : BMP_PRESENTERSCREEN_BORDER_ACTIVE_TOP_RIGHT },
252 : { "bitmaps/BorderBottom.png", BMP_PRESENTERSCREEN_BORDER_BOTTOM },
253 : { "bitmaps/BorderBottomLeft.png",
254 : BMP_PRESENTERSCREEN_BORDER_BOTTOM_LEFT },
255 : { "bitmaps/BorderBottomRight.png",
256 : BMP_PRESENTERSCREEN_BORDER_BOTTOM_RIGHT },
257 : { "bitmaps/BorderCurrentSlideBottom.png",
258 : BMP_PRESENTERSCREEN_BORDER_CURRENT_SLIDE_BOTTOM },
259 : { "bitmaps/BorderCurrentSlideBottomLeft.png",
260 : BMP_PRESENTERSCREEN_BORDER_CURRENT_SLIDE_BOTTOM_LEFT },
261 : { "bitmaps/BorderCurrentSlideBottomRight.png",
262 : BMP_PRESENTERSCREEN_BORDER_CURRENT_SLIDE_BOTTOM_RIGHT },
263 : { "bitmaps/BorderCurrentSlideLeft.png",
264 : BMP_PRESENTERSCREEN_BORDER_CURRENT_SLIDE_LEFT },
265 : { "bitmaps/BorderCurrentSlideRight.png",
266 : BMP_PRESENTERSCREEN_BORDER_CURRENT_SLIDE_RIGHT },
267 : { "bitmaps/BorderCurrentSlideTop.png",
268 : BMP_PRESENTERSCREEN_BORDER_CURRENT_SLIDE_TOP },
269 : { "bitmaps/BorderCurrentSlideTopLeft.png",
270 : BMP_PRESENTERSCREEN_BORDER_CURRENT_SLIDE_TOP_LEFT },
271 : { "bitmaps/BorderCurrentSlideTopRight.png",
272 : BMP_PRESENTERSCREEN_BORDER_CURRENT_SLIDE_TOP_RIGHT },
273 : { "bitmaps/BorderLeft.png", BMP_PRESENTERSCREEN_BORDER_LEFT },
274 : { "bitmaps/BorderRight.png", BMP_PRESENTERSCREEN_BORDER_RIGHT },
275 : { "bitmaps/BorderToolbarBottom.png",
276 : BMP_PRESENTERSCREEN_BORDER_TOOLBAR_BOTTOM },
277 : { "bitmaps/BorderToolbarLeft.png",
278 : BMP_PRESENTERSCREEN_BORDER_TOOLBAR_LEFT },
279 : { "bitmaps/BorderToolbarRight.png",
280 : BMP_PRESENTERSCREEN_BORDER_TOOLBAR_RIGHT },
281 : { "bitmaps/BorderToolbarTop.png",
282 : BMP_PRESENTERSCREEN_BORDER_TOOLBAR_TOP },
283 : { "bitmaps/BorderToolbarTopLeft.png",
284 : BMP_PRESENTERSCREEN_BORDER_TOOLBAR_TOP_LEFT },
285 : { "bitmaps/BorderToolbarTopRight.png",
286 : BMP_PRESENTERSCREEN_BORDER_TOOLBAR_TOP_RIGHT },
287 : { "bitmaps/BorderTop.png", BMP_PRESENTERSCREEN_BORDER_TOP },
288 : { "bitmaps/BorderTopLeft.png", BMP_PRESENTERSCREEN_BORDER_TOP_LEFT },
289 : { "bitmaps/BorderTopRight.png", BMP_PRESENTERSCREEN_BORDER_TOP_RIGHT },
290 : { "bitmaps/ButtonEffectNextDisabled.png",
291 : BMP_PRESENTERSCREEN_BUTTON_EFFECT_NEXT_DISABLED },
292 : { "bitmaps/ButtonEffectNextMouseOver.png",
293 : BMP_PRESENTERSCREEN_BUTTON_EFFECT_NEXT_MOUSE_OVER },
294 : { "bitmaps/ButtonEffectNextNormal.png",
295 : BMP_PRESENTERSCREEN_BUTTON_EFFECT_NEXT_NORMAL },
296 : { "bitmaps/ButtonEffectNextSelected.png",
297 : BMP_PRESENTERSCREEN_BUTTON_EFFECT_NEXT_SELECTED },
298 : { "bitmaps/ButtonFrameCenterMouseOver.png",
299 : BMP_PRESENTERSCREEN_BUTTON_FRAME_CENTER_MOUSE_OVER },
300 : { "bitmaps/ButtonFrameCenterNormal.png",
301 : BMP_PRESENTERSCREEN_BUTTON_FRAME_CENTER_NORMAL },
302 : { "bitmaps/ButtonFrameLeftMouseOver.png",
303 : BMP_PRESENTERSCREEN_BUTTON_FRAME_LEFT_MOUSE_OVER },
304 : { "bitmaps/ButtonFrameLeftNormal.png",
305 : BMP_PRESENTERSCREEN_BUTTON_FRAME_LEFT_NORMAL },
306 : { "bitmaps/ButtonFrameRightMouseOver.png",
307 : BMP_PRESENTERSCREEN_BUTTON_FRAME_RIGHT_MOUSE_OVER },
308 : { "bitmaps/ButtonFrameRightNormal.png",
309 : BMP_PRESENTERSCREEN_BUTTON_FRAME_RIGHT_NORMAL },
310 : { "bitmaps/ButtonHelpDisabled.png",
311 : BMP_PRESENTERSCREEN_BUTTON_HELP_DISABLED },
312 : { "bitmaps/ButtonHelpMouseOver.png",
313 : BMP_PRESENTERSCREEN_BUTTON_HELP_MOUSE_OVER },
314 : { "bitmaps/ButtonHelpNormal.png",
315 : BMP_PRESENTERSCREEN_BUTTON_HELP_NORMAL },
316 : { "bitmaps/ButtonHelpSelected.png",
317 : BMP_PRESENTERSCREEN_BUTTON_HELP_SELECTED },
318 : { "bitmaps/ButtonMinusDisabled.png",
319 : BMP_PRESENTERSCREEN_BUTTON_MINUS_DISABLED },
320 : { "bitmaps/ButtonMinusMouseOver.png",
321 : BMP_PRESENTERSCREEN_BUTTON_MINUS_MOUSE_OVER },
322 : { "bitmaps/ButtonMinusNormal.png",
323 : BMP_PRESENTERSCREEN_BUTTON_MINUS_NORMAL },
324 : { "bitmaps/ButtonMinusSelected.png",
325 : BMP_PRESENTERSCREEN_BUTTON_MINUS_SELECTED },
326 : { "bitmaps/ButtonNotesDisabled.png",
327 : BMP_PRESENTERSCREEN_BUTTON_NOTES_DISABLED },
328 : { "bitmaps/ButtonNotesMouseOver.png",
329 : BMP_PRESENTERSCREEN_BUTTON_NOTES_MOUSE_OVER },
330 : { "bitmaps/ButtonNotesNormal.png",
331 : BMP_PRESENTERSCREEN_BUTTON_NOTES_NORMAL },
332 : { "bitmaps/ButtonNotesSelected.png",
333 : BMP_PRESENTERSCREEN_BUTTON_NOTES_SELECTED },
334 : { "bitmaps/ButtonPlusDisabled.png",
335 : BMP_PRESENTERSCREEN_BUTTON_PLUS_DISABLED },
336 : { "bitmaps/ButtonPlusMouseOver.png",
337 : BMP_PRESENTERSCREEN_BUTTON_PLUS_MOUSE_OVER },
338 : { "bitmaps/ButtonPlusNormal.png",
339 : BMP_PRESENTERSCREEN_BUTTON_PLUS_NORMAL },
340 : { "bitmaps/ButtonPlusSelected.png",
341 : BMP_PRESENTERSCREEN_BUTTON_PLUS_SELECTED },
342 : { "bitmaps/ButtonSlideNextDisabled.png",
343 : BMP_PRESENTERSCREEN_BUTTON_SLIDE_NEXT_DISABLED },
344 : { "bitmaps/ButtonSlideNextMouseOver.png",
345 : BMP_PRESENTERSCREEN_BUTTON_SLIDE_NEXT_MOUSE_OVER },
346 : { "bitmaps/ButtonSlideNextNormal.png",
347 : BMP_PRESENTERSCREEN_BUTTON_SLIDE_NEXT_NORMAL },
348 : { "bitmaps/ButtonSlidePreviousDisabled.png",
349 : BMP_PRESENTERSCREEN_BUTTON_SLIDE_PREVIOUS_DISABLED },
350 : { "bitmaps/ButtonSlidePreviousMouseOver.png",
351 : BMP_PRESENTERSCREEN_BUTTON_SLIDE_PREVIOUS_MOUSE_OVER },
352 : { "bitmaps/ButtonSlidePreviousNormal.png",
353 : BMP_PRESENTERSCREEN_BUTTON_SLIDE_PREVIOUS_NORMAL },
354 : { "bitmaps/ButtonSlidePreviousSelected.png",
355 : BMP_PRESENTERSCREEN_BUTTON_SLIDE_PREVIOUS_SELECTED },
356 : { "bitmaps/ButtonSlideSorterDisabled.png",
357 : BMP_PRESENTERSCREEN_BUTTON_SLIDE_SORTER_DISABLED },
358 : { "bitmaps/ButtonSlideSorterMouseOver.png",
359 : BMP_PRESENTERSCREEN_BUTTON_SLIDE_SORTER_MOUSE_OVER },
360 : { "bitmaps/ButtonSlideSorterNormal.png",
361 : BMP_PRESENTERSCREEN_BUTTON_SLIDE_SORTER_NORMAL },
362 : { "bitmaps/ButtonSlideSorterSelected.png",
363 : BMP_PRESENTERSCREEN_BUTTON_SLIDE_SORTER_SELECTED },
364 : { "bitmaps/ButtonSwitchMonitorMouseOver.png",
365 : BMP_PRESENTERSCREEN_BUTTON_SWITCH_MONITOR_MOUSE_OVER },
366 : { "bitmaps/ButtonSwitchMonitorNormal.png",
367 : BMP_PRESENTERSCREEN_BUTTON_SWITCH_MONITOR_NORMAL },
368 : { "bitmaps/LabelMouseOverCenter.png",
369 : BMP_PRESENTERSCREEN_LABEL_MOUSE_OVER_CENTER },
370 : { "bitmaps/LabelMouseOverLeft.png",
371 : BMP_PRESENTERSCREEN_LABEL_MOUSE_OVER_LEFT },
372 : { "bitmaps/LabelMouseOverRight.png",
373 : BMP_PRESENTERSCREEN_LABEL_MOUSE_OVER_RIGHT },
374 : { "bitmaps/ScrollbarArrowDownDisabled.png",
375 : BMP_PRESENTERSCREEN_SCROLLBAR_ARROW_DOWN_DISABLED },
376 : { "bitmaps/ScrollbarArrowDownMouseOver.png",
377 : BMP_PRESENTERSCREEN_SCROLLBAR_ARROW_DOWN_MOUSE_OVER },
378 : { "bitmaps/ScrollbarArrowDownNormal.png",
379 : BMP_PRESENTERSCREEN_SCROLLBAR_ARROW_DOWN_NORMAL },
380 : { "bitmaps/ScrollbarArrowDownSelected.png",
381 : BMP_PRESENTERSCREEN_SCROLLBAR_ARROW_DOWN_SELECTED },
382 : { "bitmaps/ScrollbarArrowUpDisabled.png",
383 : BMP_PRESENTERSCREEN_SCROLLBAR_ARROW_UP_DISABLED },
384 : { "bitmaps/ScrollbarArrowUpMouseOver.png",
385 : BMP_PRESENTERSCREEN_SCROLLBAR_ARROW_UP_MOUSE_OVER },
386 : { "bitmaps/ScrollbarArrowUpNormal.png",
387 : BMP_PRESENTERSCREEN_SCROLLBAR_ARROW_UP_NORMAL },
388 : { "bitmaps/ScrollbarArrowUpSelected.png",
389 : BMP_PRESENTERSCREEN_SCROLLBAR_ARROW_UP_SELECTED },
390 : { "bitmaps/ScrollbarPagerMiddleMouseOver.png",
391 : BMP_PRESENTERSCREEN_SCROLLBAR_PAGER_MIDDLE_MOUSE_OVER },
392 : { "bitmaps/ScrollbarPagerMiddleNormal.png",
393 : BMP_PRESENTERSCREEN_SCROLLBAR_PAGER_MIDDLE_NORMAL },
394 : { "bitmaps/ScrollbarThumbBottomMouseOver.png",
395 : BMP_PRESENTERSCREEN_SCROLLBAR_THUMB_BOTTOM_MOUSE_OVER },
396 : { "bitmaps/ScrollbarThumbBottomNormal.png",
397 : BMP_PRESENTERSCREEN_SCROLLBAR_THUMB_BOTTOM_NORMAL },
398 : { "bitmaps/ScrollbarThumbMiddleMouseOver.png",
399 : BMP_PRESENTERSCREEN_SCROLLBAR_THUMB_MIDDLE_MOUSE_OVER },
400 : { "bitmaps/ScrollbarThumbMiddleNormal.png",
401 : BMP_PRESENTERSCREEN_SCROLLBAR_THUMB_MIDDLE_NORMAL },
402 : { "bitmaps/ScrollbarThumbTopMouseOver.png",
403 : BMP_PRESENTERSCREEN_SCROLLBAR_THUMB_TOP_MOUSE_OVER },
404 : { "bitmaps/ScrollbarThumbTopNormal.png",
405 : BMP_PRESENTERSCREEN_SCROLLBAR_THUMB_TOP_NORMAL },
406 : { "bitmaps/ViewBackground.png", BMP_PRESENTERSCREEN_VIEW_BACKGROUND }
407 : };
408 0 : sal_uInt32 nid = 0;
409 0 : for (std::size_t i = 0; i != SAL_N_ELEMENTS(map); ++i) {
410 0 : if (id.equalsAscii(map[i].sid)) {
411 0 : nid = map[i].nid;
412 0 : break;
413 : }
414 : }
415 0 : if (nid == 0) {
416 0 : return 0;
417 : }
418 :
419 0 : ::osl::MutexGuard aGuard (::osl::Mutex::getGlobalMutex());
420 :
421 : const cppcanvas::CanvasSharedPtr pCanvas (
422 0 : cppcanvas::VCLFactory::getInstance().createCanvas(
423 0 : Reference<css::rendering::XCanvas>(rxCanvas,UNO_QUERY)));
424 :
425 0 : if (pCanvas.get() != NULL)
426 : {
427 0 : BitmapEx aBitmapEx = SdResId(nid);
428 : cppcanvas::BitmapSharedPtr xBitmap(
429 0 : cppcanvas::VCLFactory::getInstance().createBitmap(pCanvas,
430 0 : aBitmapEx));
431 0 : if (xBitmap.get() == NULL)
432 0 : return NULL;
433 0 : return xBitmap->getUNOBitmap();
434 : }
435 :
436 0 : return NULL;
437 : }
438 :
439 0 : void SAL_CALL PresenterHelper::captureMouse (
440 : const Reference<awt::XWindow>& rxWindow)
441 : throw (RuntimeException, std::exception)
442 : {
443 0 : ::osl::MutexGuard aGuard (::osl::Mutex::getGlobalMutex());
444 :
445 : // Capture the mouse (if not already done.)
446 0 : vcl::Window* pWindow = VCLUnoHelper::GetWindow(rxWindow);
447 0 : if (pWindow != NULL && ! pWindow->IsMouseCaptured())
448 : {
449 0 : pWindow->CaptureMouse();
450 0 : }
451 0 : }
452 :
453 0 : void SAL_CALL PresenterHelper::releaseMouse (const Reference<awt::XWindow>& rxWindow)
454 : throw (RuntimeException, std::exception)
455 : {
456 0 : ::osl::MutexGuard aGuard (::osl::Mutex::getGlobalMutex());
457 :
458 : // Release the mouse (if not already done.)
459 0 : vcl::Window* pWindow = VCLUnoHelper::GetWindow(rxWindow);
460 0 : if (pWindow != NULL && pWindow->IsMouseCaptured())
461 : {
462 0 : pWindow->ReleaseMouse();
463 0 : }
464 0 : }
465 :
466 0 : awt::Rectangle PresenterHelper::getWindowExtentsRelative (
467 : const Reference<awt::XWindow>& rxChildWindow,
468 : const Reference<awt::XWindow>& rxParentWindow)
469 : throw (RuntimeException, std::exception)
470 : {
471 0 : vcl::Window* pChildWindow = VCLUnoHelper::GetWindow(rxChildWindow);
472 0 : vcl::Window* pParentWindow = VCLUnoHelper::GetWindow(rxParentWindow);
473 0 : if (pChildWindow!=NULL && pParentWindow!=NULL)
474 : {
475 0 : Rectangle aBox (pChildWindow->GetWindowExtentsRelative(pParentWindow));
476 0 : return awt::Rectangle(aBox.Left(),aBox.Top(),aBox.GetWidth(),aBox.GetHeight());
477 : }
478 : else
479 0 : return awt::Rectangle();
480 : }
481 :
482 114 : } } // end of namespace ::sd::presenter
483 :
484 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|