Branch data Line data Source code
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 : :
20 : : #include "PresenterPaintManager.hxx"
21 : :
22 : : #include "PresenterPaneContainer.hxx"
23 : : #include <com/sun/star/awt/InvalidateStyle.hpp>
24 : : #include <com/sun/star/awt/XWindowPeer.hpp>
25 : : #include <boost/bind.hpp>
26 : :
27 : : using namespace ::com::sun::star;
28 : : using namespace ::com::sun::star::uno;
29 : :
30 : : namespace sdext { namespace presenter {
31 : :
32 : 0 : PresenterPaintManager::PresenterPaintManager (
33 : : const css::uno::Reference<css::awt::XWindow>& rxParentWindow,
34 : : const css::uno::Reference<css::drawing::XPresenterHelper>& rxPresenterHelper,
35 : : const rtl::Reference<PresenterPaneContainer>& rpPaneContainer)
36 : : : mxParentWindow(rxParentWindow),
37 : : mxParentWindowPeer(rxParentWindow, UNO_QUERY),
38 : : mxPresenterHelper(rxPresenterHelper),
39 [ # # ]: 0 : mpPaneContainer(rpPaneContainer)
40 : : {
41 : 0 : }
42 : :
43 : : ::boost::function<void(const css::awt::Rectangle& rRepaintBox)>
44 : 0 : PresenterPaintManager::GetInvalidator (
45 : : const css::uno::Reference<css::awt::XWindow>& rxWindow,
46 : : const bool bSynchronous)
47 : : {
48 : : return ::boost::bind(
49 : : static_cast<void (PresenterPaintManager::*)(
50 : : const css::uno::Reference<css::awt::XWindow>&,
51 : : const css::awt::Rectangle&,
52 : : const bool)>(&PresenterPaintManager::Invalidate),
53 : : this,
54 : : rxWindow,
55 : : _1,
56 [ # # ][ # # ]: 0 : bSynchronous);
[ # # ]
57 : : }
58 : :
59 : 0 : void PresenterPaintManager::Invalidate (
60 : : const css::uno::Reference<css::awt::XWindow>& rxWindow,
61 : : const bool bSynchronous)
62 : : {
63 : 0 : sal_Int16 nInvalidateMode (awt::InvalidateStyle::CHILDREN);
64 [ # # ]: 0 : if (bSynchronous)
65 : 0 : nInvalidateMode |= awt::InvalidateStyle::UPDATE;
66 : :
67 : : PresenterPaneContainer::SharedPaneDescriptor pDescriptor(
68 [ # # ]: 0 : mpPaneContainer->FindContentWindow(rxWindow));
69 [ # # ][ # # ]: 0 : if (pDescriptor.get()==NULL || ! pDescriptor->mbIsOpaque)
[ # # ]
70 : 0 : nInvalidateMode |= awt::InvalidateStyle::TRANSPARENT;
71 : : else
72 : 0 : nInvalidateMode |= awt::InvalidateStyle::NOTRANSPARENT;
73 : :
74 [ # # ][ # # ]: 0 : Invalidate(rxWindow, nInvalidateMode);
75 : 0 : }
76 : :
77 : 0 : void PresenterPaintManager::Invalidate (
78 : : const css::uno::Reference<css::awt::XWindow>& rxWindow,
79 : : const sal_Int16 nInvalidateFlags)
80 : : {
81 [ # # ]: 0 : if ((nInvalidateFlags & awt::InvalidateStyle::TRANSPARENT) != 0)
82 : : {
83 : : // Window is transparent and parent window(s) have to be painted as
84 : : // well. Invalidate the parent explicitly.
85 [ # # ][ # # ]: 0 : if (mxPresenterHelper.is() && mxParentWindowPeer.is())
[ # # ]
86 : : {
87 : : const awt::Rectangle aBBox (
88 [ # # ][ # # ]: 0 : mxPresenterHelper->getWindowExtentsRelative(rxWindow, mxParentWindow));
89 [ # # ][ # # ]: 0 : mxParentWindowPeer->invalidateRect(aBBox, nInvalidateFlags);
90 : : }
91 : : }
92 : : else
93 : : {
94 [ # # ]: 0 : Reference<awt::XWindowPeer> xPeer (rxWindow, UNO_QUERY);
95 [ # # ]: 0 : if (xPeer.is())
96 [ # # ][ # # ]: 0 : xPeer->invalidate(nInvalidateFlags);
97 : : }
98 : 0 : }
99 : :
100 : 0 : void PresenterPaintManager::Invalidate (
101 : : const css::uno::Reference<css::awt::XWindow>& rxWindow,
102 : : const css::awt::Rectangle& rRepaintBox,
103 : : const bool bSynchronous)
104 : : {
105 : 0 : sal_Int16 nInvalidateMode (awt::InvalidateStyle::CHILDREN);
106 [ # # ]: 0 : if (bSynchronous)
107 : 0 : nInvalidateMode |= awt::InvalidateStyle::UPDATE;
108 : :
109 : : PresenterPaneContainer::SharedPaneDescriptor pDescriptor(
110 [ # # ]: 0 : mpPaneContainer->FindContentWindow(rxWindow));
111 [ # # ][ # # ]: 0 : if (pDescriptor.get()==NULL || ! pDescriptor->mbIsOpaque)
[ # # ]
112 : 0 : nInvalidateMode |= awt::InvalidateStyle::TRANSPARENT;
113 : : else
114 : 0 : nInvalidateMode |= awt::InvalidateStyle::NOTRANSPARENT;
115 : :
116 [ # # ][ # # ]: 0 : Invalidate(rxWindow, rRepaintBox, nInvalidateMode);
117 : 0 : }
118 : :
119 : 0 : void PresenterPaintManager::Invalidate (
120 : : const css::uno::Reference<css::awt::XWindow>& rxWindow,
121 : : const css::awt::Rectangle& rRepaintBox,
122 : : const sal_Int16 nInvalidateFlags)
123 : : {
124 [ # # ]: 0 : if ((nInvalidateFlags & awt::InvalidateStyle::TRANSPARENT) != 0)
125 : : {
126 : : // Window is transparent and parent window(s) have to be painted as
127 : : // well. Invalidate the parent explicitly.
128 [ # # ][ # # ]: 0 : if (mxPresenterHelper.is() && mxParentWindowPeer.is())
[ # # ]
129 : : {
130 : : const awt::Rectangle aBBox (
131 [ # # ][ # # ]: 0 : mxPresenterHelper->getWindowExtentsRelative(rxWindow, mxParentWindow));
132 [ # # ]: 0 : mxParentWindowPeer->invalidateRect(
133 : : awt::Rectangle(
134 : : rRepaintBox.X + aBBox.X,
135 : : rRepaintBox.Y + aBBox.Y,
136 : : rRepaintBox.Width,
137 : : rRepaintBox.Height),
138 [ # # ]: 0 : nInvalidateFlags);
139 : : }
140 : : }
141 : : else
142 : : {
143 [ # # ]: 0 : Reference<awt::XWindowPeer> xPeer (rxWindow, UNO_QUERY);
144 [ # # ]: 0 : if (xPeer.is())
145 [ # # ][ # # ]: 0 : xPeer->invalidateRect(rRepaintBox, nInvalidateFlags);
146 : : }
147 : 0 : }
148 : :
149 [ + - ][ + - ]: 24 : } }
150 : :
151 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|