LibreOffice Module sdext (master)  1
PresenterPane.cxx
Go to the documentation of this file.
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 "PresenterPane.hxx"
21 #include "PresenterController.hxx"
23 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
24 
25 using namespace ::com::sun::star;
26 using namespace ::com::sun::star::uno;
27 using namespace ::com::sun::star::drawing::framework;
28 
29 namespace sdext::presenter {
30 
31 //===== PresenterPane =========================================================
32 
34  const Reference<XComponentContext>& rxContext,
35  const ::rtl::Reference<PresenterController>& rpPresenterController)
36  : PresenterPaneBase(rxContext, rpPresenterController),
37  maBoundingBox()
38 {
39  Reference<lang::XMultiComponentFactory> xFactory (
40  mxComponentContext->getServiceManager(), UNO_SET_THROW);
42  xFactory->createInstanceWithContext(
43  "com.sun.star.comp.Draw.PresenterHelper",
45  UNO_QUERY_THROW);
46 }
47 
49 {
50 }
51 
52 //----- XPane -----------------------------------------------------------------
53 
54 Reference<awt::XWindow> SAL_CALL PresenterPane::getWindow()
55 {
57  return mxContentWindow;
58 }
59 
60 Reference<rendering::XCanvas> SAL_CALL PresenterPane::getCanvas()
61 {
63  return mxContentCanvas;
64 }
65 
66 //----- XWindowListener -------------------------------------------------------
67 
68 void SAL_CALL PresenterPane::windowResized (const awt::WindowEvent& rEvent)
69 {
71 
73 
75  ToTop();
76 
79 }
80 
81 void SAL_CALL PresenterPane::windowMoved (const awt::WindowEvent& rEvent)
82 {
84 
86 
87  ToTop();
88 
91 }
92 
93 void SAL_CALL PresenterPane::windowShown (const lang::EventObject& rEvent)
94 {
96 
97  ToTop();
98 
99  if (mxContentWindow.is())
100  {
102  mxContentWindow->setVisible(true);
103  }
104 
107 }
108 
109 void SAL_CALL PresenterPane::windowHidden (const lang::EventObject& rEvent)
110 {
112 
113  if (mxContentWindow.is())
114  mxContentWindow->setVisible(false);
115 }
116 
117 //----- XPaintListener --------------------------------------------------------
118 
119 void SAL_CALL PresenterPane::windowPaint (const awt::PaintEvent& rEvent)
120 {
121  ThrowIfDisposed();
122 
123  PaintBorder(rEvent.UpdateRect);
124 }
125 
126 
128  const Reference<rendering::XSpriteCanvas>& rxParentCanvas)
129 {
130  if ( ! mxPresenterHelper.is())
131  return;
132  if ( ! mxParentWindow.is())
133  return;
134  if ( ! rxParentCanvas.is())
135  return;
136 
137  mxBorderCanvas = mxPresenterHelper->createSharedCanvas(
138  rxParentCanvas,
140  rxParentCanvas,
143  mxContentCanvas = mxPresenterHelper->createSharedCanvas(
144  rxParentCanvas,
146  rxParentCanvas,
149 
150  PaintBorder(mxBorderWindow->getPosSize());
151 }
152 
153 void PresenterPane::Invalidate (const css::awt::Rectangle& rRepaintBox)
154 {
155  // Invalidate the parent window to be able to invalidate an area outside
156  // the current window area.
157  mpPresenterController->GetPaintManager()->Invalidate(mxParentWindow, rRepaintBox);
158 }
159 
161 {
162  if (mxBorderWindow.is() && IsVisible())
163  maBoundingBox = mxBorderWindow->getPosSize();
164  else
165  maBoundingBox = awt::Rectangle();
166 }
167 
168 } // end of namespace ::sdext::presenter
169 
170 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::awt::XWindow > SAL_CALL getWindow() override
virtual void SAL_CALL windowHidden(const css::lang::EventObject &rEvent) override
css::uno::Reference< css::uno::XComponentContext > mxComponentContext
css::awt::Rectangle maBoundingBox
Store the bounding box so that when the window is resized or moved we still know the old position and...
css::uno::Reference< css::awt::XWindow > mxBorderWindow
virtual void SAL_CALL windowResized(const css::awt::WindowEvent &rEvent) override
virtual ~PresenterPane() override
Base class of the panes used by the presenter screen.
::rtl::Reference< PresenterController > mpPresenterController
css::uno::Reference< css::rendering::XCanvas > mxContentCanvas
virtual void CreateCanvases(const css::uno::Reference< css::rendering::XSpriteCanvas > &rxParentCanvas) override
css::uno::Reference< css::rendering::XCanvas > mxBorderCanvas
virtual void SAL_CALL windowShown(const css::lang::EventObject &rEvent) override
virtual void SAL_CALL windowResized(const css::awt::WindowEvent &rEvent) override
virtual void SAL_CALL windowPaint(const css::awt::PaintEvent &rEvent) override
PresenterPane(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const ::rtl::Reference< PresenterController > &rpPresenterController)
virtual void SAL_CALL windowShown(const css::lang::EventObject &rEvent) override
css::uno::Reference< css::drawing::XPresenterHelper > mxPresenterHelper
virtual void SAL_CALL windowMoved(const css::awt::WindowEvent &rEvent) override
css::uno::Reference< css::awt::XWindow > mxContentWindow
void PaintBorder(const css::awt::Rectangle &rUpdateRectangle)
css::uno::Reference< css::awt::XWindow > mxParentWindow
css::uno::Reference< css::rendering::XCanvas > SAL_CALL getCanvas() override
Reference< XSingleServiceFactory > xFactory
virtual void SAL_CALL windowHidden(const css::lang::EventObject &rEvent) override
void Invalidate(const css::awt::Rectangle &rRepaintBox)
virtual void SAL_CALL windowMoved(const css::awt::WindowEvent &rEvent) override