Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / sdext / source / presenter / PresenterPane.cxx
blobe539d98b4373d7e2815e5e5bd6699eea93ffa0c8
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>
28 using namespace ::com::sun::star;
29 using namespace ::com::sun::star::uno;
30 using namespace ::com::sun::star::drawing::framework;
32 namespace sdext { namespace presenter {
34 //===== PresenterPane =========================================================
36 PresenterPane::PresenterPane (
37 const Reference<XComponentContext>& rxContext,
38 const ::rtl::Reference<PresenterController>& rpPresenterController)
39 : PresenterPaneBase(rxContext, rpPresenterController),
40 maBoundingBox()
42 Reference<lang::XMultiComponentFactory> xFactory (
43 mxComponentContext->getServiceManager(), UNO_QUERY_THROW);
44 mxPresenterHelper.set(
45 xFactory->createInstanceWithContext(
46 "com.sun.star.comp.Draw.PresenterHelper",
47 mxComponentContext),
48 UNO_QUERY_THROW);
51 PresenterPane::~PresenterPane()
55 //----- XPane -----------------------------------------------------------------
57 Reference<awt::XWindow> SAL_CALL PresenterPane::getWindow()
59 ThrowIfDisposed();
60 return mxContentWindow;
63 Reference<rendering::XCanvas> SAL_CALL PresenterPane::getCanvas()
65 ThrowIfDisposed();
66 return mxContentCanvas;
69 //----- XWindowListener -------------------------------------------------------
71 void SAL_CALL PresenterPane::windowResized (const awt::WindowEvent& rEvent)
73 PresenterPaneBase::windowResized(rEvent);
75 Invalidate(maBoundingBox);
77 LayoutContextWindow();
78 ToTop();
80 UpdateBoundingBox();
81 Invalidate(maBoundingBox);
84 void SAL_CALL PresenterPane::windowMoved (const awt::WindowEvent& rEvent)
86 PresenterPaneBase::windowMoved(rEvent);
88 Invalidate(maBoundingBox);
90 ToTop();
92 UpdateBoundingBox();
93 Invalidate(maBoundingBox);
96 void SAL_CALL PresenterPane::windowShown (const lang::EventObject& rEvent)
98 PresenterPaneBase::windowShown(rEvent);
100 ToTop();
102 if (mxContentWindow.is())
104 LayoutContextWindow();
105 mxContentWindow->setVisible(true);
108 UpdateBoundingBox();
109 Invalidate(maBoundingBox);
112 void SAL_CALL PresenterPane::windowHidden (const lang::EventObject& rEvent)
114 PresenterPaneBase::windowHidden(rEvent);
116 if (mxContentWindow.is())
117 mxContentWindow->setVisible(false);
120 //----- XPaintListener --------------------------------------------------------
122 void SAL_CALL PresenterPane::windowPaint (const awt::PaintEvent& rEvent)
124 ThrowIfDisposed();
126 PaintBorder(rEvent.UpdateRect);
130 void PresenterPane::CreateCanvases (
131 const Reference<rendering::XSpriteCanvas>& rxParentCanvas)
133 if ( ! mxPresenterHelper.is())
134 return;
135 if ( ! mxParentWindow.is())
136 return;
137 if ( ! rxParentCanvas.is())
138 return;
140 mxBorderCanvas = mxPresenterHelper->createSharedCanvas(
141 rxParentCanvas,
142 mxParentWindow,
143 Reference<rendering::XCanvas>(rxParentCanvas, UNO_QUERY),
144 mxParentWindow,
145 mxBorderWindow);
146 mxContentCanvas = mxPresenterHelper->createSharedCanvas(
147 rxParentCanvas,
148 mxParentWindow,
149 Reference<rendering::XCanvas>(rxParentCanvas, UNO_QUERY),
150 mxParentWindow,
151 mxContentWindow);
153 PaintBorder(mxBorderWindow->getPosSize());
156 void PresenterPane::Invalidate (const css::awt::Rectangle& rRepaintBox)
158 // Invalidate the parent window to be able to invalidate an area outside
159 // the current window area.
160 mpPresenterController->GetPaintManager()->Invalidate(mxParentWindow, rRepaintBox);
163 void PresenterPane::UpdateBoundingBox()
165 if (mxBorderWindow.is() && IsVisible())
166 maBoundingBox = mxBorderWindow->getPosSize();
167 else
168 maBoundingBox = awt::Rectangle();
171 } } // end of namespace ::sd::presenter
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */