bump product version to 5.0.4.1
[LibreOffice.git] / sdext / source / presenter / PresenterPane.cxx
blob6c1ccd37744c7e41ccf2179003a2640209ba31bd
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
29 using namespace ::com::sun::star;
30 using namespace ::com::sun::star::uno;
31 using namespace ::com::sun::star::drawing::framework;
33 namespace sdext { namespace presenter {
35 //===== PresenterPane =========================================================
37 PresenterPane::PresenterPane (
38 const Reference<XComponentContext>& rxContext,
39 const ::rtl::Reference<PresenterController>& rpPresenterController)
40 : PresenterPaneBase(rxContext, rpPresenterController),
41 maBoundingBox()
43 Reference<lang::XMultiComponentFactory> xFactory (
44 mxComponentContext->getServiceManager(), UNO_QUERY_THROW);
45 mxPresenterHelper = Reference<drawing::XPresenterHelper>(
46 xFactory->createInstanceWithContext(
47 OUString("com.sun.star.comp.Draw.PresenterHelper"),
48 mxComponentContext),
49 UNO_QUERY_THROW);
52 PresenterPane::~PresenterPane()
56 //----- XPane -----------------------------------------------------------------
58 Reference<awt::XWindow> SAL_CALL PresenterPane::getWindow()
59 throw (RuntimeException, std::exception)
61 ThrowIfDisposed();
62 return mxContentWindow;
65 Reference<rendering::XCanvas> SAL_CALL PresenterPane::getCanvas()
66 throw (RuntimeException, std::exception)
68 ThrowIfDisposed();
69 return mxContentCanvas;
72 //----- XWindowListener -------------------------------------------------------
74 void SAL_CALL PresenterPane::windowResized (const awt::WindowEvent& rEvent)
75 throw (RuntimeException, std::exception)
77 (void)rEvent;
78 PresenterPaneBase::windowResized(rEvent);
80 Invalidate(maBoundingBox);
82 LayoutContextWindow();
83 ToTop();
85 UpdateBoundingBox();
86 Invalidate(maBoundingBox);
89 void SAL_CALL PresenterPane::windowMoved (const awt::WindowEvent& rEvent)
90 throw (RuntimeException, std::exception)
92 (void)rEvent;
93 PresenterPaneBase::windowMoved(rEvent);
95 Invalidate(maBoundingBox);
97 ToTop();
99 UpdateBoundingBox();
100 Invalidate(maBoundingBox);
103 void SAL_CALL PresenterPane::windowShown (const lang::EventObject& rEvent)
104 throw (RuntimeException, std::exception)
106 (void)rEvent;
107 PresenterPaneBase::windowShown(rEvent);
109 ToTop();
111 if (mxContentWindow.is())
113 LayoutContextWindow();
114 mxContentWindow->setVisible(sal_True);
117 UpdateBoundingBox();
118 Invalidate(maBoundingBox);
121 void SAL_CALL PresenterPane::windowHidden (const lang::EventObject& rEvent)
122 throw (RuntimeException, std::exception)
124 (void)rEvent;
125 PresenterPaneBase::windowHidden(rEvent);
127 if (mxContentWindow.is())
128 mxContentWindow->setVisible(sal_False);
131 //----- XPaintListener --------------------------------------------------------
133 void SAL_CALL PresenterPane::windowPaint (const awt::PaintEvent& rEvent)
134 throw (RuntimeException, std::exception)
136 (void)rEvent;
137 ThrowIfDisposed();
139 PaintBorder(rEvent.UpdateRect);
144 void PresenterPane::CreateCanvases (
145 const Reference<awt::XWindow>& rxParentWindow,
146 const Reference<rendering::XSpriteCanvas>& rxParentCanvas)
148 if ( ! mxPresenterHelper.is())
149 return;
150 if ( ! rxParentWindow.is())
151 return;
152 if ( ! rxParentCanvas.is())
153 return;
155 mxBorderCanvas = mxPresenterHelper->createSharedCanvas(
156 rxParentCanvas,
157 rxParentWindow,
158 Reference<rendering::XCanvas>(rxParentCanvas, UNO_QUERY),
159 rxParentWindow,
160 mxBorderWindow);
161 mxContentCanvas = mxPresenterHelper->createSharedCanvas(
162 rxParentCanvas,
163 rxParentWindow,
164 Reference<rendering::XCanvas>(rxParentCanvas, UNO_QUERY),
165 rxParentWindow,
166 mxContentWindow);
168 PaintBorder(mxBorderWindow->getPosSize());
171 void PresenterPane::Invalidate (const css::awt::Rectangle& rRepaintBox)
173 // Invalidate the parent window to be able to invalidate an area outside
174 // the current window area.
175 mpPresenterController->GetPaintManager()->Invalidate(mxParentWindow, rRepaintBox);
178 void PresenterPane::UpdateBoundingBox()
180 if (mxBorderWindow.is() && IsVisible())
181 maBoundingBox = mxBorderWindow->getPosSize();
182 else
183 maBoundingBox = awt::Rectangle();
186 } } // end of namespace ::sd::presenter
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */