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 #include "macros.h" 29 30 IMPLEMENT_THUNK( user32, WINDOWS, BOOL, WINAPI, DrawStateW, 31 ( 32 HDC hdc, // handle to device context 33 HBRUSH hbr, // handle to brush 34 DRAWSTATEPROC lpOutputFunc, // pointer to callback function 35 LPARAM lData, // image information 36 WPARAM wData, // more image information 37 int x, // horizontal location of image 38 int y, // vertical location of image 39 int cx, // width of image 40 int cy, // height of image 41 UINT fuFlags // image type and state 42 43 )) 44 { 45 switch ( fuFlags & 0x000F ) 46 { 47 case DST_TEXT: 48 case DST_PREFIXTEXT: 49 { 50 LPSTR lpTextA = NULL; 51 52 if ( lData ) 53 { 54 int cchWideChar = (int) (wData ? wData : -1); 55 int cchNeeded = WideCharToMultiByte( CP_ACP, 0, (LPCWSTR)lData, cchWideChar, NULL, 0, NULL, NULL ); 56 57 lpTextA = (LPSTR)_alloca( cchNeeded * sizeof(CHAR) ); 58 59 if ( !lpTextA ) 60 { 61 SetLastError( ERROR_OUTOFMEMORY ); 62 return FALSE; 63 } 64 65 WideCharToMultiByte( CP_ACP, 0, (LPCWSTR)lData, cchWideChar, lpTextA, cchNeeded, NULL, NULL ); 66 67 } 68 69 return DrawStateA( hdc, hbr, lpOutputFunc, (LPARAM)lpTextA, wData, x, y, cx, cy, fuFlags ); 70 } 71 default: 72 return DrawStateA( hdc, hbr, lpOutputFunc, lData, wData, x, y, cx, cy, fuFlags ); 73 } 74 } 75