1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_canvas.hxx" 30 31 #include <canvas/debug.hxx> 32 #include <canvas/verbosetrace.hxx> 33 #include <canvas/canvastools.hxx> 34 35 #include <osl/mutex.hxx> 36 #include <rtl/instance.hxx> 37 #include <cppuhelper/compbase1.hxx> 38 39 #include <com/sun/star/lang/NoSupportException.hpp> 40 41 #include <basegfx/tools/canvastools.hxx> 42 #include <basegfx/tools/unopolypolygon.hxx> 43 #include <vcl/canvastools.hxx> 44 45 #include "null_spritecanvas.hxx" 46 #include "null_canvasbitmap.hxx" 47 #include "null_devicehelper.hxx" 48 49 50 using namespace ::com::sun::star; 51 52 namespace nullcanvas 53 { 54 DeviceHelper::DeviceHelper() : 55 mpSpriteCanvas( NULL ), 56 maSize(), 57 mbFullScreen(false) 58 { 59 } 60 61 void DeviceHelper::init( SpriteCanvas& rSpriteCanvas, 62 const ::basegfx::B2ISize& rSize, 63 bool bFullscreen ) 64 { 65 mpSpriteCanvas = &rSpriteCanvas; 66 maSize = rSize; 67 mbFullScreen = bFullscreen; 68 } 69 70 void DeviceHelper::disposing() 71 { 72 // release all references 73 mpSpriteCanvas = NULL; 74 } 75 76 geometry::RealSize2D DeviceHelper::getPhysicalResolution() 77 { 78 return geometry::RealSize2D( 75, 75 ); 79 } 80 81 geometry::RealSize2D DeviceHelper::getPhysicalSize() 82 { 83 return geometry::RealSize2D( 210, 280 ); 84 } 85 86 uno::Reference< rendering::XLinePolyPolygon2D > DeviceHelper::createCompatibleLinePolyPolygon( 87 const uno::Reference< rendering::XGraphicDevice >& /*rDevice*/, 88 const uno::Sequence< uno::Sequence< geometry::RealPoint2D > >& points ) 89 { 90 // disposed? 91 if( !mpSpriteCanvas ) 92 return uno::Reference< rendering::XLinePolyPolygon2D >(); // we're disposed 93 94 return uno::Reference< rendering::XLinePolyPolygon2D >( 95 new ::basegfx::unotools::UnoPolyPolygon( 96 ::basegfx::unotools::polyPolygonFromPoint2DSequenceSequence( points ))); 97 } 98 99 uno::Reference< rendering::XBezierPolyPolygon2D > DeviceHelper::createCompatibleBezierPolyPolygon( 100 const uno::Reference< rendering::XGraphicDevice >& /*rDevice*/, 101 const uno::Sequence< uno::Sequence< geometry::RealBezierSegment2D > >& points ) 102 { 103 // disposed? 104 if( !mpSpriteCanvas ) 105 return uno::Reference< rendering::XBezierPolyPolygon2D >(); // we're disposed 106 107 return uno::Reference< rendering::XBezierPolyPolygon2D >( 108 new ::basegfx::unotools::UnoPolyPolygon( 109 ::basegfx::unotools::polyPolygonFromBezier2DSequenceSequence( points ) ) ); 110 } 111 112 uno::Reference< rendering::XBitmap > DeviceHelper::createCompatibleBitmap( 113 const uno::Reference< rendering::XGraphicDevice >& /*rDevice*/, 114 const geometry::IntegerSize2D& size ) 115 { 116 // disposed? 117 if( !mpSpriteCanvas ) 118 return uno::Reference< rendering::XBitmap >(); // we're disposed 119 120 return uno::Reference< rendering::XBitmap >( 121 new CanvasBitmap( 122 ::basegfx::unotools::b2ISizeFromIntegerSize2D( size ), 123 mpSpriteCanvas, 124 false )); 125 } 126 127 uno::Reference< rendering::XVolatileBitmap > DeviceHelper::createVolatileBitmap( 128 const uno::Reference< rendering::XGraphicDevice >& /*rDevice*/, 129 const geometry::IntegerSize2D& /*size*/ ) 130 { 131 return uno::Reference< rendering::XVolatileBitmap >(); 132 } 133 134 uno::Reference< rendering::XBitmap > DeviceHelper::createCompatibleAlphaBitmap( 135 const uno::Reference< rendering::XGraphicDevice >& /*rDevice*/, 136 const geometry::IntegerSize2D& size ) 137 { 138 // disposed? 139 if( !mpSpriteCanvas ) 140 return uno::Reference< rendering::XBitmap >(); // we're disposed 141 142 return uno::Reference< rendering::XBitmap >( 143 new CanvasBitmap( 144 ::basegfx::unotools::b2ISizeFromIntegerSize2D( size ), 145 mpSpriteCanvas, 146 true )); 147 } 148 149 uno::Reference< rendering::XVolatileBitmap > DeviceHelper::createVolatileAlphaBitmap( 150 const uno::Reference< rendering::XGraphicDevice >& /*rDevice*/, 151 const geometry::IntegerSize2D& /*size*/ ) 152 { 153 return uno::Reference< rendering::XVolatileBitmap >(); 154 } 155 156 sal_Bool DeviceHelper::hasFullScreenMode() 157 { 158 // TODO(F3): offer fullscreen mode the XCanvas way 159 return false; 160 } 161 162 sal_Bool DeviceHelper::enterFullScreenMode( sal_Bool /*bEnter*/ ) 163 { 164 // TODO(F3): offer fullscreen mode the XCanvas way 165 return false; 166 } 167 168 ::sal_Int32 DeviceHelper::createBuffers( ::sal_Int32 /*nBuffers*/ ) 169 { 170 // TODO(F3): implement XBufferStrategy interface. For now, we 171 // _always_ will have exactly one backbuffer 172 return 1; 173 } 174 175 void DeviceHelper::destroyBuffers() 176 { 177 // TODO(F3): implement XBufferStrategy interface. For now, we 178 // _always_ will have exactly one backbuffer 179 } 180 181 ::sal_Bool DeviceHelper::showBuffer( bool bIsVisible, ::sal_Bool bUpdateAll ) 182 { 183 // forward to sprite canvas helper 184 if( !bIsVisible || !mpSpriteCanvas ) 185 return false; 186 187 return mpSpriteCanvas->updateScreen( bUpdateAll ); 188 } 189 190 ::sal_Bool DeviceHelper::switchBuffer( bool bIsVisible, ::sal_Bool bUpdateAll ) 191 { 192 // no difference for VCL canvas 193 return showBuffer( bIsVisible, bUpdateAll ); 194 } 195 196 uno::Any DeviceHelper::isAccelerated() const 197 { 198 return ::com::sun::star::uno::makeAny(false); 199 } 200 201 uno::Any DeviceHelper::getDeviceHandle() const 202 { 203 return uno::Any(); 204 } 205 206 uno::Any DeviceHelper::getSurfaceHandle() const 207 { 208 return uno::Any(); 209 } 210 211 namespace 212 { 213 struct DeviceColorSpace: public rtl::StaticWithInit<uno::Reference<rendering::XColorSpace>, 214 DeviceColorSpace> 215 { 216 uno::Reference<rendering::XColorSpace> operator()() 217 { 218 return vcl::unotools::createStandardColorSpace(); 219 } 220 }; 221 } 222 223 uno::Reference<rendering::XColorSpace> DeviceHelper::getColorSpace() const 224 { 225 // always the same 226 return DeviceColorSpace::get(); 227 } 228 229 void DeviceHelper::notifySizeUpdate( const awt::Rectangle& /*rBounds*/ ) 230 { 231 // TODO 232 } 233 234 void DeviceHelper::dumpScreenContent() const 235 { 236 OSL_TRACE( "%s\n", 237 BOOST_CURRENT_FUNCTION ); 238 } 239 } 240