LibreOffice Module sd (master) 1
PresenterPaintManager.cxx
Go to the documentation of this file.
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
21
23#include <com/sun/star/awt/InvalidateStyle.hpp>
24#include <com/sun/star/awt/XWindowPeer.hpp>
25#include <utility>
26
27using namespace ::com::sun::star;
28using namespace ::com::sun::star::uno;
29
30namespace sdext::presenter {
31
33 const css::uno::Reference<css::awt::XWindow>& rxParentWindow,
34 css::uno::Reference<css::drawing::XPresenterHelper> xPresenterHelper,
36 : mxParentWindow(rxParentWindow),
37 mxParentWindowPeer(rxParentWindow, UNO_QUERY),
38 mxPresenterHelper(std::move(xPresenterHelper)),
39 mpPaneContainer(std::move(xPaneContainer))
40{
41}
42
43::std::function<void (const css::awt::Rectangle& rRepaintBox)>
45 const css::uno::Reference<css::awt::XWindow>& rxWindow)
46{
47 return [this, rxWindow] (css::awt::Rectangle const& rRepaintBox)
48 {
49 return this->Invalidate(rxWindow, rRepaintBox /* , bSynchronous=false */);
50 };
51}
52
54 const css::uno::Reference<css::awt::XWindow>& rxWindow)
55{
56 sal_Int16 nInvalidateMode (awt::InvalidateStyle::CHILDREN);
57
59 mpPaneContainer->FindContentWindow(rxWindow));
60 if (!pDescriptor || ! pDescriptor->mbIsOpaque)
61 nInvalidateMode |= awt::InvalidateStyle::TRANSPARENT;
62 else
63 nInvalidateMode |= awt::InvalidateStyle::NOTRANSPARENT;
64
65 Invalidate(rxWindow, nInvalidateMode);
66}
67
69 const css::uno::Reference<css::awt::XWindow>& rxWindow,
70 const sal_Int16 nInvalidateFlags)
71{
72 if ((nInvalidateFlags & awt::InvalidateStyle::TRANSPARENT) != 0)
73 {
74 // Window is transparent and parent window(s) have to be painted as
75 // well. Invalidate the parent explicitly.
77 {
78 const awt::Rectangle aBBox (
79 mxPresenterHelper->getWindowExtentsRelative(rxWindow, mxParentWindow));
80 mxParentWindowPeer->invalidateRect(aBBox, nInvalidateFlags);
81 }
82 }
83 else
84 {
85 Reference<awt::XWindowPeer> xPeer (rxWindow, UNO_QUERY);
86 if (xPeer.is())
87 xPeer->invalidate(nInvalidateFlags);
88 }
89}
90
92 const css::uno::Reference<css::awt::XWindow>& rxWindow,
93 const css::awt::Rectangle& rRepaintBox,
94 const bool bSynchronous)
95{
96 sal_Int16 nInvalidateMode (awt::InvalidateStyle::CHILDREN);
97 if (bSynchronous)
98 nInvalidateMode |= awt::InvalidateStyle::UPDATE;
99
101 mpPaneContainer->FindContentWindow(rxWindow));
102 if (!pDescriptor || ! pDescriptor->mbIsOpaque)
103 nInvalidateMode |= awt::InvalidateStyle::TRANSPARENT;
104 else
105 nInvalidateMode |= awt::InvalidateStyle::NOTRANSPARENT;
106
107 Invalidate(rxWindow, rRepaintBox, nInvalidateMode);
108}
109
111 const css::uno::Reference<css::awt::XWindow>& rxWindow,
112 const css::awt::Rectangle& rRepaintBox,
113 const sal_Int16 nInvalidateFlags)
114{
115 if ((nInvalidateFlags & awt::InvalidateStyle::TRANSPARENT) != 0)
116 {
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())
120 {
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);
130 }
131 }
132 else
133 {
134 Reference<awt::XWindowPeer> xPeer (rxWindow, UNO_QUERY);
135 if (xPeer.is())
136 xPeer->invalidateRect(rRepaintBox, nInvalidateFlags);
137 }
138}
139
140}
141
142/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< drawing::XPresenterHelper > mxPresenterHelper
::std::function< void(const css::awt::Rectangle &rRepaintBox)> GetInvalidator(const css::uno::Reference< css::awt::XWindow > &rxWindow)
css::uno::Reference< css::drawing::XPresenterHelper > mxPresenterHelper
css::uno::Reference< css::awt::XWindowPeer > mxParentWindowPeer
css::uno::Reference< css::awt::XWindow > mxParentWindow
PresenterPaintManager(const css::uno::Reference< css::awt::XWindow > &rxParentWindow, css::uno::Reference< css::drawing::XPresenterHelper > xPresenterHelper, rtl::Reference< PresenterPaneContainer > xPaneContainer)
Create paint manager with the window that is the top node in the local window hierarchy.
void Invalidate(const css::uno::Reference< css::awt::XWindow > &rxWindow)
Request a repaint of the whole window.
::rtl::Reference< PresenterPaneContainer > mpPaneContainer
std::shared_ptr< PaneDescriptor > SharedPaneDescriptor