From 82e886d635051c1bf0ecb29423699d7a6116a731 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Tue, 23 Mar 2004 19:46:50 +0000 Subject: [PATCH] Implement GetObjectA/W() for fonts svn path=/trunk/; revision=8851 --- reactos/lib/gdi32/misc/stubsa.c | 17 +----- reactos/lib/gdi32/misc/stubsw.c | 17 +----- reactos/lib/gdi32/objects/dc.c | 53 ++++++++++++++++++ reactos/subsys/win32k/include/text.h | 1 + reactos/subsys/win32k/objects/dc.c | 83 +++++++++++++++------------- reactos/subsys/win32k/objects/text.c | 16 +++++- 6 files changed, 117 insertions(+), 70 deletions(-) diff --git a/reactos/lib/gdi32/misc/stubsa.c b/reactos/lib/gdi32/misc/stubsa.c index baa66c4a87d..5faf385615c 100644 --- a/reactos/lib/gdi32/misc/stubsa.c +++ b/reactos/lib/gdi32/misc/stubsa.c @@ -1,4 +1,4 @@ -/* $Id: stubsa.c,v 1.29 2004/03/23 07:59:47 gvg Exp $ +/* $Id: stubsa.c,v 1.30 2004/03/23 19:46:49 gvg Exp $ * * reactos/lib/gdi32/misc/stubs.c * @@ -407,21 +407,6 @@ StartDocA( } -/* - * @unimplemented - */ -int -STDCALL -GetObjectA( - HGDIOBJ a0, - int a1, - LPVOID a2 - ) -{ - return NtGdiGetObject ( a0, a1, a2 ); -} - - /* * @unimplemented */ diff --git a/reactos/lib/gdi32/misc/stubsw.c b/reactos/lib/gdi32/misc/stubsw.c index 12e1b752ed0..66240e38c4b 100644 --- a/reactos/lib/gdi32/misc/stubsw.c +++ b/reactos/lib/gdi32/misc/stubsw.c @@ -1,4 +1,4 @@ -/* $Id: stubsw.c,v 1.26 2004/03/23 07:59:47 gvg Exp $ +/* $Id: stubsw.c,v 1.27 2004/03/23 19:46:49 gvg Exp $ * * reactos/lib/gdi32/misc/stubs.c * @@ -296,21 +296,6 @@ StartDocW( } -/* - * @unimplemented - */ -int -STDCALL -GetObjectW( - HGDIOBJ a0, - int a1, - LPVOID a2 - ) -{ - return NtGdiGetObject ( a0, a1, a2 ); -} - - /* * @unimplemented */ diff --git a/reactos/lib/gdi32/objects/dc.c b/reactos/lib/gdi32/objects/dc.c index c37da44a82f..09c0f879f57 100644 --- a/reactos/lib/gdi32/objects/dc.c +++ b/reactos/lib/gdi32/objects/dc.c @@ -6,6 +6,7 @@ #include #include #include +#include /* @@ -940,3 +941,55 @@ ExtEscape( { return NtGdiExtEscape(a0, a1, a2, a3, a4, a5); } + + +/* + * @unimplemented + */ +int +STDCALL +GetObjectA(HGDIOBJ Handle, int Size, LPVOID Buffer) +{ + LOGFONTW LogFontW; + DWORD Type; + int Result; + + Type = GetObjectType(Handle); + if (0 == Type) + { + return 0; + } + + if (OBJ_FONT == Type) + { + if (Size < sizeof(LOGFONTA)) + { + SetLastError(ERROR_BUFFER_OVERFLOW); + return 0; + } + Result = NtGdiGetObject(Handle, sizeof(LOGFONTW), &LogFontW); + if (0 == Result) + { + return 0; + } + RosRtlLogFontW2A((LPLOGFONTA) Buffer, &LogFontW); + Result = sizeof(LOGFONTA); + } + else + { + Result = NtGdiGetObject(Handle, Size, Buffer); + } + + return Result; +} + + +/* + * @unimplemented + */ +int +STDCALL +GetObjectW(HGDIOBJ Handle, int Size, LPVOID Buffer) +{ + return NtGdiGetObject(Handle, Size, Buffer); +} diff --git a/reactos/subsys/win32k/include/text.h b/reactos/subsys/win32k/include/text.h index ebb8afcc149..2dca5b27da2 100644 --- a/reactos/subsys/win32k/include/text.h +++ b/reactos/subsys/win32k/include/text.h @@ -5,6 +5,7 @@ BOOL FASTCALL InitFontSupport(VOID); BOOL FASTCALL IntIsFontRenderingEnabled(VOID); BOOL FASTCALL IntIsFontRenderingEnabled(VOID); VOID FASTCALL IntEnableFontRendering(BOOL Enable); +INT FASTCALL FontGetObject(PTEXTOBJ TextObj, INT Count, PVOID Buffer); #define IntLockProcessPrivateFonts(W32Process) \ ExAcquireFastMutex(&W32Process->PrivateFontListLock) diff --git a/reactos/subsys/win32k/objects/dc.c b/reactos/subsys/win32k/objects/dc.c index f0c8c23ebff..6733eb45118 100644 --- a/reactos/subsys/win32k/objects/dc.c +++ b/reactos/subsys/win32k/objects/dc.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: dc.c,v 1.124 2004/03/15 22:02:31 gvg Exp $ +/* $Id: dc.c,v 1.125 2004/03/23 19:46:50 gvg Exp $ * * DC.C - Device context functions * @@ -53,6 +53,7 @@ #include #include #include +#include #define NDEBUG #include @@ -1425,47 +1426,55 @@ DC_GET_VAL( INT, NtGdiGetMapMode, w.MapMode ) DC_GET_VAL( INT, NtGdiGetPolyFillMode, w.polyFillMode ) INT FASTCALL -IntGdiGetObject(HANDLE handle, INT count, LPVOID buffer) +IntGdiGetObject(HANDLE Handle, INT Count, LPVOID Buffer) { - PGDIOBJHDR gdiObject; - INT result = 0; - DWORD objectType; + PGDIOBJHDR GdiObject; + INT Result = 0; + DWORD ObjectType; - gdiObject = GDIOBJ_LockObj(handle, GDI_OBJECT_TYPE_DONTCARE); - if (gdiObject == 0) - return 0; + GdiObject = GDIOBJ_LockObj(Handle, GDI_OBJECT_TYPE_DONTCARE); + if (NULL == GdiObject) + { + return 0; + } - objectType = GDIOBJ_GetObjectType(handle); - switch(objectType) - { -/* case GDI_OBJECT_TYPE_PEN: - result = PEN_GetObject((PENOBJ *)gdiObject, count, buffer); - break; - case GDI_OBJECT_TYPE_BRUSH: - result = BRUSH_GetObject((BRUSHOBJ *)gdiObject, count, buffer); - break; */ - case GDI_OBJECT_TYPE_BITMAP: - result = BITMAP_GetObject((BITMAPOBJ *)gdiObject, count, buffer); - break; -/* case GDI_OBJECT_TYPE_FONT: - result = FONT_GetObjectW((FONTOBJ *)gdiObject, count, buffer); + ObjectType = GDIOBJ_GetObjectType(Handle); + switch (ObjectType) + { +#if 0 + case GDI_OBJECT_TYPE_PEN: + Result = PEN_GetObject((PENOBJ *) GdiObject, Count, Buffer); + break; + case GDI_OBJECT_TYPE_BRUSH: + Result = BRUSH_GetObject((BRUSHOBJ *) GdiObject, Count, Buffer); + break; +#endif + case GDI_OBJECT_TYPE_BITMAP: + Result = BITMAP_GetObject((BITMAPOBJ *) GdiObject, Count, Buffer); + break; + case GDI_OBJECT_TYPE_FONT: + Result = FontGetObject((PTEXTOBJ) GdiObject, Count, Buffer); +#if 0 + // Fix the LOGFONT structure for the stock fonts + if (FIRST_STOCK_HANDLE <= Handle && Handle <= LAST_STOCK_HANDLE) + { + FixStockFontSizeW(Handle, Count, Buffer); + } +#endif + break; +#if 0 + case GDI_OBJECT_TYPE_PALETTE: + Result = PALETTE_GetObject((PALETTEOBJ *) GdiObject, Count, Buffer); + break; +#endif + default: + DPRINT1("GDI object type 0x%08x not implemented\n", ObjectType); + break; + } - // Fix the LOGFONT structure for the stock fonts + GDIOBJ_UnlockObj(Handle, GDI_OBJECT_TYPE_DONTCARE); - if ( (handle >= FIRST_STOCK_HANDLE) && (handle <= LAST_STOCK_HANDLE) ) - FixStockFontSizeW(handle, count, buffer); - break; - case GDI_OBJECT_TYPE_PALETTE: - result = PALETTE_GetObject((PALETTEOBJ *)gdiObject, count, buffer); - break; */ - default: - DPRINT1("GDI object type 0x%08x not implemented\n", objectType); - break; - } - - GDIOBJ_UnlockObj(handle, GDI_OBJECT_TYPE_DONTCARE); - - return result; + return Result; } INT STDCALL diff --git a/reactos/subsys/win32k/objects/text.c b/reactos/subsys/win32k/objects/text.c index 505ab2525e2..450e7118899 100644 --- a/reactos/subsys/win32k/objects/text.c +++ b/reactos/subsys/win32k/objects/text.c @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: text.c,v 1.83 2004/03/23 07:59:47 gvg Exp $ */ +/* $Id: text.c,v 1.84 2004/03/23 19:46:50 gvg Exp $ */ #undef WIN32_LEAN_AND_MEAN @@ -2657,4 +2657,18 @@ TextIntRealizeFont(HFONT FontHandle) return Status; } +INT FASTCALL +FontGetObject(PTEXTOBJ Font, INT Count, PVOID Buffer) +{ + if (Count < sizeof(LOGFONTW)) + { + SetLastWin32Error(ERROR_BUFFER_OVERFLOW); + return 0; + } + + RtlCopyMemory(Buffer, &Font->logfont, sizeof(LOGFONTW)); + + return sizeof(LOGFONTW); +} + /* EOF */