diff options
author | Michael Meeks <michael.meeks@suse.com> | 2012-11-06 12:12:33 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2012-11-12 11:46:43 +0000 |
commit | 2b4fd2c89a38ccac13c72f2e94501a8702e7da4b (patch) | |
tree | 8d1da4778021a1e753ca4d01d7cc8ff2e21b0d5d /vcl/source/gdi | |
parent | 08894f7c7def58431be699c3e59ef7bbc0c725a4 (diff) |
re-base on ALv2 code. Includes:
Patches contributed by Pedro Giffuni:
Avoid some uses of non portable #!/bin/bash in shell scripts.
http://svn.apache.org/viewvc?view=revision&revision=1235297
Reduce the dependencies on non standard GNU copy.
http://svn.apache.org/viewvc?view=revision&revision=1238684
Correct /usr/bin/env path.
http://svn.apache.org/viewvc?view=revision&revision=1235619
Complex Toolbar Controls Extension from the SDK
Patches contributed by Ariel Constenla-Haile
http://svn.apache.org/viewvc?view=revision&revision=1190390
i118615 - make epm more verbose
http://svn.apache.org/viewvc?view=revision&revision=1204288
Patches contributed by Mathias Bauer (and others)
gnumake4 work variously
http://svn.apache.org/viewvc?view=revision&revision=1394707
http://svn.apache.org/viewvc?view=revision&revision=1394326
Patches contributed by Juergen Schmidt:
jsc341: i117327: take care if no dependency node in current
description exists, create one
http://svn.apache.org/viewvc?view=revision&revision=1172101
jsc341: i117327: add extra extension dependency check
http://svn.apache.org/viewvc?view=revision&revision=1172098
make initial branding changes
http://svn.apache.org/viewvc?view=revision&revision=1231878
Patches contributed by Ingo Schmidt
native373: #i117733# no linux jre installation on 64 bit systems
http://svn.apache.org/viewvc?view=revision&revision=1167536
native373: ##164464# improve debian support
http://svn.apache.org/viewvc?view=revision&revision=1167537
Patch contribtued by Armin Le-Grand:
Changed various aspects concerning usages of old vendor names
http://svn.apache.org/viewvc?view=revision&revision=1293313
fix for neon webdav, remove coinmp bits, improve odk script,
cleanup & remove OS/2 conditionals, system ucpp fixes,
remove OS/2 conditionals, restore our license filenames.
Diffstat (limited to 'vcl/source/gdi')
-rw-r--r-- | vcl/source/gdi/bitmap3.cxx | 37 | ||||
-rw-r--r-- | vcl/source/gdi/pdfextoutdevdata.cxx | 37 | ||||
-rw-r--r-- | vcl/source/gdi/rendergraphic.cxx | 231 | ||||
-rw-r--r-- | vcl/source/gdi/rendergraphicrasterizer.cxx | 405 | ||||
-rw-r--r-- | vcl/source/gdi/svgread.cxx | 143 |
5 files changed, 28 insertions, 825 deletions
diff --git a/vcl/source/gdi/bitmap3.cxx b/vcl/source/gdi/bitmap3.cxx index 13b6d13ff55c..0031fa03099f 100644 --- a/vcl/source/gdi/bitmap3.cxx +++ b/vcl/source/gdi/bitmap3.cxx @@ -1,30 +1,21 @@ /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* +/* + * This file is part of the LibreOffice project. * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. * - * Copyright 2000, 2010 Oracle and/or its affiliates. + * This file incorporates work covered by the following license notice: * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ #include <stdlib.h> diff --git a/vcl/source/gdi/pdfextoutdevdata.cxx b/vcl/source/gdi/pdfextoutdevdata.cxx index b917a0ad04fe..8461b579f13f 100644 --- a/vcl/source/gdi/pdfextoutdevdata.cxx +++ b/vcl/source/gdi/pdfextoutdevdata.cxx @@ -1,30 +1,21 @@ /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* +/* + * This file is part of the LibreOffice project. * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. * - * Copyright 2000, 2010 Oracle and/or its affiliates. + * This file incorporates work covered by the following license notice: * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ #include "vcl/pdfextoutdevdata.hxx" #include "vcl/graph.hxx" diff --git a/vcl/source/gdi/rendergraphic.cxx b/vcl/source/gdi/rendergraphic.cxx deleted file mode 100644 index e11993fc52f3..000000000000 --- a/vcl/source/gdi/rendergraphic.cxx +++ /dev/null @@ -1,231 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <vcl/rendergraphic.hxx> -#include <vcl/rendergraphicrasterizer.hxx> -#include <vcl/mapmod.hxx> -#include <tools/stream.hxx> -#include <tools/vcompat.hxx> - -#include <cstring> -#include <cstdio> - -namespace vcl -{ - -// ----------------- -// - RenderGraphic - -// ----------------- -RenderGraphic::RenderGraphic( ) : - mnGraphicDataLength( 0 ) -{ -} - -// ------------------------------------------------------------------------- - -RenderGraphic::RenderGraphic( const RenderGraphic& rRenderGraphic ) : - maGraphicData( rRenderGraphic.maGraphicData ), - mnGraphicDataLength( rRenderGraphic.mnGraphicDataLength ), - maGraphicDataMimeType( rRenderGraphic.maGraphicDataMimeType ), - mapPrefMapMode( rRenderGraphic.mapPrefMapMode.get() ? new MapMode( *rRenderGraphic.mapPrefMapMode ) : NULL ), - mapPrefSize( rRenderGraphic.mapPrefSize.get() ? new Size( *rRenderGraphic.mapPrefSize ) : NULL ) -{ -} - -// ------------------------------------------------------------------------- - -RenderGraphic::RenderGraphic( const rtl::OUString& rGraphicDataMimeType, - sal_uInt32 nGraphicDataLength, - const sal_uInt8* pGraphicData ) : - maGraphicData(), - mnGraphicDataLength( nGraphicDataLength ), - maGraphicDataMimeType( rGraphicDataMimeType ) -{ - if( !rGraphicDataMimeType.isEmpty( ) && nGraphicDataLength ) - { - maGraphicData.reset( new sal_uInt8[ nGraphicDataLength ] ); - - if( pGraphicData ) - { - memcpy( maGraphicData.get(), pGraphicData, nGraphicDataLength ); - } - } - else - { - ImplCheckData( ); - } -} - -// ------------------------------------------------------------------------- - -RenderGraphic::~RenderGraphic( ) -{ -} - -// ------------------------------------------------------------------------- - -RenderGraphic& RenderGraphic::operator=(const RenderGraphic& rRenderGraphic ) -{ - maGraphicData = rRenderGraphic.maGraphicData; - mnGraphicDataLength = rRenderGraphic.mnGraphicDataLength; - maGraphicDataMimeType = rRenderGraphic.maGraphicDataMimeType; - mapPrefMapMode.reset( rRenderGraphic.mapPrefMapMode.get() ? new MapMode( *rRenderGraphic.mapPrefMapMode ) : NULL ); - mapPrefSize.reset( rRenderGraphic.mapPrefSize.get() ? new Size( *rRenderGraphic.mapPrefSize ) : NULL ); - - return( *this ); -} - -// ------------------------------------------------------------------------- - -bool RenderGraphic::operator==(const RenderGraphic& rRenderGraphic ) const -{ - return( ( rRenderGraphic.mnGraphicDataLength == mnGraphicDataLength ) && - ( rRenderGraphic.maGraphicData == maGraphicData ) && - ( rRenderGraphic.maGraphicDataMimeType.equalsIgnoreAsciiCase( maGraphicDataMimeType ) ) ); -} - -// ------------------------------------------------------------------------- - -bool RenderGraphic::operator!() const -{ - return( ( maGraphicDataMimeType.isEmpty( ) ) || - ( 0 == mnGraphicDataLength ) || - !maGraphicData.get( ) ); -} - -// ------------------------------------------------------------------------- - -bool RenderGraphic::IsEqual( const RenderGraphic& rRenderGraphic ) const -{ - bool bRet = ( rRenderGraphic.mnGraphicDataLength == mnGraphicDataLength ) && - ( rRenderGraphic.maGraphicDataMimeType.equalsIgnoreAsciiCase( maGraphicDataMimeType ) ); - - if( bRet && mnGraphicDataLength && ( rRenderGraphic.maGraphicData != maGraphicData ) ) - { - bRet = ( 0 == memcmp( rRenderGraphic.maGraphicData.get( ), - maGraphicData.get( ), - mnGraphicDataLength ) ); - } - - return( bRet ); -} - -// ------------------------------------------------------------------------- - -const MapMode& RenderGraphic::GetPrefMapMode() const -{ - ImplGetDefaults(); - return( *mapPrefMapMode ); -} - -// ------------------------------------------------------------------------- - -const Size& RenderGraphic::GetPrefSize() const -{ - ImplGetDefaults(); - return( *mapPrefSize ); -} - -// ------------------------------------------------------------------------- - -BitmapEx RenderGraphic::GetReplacement() const -{ - const RenderGraphicRasterizer aRasterizer( *this ); - - return( aRasterizer.GetReplacement() ); -} - -// ------------------------------------------------------------------------- - -void RenderGraphic::ImplCheckData( ) -{ - if( !( *this ) ) - { - maGraphicData.reset( ); - mnGraphicDataLength = 0; - maGraphicDataMimeType = ::rtl::OUString(); - mapPrefMapMode.reset(); - mapPrefSize.reset(); - } -} - -// ------------------------------------------------------------------------- - -void RenderGraphic::ImplGetDefaults() const -{ - if( !mapPrefMapMode.get() || !mapPrefSize.get() ) - { - const RenderGraphicRasterizer aRasterizer( *this ); - - mapPrefMapMode.reset( new MapMode( aRasterizer.GetPrefMapMode() ) ); - mapPrefSize.reset( new Size( aRasterizer.GetPrefSize() ) ); - } -} - -// ------------------------------------------------------------------------- - -::SvStream& operator>>( ::SvStream& rIStm, RenderGraphic& rRenderGraphic ) -{ - ::VersionCompat aVCompat( rIStm, STREAM_READ ); - sal_uInt32 nGraphicDataLength = 0; - - rtl::OUString aGraphicDataMimeType = read_lenPrefixed_uInt8s_ToOUString<sal_uInt16>(rIStm, RTL_TEXTENCODING_ASCII_US); - rIStm >> nGraphicDataLength; - - rRenderGraphic = RenderGraphic( aGraphicDataMimeType, nGraphicDataLength ); - - if( !rRenderGraphic.IsEmpty() ) - { - rIStm.Read( rRenderGraphic.GetGraphicData().get(), nGraphicDataLength ); - } - - return rIStm; -} - -// ------------------------------------------------------------------ - -::SvStream& operator<<( ::SvStream& rOStm, const RenderGraphic& rRenderGraphic ) -{ - ::VersionCompat aVCompat( rOStm, STREAM_WRITE, 1 ); - const sal_uInt32 nGraphicDataLength = rRenderGraphic.GetGraphicDataLength(); - - write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(rOStm, rRenderGraphic.GetGraphicDataMimeType(), - RTL_TEXTENCODING_ASCII_US); - rOStm << nGraphicDataLength; - - if( nGraphicDataLength ) - { - rOStm.Write( rRenderGraphic.GetGraphicData().get(), nGraphicDataLength ); - } - - return rOStm; -} - -} // VCL - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/gdi/rendergraphicrasterizer.cxx b/vcl/source/gdi/rendergraphicrasterizer.cxx deleted file mode 100644 index a3b06ec864ae..000000000000 --- a/vcl/source/gdi/rendergraphicrasterizer.cxx +++ /dev/null @@ -1,405 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <vcl/rendergraphicrasterizer.hxx> -#include <vcl/svapp.hxx> -#include <vcl/wrkwin.hxx> -#include <vcl/virdev.hxx> -#include <vcl/unohelp.hxx> -#include <vcl/bmpacc.hxx> -#include <vcl/graph.hxx> -#include <tools/stream.hxx> -#include <comphelper/processfactory.hxx> -#include <unotools/streamwrap.hxx> - -#include <com/sun/star/lang/XMultiServiceFactory.hpp> - -#include <boost/scoped_ptr.hpp> - -#define VCL_SERVICENAME_RASTERIZER_SVG "com.sun.star.graphic.GraphicRasterizer_RSVG" - -using namespace com::sun::star; - -namespace vcl -{ -// --------------------------------------------------------- -// - maximum extent in pixel for graphics to be rasterized - -// --------------------------------------------------------- - -static const sal_uInt32 nRasterizerDefaultExtent = 4096; - -// --------------------------- -// - RenderGraphicRasterizer - -// --------------------------- - -RenderGraphicRasterizer::RenderGraphicRasterizer( const RenderGraphic& rRenderGraphic ) : - maRenderGraphic( rRenderGraphic ), - mfRotateAngle( 0.0 ), - mfShearAngleX( 0.0 ), - mfShearAngleY( 0.0 ) -{ -} - -// ------------------------------------------------------------------------- - -RenderGraphicRasterizer::RenderGraphicRasterizer( const RenderGraphicRasterizer& rRenderGraphicRasterizer ) : - maRenderGraphic( rRenderGraphicRasterizer.maRenderGraphic ), - mxRasterizer( rRenderGraphicRasterizer.mxRasterizer ), - maBitmapEx( rRenderGraphicRasterizer.maBitmapEx ), - maDefaultSizePixel( rRenderGraphicRasterizer.maDefaultSizePixel ), - mfRotateAngle( rRenderGraphicRasterizer.mfRotateAngle ), - mfShearAngleX( rRenderGraphicRasterizer.mfShearAngleX ), - mfShearAngleY( rRenderGraphicRasterizer.mfShearAngleY ) -{ -} - -// ------------------------------------------------------------------------- - -RenderGraphicRasterizer::~RenderGraphicRasterizer() -{ -} - -// ------------------------------------------------------------------------- - -RenderGraphicRasterizer& RenderGraphicRasterizer::operator=( - const RenderGraphicRasterizer& rRenderGraphicRasterizer ) -{ - maRenderGraphic = rRenderGraphicRasterizer.maRenderGraphic; - maBitmapEx = rRenderGraphicRasterizer.maBitmapEx; - maDefaultSizePixel = rRenderGraphicRasterizer.maDefaultSizePixel; - mfRotateAngle = rRenderGraphicRasterizer.mfRotateAngle; - mfShearAngleX = rRenderGraphicRasterizer.mfShearAngleX; - mfShearAngleY = rRenderGraphicRasterizer.mfShearAngleY; - mxRasterizer = rRenderGraphicRasterizer.mxRasterizer; - - return( *this ); -} - -// ------------------------------------------------------------------------- - -const Size& RenderGraphicRasterizer::GetDefaultSizePixel() const -{ - const_cast< RenderGraphicRasterizer* >( this )->InitializeRasterizer(); - - return( maDefaultSizePixel ); -} - -// ------------------------------------------------------------------------- - -BitmapEx RenderGraphicRasterizer::GetReplacement() const -{ - BitmapEx aRet( Rasterize( GetDefaultSizePixel() ) ); - - aRet.SetPrefSize( GetPrefSize() ); - aRet.SetPrefMapMode( GetPrefMapMode() ); - - return( aRet ); -} - -// ------------------------------------------------------------------------- - -Size RenderGraphicRasterizer::GetPrefSize() const -{ - const Size aSizePixel( GetDefaultSizePixel() ); - boost::scoped_ptr< VirtualDevice > xCompVDev; - OutputDevice* pCompDev = NULL; - -#ifndef NO_GETAPPWINDOW - pCompDev = Application::GetAppWindow(); -#endif - - if( !pCompDev ) - { - xCompVDev.reset( new VirtualDevice ); - pCompDev = xCompVDev.get(); - } - - return( pCompDev->PixelToLogic( aSizePixel, GetPrefMapMode() ) ); -} - -// ------------------------------------------------------------------------- - -MapMode RenderGraphicRasterizer::GetPrefMapMode() const -{ - return( MapMode( MAP_100TH_MM ) ); -} - -// ------------------------------------------------------------------------- - -const BitmapEx& RenderGraphicRasterizer::Rasterize( const Size& rSizePixel, - double fRotateAngle, - double fShearAngleX, - double fShearAngleY, - sal_uInt32 nMaxExtent ) const -{ - const bool bRasterize = !maRenderGraphic.IsEmpty() && - rSizePixel.Width() && rSizePixel.Height() && - ( maBitmapEx.IsEmpty() || - ( rSizePixel != maBitmapEx.GetSizePixel() ) || - ( fRotateAngle != mfRotateAngle ) || - ( fShearAngleX != mfShearAngleX ) || - ( fShearAngleY != mfShearAngleY ) ); - - if( bRasterize ) - { - const_cast< RenderGraphicRasterizer* >( this )->InitializeRasterizer(); - - if( mxRasterizer.is() ) - { - sal_uInt32 nWidth = labs( rSizePixel.Width() ); - sal_uInt32 nHeight = labs( rSizePixel.Height() ); - - // limiting the extent of the rastered bitmap - if( VCL_RASTERIZER_UNLIMITED_EXTENT != nMaxExtent ) - { - if( VCL_RASTERIZER_DEFAULT_EXTENT == nMaxExtent ) - { - nMaxExtent = nRasterizerDefaultExtent; - } - - if( ( nWidth > nMaxExtent ) || ( nHeight > nMaxExtent ) ) - { - const double fScale = static_cast< double >( nMaxExtent ) / ::std::max( nWidth, nHeight ); - - nWidth = FRound( nWidth * fScale ); - nHeight = FRound( nHeight * fScale ); - } - } - - if( !ImplRasterizeFromCache( const_cast< RenderGraphicRasterizer& >( *this ), - Size( nWidth, nHeight ), fRotateAngle, fShearAngleX, fShearAngleY ) ) - { - try - { - const uno::Sequence< beans::PropertyValue > aPropertySeq; - const Graphic aRasteredGraphic( mxRasterizer->rasterize( nWidth, - nHeight, - fRotateAngle, - fShearAngleX, - fShearAngleY, - aPropertySeq ) ); - - maBitmapEx = aRasteredGraphic.GetBitmapEx(); - mfRotateAngle = fRotateAngle; - mfShearAngleX = fShearAngleX; - mfShearAngleY = fShearAngleY; - - ImplUpdateCache( *this ); - -// OSL_TRACE( "Wanted: %d x %d / Got: %d x %d", rSizePixel.Width(), rSizePixel.Height(), maBitmapEx.GetSizePixel().Width(), maBitmapEx.GetSizePixel().Height() ); - } - catch( ... ) - { - OSL_TRACE( "caught exception during rasterization" ); - } - } - } - } - - return( maBitmapEx ); -} - -// ------------------------------------------------------------------------- - -void RenderGraphicRasterizer::InitializeRasterizer() -{ - if( !mxRasterizer.is() && !ImplInitializeFromCache( *this ) ) - { - uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); - - maDefaultSizePixel.Width() = maDefaultSizePixel.Height() = 0; - - if ( !maRenderGraphic.IsEmpty() ) - { - rtl::OUString aServiceName; - - if( maRenderGraphic.GetGraphicDataMimeType() == "image/svg+xml" ) - { - aServiceName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VCL_SERVICENAME_RASTERIZER_SVG ) ); - } - - if( !aServiceName.isEmpty() ) - { - mxRasterizer.set( xFactory->createInstance( aServiceName ), uno::UNO_QUERY ); - - if( mxRasterizer.is() ) - { - boost::scoped_ptr< VirtualDevice > xCompVDev; - OutputDevice* pCompDev = NULL; - -#ifndef NO_GETAPPWINDOW - pCompDev = Application::GetAppWindow(); -#endif - - if( !pCompDev ) - { - xCompVDev.reset( new VirtualDevice ); - pCompDev = xCompVDev.get(); - } - - const Size aDPI( pCompDev->LogicToPixel( Size( 1, 1 ), MAP_INCH ) ); - awt::Size aSizePixel; - SvMemoryStream aMemStm( maRenderGraphic.GetGraphicData().get(), - maRenderGraphic.GetGraphicDataLength(), - STREAM_READ ); - - uno::Reference< io::XInputStream > xIStm( new utl::OSeekableInputStreamWrapper( aMemStm ) ); - - try - { - if( !xIStm.is() || !mxRasterizer->initializeData( xIStm, aDPI.Width(), aDPI.Height(), aSizePixel ) ) - { - mxRasterizer.clear(); - } - else - { - maDefaultSizePixel.Width() = aSizePixel.Width; - maDefaultSizePixel.Height() = aSizePixel.Height; - } - } - catch( ... ) - { - OSL_TRACE( "caught exception during initialization of SVG rasterizer component" ); - mxRasterizer.clear(); - } - } - } - } - } -} - -// ------------------------------------------------------------------------------ - -RenderGraphicRasterizer::RenderGraphicRasterizerCache& RenderGraphicRasterizer::ImplGetCache() -{ - static RenderGraphicRasterizerCache* pCache = NULL; - - if( !pCache ) - { - pCache = new RenderGraphicRasterizerCache; - } - - return( *pCache ); -} - -// ------------------------------------------------------------------------------ - -bool RenderGraphicRasterizer::ImplInitializeFromCache( RenderGraphicRasterizer& rRasterizer ) -{ - RenderGraphicRasterizerCache& rCache = ImplGetCache(); - bool bRet = false; - - for( sal_uInt32 i = 0; i < rCache.size(); ++i ) - { - const RenderGraphicRasterizer* pCheck = &rCache[ i ]; - - if( pCheck && pCheck->mxRasterizer.is() && ( pCheck->maRenderGraphic == rRasterizer.maRenderGraphic ) ) - { -// OSL_TRACE( "Hit RenderGraphicRasterizer cache for initialization" ); - - rRasterizer.mxRasterizer = pCheck->mxRasterizer; - rRasterizer.maDefaultSizePixel = pCheck->maDefaultSizePixel; - - // put found Rasterizer at begin of deque - const RenderGraphicRasterizer aFound( rCache[ i ] ); - - rCache.erase( rCache.begin() + i ); - rCache.push_front( aFound ); - - - bRet = true; - } - } - - return( bRet ); -} - -// ------------------------------------------------------------------------------ - -bool RenderGraphicRasterizer::ImplRasterizeFromCache( RenderGraphicRasterizer& rRasterizer, - const Size& rSizePixel, - double fRotateAngle, - double fShearAngleX, - double fShearAngleY ) -{ - RenderGraphicRasterizerCache& rCache = ImplGetCache(); - bool bRet = false; - - for( sal_uInt32 i = 0; i < rCache.size(); ++i ) - { - const RenderGraphicRasterizer& rCheck = rCache[ i ]; - - if( rCheck.mxRasterizer.is() && rRasterizer.mxRasterizer.is() && - ( ( rCheck.mxRasterizer == rRasterizer.mxRasterizer ) || - ( rRasterizer.maRenderGraphic == rCheck.maRenderGraphic ) ) && - ( rCheck.maBitmapEx.GetSizePixel() == rSizePixel ) && - ( rCheck.mfRotateAngle == fRotateAngle ) && - ( rCheck.mfShearAngleX == fShearAngleX ) && - ( rCheck.mfShearAngleY == fShearAngleY ) ) - { -// OSL_TRACE( "Hit RenderGraphicRasterizer cache for rasterizing" ); - - rRasterizer.maBitmapEx = rCheck.maBitmapEx; - rRasterizer.mfRotateAngle = fRotateAngle; - rRasterizer.mfShearAngleX = fShearAngleX; - rRasterizer.mfShearAngleY = fShearAngleY; - - // put found Rasterizer at begin of deque - const RenderGraphicRasterizer aFound( rCache[ i ] ); - - rCache.erase( rCache.begin() + i ); - rCache.push_front( aFound ); - - bRet = true; - } - } - - return( bRet ); -} - -// ------------------------------------------------------------------------------ - -void RenderGraphicRasterizer::ImplUpdateCache( const RenderGraphicRasterizer& rRasterizer ) -{ - RenderGraphicRasterizerCache& rCache = ImplGetCache(); - const sal_uInt32 nMaxCacheSize = 8; - - if( rCache.size() < nMaxCacheSize ) - { - rCache.push_front( rRasterizer ); - } - else - { - rCache.pop_back(); - rCache.push_front( rRasterizer ); - } -} - -} // VCL - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/gdi/svgread.cxx b/vcl/source/gdi/svgread.cxx deleted file mode 100644 index a74cfd23d6fb..000000000000 --- a/vcl/source/gdi/svgread.cxx +++ /dev/null @@ -1,143 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <tools/stream.hxx> -#include <vcl/svgread.hxx> -#include <vcl/gdimtf.hxx> -#include <vcl/metaact.hxx> -#include <vcl/rendergraphicrasterizer.hxx> - -// ----------- -// - Defines - -// ----------- - -namespace vcl -{ - // ----------------- - // - SVGReaderImpl - - // ----------------- - - class SVGReaderImpl - { - public: - - SVGReaderImpl( SvStream& rStm ); - ~SVGReaderImpl(); - - GDIMetaFile& ImplRead( GDIMetaFile& rSVGMtf ); - vcl::RenderGraphic ImplGetRenderGraphic(); - - private: - - SvStream& mrStm; - }; - - // ------------------------------------------------------------------------------ - - SVGReaderImpl::SVGReaderImpl( SvStream& rStm ) : - mrStm( rStm ) - { - } - - // ------------------------------------------------------------------------ - - SVGReaderImpl::~SVGReaderImpl() - { - } - - // ------------------------------------------------------------------------ - - GDIMetaFile& SVGReaderImpl::ImplRead( GDIMetaFile& rSVGMtf ) - { - vcl::RenderGraphic aSVGGraphic = ImplGetRenderGraphic(); - - if( !mrStm.GetError() ) - { - const vcl::RenderGraphicRasterizer aRasterizer( aSVGGraphic ); - const Size aDefaultSizePixel( aRasterizer.GetDefaultSizePixel() ); - - if( aDefaultSizePixel.Width() && aDefaultSizePixel.Height() ) - { - const Point aPos; - const Size aPrefSize( aRasterizer.GetPrefSize() ); - - rSVGMtf.SetPrefMapMode( aRasterizer.GetPrefMapMode() ); - rSVGMtf.SetPrefSize( aPrefSize ); - rSVGMtf.AddAction( new MetaRenderGraphicAction( aPos, aPrefSize, aSVGGraphic ) ); - rSVGMtf.WindStart(); - } - } - - return( rSVGMtf ); - } - - vcl::RenderGraphic SVGReaderImpl::ImplGetRenderGraphic() - { - const sal_uInt32 nStmPos = mrStm.Tell(); - const sal_uInt32 nStmLen = mrStm.Seek( STREAM_SEEK_TO_END ) - nStmPos; - - vcl::RenderGraphic aSVGGraphic( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("image/svg+xml")), nStmLen ); - mrStm.Seek( nStmPos ); - mrStm.Read( aSVGGraphic.GetGraphicData().get(), nStmLen ); - - return( aSVGGraphic ); - } - - - // ------------- - // - SVGReader - - // ------------- - - SVGReader::SVGReader( SvStream& rIStm ) : - mapImpl( new ::vcl::SVGReaderImpl( rIStm ) ) - { - } - - // ------------------------------------------------------------------------ - - SVGReader::~SVGReader() - { - } - - // ------------------------------------------------------------------------ - - GDIMetaFile& SVGReader::Read( GDIMetaFile& rSVGMtf ) - { - rSVGMtf = GDIMetaFile(); - - return( mapImpl.get() ? mapImpl->ImplRead( rSVGMtf ) : rSVGMtf ); - } - - vcl::RenderGraphic SVGReader::GetRenderGraphic() - { - return( mapImpl->ImplGetRenderGraphic() ); - } - -} // namespace vcl - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |