- Add annotations for text function
- Improve formatting and some variable names
- No code change

svn path=/trunk/; revision=65324
This commit is contained in:
Timo Kreuzer 2014-11-08 15:34:47 +00:00
parent 34353069cc
commit b461fd27f1

View file

@ -9,27 +9,30 @@
BOOL BOOL
WINAPI WINAPI
TextOutA( TextOutA(
HDC hdc, _In_ HDC hdc,
int nXStart, _In_ INT nXStart,
int nYStart, _In_ INT nYStart,
LPCSTR lpString, _In_reads_(cchString) LPCSTR lpString,
int cchString) _In_ INT cchString)
{ {
ANSI_STRING StringA; ANSI_STRING StringA;
UNICODE_STRING StringU; UNICODE_STRING StringU;
BOOL ret; BOOL bResult;
if (NULL != lpString) if (lpString != NULL)
{ {
RtlInitAnsiString(&StringA, (LPSTR)lpString); RtlInitAnsiString(&StringA, (LPSTR)lpString);
RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE); RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
} }
else else
{
StringU.Buffer = NULL; StringU.Buffer = NULL;
}
bResult = TextOutW(hdc, nXStart, nYStart, StringU.Buffer, cchString);
ret = TextOutW(hdc, nXStart, nYStart, StringU.Buffer, cchString);
RtlFreeUnicodeString(&StringU); RtlFreeUnicodeString(&StringU);
return ret; return bResult;
} }
@ -39,13 +42,20 @@ TextOutA(
BOOL BOOL
WINAPI WINAPI
TextOutW( TextOutW(
HDC hdc, _In_ HDC hdc,
int nXStart, _In_ INT nXStart,
int nYStart, _In_ INT nYStart,
LPCWSTR lpString, _In_reads_(cchString) LPCWSTR lpString,
int cchString) _In_ INT cchString)
{ {
return NtGdiExtTextOutW(hdc, nXStart, nYStart, 0, NULL, (LPWSTR)lpString, cchString, NULL, 0); return NtGdiExtTextOutW(hdc,
nXStart,
nYStart,
0, NULL,
(LPWSTR)lpString,
cchString,
NULL,
0);
} }
@ -54,11 +64,26 @@ TextOutW(
*/ */
BOOL BOOL
WINAPI WINAPI
PolyTextOutA( HDC hdc, const POLYTEXTA *pptxt, INT cStrings ) PolyTextOutA(
_In_ HDC hdc,
_In_reads_(cStrings) const POLYTEXTA *pptxt,
_In_ INT cStrings)
{ {
for (; cStrings>0; cStrings--, pptxt++) for (; cStrings>0; cStrings--, pptxt++)
if (!ExtTextOutA( hdc, pptxt->x, pptxt->y, pptxt->uiFlags, &pptxt->rcl, pptxt->lpstr, pptxt->n, pptxt->pdx )) {
if (!ExtTextOutA(hdc,
pptxt->x,
pptxt->y,
pptxt->uiFlags,
&pptxt->rcl,
pptxt->lpstr,
pptxt->n,
pptxt->pdx))
{
return FALSE; return FALSE;
}
}
return TRUE; return TRUE;
} }
@ -68,11 +93,26 @@ PolyTextOutA( HDC hdc, const POLYTEXTA *pptxt, INT cStrings )
*/ */
BOOL BOOL
WINAPI WINAPI
PolyTextOutW( HDC hdc, const POLYTEXTW *pptxt, INT cStrings ) PolyTextOutW(
_In_ HDC hdc,
_In_reads_(cStrings) const POLYTEXTW *pptxt,
_In_ INT cStrings)
{ {
for (; cStrings>0; cStrings--, pptxt++) for (; cStrings>0; cStrings--, pptxt++)
if (!ExtTextOutW( hdc, pptxt->x, pptxt->y, pptxt->uiFlags, &pptxt->rcl, pptxt->lpstr, pptxt->n, pptxt->pdx )) {
if (!ExtTextOutW(hdc,
pptxt->x,
pptxt->y,
pptxt->uiFlags,
&pptxt->rcl,
pptxt->lpstr,
pptxt->n,
pptxt->pdx))
{
return FALSE; return FALSE;
}
}
return TRUE; return TRUE;
} }
@ -82,7 +122,8 @@ PolyTextOutW( HDC hdc, const POLYTEXTW *pptxt, INT cStrings )
*/ */
DWORD DWORD
WINAPI WINAPI
GdiGetCodePage(HDC hdc) GdiGetCodePage(
_In_ HDC hdc)
{ {
PDC_ATTR pdcattr; PDC_ATTR pdcattr;
@ -104,11 +145,10 @@ GdiGetCodePage(HDC hdc)
/* /*
* @unimplemented * @unimplemented
*/ */
int INT
WINAPI WINAPI
GetTextCharacterExtra( GetTextCharacterExtra(
HDC hdc _In_ HDC hdc)
)
{ {
PDC_ATTR pdcattr; PDC_ATTR pdcattr;
@ -127,25 +167,24 @@ GetTextCharacterExtra(
/* /*
* @implemented * @implemented
*/ */
int INT
WINAPI WINAPI
GetTextCharset(HDC hdc) GetTextCharset(
_In_ HDC hdc)
{ {
/* MSDN docs say this is equivalent */ /* MSDN docs say this is equivalent */
return NtGdiGetTextCharsetInfo(hdc,NULL,0); return NtGdiGetTextCharsetInfo(hdc,NULL,0);
} }
/* /*
* @implemented * @implemented
*/ */
BOOL BOOL
WINAPI WINAPI
GetTextMetricsA( GetTextMetricsA(
HDC hdc, _In_ HDC hdc,
LPTEXTMETRICA lptm _Out_ LPTEXTMETRICA lptm)
)
{ {
TMW_INTERNAL tmwi; TMW_INTERNAL tmwi;
@ -165,13 +204,12 @@ GetTextMetricsA(
BOOL BOOL
WINAPI WINAPI
GetTextMetricsW( GetTextMetricsW(
HDC hdc, _In_ HDC hdc,
LPTEXTMETRICW lptm _Out_ LPTEXTMETRICW lptm)
)
{ {
TMW_INTERNAL tmwi; TMW_INTERNAL tmwi;
if (! NtGdiGetTextMetricsW(hdc, &tmwi, sizeof(TMW_INTERNAL))) if (!NtGdiGetTextMetricsW(hdc, &tmwi, sizeof(TMW_INTERNAL)))
{ {
return FALSE; return FALSE;
} }
@ -187,11 +225,10 @@ GetTextMetricsW(
BOOL BOOL
APIENTRY APIENTRY
GetTextExtentPointA( GetTextExtentPointA(
HDC hdc, _In_ HDC hdc,
LPCSTR lpString, _In_reads_(cchString) LPCSTR lpString,
int cchString, _In_ INT cchString,
LPSIZE lpSize _Out_ LPSIZE lpsz)
)
{ {
ANSI_STRING StringA; ANSI_STRING StringA;
UNICODE_STRING StringU; UNICODE_STRING StringU;
@ -200,7 +237,7 @@ GetTextExtentPointA(
RtlInitAnsiString(&StringA, (LPSTR)lpString); RtlInitAnsiString(&StringA, (LPSTR)lpString);
RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE); RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
ret = GetTextExtentPointW(hdc, StringU.Buffer, cchString, lpSize); ret = GetTextExtentPointW(hdc, StringU.Buffer, cchString, lpsz);
RtlFreeUnicodeString(&StringU); RtlFreeUnicodeString(&StringU);
@ -214,38 +251,12 @@ GetTextExtentPointA(
BOOL BOOL
APIENTRY APIENTRY
GetTextExtentPointW( GetTextExtentPointW(
HDC hdc, _In_ HDC hdc,
LPCWSTR lpString, _In_reads_(cchString) LPCWSTR lpString,
int cchString, _In_ INT cchString,
LPSIZE lpSize _Out_ LPSIZE lpsz)
)
{ {
return NtGdiGetTextExtent(hdc, (LPWSTR)lpString, cchString, lpSize, 0); return NtGdiGetTextExtent(hdc, (LPWSTR)lpString, cchString, lpsz, 0);
}
/*
* @implemented
*/
BOOL
APIENTRY
GetTextExtentExPointW(
HDC hdc,
LPCWSTR lpszStr,
int cchString,
int nMaxExtent,
LPINT lpnFit,
LPINT alpDx,
LPSIZE lpSize
)
{
/* Windows doesn't check nMaxExtent validity in unicode version */
if(nMaxExtent < -1)
DPRINT("nMaxExtent is invalid: %d\n", nMaxExtent);
return NtGdiGetTextExtentExW (
hdc, (LPWSTR)lpszStr, cchString, nMaxExtent, (PULONG)lpnFit, (PULONG)alpDx, lpSize, 0 );
} }
@ -254,54 +265,87 @@ GetTextExtentExPointW(
*/ */
BOOL BOOL
WINAPI WINAPI
GetTextExtentExPointWPri(HDC hdc, GetTextExtentExPointW(
LPWSTR lpwsz, _In_ HDC hdc,
ULONG cwc, _In_reads_(cchString) LPCWSTR lpszString,
ULONG dxMax, _In_ INT cchString,
ULONG *pcCh, _In_ INT nMaxExtent,
PULONG pdxOut, _Out_opt_ LPINT lpnFit,
LPSIZE psize) _Out_writes_to_opt_(cchString, *lpnFit) LPINT lpnDx,
_Out_ LPSIZE lpSize)
{ {
return NtGdiGetTextExtentExW(hdc,lpwsz,cwc,dxMax,pcCh,pdxOut,psize,0);
/* Windows doesn't check nMaxExtent validity in unicode version */
if (nMaxExtent < -1)
{
DPRINT("nMaxExtent is invalid: %d\n", nMaxExtent);
}
return NtGdiGetTextExtentExW (
hdc, (LPWSTR)lpszString, cchString, nMaxExtent, (PULONG)lpnFit, (PULONG)lpnDx, lpSize, 0 );
}
/*
* @implemented
*/
BOOL
WINAPI
GetTextExtentExPointWPri(
_In_ HDC hdc,
_In_reads_(cwc) LPWSTR lpwsz,
_In_ ULONG cwc,
_In_ ULONG dxMax,
_Out_opt_ ULONG *pcCh,
_Out_writes_to_opt_(cwc, *pcCh) PULONG pdxOut,
_In_ LPSIZE psize)
{
return NtGdiGetTextExtentExW(hdc, lpwsz, cwc, dxMax, pcCh, pdxOut, psize, 0);
} }
/* /*
* @implemented * @implemented
*/ */
BOOL BOOL
APIENTRY WINAPI
GetTextExtentExPointA( GetTextExtentExPointA(
HDC hdc, _In_ HDC hdc,
LPCSTR lpszStr, _In_reads_(cchString) LPCSTR lpszStr,
int cchString, _In_ INT cchString,
int nMaxExtent, _In_ INT nMaxExtent,
LPINT lpnFit, _Out_opt_ LPINT lpnFit,
LPINT alpDx, _Out_writes_to_opt_ (cchString, *lpnFit) LPINT lpnDx,
LPSIZE lpSize _Out_ LPSIZE lpSize)
)
{ {
NTSTATUS Status; NTSTATUS Status;
LPWSTR lpszStrW; LPWSTR lpszStrW;
BOOL rc = 0; BOOL bResult = FALSE;
if(nMaxExtent < -1) if (nMaxExtent < -1)
{ {
SetLastError(ERROR_INVALID_PARAMETER); SetLastError(ERROR_INVALID_PARAMETER);
return FALSE; return FALSE;
} }
Status = HEAP_strdupA2W ( &lpszStrW, lpszStr ); Status = HEAP_strdupA2W(&lpszStrW, lpszStr);
if (!NT_SUCCESS (Status)) if (!NT_SUCCESS (Status))
SetLastError (RtlNtStatusToDosError(Status));
else
{ {
rc = NtGdiGetTextExtentExW ( SetLastError(RtlNtStatusToDosError(Status));
hdc, lpszStrW, cchString, nMaxExtent, (PULONG)lpnFit, (PULONG)alpDx, lpSize, 0 ); return FALSE;
HEAP_free ( lpszStrW );
} }
return rc; bResult = NtGdiGetTextExtentExW(hdc,
lpszStrW,
cchString,
nMaxExtent,
(PULONG)lpnFit,
(PULONG)lpnDx,
lpSize,
0);
HEAP_free(lpszStrW);
return bResult;
} }
@ -309,13 +353,12 @@ GetTextExtentExPointA(
* @implemented * @implemented
*/ */
BOOL BOOL
APIENTRY WINAPI
GetTextExtentPoint32A( GetTextExtentPoint32A(
HDC hdc, _In_ HDC hdc,
LPCSTR lpString, _In_reads_(cchString) LPCSTR lpString,
int cchString, _In_ INT cchString,
LPSIZE lpSize _Out_ LPSIZE lpSize)
)
{ {
ANSI_STRING StringA; ANSI_STRING StringA;
UNICODE_STRING StringU; UNICODE_STRING StringU;
@ -337,13 +380,12 @@ GetTextExtentPoint32A(
* @implemented * @implemented
*/ */
BOOL BOOL
APIENTRY WINAPI
GetTextExtentPoint32W( GetTextExtentPoint32W(
HDC hdc, _In_ HDC hdc,
LPCWSTR lpString, _In_reads_(cchString) LPCWSTR lpString,
int cchString, _In_ int cchString,
LPSIZE lpSize _Out_ LPSIZE lpSize)
)
{ {
return NtGdiGetTextExtent(hdc, (LPWSTR)lpString, cchString, lpSize, 0); return NtGdiGetTextExtent(hdc, (LPWSTR)lpString, cchString, lpSize, 0);
} }
@ -353,15 +395,23 @@ GetTextExtentPoint32W(
*/ */
BOOL BOOL
WINAPI WINAPI
GetTextExtentExPointI(HDC hdc, GetTextExtentExPointI(
LPWORD pgiIn, _In_ HDC hdc,
int cgi, _In_reads_(cgi) LPWORD pgiIn,
int nMaxExtent, _In_ INT cgi,
LPINT lpnFit, _In_ INT nMaxExtent,
LPINT alpDx, _Out_opt_ LPINT lpnFit,
LPSIZE lpSize) _Out_writes_to_opt_(cwchString, *lpnFit) LPINT lpnDx,
_Out_ LPSIZE lpSize)
{ {
return NtGdiGetTextExtentExW(hdc,pgiIn,cgi,nMaxExtent,(ULONG *)lpnFit, (PULONG) alpDx,lpSize,GTEF_INDICES); return NtGdiGetTextExtentExW(hdc,
pgiIn,
cgi,
nMaxExtent,
(PULONG)lpnFit,
(PULONG)lpnDx,
lpSize,
GTEF_INDICES);
} }
/* /*
@ -369,12 +419,13 @@ GetTextExtentExPointI(HDC hdc,
*/ */
BOOL BOOL
WINAPI WINAPI
GetTextExtentPointI(HDC hdc, GetTextExtentPointI(
LPWORD pgiIn, _In_ HDC hdc,
int cgi, _In_reads_(cgi) LPWORD pgiIn,
LPSIZE lpSize) _In_ int cgi,
_Out_ LPSIZE lpSize)
{ {
return NtGdiGetTextExtent(hdc,pgiIn,cgi,lpSize,GTEF_INDICES); return NtGdiGetTextExtent(hdc, pgiIn, cgi, lpSize, GTEF_INDICES);
} }
/* /*
@ -383,15 +434,14 @@ GetTextExtentPointI(HDC hdc,
BOOL BOOL
WINAPI WINAPI
ExtTextOutA( ExtTextOutA(
HDC hdc, _In_ HDC hdc,
int X, _In_ INT x,
int Y, _In_ INT y,
UINT fuOptions, _In_ UINT fuOptions,
CONST RECT *lprc, _In_opt_ const RECT *lprc,
LPCSTR lpString, _In_reads_opt_(cch) LPCSTR lpString,
UINT cchString, _In_ UINT cch,
CONST INT *lpDx _In_reads_opt_(cch) const INT *lpDx)
)
{ {
ANSI_STRING StringA; ANSI_STRING StringA;
UNICODE_STRING StringU; UNICODE_STRING StringU;
@ -400,7 +450,7 @@ ExtTextOutA(
RtlInitAnsiString(&StringA, (LPSTR)lpString); RtlInitAnsiString(&StringA, (LPSTR)lpString);
RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE); RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
ret = ExtTextOutW(hdc, X, Y, fuOptions, lprc, StringU.Buffer, cchString, lpDx); ret = ExtTextOutW(hdc, x, y, fuOptions, lprc, StringU.Buffer, cch, lpDx);
RtlFreeUnicodeString(&StringU); RtlFreeUnicodeString(&StringU);
@ -414,17 +464,24 @@ ExtTextOutA(
BOOL BOOL
WINAPI WINAPI
ExtTextOutW( ExtTextOutW(
HDC hdc, _In_ HDC hdc,
int X, _In_ INT x,
int Y, _In_ INT y,
UINT fuOptions, _In_ UINT fuOptions,
CONST RECT *lprc, _In_opt_ const RECT *lprc,
LPCWSTR lpString, _In_reads_opt_(cwc) LPCWSTR lpString,
UINT cchString, _In_ UINT cwc,
CONST INT *lpDx _In_reads_opt_(cwc) const INT *lpDx)
)
{ {
return NtGdiExtTextOutW(hdc, X, Y, fuOptions, (LPRECT)lprc, (LPWSTR)lpString, cchString, (LPINT)lpDx, 0); return NtGdiExtTextOutW(hdc,
x,
y,
fuOptions,
(LPRECT)lprc,
(LPWSTR)lpString,
cwc,
(LPINT)lpDx,
0);
} }
@ -433,12 +490,13 @@ ExtTextOutW(
*/ */
INT INT
WINAPI WINAPI
GetTextFaceW(HDC hDC, GetTextFaceW(
INT nCount, _In_ HDC hdc,
PWSTR pFaceName) _In_ INT cwcMax,
_Out_writes_to_opt_(cwcMax, return) LPWSTR pFaceName)
{ {
/* Validate parameters */ /* Validate parameters */
if (pFaceName && nCount <= 0) if (pFaceName && cwcMax <= 0)
{ {
/* Set last error and return failure */ /* Set last error and return failure */
GdiSetLastError(ERROR_INVALID_PARAMETER); GdiSetLastError(ERROR_INVALID_PARAMETER);
@ -446,22 +504,25 @@ GetTextFaceW(HDC hDC,
} }
/* Forward to kernel */ /* Forward to kernel */
return NtGdiGetTextFaceW(hDC, nCount, pFaceName, FALSE); return NtGdiGetTextFaceW(hdc, cwcMax, pFaceName, FALSE);
} }
/* /*
* @implemented * @implemented
*/ */
int INT
WINAPI WINAPI
GetTextFaceA( HDC hdc, INT count, LPSTR name ) GetTextFaceA(
_In_ HDC hdc,
_In_ INT cchMax,
_Out_writes_to_opt_(cchMax, return) LPSTR lpName)
{ {
INT res; INT res;
LPWSTR nameW; LPWSTR nameW;
/* Validate parameters */ /* Validate parameters */
if (name && count <= 0) if (lpName && cchMax <= 0)
{ {
/* Set last error and return failure */ /* Set last error and return failure */
GdiSetLastError(ERROR_INVALID_PARAMETER); GdiSetLastError(ERROR_INVALID_PARAMETER);
@ -474,16 +535,20 @@ GetTextFaceA( HDC hdc, INT count, LPSTR name )
{ {
return 0; return 0;
} }
GetTextFaceW( hdc, res, nameW ); GetTextFaceW( hdc, res, nameW );
if (name) if (lpName)
{ {
if (count && !WideCharToMultiByte( CP_ACP, 0, nameW, -1, name, count, NULL, NULL)) if (cchMax && !WideCharToMultiByte( CP_ACP, 0, nameW, -1, lpName, cchMax, NULL, NULL))
name[count-1] = 0; lpName[cchMax-1] = 0;
res = strlen(name); res = strlen(lpName);
} }
else else
{
res = WideCharToMultiByte( CP_ACP, 0, nameW, -1, NULL, 0, NULL, NULL); res = WideCharToMultiByte( CP_ACP, 0, nameW, -1, NULL, 0, NULL, NULL);
}
HeapFree( GetProcessHeap(), 0, nameW ); HeapFree( GetProcessHeap(), 0, nameW );
return res; return res;
} }
@ -494,27 +559,28 @@ GetTextFaceA( HDC hdc, INT count, LPSTR name )
*/ */
INT INT
WINAPI WINAPI
GetTextFaceAliasW(HDC hdc, GetTextFaceAliasW(
int cChar, _In_ HDC hdc,
LPWSTR pszOut) _In_ INT cwcMax,
_Out_writes_to_opt_(cwcMax, return) LPWSTR pszOut)
{ {
if ( pszOut && !cChar ) if (pszOut && !cwcMax)
{ {
GdiSetLastError(ERROR_INVALID_PARAMETER); GdiSetLastError(ERROR_INVALID_PARAMETER);
return 0; return 0;
} }
return NtGdiGetTextFaceW(hdc,cChar,pszOut,TRUE);
return NtGdiGetTextFaceW(hdc, cwcMax, pszOut, TRUE);
} }
BOOL BOOL
WINAPI WINAPI
GetFontResourceInfoW( GetFontResourceInfoW(
LPCWSTR lpFileName, _In_z_ LPCWSTR lpFileName,
DWORD *pdwBufSize, _Inout_ DWORD *pdwBufSize,
void* lpBuffer, _Out_writes_to_(*pdwBufSize, *pdwBufSize) PVOID lpBuffer,
DWORD dwType _In_ DWORD dwType)
)
{ {
BOOL bRet; BOOL bRet;
UNICODE_STRING NtFileName; UNICODE_STRING NtFileName;
@ -545,29 +611,23 @@ GetFontResourceInfoW(
RtlFreeHeap(RtlGetProcessHeap(), 0, NtFileName.Buffer); RtlFreeHeap(RtlGetProcessHeap(), 0, NtFileName.Buffer);
if (!bRet) return bRet;
{
return FALSE;
}
return TRUE;
} }
/* /*
* @unimplemented * @unimplemented
*/ */
int INT
WINAPI WINAPI
SetTextCharacterExtra( SetTextCharacterExtra(
HDC hdc, _In_ HDC hdc,
int CharExtra _In_ INT nCharExtra)
)
{ {
INT cExtra;
PDC_ATTR pdcattr; PDC_ATTR pdcattr;
INT nOldCharExtra;
if (CharExtra == 0x80000000) if (nCharExtra == 0x80000000)
{ {
SetLastError(ERROR_INVALID_PARAMETER); SetLastError(ERROR_INVALID_PARAMETER);
return 0x80000000; return 0x80000000;
@ -576,7 +636,7 @@ SetTextCharacterExtra(
#if 0 #if 0
if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC)
{ {
return MFDRV_SetTextCharacterExtra( hdc, CharExtra ); // Wine port. return MFDRV_SetTextCharacterExtra( hdc, nCharExtra ); // Wine port.
} }
#endif #endif
@ -597,9 +657,9 @@ SetTextCharacterExtra(
} }
} }
cExtra = pdcattr->lTextExtra; nOldCharExtra = pdcattr->lTextExtra;
pdcattr->lTextExtra = CharExtra; pdcattr->lTextExtra = nCharExtra;
return cExtra; return nOldCharExtra;
} }
/* /*
@ -608,7 +668,8 @@ SetTextCharacterExtra(
*/ */
UINT UINT
WINAPI WINAPI
GetTextAlign(HDC hdc) GetTextAlign(
_In_ HDC hdc)
{ {
PDC_ATTR pdcattr; PDC_ATTR pdcattr;
@ -630,7 +691,8 @@ GetTextAlign(HDC hdc)
*/ */
COLORREF COLORREF
WINAPI WINAPI
GetTextColor(HDC hdc) GetTextColor(
_In_ HDC hdc)
{ {
PDC_ATTR pdcattr; PDC_ATTR pdcattr;
@ -651,11 +713,12 @@ GetTextColor(HDC hdc)
*/ */
UINT UINT
WINAPI WINAPI
SetTextAlign(HDC hdc, SetTextAlign(
UINT fMode) _In_ HDC hdc,
_In_ UINT fMode)
{ {
PDC_ATTR pdcattr; PDC_ATTR pdcattr;
INT OldMode; INT fOldMode;
/* Get the DC attribute */ /* Get the DC attribute */
pdcattr = GdiGetDcAttr(hdc); pdcattr = GdiGetDcAttr(hdc);
@ -686,7 +749,7 @@ SetTextAlign(HDC hdc,
} }
#endif #endif
OldMode = pdcattr->lTextAlign; fOldMode = pdcattr->lTextAlign;
pdcattr->lTextAlign = fMode; // Raw pdcattr->lTextAlign = fMode; // Raw
if (pdcattr->dwLayout & LAYOUT_RTL) if (pdcattr->dwLayout & LAYOUT_RTL)
{ {
@ -694,7 +757,7 @@ SetTextAlign(HDC hdc,
} }
pdcattr->flTextAlign = fMode & TA_MASK; pdcattr->flTextAlign = fMode & TA_MASK;
return OldMode; return fOldMode;
} }
@ -704,12 +767,11 @@ SetTextAlign(HDC hdc,
COLORREF COLORREF
WINAPI WINAPI
SetTextColor( SetTextColor(
HDC hdc, _In_ HDC hdc,
COLORREF crColor _In_ COLORREF crColor)
)
{ {
PDC_ATTR pdcattr; PDC_ATTR pdcattr;
COLORREF OldColor = CLR_INVALID; COLORREF crOldColor = CLR_INVALID;
/* Get the DC attribute */ /* Get the DC attribute */
pdcattr = GdiGetDcAttr(hdc); pdcattr = GdiGetDcAttr(hdc);
@ -740,15 +802,16 @@ SetTextColor(
} }
#endif #endif
OldColor = (COLORREF) pdcattr->ulForegroundClr; crOldColor = (COLORREF) pdcattr->ulForegroundClr;
pdcattr->ulForegroundClr = (ULONG) crColor; pdcattr->ulForegroundClr = (ULONG)crColor;
if ( pdcattr->crForegroundClr != crColor ) if (pdcattr->crForegroundClr != crColor)
{ {
pdcattr->ulDirty_ |= (DIRTY_TEXT|DIRTY_LINE|DIRTY_FILL); pdcattr->ulDirty_ |= (DIRTY_TEXT|DIRTY_LINE|DIRTY_FILL);
pdcattr->crForegroundClr = crColor; pdcattr->crForegroundClr = crColor;
} }
return OldColor;
return crOldColor;
} }
/* /*
@ -757,10 +820,9 @@ SetTextColor(
BOOL BOOL
WINAPI WINAPI
SetTextJustification( SetTextJustification(
HDC hdc, _In_ HDC hdc,
int extra, _In_ INT nBreakExtra,
int breaks _In_ INT nBreakCount)
)
{ {
PDC_ATTR pdcattr; PDC_ATTR pdcattr;
@ -776,7 +838,7 @@ SetTextJustification(
if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC)
{ {
if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC)
return MFDRV_SetTextJustification( hdc, extra, breaks ) return MFDRV_SetTextJustification( hdc, nBreakExtra, nBreakCount )
else else
{ {
SetLastError(ERROR_INVALID_HANDLE); SetLastError(ERROR_INVALID_HANDLE);
@ -793,8 +855,8 @@ SetTextJustification(
} }
} }
pdcattr->cBreak = breaks; pdcattr->cBreak = nBreakCount;
pdcattr->lBreakExtra = extra; pdcattr->lBreakExtra = nBreakExtra;
return TRUE; return TRUE;
} }
@ -803,32 +865,35 @@ SetTextJustification(
*/ */
UINT UINT
WINAPI WINAPI
GetStringBitmapA(HDC hdc, GetStringBitmapA(
LPSTR psz, _In_ HDC hdc,
BOOL DoCall, _In_ LPSTR psz,
UINT cj, _In_ BOOL bDoCall,
BYTE *lpSB) _In_ UINT cj,
_Out_writes_(cj) BYTE *lpSB)
{ {
NTSTATUS Status; NTSTATUS Status;
PWSTR pwsz; PWSTR pwsz;
UINT retValue = 0; UINT uResult = 0;
if (DoCall) if (!bDoCall)
{ {
Status = HEAP_strdupA2W ( &pwsz, psz ); return 0;
if ( !NT_SUCCESS (Status) )
{
SetLastError (RtlNtStatusToDosError(Status));
}
else
{
retValue = NtGdiGetStringBitmapW(hdc, pwsz, 1, lpSB, cj);
HEAP_free ( pwsz );
}
} }
return retValue; Status = HEAP_strdupA2W(&pwsz, psz);
if (!NT_SUCCESS(Status))
{
SetLastError (RtlNtStatusToDosError(Status));
}
else
{
uResult = NtGdiGetStringBitmapW(hdc, pwsz, 1, lpSB, cj);
HEAP_free(pwsz);
}
return uResult;
} }
@ -837,20 +902,19 @@ GetStringBitmapA(HDC hdc,
*/ */
UINT UINT
WINAPI WINAPI
GetStringBitmapW(HDC hdc, GetStringBitmapW(
LPWSTR pwsz, _In_ HDC hdc,
BOOL doCall, _In_ LPWSTR pwsz,
UINT cj, _In_ BOOL bDoCall,
BYTE *lpSB) _In_ UINT cj,
_Out_writes_(cj) BYTE *lpSB)
{ {
UINT retValue = 0; if (!bDoCall)
if (doCall)
{ {
retValue = NtGdiGetStringBitmapW(hdc, pwsz, 1, lpSB, cj); return 0;
} }
return retValue; return NtGdiGetStringBitmapW(hdc, pwsz, 1, lpSB, cj);
} }
@ -859,13 +923,18 @@ GetStringBitmapW(HDC hdc,
*/ */
BOOL BOOL
WINAPI WINAPI
GetETM(HDC hdc, GetETM(
EXTTEXTMETRIC *petm) _In_ HDC hdc,
_Out_ EXTTEXTMETRIC *petm)
{ {
BOOL Ret = NtGdiGetETM(hdc, petm); BOOL bResult;
if (Ret && petm) bResult = NtGdiGetETM(hdc, petm);
if (bResult && petm)
{
petm->emKernPairs = (WORD)GetKerningPairsA(hdc, 0, 0); petm->emKernPairs = (WORD)GetKerningPairsA(hdc, 0, 0);
}
return Ret; return bResult;
} }