1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: PresenterPaintManager.cxx,v $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_sdext.hxx"
35 #include "PresenterPaintManager.hxx"
37 #include "PresenterPaneContainer.hxx"
38 #include <com/sun/star/awt/InvalidateStyle.hpp>
39 #include <com/sun/star/awt/XWindowPeer.hpp>
41 using namespace ::com::sun::star
;
42 using namespace ::com::sun::star::uno
;
44 namespace sdext
{ namespace presenter
{
46 PresenterPaintManager::PresenterPaintManager (
47 const css::uno::Reference
<css::awt::XWindow
>& rxParentWindow
,
48 const css::uno::Reference
<css::drawing::XPresenterHelper
>& rxPresenterHelper
,
49 const rtl::Reference
<PresenterPaneContainer
>& rpPaneContainer
)
50 : mxParentWindow(rxParentWindow
),
51 mxParentWindowPeer(rxParentWindow
, UNO_QUERY
),
52 mxPresenterHelper(rxPresenterHelper
),
53 mpPaneContainer(rpPaneContainer
)
60 void PresenterPaintManager::Invalidate (
61 const css::uno::Reference
<css::awt::XWindow
>& rxWindow
,
62 const bool bSynchronous
)
64 sal_Int16
nInvalidateMode (awt::InvalidateStyle::CHILDREN
);
66 nInvalidateMode
|= awt::InvalidateStyle::UPDATE
;
68 PresenterPaneContainer::SharedPaneDescriptor
pDescriptor(
69 mpPaneContainer
->FindContentWindow(rxWindow
));
70 if (pDescriptor
.get()==NULL
|| ! pDescriptor
->mbIsOpaque
)
71 nInvalidateMode
|= awt::InvalidateStyle::TRANSPARENT
;
73 nInvalidateMode
|= awt::InvalidateStyle::NOTRANSPARENT
;
75 Invalidate(rxWindow
, nInvalidateMode
);
81 void PresenterPaintManager::Invalidate (
82 const css::uno::Reference
<css::awt::XWindow
>& rxWindow
,
83 const sal_Int16 nInvalidateFlags
)
85 if ((nInvalidateFlags
& awt::InvalidateStyle::TRANSPARENT
) != 0)
87 // Window is transparent and parent window(s) have to be painted as
88 // well. Invalidate the parent explicitly.
89 if (mxPresenterHelper
.is() && mxParentWindowPeer
.is())
91 const awt::Rectangle
aBBox (
92 mxPresenterHelper
->getWindowExtentsRelative(rxWindow
, mxParentWindow
));
93 mxParentWindowPeer
->invalidateRect(aBBox
, nInvalidateFlags
);
98 Reference
<awt::XWindowPeer
> xPeer (rxWindow
, UNO_QUERY
);
100 xPeer
->invalidate(nInvalidateFlags
);
107 void PresenterPaintManager::Invalidate (
108 const css::uno::Reference
<css::awt::XWindow
>& rxWindow
,
109 const css::awt::Rectangle
& rRepaintBox
,
110 const bool bSynchronous
)
112 sal_Int16
nInvalidateMode (awt::InvalidateStyle::CHILDREN
);
114 nInvalidateMode
|= awt::InvalidateStyle::UPDATE
;
116 PresenterPaneContainer::SharedPaneDescriptor
pDescriptor(
117 mpPaneContainer
->FindContentWindow(rxWindow
));
118 if (pDescriptor
.get()==NULL
|| ! pDescriptor
->mbIsOpaque
)
119 nInvalidateMode
|= awt::InvalidateStyle::TRANSPARENT
;
121 nInvalidateMode
|= awt::InvalidateStyle::NOTRANSPARENT
;
123 Invalidate(rxWindow
, rRepaintBox
, nInvalidateMode
);
129 void PresenterPaintManager::Invalidate (
130 const css::uno::Reference
<css::awt::XWindow
>& rxWindow
,
131 const css::awt::Rectangle
& rRepaintBox
,
132 const sal_Int16 nInvalidateFlags
)
134 if ((nInvalidateFlags
& awt::InvalidateStyle::TRANSPARENT
) != 0)
136 // Window is transparent and parent window(s) have to be painted as
137 // well. Invalidate the parent explicitly.
138 if (mxPresenterHelper
.is() && mxParentWindowPeer
.is())
140 const awt::Rectangle
aBBox (
141 mxPresenterHelper
->getWindowExtentsRelative(rxWindow
, mxParentWindow
));
142 mxParentWindowPeer
->invalidateRect(
144 rRepaintBox
.X
+ aBBox
.X
,
145 rRepaintBox
.Y
+ aBBox
.Y
,
153 Reference
<awt::XWindowPeer
> xPeer (rxWindow
, UNO_QUERY
);
155 xPeer
->invalidateRect(rRepaintBox
, nInvalidateFlags
);