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"
22 #include "PresenterPaintManager.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
PresenterPane(const Reference<XComponentContext> & rxContext,const::rtl::Reference<PresenterController> & rpPresenterController)33 PresenterPane::PresenterPane (
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);
41 mxPresenterHelper.set(
42 xFactory->createInstanceWithContext(
43 "com.sun.star.comp.Draw.PresenterHelper",
44 mxComponentContext),
45 UNO_QUERY_THROW);
46 }
47
~PresenterPane()48 PresenterPane::~PresenterPane()
49 {
50 }
51
52 //----- XPane -----------------------------------------------------------------
53
getWindow()54 Reference<awt::XWindow> SAL_CALL PresenterPane::getWindow()
55 {
56 ThrowIfDisposed();
57 return mxContentWindow;
58 }
59
getCanvas()60 Reference<rendering::XCanvas> SAL_CALL PresenterPane::getCanvas()
61 {
62 ThrowIfDisposed();
63 return mxContentCanvas;
64 }
65
66 //----- XWindowListener -------------------------------------------------------
67
windowResized(const awt::WindowEvent & rEvent)68 void SAL_CALL PresenterPane::windowResized (const awt::WindowEvent& rEvent)
69 {
70 PresenterPaneBase::windowResized(rEvent);
71
72 Invalidate(maBoundingBox);
73
74 LayoutContextWindow();
75 ToTop();
76
77 UpdateBoundingBox();
78 Invalidate(maBoundingBox);
79 }
80
windowMoved(const awt::WindowEvent & rEvent)81 void SAL_CALL PresenterPane::windowMoved (const awt::WindowEvent& rEvent)
82 {
83 PresenterPaneBase::windowMoved(rEvent);
84
85 Invalidate(maBoundingBox);
86
87 ToTop();
88
89 UpdateBoundingBox();
90 Invalidate(maBoundingBox);
91 }
92
windowShown(const lang::EventObject & rEvent)93 void SAL_CALL PresenterPane::windowShown (const lang::EventObject& rEvent)
94 {
95 PresenterPaneBase::windowShown(rEvent);
96
97 ToTop();
98
99 if (mxContentWindow.is())
100 {
101 LayoutContextWindow();
102 mxContentWindow->setVisible(true);
103 }
104
105 UpdateBoundingBox();
106 Invalidate(maBoundingBox);
107 }
108
windowHidden(const lang::EventObject & rEvent)109 void SAL_CALL PresenterPane::windowHidden (const lang::EventObject& rEvent)
110 {
111 PresenterPaneBase::windowHidden(rEvent);
112
113 if (mxContentWindow.is())
114 mxContentWindow->setVisible(false);
115 }
116
117 //----- XPaintListener --------------------------------------------------------
118
windowPaint(const awt::PaintEvent & rEvent)119 void SAL_CALL PresenterPane::windowPaint (const awt::PaintEvent& rEvent)
120 {
121 ThrowIfDisposed();
122
123 PaintBorder(rEvent.UpdateRect);
124 }
125
126
CreateCanvases(const Reference<rendering::XSpriteCanvas> & rxParentCanvas)127 void PresenterPane::CreateCanvases (
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,
139 mxParentWindow,
140 rxParentCanvas,
141 mxParentWindow,
142 mxBorderWindow);
143 mxContentCanvas = mxPresenterHelper->createSharedCanvas(
144 rxParentCanvas,
145 mxParentWindow,
146 rxParentCanvas,
147 mxParentWindow,
148 mxContentWindow);
149
150 PaintBorder(mxBorderWindow->getPosSize());
151 }
152
Invalidate(const css::awt::Rectangle & rRepaintBox)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
UpdateBoundingBox()160 void PresenterPane::UpdateBoundingBox()
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: */
171