The following C++ code places an enhanced metafile onto the clipboard, which can then be pasted into powerpoint, wordpad, paint, LO impress, etc. The LO internal drawing functions seem to skip some of the metafile records or misinterpret them resulting in image corruption, the other aforementioned applications handle it correctly. void DrawMetafile(HWND hWnd) { HDC RefDC; RefDC = ::GetDC(hWnd); RECT TrueSize = {0, 0, 256, 256};//{100, 100, 356, 356}; int iWidthMM = ::GetDeviceCaps(RefDC, HORZSIZE); int iHeightMM = ::GetDeviceCaps(RefDC, VERTSIZE); int iWidthPels = ::GetDeviceCaps(RefDC, HORZRES); int iHeightPels = ::GetDeviceCaps(RefDC, VERTRES); RECT MetaSize; MetaSize.left = ::MulDiv(TrueSize.left, iWidthMM * 100 * 96, iWidthPels * 96); MetaSize.top = ::MulDiv(TrueSize.top, iHeightMM * 100 * 96, iHeightPels * 96); MetaSize.right = ::MulDiv(TrueSize.right, iWidthMM * 100* 96, iWidthPels * 96); MetaSize.bottom = ::MulDiv(TrueSize.bottom, iHeightMM * 100* 96, iHeightPels * 96); HDC MetaDC = ::CreateEnhMetaFile(RefDC, NULL, &MetaSize, TEXT("Bug Demo.")); ::ReleaseDC(hWnd, RefDC); ::FillRect(MetaDC, &TrueSize, ::GetSysColorBrush(COLOR_WINDOW)); HBRUSH Black = ::CreateSolidBrush(0x00000000); HBRUSH Red = ::CreateSolidBrush(0x000000FF); HBRUSH Green = ::CreateSolidBrush(0x0000FF00); HBRUSH Blue = ::CreateSolidBrush(0x00FF0000); RECT SubRc = {16, 16, 48, 48}; // Fill everything with red, excluse a small rect, then fill everything with black // Should leave a small red rectangle... ::FillRect(MetaDC, &SubRc, Red); // Following clip code is ignored in libreoffice ::ExcludeClipRect(MetaDC, SubRc.left, SubRc.top, SubRc.right, SubRc.bottom); ::FillRect(MetaDC, &TrueSize, Black); ::OffsetRect(&SubRc, 192, 0); // Fill a small rectangle with blue, limit clipping to this small rect, and fill everything with green // should leave a small green rectangle with everything else still black ::FillRect(MetaDC, &SubRc, Blue); // Following clip code leaves weird borders in libreoffice ::IntersectClipRect(MetaDC, SubRc.left, SubRc.top, SubRc.right, SubRc.bottom); ::FillRect(MetaDC, &TrueSize, Green); // Limit clipping to bottom half of image for third bug // Then we fill it with blue, set a transformation, modify and restore clip rectangle, and // fill everything with green. Should leave a solid green rectangle, but apparently // world transformation does not update the selected clipping rectangle in both directions HRGN Temp = ::CreateRectRgn(0, 128, 256, 256); ::SelectClipRgn(MetaDC, Temp); ::DeleteObject(Temp); ::FillRect(MetaDC, &TrueSize, Blue); XFORM stX, oldstX; ZeroMemory(&stX,sizeof(stX)); stX.eM11 = 0.25; stX.eM22 = 0.25; stX.eDy = 128; BOOL HadXform = ::GetWorldTransform(MetaDC, &oldstX); ModifyWorldTransform(MetaDC, &stX, MWT_LEFTMULTIPLY); HRGN OldClip = ::CreateRectRgn(0, 0, 1, 1); ::GetClipRgn(MetaDC, OldClip); // Setting the clip region we just retrieved leads to a different clip region being selected... ::SelectClipRgn(MetaDC, OldClip); ::DeleteObject(OldClip); if (HadXform) ::SetWorldTransform(MetaDC, &oldstX); else { XFORM DefXForm = {0}; DefXForm.eM11 = DefXForm.eM22 = 1.0; ::SetWorldTransform(MetaDC, &DefXForm); } ::FillRect(MetaDC, &TrueSize, Green); ::DeleteObject(Black); ::DeleteObject(Red); ::DeleteObject(Green); ::DeleteObject(Blue); HENHMETAFILE MetaFile = ::CloseEnhMetaFile(MetaDC); ENHMETAHEADER Header = {EMR_HEADER, sizeof(ENHMETAHEADER)}; ::GetEnhMetaFileHeader(MetaFile, sizeof(ENHMETAHEADER), &Header); ::OpenClipboard(hWnd); ::EmptyClipboard(); ::SetClipboardData(CF_ENHMETAFILE, MetaFile); ::CloseClipboard(); }
@Thorsten: Could you take a look at it? Is this maybe something for you?
(In reply to comment #0) > The following C++ code places an enhanced metafile onto the > clipboard... > Can you quickly attach the EMF, easier for me than getting your code to run here? ;)
** Please read this message in its entirety before responding ** To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year. There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present. If you have time, please do the following: Test to see if the bug is still present on a currently supported version of LibreOffice (4.4.1.2 or later): https://www.libreoffice.org/download/ If the bug is present, please leave a comment that includes the version of LibreOffice and your operating system, and any changes you see in the bug behavior If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a short comment that includes your version of LibreOffice and Operating System Please DO NOT Update the version field Reply via email (please reply directly on the bug tracker) Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not appropriate in this case) Thank you for your help! -- The LibreOffice QA Team This NEW Message was generated on: 2015-03-03
No answer from reporter since 2 years --> closing as INVALID @reporter: Please, feel free to reopen if you are willing to answer the question in comment #2 (attach the EMF file). Best regards. JBF
Conversion code fails to properly adjust clipping rectangles when coordinate transformations are set. With changing in these clipping you mostly see biggest https://assignmentman.co.uk/ rectangles in you so now you can save photo and then everything you can see after sometime which show you how it is change with time.
I am first time visiting here and I am so excited to find this blog because I belong to the UK and marketing for https://www.theacademicpapers.co.uk/masters-dissertation-help.php which is a writing company in the UK students who are completing their study.