winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
February 2010
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
2 participants
783 discussions
Start a n
N
ew thread
Dylan Smith : wordpad: Avoid unnecessary deletion of hdcSized.
by Alexandre Julliard
22 Feb '10
22 Feb '10
Module: wine Branch: master Commit: f235c48cae7cf27c5e5a44972856f1ce6caf2c8b URL:
http://source.winehq.org/git/wine.git/?a=commit;h=f235c48cae7cf27c5e5a44972…
Author: Dylan Smith <dylan.ah.smith(a)gmail.com> Date: Mon Feb 22 03:18:29 2010 -0500 wordpad: Avoid unnecessary deletion of hdcSized. --- programs/wordpad/print.c | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) diff --git a/programs/wordpad/print.c b/programs/wordpad/print.c index 868f992..5c679ea 100644 --- a/programs/wordpad/print.c +++ b/programs/wordpad/print.c @@ -927,16 +927,20 @@ LRESULT CALLBACK ruler_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) static void draw_preview_page(HDC hdc, HDC* hdcSized, FORMATRANGE* lpFr, float ratio, int bmNewWidth, int bmNewHeight, int bmWidth, int bmHeight) { HBITMAP hBitmapScaled = CreateCompatibleBitmap(hdc, bmNewWidth, bmNewHeight); + HBITMAP oldbm; HPEN hPen, oldPen; int TopMargin = (int)((float)twips_to_pixels(lpFr->rc.top, GetDeviceCaps(hdc, LOGPIXELSX)) * ratio); int BottomMargin = (int)((float)twips_to_pixels(lpFr->rc.bottom, GetDeviceCaps(hdc, LOGPIXELSX)) * ratio); int LeftMargin = (int)((float)twips_to_pixels(lpFr->rc.left, GetDeviceCaps(hdc, LOGPIXELSY)) * ratio); int RightMargin = (int)((float)twips_to_pixels(lpFr->rc.right, GetDeviceCaps(hdc, LOGPIXELSY)) * ratio); - if(*hdcSized) - DeleteDC(*hdcSized); - *hdcSized = CreateCompatibleDC(hdc); - SelectObject(*hdcSized, hBitmapScaled); + if(*hdcSized) { + oldbm = SelectObject(*hdcSized, hBitmapScaled); + DeleteObject(oldbm); + } else { + *hdcSized = CreateCompatibleDC(hdc); + SelectObject(*hdcSized, hBitmapScaled); + } StretchBlt(*hdcSized, 0, 0, bmNewWidth, bmNewHeight, hdc, 0, 0, bmWidth, bmHeight, SRCCOPY);
1
0
0
0
Dylan Smith : wordpad: Cache text length.
by Alexandre Julliard
22 Feb '10
22 Feb '10
Module: wine Branch: master Commit: 8f19111325bc49bd17f2e5e78f75c9d105f7898a URL:
http://source.winehq.org/git/wine.git/?a=commit;h=8f19111325bc49bd17f2e5e78…
Author: Dylan Smith <dylan.ah.smith(a)gmail.com> Date: Mon Feb 22 03:18:23 2010 -0500 wordpad: Cache text length. --- programs/wordpad/print.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/programs/wordpad/print.c b/programs/wordpad/print.c index 0dfce24..868f992 100644 --- a/programs/wordpad/print.c +++ b/programs/wordpad/print.c @@ -30,6 +30,7 @@ typedef struct _previewinfo int pages; int pages_shown; int *pageEnds, pageCapacity; + int textlength; HDC hdc; HDC hdc2; HDC hdcSized; @@ -638,10 +639,12 @@ LRESULT CALLBACK preview_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) preview.bmSize.cx = twips_to_pixels(preview.rcPage.right, GetDeviceCaps(hdc, LOGPIXELSX)); preview.bmSize.cy = twips_to_pixels(preview.rcPage.bottom, GetDeviceCaps(hdc, LOGPIXELSY)); + preview.textlength = SendMessageW(hEditorWnd, EM_GETTEXTLENGTHEX, (WPARAM)>, 0); + fr.hdc = CreateCompatibleDC(hdc); fr.hdcTarget = hdcTarget; fr.chrg.cpMin = 0; - fr.chrg.cpMax = SendMessageW(hEditorWnd, EM_GETTEXTLENGTHEX, (WPARAM)>, 0); + fr.chrg.cpMax = preview.textlength; preview.pages = get_num_pages(hEditorWnd, fr); DeleteDC(fr.hdc); DeleteDC(hdcTarget); @@ -1031,7 +1034,6 @@ LRESULT print_preview(HWND hwndPreview) /* Update for page changes. */ static void update_preview(HWND hMainWnd) { - GETTEXTLENGTHEX gt; RECT paper; HWND hEditorWnd = GetDlgItem(hMainWnd, IDC_EDITOR); HWND hwndPreview = GetDlgItem(hMainWnd, IDC_PREVIEW); @@ -1046,10 +1048,8 @@ static void update_preview(HWND hMainWnd) fr.rc.bottom -= margins.bottom; fr.rc.right -= margins.right; - gt.flags = GTL_DEFAULT; - gt.codepage = 1200; fr.chrg.cpMin = 0; - fr.chrg.cpMax = SendMessageW(hEditorWnd, EM_GETTEXTLENGTHEX, (WPARAM)>, 0); + fr.chrg.cpMax = preview.textlength; paper.left = 0; paper.right = preview.bmSize.cx;
1
0
0
0
Dylan Smith : wordpad: Update bitmaps outside of WM_PAINT.
by Alexandre Julliard
22 Feb '10
22 Feb '10
Module: wine Branch: master Commit: 7a9f72863df0820f484060ed98ba7225d6cb7f5d URL:
http://source.winehq.org/git/wine.git/?a=commit;h=7a9f72863df0820f484060ed9…
Author: Dylan Smith <dylan.ah.smith(a)gmail.com> Date: Mon Feb 22 03:18:18 2010 -0500 wordpad: Update bitmaps outside of WM_PAINT. This avoids having to delete the device context and the bitmap selected into it just to update the bitmap, since it was setting preview.hdc to NULL to indicate that these bitmaps needed to be updated. This patch also helps make WM_PAINT messages get processed faster by moving this out of the code for handling WM_PAINT. --- programs/wordpad/print.c | 179 ++++++++++++++++++++++++++++------------------ 1 files changed, 110 insertions(+), 69 deletions(-) diff --git a/programs/wordpad/print.c b/programs/wordpad/print.c index 45c112e..0dfce24 100644 --- a/programs/wordpad/print.c +++ b/programs/wordpad/print.c @@ -578,21 +578,52 @@ static void update_preview_sizes(HWND hwndPreview, BOOL zoomLevelUpdated) update_preview_scrollbars(hwndPreview, &window); } +static void draw_preview_page(HDC hdc, HDC* hdcSized, FORMATRANGE* lpFr, float ratio, int bmNewWidth, int bmNewHeight, int bmWidth, int bmHeight); + /* Update for zoom ratio changes with same page. */ static void update_scaled_preview(HWND hMainWnd) { - HWND hwndPreview = GetDlgItem(hMainWnd, IDC_PREVIEW); - preview.window.right = 0; + FORMATRANGE fr; + HWND hwndPreview; + + /* This may occur on WM_CREATE before update_preview is called + * because a WM_SIZE message is generated from updating the + * scrollbars. */ + if (!preview.hdc) return; + + hwndPreview = GetDlgItem(hMainWnd, IDC_PREVIEW); + fr.hdcTarget = make_dc(); + fr.rc = fr.rcPage = preview.rcPage; + fr.rc.left += margins.left; + fr.rc.top += margins.top; + fr.rc.bottom -= margins.bottom; + fr.rc.right -= margins.right; + + draw_preview_page(preview.hdc, &preview.hdcSized, &fr, preview.zoomratio, + preview.bmScaledSize.cx, preview.bmScaledSize.cy, + preview.bmSize.cx, preview.bmSize.cy); + + if(preview.pages_shown > 1) + { + draw_preview_page(preview.hdc2, &preview.hdcSized2, &fr, preview.zoomratio, + preview.bmScaledSize.cx, preview.bmScaledSize.cy, + preview.bmSize.cx, preview.bmSize.cy); + } + InvalidateRect(hwndPreview, NULL, TRUE); + DeleteDC(fr.hdcTarget); } +static void update_preview(HWND hMainWnd); + LRESULT CALLBACK preview_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CREATE: { - HWND hEditorWnd = GetDlgItem(GetParent(hWnd), IDC_EDITOR); + HWND hMainWnd = GetParent(hWnd); + HWND hEditorWnd = GetDlgItem(hMainWnd, IDC_EDITOR); FORMATRANGE fr; GETTEXTLENGTHEX gt = {GTL_DEFAULT, 1200}; HDC hdc = GetDC(hWnd); @@ -617,6 +648,7 @@ LRESULT CALLBACK preview_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) ReleaseDC(hWnd, hdc); update_preview_sizes(hWnd, TRUE); + update_preview(hMainWnd); break; } @@ -716,6 +748,30 @@ void close_preview(HWND hMainWnd) HeapFree(GetProcessHeap(), 0, preview.pageEnds); preview.pageEnds = NULL; preview.pageCapacity = 0; + if(preview.hdc) { + HBITMAP oldbm = GetCurrentObject(preview.hdc, OBJ_BITMAP); + DeleteDC(preview.hdc); + DeleteObject(oldbm); + preview.hdc = NULL; + } + if(preview.hdc2) { + HBITMAP oldbm = GetCurrentObject(preview.hdc2, OBJ_BITMAP); + DeleteDC(preview.hdc2); + DeleteObject(oldbm); + preview.hdc2 = NULL; + } + if(preview.hdcSized) { + HBITMAP oldbm = GetCurrentObject(preview.hdcSized, OBJ_BITMAP); + DeleteDC(preview.hdcSized); + DeleteObject(oldbm); + preview.hdcSized = NULL; + } + if(preview.hdcSized2) { + HBITMAP oldbm = GetCurrentObject(preview.hdcSized2, OBJ_BITMAP); + DeleteDC(preview.hdcSized2); + DeleteObject(oldbm); + preview.hdcSized2 = NULL; + } preview_bar_show(hMainWnd, FALSE); DestroyWindow(hwndPreview); @@ -926,63 +982,14 @@ static void update_preview_buttons(HWND hMainWnd) LRESULT print_preview(HWND hwndPreview) { - FORMATRANGE fr; HDC hdc; RECT window, background; PAINTSTRUCT ps; - HWND hMainWnd = GetParent(hwndPreview); POINT scrollpos; hdc = BeginPaint(hwndPreview, &ps); GetClientRect(hwndPreview, &window); - fr.hdcTarget = make_dc(); - fr.rc = fr.rcPage = preview.rcPage; - fr.rc.left += margins.left; - fr.rc.top += margins.top; - fr.rc.bottom -= margins.bottom; - fr.rc.right -= margins.right; - - if(!preview.hdc) - { - GETTEXTLENGTHEX gt; - RECT paper; - HWND hEditorWnd = GetDlgItem(hMainWnd, IDC_EDITOR); - HBITMAP hBitmapCapture; - - gt.flags = GTL_DEFAULT; - gt.codepage = 1200; - fr.chrg.cpMin = 0; - fr.chrg.cpMax = SendMessageW(hEditorWnd, EM_GETTEXTLENGTHEX, (WPARAM)>, 0); - - paper.left = 0; - paper.right = preview.bmSize.cx; - paper.top = 0; - paper.bottom = preview.bmSize.cy; - - fr.hdc = preview.hdc = CreateCompatibleDC(hdc); - hBitmapCapture = CreateCompatibleBitmap(hdc, preview.bmSize.cx, preview.bmSize.cy); - SelectObject(fr.hdc, hBitmapCapture); - draw_preview(hEditorWnd, &fr, &paper, preview.page); - - if(preview.pages_shown > 1) - { - if (!preview.hdc2) - { - preview.hdc2 = CreateCompatibleDC(hdc); - hBitmapCapture = CreateCompatibleBitmap(hdc, - preview.bmSize.cx, - preview.bmSize.cy); - SelectObject(preview.hdc2, hBitmapCapture); - } - - fr.hdc = preview.hdc2; - draw_preview(hEditorWnd, &fr, &fr.rcPage, preview.page + 1); - } - - update_preview_buttons(hMainWnd); - } - FillRect(hdc, &window, GetStockObject(GRAY_BRUSH)); scrollpos.x = GetScrollPos(hwndPreview, SB_HORZ); @@ -1003,20 +1010,6 @@ LRESULT print_preview(HWND hwndPreview) FillRect(hdc, &background, GetStockObject(BLACK_BRUSH)); } - if(window.right != preview.window.right || window.bottom != preview.window.bottom) - { - draw_preview_page(preview.hdc, &preview.hdcSized, &fr, preview.zoomratio, - preview.bmScaledSize.cx, preview.bmScaledSize.cy, - preview.bmSize.cx, preview.bmSize.cy); - - if(preview.pages_shown > 1) - { - draw_preview_page(preview.hdc2, &preview.hdcSized2, &fr, preview.zoomratio, - preview.bmScaledSize.cx, preview.bmScaledSize.cy, - preview.bmSize.cx, preview.bmSize.cy); - } - } - BitBlt(hdc, preview.spacing.cx - scrollpos.x, preview.spacing.cy - scrollpos.y, preview.bmScaledSize.cx, preview.bmScaledSize.cy, preview.hdcSized, 0, 0, SRCCOPY); @@ -1028,7 +1021,6 @@ LRESULT print_preview(HWND hwndPreview) preview.bmScaledSize.cy, preview.hdcSized2, 0, 0, SRCCOPY); } - DeleteDC(fr.hdcTarget); preview.window = window; EndPaint(hwndPreview, &ps); @@ -1039,10 +1031,59 @@ LRESULT print_preview(HWND hwndPreview) /* Update for page changes. */ static void update_preview(HWND hMainWnd) { - DeleteDC(preview.hdc); - preview.hdc = 0; + GETTEXTLENGTHEX gt; + RECT paper; + HWND hEditorWnd = GetDlgItem(hMainWnd, IDC_EDITOR); + HWND hwndPreview = GetDlgItem(hMainWnd, IDC_PREVIEW); + HBITMAP hBitmapCapture; + FORMATRANGE fr; + HDC hdc = GetDC(hwndPreview); + + fr.hdcTarget = make_dc(); + fr.rc = fr.rcPage = preview.rcPage; + fr.rc.left += margins.left; + fr.rc.top += margins.top; + fr.rc.bottom -= margins.bottom; + fr.rc.right -= margins.right; + + gt.flags = GTL_DEFAULT; + gt.codepage = 1200; + fr.chrg.cpMin = 0; + fr.chrg.cpMax = SendMessageW(hEditorWnd, EM_GETTEXTLENGTHEX, (WPARAM)>, 0); + + paper.left = 0; + paper.right = preview.bmSize.cx; + paper.top = 0; + paper.bottom = preview.bmSize.cy; + + if (!preview.hdc) { + preview.hdc = CreateCompatibleDC(hdc); + hBitmapCapture = CreateCompatibleBitmap(hdc, preview.bmSize.cx, preview.bmSize.cy); + SelectObject(preview.hdc, hBitmapCapture); + } + + fr.hdc = preview.hdc; + draw_preview(hEditorWnd, &fr, &paper, preview.page); + + if(preview.pages_shown > 1) + { + if (!preview.hdc2) + { + preview.hdc2 = CreateCompatibleDC(hdc); + hBitmapCapture = CreateCompatibleBitmap(hdc, + preview.bmSize.cx, + preview.bmSize.cy); + SelectObject(preview.hdc2, hBitmapCapture); + } + + fr.hdc = preview.hdc2; + draw_preview(hEditorWnd, &fr, &fr.rcPage, preview.page + 1); + } + DeleteDC(fr.hdcTarget); + ReleaseDC(hwndPreview, hdc); update_scaled_preview(hMainWnd); + update_preview_buttons(hMainWnd); } static void toggle_num_pages(HWND hMainWnd)
1
0
0
0
Dylan Smith : wordpad: Use pages_shown variables to indicate pages shown.
by Alexandre Julliard
22 Feb '10
22 Feb '10
Module: wine Branch: master Commit: a75bf390d70e9b0667c1dd6ea6f7b2c792f600eb URL:
http://source.winehq.org/git/wine.git/?a=commit;h=a75bf390d70e9b0667c1dd6ea…
Author: Dylan Smith <dylan.ah.smith(a)gmail.com> Date: Mon Feb 22 03:18:11 2010 -0500 wordpad: Use pages_shown variables to indicate pages shown. Previously hdc2 needed to be deleted and set to NULL to indicate that only one page should be shown. I have avoided this using a new variable for the preview structure. The device context were also being deleted without deleting the bitmaps created for them and selected into them, so this patch also gets these bitmaps and deletes them with their device context. --- programs/wordpad/print.c | 72 +++++++++++++++++++++------------------------- 1 files changed, 33 insertions(+), 39 deletions(-) diff --git a/programs/wordpad/print.c b/programs/wordpad/print.c index faf9439..45c112e 100644 --- a/programs/wordpad/print.c +++ b/programs/wordpad/print.c @@ -28,6 +28,7 @@ typedef struct _previewinfo { int page; int pages; + int pages_shown; int *pageEnds, pageCapacity; HDC hdc; HDC hdc2; @@ -519,10 +520,8 @@ static void update_preview_scrollbars(HWND hwndPreview, RECT *window) sbi.nPage = window->bottom; SetScrollInfo(hwndPreview, SB_VERT, &sbi, TRUE); } else { - if (!preview.hdc2) - sbi.nMax = preview.bmScaledSize.cx + min_spacing * 2; - else - sbi.nMax = preview.bmScaledSize.cx * 2 + min_spacing * 3; + sbi.nMax = preview.bmScaledSize.cx * preview.pages_shown + + min_spacing * (preview.pages_shown + 1); sbi.nPage = window->right; SetScrollInfo(hwndPreview, SB_HORZ, &sbi, TRUE); /* Change in the horizontal scrollbar visibility affects the @@ -550,10 +549,9 @@ static void update_preview_sizes(HWND hwndPreview, BOOL zoomLevelUpdated) } else { ratioHeight = (window.bottom - min_spacing * 2) / (float)preview.bmSize.cy; - if(preview.hdc2) - ratioWidth = ((window.right - min_spacing * 3) / 2.0) / (float)preview.bmSize.cx; - else - ratioWidth = (window.right - min_spacing * 2) / (float)preview.bmSize.cx; + ratioWidth = (float)(window.right - + min_spacing * (preview.pages_shown + 1)) / + (preview.pages_shown * preview.bmSize.cx); if(ratioWidth > ratioHeight) ratio = ratioHeight; @@ -571,10 +569,9 @@ static void update_preview_sizes(HWND hwndPreview, BOOL zoomLevelUpdated) preview.spacing.cy = max(min_spacing, (window.bottom - preview.bmScaledSize.cy) / 2); - if(!preview.hdc2) - preview.spacing.cx = (window.right - preview.bmScaledSize.cx) / 2; - else - preview.spacing.cx = (window.right - preview.bmScaledSize.cx * 2) / 3; + preview.spacing.cx = (window.right - + preview.bmScaledSize.cx * preview.pages_shown) / + (preview.pages_shown + 1); if (preview.spacing.cx < min_spacing) preview.spacing.cx = min_spacing; @@ -702,6 +699,7 @@ void init_preview(HWND hMainWnd, LPWSTR wszFileName) preview.zoomratio = 0; preview.zoomlevel = 0; preview_bar_show(hMainWnd, TRUE); + if (preview.pages_shown < 1) preview.pages_shown = 1; hwndPreview = CreateWindowExW(0, wszPreviewWndClass, NULL, WS_VISIBLE | WS_CHILD | WS_VSCROLL | WS_HSCROLL, @@ -919,9 +917,8 @@ static void update_preview_buttons(HWND hMainWnd) { HWND hReBar = GetDlgItem(hMainWnd, IDC_REBAR); EnableWindow(GetDlgItem(hReBar, ID_PREVIEW_PREVPAGE), preview.page > 1); - EnableWindow(GetDlgItem(hReBar, ID_PREVIEW_NEXTPAGE), preview.hdc2 ? - (preview.page + 1) < preview.pages : - preview.page < preview.pages); + EnableWindow(GetDlgItem(hReBar, ID_PREVIEW_NEXTPAGE), + preview.page + preview.pages_shown - 1 < preview.pages); EnableWindow(GetDlgItem(hReBar, ID_PREVIEW_NUMPAGES), preview.pages > 1 && preview.zoomlevel == 0); EnableWindow(GetDlgItem(hReBar, ID_PREVIEW_ZOOMIN), preview.zoomlevel < 2); EnableWindow(GetDlgItem(hReBar, ID_PREVIEW_ZOOMOUT), preview.zoomlevel > 0); @@ -953,15 +950,6 @@ LRESULT print_preview(HWND hwndPreview) HWND hEditorWnd = GetDlgItem(hMainWnd, IDC_EDITOR); HBITMAP hBitmapCapture; - preview.hdc = CreateCompatibleDC(hdc); - - if(preview.hdc2) - { - if(preview.hdc2 != (HDC)-1) - DeleteDC(preview.hdc2); - preview.hdc2 = CreateCompatibleDC(hdc); - } - gt.flags = GTL_DEFAULT; gt.codepage = 1200; fr.chrg.cpMin = 0; @@ -972,16 +960,23 @@ LRESULT print_preview(HWND hwndPreview) paper.top = 0; paper.bottom = preview.bmSize.cy; - fr.hdc = preview.hdc; + fr.hdc = preview.hdc = CreateCompatibleDC(hdc); hBitmapCapture = CreateCompatibleBitmap(hdc, preview.bmSize.cx, preview.bmSize.cy); SelectObject(fr.hdc, hBitmapCapture); draw_preview(hEditorWnd, &fr, &paper, preview.page); - if(preview.hdc2) + if(preview.pages_shown > 1) { + if (!preview.hdc2) + { + preview.hdc2 = CreateCompatibleDC(hdc); + hBitmapCapture = CreateCompatibleBitmap(hdc, + preview.bmSize.cx, + preview.bmSize.cy); + SelectObject(preview.hdc2, hBitmapCapture); + } + fr.hdc = preview.hdc2; - hBitmapCapture = CreateCompatibleBitmap(hdc, preview.bmSize.cx, preview.bmSize.cy); - SelectObject(fr.hdc, hBitmapCapture); draw_preview(hEditorWnd, &fr, &fr.rcPage, preview.page + 1); } @@ -1000,7 +995,7 @@ LRESULT print_preview(HWND hwndPreview) FillRect(hdc, &background, GetStockObject(BLACK_BRUSH)); - if(preview.hdc2) + if(preview.pages_shown > 1) { background.left += preview.bmScaledSize.cx + preview.spacing.cx; background.right += preview.bmScaledSize.cx + preview.spacing.cx; @@ -1014,7 +1009,7 @@ LRESULT print_preview(HWND hwndPreview) preview.bmScaledSize.cx, preview.bmScaledSize.cy, preview.bmSize.cx, preview.bmSize.cy); - if(preview.hdc2) + if(preview.pages_shown > 1) { draw_preview_page(preview.hdc2, &preview.hdcSized2, &fr, preview.zoomratio, preview.bmScaledSize.cx, preview.bmScaledSize.cy, @@ -1026,7 +1021,7 @@ LRESULT print_preview(HWND hwndPreview) preview.bmScaledSize.cx, preview.bmScaledSize.cy, preview.hdcSized, 0, 0, SRCCOPY); - if(preview.hdc2) + if(preview.pages_shown > 1) { BitBlt(hdc, preview.spacing.cx * 2 + preview.bmScaledSize.cx - scrollpos.x, preview.spacing.cy - scrollpos.y, preview.bmScaledSize.cx, @@ -1056,18 +1051,17 @@ static void toggle_num_pages(HWND hMainWnd) WCHAR name[MAX_STRING_LEN]; HINSTANCE hInst = GetModuleHandleW(0); - if(preview.hdc2) - { - DeleteDC(preview.hdc2); - preview.hdc2 = 0; - } else + if(preview.pages_shown > 1) { + preview.pages_shown = 1; + } else { if(preview.page == preview.pages) preview.page--; - preview.hdc2 = (HDC)-1; + preview.pages_shown = 2; } - LoadStringW(hInst, preview.hdc2 ? STRING_PREVIEW_ONEPAGE : STRING_PREVIEW_TWOPAGES, + LoadStringW(hInst, preview.pages_shown > 1 ? STRING_PREVIEW_ONEPAGE : + STRING_PREVIEW_TWOPAGES, name, MAX_STRING_LEN); SetWindowTextW(GetDlgItem(hReBar, ID_PREVIEW_NUMPAGES), name); @@ -1104,7 +1098,7 @@ LRESULT preview_command(HWND hWnd, WPARAM wParam) { preview.zoomlevel++; preview.zoomratio = 0; - if (preview.hdc2) + if (preview.pages_shown > 1) { /* Forced switch to one page when zooming in. */ toggle_num_pages(hWnd);
1
0
0
0
Dylan Smith : wordpad: Get preview page character boundaries with number of pages.
by Alexandre Julliard
22 Feb '10
22 Feb '10
Module: wine Branch: master Commit: b2781015807bfedcdad24b9c52bc1c81dbcd95f9 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=b2781015807bfedcdad24b9c5…
Author: Dylan Smith <dylan.ah.smith(a)gmail.com> Date: Mon Feb 22 03:18:06 2010 -0500 wordpad: Get preview page character boundaries with number of pages. Rather than making seperate calls to EM_FORMATRANGE to get the number of pages and the character boundaries, it would be easiest to get both together. The time to process EM_FORMATRANGE seems like it would take a lot longer than the time needed to cache the character page boundaries. --- programs/wordpad/print.c | 26 ++++++++++++++++++++++++-- 1 files changed, 24 insertions(+), 2 deletions(-) diff --git a/programs/wordpad/print.c b/programs/wordpad/print.c index f4d4eef..faf9439 100644 --- a/programs/wordpad/print.c +++ b/programs/wordpad/print.c @@ -28,6 +28,7 @@ typedef struct _previewinfo { int page; int pages; + int *pageEnds, pageCapacity; HDC hdc; HDC hdc2; HDC hdcSized; @@ -249,12 +250,30 @@ static int get_num_pages(HWND hEditorWnd, FORMATRANGE fr) int page = 0; fr.chrg.cpMin = 0; + if (!preview.pageEnds) + { + preview.pageCapacity = 32; + preview.pageEnds = HeapAlloc(GetProcessHeap(), 0, + sizeof(int) * preview.pageCapacity); + if (!preview.pageEnds) return 0; + } + do { int bottom = fr.rc.bottom; - page++; fr.chrg.cpMin = SendMessageW(hEditorWnd, EM_FORMATRANGE, FALSE, (LPARAM)&fr); + if (page >= preview.pageCapacity) + { + int *new_buffer; + new_buffer = HeapReAlloc(GetProcessHeap(), 0, preview.pageEnds, + sizeof(int) * preview.pageCapacity * 2); + if (!new_buffer) return page; + preview.pageCapacity *= 2; + preview.pageEnds = new_buffer; + } + preview.pageEnds[page] = fr.chrg.cpMin; + page++; fr.rc.bottom = bottom; } while(fr.chrg.cpMin && fr.chrg.cpMin < fr.chrg.cpMax); @@ -696,6 +715,9 @@ void close_preview(HWND hMainWnd) preview.window.bottom = 0; preview.page = 0; preview.pages = 0; + HeapFree(GetProcessHeap(), 0, preview.pageEnds); + preview.pageEnds = NULL; + preview.pageCapacity = 0; preview_bar_show(hMainWnd, FALSE); DestroyWindow(hwndPreview); @@ -883,7 +905,7 @@ static void draw_preview(HWND hEditorWnd, FORMATRANGE* lpFr, RECT* paper, int pa { int bottom; - char_from_pagenum(hEditorWnd, lpFr, page); + lpFr->chrg.cpMin = page <= 1 ? 0 : preview.pageEnds[page-2]; FillRect(lpFr->hdc, paper, GetStockObject(WHITE_BRUSH)); bottom = lpFr->rc.bottom; SendMessageW(hEditorWnd, EM_FORMATRANGE, TRUE, (LPARAM)lpFr);
1
0
0
0
Dylan Smith : wordpad: Added missing calls to DeleteDC and ReleaseDC.
by Alexandre Julliard
22 Feb '10
22 Feb '10
Module: wine Branch: master Commit: 7451facf2f7a9ee8e5873b6c6976bffea241199a URL:
http://source.winehq.org/git/wine.git/?a=commit;h=7451facf2f7a9ee8e5873b6c6…
Author: Dylan Smith <dylan.ah.smith(a)gmail.com> Date: Mon Feb 22 03:17:59 2010 -0500 wordpad: Added missing calls to DeleteDC and ReleaseDC. --- programs/wordpad/print.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/programs/wordpad/print.c b/programs/wordpad/print.c index e8d14e8..f4d4eef 100644 --- a/programs/wordpad/print.c +++ b/programs/wordpad/print.c @@ -412,6 +412,7 @@ void print_quick(HWND hMainWnd, LPWSTR wszFileName) pd.hDC = make_dc(); print(&pd, wszFileName); + DeleteDC(pd.hDC); } void dialog_print(HWND hMainWnd, LPWSTR wszFileName) @@ -596,6 +597,8 @@ LRESULT CALLBACK preview_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) fr.chrg.cpMax = SendMessageW(hEditorWnd, EM_GETTEXTLENGTHEX, (WPARAM)>, 0); preview.pages = get_num_pages(hEditorWnd, fr); DeleteDC(fr.hdc); + DeleteDC(hdcTarget); + ReleaseDC(hWnd, hdc); update_preview_sizes(hWnd, TRUE); break; @@ -845,7 +848,7 @@ LRESULT CALLBACK ruler_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) static void draw_preview_page(HDC hdc, HDC* hdcSized, FORMATRANGE* lpFr, float ratio, int bmNewWidth, int bmNewHeight, int bmWidth, int bmHeight) { HBITMAP hBitmapScaled = CreateCompatibleBitmap(hdc, bmNewWidth, bmNewHeight); - HPEN hPen; + HPEN hPen, oldPen; int TopMargin = (int)((float)twips_to_pixels(lpFr->rc.top, GetDeviceCaps(hdc, LOGPIXELSX)) * ratio); int BottomMargin = (int)((float)twips_to_pixels(lpFr->rc.bottom, GetDeviceCaps(hdc, LOGPIXELSX)) * ratio); int LeftMargin = (int)((float)twips_to_pixels(lpFr->rc.left, GetDeviceCaps(hdc, LOGPIXELSY)) * ratio); @@ -860,7 +863,7 @@ static void draw_preview_page(HDC hdc, HDC* hdcSized, FORMATRANGE* lpFr, float r /* Draw margin lines */ hPen = CreatePen(PS_DOT, 1, RGB(0,0,0)); - SelectObject(*hdcSized, hPen); + oldPen = SelectObject(*hdcSized, hPen); MoveToEx(*hdcSized, 0, TopMargin, NULL); LineTo(*hdcSized, bmNewWidth, TopMargin); @@ -872,6 +875,8 @@ static void draw_preview_page(HDC hdc, HDC* hdcSized, FORMATRANGE* lpFr, float r MoveToEx(*hdcSized, RightMargin, 0, NULL); LineTo(*hdcSized, RightMargin, bmNewHeight); + SelectObject(*hdcSized, oldPen); + DeleteObject(hPen); } static void draw_preview(HWND hEditorWnd, FORMATRANGE* lpFr, RECT* paper, int page)
1
0
0
0
Dylan Smith : richedit: Added some extra tests for EM_FORMATRANGE.
by Alexandre Julliard
22 Feb '10
22 Feb '10
Module: wine Branch: master Commit: fe9933ae4d4d84910032b3ed393cbb8c66dc3eae URL:
http://source.winehq.org/git/wine.git/?a=commit;h=fe9933ae4d4d84910032b3ed3…
Author: Dylan Smith <dylan.ah.smith(a)gmail.com> Date: Mon Feb 22 03:17:49 2010 -0500 richedit: Added some extra tests for EM_FORMATRANGE. The existing tests were not properly testing the return value for the case where all the text fits in the page rect, so this patch adds a couple of simple tests for this case. --- dlls/riched20/tests/editor.c | 22 +++++++++++++++++++--- 1 files changed, 19 insertions(+), 3 deletions(-) diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c index 8aa1c39..1fbdaa5 100644 --- a/dlls/riched20/tests/editor.c +++ b/dlls/riched20/tests/editor.c @@ -4812,9 +4812,10 @@ static void test_WM_PASTE(void) static void test_EM_FORMATRANGE(void) { - int i, tpp_x, tpp_y; + int r, i, tpp_x, tpp_y; HDC hdc; HWND hwndRichEdit = new_richedit(NULL); + FORMATRANGE fr; static const struct { const char *string; /* The string */ int first; /* First 'pagebreak', 0 for don't care */ @@ -4834,14 +4835,29 @@ static void test_EM_FORMATRANGE(void) tpp_x = 1440 / GetDeviceCaps(hdc, LOGPIXELSX); tpp_y = 1440 / GetDeviceCaps(hdc, LOGPIXELSY); + /* Test the simple case where all the text fits in the page rect. */ + SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"a"); + fr.hdc = fr.hdcTarget = hdc; + fr.rc.top = fr.rcPage.top = fr.rc.left = fr.rcPage.left = 0; + fr.rc.right = fr.rcPage.right = 500 * tpp_x; + fr.rc.bottom = fr.rcPage.bottom = 500 * tpp_y; + fr.chrg.cpMin = 0; + fr.chrg.cpMax = -1; + r = SendMessage(hwndRichEdit, EM_FORMATRANGE, FALSE, (LPARAM)&fr); + todo_wine ok(r == 2, "r=%d expected r=2\n", r); + + SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"ab"); + fr.rc.bottom = fr.rcPage.bottom; + r = SendMessage(hwndRichEdit, EM_FORMATRANGE, FALSE, (LPARAM)&fr); + todo_wine ok(r == 3, "r=%d expected r=3\n", r); + SendMessage(hwndRichEdit, EM_FORMATRANGE, FALSE, 0); for (i = 0; i < sizeof(fmtstrings)/sizeof(fmtstrings[0]); i++) { - FORMATRANGE fr; GETTEXTLENGTHEX gtl; SIZE stringsize; - int r, len; + int len; SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) fmtstrings[i].string);
1
0
0
0
Piotr Caban : oleaut32: Added MEMBERID_NIL handling to ICreateTypeInfo_LayOut.
by Alexandre Julliard
22 Feb '10
22 Feb '10
Module: wine Branch: master Commit: bf0815424b56636cc0ffb0023a2ee03e72744c6d URL:
http://source.winehq.org/git/wine.git/?a=commit;h=bf0815424b56636cc0ffb0023…
Author: Piotr Caban <piotr(a)codeweavers.com> Date: Mon Feb 22 01:58:39 2010 +0100 oleaut32: Added MEMBERID_NIL handling to ICreateTypeInfo_LayOut. --- dlls/oleaut32/tests/typelib.c | 4 ++++ dlls/oleaut32/typelib2.c | 21 +++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/dlls/oleaut32/tests/typelib.c b/dlls/oleaut32/tests/typelib.c index 2a04ae9..e75d320 100644 --- a/dlls/oleaut32/tests/typelib.c +++ b/dlls/oleaut32/tests/typelib.c @@ -1041,6 +1041,10 @@ static void test_CreateTypeLib(void) { hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc); ok(hres == S_OK, "got %08x\n", hres); + funcdesc.memid = MEMBERID_NIL; + hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc); + ok(hres == S_OK, "got %08x\n", hres); + ICreateTypeInfo_Release(createti); hres = ICreateTypeLib_CreateTypeInfo(createtl, interface1W, TKIND_INTERFACE, &createti); diff --git a/dlls/oleaut32/typelib2.c b/dlls/oleaut32/typelib2.c index 6eb13af..e1a36b2 100644 --- a/dlls/oleaut32/typelib2.c +++ b/dlls/oleaut32/typelib2.c @@ -1994,8 +1994,25 @@ static HRESULT WINAPI ICreateTypeInfo2_fnLayOut( i = 0; This->typeinfo->cbSizeVft = 0; for(iter=This->typedata->next->next; iter!=This->typedata->next; iter=iter->next) { - if(iter->indice == MEMBERID_NIL) - FIXME("MEMBERID_NIL handling not yet implemented\n"); + /* Assign MEMBERID if MEMBERID_NIL was specified */ + if(iter->indice == MEMBERID_NIL) { + iter->indice = 0x60000000 + i; + + for(iter2=This->typedata->next->next; iter2!=This->typedata->next; iter2=iter2->next) { + if(iter == iter2) continue; + if(iter2->indice == iter->indice) { + iter->indice = 0x5fffffff + This->typeinfo->cElement + i; + + for(iter2=This->typedata->next->next; iter2!=This->typedata->next; iter2=iter2->next) { + if(iter == iter2) continue; + if(iter2->indice == iter->indice) + return E_ACCESSDENIED; + } + + break; + } + } + } typedata[i] = iter;
1
0
0
0
Piotr Caban : oleaut32: Added TypeInfo validation in ICreateTypeInfo_LayOut .
by Alexandre Julliard
22 Feb '10
22 Feb '10
Module: wine Branch: master Commit: 17652291580e1e3ed1bea44c1ee673421ee1085e URL:
http://source.winehq.org/git/wine.git/?a=commit;h=17652291580e1e3ed1bea44c1…
Author: Piotr Caban <piotr(a)codeweavers.com> Date: Mon Feb 22 01:58:17 2010 +0100 oleaut32: Added TypeInfo validation in ICreateTypeInfo_LayOut. --- dlls/oleaut32/typelib2.c | 56 ++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 49 insertions(+), 7 deletions(-) diff --git a/dlls/oleaut32/typelib2.c b/dlls/oleaut32/typelib2.c index 66edc37..6eb13af 100644 --- a/dlls/oleaut32/typelib2.c +++ b/dlls/oleaut32/typelib2.c @@ -1978,7 +1978,7 @@ static HRESULT WINAPI ICreateTypeInfo2_fnLayOut( ICreateTypeInfo2* iface) { ICreateTypeInfo2Impl *This = (ICreateTypeInfo2Impl *)iface; - CyclicList *iter, *iter2; + CyclicList *iter, *iter2, **typedata; int i; TRACE("(%p)\n", iface); @@ -1986,6 +1986,10 @@ static HRESULT WINAPI ICreateTypeInfo2_fnLayOut( if(!This->typedata) return S_OK; + typedata = HeapAlloc(GetProcessHeap(), 0, sizeof(CyclicList*)*This->typeinfo->cElement); + if(!typedata) + return E_OUTOFMEMORY; + /* Assign IDs and VTBL entries */ i = 0; This->typeinfo->cbSizeVft = 0; @@ -1993,6 +1997,8 @@ static HRESULT WINAPI ICreateTypeInfo2_fnLayOut( if(iter->indice == MEMBERID_NIL) FIXME("MEMBERID_NIL handling not yet implemented\n"); + typedata[i] = iter; + iter->u.data[0] = (iter->u.data[0]&0xffff) | (i<<16); if((This->typeinfo->typekind&0xf) != TKIND_MODULE) { @@ -2018,7 +2024,33 @@ static HRESULT WINAPI ICreateTypeInfo2_fnLayOut( i++; } - FIXME("Typeinfo validation not implemented\n"); + for(i=0; i<This->typeinfo->cElement; i++) { + if(typedata[i]->u.data[4]>>16 > i) { + int inv; + + inv = (typedata[i]->u.data[4]>>3) & 0xf; + i = typedata[i]->u.data[4] >> 16; + + while(i > typedata[i]->u.data[4]>>16) { + int invkind = (typedata[i]->u.data[4]>>3) & 0xf; + + if(inv & invkind) { + HeapFree(GetProcessHeap(), 0, typedata); + return TYPE_E_DUPLICATEID; + } + + i = typedata[i]->u.data[4] >> 16; + inv |= invkind; + } + + if(inv & INVOKE_FUNC) { + HeapFree(GetProcessHeap(), 0, typedata); + return TYPE_E_INCONSISTENTPROPFUNCS; + } + } + } + + HeapFree(GetProcessHeap(), 0, typedata); return S_OK; } @@ -3384,17 +3416,23 @@ static int ctl2_write_segment(ICreateTypeLib2Impl *This, HANDLE hFile, int segme return -1; } -static void ctl2_finalize_typeinfos(ICreateTypeLib2Impl *This, int filesize) +static HRESULT ctl2_finalize_typeinfos(ICreateTypeLib2Impl *This, int filesize) { ICreateTypeInfo2Impl *typeinfo; + HRESULT hres; for (typeinfo = This->typeinfos; typeinfo; typeinfo = typeinfo->next_typeinfo) { typeinfo->typeinfo->memoffset = filesize; if (typeinfo->typedata) { - ICreateTypeInfo2_fnLayOut((ICreateTypeInfo2 *)typeinfo); + hres = ICreateTypeInfo2_fnLayOut((ICreateTypeInfo2 *)typeinfo); + if(FAILED(hres)) + return hres; + filesize += typeinfo->typedata->next->u.val + ((typeinfo->typeinfo->cElement >> 16) * 12) + ((typeinfo->typeinfo->cElement & 0xffff) * 12) + 4; } } + + return S_OK; } static int ctl2_finalize_segment(ICreateTypeLib2Impl *This, int filepos, int segment) @@ -3448,6 +3486,7 @@ static HRESULT WINAPI ICreateTypeLib2_fnSaveAllChanges(ICreateTypeLib2 * iface) int retval; int filepos; HANDLE hFile; + HRESULT hres; TRACE("(%p)\n", iface); @@ -3473,7 +3512,11 @@ static HRESULT WINAPI ICreateTypeLib2_fnSaveAllChanges(ICreateTypeLib2 * iface) filepos += ctl2_finalize_segment(This, filepos, MSFT_SEG_CUSTDATA); filepos += ctl2_finalize_segment(This, filepos, MSFT_SEG_CUSTDATAGUID); - ctl2_finalize_typeinfos(This, filepos); + hres = ctl2_finalize_typeinfos(This, filepos); + if(FAILED(hres)) { + CloseHandle(hFile); + return hres; + } if (!ctl2_write_chunk(hFile, &This->typelib_header, sizeof(This->typelib_header))) return retval; if (This->typelib_header.varflags & HELPDLLFLAG) @@ -3498,8 +3541,7 @@ static HRESULT WINAPI ICreateTypeLib2_fnSaveAllChanges(ICreateTypeLib2 * iface) if (!CloseHandle(hFile)) return retval; - retval = S_OK; - return retval; + return S_OK; }
1
0
0
0
Piotr Caban : oleaut32: Improved ICreateTypeInfo2_fnAddFuncDesc implementation.
by Alexandre Julliard
22 Feb '10
22 Feb '10
Module: wine Branch: master Commit: 1dda40deb2ae1dac4852f1bd7547a92694a25cb7 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=1dda40deb2ae1dac4852f1bd7…
Author: Piotr Caban <piotr(a)codeweavers.com> Date: Mon Feb 22 10:24:17 2010 +0100 oleaut32: Improved ICreateTypeInfo2_fnAddFuncDesc implementation. --- dlls/oleaut32/tests/typelib.c | 53 ++++++++++++++++++++++++ dlls/oleaut32/typelib2.c | 89 +++++++++++++++++++++++++---------------- 2 files changed, 107 insertions(+), 35 deletions(-) diff --git a/dlls/oleaut32/tests/typelib.c b/dlls/oleaut32/tests/typelib.c index ff85320..2a04ae9 100644 --- a/dlls/oleaut32/tests/typelib.c +++ b/dlls/oleaut32/tests/typelib.c @@ -976,6 +976,8 @@ static void test_CreateTypeLib(void) { ICreateTypeLib2 *createtl; ICreateTypeInfo *createti; ITypeLib *tl; + FUNCDESC funcdesc; + ELEMDESC elemdesc; HRESULT hres; trace("CreateTypeLib tests\n"); @@ -988,6 +990,57 @@ static void test_CreateTypeLib(void) { hres = ICreateTypeLib_CreateTypeInfo(createtl, interface1W, TKIND_INTERFACE, &createti); ok(hres == S_OK, "got %08x\n", hres); + + hres = ICreateTypeInfo_LayOut(createti); + ok(hres == S_OK, "got %08x\n", hres); + + memset(&funcdesc, 0, sizeof(FUNCDESC)); + funcdesc.funckind = FUNC_PUREVIRTUAL; + funcdesc.invkind = INVOKE_PROPERTYGET; + funcdesc.callconv = CC_STDCALL; + funcdesc.elemdescFunc.tdesc.vt = VT_BSTR; + funcdesc.elemdescFunc.idldesc.wIDLFlags = IDLFLAG_NONE; + + hres = ICreateTypeInfo_AddFuncDesc(createti, 0, NULL); + ok(hres == E_INVALIDARG, "got %08x\n", hres); + + hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc); + ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres); + + hres = ICreateTypeInfo_AddFuncDesc(createti, 0, &funcdesc); + ok(hres == S_OK, "got %08x\n", hres); + + funcdesc.invkind = INVOKE_PROPERTYPUT; + hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc); + ok(hres == TYPE_E_INCONSISTENTPROPFUNCS, "got %08x\n", hres); + + funcdesc.invkind = INVOKE_PROPERTYPUTREF; + hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc); + ok(hres == TYPE_E_INCONSISTENTPROPFUNCS, "got %08x\n", hres); + + elemdesc.tdesc.vt = VT_BSTR; + elemdesc.idldesc.dwReserved = 0; + elemdesc.idldesc.wIDLFlags = IDLFLAG_FIN; + + funcdesc.lprgelemdescParam = &elemdesc; + funcdesc.invkind = INVOKE_PROPERTYPUT; + funcdesc.cParams = 1; + funcdesc.elemdescFunc.tdesc.vt = VT_VOID; + + hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc); + ok(hres == S_OK, "got %08x\n", hres); + + funcdesc.invkind = INVOKE_PROPERTYPUTREF; + hres = ICreateTypeInfo_AddFuncDesc(createti, 0, &funcdesc); + ok(hres == S_OK, "got %08x\n", hres); + + funcdesc.memid = 1; + funcdesc.lprgelemdescParam = NULL; + funcdesc.invkind = INVOKE_FUNC; + funcdesc.cParams = 0; + hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc); + ok(hres == S_OK, "got %08x\n", hres); + ICreateTypeInfo_Release(createti); hres = ICreateTypeLib_CreateTypeInfo(createtl, interface1W, TKIND_INTERFACE, &createti); diff --git a/dlls/oleaut32/typelib2.c b/dlls/oleaut32/typelib2.c index 0f5d57f..66edc37 100644 --- a/dlls/oleaut32/typelib2.c +++ b/dlls/oleaut32/typelib2.c @@ -514,7 +514,7 @@ static int ctl2_alloc_typeinfo( typeinfo->typekind = (This->typelib_header.nrtypeinfos - 1) << 16; typeinfo->memoffset = -1; /* should be EOF if no elements */ typeinfo->res2 = 0; - typeinfo->res3 = -1; + typeinfo->res3 = 0; typeinfo->res4 = 3; typeinfo->res5 = 0; typeinfo->cElement = 0; @@ -1382,16 +1382,43 @@ static HRESULT WINAPI ICreateTypeInfo2_fnAddFuncDesc( { ICreateTypeInfo2Impl *This = (ICreateTypeInfo2Impl *)iface; - CyclicList *insert; + CyclicList *iter, *insert; int *typedata; int i; int decoded_size; - FIXME("(%p,%d,%p), stub!\n", iface, index, pFuncDesc); - FIXME("{%d,%p,%p,%d,%d,%d,%d,%d,%d,%d,{%d},%d}\n", pFuncDesc->memid, pFuncDesc->lprgscode, pFuncDesc->lprgelemdescParam, pFuncDesc->funckind, pFuncDesc->invkind, pFuncDesc->callconv, pFuncDesc->cParams, pFuncDesc->cParamsOpt, pFuncDesc->oVft, pFuncDesc->cScodes, pFuncDesc->elemdescFunc.tdesc.vt, pFuncDesc->wFuncFlags); -/* FIXME("{%d, %d}\n", pFuncDesc->lprgelemdescParam[0].tdesc.vt, pFuncDesc->lprgelemdescParam[1].tdesc.vt); */ -/* return E_OUTOFMEMORY; */ - + TRACE("(%p,%d,%p)\n", iface, index, pFuncDesc); + + if(!pFuncDesc || (pFuncDesc->memid>0x7fffffff && pFuncDesc->memid!=MEMBERID_NIL)) + return E_INVALIDARG; + + TRACE("{%d,%p,%p,%d,%d,%d,%d,%d,%d,%d,{%d},%d}\n", pFuncDesc->memid, + pFuncDesc->lprgscode, pFuncDesc->lprgelemdescParam, pFuncDesc->funckind, + pFuncDesc->invkind, pFuncDesc->callconv, pFuncDesc->cParams, + pFuncDesc->cParamsOpt, pFuncDesc->oVft, pFuncDesc->cScodes, + pFuncDesc->elemdescFunc.tdesc.vt, pFuncDesc->wFuncFlags); + + switch(This->typeinfo->typekind&0xf) { + case TKIND_MODULE: + if(pFuncDesc->funckind != FUNC_STATIC) + return TYPE_E_BADMODULEKIND; + break; + case TKIND_DISPATCH: + if(pFuncDesc->funckind != FUNC_DISPATCH) + return TYPE_E_BADMODULEKIND; + break; + default: + if(pFuncDesc->funckind != FUNC_PUREVIRTUAL) + return TYPE_E_BADMODULEKIND; + } + + if(This->typeinfo->cElement<index) + return TYPE_E_ELEMENTNOTFOUND; + + if((pFuncDesc->invkind&(INVOKE_PROPERTYPUT|INVOKE_PROPERTYPUTREF)) && + !pFuncDesc->cParams) + return TYPE_E_INCONSISTENTPROPFUNCS; + if (!This->typedata) { This->typedata = HeapAlloc(GetProcessHeap(), 0, sizeof(CyclicList)); if(!This->typedata) @@ -1411,19 +1438,30 @@ static HRESULT WINAPI ICreateTypeInfo2_fnAddFuncDesc( return E_OUTOFMEMORY; } - insert->next = This->typedata->next; - This->typedata->next = insert; - This->typedata = insert; + /* insert type data to list */ + if(index == This->typeinfo->cElement) { + insert->next = This->typedata->next; + This->typedata->next = insert; + This->typedata = insert; + } else { + iter = This->typedata->next; + for(i=0; i<index; i++) + iter = iter->next; + + insert->next = iter->next; + iter->next = insert; + } + /* update type data size */ This->typedata->next->u.val += 0x18 + (pFuncDesc->cParams * 12); - typedata = This->typedata->u.data; /* fill out the basic type information */ - typedata[0] = (0x18 + (pFuncDesc->cParams * 12)) | (index << 16); + typedata = insert->u.data; + typedata[0] = 0x18 + pFuncDesc->cParams * 12; ctl2_encode_typedesc(This->typelib, &pFuncDesc->elemdescFunc.tdesc, &typedata[1], NULL, NULL, &decoded_size); typedata[2] = pFuncDesc->wFuncFlags; typedata[3] = ((sizeof(FUNCDESC) + decoded_size) << 16) | This->typeinfo->cbSizeVft; - typedata[4] = (index << 16) | (pFuncDesc->callconv << 8) | 9; + typedata[4] = (pFuncDesc->callconv << 8) | (pFuncDesc->invkind << 3) | pFuncDesc->funckind; typedata[5] = pFuncDesc->cParams; /* NOTE: High word of typedata[3] is total size of FUNCDESC + size of all ELEMDESCs for params + TYPEDESCs for pointer params and return types. */ @@ -1436,33 +1474,14 @@ static HRESULT WINAPI ICreateTypeInfo2_fnAddFuncDesc( typedata[8+(i*3)] = pFuncDesc->lprgelemdescParam[i].u.paramdesc.wParamFlags; typedata[3] += decoded_size << 16; -#if 0 - /* FIXME: Doesn't work. Doesn't even come up with usable VTs for varDefaultValue. */ - if (pFuncDesc->lprgelemdescParam[i].u.paramdesc.wParamFlags & PARAMFLAG_FHASDEFAULT) { - ctl2_alloc_custdata(This->typelib, &pFuncDesc->lprgelemdescParam[i].u.paramdesc.pparamdescex->varDefaultValue); - } -#endif + if(pFuncDesc->lprgelemdescParam[i].u.paramdesc.wParamFlags & PARAMFLAG_FHASDEFAULT) + FIXME("default values not implemented\n"); } /* update the index data */ - insert->indice = ((0x6000 | This->typeinfo->cImplTypes) << 16) | index; + insert->indice = (This->typeinfo->cImplTypes << 16) | pFuncDesc->memid; insert->name = -1; - /* ??? */ - if (!This->typeinfo->res2) This->typeinfo->res2 = 0x20; - This->typeinfo->res2 <<= 1; - - /* ??? */ - if (This->typeinfo->res3 == -1) This->typeinfo->res3 = 0; - This->typeinfo->res3 += 0x38; - - /* ??? */ - if (index < 2) This->typeinfo->res2 += pFuncDesc->cParams << 4; - This->typeinfo->res3 += pFuncDesc->cParams << 4; - - /* adjust size of VTBL */ - This->typeinfo->cbSizeVft += 4; - /* Increment the number of function elements */ This->typeinfo->cElement += 1;
1
0
0
0
← Newer
1
...
11
12
13
14
15
16
17
...
79
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
Results per page:
10
25
50
100
200