Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sd / source / console / PresenterPaintManager.cxx
blobf7b612d9a05af0fe9b01bc292bf2d323b18e2ae6
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 "PresenterPaintManager.hxx"
22 #include "PresenterPaneContainer.hxx"
23 #include <com/sun/star/awt/InvalidateStyle.hpp>
24 #include <com/sun/star/awt/XWindowPeer.hpp>
25 #include <utility>
27 using namespace ::com::sun::star;
28 using namespace ::com::sun::star::uno;
30 namespace sdext::presenter {
32 PresenterPaintManager::PresenterPaintManager (
33 const css::uno::Reference<css::awt::XWindow>& rxParentWindow,
34 css::uno::Reference<css::drawing::XPresenterHelper> xPresenterHelper,
35 rtl::Reference<PresenterPaneContainer> xPaneContainer)
36 : mxParentWindow(rxParentWindow),
37 mxParentWindowPeer(rxParentWindow, UNO_QUERY),
38 mxPresenterHelper(std::move(xPresenterHelper)),
39 mpPaneContainer(std::move(xPaneContainer))
43 ::std::function<void (const css::awt::Rectangle& rRepaintBox)>
44 PresenterPaintManager::GetInvalidator (
45 const css::uno::Reference<css::awt::XWindow>& rxWindow)
47 return [this, rxWindow] (css::awt::Rectangle const& rRepaintBox)
49 return this->Invalidate(rxWindow, rRepaintBox /* , bSynchronous=false */);
53 void PresenterPaintManager::Invalidate (
54 const css::uno::Reference<css::awt::XWindow>& rxWindow)
56 sal_Int16 nInvalidateMode (awt::InvalidateStyle::CHILDREN);
58 PresenterPaneContainer::SharedPaneDescriptor pDescriptor(
59 mpPaneContainer->FindContentWindow(rxWindow));
60 if (!pDescriptor || ! pDescriptor->mbIsOpaque)
61 nInvalidateMode |= awt::InvalidateStyle::TRANSPARENT;
62 else
63 nInvalidateMode |= awt::InvalidateStyle::NOTRANSPARENT;
65 Invalidate(rxWindow, nInvalidateMode);
68 void PresenterPaintManager::Invalidate (
69 const css::uno::Reference<css::awt::XWindow>& rxWindow,
70 const sal_Int16 nInvalidateFlags)
72 if ((nInvalidateFlags & awt::InvalidateStyle::TRANSPARENT) != 0)
74 // Window is transparent and parent window(s) have to be painted as
75 // well. Invalidate the parent explicitly.
76 if (mxPresenterHelper.is() && mxParentWindowPeer.is())
78 const awt::Rectangle aBBox (
79 mxPresenterHelper->getWindowExtentsRelative(rxWindow, mxParentWindow));
80 mxParentWindowPeer->invalidateRect(aBBox, nInvalidateFlags);
83 else
85 Reference<awt::XWindowPeer> xPeer (rxWindow, UNO_QUERY);
86 if (xPeer.is())
87 xPeer->invalidate(nInvalidateFlags);
91 void PresenterPaintManager::Invalidate (
92 const css::uno::Reference<css::awt::XWindow>& rxWindow,
93 const css::awt::Rectangle& rRepaintBox,
94 const bool bSynchronous)
96 sal_Int16 nInvalidateMode (awt::InvalidateStyle::CHILDREN);
97 if (bSynchronous)
98 nInvalidateMode |= awt::InvalidateStyle::UPDATE;
100 PresenterPaneContainer::SharedPaneDescriptor pDescriptor(
101 mpPaneContainer->FindContentWindow(rxWindow));
102 if (!pDescriptor || ! pDescriptor->mbIsOpaque)
103 nInvalidateMode |= awt::InvalidateStyle::TRANSPARENT;
104 else
105 nInvalidateMode |= awt::InvalidateStyle::NOTRANSPARENT;
107 Invalidate(rxWindow, rRepaintBox, nInvalidateMode);
110 void PresenterPaintManager::Invalidate (
111 const css::uno::Reference<css::awt::XWindow>& rxWindow,
112 const css::awt::Rectangle& rRepaintBox,
113 const sal_Int16 nInvalidateFlags)
115 if ((nInvalidateFlags & awt::InvalidateStyle::TRANSPARENT) != 0)
117 // Window is transparent and parent window(s) have to be painted as
118 // well. Invalidate the parent explicitly.
119 if (mxPresenterHelper.is() && mxParentWindowPeer.is())
121 const awt::Rectangle aBBox (
122 mxPresenterHelper->getWindowExtentsRelative(rxWindow, mxParentWindow));
123 mxParentWindowPeer->invalidateRect(
124 awt::Rectangle(
125 rRepaintBox.X + aBBox.X,
126 rRepaintBox.Y + aBBox.Y,
127 rRepaintBox.Width,
128 rRepaintBox.Height),
129 nInvalidateFlags);
132 else
134 Reference<awt::XWindowPeer> xPeer (rxWindow, UNO_QUERY);
135 if (xPeer.is())
136 xPeer->invalidateRect(rRepaintBox, nInvalidateFlags);
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */