From 4797c34002c513f5adc65f2fefe843df606a0233 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Tue, 26 Jan 2010 11:23:25 +0100 Subject: vcl109: #i108454# do not depend on onsolete PICT format as image clipboard content --- vcl/aqua/source/dtrans/PictToBmpFlt.cxx | 91 ++++++++++++++++++++++++++++++++- 1 file changed, 89 insertions(+), 2 deletions(-) (limited to 'vcl/aqua/source/dtrans/PictToBmpFlt.cxx') diff --git a/vcl/aqua/source/dtrans/PictToBmpFlt.cxx b/vcl/aqua/source/dtrans/PictToBmpFlt.cxx index 0643efae33ca..15f99cbef8eb 100644 --- a/vcl/aqua/source/dtrans/PictToBmpFlt.cxx +++ b/vcl/aqua/source/dtrans/PictToBmpFlt.cxx @@ -1,22 +1,52 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: OSXTransferable.hxx,v $ + * $Revision: 1.4 $ + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + #include "PictToBmpFlt.hxx" /* This is a work-around to prevent 'deprecated' warning for 'KillPicture' API Hopefully we can get rid of this whole code again when the OOo PICT filter are good enough to be used see #i78953 thus this hack would vanish to again. */ +#include #include #undef DEPRECATED_ATTRIBUTE #define DEPRECATED_ATTRIBUTE -#include #include #include #include - bool PICTtoBMP(com::sun::star::uno::Sequence& aPict, com::sun::star::uno::Sequence& aBmp) { + bool result = false; ComponentInstance bmpExporter; @@ -112,3 +142,60 @@ bool BMPtoPICT(com::sun::star::uno::Sequence& aBmp, return result; } + +bool ImageToBMP( com::sun::star::uno::Sequence& aPict, + com::sun::star::uno::Sequence& aBmp, + NSBitmapImageFileType eInFormat) +{ + if( eInFormat == PICTImageFileType ) + return PICTtoBMP( aPict, aBmp ); + + bool bResult = false; + + NSData* pData = [NSData dataWithBytesNoCopy: (void*)aPict.getConstArray() length: aPict.getLength() freeWhenDone: 0]; + if( pData ) + { + NSBitmapImageRep* pRep = [NSBitmapImageRep imageRepWithData: pData]; + if( pRep ) + { + NSData* pOut = [pRep representationUsingType: NSBMPFileType properties: nil]; + if( pOut ) + { + aBmp.realloc( [pOut length] ); + [pOut getBytes: aBmp.getArray() length: aBmp.getLength()]; + bResult = (aBmp.getLength() != 0); + } + } + } + + return bResult; +} + +bool BMPToImage( com::sun::star::uno::Sequence& aBmp, + com::sun::star::uno::Sequence& aPict, + NSBitmapImageFileType eOutFormat + ) +{ + if( eOutFormat == PICTImageFileType ) + return BMPtoPICT( aBmp, aPict ); + + bool bResult = false; + + NSData* pData = [NSData dataWithBytesNoCopy: const_cast(aBmp.getConstArray()) length: aBmp.getLength() freeWhenDone: 0]; + if( pData ) + { + NSBitmapImageRep* pRep = [NSBitmapImageRep imageRepWithData: pData]; + if( pRep ) + { + NSData* pOut = [pRep representationUsingType: eOutFormat properties: nil]; + if( pOut ) + { + aPict.realloc( [pOut length] ); + [pOut getBytes: aPict.getArray() length: aPict.getLength()]; + bResult = (aPict.getLength() != 0); + } + } + } + + return bResult; +} -- cgit From b9bf85ffe5c1b22bb096cb63fc7059ebe590134e Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Fri, 19 Feb 2010 11:45:31 +0100 Subject: workaround deprecation warning for KillPicture --- vcl/aqua/source/dtrans/PictToBmpFlt.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'vcl/aqua/source/dtrans/PictToBmpFlt.cxx') diff --git a/vcl/aqua/source/dtrans/PictToBmpFlt.cxx b/vcl/aqua/source/dtrans/PictToBmpFlt.cxx index 15f99cbef8eb..1410fc2bd66d 100644 --- a/vcl/aqua/source/dtrans/PictToBmpFlt.cxx +++ b/vcl/aqua/source/dtrans/PictToBmpFlt.cxx @@ -28,8 +28,6 @@ * ************************************************************************/ -#include "PictToBmpFlt.hxx" - /* This is a work-around to prevent 'deprecated' warning for 'KillPicture' API Hopefully we can get rid of this whole code again when the OOo PICT filter are good enough to be used see #i78953 thus this hack would vanish to again. @@ -43,6 +41,8 @@ #include #include +#include "PictToBmpFlt.hxx" + bool PICTtoBMP(com::sun::star::uno::Sequence& aPict, com::sun::star::uno::Sequence& aBmp) { -- cgit