mirror of
https://github.com/reactos/reactos.git
synced 2025-05-28 05:28:14 +00:00
Sorry again... NtGdiCreateEnhMetaFile will be converted to NtGdiCreateMetafileDC. Keeping the original code for now.
svn path=/trunk/; revision=33796
This commit is contained in:
parent
9adac31641
commit
1177ff923f
3 changed files with 9 additions and 361 deletions
|
@ -23,243 +23,6 @@
|
|||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
HENHMETAFILE
|
||||
STDCALL
|
||||
NtGdiCloseEnhMetaFile(HDC hDC)
|
||||
{
|
||||
LPENHMETAHEADER emh;
|
||||
HANDLE hmf = 0;
|
||||
PDD_ENHMETAFILEOBJ phmf;
|
||||
HANDLE hMapping = 0;
|
||||
EMREOF emr;
|
||||
PDC Dc;
|
||||
|
||||
IO_STATUS_BLOCK Iosb;
|
||||
NTSTATUS Status;
|
||||
|
||||
|
||||
|
||||
Dc = DC_LockDc(hDC);
|
||||
if (Dc == NULL)
|
||||
{
|
||||
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
emr.emr.iType = EMR_EOF;
|
||||
emr.emr.nSize = sizeof(EMREOF);
|
||||
emr.nPalEntries = 0;
|
||||
emr.offPalEntries = 0;
|
||||
emr.nSizeLast = emr.emr.nSize;
|
||||
|
||||
if(Dc->hFile)
|
||||
{
|
||||
Status = NtWriteFile(Dc->hFile, NULL, NULL, NULL, &Iosb, (PVOID)&emr, emr.emr.nSize, NULL, NULL);
|
||||
if (Status == STATUS_PENDING)
|
||||
{
|
||||
Status = NtWaitForSingleObject(Dc->hFile,FALSE,NULL);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Status = Iosb.Status;
|
||||
}
|
||||
}
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
DWORD len = Dc->emh->nBytes + emr.emr.nSize;
|
||||
/* always resize the buffer */
|
||||
emh = EngAllocMem(FL_ZERO_MEMORY, len, 0);
|
||||
if (emh != NULL)
|
||||
{
|
||||
memcpy(emh,Dc->emh,Dc->emh->nBytes);
|
||||
EngFreeMem(Dc->emh);
|
||||
Dc->emh = emh;
|
||||
|
||||
memcpy(Dc->emh + Dc->emh->nBytes, &emr, emr.emr.nSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
EngFreeMem(Dc->emh);
|
||||
Dc->emh=NULL;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Dc->hFile = NULL;
|
||||
DPRINT1("Write to EnhMetaFile fail\n");
|
||||
}
|
||||
}
|
||||
|
||||
Dc->emh->nBytes += emr.emr.nSize;
|
||||
Dc->emh->nRecords++;
|
||||
|
||||
if(Dc->emh->rclFrame.left > Dc->emh->rclFrame.right)
|
||||
{
|
||||
Dc->emh->rclFrame.left = Dc->emh->rclBounds.left * Dc->emh->szlMillimeters.cx * 100 / Dc->emh->szlDevice.cx;
|
||||
Dc->emh->rclFrame.top = Dc->emh->rclBounds.top * Dc->emh->szlMillimeters.cy * 100 / Dc->emh->szlDevice.cy;
|
||||
Dc->emh->rclFrame.right = Dc->emh->rclBounds.right * Dc->emh->szlMillimeters.cx * 100 / Dc->emh->szlDevice.cx;
|
||||
Dc->emh->rclFrame.bottom = Dc->emh->rclBounds.bottom * Dc->emh->szlMillimeters.cy * 100 / Dc->emh->szlDevice.cy;
|
||||
}
|
||||
|
||||
if (Dc->hFile) /* disk based metafile */
|
||||
{
|
||||
FILE_POSITION_INFORMATION FilePosition;
|
||||
LARGE_INTEGER Distance ;
|
||||
IO_STATUS_BLOCK IoStatusBlock;
|
||||
|
||||
POBJECT_ATTRIBUTES ObjectAttributes = NULL;
|
||||
ACCESS_MASK DesiredAccess;
|
||||
PLARGE_INTEGER SectionSize = NULL;
|
||||
DWORD flProtect;
|
||||
ULONG Attributes;
|
||||
LARGE_INTEGER SectionOffset;
|
||||
ULONG ViewSize;
|
||||
ULONG Protect;
|
||||
LPVOID ViewBase;
|
||||
|
||||
Distance.u.LowPart = 0;
|
||||
Distance.u.HighPart = 0;
|
||||
FilePosition.CurrentByteOffset.QuadPart = Distance.QuadPart;
|
||||
|
||||
DPRINT1("Trying write to metafile and map it\n");
|
||||
|
||||
Status = NtSetInformationFile(Dc->hFile, &IoStatusBlock, &FilePosition,
|
||||
sizeof(FILE_POSITION_INFORMATION), FilePositionInformation);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
// SetLastErrorByStatus(Status);
|
||||
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
||||
|
||||
NtClose( Dc->hFile );
|
||||
DC_UnlockDc(Dc);
|
||||
NtGdiDeleteObjectApp(hDC);
|
||||
|
||||
DPRINT1("NtSetInformationFile fail\n");
|
||||
return hmf;
|
||||
}
|
||||
|
||||
if (FilePosition.CurrentByteOffset.u.LowPart != 0)
|
||||
{
|
||||
// SetLastErrorByStatus(Status);
|
||||
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
||||
|
||||
NtClose( Dc->hFile );
|
||||
DC_UnlockDc(Dc);
|
||||
NtGdiDeleteObjectApp(hDC);
|
||||
DPRINT1("FilePosition.CurrentByteOffset.u.LowPart is not 0\n");
|
||||
return hmf;
|
||||
}
|
||||
|
||||
Status = NtWriteFile(Dc->hFile, NULL, NULL, NULL, &Iosb, (PVOID)&Dc->emh, sizeof(*Dc->emh), NULL, NULL);
|
||||
if (Status == STATUS_PENDING)
|
||||
{
|
||||
Status = NtWaitForSingleObject(Dc->hFile,FALSE,NULL);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Status = Iosb.Status;
|
||||
}
|
||||
}
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
NtClose( Dc->hFile );
|
||||
DC_UnlockDc(Dc);
|
||||
NtGdiDeleteObjectApp(hDC);
|
||||
DPRINT1("fail to write 0\n");
|
||||
return hmf;
|
||||
}
|
||||
|
||||
EngFreeMem(Dc->emh);
|
||||
|
||||
/* create maping */
|
||||
DesiredAccess = STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_READ;
|
||||
Attributes = (PAGE_READONLY & (SEC_FILE | SEC_IMAGE | SEC_RESERVE | SEC_NOCACHE | SEC_COMMIT));
|
||||
flProtect = PAGE_READONLY ^ (PAGE_READONLY & (SEC_FILE | SEC_IMAGE | SEC_RESERVE | SEC_NOCACHE | SEC_COMMIT));
|
||||
|
||||
if (!Attributes) Attributes = SEC_COMMIT;
|
||||
|
||||
if (Dc->hFile == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
Dc->hFile = NULL;
|
||||
if (!SectionSize)
|
||||
{
|
||||
SetLastWin32Error(ERROR_INVALID_PARAMETER);
|
||||
hMapping = NULL;
|
||||
DPRINT1("fail !SectionSize \n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Status = NtCreateSection(&hMapping, DesiredAccess, ObjectAttributes, SectionSize, flProtect, Attributes, Dc->hFile);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
//SetLastErrorByStatus(Status);
|
||||
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
||||
hMapping = NULL;
|
||||
DPRINT1("fail NtCreateSection \n");
|
||||
}
|
||||
}
|
||||
|
||||
/* MapViewOfFile */
|
||||
SectionOffset.LowPart = 0;
|
||||
SectionOffset.HighPart = 0;
|
||||
ViewBase = NULL;
|
||||
ViewSize = 0;
|
||||
|
||||
Protect = PAGE_READONLY;
|
||||
|
||||
Status = ZwMapViewOfSection(&hMapping, NtCurrentProcess(), &ViewBase, 0,
|
||||
0, &SectionOffset, &ViewSize, ViewShare, 0, Protect);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
//SetLastErrorByStatus(Status);
|
||||
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
||||
Dc->emh = NULL;
|
||||
DPRINT1("fail ZwMapViewOfSection \n");
|
||||
}
|
||||
else
|
||||
{
|
||||
Dc->emh = ViewBase;
|
||||
}
|
||||
/* Close */
|
||||
if (hMapping != NULL)
|
||||
NtClose( hMapping );
|
||||
if (Dc->hFile != NULL)
|
||||
NtClose( Dc->hFile );
|
||||
}
|
||||
|
||||
phmf = GDIOBJ_AllocObjWithHandle(GdiHandleTable, GDI_OBJECT_TYPE_ENHMETAFILE);
|
||||
if (phmf != NULL)
|
||||
{
|
||||
hmf = phmf->BaseObject.hHmgr;
|
||||
if (Dc->hFile != NULL)
|
||||
{
|
||||
phmf->on_disk = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
phmf->on_disk = FALSE;
|
||||
}
|
||||
phmf->emh = Dc->emh;
|
||||
GDIOBJ_UnlockObjByPtr(GdiHandleTable, phmf);
|
||||
}
|
||||
|
||||
Dc->emh = NULL; /* So it won't be deleted */
|
||||
DC_UnlockDc(Dc);
|
||||
NtGdiDeleteObjectApp(hDC);
|
||||
return hmf;
|
||||
}
|
||||
|
||||
HENHMETAFILE
|
||||
STDCALL
|
||||
NtGdiCopyEnhMetaFile(HENHMETAFILE Src,
|
||||
LPCWSTR File)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
|
@ -268,11 +31,14 @@ NtGdiCopyEnhMetaFile(HENHMETAFILE Src,
|
|||
//
|
||||
HDC
|
||||
STDCALL
|
||||
NtGdiCreateEnhMetaFile(HDC hDCRef,
|
||||
LPCWSTR File,
|
||||
CONST LPRECT Rect,
|
||||
LPCWSTR Description)
|
||||
NtGdiCreateMetafileDC(IN HDC hdc)
|
||||
{
|
||||
|
||||
UNIMPLEMENTED;
|
||||
return NULL;
|
||||
|
||||
|
||||
#if 0
|
||||
PDC Dc;
|
||||
HDC ret = NULL;
|
||||
DWORD length = 0;
|
||||
|
@ -467,114 +233,8 @@ NtGdiCreateEnhMetaFile(HDC hDCRef,
|
|||
}
|
||||
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiDeleteEnhMetaFile(HENHMETAFILE emf)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiEnumEnhMetaFile(HDC hDC,
|
||||
HENHMETAFILE emf,
|
||||
ENHMFENUMPROC EnhMetaFunc,
|
||||
LPVOID Data,
|
||||
CONST LPRECT Rect)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiGdiComment(HDC hDC,
|
||||
UINT Size,
|
||||
CONST LPBYTE Data)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
HENHMETAFILE
|
||||
STDCALL
|
||||
NtGdiGetEnhMetaFile(LPCWSTR MetaFile)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT
|
||||
STDCALL
|
||||
NtGdiGetEnhMetaFileBits(HENHMETAFILE hemf,
|
||||
UINT BufSize,
|
||||
LPBYTE Buffer)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT
|
||||
STDCALL
|
||||
NtGdiGetEnhMetaFileDescription(HENHMETAFILE hemf,
|
||||
UINT BufSize,
|
||||
LPWSTR Description)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT
|
||||
STDCALL
|
||||
NtGdiGetEnhMetaFileHeader(HENHMETAFILE hemf,
|
||||
UINT BufSize,
|
||||
LPENHMETAHEADER emh)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT
|
||||
STDCALL
|
||||
NtGdiGetEnhMetaFilePaletteEntries(HENHMETAFILE hemf,
|
||||
UINT Entries,
|
||||
LPPALETTEENTRY pe)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiPlayEnhMetaFile(HDC hDC,
|
||||
HENHMETAFILE hemf,
|
||||
CONST PRECT Rect)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtGdiPlayEnhMetaFileRecord(HDC hDC,
|
||||
LPHANDLETABLE Handletable,
|
||||
CONST ENHMETARECORD *EnhMetaRecord,
|
||||
UINT Handles)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
HENHMETAFILE
|
||||
STDCALL
|
||||
NtGdiSetEnhMetaFileBits(UINT BufSize,
|
||||
CONST PBYTE Data)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -1665,19 +1665,6 @@ NtGdiCreateServerMetaFile(
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
|
||||
HDC
|
||||
APIENTRY
|
||||
NtGdiCreateMetafileDC(IN HDC hdc)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
|
|
|
@ -160,6 +160,7 @@
|
|||
<file>gdiobj.c</file>
|
||||
<file>icm.c</file>
|
||||
<file>line.c</file>
|
||||
<file>metafile.c</file>
|
||||
<file>palobj.c</file>
|
||||
<file>path.c</file>
|
||||
<file>pen.c</file>
|
||||
|
|
Loading…
Reference in a new issue