Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sd / source / console / PresenterPane.cxx
blobad35315438e8442a07935e94f49c67bc10c6baeb
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/lang/XMultiComponentFactory.hpp>
25 using namespace ::com::sun::star;
26 using namespace ::com::sun::star::uno;
27 using namespace ::com::sun::star::drawing::framework;
29 namespace sdext::presenter {
31 //===== PresenterPane =========================================================
33 PresenterPane::PresenterPane (
34 const Reference<XComponentContext>& rxContext,
35 const ::rtl::Reference<PresenterController>& rpPresenterController)
36 : PresenterPaneBase(rxContext, rpPresenterController)
38 Reference<lang::XMultiComponentFactory> xFactory (
39 mxComponentContext->getServiceManager(), UNO_SET_THROW);
40 mxPresenterHelper.set(
41 xFactory->createInstanceWithContext(
42 "com.sun.star.comp.Draw.PresenterHelper",
43 mxComponentContext),
44 UNO_QUERY_THROW);
47 PresenterPane::~PresenterPane()
51 //----- XPane -----------------------------------------------------------------
53 Reference<awt::XWindow> SAL_CALL PresenterPane::getWindow()
55 ThrowIfDisposed();
56 return mxContentWindow;
59 Reference<rendering::XCanvas> SAL_CALL PresenterPane::getCanvas()
61 ThrowIfDisposed();
62 return mxContentCanvas;
65 //----- XWindowListener -------------------------------------------------------
67 void SAL_CALL PresenterPane::windowResized (const awt::WindowEvent& rEvent)
69 PresenterPaneBase::windowResized(rEvent);
71 Invalidate(maBoundingBox);
73 LayoutContextWindow();
74 ToTop();
76 UpdateBoundingBox();
77 Invalidate(maBoundingBox);
80 void SAL_CALL PresenterPane::windowMoved (const awt::WindowEvent& rEvent)
82 PresenterPaneBase::windowMoved(rEvent);
84 Invalidate(maBoundingBox);
86 ToTop();
88 UpdateBoundingBox();
89 Invalidate(maBoundingBox);
92 void SAL_CALL PresenterPane::windowShown (const lang::EventObject& rEvent)
94 PresenterPaneBase::windowShown(rEvent);
96 ToTop();
98 if (mxContentWindow.is())
100 LayoutContextWindow();
101 mxContentWindow->setVisible(true);
104 UpdateBoundingBox();
105 Invalidate(maBoundingBox);
108 void SAL_CALL PresenterPane::windowHidden (const lang::EventObject& rEvent)
110 PresenterPaneBase::windowHidden(rEvent);
112 if (mxContentWindow.is())
113 mxContentWindow->setVisible(false);
116 //----- XPaintListener --------------------------------------------------------
118 void SAL_CALL PresenterPane::windowPaint (const awt::PaintEvent& rEvent)
120 ThrowIfDisposed();
122 PaintBorder(rEvent.UpdateRect);
126 void PresenterPane::CreateCanvases (
127 const Reference<rendering::XSpriteCanvas>& rxParentCanvas)
129 if ( ! mxPresenterHelper.is())
130 return;
131 if ( ! mxParentWindow.is())
132 return;
133 if ( ! rxParentCanvas.is())
134 return;
136 mxBorderCanvas = mxPresenterHelper->createSharedCanvas(
137 rxParentCanvas,
138 mxParentWindow,
139 rxParentCanvas,
140 mxParentWindow,
141 mxBorderWindow);
142 mxContentCanvas = mxPresenterHelper->createSharedCanvas(
143 rxParentCanvas,
144 mxParentWindow,
145 rxParentCanvas,
146 mxParentWindow,
147 mxContentWindow);
149 PaintBorder(mxBorderWindow->getPosSize());
152 void PresenterPane::Invalidate (const css::awt::Rectangle& rRepaintBox)
154 // Invalidate the parent window to be able to invalidate an area outside
155 // the current window area.
156 mpPresenterController->GetPaintManager()->Invalidate(mxParentWindow, rRepaintBox);
159 void PresenterPane::UpdateBoundingBox()
161 if (mxBorderWindow.is() && IsVisible())
162 maBoundingBox = mxBorderWindow->getPosSize();
163 else
164 maBoundingBox = awt::Rectangle();
167 } // end of namespace ::sdext::presenter
169 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */