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 "PresenterPane.hxx"
21 : #include "PresenterController.hxx"
22 : #include "PresenterPaintManager.hxx"
23 : #include <com/sun/star/awt/XWindowPeer.hpp>
24 : #include <com/sun/star/lang/XMultiComponentFactory.hpp>
25 : #include <com/sun/star/drawing/CanvasFeature.hpp>
26 : #include <com/sun/star/rendering/CompositeOperation.hpp>
27 : #include <osl/mutex.hxx>
28 :
29 : using namespace ::com::sun::star;
30 : using namespace ::com::sun::star::uno;
31 : using namespace ::com::sun::star::drawing::framework;
32 : using ::rtl::OUString;
33 :
34 : namespace sdext { namespace presenter {
35 :
36 : //===== PresenterPane =========================================================
37 :
38 0 : PresenterPane::PresenterPane (
39 : const Reference<XComponentContext>& rxContext,
40 : const ::rtl::Reference<PresenterController>& rpPresenterController)
41 : : PresenterPaneBase(rxContext, rpPresenterController),
42 0 : maBoundingBox()
43 : {
44 : Reference<lang::XMultiComponentFactory> xFactory (
45 0 : mxComponentContext->getServiceManager(), UNO_QUERY_THROW);
46 : mxPresenterHelper = Reference<drawing::XPresenterHelper>(
47 0 : xFactory->createInstanceWithContext(
48 : OUString("com.sun.star.comp.Draw.PresenterHelper"),
49 0 : mxComponentContext),
50 0 : UNO_QUERY_THROW);
51 0 : }
52 :
53 0 : PresenterPane::~PresenterPane (void)
54 : {
55 0 : }
56 :
57 : //----- XPane -----------------------------------------------------------------
58 :
59 0 : Reference<awt::XWindow> SAL_CALL PresenterPane::getWindow (void)
60 : throw (RuntimeException)
61 : {
62 0 : ThrowIfDisposed();
63 0 : return mxContentWindow;
64 : }
65 :
66 0 : Reference<rendering::XCanvas> SAL_CALL PresenterPane::getCanvas (void)
67 : throw (RuntimeException)
68 : {
69 0 : ThrowIfDisposed();
70 0 : return mxContentCanvas;
71 : }
72 :
73 : //----- XWindowListener -------------------------------------------------------
74 :
75 0 : void SAL_CALL PresenterPane::windowResized (const awt::WindowEvent& rEvent)
76 : throw (RuntimeException)
77 : {
78 : (void)rEvent;
79 0 : PresenterPaneBase::windowResized(rEvent);
80 :
81 0 : Invalidate(maBoundingBox);
82 :
83 0 : LayoutContextWindow();
84 0 : ToTop();
85 :
86 0 : UpdateBoundingBox();
87 0 : Invalidate(maBoundingBox);
88 0 : }
89 :
90 0 : void SAL_CALL PresenterPane::windowMoved (const awt::WindowEvent& rEvent)
91 : throw (RuntimeException)
92 : {
93 : (void)rEvent;
94 0 : PresenterPaneBase::windowMoved(rEvent);
95 :
96 0 : Invalidate(maBoundingBox);
97 :
98 0 : ToTop();
99 :
100 0 : UpdateBoundingBox();
101 0 : Invalidate(maBoundingBox);
102 0 : }
103 :
104 0 : void SAL_CALL PresenterPane::windowShown (const lang::EventObject& rEvent)
105 : throw (RuntimeException)
106 : {
107 : (void)rEvent;
108 0 : PresenterPaneBase::windowShown(rEvent);
109 :
110 0 : ToTop();
111 :
112 0 : if (mxContentWindow.is())
113 : {
114 0 : LayoutContextWindow();
115 0 : mxContentWindow->setVisible(sal_True);
116 : }
117 :
118 0 : UpdateBoundingBox();
119 0 : Invalidate(maBoundingBox);
120 0 : }
121 :
122 0 : void SAL_CALL PresenterPane::windowHidden (const lang::EventObject& rEvent)
123 : throw (RuntimeException)
124 : {
125 : (void)rEvent;
126 0 : PresenterPaneBase::windowHidden(rEvent);
127 :
128 0 : if (mxContentWindow.is())
129 0 : mxContentWindow->setVisible(sal_False);
130 0 : }
131 :
132 : //----- XPaintListener --------------------------------------------------------
133 :
134 0 : void SAL_CALL PresenterPane::windowPaint (const awt::PaintEvent& rEvent)
135 : throw (RuntimeException)
136 : {
137 : (void)rEvent;
138 0 : ThrowIfDisposed();
139 :
140 0 : PaintBorder(rEvent.UpdateRect);
141 0 : }
142 :
143 : //-----------------------------------------------------------------------------
144 :
145 0 : void PresenterPane::CreateCanvases (
146 : const Reference<awt::XWindow>& rxParentWindow,
147 : const Reference<rendering::XSpriteCanvas>& rxParentCanvas)
148 : {
149 0 : if ( ! mxPresenterHelper.is())
150 0 : return;
151 0 : if ( ! rxParentWindow.is())
152 0 : return;
153 0 : if ( ! rxParentCanvas.is())
154 0 : return;
155 :
156 0 : mxBorderCanvas = mxPresenterHelper->createSharedCanvas(
157 : rxParentCanvas,
158 : rxParentWindow,
159 : Reference<rendering::XCanvas>(rxParentCanvas, UNO_QUERY),
160 : rxParentWindow,
161 0 : mxBorderWindow);
162 0 : mxContentCanvas = mxPresenterHelper->createSharedCanvas(
163 : rxParentCanvas,
164 : rxParentWindow,
165 : Reference<rendering::XCanvas>(rxParentCanvas, UNO_QUERY),
166 : rxParentWindow,
167 0 : mxContentWindow);
168 :
169 0 : PaintBorder(mxBorderWindow->getPosSize());
170 : }
171 :
172 0 : void PresenterPane::Invalidate (const css::awt::Rectangle& rRepaintBox)
173 : {
174 : // Invalidate the parent window to be able to invalidate an area outside
175 : // the current window area.
176 0 : mpPresenterController->GetPaintManager()->Invalidate(mxParentWindow, rRepaintBox);
177 0 : }
178 :
179 0 : void PresenterPane::UpdateBoundingBox (void)
180 : {
181 0 : if (mxBorderWindow.is() && IsVisible())
182 0 : maBoundingBox = mxBorderWindow->getPosSize();
183 : else
184 0 : maBoundingBox = awt::Rectangle();
185 0 : }
186 :
187 : } } // end of namespace ::sd::presenter
188 :
189 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|