1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sdext.hxx" 26 27 #include "PresenterPaintManager.hxx" 28 29 #include "PresenterPaneContainer.hxx" 30 #include <com/sun/star/awt/InvalidateStyle.hpp> 31 #include <com/sun/star/awt/XWindowPeer.hpp> 32 #include <boost/bind.hpp> 33 34 using namespace ::com::sun::star; 35 using namespace ::com::sun::star::uno; 36 37 namespace sdext { namespace presenter { 38 39 PresenterPaintManager::PresenterPaintManager ( 40 const css::uno::Reference<css::awt::XWindow>& rxParentWindow, 41 const css::uno::Reference<css::drawing::XPresenterHelper>& rxPresenterHelper, 42 const rtl::Reference<PresenterPaneContainer>& rpPaneContainer) 43 : mxParentWindow(rxParentWindow), 44 mxParentWindowPeer(rxParentWindow, UNO_QUERY), 45 mxPresenterHelper(rxPresenterHelper), 46 mpPaneContainer(rpPaneContainer) 47 { 48 } 49 50 51 52 53 ::boost::function<void(const css::awt::Rectangle& rRepaintBox)> 54 PresenterPaintManager::GetInvalidator ( 55 const css::uno::Reference<css::awt::XWindow>& rxWindow, 56 const bool bSynchronous) 57 { 58 return ::boost::bind( 59 static_cast<void (PresenterPaintManager::*)( 60 const css::uno::Reference<css::awt::XWindow>&, 61 const css::awt::Rectangle&, 62 const bool)>(&PresenterPaintManager::Invalidate), 63 this, 64 rxWindow, 65 _1, 66 bSynchronous); 67 } 68 69 70 71 72 void PresenterPaintManager::Invalidate ( 73 const css::uno::Reference<css::awt::XWindow>& rxWindow, 74 const bool bSynchronous) 75 { 76 sal_Int16 nInvalidateMode (awt::InvalidateStyle::CHILDREN); 77 if (bSynchronous) 78 nInvalidateMode |= awt::InvalidateStyle::UPDATE; 79 80 PresenterPaneContainer::SharedPaneDescriptor pDescriptor( 81 mpPaneContainer->FindContentWindow(rxWindow)); 82 if (pDescriptor.get()==NULL || ! pDescriptor->mbIsOpaque) 83 nInvalidateMode |= awt::InvalidateStyle::TRANSPARENT; 84 else 85 nInvalidateMode |= awt::InvalidateStyle::NOTRANSPARENT; 86 87 Invalidate(rxWindow, nInvalidateMode); 88 } 89 90 91 92 93 void PresenterPaintManager::Invalidate ( 94 const css::uno::Reference<css::awt::XWindow>& rxWindow, 95 const sal_Int16 nInvalidateFlags) 96 { 97 if ((nInvalidateFlags & awt::InvalidateStyle::TRANSPARENT) != 0) 98 { 99 // Window is transparent and parent window(s) have to be painted as 100 // well. Invalidate the parent explicitly. 101 if (mxPresenterHelper.is() && mxParentWindowPeer.is()) 102 { 103 const awt::Rectangle aBBox ( 104 mxPresenterHelper->getWindowExtentsRelative(rxWindow, mxParentWindow)); 105 mxParentWindowPeer->invalidateRect(aBBox, nInvalidateFlags); 106 } 107 } 108 else 109 { 110 Reference<awt::XWindowPeer> xPeer (rxWindow, UNO_QUERY); 111 if (xPeer.is()) 112 xPeer->invalidate(nInvalidateFlags); 113 } 114 } 115 116 117 118 119 void PresenterPaintManager::Invalidate ( 120 const css::uno::Reference<css::awt::XWindow>& rxWindow, 121 const css::awt::Rectangle& rRepaintBox, 122 const bool bSynchronous) 123 { 124 sal_Int16 nInvalidateMode (awt::InvalidateStyle::CHILDREN); 125 if (bSynchronous) 126 nInvalidateMode |= awt::InvalidateStyle::UPDATE; 127 128 PresenterPaneContainer::SharedPaneDescriptor pDescriptor( 129 mpPaneContainer->FindContentWindow(rxWindow)); 130 if (pDescriptor.get()==NULL || ! pDescriptor->mbIsOpaque) 131 nInvalidateMode |= awt::InvalidateStyle::TRANSPARENT; 132 else 133 nInvalidateMode |= awt::InvalidateStyle::NOTRANSPARENT; 134 135 Invalidate(rxWindow, rRepaintBox, nInvalidateMode); 136 } 137 138 139 140 141 void PresenterPaintManager::Invalidate ( 142 const css::uno::Reference<css::awt::XWindow>& rxWindow, 143 const css::awt::Rectangle& rRepaintBox, 144 const sal_Int16 nInvalidateFlags) 145 { 146 if ((nInvalidateFlags & awt::InvalidateStyle::TRANSPARENT) != 0) 147 { 148 // Window is transparent and parent window(s) have to be painted as 149 // well. Invalidate the parent explicitly. 150 if (mxPresenterHelper.is() && mxParentWindowPeer.is()) 151 { 152 const awt::Rectangle aBBox ( 153 mxPresenterHelper->getWindowExtentsRelative(rxWindow, mxParentWindow)); 154 mxParentWindowPeer->invalidateRect( 155 awt::Rectangle( 156 rRepaintBox.X + aBBox.X, 157 rRepaintBox.Y + aBBox.Y, 158 rRepaintBox.Width, 159 rRepaintBox.Height), 160 nInvalidateFlags); 161 } 162 } 163 else 164 { 165 Reference<awt::XWindowPeer> xPeer (rxWindow, UNO_QUERY); 166 if (xPeer.is()) 167 xPeer->invalidateRect(rRepaintBox, nInvalidateFlags); 168 } 169 } 170 171 } } 172