summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorArmin Le Grand <alg@apache.org>2013-01-10 16:28:40 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-06-13 14:50:46 +0100
commite0cce521f1ad0cc384d30ce2f1077ea229fffe62 (patch)
treeae40b74bceb4b036d87b79e861f5eef76ec41102 /svtools
parent6ed3ef87d2472bad71b719e9ec927e72acfd2850 (diff)
Resolves: #i121504# Support for alpha channel in clipboard for all systems
(cherry picked from commit ef3931ff410117e1237b3bef7bc090e8b83b9519) Conflicts: automation/source/server/statemnt.cxx basic/source/runtime/methods.cxx canvas/source/vcl/devicehelper.cxx canvas/source/vcl/spritedevicehelper.cxx drawinglayer/source/processor2d/vclhelperbufferdevice.cxx drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx drawinglayer/source/tools/converters.cxx dtrans/source/win32/dtobj/FmtFilter.cxx editeng/source/items/bulitem.cxx extensions/source/scanner/sanedlg.cxx external/gcc3_specific/makefile.mk filter/source/graphicfilter/eos2met/eos2met.cxx filter/source/graphicfilter/ios2met/ios2met.cxx filter/source/msfilter/msdffimp.cxx fpicker/source/office/iodlg.cxx framework/source/fwe/classes/addonsoptions.cxx framework/source/fwe/helper/actiontriggerhelper.cxx sc/source/filter/excel/xiescher.cxx sc/source/ui/docshell/docsh.cxx sc/source/ui/inc/viewfunc.hxx sd/source/ui/app/sdxfer.cxx sd/source/ui/unoidl/unopage.cxx sd/source/ui/view/sdview3.cxx sfx2/source/appl/fileobj.cxx sfx2/source/appl/linkmgr2.cxx sfx2/source/dialog/filedlghelper.cxx sfx2/source/dialog/intro.cxx sfx2/source/doc/docinf.cxx sot/inc/sot/formats.hxx sot/source/base/formats.cxx svtools/bmpmaker/bmpcore.cxx svtools/bmpmaker/bmpsum.cxx svtools/inc/svtools/transfer.hxx svtools/source/filter/filter.cxx svtools/source/filter/wmf/emfwr.cxx svtools/source/filter/wmf/enhwmf.cxx svtools/source/filter/wmf/winwmf.cxx svtools/source/filter/wmf/wmfwr.cxx svtools/source/graphic/graphic.cxx svtools/source/graphic/provider.cxx svtools/source/misc/transfer.cxx svx/inc/svx/xoutbmp.hxx svx/source/sdr/overlay/overlaymanagerbuffered.cxx svx/source/xoutdev/_xoutbmp.cxx sw/source/core/view/viewsh.cxx sw/source/filter/ww1/w1filter.cxx sw/source/filter/ww8/ww8par.hxx sw/source/ui/dochdl/swdtflvr.cxx toolkit/source/awt/vclxbitmap.cxx toolkit/source/helper/vclunohelper.cxx vcl/Library_vcl.mk vcl/Package_inc.mk vcl/aqua/source/dtrans/DataFlavorMapping.cxx vcl/aqua/source/dtrans/OSXTransferable.cxx vcl/aqua/source/dtrans/PictToBmpFlt.cxx vcl/aqua/source/dtrans/PictToBmpFlt.hxx vcl/inc/vcl/alpha.hxx vcl/inc/vcl/bitmap.hxx vcl/inc/vcl/bitmapex.hxx vcl/inc/vcl/pngwrite.hxx vcl/inc/vcl/salbtype.hxx vcl/inc/vcl/wall.hxx vcl/source/gdi/animate.cxx vcl/source/gdi/bitmap2.cxx vcl/source/gdi/bitmapex.cxx vcl/source/gdi/bmpconv.cxx vcl/source/gdi/cvtsvm.cxx vcl/source/gdi/impgraph.cxx vcl/source/gdi/impimagetree.cxx vcl/source/gdi/metaact.cxx vcl/source/gdi/wall.cxx Change-Id: I79938bc412c048c3d4e64f430f216e73bec16167
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/graphic/graphic.cxx7
-rw-r--r--svtools/source/graphic/provider.cxx8
-rw-r--r--svtools/source/misc/transfer.cxx165
3 files changed, 140 insertions, 40 deletions
diff --git a/svtools/source/graphic/graphic.cxx b/svtools/source/graphic/graphic.cxx
index a3c17517fb11..bec4e4f1724b 100644
--- a/svtools/source/graphic/graphic.cxx
+++ b/svtools/source/graphic/graphic.cxx
@@ -21,6 +21,7 @@
#include <vcl/svapp.hxx>
#include <com/sun/star/graphic/GraphicType.hpp>
#include <com/sun/star/graphic/XGraphicTransformer.hpp>
+#include <vcl/dibtools.hxx>
#include <vcl/graph.hxx>
#include "graphic.hxx"
#include <comphelper/servicehelper.hxx>
@@ -239,7 +240,8 @@ uno::Sequence< ::sal_Int8 > SAL_CALL Graphic::getDIB( ) throw (uno::RuntimeExce
if( mpGraphic && ( mpGraphic->GetType() != GRAPHIC_NONE ) )
{
SvMemoryStream aMem;
- aMem << mpGraphic->GetBitmapEx().GetBitmap();
+
+ WriteDIB(mpGraphic->GetBitmapEx().GetBitmap(), aMem, false, true);
return ::com::sun::star::uno::Sequence<sal_Int8>( (sal_Int8*) aMem.GetData(), aMem.Tell() );
}
else
@@ -257,7 +259,8 @@ uno::Sequence< ::sal_Int8 > SAL_CALL Graphic::getMaskDIB( ) throw (uno::Runtime
if( mpGraphic && ( mpGraphic->GetType() != GRAPHIC_NONE ) )
{
SvMemoryStream aMem;
- aMem << mpGraphic->GetBitmapEx().GetMask();
+
+ WriteDIB(mpGraphic->GetBitmapEx().GetMask(), aMem, false, true);
return ::com::sun::star::uno::Sequence<sal_Int8>( (sal_Int8*) aMem.GetData(), aMem.Tell() );
}
else
diff --git a/svtools/source/graphic/provider.cxx b/svtools/source/graphic/provider.cxx
index 18a68f9fe36e..9bc54b915211 100644
--- a/svtools/source/graphic/provider.cxx
+++ b/svtools/source/graphic/provider.cxx
@@ -39,6 +39,7 @@
#include "graphic.hxx"
#include <svtools/grfmgr.hxx>
#include "provider.hxx"
+#include <vcl/dibtools.hxx>
using namespace com::sun::star;
@@ -244,15 +245,16 @@ uno::Reference< ::graphic::XGraphic > GraphicProvider::implLoadBitmap( const uno
uno::Sequence< sal_Int8 > aMaskSeq( xBtm->getMaskDIB() );
SvMemoryStream aBmpStream( aBmpSeq.getArray(), aBmpSeq.getLength(), STREAM_READ );
Bitmap aBmp;
- aBmpStream >> aBmp;
-
BitmapEx aBmpEx;
+ ReadDIB(aBmp, aBmpStream, true);
+
if( aMaskSeq.getLength() )
{
SvMemoryStream aMaskStream( aMaskSeq.getArray(), aMaskSeq.getLength(), STREAM_READ );
Bitmap aMask;
- aMaskStream >> aMask;
+
+ ReadDIB(aMask, aMaskStream, true);
aBmpEx = BitmapEx( aBmp, aMask );
}
else
diff --git a/svtools/source/misc/transfer.cxx b/svtools/source/misc/transfer.cxx
index c1806c4fd1cf..8407e1926d9b 100644
--- a/svtools/source/misc/transfer.cxx
+++ b/svtools/source/misc/transfer.cxx
@@ -55,6 +55,9 @@
#include <svtools/transfer.hxx>
#include <rtl/strbuf.hxx>
#include <cstdio>
+#include <vcl/dibtools.hxx>
+#include <vcl/pngread.hxx>
+#include <vcl/pngwrite.hxx>
// --------------
// - Namespaces -
@@ -358,9 +361,9 @@ Any SAL_CALL TransferableHelper::getTransferData( const DataFlavor& rFlavor ) th
GetData( aSubstFlavor );
bDone = maAny.hasValue();
}
- else if( SotExchange::GetFormatDataFlavor( SOT_FORMATSTR_ID_BMP, aSubstFlavor ) &&
- TransferableDataHelper::IsEqual( aSubstFlavor, rFlavor ) &&
- SotExchange::GetFormatDataFlavor( FORMAT_BITMAP, aSubstFlavor ) )
+ else if(SotExchange::GetFormatDataFlavor(SOT_FORMATSTR_ID_BMP, aSubstFlavor )
+ && TransferableDataHelper::IsEqual( aSubstFlavor, rFlavor )
+ && SotExchange::GetFormatDataFlavor(FORMAT_BITMAP, aSubstFlavor))
{
GetData( aSubstFlavor );
bDone = sal_True;
@@ -672,6 +675,7 @@ void TransferableHelper::AddFormat( const DataFlavor& rFlavor )
if( FORMAT_BITMAP == aFlavorEx.mnSotId )
{
AddFormat( SOT_FORMATSTR_ID_BMP );
+ AddFormat( SOT_FORMATSTR_ID_PNG );
}
else if( FORMAT_GDIMETAFILE == aFlavorEx.mnSotId )
{
@@ -765,13 +769,37 @@ sal_Bool TransferableHelper::SetString( const OUString& rString, const DataFlavo
// -----------------------------------------------------------------------------
-sal_Bool TransferableHelper::SetBitmap( const Bitmap& rBitmap, const DataFlavor& )
+sal_Bool TransferableHelper::SetBitmapEx( const BitmapEx& rBitmapEx, const DataFlavor& rFlavor )
{
- if( !rBitmap.IsEmpty() )
+ if( !rBitmapEx.IsEmpty() )
{
SvMemoryStream aMemStm( 65535, 65535 );
- aMemStm << rBitmap;
+ if(rFlavor.MimeType.equalsIgnoreAsciiCase(::rtl::OUString::createFromAscii("image/png")))
+ {
+ // write a PNG
+ ::vcl::PNGWriter aPNGWriter(rBitmapEx);
+
+ aPNGWriter.Write(aMemStm);
+ }
+ else
+ {
+ const Bitmap aBitmap(rBitmapEx.GetBitmap());
+
+ if(rBitmapEx.IsTransparent())
+ {
+ const Bitmap aMask(rBitmapEx.GetAlpha().GetBitmap());
+
+ // explicitely use Bitmap::Write with bCompressed = sal_False and bFileHeader = sal_True
+ WriteDIBV5(aBitmap, aMask, aMemStm);
+ }
+ else
+ {
+ // explicitely use Bitmap::Write with bCompressed = sal_False and bFileHeader = sal_True
+ WriteDIB(aBitmap, aMemStm, false, true);
+ }
+ }
+
maAny <<= Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aMemStm.GetData() ), aMemStm.Seek( STREAM_SEEK_TO_END ) );
}
@@ -1358,7 +1386,7 @@ void TransferableDataHelper::FillDataFlavorExVector( const Sequence< DataFlavor
rDataFlavorExVector.push_back( aFlavorEx );
// add additional formats for special mime types
- if( SOT_FORMATSTR_ID_BMP == aFlavorEx.mnSotId )
+ if(SOT_FORMATSTR_ID_BMP == aFlavorEx.mnSotId || SOT_FORMATSTR_ID_PNG == aFlavorEx.mnSotId)
{
if( SotExchange::GetFormatDataFlavor( SOT_FORMAT_BITMAP, aFlavorEx ) )
{
@@ -1663,24 +1691,74 @@ sal_Bool TransferableDataHelper::GetString( const DataFlavor& rFlavor, OUString&
// -----------------------------------------------------------------------------
-sal_Bool TransferableDataHelper::GetBitmap( SotFormatStringId nFormat, Bitmap& rBmp )
+sal_Bool TransferableDataHelper::GetBitmapEx( SotFormatStringId nFormat, BitmapEx& rBmpEx )
{
+ if(FORMAT_BITMAP == nFormat)
+ {
+ // try to get PNG first
+ DataFlavor aFlavor;
+
+ if(SotExchange::GetFormatDataFlavor(SOT_FORMATSTR_ID_PNG, aFlavor))
+ {
+ if(GetBitmapEx(aFlavor, rBmpEx))
+ {
+ return true;
+ }
+ }
+ }
+
DataFlavor aFlavor;
- return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetBitmap( aFlavor, rBmp ) );
+ return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetBitmapEx( aFlavor, rBmpEx ) );
}
// -----------------------------------------------------------------------------
-sal_Bool TransferableDataHelper::GetBitmap( const DataFlavor& rFlavor, Bitmap& rBmp )
+sal_Bool TransferableDataHelper::GetBitmapEx( const DataFlavor& rFlavor, BitmapEx& rBmpEx )
{
SotStorageStreamRef xStm;
- DataFlavor aSubstFlavor;
- sal_Bool bRet = GetSotStorageStream( rFlavor, xStm );
+ DataFlavor aSubstFlavor;
+ bool bRet(GetSotStorageStream(rFlavor, xStm));
- if( bRet )
+ if(!bRet && HasFormat(SOT_FORMATSTR_ID_PNG) && SotExchange::GetFormatDataFlavor(SOT_FORMATSTR_ID_PNG, aSubstFlavor))
{
- *xStm >> rBmp;
- bRet = ( xStm->GetError() == ERRCODE_NONE );
+ // when no direct success, try if PNG is available
+ bRet = GetSotStorageStream(aSubstFlavor, xStm);
+ }
+
+ if(!bRet && HasFormat(SOT_FORMATSTR_ID_BMP) && SotExchange::GetFormatDataFlavor(SOT_FORMATSTR_ID_BMP, aSubstFlavor))
+ {
+ // when no direct success, try if BMP is available
+ bRet = GetSotStorageStream(aSubstFlavor, xStm);
+ }
+
+ if(bRet)
+ {
+ if(rFlavor.MimeType.equalsIgnoreAsciiCase(::rtl::OUString::createFromAscii("image/png")))
+ {
+ // it's a PNG, import to BitmapEx
+ ::vcl::PNGReader aPNGReader(*xStm);
+
+ rBmpEx = aPNGReader.Read();
+ }
+ else
+ {
+ Bitmap aBitmap;
+ Bitmap aMask;
+
+ // explicitely use Bitmap::Read with bFileHeader = sal_True
+ ReadDIBV5(aBitmap, aMask, *xStm);
+
+ if(aMask.IsEmpty())
+ {
+ rBmpEx = aBitmap;
+ }
+ else
+ {
+ rBmpEx = BitmapEx(aBitmap, aMask);
+ }
+ }
+
+ bRet = (ERRCODE_NONE == xStm->GetError());
/* SJ: #110748# At the moment we are having problems with DDB inserted as DIB. The
problem is, that some graphics are inserted much too big because the nXPelsPerMeter
@@ -1691,28 +1769,22 @@ sal_Bool TransferableDataHelper::GetBitmap( const DataFlavor& rFlavor, Bitmap& r
The following code should be removed if DDBs and DIBs are supported via clipboard
properly.
*/
- if ( bRet )
+ if(bRet)
{
- MapMode aMapMode = rBmp.GetPrefMapMode();
- if ( aMapMode.GetMapUnit() != MAP_PIXEL )
+ const MapMode aMapMode(rBmpEx.GetPrefMapMode());
+
+ if(MAP_PIXEL != aMapMode.GetMapUnit())
{
- Size aSize = OutputDevice::LogicToLogic( rBmp.GetPrefSize(), aMapMode, MAP_100TH_MM );
- if ( ( aSize.Width() > 5000 ) || ( aSize.Height() > 5000 ) )
- rBmp.SetPrefMapMode( MAP_PIXEL );
+ const Size aSize(OutputDevice::LogicToLogic(rBmpEx.GetPrefSize(), aMapMode, MAP_100TH_MM));
+
+ if((aSize.Width() > 5000) || (aSize.Height() > 5000))
+ {
+ rBmpEx.SetPrefMapMode(MAP_PIXEL);
+ }
}
}
}
- if( !bRet &&
- HasFormat( SOT_FORMATSTR_ID_BMP ) &&
- SotExchange::GetFormatDataFlavor( SOT_FORMATSTR_ID_BMP, aSubstFlavor ) &&
- GetSotStorageStream( aSubstFlavor, xStm ) )
- {
- xStm->ResetError();
- *xStm >> rBmp;
- bRet = ( xStm->GetError() == ERRCODE_NONE );
- }
-
return bRet;
}
@@ -1773,6 +1845,20 @@ sal_Bool TransferableDataHelper::GetGDIMetaFile( const DataFlavor& rFlavor, GDIM
sal_Bool TransferableDataHelper::GetGraphic( SotFormatStringId nFormat, Graphic& rGraphic )
{
+ if(FORMAT_BITMAP == nFormat)
+ {
+ // try to get PNG first
+ DataFlavor aFlavor;
+
+ if(SotExchange::GetFormatDataFlavor(SOT_FORMATSTR_ID_PNG, aFlavor))
+ {
+ if(GetGraphic(aFlavor, rGraphic))
+ {
+ return true;
+ }
+ }
+ }
+
DataFlavor aFlavor;
return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetGraphic( aFlavor, rGraphic ) );
}
@@ -1784,13 +1870,22 @@ sal_Bool TransferableDataHelper::GetGraphic( const ::com::sun::star::datatransfe
DataFlavor aFlavor;
sal_Bool bRet = sal_False;
- if( SotExchange::GetFormatDataFlavor( SOT_FORMAT_BITMAP, aFlavor ) &&
+ if(SotExchange::GetFormatDataFlavor(SOT_FORMATSTR_ID_PNG, aFlavor) &&
+ TransferableDataHelper::IsEqual(aFlavor, rFlavor))
+ {
+ // try to get PNG first
+ BitmapEx aBmpEx;
+
+ if( ( bRet = GetBitmapEx( aFlavor, aBmpEx ) ) == sal_True )
+ rGraphic = aBmpEx;
+ }
+ else if(SotExchange::GetFormatDataFlavor( SOT_FORMAT_BITMAP, aFlavor ) &&
TransferableDataHelper::IsEqual( aFlavor, rFlavor ) )
{
- Bitmap aBmp;
+ BitmapEx aBmpEx;
- if( ( bRet = GetBitmap( aFlavor, aBmp ) ) == sal_True )
- rGraphic = aBmp;
+ if( ( bRet = GetBitmapEx( aFlavor, aBmpEx ) ) == sal_True )
+ rGraphic = aBmpEx;
}
else if( SotExchange::GetFormatDataFlavor( SOT_FORMAT_GDIMETAFILE, aFlavor ) &&
TransferableDataHelper::IsEqual( aFlavor, rFlavor ) )