diff options
author | Philipp Lohmann [pl] <Philipp.Lohmann@Sun.COM> | 2010-07-07 19:01:58 +0200 |
---|---|---|
committer | Philipp Lohmann [pl] <Philipp.Lohmann@Sun.COM> | 2010-07-07 19:01:58 +0200 |
commit | e9391ae8eb3d0a4edf977f0159ee7e07a0a95859 (patch) | |
tree | c4a117ce1ba30c3f5355ee49372440a8505c0c22 /dtrans/source/win32 | |
parent | 495b598673a964bdf0ceac1250d1f009e7b6ef7d (diff) |
vcl113: #i111834# support pasting HBITMAP
Diffstat (limited to 'dtrans/source/win32')
-rwxr-xr-x[-rw-r--r--] | dtrans/source/win32/dtobj/DOTransferable.cxx | 9 | ||||
-rwxr-xr-x[-rw-r--r--] | dtrans/source/win32/dtobj/FmtFilter.cxx | 43 | ||||
-rwxr-xr-x[-rw-r--r--] | dtrans/source/win32/dtobj/FmtFilter.hxx | 6 | ||||
-rwxr-xr-x[-rw-r--r--] | dtrans/source/win32/ftransl/ftransl.cxx | 1 |
4 files changed, 59 insertions, 0 deletions
diff --git a/dtrans/source/win32/dtobj/DOTransferable.cxx b/dtrans/source/win32/dtobj/DOTransferable.cxx index 951c3a69d291..c590bf0e6a80 100644..100755 --- a/dtrans/source/win32/dtobj/DOTransferable.cxx +++ b/dtrans/source/win32/dtobj/DOTransferable.cxx @@ -348,6 +348,15 @@ CDOTransferable::ByteSequence_t SAL_CALL CDOTransferable::getClipboardData( CFor byteStream = WinENHMFPictToOOMFPict( stgmedium.hEnhMetaFile ); else if (CF_HDROP == aFormatEtc.getClipformat()) byteStream = CF_HDROPToFileList(stgmedium.hGlobal); + else if ( CF_BITMAP == aFormatEtc.getClipformat() ) + { + byteStream = WinBITMAPToOOBMP(stgmedium.hBitmap); + if( aFormatEtc.getTymed() == TYMED_GDI && + ! stgmedium.pUnkForRelease ) + { + DeleteObject(stgmedium.hBitmap); + } + } else { clipDataToByteStream( aFormatEtc.getClipformat( ), stgmedium, byteStream ); diff --git a/dtrans/source/win32/dtobj/FmtFilter.cxx b/dtrans/source/win32/dtobj/FmtFilter.cxx index c8a8743647a9..c4f73977d92d 100644..100755 --- a/dtrans/source/win32/dtobj/FmtFilter.cxx +++ b/dtrans/source/win32/dtobj/FmtFilter.cxx @@ -534,3 +534,46 @@ ByteSequence_t CF_HDROPToFileList(HGLOBAL hGlobal) return FileListToByteSequence(files); } +//------------------------------------------------------------------------ +// convert a windows bitmap handle into a openoffice bitmap +//------------------------------------------------------------------------ + +Sequence< sal_Int8 > SAL_CALL WinBITMAPToOOBMP( HBITMAP aHBMP ) +{ + Sequence< sal_Int8 > ooBmpStream; + + SIZE aBmpSize; + if( GetBitmapDimensionEx( aHBMP, &aBmpSize ) ) + { + // fill bitmap info header + size_t nDataBytes = 4 * aBmpSize.cy * aBmpSize.cy; + Sequence< sal_Int8 > aBitmapStream( + sizeof(BITMAPINFO) + + nDataBytes + ); + PBITMAPINFOHEADER pBmp = (PBITMAPINFOHEADER)aBitmapStream.getArray(); + pBmp->biSize = sizeof( BITMAPINFOHEADER ); + pBmp->biWidth = aBmpSize.cx; + pBmp->biHeight = aBmpSize.cy; + pBmp->biPlanes = 1; + pBmp->biBitCount = 32; + pBmp->biCompression = BI_RGB; + pBmp->biSizeImage = (DWORD)nDataBytes; + pBmp->biXPelsPerMeter = 1000; + pBmp->biYPelsPerMeter = 1000; + pBmp->biClrUsed = 0; + pBmp->biClrImportant = 0; + if( GetDIBits( 0, // DC, 0 is a default GC, basically that of the desktop + aHBMP, + 0, aBmpSize.cy, + aBitmapStream.getArray() + sizeof(BITMAPINFO), + (LPBITMAPINFO)pBmp, + DIB_RGB_COLORS ) ) + { + ooBmpStream = WinDIBToOOBMP( aBitmapStream ); + } + } + + return ooBmpStream; +} + diff --git a/dtrans/source/win32/dtobj/FmtFilter.hxx b/dtrans/source/win32/dtobj/FmtFilter.hxx index 3f433561a3b1..84f764c9769b 100644..100755 --- a/dtrans/source/win32/dtobj/FmtFilter.hxx +++ b/dtrans/source/win32/dtobj/FmtFilter.hxx @@ -67,6 +67,12 @@ com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL WinDIBToOOBMP( const com::sun /*------------------------------------------------------------------------ input: + aWinDIB - sequence of bytes containing a windows bitmap handle +------------------------------------------------------------------------*/ +com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL WinBITMAPToOOBMP( HBITMAP ); + +/*------------------------------------------------------------------------ + input: aOOBmp - sequence of bytes containing a openoffice bitmap ------------------------------------------------------------------------*/ com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL OOBmpToWinDIB( com::sun::star::uno::Sequence< sal_Int8 >& aOOBmp ); diff --git a/dtrans/source/win32/ftransl/ftransl.cxx b/dtrans/source/win32/ftransl/ftransl.cxx index c0a8264a71b8..98c6625bb33e 100644..100755 --- a/dtrans/source/win32/ftransl/ftransl.cxx +++ b/dtrans/source/win32/ftransl/ftransl.cxx @@ -281,6 +281,7 @@ void SAL_CALL CDataFormatTranslator::initTranslationTable() m_TranslTable.push_back(FormatEntry("application/x-openoffice-dif;windows_formatname=\"DIF\"", "DIF", "DIF", CF_DIF, CPPUTYPE_DEFAULT)); // SOT_FORMAT_BITMAP m_TranslTable.push_back(FormatEntry("application/x-openoffice-bitmap;windows_formatname=\"Bitmap\"", "Bitmap", "Bitmap", CF_DIB, CPPUTYPE_DEFAULT)); + m_TranslTable.push_back(FormatEntry("application/x-openoffice-bitmap;windows_formatname=\"Bitmap\"", "Bitmap", "Bitmap", CF_BITMAP, CPPUTYPE_DEFAULT)); // SOT_FORMAT_STRING m_TranslTable.push_back(FormatEntry("text/plain;charset=utf-16", "Unicode-Text", "", CF_UNICODETEXT, CppuType_String)); // Format Locale - for internal use |