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 "PresenterPane.hxx" 28 #include "PresenterController.hxx" 29 #include "PresenterPaintManager.hxx" 30 #include <com/sun/star/awt/XWindowPeer.hpp> 31 #include <com/sun/star/lang/XMultiComponentFactory.hpp> 32 #include <com/sun/star/drawing/CanvasFeature.hpp> 33 #include <com/sun/star/rendering/CompositeOperation.hpp> 34 #include <osl/mutex.hxx> 35 36 using namespace ::com::sun::star; 37 using namespace ::com::sun::star::uno; 38 using namespace ::com::sun::star::drawing::framework; 39 using ::rtl::OUString; 40 41 namespace sdext { namespace presenter { 42 43 //===== PresenterPane ========================================================= 44 45 PresenterPane::PresenterPane ( 46 const Reference<XComponentContext>& rxContext, 47 const ::rtl::Reference<PresenterController>& rpPresenterController) 48 : PresenterPaneBase(rxContext, rpPresenterController), 49 maBoundingBox() 50 { 51 Reference<lang::XMultiComponentFactory> xFactory ( 52 mxComponentContext->getServiceManager(), UNO_QUERY_THROW); 53 mxPresenterHelper = Reference<drawing::XPresenterHelper>( 54 xFactory->createInstanceWithContext( 55 OUString::createFromAscii("com.sun.star.comp.Draw.PresenterHelper"), 56 mxComponentContext), 57 UNO_QUERY_THROW); 58 } 59 60 61 62 63 PresenterPane::~PresenterPane (void) 64 { 65 } 66 67 68 69 70 //----- XPane ----------------------------------------------------------------- 71 72 Reference<awt::XWindow> SAL_CALL PresenterPane::getWindow (void) 73 { 74 ThrowIfDisposed(); 75 return mxContentWindow; 76 } 77 78 79 80 81 Reference<rendering::XCanvas> SAL_CALL PresenterPane::getCanvas (void) 82 { 83 ThrowIfDisposed(); 84 return mxContentCanvas; 85 } 86 87 88 89 90 //----- XWindowListener ------------------------------------------------------- 91 92 void SAL_CALL PresenterPane::windowResized (const awt::WindowEvent& rEvent) 93 { 94 (void)rEvent; 95 PresenterPaneBase::windowResized(rEvent); 96 97 Invalidate(maBoundingBox); 98 99 LayoutContextWindow(); 100 ToTop(); 101 102 UpdateBoundingBox(); 103 Invalidate(maBoundingBox); 104 } 105 106 107 108 109 110 void SAL_CALL PresenterPane::windowMoved (const awt::WindowEvent& rEvent) 111 { 112 (void)rEvent; 113 PresenterPaneBase::windowMoved(rEvent); 114 115 Invalidate(maBoundingBox); 116 117 ToTop(); 118 119 UpdateBoundingBox(); 120 Invalidate(maBoundingBox); 121 } 122 123 124 125 126 void SAL_CALL PresenterPane::windowShown (const lang::EventObject& rEvent) 127 { 128 (void)rEvent; 129 PresenterPaneBase::windowShown(rEvent); 130 131 ToTop(); 132 133 if (mxContentWindow.is()) 134 { 135 LayoutContextWindow(); 136 mxContentWindow->setVisible(sal_True); 137 } 138 139 UpdateBoundingBox(); 140 Invalidate(maBoundingBox); 141 } 142 143 144 145 146 void SAL_CALL PresenterPane::windowHidden (const lang::EventObject& rEvent) 147 { 148 (void)rEvent; 149 PresenterPaneBase::windowHidden(rEvent); 150 151 if (mxContentWindow.is()) 152 mxContentWindow->setVisible(sal_False); 153 } 154 155 156 157 158 //----- XPaintListener -------------------------------------------------------- 159 160 void SAL_CALL PresenterPane::windowPaint (const awt::PaintEvent& rEvent) 161 { 162 (void)rEvent; 163 ThrowIfDisposed(); 164 165 PaintBorder(rEvent.UpdateRect); 166 } 167 168 169 170 171 //----------------------------------------------------------------------------- 172 173 174 void PresenterPane::CreateCanvases ( 175 const Reference<awt::XWindow>& rxParentWindow, 176 const Reference<rendering::XSpriteCanvas>& rxParentCanvas) 177 { 178 if ( ! mxPresenterHelper.is()) 179 return; 180 if ( ! rxParentWindow.is()) 181 return; 182 if ( ! rxParentCanvas.is()) 183 return; 184 185 mxBorderCanvas = mxPresenterHelper->createSharedCanvas( 186 rxParentCanvas, 187 rxParentWindow, 188 Reference<rendering::XCanvas>(rxParentCanvas, UNO_QUERY), 189 rxParentWindow, 190 mxBorderWindow); 191 mxContentCanvas = mxPresenterHelper->createSharedCanvas( 192 rxParentCanvas, 193 rxParentWindow, 194 Reference<rendering::XCanvas>(rxParentCanvas, UNO_QUERY), 195 rxParentWindow, 196 mxContentWindow); 197 198 PaintBorder(mxBorderWindow->getPosSize()); 199 } 200 201 202 203 204 void PresenterPane::Invalidate (const css::awt::Rectangle& rRepaintBox) 205 { 206 // Invalidate the parent window to be able to invalidate an area outside 207 // the current window area. 208 mpPresenterController->GetPaintManager()->Invalidate(mxParentWindow, rRepaintBox); 209 } 210 211 212 213 214 void PresenterPane::UpdateBoundingBox (void) 215 { 216 if (mxBorderWindow.is() && IsVisible()) 217 maBoundingBox = mxBorderWindow->getPosSize(); 218 else 219 maBoundingBox = awt::Rectangle(); 220 } 221 222 223 } } // end of namespace ::sd::presenter 224