From b6925bdd6f4387e528a317aa1a19741f3fbdfbd3 Mon Sep 17 00:00:00 2001 From: Mikhail Tyukin Date: Sun, 8 Jun 2025 18:05:27 -0400 Subject: [PATCH] [RICHED20] Sync to Wine-10.0 (#8078) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [RICHED20] Sync to Wine-10.0 Sync wine/rbtree.h to Wine-10.0 as changes in riched20 require this. Also added a define to allow directx code to compile. Sync riched20 to Wine-10.0 and its tests using the script. Signed-off-by: Francois Gouget Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard wine commit id 9f72c5601173728c52626342a1ec6c9a4c70670f by Francois Gouget Update WINESYNC.txt Update precomp.h fix build [WINESYNC]: riched20 is now in sync with wine-staging wine-10.0 [WINESYNC] riched20: Only call ME_SendRequestResize when control is in-place active. Prevent GetClientRect from being called when not in-place active. wine commit id e61db557ab8473a490c84301dbb4b4665b6c9c9f by Charlotte Pabst [WINESYNC] riched20: Exit from editor_ensure_visible when control is not in-place active. According to microsoft documentation, ScrollWindowEx, SetScrollPos and SetScrollRange may only be called while the control is in-place active. This fixes a segmentation fault in an application. wine commit id dafaadcb4addd9af334433666a4bc2e7aa6eb9ff by Charlotte Pabst [WINESYNC] riched20/tests: Test that ScrollWindowEx and GetClientRect are only called when control is in-place active. wine commit id f1301cedbea51be107017bb8545956bcfd02b610 by Charlotte Pabst Update editor.c [WINESYNC] riched20: Release IME input context when done using it. wine commit id 3f51fb96c162e8d3314627b3db25564fa7d9d419 by Zhiyi Zhang [WINESYNC] riched20: In para_set_fmt protect against out of bound cTabStop values. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56730 wine commit id 7b2ff977739df25252d46552d2447af50c23040e by Fabian Maurer Update editor.c [WINESYNC] riched20: Don't write past end of buffer. Signed-off-by: Eric Pouech wine commit id 5cbe3a6cb186cffed20e3fea5f88abd0880d3914 by Eric Pouech [WINESYNC] riched20: Don't crash when no OLE obj is present. This was generating a lot of crashes in riched20 tests. Signed-off-by: Eric Pouech wine commit id 015aae30cf2217164f631d1c03abfc9ea63bb43d by Eric Pouech Update editor.c [WINESYNC] riched20: Use CRT allocation functions. wine commit id 42579f1dcd2f14e765e2f53ceb5b46fff5623f10 by Alex Henrie [WINESYNC] riched20/tests: Make the editor paste test failures more informative and unique. Knowing the content of the edit field is more useful than knowing the strcmp() result. The text field may contain carriage returns and linefeeds so use wine_dbgstr_a() so they are clearly visible in the failure message. Also prefix the ok messages with a unique string to indicate which test_WM_PASTE() test failed. wine commit id b8950d04e439f649f2167477a36ee453ad8b81ef by Francois Gouget [WINESYNC] riched20: Don't call wrap_marked_paras_dc() before the editor is fully initialized. Today, CreateTextServices() sometimes triggers an assertion failure in select_style(). When ME_MakeEditor() calls ME_MakeFirstParagraph(), the editor (ME_TextEditor) is not in a fully initialized state. For example, the font cache (pFontCache) is not fully initialized, which sometimes makes select_style() believe that the cache slots are fully occupied. Fix this by delaying the call to wrap_marked_paras_dc() until the editor is fully initialized. Also, delay the call to ITextHost::TxReleaseDC() until after wrap_marked_paras_dc(), since we need the device context a bit longer. Fixes: b70eb32c5f3e506181d9e1e9fbef62e9baf3674d wine commit id 548d7179e3b2b9961321a4df50644c9b3874a295 by Jinoh Kang [WINESYNC] riched20: Factor out device context acquisition from ME_MakeFirstParagraph. This lets ME_MakeEditor() reuse the device context throughout the editor initialization process. wine commit id 03036f42e1afa9c79246dcee6b9fe876286b1aa4 by Jinoh Kang [WINESYNC] riched20: Don't call ME_UpdateRepaint inside set_selection(). This partially reverts c5daf6a30f21 (riched20: Call ME_UpdateRepaint instead of editor_ensure_visible in set_selection.) Fixes: c5daf6a30f21acd20263692b278acba49e014cc1 wine commit id ac5110131493b8b05795e8825285e41ca40ab6f1 by Jinoh Kang [WINESYNC] riched20/tests: Add tests for change notifications caused by EM_SETSEL{,EX}. wine commit id c35926e49825f7a3d48ba826085fe1ae3d2a7e27 by Jinoh Kang [WINESYNC] riched20: Wrap marked paragraphs at Text Services initialization. Today, CreateTextServices() returns an Rich Edit object without row start and end marks, which are expected to exist by many Rich Edit operations as well as EM_* message handlers. This leads to a crash when certain messages (e.g., EM_SCROLLCARET) are sent to the Rich Edit object via ITextServices::TxSendMessage(), unless ME_WrapMarkedParagraphs() has been called beforehand. Fix this by calling wrap_marked_paras_dc() early in the initialization process. This is not a problem for windowed Rich Edit controls, which already calls ME_WrapMarkedParagraphs() before the user or application starts interacting with it. wine commit id b70eb32c5f3e506181d9e1e9fbef62e9baf3674d by Jinoh Kang [WINESYNC] riched20: Use nameless unions/structs. wine commit id 26826d3af8b1969de389f3d6702d7c8b805126e1 by Alexandre Julliard Update editor.h [WINESYNC] riched20: Remove DECLSPEC_HIDDEN usage. wine commit id c04ab166498b5841ecde620a9bd0b74969b01596 by Alistair Leslie-Hughes [WINESYNC] riched20: Call ME_UpdateRepaint instead of editor_ensure_visible in set_selection. To prevent cases where ME_WrapMarkedParagraphs has not been called causing a NULL pointer when editor_ensure_visible tries to get the row from the cursor. wine commit id c5daf6a30f21acd20263692b278acba49e014cc1 by Santino Mazza [WINESYNC] riched20: Update paragraph position in marked tree. nCharOfs is the key for paragraphs added to the marked tree If it is updated, re-add the entry to update its position wine commit id f1aa3f37ef326b7cbf8fc94e982c9f0b398181c4 by Daniel Lehman Update editor.c [WINESYNC] riched20: Update the editor IME position on GCS_RESULTSTR. So that a GCS_RESULTSTR followed by GCS_COMPSTR, without interruping the composition, begins inserting the new composition text after the result instead of before it. wine commit id de45bc33a73eac5dbc3502b4a43cd48399507c73 by Rémi Bernon [WINESYNC] riched20/tests: Fix a typo in a comment. wine commit id 145e3c758b9594596835e291b2fcb3c80e4c0479 by Francois Gouget [WINESYNC] riched20/tests: Don't specify DT_WORDBREAK in _check_txgetnaturalsize(). Today, test_TxGetNaturalSize() creates a pop-up window with a fixed size (extent) of 100 x 100. The test function then proceeds to compute the natural size of rich edit control that fits the sample text "TestSomeText" and compare it to the RECT calculated by DrawText. Apparently, this test fails if the width of the sample text "TestSomeText" exceeds the width of the test window's client area. In this case, DrawText() with DT_WORDBREAK breaks the text into the two lines due to text wrapping; however, Rich Edit's ITextServices::TxGetNaturalSize implementation does not seem to perform text wrapping on overflow. This results in extent mismatch. (Note that the test may either succeed or fail depending on the current font used for DEFAULT_GUI_FONT, which defaults to Tahoma according to Microsoft's documentation. To reproduce this failure, it may be necessary to switch fonts or change the width of the pop-up window.) Fix this by omitting the DT_WORDBREAK flag for the DrawText() call in _check_txgetnaturalsize(). Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54637 wine commit id f54a1dac64c89aea3fe02ae8c0d6eef43a0aa117 by Jinoh Kang Update editstr.h [WINESYNC] riched20: Implement ITextDocument::Freeze and ITextDocument::Unfreeze. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54617 wine commit id 3fe15349d39ccf31026a92eae30f83f65c91cb1f by Jinoh Kang [WINESYNC] riched20: Don't assume that TxDraw preserves the device context's brush selection. Today, RichEditWndProc_common assumes that ITextServices::TxDraw preserves the brush selection of the given device context. However, this invariant may be broken by misbehaving embedded OLE objects in the text document. Fix this by not assuming that the return value of the second SelectObject() call equals the brush passed to the first SelectObject() call in RichEditWndProc_common's WM_PAINT / WM_PRINTCLIENT case. wine commit id 2027be7e0370c92595f126a0b0dd167a635d50a2 by Jinoh Kang [WINESYNC] riched20/tests: Test for ITextDocument::Freeze and ITextDocument::Unfreeze. wine commit id 3105fad82b9bae390fcd710a2fc10a18988b4622 by Jinoh Kang [WINESYNC] riched20: Don't set para unless committing cursor move in ME_MoveCursorWords. Introduce a temporary variable, `other_para`, so that we don't end up returning incorrect para (with stale run) inside the output cursor. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54564 wine commit id 7e28fa5c558f1417f8f033cb843424778bbfb8b8 by Jinoh Kang [WINESYNC] riched20/tests: Test for word movement across paragraph boundary. wine commit id 21d25b17c2cae8eb2d2376ce42b76e3f61eb0bba by Jinoh Kang [WINESYNC] riched20/tests: Fix the EM_GETSELTEXT tests in Hindi on Windows. On Windows EM_GETSELTEXT fails with an invalid parameter error in the Hindi locale but works in most other locales, including UTF-8 ones. So check for this issue and adjust the expected results accordingly. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54559 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54565 wine commit id 37cd13abdf5d91c7b3f25b39fa14976bc3a3e3a3 by Francois Gouget [WINESYNC] riched20/tests: EM_GETSELTEXT's wparam is not used and should be 0. wine commit id baa41970647a7e548701a72bea2e4aa2a61ca27e by Francois Gouget [WINESYNC] riched20/tests: Add context to the EM_FORMATRANGE tests. wine commit id 020145248371bbfd2e473e79ba873e8313dde72d by Francois Gouget [WINESYNC] riched20/tests: Check clipboard content after destroying the editor window. Destroying the editor window should render all the formats so they are still available after. wine commit id b5b5b0b365639b889a0240d4992e16174b428f75 by Francois Gouget [WINESYNC] riched20/tests: Add retry loop around OpenClipboard() to avoid access denial. Reusing existing helper from user32 & comctl32. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47888 Signed-off-by: Eric Pouech wine commit id 25743d46f4103c7345c955b87b4134a065fb5f1d by Eric Pouech [WINESYNC] riched20/tests: Ensure clipboard has been pasted before testing the result. The patch does reduce error failures locally. For the record: - WM_PASTE in undo operations haven't been transformed (as it requires UNDO stack manipulation in a coherent way across platforms) Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47888 Signed-off-by: Eric Pouech wine commit id 4fd5252f635817b431673accaba718c7481f48f6 by Eric Pouech [WINESYNC] riched20: Support SFF_SELECTION when streaming in plain text. Signed-off-by: Eric Pouech wine commit id 1b7a918bd7ec8bc2c51bcb76525b56b17c5ff0c0 by Eric Pouech [WINESYNC] riched20/tests: Add tests when pasting in plain text mode. Signed-off-by: Eric Pouech wine commit id 82fa1048b5cc7d9c6a2a289403f25adbdd8158c7 by Eric Pouech [WINESYNC] riched20: Obtain the composition start index after deleting selection. Today, the Rich Edit control handles the WM_IME_STARTCOMPOSITION message by the computing the composition start position (imeStartIndex) _before_ calling ME_DeleteSelection(), which shifts the character positions after the range of deletion. If the selection were not empty, imeStartIndex immediately becomes stale, since it does not take into account the number of deleted characters before it. Fix this by computing imeStartIndex after the ME_DeleteSelection() call. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54318 wine commit id 8c43577f0f9b4422d3641457c595c3998bd54a18 by Jinoh Kang [WINESYNC] riched20: Call GlobalReAlloc with GMEM_MOVEABLE flag. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53474 wine commit id dfd44bb979ee2052eceff094083147e9879fa807 by Rémi Bernon [WINESYNC] riched20: Fix failing test in UTF8 locales. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52875 Signed-off-by: Eric Pouech wine commit id 5902cfd2990261189ce9af27981a95ac12fa2a5d by Eric Pouech [WINESYNC] riched20: Don't emit EN_CHANGE events during window creation. wine commit id 5c997de8dc1e4885266fa884a2fb74f840e3bedc by Evan Tang [WINESYNC] riched20: Add test for EN_CHANGE events during window creation. GenoPro isn't very happy if it receives one wine commit id 0b069106b0e0f141d6925d3e10166be89fc59145 by Evan Tang [WINESYNC] riched20: Move test class creation to a helper function. wine commit id f9083961ed187777d660796f7136addc04fff8b0 by Evan Tang [WINESYNC] riched20/tests: Use ARRAY_SIZE instead of open coding it. wine commit id 90b6288f54afdc4430dac146779a92b89f4d1219 by Michael Stefaniuc [WINESYNC] riched20/test: Add scrolling test for richole. Signed-off-by: Santino Mazza wine commit id 059c70d736baa164a1b246e949acd006cf83ab5a by Santino Mazza [WINESYNC] riched20: Ensure that cursor is visible when selecting text. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=40444 Signed-off-by: Santino Mazza wine commit id 25209c162fc209124b369abbad55d915d31909b2 by Santino Mazza [WINESYNC] riched20/tests: When selection is out of view, the scrollbar should move. Signed-off-by: Santino Mazza wine commit id ee131e9eba7dad090f0baf4a73fab2d62dc73b52 by Santino Mazza [WINESYNC] riched20: Remove duplicate code. Signed-off-by: David Kahurani wine commit id 3588479e1a674e5f43f1acb9e7c0aa8cecf98f25 by David Kahurani [WINESYNC] riched20: Implement ITextDocument::Undo and ITextDocument::Redo. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53289 Signed-off-by: Jinoh Kang wine commit id ded8227774570a1ea320dc34f2de0033f85b3ce7 by Jinoh Kang [WINESYNC] riched20: Add undo control state variable to ME_TextEditor. Signed-off-by: Jinoh Kang wine commit id 40c54854e61d8adfca21e2fa9260712e4f5453e9 by Jinoh Kang [WINESYNC] riched20: Factor out undo-ignored status check. Signed-off-by: Jinoh Kang wine commit id 0cd86e010e41eebdc1a4c142f9cc6a4948554d0e by Jinoh Kang [WINESYNC] riched20: Ensure MEPF_COMPLEX is unset when in password input mode. Otherwise, Wine may crash while attempting to fetch the script shaping information, which does not exist since shape_para() was not called. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53335 Signed-off-by: Jinoh Kang wine commit id f77f12ba3b1dad9ebdcb116c66b137e9103a0d1b by Jinoh Kang [WINESYNC] riched20/tests: Test for ITextDocument::Undo and ITextDocument::Redo. Signed-off-by: Jinoh Kang wine commit id 73284ea18891a152dce989ffff59e2c527f94c73 by Jinoh Kang [WINESYNC] riched20: Commit and wrap paragraphs after changing text properties. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53170 Signed-off-by: Jinoh Kang wine commit id 0974f047b57357252ec94bea119e5291250a446c by Jinoh Kang [WINESYNC] riched20: Draw OLE objects with IViewObject implementation. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52752 Signed-off-by: Jinoh Kang wine commit id ecc607c6da96a5c2e8988f3021e98b442fe24c12 by Jinoh Kang [WINESYNC] riched20: Fetch extent from object if REOBJECT::sizel is unset. Signed-off-by: Jinoh Kang wine commit id 164897e6c94d3eee4798f82a730472a5a847f9b2 by Jinoh Kang [WINESYNC] riched20/tests: Add tests for drawing embedded OLE objects. Signed-off-by: Jinoh Kang wine commit id a7d29d1625f7e02df4fbf59ef4e4a999d39edde0 by Jinoh Kang [WINESYNC] riched20/tests: Fix the spelling of a comment. Signed-off-by: Francois Gouget Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard wine commit id f9fa5f9e523b45766f715c6981c6a6ab5f183157 by Francois Gouget [WINESYNC] riched20: Implement callback to IRichEditOleCallback_QueryInsertObject. Signed-off-by: Jinoh Kang Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard wine commit id 10667b39aad6710668f60c1ba8f10e50aeb87242 by Jinoh Kang [WINESYNC] riched20/tests: Add tests for IRichEditOleCallback_QueryInsertObject. Signed-off-by: Jinoh Kang Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard wine commit id 95b4072cc774ba7a7eabb0d4c114b933b7d71105 by Jinoh Kang Update richole.c [WINESYNC] riched20: Set REOBJECT's cp correctly in IRichEditOle::GetObject. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52705 Signed-off-by: Jinoh Kang Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard wine commit id 194ba06c403fd72fbfb95048385c9ca4838af169 by Jinoh Kang [WINESYNC] riched20: Add back-reference to outer ME_Run from struct re_object. Signed-off-by: Jinoh Kang Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard wine commit id 05796c4e2a4acb91e6035c536b4d0e1f7e16896d by Jinoh Kang fix [WINESYNC] riched20/tests: Enable compilation with long types. Signed-off-by: Eric Pouech Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard wine commit id 9e90cecdc603d79c6332a03884ed8d4851ef2e88 by Eric Pouech [WINESYNC] riched20/tests: Use correct integral type. Signed-off-by: Eric Pouech Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard wine commit id 8b66db027d4112bfd4287b03d5c7b6f33994adc3 by Eric Pouech fix build, sync rbtree.h [WINESYNC] riched20: Enable compilation with long types. Signed-off-by: Eric Pouech Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard wine commit id 42d0e56643740a0eac5913a9f176e789457cb475 by Eric Pouech [WINESYNC] riched20/tests: Add a test to see what richedit class flavours should be available. Signed-off-by: Dmitry Timoshkov Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard wine commit id d54a0e2bea4548bb5d9c0cca9f918d7c46591e23 by Dmitry Timoshkov [WINESYNC] riched20: Use correct integral type. Signed-off-by: Eric Pouech Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard wine commit id 63a643f7f42ecd0c2625a5f5704b5b9647349e7b by Eric Pouech [WINESYNC] riched20/tests: Avoid "misleading indentation" warnings. Signed-off-by: Fabian Maurer Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard wine commit id 2d6fad7bda2f2e21a871f405a6b0c3e70ebf6a6a by Fabian Maurer [WINESYNC] include: Remove the wine_ prefix on rbtree functions. Add defines for frequently-used functions. For compatibility with vkd3d. Signed-off-by: Alexandre Julliard wine commit id 3527230c461b6baba9c29e69b575ada85bdbbc43 by Alexandre Julliard [WINESYNC] riched20: Defer releasing the host if inside a notify callback. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51521 Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard wine commit id 8138159f20d6453443861570689e0f14018051da by Huw Davies [WINESYNC] riched20: Return the nearest char pos if the coords are outside the format rect. For the two tests that remain todo_wine, the results differ between riched20 and msftedit, with Wine's implementation matching msftedit. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52041 Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard wine commit id 363508454d5f8f1fc5916bda47e6429756b7dc8f by Huw Davies [WINESYNC] riched20: Check font_cache in select_style() too. Signed-off-by: Serge Gautherie Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard wine commit id 177f808aa86e5442be1a0a92ddccc4904bf2e743 by Serge Gautherie [WINESYNC] riched20: Use the standard va_list instead of __ms_va_list. Signed-off-by: Alexandre Julliard wine commit id 5b15bf33255bd373cbf26ec373d16a8234ec6b1c by Alexandre Julliard [WINESYNC] riched20: Use regular allocation helpers for text services objects. Signed-off-by: Nikolay Sivov Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard wine commit id 2064c206c0b67edb8524f572166b974ba9cbd6fe by Nikolay Sivov [WINESYNC] riched20: Remove New() allocation macro. Signed-off-by: Nikolay Sivov Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard wine commit id 1d5c9defb19fca6cfb1107384fc2325d391726d6 by Nikolay Sivov [WINESYNC] riched20: Don't create custom heap. Signed-off-by: Dmitry Timoshkov Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard wine commit id 8bff437e9d5e047e689d8b32f62995785c0cd48e by Dmitry Timoshkov [WINESYNC] riched20/tests: Don't cast NULL. Signed-off-by: Michael Stefaniuc Signed-off-by: Alexandre Julliard wine commit id b701c3df99fbd6d4df7eaa11327bb11db95d8676 by Michael Stefaniuc [WINESYNC] riched20/tests: Add more tests for testing EM_GETTEXTEX with OLE objects. Signed-off-by: Jactry Zeng Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard wine commit id 40988d6c3886d0f7a914c45ea68264bfc8540859 by Jactry Zeng Update richole.c [WINESYNC] riched20: Allow to insert OLE object at specified offset. Signed-off-by: Jactry Zeng Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard wine commit id 8c894382dde5b9da88b0e9f23a753d5e851a43d6 by Jactry Zeng Update richole.c [WINESYNC] riched20/tests: Lock hGlobal before use. Signed-off-by: Jactry Zeng Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard wine commit id f9c8c95856ded333be35ff41ab40a246bfe345b6 by Jactry Zeng Co-authored-by: winesync --- dll/win32/riched20/CMakeLists.txt | 3 +- dll/win32/riched20/caret.c | 95 +- dll/win32/riched20/clipboard.c | 38 +- dll/win32/riched20/editor.c | 175 +- dll/win32/riched20/editor.h | 444 +-- dll/win32/riched20/editstr.h | 13 +- dll/win32/riched20/list.c | 8 +- dll/win32/riched20/paint.c | 22 +- dll/win32/riched20/para.c | 24 +- dll/win32/riched20/precomp.h | 3 - dll/win32/riched20/reader.c | 72 +- dll/win32/riched20/richole.c | 452 ++- dll/win32/riched20/rtf.h | 51 +- dll/win32/riched20/run.c | 14 +- dll/win32/riched20/string.c | 24 +- dll/win32/riched20/style.c | 10 +- dll/win32/riched20/table.c | 2 +- dll/win32/riched20/txthost.c | 150 +- dll/win32/riched20/txtsrv.c | 54 +- dll/win32/riched20/undo.c | 38 +- dll/win32/riched20/wrap.c | 39 +- dll/win32/riched20/writer.c | 64 +- media/doc/WINESYNC.txt | 2 +- .../winetests/riched20/CMakeLists.txt | 1 + modules/rostests/winetests/riched20/editor.c | 882 +++-- modules/rostests/winetests/riched20/richole.c | 3086 ++++++++++++----- modules/rostests/winetests/riched20/txtsrv.c | 443 ++- sdk/include/reactos/wine/rbtree.h | 261 +- sdk/tools/winesync/riched20.cfg | 6 + 29 files changed, 4214 insertions(+), 2262 deletions(-) create mode 100644 sdk/tools/winesync/riched20.cfg diff --git a/dll/win32/riched20/CMakeLists.txt b/dll/win32/riched20/CMakeLists.txt index 15e448ac204..719b54aa16e 100644 --- a/dll/win32/riched20/CMakeLists.txt +++ b/dll/win32/riched20/CMakeLists.txt @@ -1,6 +1,5 @@ remove_definitions(-D_CRT_NON_CONFORMING_SWPRINTFS) -add_definitions(-D__ROS_LONG64__) include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine) spec2def(riched20.dll riched20.spec ADD_IMPORTLIB) @@ -44,7 +43,7 @@ endif() add_typelib(riched_tom.idl) add_dependencies(riched20 stdole2) set_module_type(riched20 win32dll) -target_link_libraries(riched20 wine uuid) +target_link_libraries(riched20 wine uuid oldnames) add_importlibs(riched20 ole32 oleaut32 usp10 imm32 user32 gdi32 msvcrt kernel32 ntdll) add_pch(riched20 precomp.h SOURCE) add_cd_file(TARGET riched20 DESTINATION reactos/system32 FOR all) diff --git a/dll/win32/riched20/caret.c b/dll/win32/riched20/caret.c index 4785650bb78..2f49085f8ad 100644 --- a/dll/win32/riched20/caret.c +++ b/dll/win32/riched20/caret.c @@ -39,14 +39,14 @@ static void ME_SetCursorToEnd(ME_TextEditor *editor, ME_Cursor *cursor, BOOL fin } -int ME_GetSelectionOfs(ME_TextEditor *editor, int *from, int *to) +int ME_GetSelectionOfs(ME_TextEditor *editor, LONG *from, LONG *to) { *from = ME_GetCursorOfs(&editor->pCursors[0]); *to = ME_GetCursorOfs(&editor->pCursors[1]); if (*from > *to) { - int tmp = *from; + LONG tmp = *from; *from = *to; *to = tmp; return 1; @@ -160,7 +160,7 @@ int set_selection_cursors(ME_TextEditor *editor, int from, int to) /* deselected and caret moved to end of the current selection */ if (from < 0) { - int start, end; + LONG start, end; ME_GetSelectionOfs(editor, &start, &end); if (start != end) { @@ -461,7 +461,7 @@ BOOL ME_InternalDeleteText(ME_TextEditor *editor, ME_Cursor *start, /* c = updated data now */ if (c.run == cursor.run) c.run->nCharOfs -= shift; - editor_propagate_char_ofs( NULL, c.run, shift ); + editor_propagate_char_ofs( editor, NULL, c.run, shift ); if (!cursor.run->len) { @@ -487,9 +487,9 @@ BOOL ME_DeleteTextAtCursor(ME_TextEditor *editor, int nCursor, int nChars) nChars, FALSE); } -static struct re_object* create_re_object(const REOBJECT *reo) +static struct re_object* create_re_object(const REOBJECT *reo, ME_Run *run) { - struct re_object *reobj = heap_alloc(sizeof(*reobj)); + struct re_object *reobj = malloc(sizeof(*reobj)); if (!reobj) { @@ -497,24 +497,54 @@ static struct re_object* create_re_object(const REOBJECT *reo) return NULL; } ME_CopyReObject(&reobj->obj, reo, REO_GETOBJ_ALL_INTERFACES); + reobj->run = run; return reobj; } -void ME_InsertOLEFromCursor(ME_TextEditor *editor, const REOBJECT* reo, int nCursor) +HRESULT editor_insert_oleobj(ME_TextEditor *editor, const REOBJECT *reo) { ME_Run *run, *prev; const WCHAR space = ' '; struct re_object *reobj_prev = NULL; - ME_Cursor *cursor = editor->pCursors + nCursor; - ME_Style *style = style_get_insert_style( editor, cursor ); + ME_Cursor *cursor, cursor_from_ofs; + ME_Style *style; + HRESULT hr; + SIZEL extent; + + if (editor->lpOleCallback) + { + hr = IRichEditOleCallback_QueryInsertObject(editor->lpOleCallback, (LPCLSID)&reo->clsid, reo->pstg, REO_CP_SELECTION); + if (hr != S_OK) + return hr; + } + + extent = reo->sizel; + if (!extent.cx && !extent.cy && reo->poleobj) + { + hr = IOleObject_GetExtent( reo->poleobj, DVASPECT_CONTENT, &extent ); + if (FAILED(hr)) + { + extent.cx = 0; + extent.cy = 0; + } + } + + if (reo->cp == REO_CP_SELECTION) + cursor = editor->pCursors; + else + { + cursor_from_char_ofs( editor, reo->cp, &cursor_from_ofs ); + cursor = &cursor_from_ofs; + } + style = style_get_insert_style( editor, cursor ); - /* FIXME no no no */ if (ME_IsSelection(editor)) ME_DeleteSelection(editor); run = run_insert( editor, cursor, style, &space, 1, MERF_GRAPHICS ); - run->reobj = create_re_object( reo ); + run->reobj = create_re_object( reo, run ); + run->reobj->obj.sizel = extent; prev = run; while ((prev = run_prev_all_paras( prev ))) @@ -531,6 +561,7 @@ void ME_InsertOLEFromCursor(ME_TextEditor *editor, const REOBJECT* reo, int nCur list_add_head(&editor->reobj_list, &run->reobj->entry); ME_ReleaseStyle( style ); + return S_OK; } @@ -816,15 +847,18 @@ ME_MoveCursorWords(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs) } else { - para = para_next( para ); - if (!para_next( para )) + ME_Paragraph *other_para = para_next( para ); + if (!para_next( other_para )) { if (cursor->run == run) return FALSE; nOffset = 0; break; } - if (para->nFlags & MEPF_ROWSTART) para = para_next( para ); - if (cursor->run == run) run = para_first_run( para ); + if (other_para->nFlags & MEPF_ROWSTART) other_para = para_next( other_para ); + if (cursor->run == run) { + para = other_para; + run = para_first_run( para ); + } nOffset = 0; break; } @@ -1030,32 +1064,17 @@ static BOOL cursor_from_virtual_coords( ME_TextEditor *editor, int x, int y, * * x & y are pixel positions in client coordinates. * - * isExact will be set to TRUE if the run is directly under the pixel - * position, FALSE if it not, unless isExact is set to NULL. - * - * return FALSE if outside client area and the cursor is not set, - * otherwise TRUE is returned. + * return TRUE if the run is directly under the pixel + * position, FALSE if it not. */ -BOOL ME_CharFromPos(ME_TextEditor *editor, int x, int y, - ME_Cursor *cursor, BOOL *isExact) +BOOL cursor_from_coords( ME_TextEditor *editor, int x, int y, ME_Cursor *cursor ) { - RECT rc; - BOOL bResult; - - ITextHost_TxGetClientRect(editor->texthost, &rc); - if (x < 0 || y < 0 || x >= rc.right || y >= rc.bottom) { - if (isExact) *isExact = FALSE; - return FALSE; - } - x += editor->horz_si.nPos; - y += editor->vert_si.nPos; - bResult = cursor_from_virtual_coords( editor, x, y, cursor, FALSE ); - if (isExact) *isExact = bResult; - return TRUE; + x += editor->horz_si.nPos; + y += editor->vert_si.nPos; + return cursor_from_virtual_coords( editor, x, y, cursor, FALSE ); } - /* Extends the selection with a word, line, or paragraph selection type. * * The selection is anchored by editor->pCursors[2-3] such that the text @@ -1405,7 +1424,7 @@ BOOL ME_IsSelection(ME_TextEditor *editor) void ME_DeleteSelection(ME_TextEditor *editor) { - int from, to; + LONG from, to; int nStartCursor = ME_GetSelectionOfs(editor, &from, &to); int nEndCursor = nStartCursor ^ 1; ME_DeleteTextAtCursor(editor, nStartCursor, to - from); @@ -1439,7 +1458,7 @@ void ME_SendSelChange(ME_TextEditor *editor) if (editor->nEventMask & ENM_SELCHANGE) { - TRACE("cpMin=%d cpMax=%d seltyp=%d (%s %s)\n", + TRACE("cpMin=%ld cpMax=%ld seltyp=%d (%s %s)\n", sc.chrg.cpMin, sc.chrg.cpMax, sc.seltyp, (sc.seltyp & SEL_TEXT) ? "SEL_TEXT" : "", (sc.seltyp & SEL_MULTICHAR) ? "SEL_MULTICHAR" : ""); diff --git a/dll/win32/riched20/clipboard.c b/dll/win32/riched20/clipboard.c index 10a814214be..65d317b6bc7 100644 --- a/dll/win32/riched20/clipboard.c +++ b/dll/win32/riched20/clipboard.c @@ -18,8 +18,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#define NONAMELESSUNION - #include "editor.h" WINE_DEFAULT_DEBUG_CHANNEL(richedit); @@ -77,7 +75,7 @@ static ULONG WINAPI EnumFormatImpl_AddRef(IEnumFORMATETC *iface) { EnumFormatImpl *This = impl_from_IEnumFORMATETC(iface); LONG ref = InterlockedIncrement(&This->ref); - TRACE("(%p) ref=%d\n", This, ref); + TRACE("(%p) ref=%ld\n", This, ref); return ref; } @@ -85,11 +83,11 @@ static ULONG WINAPI EnumFormatImpl_Release(IEnumFORMATETC *iface) { EnumFormatImpl *This = impl_from_IEnumFORMATETC(iface); ULONG ref = InterlockedDecrement(&This->ref); - TRACE("(%p) ref=%d\n", This, ref); + TRACE("(%p) ref=%ld\n", This, ref); if(!ref) { GlobalFree(This->fmtetc); - heap_free(This); + free(This); } return ref; @@ -100,7 +98,7 @@ static HRESULT WINAPI EnumFormatImpl_Next(IEnumFORMATETC *iface, ULONG celt, { EnumFormatImpl *This = impl_from_IEnumFORMATETC(iface); ULONG count = 0; - TRACE("(%p)->(%d %p %p)\n", This, celt, rgelt, pceltFetched); + TRACE("(%p)->(%ld %p %p)\n", This, celt, rgelt, pceltFetched); if(!rgelt) return E_INVALIDARG; @@ -119,7 +117,7 @@ static HRESULT WINAPI EnumFormatImpl_Skip(IEnumFORMATETC *iface, ULONG celt) { EnumFormatImpl *This = impl_from_IEnumFORMATETC(iface); ULONG count = 0; - TRACE("(%p)->(%d)\n", This, celt); + TRACE("(%p)->(%ld)\n", This, celt); count = min(celt, This->fmtetc_cnt-This->cur); This->cur += count; @@ -165,7 +163,7 @@ static HRESULT EnumFormatImpl_Create(const FORMATETC *fmtetc, UINT fmtetc_cnt, EnumFormatImpl *ret; TRACE("\n"); - ret = heap_alloc(sizeof(EnumFormatImpl)); + ret = malloc(sizeof(EnumFormatImpl)); ret->IEnumFORMATETC_iface.lpVtbl = &VT_EnumFormatImpl; ret->ref = 1; ret->cur = 0; @@ -194,7 +192,7 @@ static ULONG WINAPI DataObjectImpl_AddRef(IDataObject* iface) { DataObjectImpl *This = impl_from_IDataObject(iface); ULONG ref = InterlockedIncrement(&This->ref); - TRACE("(%p) ref=%d\n", This, ref); + TRACE("(%p) ref=%ld\n", This, ref); return ref; } @@ -202,13 +200,13 @@ static ULONG WINAPI DataObjectImpl_Release(IDataObject* iface) { DataObjectImpl *This = impl_from_IDataObject(iface); ULONG ref = InterlockedDecrement(&This->ref); - TRACE("(%p) ref=%d\n",This, ref); + TRACE("(%p) ref=%ld\n",This, ref); if(!ref) { if(This->unicode) GlobalFree(This->unicode); if(This->rtf) GlobalFree(This->rtf); if(This->fmtetc) GlobalFree(This->fmtetc); - heap_free(This); + free(This); } return ref; @@ -217,7 +215,7 @@ static ULONG WINAPI DataObjectImpl_Release(IDataObject* iface) static HRESULT WINAPI DataObjectImpl_GetData(IDataObject* iface, FORMATETC *pformatetc, STGMEDIUM *pmedium) { DataObjectImpl *This = impl_from_IDataObject(iface); - TRACE("(%p)->(fmt=0x%08x tym=0x%08x)\n", This, pformatetc->cfFormat, pformatetc->tymed); + TRACE("(%p)->(fmt=0x%08x tym=0x%08lx)\n", This, pformatetc->cfFormat, pformatetc->tymed); if(pformatetc->lindex != -1) return DV_E_LINDEX; @@ -226,9 +224,9 @@ static HRESULT WINAPI DataObjectImpl_GetData(IDataObject* iface, FORMATETC *pfor return DV_E_TYMED; if(This->unicode && pformatetc->cfFormat == CF_UNICODETEXT) - pmedium->u.hGlobal = This->unicode; + pmedium->hGlobal = This->unicode; else if(This->rtf && pformatetc->cfFormat == cfRTF) - pmedium->u.hGlobal = This->rtf; + pmedium->hGlobal = This->rtf; else return DV_E_FORMATETC; @@ -250,7 +248,7 @@ static HRESULT WINAPI DataObjectImpl_QueryGetData(IDataObject* iface, FORMATETC DataObjectImpl *This = impl_from_IDataObject(iface); UINT i; BOOL foundFormat = FALSE; - TRACE("(%p)->(fmt=0x%08x tym=0x%08x)\n", This, pformatetc->cfFormat, pformatetc->tymed); + TRACE("(%p)->(fmt=0x%08x tym=0x%08lx)\n", This, pformatetc->cfFormat, pformatetc->tymed); if(pformatetc->lindex != -1) return DV_E_LINDEX; @@ -290,10 +288,10 @@ static HRESULT WINAPI DataObjectImpl_EnumFormatEtc(IDataObject* iface, DWORD dwD IEnumFORMATETC **ppenumFormatEtc) { DataObjectImpl *This = impl_from_IDataObject(iface); - TRACE("(%p)->(%d)\n", This, dwDirection); + TRACE("(%p)->(%ld)\n", This, dwDirection); if(dwDirection != DATADIR_GET) { - FIXME("Unsupported direction: %d\n", dwDirection); + FIXME("Unsupported direction: %ld\n", dwDirection); /* WinXP riched20 also returns E_NOTIMPL in this case */ *ppenumFormatEtc = NULL; return E_NOTIMPL; @@ -375,7 +373,7 @@ static DWORD CALLBACK ME_AppendToHGLOBAL(DWORD_PTR dwCookie, LPBYTE lpBuff, LONG if (pData->nLength+cb+1 >= cb) { /* round up to 2^17 */ int nNewSize = (((nMaxSize+cb+1)|0x1FFFF)+1) & 0xFFFE0000; - pData->hData = GlobalReAlloc(pData->hData, nNewSize, 0); + pData->hData = GlobalReAlloc(pData->hData, nNewSize, GMEM_MOVEABLE); } pDest = GlobalLock(pData->hData); memcpy(pDest + pData->nLength, lpBuff, cb); @@ -397,7 +395,7 @@ static HGLOBAL get_rtf_text(ME_TextEditor *editor, const ME_Cursor *start, int n es.dwCookie = (DWORD_PTR)&gds; es.pfnCallback = ME_AppendToHGLOBAL; ME_StreamOutRange(editor, SF_RTF, start, nChars, &es); - GlobalReAlloc(gds.hData, gds.nLength+1, 0); + GlobalReAlloc(gds.hData, gds.nLength+1, GMEM_MOVEABLE); return gds.hData; } @@ -407,7 +405,7 @@ HRESULT ME_GetDataObject(ME_TextEditor *editor, const ME_Cursor *start, int nCha DataObjectImpl *obj; TRACE("(%p,%d,%d)\n", editor, ME_GetCursorOfs(start), nChars); - obj = heap_alloc(sizeof(DataObjectImpl)); + obj = malloc(sizeof(DataObjectImpl)); if(cfRTF == 0) cfRTF = RegisterClipboardFormatA("Rich Text Format"); diff --git a/dll/win32/riched20/editor.c b/dll/win32/riched20/editor.c index 5c602d5f74e..b2a0f78200c 100644 --- a/dll/win32/riched20/editor.c +++ b/dll/win32/riched20/editor.c @@ -224,8 +224,6 @@ * */ -#define NONAMELESSUNION - #include "editor.h" #include "commdlg.h" #include "winreg.h" @@ -254,10 +252,9 @@ static BOOL ME_UpdateLinkAttribute(ME_TextEditor *editor, ME_Cursor *start, int HINSTANCE dll_instance = NULL; BOOL me_debug = FALSE; -HANDLE me_heap = NULL; static ME_TextBuffer *ME_MakeText(void) { - ME_TextBuffer *buf = heap_alloc(sizeof(*buf)); + ME_TextBuffer *buf = malloc(sizeof(*buf)); ME_DisplayItem *p1 = ME_MakeDI(diTextStart); ME_DisplayItem *p2 = ME_MakeDI(diTextEnd); @@ -302,7 +299,7 @@ static LRESULT ME_StreamInText(ME_TextEditor *editor, DWORD dwFormat, ME_InStrea static const char bom_utf8[] = {0xEF, 0xBB, 0xBF}; - TRACE("%08x %p\n", dwFormat, stream); + TRACE("%08lx %p\n", dwFormat, stream); do { LONG nWideChars = 0; @@ -618,7 +615,7 @@ void ME_RTFParAttrHook(RTF_Info *info) { while (info->rtfParam > info->nestingLevel) { - RTFTable *tableDef = heap_alloc_zero(sizeof(*tableDef)); + RTFTable *tableDef = calloc(1, sizeof(*tableDef)); tableDef->parent = info->tableDef; info->tableDef = tableDef; @@ -652,7 +649,7 @@ void ME_RTFParAttrHook(RTF_Info *info) ME_Paragraph *para; if (!info->tableDef) - info->tableDef = heap_alloc_zero(sizeof(*info->tableDef)); + info->tableDef = calloc(1, sizeof(*info->tableDef)); tableDef = info->tableDef; RTFFlushOutputBuffer(info); if (tableDef->row_start && tableDef->row_start->nFlags & MEPF_ROWEND) @@ -1070,14 +1067,14 @@ void ME_RTFSpecialCharHook(RTF_Info *info) { tableDef = info->tableDef; info->tableDef = tableDef->parent; - heap_free(tableDef); + free(tableDef); } } } else { info->tableDef = tableDef->parent; - heap_free(tableDef); + free(tableDef); } } else /* v1.0 - v3.0 */ @@ -1138,13 +1135,13 @@ static HRESULT insert_static_object(ME_TextEditor *editor, HENHMETAFILE hemf, HB if (hemf) { stgm.tymed = TYMED_ENHMF; - stgm.u.hEnhMetaFile = hemf; + stgm.hEnhMetaFile = hemf; fm.cfFormat = CF_ENHMETAFILE; } else if (hbmp) { stgm.tymed = TYMED_GDI; - stgm.u.hBitmap = hbmp; + stgm.hBitmap = hbmp; fm.cfFormat = CF_BITMAP; } else return E_FAIL; @@ -1180,8 +1177,7 @@ static HRESULT insert_static_object(ME_TextEditor *editor, HENHMETAFILE hemf, HB reobject.dwFlags = 0; /* FIXME */ reobject.dwUser = 0; - ME_InsertOLEFromCursor(editor, &reobject, 0); - hr = S_OK; + hr = editor_insert_oleobj(editor, &reobject); } if (lpObject) IOleObject_Release(lpObject); @@ -1236,7 +1232,7 @@ static DWORD read_hex_data( RTF_Info *info, BYTE **out ) return 0; } - buf = HeapAlloc( GetProcessHeap(), 0, size ); + buf = malloc(size); if (!buf) return 0; val = info->rtfMajor; @@ -1245,7 +1241,7 @@ static DWORD read_hex_data( RTF_Info *info, BYTE **out ) RTFGetToken( info ); if (info->rtfClass == rtfEOF) { - HeapFree( GetProcessHeap(), 0, buf ); + free(buf); return 0; } if (info->rtfClass != rtfText) break; @@ -1254,7 +1250,7 @@ static DWORD read_hex_data( RTF_Info *info, BYTE **out ) if (read >= size) { size *= 2; - buf = HeapReAlloc( GetProcessHeap(), 0, buf, size ); + buf = realloc(buf, size); if (!buf) return 0; } buf[read++] = RTFCharToHex(val) * 16 + RTFCharToHex(info->rtfMajor); @@ -1375,7 +1371,7 @@ static void ME_RTFReadPictGroup(RTF_Info *info) break; } } - HeapFree( GetProcessHeap(), 0, buffer ); + free( buffer ); RTFRouteToken( info ); /* feed "}" back to router */ return; } @@ -1576,14 +1572,15 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre { RTF_Info parser; ME_Style *style; - int from, to, nUndoMode; + LONG from, to; + int nUndoMode; int nEventMask = editor->nEventMask; ME_InStream inStream; BOOL invalidRTF = FALSE; ME_Cursor *selStart, *selEnd; LRESULT num_read = 0; /* bytes read for SF_TEXT, non-control chars inserted for SF_RTF */ - TRACE("stream==%p editor==%p format==0x%X\n", stream, editor, format); + TRACE("stream==%p editor==%p format==0x%lX\n", stream, editor, format); editor->nEventMask = 0; ME_GetSelectionOfs(editor, &from, &to); @@ -1618,9 +1615,17 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre { style = editor->pBuffer->pDefaultStyle; ME_AddRefStyle(style); - set_selection_cursors(editor, 0, 0); - ME_InternalDeleteText(editor, &editor->pCursors[1], - ME_GetTextLength(editor), FALSE); + if (format & SFF_SELECTION) + { + ME_GetSelection(editor, &selStart, &selEnd); + ME_InternalDeleteText(editor, selStart, to - from, FALSE); + } + else + { + set_selection_cursors(editor, 0, 0); + ME_InternalDeleteText(editor, &editor->pCursors[1], + ME_GetTextLength(editor), FALSE); + } from = to = 0; ME_ClearTempStyle(editor); editor_set_default_para_fmt( editor, &editor->pCursors[0].para->fmt ); @@ -1849,11 +1854,11 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH ME_Cursor cursor; WCHAR wLastChar = ' '; - TRACE("flags==0x%08x, chrg->cpMin==%d, chrg->cpMax==%d text==%s\n", + TRACE("flags==0x%08lx, chrg->cpMin==%ld, chrg->cpMax==%ld text==%s\n", flags, chrg->cpMin, chrg->cpMax, debugstr_w(text)); if (flags & ~(FR_DOWN | FR_MATCHCASE | FR_WHOLEWORD)) - FIXME("Flags 0x%08x not implemented\n", + FIXME("Flags 0x%08lx not implemented\n", flags & ~(FR_DOWN | FR_MATCHCASE | FR_WHOLEWORD)); nMin = chrg->cpMin; @@ -2092,11 +2097,11 @@ static int ME_GetTextEx(ME_TextEditor *editor, GETTEXTEX *ex, LPARAM pText) if (!ex->cb || !pText) return 0; if (ex->flags & ~(GT_SELECTION | GT_USECRLF)) - FIXME("GETTEXTEX flags 0x%08x not supported\n", ex->flags & ~(GT_SELECTION | GT_USECRLF)); + FIXME("GETTEXTEX flags 0x%08lx not supported\n", ex->flags & ~(GT_SELECTION | GT_USECRLF)); if (ex->flags & GT_SELECTION) { - int from, to; + LONG from, to; int nStartCur = ME_GetSelectionOfs(editor, &from, &to); start = editor->pCursors[nStartCur]; nChars = to - from; @@ -2124,14 +2129,14 @@ static int ME_GetTextEx(ME_TextEditor *editor, GETTEXTEX *ex, LPARAM pText) LRESULT rc; buflen = min(crlfmul * nChars, ex->cb - 1); - buffer = heap_alloc((buflen + 1) * sizeof(WCHAR)); + buffer = malloc((buflen + 1) * sizeof(WCHAR)); nChars = ME_GetTextW(editor, buffer, buflen, &start, nChars, ex->flags & GT_USECRLF, FALSE); rc = WideCharToMultiByte(ex->codepage, 0, buffer, nChars + 1, (LPSTR)pText, ex->cb, ex->lpDefaultChar, ex->lpUsedDefChar); if (rc) rc--; /* do not count 0 terminator */ - heap_free(buffer); + free(buffer); return rc; } } @@ -2151,8 +2156,10 @@ int set_selection( ME_TextEditor *editor, int to, int from ) if (!editor->bHideSelection) ME_InvalidateSelection( editor ); end = set_selection_cursors( editor, to, from ); + editor_ensure_visible( editor, &editor->pCursors[0] ); if (!editor->bHideSelection) ME_InvalidateSelection( editor ); update_caret( editor ); + ME_Repaint( editor ); ME_SendSelChange( editor ); return end; @@ -2205,7 +2212,7 @@ static HRESULT paste_rtf(ME_TextEditor *editor, FORMATETC *fmt, STGMEDIUM *med) ME_GlobalDestStruct gds; HRESULT hr; - gds.hData = med->u.hGlobal; + gds.hData = med->hGlobal; gds.nLength = 0; es.dwCookie = (DWORD_PTR)&gds; es.pfnCallback = ME_ReadFromHGLOBALRTF; @@ -2220,7 +2227,7 @@ static HRESULT paste_text(ME_TextEditor *editor, FORMATETC *fmt, STGMEDIUM *med) ME_GlobalDestStruct gds; HRESULT hr; - gds.hData = med->u.hGlobal; + gds.hData = med->hGlobal; gds.nLength = 0; es.dwCookie = (DWORD_PTR)&gds; es.pfnCallback = ME_ReadFromHGLOBALUnicode; @@ -2234,7 +2241,7 @@ static HRESULT paste_emf(ME_TextEditor *editor, FORMATETC *fmt, STGMEDIUM *med) HRESULT hr; SIZEL sz = {0, 0}; - hr = insert_static_object( editor, med->u.hEnhMetaFile, NULL, &sz ); + hr = insert_static_object( editor, med->hEnhMetaFile, NULL, &sz ); if (SUCCEEDED(hr)) { ME_CommitUndo( editor ); @@ -2292,7 +2299,7 @@ static BOOL paste_special(ME_TextEditor *editor, UINT cf, REPASTESPECIAL *ps, BO init_paste_formats(); if (ps && ps->dwAspect != DVASPECT_CONTENT) - FIXME("Ignoring aspect %x\n", ps->dwAspect); + FIXME("Ignoring aspect %lx\n", ps->dwAspect); hr = OleGetClipboard( &data ); if (hr != S_OK) return FALSE; @@ -2375,7 +2382,7 @@ HRESULT editor_copy_or_cut( ME_TextEditor *editor, BOOL cut, ME_Cursor *start, i static BOOL copy_or_cut( ME_TextEditor *editor, BOOL cut ) { HRESULT hr; - int offs, count; + LONG offs, count; int start_cursor = ME_GetSelectionOfs( editor, &offs, &count ); ME_Cursor *sel_start = &editor->pCursors[start_cursor]; @@ -2421,7 +2428,7 @@ static BOOL handle_enter(ME_TextEditor *editor) { ME_Cursor cursor = editor->pCursors[0]; ME_Paragraph *para = cursor.para; - int from, to; + LONG from, to; ME_Style *style, *eop_style; if (editor->props & TXTBIT_READONLY) @@ -2698,7 +2705,7 @@ static LRESULT handle_wm_char( ME_TextEditor *editor, WCHAR wstr, LPARAM flags ) { ME_Cursor cursor = editor->pCursors[0]; ME_Paragraph *para = cursor.para; - int from, to; + LONG from, to; BOOL ctrl_is_down = GetKeyState(VK_CONTROL) & 0x8000; ME_GetSelectionOfs(editor, &from, &to); if (wstr == '\t' && @@ -2824,7 +2831,6 @@ static BOOL is_link( ME_Run *run ) void editor_set_cursor( ME_TextEditor *editor, int x, int y ) { ME_Cursor pos; - BOOL is_exact; static HCURSOR cursor_arrow, cursor_hand, cursor_ibeam, cursor_reverse; HCURSOR cursor; @@ -2847,22 +2853,19 @@ void editor_set_cursor( ME_TextEditor *editor, int x, int y ) else cursor = cursor_ibeam; } else if (x < editor->rcFormat.left) cursor = cursor_reverse; - else + else if (cursor_from_coords( editor, x, y, &pos )) { - ME_CharFromPos( editor, x, y, &pos, &is_exact ); - if (is_exact) + ME_Run *run = pos.run; + + if (is_link( run )) cursor = cursor_hand; + + else if (ME_IsSelection( editor )) { - ME_Run *run = pos.run; + LONG start, end; + int offset = ME_GetCursorOfs( &pos ); - if (is_link( run )) cursor = cursor_hand; - - else if (ME_IsSelection( editor )) - { - int start, end, offset = ME_GetCursorOfs( &pos ); - - ME_GetSelectionOfs( editor, &start, &end ); - if (start <= offset && end >= offset) cursor = cursor_arrow; - } + ME_GetSelectionOfs( editor, &start, &end ); + if (start <= offset && end >= offset) cursor = cursor_arrow; } } @@ -2932,10 +2935,11 @@ static BOOL ME_ShowContextMenu(ME_TextEditor *editor, int x, int y) ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10) { - ME_TextEditor *ed = heap_alloc(sizeof(*ed)); + ME_TextEditor *ed = malloc( sizeof(*ed) ); int i; LONG selbarwidth; HRESULT hr; + HDC hdc; ed->sizeWindow.cx = ed->sizeWindow.cy = 0; if (ITextHost_QueryInterface( texthost, &IID_ITextHost2, (void **)&ed->texthost ) == S_OK) @@ -2962,7 +2966,9 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10) ed->nZoomNumerator = ed->nZoomDenominator = 0; ed->nAvailWidth = 0; /* wrap to client area */ list_init( &ed->style_list ); - ME_MakeFirstParagraph(ed); + + hdc = ITextHost_TxGetDC( ed->texthost ); + ME_MakeFirstParagraph( ed, hdc ); /* The four cursors are for: * 0 - The position where the caret is shown * 1 - The anchored end of the selection (for normal selection) @@ -2970,7 +2976,7 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10) * or paragraph selection. */ ed->nCursors = 4; - ed->pCursors = heap_alloc(ed->nCursors * sizeof(*ed->pCursors)); + ed->pCursors = malloc( ed->nCursors * sizeof(*ed->pCursors) ); ME_SetCursorToStart(ed, &ed->pCursors[0]); ed->pCursors[1] = ed->pCursors[0]; ed->pCursors[2] = ed->pCursors[0]; @@ -2986,6 +2992,7 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10) ed->nUndoStackSize = 0; ed->nUndoLimit = STACK_SIZE_DEFAULT; ed->nUndoMode = umAddToUndo; + ed->undo_ctl_state = undoActive; ed->nParagraphs = 1; ed->nLastSelStart = ed->nLastSelEnd = 0; ed->last_sel_start_para = ed->last_sel_end_para = ed->pCursors[0].para; @@ -2997,6 +3004,7 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10) ed->mode |= (ed->props & TXTBIT_RICHTEXT) ? TM_RICHTEXT : TM_PLAINTEXT; ed->AutoURLDetect_bEnable = FALSE; ed->bHaveFocus = FALSE; + ed->freeze_count = 0; ed->bMouseCaptured = FALSE; ed->caret_hidden = FALSE; ed->caret_height = 0; @@ -3060,6 +3068,9 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10) list_init( &ed->reobj_list ); OleInitialize(NULL); + wrap_marked_paras_dc( ed, hdc, FALSE ); + ITextHost_TxReleaseDC( ed->texthost, hdc ); + return ed; } @@ -3096,9 +3107,9 @@ void ME_DestroyEditor(ME_TextEditor *editor) OleUninitialize(); - heap_free(editor->pBuffer); - heap_free(editor->pCursors); - heap_free(editor); + free(editor->pBuffer); + free(editor->pCursors); + free(editor); } static inline int get_default_line_height( ME_TextEditor *editor ) @@ -3122,15 +3133,13 @@ static inline int calc_wheel_change( int *remain, int amount_per_click ) void link_notify(ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM lParam) { int x,y; - BOOL isExact; ME_Cursor cursor; /* The start of the clicked text. */ ME_Run *run; ENLINK info; x = (short)LOWORD(lParam); y = (short)HIWORD(lParam); - ME_CharFromPos(editor, x, y, &cursor, &isExact); - if (!isExact) return; + if (!cursor_from_coords( editor, x, y, &cursor )) return; if (is_link( cursor.run )) { /* The clicked run has CFE_LINK set */ @@ -3160,7 +3169,8 @@ void link_notify(ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM lParam) void ME_ReplaceSel(ME_TextEditor *editor, BOOL can_undo, const WCHAR *str, int len) { - int from, to, nStartCursor; + LONG from, to; + int nStartCursor; ME_Style *style; nStartCursor = ME_GetSelectionOfs(editor, &from, &to); @@ -3295,10 +3305,10 @@ LRESULT editor_handle_message( ME_TextEditor *editor, UINT msg, WPARAM wParam, case EM_GETSEL: { /* Note: wParam/lParam can be NULL */ - UINT from, to; - PUINT pfrom = wParam ? (PUINT)wParam : &from; - PUINT pto = lParam ? (PUINT)lParam : &to; - ME_GetSelectionOfs(editor, (int *)pfrom, (int *)pto); + LONG from, to; + LONG *pfrom = wParam ? (LONG *)wParam : &from; + LONG *pto = lParam ? (LONG *)lParam : &to; + ME_GetSelectionOfs(editor, pfrom, pto); if ((*pfrom|*pto) & 0xFFFF0000) return -1; return MAKELONG(*pfrom,*pto); @@ -3307,11 +3317,12 @@ LRESULT editor_handle_message( ME_TextEditor *editor, UINT msg, WPARAM wParam, { CHARRANGE *pRange = (CHARRANGE *)lParam; ME_GetSelectionOfs(editor, &pRange->cpMin, &pRange->cpMax); - TRACE("EM_EXGETSEL = (%d,%d)\n", pRange->cpMin, pRange->cpMax); + TRACE("EM_EXGETSEL = (%ld,%ld)\n", pRange->cpMin, pRange->cpMax); return 0; } case EM_SETUNDOLIMIT: { + editor_enable_undo(editor); if ((int)wParam < 0) editor->nUndoLimit = STACK_SIZE_DEFAULT; else @@ -3404,7 +3415,8 @@ LRESULT editor_handle_message( ME_TextEditor *editor, UINT msg, WPARAM wParam, { LPWSTR wszText; SETTEXTEX *pStruct = (SETTEXTEX *)wParam; - int from, to, len; + LONG from, to; + int len; ME_Style *style; BOOL bRtf, bUnicode, bSelection, bUTF8; int oldModify = editor->nModifyStep; @@ -3419,7 +3431,7 @@ LRESULT editor_handle_message( ME_TextEditor *editor, UINT msg, WPARAM wParam, bUnicode = !bRtf && pStruct->codepage == CP_UNICODE; bUTF8 = (lParam && (!strncmp((char *)lParam, utf8_bom, 3))); - TRACE("EM_SETTEXTEX - %s, flags %d, cp %d\n", + TRACE("EM_SETTEXTEX - %s, flags %ld, cp %d\n", bUnicode ? debugstr_w((LPCWSTR)lParam) : debugstr_a((LPCSTR)lParam), pStruct->flags, pStruct->codepage); @@ -3561,7 +3573,7 @@ LRESULT editor_handle_message( ME_TextEditor *editor, UINT msg, WPARAM wParam, } case WM_CLEAR: { - int from, to; + LONG from, to; int nStartCursor = ME_GetSelectionOfs(editor, &from, &to); ME_InternalDeleteText(editor, &editor->pCursors[nStartCursor], to-from, FALSE); ME_CommitUndo(editor); @@ -3626,7 +3638,7 @@ LRESULT editor_handle_message( ME_TextEditor *editor, UINT msg, WPARAM wParam, ME_InternalDeleteText(editor, &cursor, ME_GetTextLength(editor), FALSE); if (lParam) { - TRACE("WM_SETTEXT lParam==%lx\n",lParam); + TRACE("WM_SETTEXT lParam==%Ix\n",lParam); if (!strncmp((char *)lParam, "{\\rtf", 5) || !strncmp((char *)lParam, "{\\urtf", 6)) { @@ -3684,7 +3696,8 @@ LRESULT editor_handle_message( ME_TextEditor *editor, UINT msg, WPARAM wParam, return ME_GetTextEx(editor, (GETTEXTEX*)wParam, lParam); case EM_GETSELTEXT: { - int nFrom, nTo, nStartCur = ME_GetSelectionOfs(editor, &nFrom, &nTo); + LONG nFrom, nTo; + int nStartCur = ME_GetSelectionOfs(editor, &nFrom, &nTo); ME_Cursor *from = &editor->pCursors[nStartCur]; return get_text_range( editor, (WCHAR *)lParam, from, nTo - nFrom ); } @@ -3708,7 +3721,7 @@ LRESULT editor_handle_message( ME_TextEditor *editor, UINT msg, WPARAM wParam, int nEnd = rng->chrg.cpMax; int textlength = ME_GetTextLength(editor); - TRACE( "EM_GETTEXTRANGE min = %d max = %d textlength = %d\n", rng->chrg.cpMin, rng->chrg.cpMax, textlength ); + TRACE( "EM_GETTEXTRANGE min = %ld max = %ld textlength = %d\n", rng->chrg.cpMin, rng->chrg.cpMax, textlength ); if (nStart < 0) return 0; if ((nStart == 0 && nEnd == -1) || nEnd > textlength) nEnd = textlength; @@ -3822,7 +3835,7 @@ LRESULT editor_handle_message( ME_TextEditor *editor, UINT msg, WPARAM wParam, start_ofs = ME_GetCursorOfs( &cursor ); row_end_cursor( row, &cursor, FALSE ); end_ofs = ME_GetCursorOfs( &cursor ); - TRACE( "EM_LINELENGTH(%ld)==%d\n", wParam, end_ofs - start_ofs ); + TRACE( "EM_LINELENGTH(%Id)==%d\n", wParam, end_ofs - start_ofs ); return end_ofs - start_ofs; } case EM_EXLIMITTEXT: @@ -3870,11 +3883,10 @@ LRESULT editor_handle_message( ME_TextEditor *editor, UINT msg, WPARAM wParam, case EM_CHARFROMPOS: { ME_Cursor cursor; - if (ME_CharFromPos(editor, ((POINTL *)lParam)->x, ((POINTL *)lParam)->y, - &cursor, NULL)) - return ME_GetCursorOfs(&cursor); - else - return -1; + POINTL *pt = (POINTL *)lParam; + + cursor_from_coords(editor, pt->x, pt->y, &cursor); + return ME_GetCursorOfs(&cursor); } case EM_POSFROMCHAR: { @@ -4174,20 +4186,23 @@ LRESULT editor_handle_message( ME_TextEditor *editor, UINT msg, WPARAM wParam, dwIndex = GCS_COMPSTR; dwBufLen = ImmGetCompositionStringW(hIMC, dwIndex, NULL, 0); - lpCompStr = HeapAlloc(GetProcessHeap(),0,dwBufLen + sizeof(WCHAR)); + lpCompStr = malloc(dwBufLen + sizeof(WCHAR)); ImmGetCompositionStringW(hIMC, dwIndex, lpCompStr, dwBufLen); lpCompStr[dwBufLen/sizeof(WCHAR)] = 0; #ifndef __REACTOS__ ME_InsertTextFromCursor(editor,0,lpCompStr,dwBufLen/sizeof(WCHAR),style); #endif - HeapFree(GetProcessHeap(), 0, lpCompStr); + free(lpCompStr); #ifndef __REACTOS__ if (dwIndex == GCS_COMPSTR) set_selection_cursors(editor,editor->imeStartIndex, editor->imeStartIndex + dwBufLen/sizeof(WCHAR)); + else + editor->imeStartIndex = ME_GetCursorOfs(&editor->pCursors[0]); #endif } + ITextHost_TxImmReleaseContext(editor->texthost, hIMC); ME_ReleaseStyle(style); ME_CommitUndo(editor); ME_UpdateRepaint(editor, FALSE); @@ -4357,11 +4372,7 @@ int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int buflen, str = get_text( run, 0 ); } /* append '\r' to the last paragraph. */ -#ifdef __REACTOS__ if (run == para_end_run( para_prev( editor_end_para( editor ) ) ) && bEOP && buflen) -#else - if (run == para_end_run( para_prev( editor_end_para( editor ) ) ) && bEOP) -#endif { *buffer = '\r'; buffer ++; diff --git a/dll/win32/riched20/editor.h b/dll/win32/riched20/editor.h index 9f05a9e6c95..be582f24ae4 100644 --- a/dll/win32/riched20/editor.h +++ b/dll/win32/riched20/editor.h @@ -24,8 +24,7 @@ struct _RTF_Info; -extern HINSTANCE dll_instance DECLSPEC_HIDDEN; -extern HANDLE me_heap DECLSPEC_HIDDEN; +extern HINSTANCE dll_instance; #define RUN_IS_HIDDEN(run) ((run)->style->fmt.dwMask & CFM_HIDDEN \ && (run)->style->fmt.dwEffects & CFE_HIDDEN) @@ -50,51 +49,51 @@ static inline const char *debugstr_run( const ME_Run *run ) } /* style.c */ -ME_Style *style_get_insert_style( ME_TextEditor *editor, ME_Cursor *cursor ) DECLSPEC_HIDDEN; -ME_Style *ME_MakeStyle(CHARFORMAT2W *style) DECLSPEC_HIDDEN; -void ME_AddRefStyle(ME_Style *item) DECLSPEC_HIDDEN; -void ME_DestroyStyle(ME_Style *item) DECLSPEC_HIDDEN; -void ME_ReleaseStyle(ME_Style *item) DECLSPEC_HIDDEN; -ME_Style *ME_ApplyStyle(ME_TextEditor *ed, ME_Style *sSrc, CHARFORMAT2W *style) DECLSPEC_HIDDEN; -void select_style(ME_Context *c, ME_Style *s) DECLSPEC_HIDDEN; -void ME_InitCharFormat2W(CHARFORMAT2W *pFmt) DECLSPEC_HIDDEN; -void ME_SaveTempStyle(ME_TextEditor *editor, ME_Style *style) DECLSPEC_HIDDEN; -void ME_ClearTempStyle(ME_TextEditor *editor) DECLSPEC_HIDDEN; -void ME_DumpStyleToBuf(CHARFORMAT2W *pFmt, char buf[2048]) DECLSPEC_HIDDEN; -void ME_DumpStyle(ME_Style *s) DECLSPEC_HIDDEN; -BOOL cfany_to_cf2w(CHARFORMAT2W *to, const CHARFORMAT2W *from) DECLSPEC_HIDDEN; -BOOL cf2w_to_cfany(CHARFORMAT2W *to, const CHARFORMAT2W *from) DECLSPEC_HIDDEN; -void ME_CopyCharFormat(CHARFORMAT2W *pDest, const CHARFORMAT2W *pSrc) DECLSPEC_HIDDEN; /* only works with 2W structs */ -void ME_CharFormatFromLogFont(HDC hDC, const LOGFONTW *lf, CHARFORMAT2W *fmt) DECLSPEC_HIDDEN; /* ditto */ +ME_Style *style_get_insert_style( ME_TextEditor *editor, ME_Cursor *cursor ); +ME_Style *ME_MakeStyle(CHARFORMAT2W *style); +void ME_AddRefStyle(ME_Style *item); +void ME_DestroyStyle(ME_Style *item); +void ME_ReleaseStyle(ME_Style *item); +ME_Style *ME_ApplyStyle(ME_TextEditor *ed, ME_Style *sSrc, CHARFORMAT2W *style); +void select_style(ME_Context *c, ME_Style *s); +void ME_InitCharFormat2W(CHARFORMAT2W *pFmt); +void ME_SaveTempStyle(ME_TextEditor *editor, ME_Style *style); +void ME_ClearTempStyle(ME_TextEditor *editor); +void ME_DumpStyleToBuf(CHARFORMAT2W *pFmt, char buf[2048]); +void ME_DumpStyle(ME_Style *s); +BOOL cfany_to_cf2w(CHARFORMAT2W *to, const CHARFORMAT2W *from); +BOOL cf2w_to_cfany(CHARFORMAT2W *to, const CHARFORMAT2W *from); +void ME_CopyCharFormat(CHARFORMAT2W *pDest, const CHARFORMAT2W *pSrc); /* only works with 2W structs */ +void ME_CharFormatFromLogFont(HDC hDC, const LOGFONTW *lf, CHARFORMAT2W *fmt); /* ditto */ /* list.c */ -void ME_InsertBefore(ME_DisplayItem *diWhere, ME_DisplayItem *diWhat) DECLSPEC_HIDDEN; -void ME_Remove(ME_DisplayItem *diWhere) DECLSPEC_HIDDEN; -ME_DisplayItem *ME_FindItemBack(ME_DisplayItem *di, ME_DIType nTypeOrClass) DECLSPEC_HIDDEN; -ME_DisplayItem *ME_FindItemFwd(ME_DisplayItem *di, ME_DIType nTypeOrClass) DECLSPEC_HIDDEN; -ME_DisplayItem *ME_FindItemBackOrHere(ME_DisplayItem *di, ME_DIType nTypeOrClass) DECLSPEC_HIDDEN; -ME_DisplayItem *ME_MakeDI(ME_DIType type) DECLSPEC_HIDDEN; -void ME_DestroyDisplayItem(ME_DisplayItem *item) DECLSPEC_HIDDEN; -void ME_DumpDocument(ME_TextBuffer *buffer) DECLSPEC_HIDDEN; +void ME_InsertBefore(ME_DisplayItem *diWhere, ME_DisplayItem *diWhat); +void ME_Remove(ME_DisplayItem *diWhere); +ME_DisplayItem *ME_FindItemBack(ME_DisplayItem *di, ME_DIType nTypeOrClass); +ME_DisplayItem *ME_FindItemFwd(ME_DisplayItem *di, ME_DIType nTypeOrClass); +ME_DisplayItem *ME_FindItemBackOrHere(ME_DisplayItem *di, ME_DIType nTypeOrClass); +ME_DisplayItem *ME_MakeDI(ME_DIType type); +void ME_DestroyDisplayItem(ME_DisplayItem *item); +void ME_DumpDocument(ME_TextBuffer *buffer); /* string.c */ -ME_String *ME_MakeStringN(LPCWSTR szText, int nMaxChars) DECLSPEC_HIDDEN; -ME_String *ME_MakeStringR(WCHAR cRepeat, int nMaxChars) DECLSPEC_HIDDEN; -ME_String *ME_MakeStringConst(const WCHAR *str, int len) DECLSPEC_HIDDEN; -ME_String *ME_MakeStringEmpty(int len) DECLSPEC_HIDDEN; -void ME_DestroyString(ME_String *s) DECLSPEC_HIDDEN; -BOOL ME_AppendString(ME_String *s, const WCHAR *append, int len) DECLSPEC_HIDDEN; -ME_String *ME_VSplitString(ME_String *orig, int nVPos) DECLSPEC_HIDDEN; -int ME_FindNonWhitespaceV(const ME_String *s, int nVChar) DECLSPEC_HIDDEN; -int ME_CallWordBreakProc(ME_TextEditor *editor, WCHAR *str, INT len, INT start, INT code) DECLSPEC_HIDDEN; -void ME_StrDeleteV(ME_String *s, int nVChar, int nChars) DECLSPEC_HIDDEN; -BOOL ME_InsertString(ME_String *s, int ofs, const WCHAR *insert, int len) DECLSPEC_HIDDEN; +ME_String *ME_MakeStringN(LPCWSTR szText, int nMaxChars); +ME_String *ME_MakeStringR(WCHAR cRepeat, int nMaxChars); +ME_String *ME_MakeStringConst(const WCHAR *str, int len); +ME_String *ME_MakeStringEmpty(int len); +void ME_DestroyString(ME_String *s); +BOOL ME_AppendString(ME_String *s, const WCHAR *append, int len); +ME_String *ME_VSplitString(ME_String *orig, int nVPos); +int ME_FindNonWhitespaceV(const ME_String *s, int nVChar); +int ME_CallWordBreakProc(ME_TextEditor *editor, WCHAR *str, INT len, INT start, INT code); +void ME_StrDeleteV(ME_String *s, int nVChar, int nChars); +BOOL ME_InsertString(ME_String *s, int ofs, const WCHAR *insert, int len); #define CP_UNICODE 1200 /* smart helpers for A<->W conversions, they reserve/free memory and call MultiByte<->WideChar functions */ -LPWSTR ME_ToUnicode(LONG codepage, LPVOID psz, INT *len) DECLSPEC_HIDDEN; -void ME_EndToUnicode(LONG codepage, LPVOID psz) DECLSPEC_HIDDEN; +LPWSTR ME_ToUnicode(LONG codepage, LPVOID psz, INT *len); +void ME_EndToUnicode(LONG codepage, LPVOID psz); static inline int ME_IsWSpace(WCHAR ch) { @@ -108,131 +107,131 @@ static inline int ME_CharCompare(WCHAR a, WCHAR b, int caseSensitive) /* note: those two really return the first matching offset (starting from EOS)+1 * in other words, an offset of the first trailing white/black */ -int ME_ReverseFindNonWhitespaceV(const ME_String *s, int nVChar) DECLSPEC_HIDDEN; -int ME_ReverseFindWhitespaceV(const ME_String *s, int nVChar) DECLSPEC_HIDDEN; +int ME_ReverseFindNonWhitespaceV(const ME_String *s, int nVChar); +int ME_ReverseFindWhitespaceV(const ME_String *s, int nVChar); /* row.c */ -void row_end_cursor( ME_Row *row, ME_Cursor *cursor, BOOL include_eop ) DECLSPEC_HIDDEN; -void row_first_cursor( ME_Row *row, ME_Cursor *cursor ) DECLSPEC_HIDDEN; -ME_Run *row_first_run( ME_Row *row ) DECLSPEC_HIDDEN; -ME_Row *row_from_cursor( ME_Cursor *cursor ) DECLSPEC_HIDDEN; -ME_Row *row_from_row_number( ME_TextEditor *editor, int row_num ) DECLSPEC_HIDDEN; -ME_Row *row_next( ME_Row *row ) DECLSPEC_HIDDEN; -ME_Row *row_next_all_paras( ME_Row *row ) DECLSPEC_HIDDEN; -ME_Run *row_next_run( ME_Row *row, ME_Run *run ) DECLSPEC_HIDDEN; -int row_number_from_char_ofs( ME_TextEditor *editor, int ofs ) DECLSPEC_HIDDEN; -ME_Paragraph *row_para( ME_Row *row ) DECLSPEC_HIDDEN; -ME_Row *row_prev_all_paras( ME_Row *row ) DECLSPEC_HIDDEN; +void row_end_cursor( ME_Row *row, ME_Cursor *cursor, BOOL include_eop ); +void row_first_cursor( ME_Row *row, ME_Cursor *cursor ); +ME_Run *row_first_run( ME_Row *row ); +ME_Row *row_from_cursor( ME_Cursor *cursor ); +ME_Row *row_from_row_number( ME_TextEditor *editor, int row_num ); +ME_Row *row_next( ME_Row *row ); +ME_Row *row_next_all_paras( ME_Row *row ); +ME_Run *row_next_run( ME_Row *row, ME_Run *run ); +int row_number_from_char_ofs( ME_TextEditor *editor, int ofs ); +ME_Paragraph *row_para( ME_Row *row ); +ME_Row *row_prev_all_paras( ME_Row *row ); static inline ME_DisplayItem *row_get_di( ME_Row *row ) { return (ME_DisplayItem *)((ptrdiff_t)row - offsetof(ME_DisplayItem, member)); } /* run.c */ -void cursor_from_char_ofs( ME_TextEditor *editor, int char_ofs, ME_Cursor *cursor ) DECLSPEC_HIDDEN; -BOOL cursor_next_run( ME_Cursor *cursor, BOOL all_para ) DECLSPEC_HIDDEN; -BOOL cursor_prev_run( ME_Cursor *cursor, BOOL all_para ) DECLSPEC_HIDDEN; -void editor_propagate_char_ofs( ME_Paragraph *para, ME_Run *run, int shift ) DECLSPEC_HIDDEN; -int run_char_ofs( ME_Run *run, int ofs ) DECLSPEC_HIDDEN; -ME_Run *run_create( ME_Style *s, int nFlags ) DECLSPEC_HIDDEN; +void cursor_from_char_ofs( ME_TextEditor *editor, int char_ofs, ME_Cursor *cursor ); +BOOL cursor_next_run( ME_Cursor *cursor, BOOL all_para ); +BOOL cursor_prev_run( ME_Cursor *cursor, BOOL all_para ); +void editor_propagate_char_ofs( ME_TextEditor *editor, ME_Paragraph *para, ME_Run *run, int shift ); +int run_char_ofs( ME_Run *run, int ofs ); +ME_Run *run_create( ME_Style *s, int nFlags ); ME_Run *run_insert( ME_TextEditor *editor, ME_Cursor *cursor, - ME_Style *style, const WCHAR *str, int len, int flags ) DECLSPEC_HIDDEN; -void ME_CheckCharOffsets(ME_TextEditor *editor) DECLSPEC_HIDDEN; + ME_Style *style, const WCHAR *str, int len, int flags ); +void ME_CheckCharOffsets(ME_TextEditor *editor); /* this one accounts for 1/2 char tolerance */ -int ME_CharFromPointContext(ME_Context *c, int cx, ME_Run *run, BOOL closest, BOOL visual_order) DECLSPEC_HIDDEN; -int ME_CharFromPoint(ME_TextEditor *editor, int cx, ME_Run *run, BOOL closest, BOOL visual_order) DECLSPEC_HIDDEN; -int ME_PointFromCharContext(ME_Context *c, ME_Run *pRun, int nOffset, BOOL visual_order) DECLSPEC_HIDDEN; -int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset, BOOL visual_order) DECLSPEC_HIDDEN; -BOOL ME_CanJoinRuns(const ME_Run *run1, const ME_Run *run2) DECLSPEC_HIDDEN; -void run_join( ME_TextEditor *editor, ME_Run *run ) DECLSPEC_HIDDEN; -ME_Run *run_next( ME_Run *run ) DECLSPEC_HIDDEN; -ME_Run *run_next_all_paras( ME_Run *run ) DECLSPEC_HIDDEN; -ME_Run *run_prev( ME_Run *run ) DECLSPEC_HIDDEN; -ME_Run *run_prev_all_paras( ME_Run *run ) DECLSPEC_HIDDEN; -ME_Run *run_split( ME_TextEditor *editor, ME_Cursor *cursor ) DECLSPEC_HIDDEN; -void ME_UpdateRunFlags(ME_TextEditor *editor, ME_Run *run) DECLSPEC_HIDDEN; +int ME_CharFromPointContext(ME_Context *c, int cx, ME_Run *run, BOOL closest, BOOL visual_order); +int ME_CharFromPoint(ME_TextEditor *editor, int cx, ME_Run *run, BOOL closest, BOOL visual_order); +int ME_PointFromCharContext(ME_Context *c, ME_Run *pRun, int nOffset, BOOL visual_order); +int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset, BOOL visual_order); +BOOL ME_CanJoinRuns(const ME_Run *run1, const ME_Run *run2); +void run_join( ME_TextEditor *editor, ME_Run *run ); +ME_Run *run_next( ME_Run *run ); +ME_Run *run_next_all_paras( ME_Run *run ); +ME_Run *run_prev( ME_Run *run ); +ME_Run *run_prev_all_paras( ME_Run *run ); +ME_Run *run_split( ME_TextEditor *editor, ME_Cursor *cursor ); +void ME_UpdateRunFlags(ME_TextEditor *editor, ME_Run *run); SIZE ME_GetRunSizeCommon(ME_Context *c, const ME_Paragraph *para, ME_Run *run, int nLen, - int startx, int *pAscent, int *pDescent) DECLSPEC_HIDDEN; -void ME_SetCharFormat(ME_TextEditor *editor, ME_Cursor *start, ME_Cursor *end, CHARFORMAT2W *pFmt) DECLSPEC_HIDDEN; -void ME_SetSelectionCharFormat(ME_TextEditor *editor, CHARFORMAT2W *pFmt) DECLSPEC_HIDDEN; + int startx, int *pAscent, int *pDescent); +void ME_SetCharFormat(ME_TextEditor *editor, ME_Cursor *start, ME_Cursor *end, CHARFORMAT2W *pFmt); +void ME_SetSelectionCharFormat(ME_TextEditor *editor, CHARFORMAT2W *pFmt); void ME_GetCharFormat(ME_TextEditor *editor, const ME_Cursor *from, - const ME_Cursor *to, CHARFORMAT2W *pFmt) DECLSPEC_HIDDEN; -void ME_GetSelectionCharFormat(ME_TextEditor *editor, CHARFORMAT2W *pFmt) DECLSPEC_HIDDEN; -void ME_GetDefaultCharFormat(ME_TextEditor *editor, CHARFORMAT2W *pFmt) DECLSPEC_HIDDEN; -void ME_SetDefaultCharFormat(ME_TextEditor *editor, CHARFORMAT2W *mod) DECLSPEC_HIDDEN; + const ME_Cursor *to, CHARFORMAT2W *pFmt); +void ME_GetSelectionCharFormat(ME_TextEditor *editor, CHARFORMAT2W *pFmt); +void ME_GetDefaultCharFormat(ME_TextEditor *editor, CHARFORMAT2W *pFmt); +void ME_SetDefaultCharFormat(ME_TextEditor *editor, CHARFORMAT2W *mod); static inline ME_DisplayItem *run_get_di( ME_Run *run ) { return (ME_DisplayItem *)((ptrdiff_t)run - offsetof(ME_DisplayItem, member)); } /* caret.c */ -void cursor_coords( ME_TextEditor *editor, ME_Cursor *cursor, int *x, int *y, int *height ) DECLSPEC_HIDDEN; -void ME_SetCursorToStart(ME_TextEditor *editor, ME_Cursor *cursor) DECLSPEC_HIDDEN; -int set_selection_cursors(ME_TextEditor *editor, int from, int to) DECLSPEC_HIDDEN; -BOOL ME_MoveCursorWords(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs) DECLSPEC_HIDDEN; -void hide_caret(ME_TextEditor *ed) DECLSPEC_HIDDEN; -void show_caret(ME_TextEditor *ed) DECLSPEC_HIDDEN; -void update_caret(ME_TextEditor *ed) DECLSPEC_HIDDEN; -void create_caret(ME_TextEditor *ed) DECLSPEC_HIDDEN; -BOOL ME_CharFromPos(ME_TextEditor *editor, int x, int y, ME_Cursor *cursor, BOOL *isExact) DECLSPEC_HIDDEN; -void ME_LButtonDown(ME_TextEditor *editor, int x, int y, int clickNum) DECLSPEC_HIDDEN; -void ME_MouseMove(ME_TextEditor *editor, int x, int y) DECLSPEC_HIDDEN; -BOOL ME_DeleteTextAtCursor(ME_TextEditor *editor, int nCursor, int nChars) DECLSPEC_HIDDEN; -void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor, - const WCHAR *str, int len, ME_Style *style) DECLSPEC_HIDDEN; -void ME_InsertEndRowFromCursor(ME_TextEditor *editor, int nCursor) DECLSPEC_HIDDEN; -int ME_MoveCursorChars(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs, BOOL final_eop) DECLSPEC_HIDDEN; -BOOL ME_ArrowKey(ME_TextEditor *ed, int nVKey, BOOL extend, BOOL ctrl) DECLSPEC_HIDDEN; +void cursor_coords( ME_TextEditor *editor, ME_Cursor *cursor, int *x, int *y, int *height ); +BOOL cursor_from_coords( ME_TextEditor *editor, int x, int y, ME_Cursor *cursor ); +void ME_SetCursorToStart(ME_TextEditor *editor, ME_Cursor *cursor); +int set_selection_cursors(ME_TextEditor *editor, int from, int to); +BOOL ME_MoveCursorWords(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs); +void hide_caret(ME_TextEditor *ed); +void show_caret(ME_TextEditor *ed); +void update_caret(ME_TextEditor *ed); +void create_caret(ME_TextEditor *ed); +void ME_LButtonDown(ME_TextEditor *editor, int x, int y, int clickNum); +void ME_MouseMove(ME_TextEditor *editor, int x, int y); +BOOL ME_DeleteTextAtCursor(ME_TextEditor *editor, int nCursor, int nChars); +void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor, + const WCHAR *str, int len, ME_Style *style); +void ME_InsertEndRowFromCursor(ME_TextEditor *editor, int nCursor); +int ME_MoveCursorChars(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs, BOOL final_eop); +BOOL ME_ArrowKey(ME_TextEditor *ed, int nVKey, BOOL extend, BOOL ctrl); -int ME_GetCursorOfs(const ME_Cursor *cursor) DECLSPEC_HIDDEN; -int ME_GetSelectionOfs(ME_TextEditor *editor, int *from, int *to) DECLSPEC_HIDDEN; -int ME_GetSelection(ME_TextEditor *editor, ME_Cursor **from, ME_Cursor **to) DECLSPEC_HIDDEN; -BOOL ME_IsSelection(ME_TextEditor *editor) DECLSPEC_HIDDEN; -void ME_DeleteSelection(ME_TextEditor *editor) DECLSPEC_HIDDEN; -void ME_SendSelChange(ME_TextEditor *editor) DECLSPEC_HIDDEN; -void ME_InsertOLEFromCursor(ME_TextEditor *editor, const REOBJECT* reo, int nCursor) DECLSPEC_HIDDEN; -BOOL ME_InternalDeleteText(ME_TextEditor *editor, ME_Cursor *start, int nChars, BOOL bForce) DECLSPEC_HIDDEN; -int ME_GetTextLength(ME_TextEditor *editor) DECLSPEC_HIDDEN; -int ME_GetTextLengthEx(ME_TextEditor *editor, const GETTEXTLENGTHEX *how) DECLSPEC_HIDDEN; -ME_Style *ME_GetSelectionInsertStyle(ME_TextEditor *editor) DECLSPEC_HIDDEN; +int ME_GetCursorOfs(const ME_Cursor *cursor); +int ME_GetSelectionOfs(ME_TextEditor *editor, LONG *from, LONG *to); +int ME_GetSelection(ME_TextEditor *editor, ME_Cursor **from, ME_Cursor **to); +BOOL ME_IsSelection(ME_TextEditor *editor); +void ME_DeleteSelection(ME_TextEditor *editor); +void ME_SendSelChange(ME_TextEditor *editor); +HRESULT editor_insert_oleobj( ME_TextEditor *editor, const REOBJECT *reo ); +BOOL ME_InternalDeleteText(ME_TextEditor *editor, ME_Cursor *start, int nChars, BOOL bForce); +int ME_GetTextLength(ME_TextEditor *editor); +int ME_GetTextLengthEx(ME_TextEditor *editor, const GETTEXTLENGTHEX *how); +ME_Style *ME_GetSelectionInsertStyle(ME_TextEditor *editor); /* context.c */ -void ME_InitContext(ME_Context *c, ME_TextEditor *editor, HDC hDC) DECLSPEC_HIDDEN; -void ME_DestroyContext(ME_Context *c) DECLSPEC_HIDDEN; +void ME_InitContext(ME_Context *c, ME_TextEditor *editor, HDC hDC); +void ME_DestroyContext(ME_Context *c); /* wrap.c */ -BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor) DECLSPEC_HIDDEN; -void para_range_invalidate( ME_TextEditor *editor, ME_Paragraph *start_para, ME_Paragraph *last_para ) DECLSPEC_HIDDEN; -void ME_SendRequestResize(ME_TextEditor *editor, BOOL force) DECLSPEC_HIDDEN; -BOOL wrap_marked_paras_dc( ME_TextEditor *editor, HDC hdc, BOOL invalidate ) DECLSPEC_HIDDEN; +BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor); +void para_range_invalidate( ME_TextEditor *editor, ME_Paragraph *start_para, ME_Paragraph *last_para ); +void ME_SendRequestResize(ME_TextEditor *editor, BOOL force); +BOOL wrap_marked_paras_dc( ME_TextEditor *editor, HDC hdc, BOOL invalidate ); /* para.c */ -void editor_get_selection_paras(ME_TextEditor *editor, ME_Paragraph **para, ME_Paragraph **para_end ) DECLSPEC_HIDDEN; -void editor_get_selection_para_fmt( ME_TextEditor *editor, PARAFORMAT2 *fmt ) DECLSPEC_HIDDEN; -void editor_mark_rewrap_all( ME_TextEditor *editor ) DECLSPEC_HIDDEN; -void editor_set_default_para_fmt(ME_TextEditor *editor, PARAFORMAT2 *pFmt) DECLSPEC_HIDDEN; -BOOL editor_set_selection_para_fmt( ME_TextEditor *editor, const PARAFORMAT2 *fmt ) DECLSPEC_HIDDEN; -void ME_MakeFirstParagraph(ME_TextEditor *editor) DECLSPEC_HIDDEN; -void ME_DumpParaStyle(ME_Paragraph *s) DECLSPEC_HIDDEN; -void ME_DumpParaStyleToBuf(const PARAFORMAT2 *pFmt, char buf[2048]) DECLSPEC_HIDDEN; -int get_total_width(ME_TextEditor *editor) DECLSPEC_HIDDEN; -ME_Cell *para_cell( ME_Paragraph *para ) DECLSPEC_HIDDEN; -void para_destroy( ME_TextEditor *editor, ME_Paragraph *item ) DECLSPEC_HIDDEN; -ME_Row *para_end_row( ME_Paragraph *para ) DECLSPEC_HIDDEN; -ME_Run *para_end_run( ME_Paragraph *para ) DECLSPEC_HIDDEN; -ME_Row *para_first_row( ME_Paragraph *para ) DECLSPEC_HIDDEN; -ME_Run *para_first_run( ME_Paragraph *para ) DECLSPEC_HIDDEN; -BOOL para_in_table( ME_Paragraph *para ) DECLSPEC_HIDDEN; -ME_Paragraph *para_join( ME_TextEditor *editor, ME_Paragraph *para, BOOL use_first_fmt ) DECLSPEC_HIDDEN; -void para_mark_add( ME_TextEditor *editor, ME_Paragraph *para ) DECLSPEC_HIDDEN; -void para_mark_remove( ME_TextEditor *editor, ME_Paragraph *para ) DECLSPEC_HIDDEN; -void para_mark_rewrap( ME_TextEditor *editor, ME_Paragraph *para ) DECLSPEC_HIDDEN; -ME_Paragraph *para_next( ME_Paragraph *para ) DECLSPEC_HIDDEN; -void para_num_clear( struct para_num *pn ) DECLSPEC_HIDDEN; -void para_num_init( ME_Context *c, ME_Paragraph *para ) DECLSPEC_HIDDEN; -ME_Paragraph *para_prev( ME_Paragraph *para ) DECLSPEC_HIDDEN; +void editor_get_selection_paras(ME_TextEditor *editor, ME_Paragraph **para, ME_Paragraph **para_end ); +void editor_get_selection_para_fmt( ME_TextEditor *editor, PARAFORMAT2 *fmt ); +void editor_mark_rewrap_all( ME_TextEditor *editor ); +void editor_set_default_para_fmt(ME_TextEditor *editor, PARAFORMAT2 *pFmt); +BOOL editor_set_selection_para_fmt( ME_TextEditor *editor, const PARAFORMAT2 *fmt ); +void ME_MakeFirstParagraph(ME_TextEditor *editor, HDC hdc); +void ME_DumpParaStyle(ME_Paragraph *s); +void ME_DumpParaStyleToBuf(const PARAFORMAT2 *pFmt, char buf[2048]); +int get_total_width(ME_TextEditor *editor); +ME_Cell *para_cell( ME_Paragraph *para ); +void para_destroy( ME_TextEditor *editor, ME_Paragraph *item ); +ME_Row *para_end_row( ME_Paragraph *para ); +ME_Run *para_end_run( ME_Paragraph *para ); +ME_Row *para_first_row( ME_Paragraph *para ); +ME_Run *para_first_run( ME_Paragraph *para ); +BOOL para_in_table( ME_Paragraph *para ); +ME_Paragraph *para_join( ME_TextEditor *editor, ME_Paragraph *para, BOOL use_first_fmt ); +void para_mark_add( ME_TextEditor *editor, ME_Paragraph *para ); +void para_mark_remove( ME_TextEditor *editor, ME_Paragraph *para ); +void para_mark_rewrap( ME_TextEditor *editor, ME_Paragraph *para ); +ME_Paragraph *para_next( ME_Paragraph *para ); +void para_num_clear( struct para_num *pn ); +void para_num_init( ME_Context *c, ME_Paragraph *para ); +ME_Paragraph *para_prev( ME_Paragraph *para ); ME_Paragraph *para_split( ME_TextEditor *editor, ME_Run *run, ME_Style *style, - const WCHAR *eol_str, int eol_len, int paraFlags ) DECLSPEC_HIDDEN; + const WCHAR *eol_str, int eol_len, int paraFlags ); static inline ME_DisplayItem *para_get_di(ME_Paragraph *para) { @@ -240,82 +239,82 @@ static inline ME_DisplayItem *para_get_di(ME_Paragraph *para) } /* paint.c */ -void editor_draw( ME_TextEditor *editor, HDC hDC, const RECT *update ) DECLSPEC_HIDDEN; -void ME_Repaint(ME_TextEditor *editor) DECLSPEC_HIDDEN; -void ME_RewrapRepaint(ME_TextEditor *editor) DECLSPEC_HIDDEN; -void ME_UpdateRepaint(ME_TextEditor *editor, BOOL update_now) DECLSPEC_HIDDEN; -void editor_ensure_visible( ME_TextEditor *editor, ME_Cursor *cursor ) DECLSPEC_HIDDEN; -void ME_InvalidateSelection(ME_TextEditor *editor) DECLSPEC_HIDDEN; -BOOL ME_SetZoom(ME_TextEditor *editor, int numerator, int denominator) DECLSPEC_HIDDEN; -int ME_twips2pointsX(const ME_Context *c, int x) DECLSPEC_HIDDEN; -int ME_twips2pointsY(const ME_Context *c, int y) DECLSPEC_HIDDEN; +void editor_draw( ME_TextEditor *editor, HDC hDC, const RECT *update ); +void ME_Repaint(ME_TextEditor *editor); +void ME_RewrapRepaint(ME_TextEditor *editor); +void ME_UpdateRepaint(ME_TextEditor *editor, BOOL update_now); +void editor_ensure_visible( ME_TextEditor *editor, ME_Cursor *cursor ); +void ME_InvalidateSelection(ME_TextEditor *editor); +BOOL ME_SetZoom(ME_TextEditor *editor, int numerator, int denominator); +int ME_twips2pointsX(const ME_Context *c, int x); +int ME_twips2pointsY(const ME_Context *c, int y); /* scroll functions in paint.c */ -void scroll_abs( ME_TextEditor *editor, int x, int y, BOOL notify ) DECLSPEC_HIDDEN; -void scroll_h_abs( ME_TextEditor *editor, int x, BOOL notify ) DECLSPEC_HIDDEN; -void scroll_v_abs( ME_TextEditor *editor, int y, BOOL notify ) DECLSPEC_HIDDEN; -void ME_ScrollUp(ME_TextEditor *editor, int cy) DECLSPEC_HIDDEN; -void ME_ScrollDown(ME_TextEditor *editor, int cy) DECLSPEC_HIDDEN; -void ME_ScrollLeft(ME_TextEditor *editor, int cx) DECLSPEC_HIDDEN; -void ME_ScrollRight(ME_TextEditor *editor, int cx) DECLSPEC_HIDDEN; -void ME_UpdateScrollBar(ME_TextEditor *editor) DECLSPEC_HIDDEN; +void scroll_abs( ME_TextEditor *editor, int x, int y, BOOL notify ); +void scroll_h_abs( ME_TextEditor *editor, int x, BOOL notify ); +void scroll_v_abs( ME_TextEditor *editor, int y, BOOL notify ); +void ME_ScrollUp(ME_TextEditor *editor, int cy); +void ME_ScrollDown(ME_TextEditor *editor, int cy); +void ME_ScrollLeft(ME_TextEditor *editor, int cx); +void ME_ScrollRight(ME_TextEditor *editor, int cx); +void ME_UpdateScrollBar(ME_TextEditor *editor); /* other functions in paint.c */ -int ME_GetParaBorderWidth(const ME_Context *c, int flags) DECLSPEC_HIDDEN; +int ME_GetParaBorderWidth(const ME_Context *c, int flags); /* richole.c */ -void draw_ole( ME_Context *c, int x, int y, ME_Run* run, BOOL selected ) DECLSPEC_HIDDEN; -void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize) DECLSPEC_HIDDEN; -void ME_CopyReObject(REOBJECT *dst, const REOBJECT *src, DWORD flags) DECLSPEC_HIDDEN; -void ME_DeleteReObject(struct re_object *re_object) DECLSPEC_HIDDEN; -void richole_release_children( struct text_services *services ) DECLSPEC_HIDDEN; -extern const IRichEditOleVtbl re_ole_vtbl DECLSPEC_HIDDEN; -extern const ITextDocument2OldVtbl text_doc2old_vtbl DECLSPEC_HIDDEN; +void draw_ole( ME_Context *c, int x, int y, ME_Run* run, BOOL selected ); +void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize); +void ME_CopyReObject(REOBJECT *dst, const REOBJECT *src, DWORD flags); +void ME_DeleteReObject(struct re_object *re_object); +void richole_release_children( struct text_services *services ); +extern const IRichEditOleVtbl re_ole_vtbl; +extern const ITextDocument2OldVtbl text_doc2old_vtbl; /* editor.c */ -ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10) DECLSPEC_HIDDEN; -void ME_DestroyEditor(ME_TextEditor *editor) DECLSPEC_HIDDEN; +ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10); +void ME_DestroyEditor(ME_TextEditor *editor); LRESULT editor_handle_message( ME_TextEditor *editor, UINT msg, WPARAM wParam, - LPARAM lParam, HRESULT* phresult ) DECLSPEC_HIDDEN; + LPARAM lParam, HRESULT* phresult ); int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int buflen, - const ME_Cursor *start, int srcChars, BOOL bCRLF, BOOL bEOP) DECLSPEC_HIDDEN; -void ME_RTFCharAttrHook(struct _RTF_Info *info) DECLSPEC_HIDDEN; -void ME_RTFParAttrHook(struct _RTF_Info *info) DECLSPEC_HIDDEN; -void ME_RTFTblAttrHook(struct _RTF_Info *info) DECLSPEC_HIDDEN; -void ME_RTFSpecialCharHook(struct _RTF_Info *info) DECLSPEC_HIDDEN; -void ME_StreamInFill(ME_InStream *stream) DECLSPEC_HIDDEN; -extern BOOL me_debug DECLSPEC_HIDDEN; -void ME_ReplaceSel(ME_TextEditor *editor, BOOL can_undo, const WCHAR *str, int len) DECLSPEC_HIDDEN; -int set_selection( ME_TextEditor *editor, int to, int from ) DECLSPEC_HIDDEN; + const ME_Cursor *start, int srcChars, BOOL bCRLF, BOOL bEOP); +void ME_RTFCharAttrHook(struct _RTF_Info *info); +void ME_RTFParAttrHook(struct _RTF_Info *info); +void ME_RTFTblAttrHook(struct _RTF_Info *info); +void ME_RTFSpecialCharHook(struct _RTF_Info *info); +void ME_StreamInFill(ME_InStream *stream); +extern BOOL me_debug; +void ME_ReplaceSel(ME_TextEditor *editor, BOOL can_undo, const WCHAR *str, int len); +int set_selection( ME_TextEditor *editor, int to, int from ); HRESULT editor_copy_or_cut( ME_TextEditor *editor, BOOL cut, ME_Cursor *start, int count, - IDataObject **data_out ) DECLSPEC_HIDDEN; -ME_Paragraph *editor_end_para( ME_TextEditor *editor ) DECLSPEC_HIDDEN; -ME_Paragraph *editor_first_para( ME_TextEditor *editor ) DECLSPEC_HIDDEN; -void editor_set_cursor( ME_TextEditor *editor, int x, int y ) DECLSPEC_HIDDEN; -void link_notify( ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN; + IDataObject **data_out ); +ME_Paragraph *editor_end_para( ME_TextEditor *editor ); +ME_Paragraph *editor_first_para( ME_TextEditor *editor ); +void editor_set_cursor( ME_TextEditor *editor, int x, int y ); +void link_notify( ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM lParam ); /* table.c */ -ME_Cell *cell_create( void ) DECLSPEC_HIDDEN; -ME_Paragraph *cell_end_para( ME_Cell *cell ) DECLSPEC_HIDDEN; -ME_Paragraph *cell_first_para( ME_Cell *cell ) DECLSPEC_HIDDEN; -ME_Cell *cell_next( ME_Cell *cell ) DECLSPEC_HIDDEN; -ME_Cell *cell_prev( ME_Cell *cell ) DECLSPEC_HIDDEN; -ME_Paragraph *table_append_row( ME_TextEditor *editor, ME_Paragraph *table_row ) DECLSPEC_HIDDEN; -void table_handle_tab( ME_TextEditor *editor, BOOL selected_row ) DECLSPEC_HIDDEN; -ME_Paragraph *table_insert_cell( ME_TextEditor *editor, ME_Cursor *cursor ) DECLSPEC_HIDDEN; -ME_Paragraph *table_insert_row_end( ME_TextEditor *editor, ME_Cursor *cursor ) DECLSPEC_HIDDEN; -ME_Paragraph *table_insert_row_start( ME_TextEditor *editor, ME_Cursor *cursor ) DECLSPEC_HIDDEN; -ME_Paragraph *table_insert_row_start_at_para( ME_TextEditor *editor, ME_Paragraph *para ) DECLSPEC_HIDDEN; -void table_move_from_row_start( ME_TextEditor *editor ) DECLSPEC_HIDDEN; -ME_Paragraph *table_outer_para( ME_Paragraph *para ) DECLSPEC_HIDDEN; -void table_protect_partial_deletion( ME_TextEditor *editor, ME_Cursor *c, int *num_chars ) DECLSPEC_HIDDEN; -ME_Paragraph *table_row_end( ME_Paragraph *para ) DECLSPEC_HIDDEN; -ME_Cell *table_row_end_cell( ME_Paragraph *para ) DECLSPEC_HIDDEN; -ME_Cell *table_row_first_cell( ME_Paragraph *para ) DECLSPEC_HIDDEN; -ME_Paragraph *table_row_start( ME_Paragraph *para ) DECLSPEC_HIDDEN; -struct RTFTable *ME_MakeTableDef(ME_TextEditor *editor) DECLSPEC_HIDDEN; -void ME_InitTableDef(ME_TextEditor *editor, struct RTFTable *tableDef) DECLSPEC_HIDDEN; +ME_Cell *cell_create( void ); +ME_Paragraph *cell_end_para( ME_Cell *cell ); +ME_Paragraph *cell_first_para( ME_Cell *cell ); +ME_Cell *cell_next( ME_Cell *cell ); +ME_Cell *cell_prev( ME_Cell *cell ); +ME_Paragraph *table_append_row( ME_TextEditor *editor, ME_Paragraph *table_row ); +void table_handle_tab( ME_TextEditor *editor, BOOL selected_row ); +ME_Paragraph *table_insert_cell( ME_TextEditor *editor, ME_Cursor *cursor ); +ME_Paragraph *table_insert_row_end( ME_TextEditor *editor, ME_Cursor *cursor ); +ME_Paragraph *table_insert_row_start( ME_TextEditor *editor, ME_Cursor *cursor ); +ME_Paragraph *table_insert_row_start_at_para( ME_TextEditor *editor, ME_Paragraph *para ); +void table_move_from_row_start( ME_TextEditor *editor ); +ME_Paragraph *table_outer_para( ME_Paragraph *para ); +void table_protect_partial_deletion( ME_TextEditor *editor, ME_Cursor *c, int *num_chars ); +ME_Paragraph *table_row_end( ME_Paragraph *para ); +ME_Cell *table_row_end_cell( ME_Paragraph *para ); +ME_Cell *table_row_first_cell( ME_Paragraph *para ); +ME_Paragraph *table_row_start( ME_Paragraph *para ); +struct RTFTable *ME_MakeTableDef(ME_TextEditor *editor); +void ME_InitTableDef(ME_TextEditor *editor, struct RTFTable *tableDef); static inline ME_DisplayItem *cell_get_di(ME_Cell *cell) { return (ME_DisplayItem *)((ptrdiff_t)cell - offsetof(ME_DisplayItem, member)); @@ -324,7 +323,7 @@ static inline ME_DisplayItem *cell_get_di(ME_Cell *cell) /* txthost.c */ #ifdef __ASM_USE_THISCALL_WRAPPER -extern const struct ITextHost2Vtbl text_host2_stdcall_vtbl DECLSPEC_HIDDEN; +extern const struct ITextHost2Vtbl text_host2_stdcall_vtbl; #define TXTHOST_VTABLE(This) (&text_host2_stdcall_vtbl) #else #define TXTHOST_VTABLE(This) (This)->lpVtbl @@ -384,23 +383,30 @@ extern const struct ITextHost2Vtbl text_host2_stdcall_vtbl DECLSPEC_HIDDEN; #define ITextHost2_TxGetHorzExtent(This,a) TXTHOST_VTABLE(This)->TxGetHorzExtent(This,a) /* undo.c */ -BOOL add_undo_insert_run( ME_TextEditor *, int pos, const WCHAR *str, int len, int flags, ME_Style *style ) DECLSPEC_HIDDEN; -BOOL add_undo_delete_run( ME_TextEditor *, int pos, int len ) DECLSPEC_HIDDEN; -BOOL add_undo_set_para_fmt( ME_TextEditor *, const ME_Paragraph *para ) DECLSPEC_HIDDEN; -BOOL add_undo_set_char_fmt( ME_TextEditor *, int pos, int len, const CHARFORMAT2W *fmt ) DECLSPEC_HIDDEN; -BOOL add_undo_join_paras( ME_TextEditor *, int pos ) DECLSPEC_HIDDEN; -BOOL add_undo_split_para( ME_TextEditor *, const ME_Paragraph *para, ME_String *eol_str, const ME_Cell *cell) DECLSPEC_HIDDEN; -void ME_CommitUndo(ME_TextEditor *editor) DECLSPEC_HIDDEN; -void ME_ContinueCoalescingTransaction(ME_TextEditor *editor) DECLSPEC_HIDDEN; -void ME_CommitCoalescingUndo(ME_TextEditor *editor) DECLSPEC_HIDDEN; -BOOL ME_Undo(ME_TextEditor *editor) DECLSPEC_HIDDEN; -BOOL ME_Redo(ME_TextEditor *editor) DECLSPEC_HIDDEN; -void ME_EmptyUndoStack(ME_TextEditor *editor) DECLSPEC_HIDDEN; +BOOL add_undo_insert_run( ME_TextEditor *, int pos, const WCHAR *str, int len, int flags, ME_Style *style ); +BOOL add_undo_delete_run( ME_TextEditor *, int pos, int len ); +BOOL add_undo_set_para_fmt( ME_TextEditor *, const ME_Paragraph *para ); +BOOL add_undo_set_char_fmt( ME_TextEditor *, int pos, int len, const CHARFORMAT2W *fmt ); +BOOL add_undo_join_paras( ME_TextEditor *, int pos ); +BOOL add_undo_split_para( ME_TextEditor *, const ME_Paragraph *para, ME_String *eol_str, const ME_Cell *cell); +void ME_CommitUndo(ME_TextEditor *editor); +void ME_ContinueCoalescingTransaction(ME_TextEditor *editor); +void ME_CommitCoalescingUndo(ME_TextEditor *editor); +BOOL ME_Undo(ME_TextEditor *editor); +BOOL ME_Redo(ME_TextEditor *editor); +void ME_EmptyUndoStack(ME_TextEditor *editor); +void editor_disable_undo(ME_TextEditor *editor); +void editor_enable_undo(ME_TextEditor *editor); + +static inline BOOL editor_undo_ignored(ME_TextEditor *editor) +{ + return editor->undo_ctl_state != undoActive || editor->nUndoMode == umIgnore; +} /* txtsrv.c */ -HRESULT create_text_services( IUnknown *outer, ITextHost *text_host, IUnknown **unk, BOOL emulate_10 ) DECLSPEC_HIDDEN; +HRESULT create_text_services( IUnknown *outer, ITextHost *text_host, IUnknown **unk, BOOL emulate_10 ); #ifdef __ASM_USE_THISCALL_WRAPPER -extern const struct ITextServicesVtbl text_services_stdcall_vtbl DECLSPEC_HIDDEN; +extern const struct ITextServicesVtbl text_services_stdcall_vtbl; #define TXTSERV_VTABLE(This) (&text_services_stdcall_vtbl) #else #define TXTSERV_VTABLE(This) (This)->lpVtbl @@ -425,11 +431,11 @@ extern const struct ITextServicesVtbl text_services_stdcall_vtbl DECLSPEC_HIDDEN #define ITextServices_TxGetCachedSize(This,a,b) TXTSERV_VTABLE(This)->TxGetCachedSize(This,a,b) /* writer.c */ -LRESULT ME_StreamOutRange(ME_TextEditor *editor, DWORD dwFormat, const ME_Cursor *start, int nChars, EDITSTREAM *stream) DECLSPEC_HIDDEN; -LRESULT ME_StreamOut(ME_TextEditor *editor, DWORD dwFormat, EDITSTREAM *stream) DECLSPEC_HIDDEN; +LRESULT ME_StreamOutRange(ME_TextEditor *editor, DWORD dwFormat, const ME_Cursor *start, int nChars, EDITSTREAM *stream); +LRESULT ME_StreamOut(ME_TextEditor *editor, DWORD dwFormat, EDITSTREAM *stream); /* clipboard.c */ -HRESULT ME_GetDataObject(ME_TextEditor *editor, const ME_Cursor *start, int nChars, LPDATAOBJECT *lplpdataobj) DECLSPEC_HIDDEN; +HRESULT ME_GetDataObject(ME_TextEditor *editor, const ME_Cursor *start, int nChars, LPDATAOBJECT *lplpdataobj); -void release_typelib(void) DECLSPEC_HIDDEN; +void release_typelib(void); diff --git a/dll/win32/riched20/editstr.h b/dll/win32/riched20/editstr.h index 115e550f5af..65806d47dee 100644 --- a/dll/win32/riched20/editstr.h +++ b/dll/win32/riched20/editstr.h @@ -46,7 +46,6 @@ #include "wine/asm.h" #include "wine/debug.h" -#include "wine/heap.h" #include "wine/list.h" #include "wine/rbtree.h" @@ -147,11 +146,13 @@ typedef enum { /******************************** structures *************************/ struct tagME_DisplayItem; +struct tagME_Run; struct re_object { struct list entry; REOBJECT obj; + struct tagME_Run *run; /* ptr to the reobj's run */ }; typedef struct tagME_Run @@ -283,6 +284,12 @@ typedef enum { umAddBackToUndo } ME_UndoMode; +typedef enum { + undoActive, + undoSuspended, + undoDisabled +} ME_UndoControlState; + enum undo_type { undo_insert_run, @@ -406,8 +413,9 @@ typedef struct tagME_TextEditor int nUndoStackSize; int nUndoLimit; ME_UndoMode nUndoMode; + ME_UndoControlState undo_ctl_state; int nParagraphs; - int nLastSelStart, nLastSelEnd; + LONG nLastSelStart, nLastSelEnd; ME_Paragraph *last_sel_start_para, *last_sel_end_para; ME_FontCacheItem pFontCache[HFONT_CACHE_SIZE]; int nZoomNumerator, nZoomDenominator; @@ -426,6 +434,7 @@ typedef struct tagME_TextEditor BOOL AutoURLDetect_bEnable; WCHAR password_char; BOOL bHaveFocus; + DWORD freeze_count; #ifndef __REACTOS__ /*for IME */ int imeStartIndex; diff --git a/dll/win32/riched20/list.c b/dll/win32/riched20/list.c index 891a52e605f..8348b245bc5 100644 --- a/dll/win32/riched20/list.c +++ b/dll/win32/riched20/list.c @@ -123,16 +123,16 @@ void ME_DestroyDisplayItem(ME_DisplayItem *item) list_remove(&item->member.run.reobj->entry); ME_DeleteReObject(item->member.run.reobj); } - heap_free( item->member.run.glyphs ); - heap_free( item->member.run.clusters ); + free(item->member.run.glyphs); + free(item->member.run.clusters); ME_ReleaseStyle(item->member.run.style); } - heap_free(item); + free(item); } ME_DisplayItem *ME_MakeDI(ME_DIType type) { - ME_DisplayItem *item = heap_alloc_zero(sizeof(*item)); + ME_DisplayItem *item = calloc(1, sizeof(*item)); item->type = type; item->prev = item->next = NULL; diff --git a/dll/win32/riched20/paint.c b/dll/win32/riched20/paint.c index 6ab7e4de76b..0182e54bfc6 100644 --- a/dll/win32/riched20/paint.c +++ b/dll/win32/riched20/paint.c @@ -110,10 +110,12 @@ void editor_draw( ME_TextEditor *editor, HDC hDC, const RECT *update ) if (oldRgn) DeleteObject( oldRgn ); ME_DestroyContext( &c ); - if (editor->nTotalLength != editor->nLastTotalLength || editor->nTotalWidth != editor->nLastTotalWidth) - ME_SendRequestResize(editor, FALSE); - editor->nLastTotalLength = editor->nTotalLength; - editor->nLastTotalWidth = editor->nTotalWidth; + if (editor->in_place_active) { + if (editor->nTotalLength != editor->nLastTotalLength || editor->nTotalWidth != editor->nLastTotalWidth) + ME_SendRequestResize(editor, FALSE); + editor->nLastTotalLength = editor->nTotalLength; + editor->nLastTotalWidth = editor->nTotalWidth; + } } void ME_Repaint(ME_TextEditor *editor) @@ -123,7 +125,8 @@ void ME_Repaint(ME_TextEditor *editor) ME_UpdateScrollBar(editor); FIXME("ME_Repaint had to call ME_WrapMarkedParagraphs\n"); } - ITextHost_TxViewChange(editor->texthost, TRUE); + if (!editor->freeze_count) + ITextHost_TxViewChange(editor->texthost, TRUE); } void ME_UpdateRepaint(ME_TextEditor *editor, BOOL update_now) @@ -140,7 +143,8 @@ void ME_UpdateRepaint(ME_TextEditor *editor, BOOL update_now) update_caret( editor ); - ITextHost_TxViewChange(editor->texthost, update_now); + if (!editor->freeze_count) + ITextHost_TxViewChange(editor->texthost, update_now); ME_SendSelChange(editor); @@ -459,7 +463,7 @@ static void draw_run( ME_Context *c, int x, int y, ME_Cursor *cursor ) ME_Row *row; ME_Run *run = cursor->run; int runofs = run_char_ofs( run, cursor->nOffset ); - int nSelFrom, nSelTo; + LONG nSelFrom, nSelTo; if (run->nFlags & MERF_HIDDEN) return; @@ -1210,6 +1214,8 @@ void editor_ensure_visible( ME_TextEditor *editor, ME_Cursor *cursor ) ME_Paragraph *para = cursor->para; int x, y, yheight; + if (!editor->in_place_active) + return; if (editor->scrollbars & ES_AUTOHSCROLL) { @@ -1248,7 +1254,7 @@ ME_InvalidateSelection(ME_TextEditor *editor) { ME_Paragraph *sel_start, *sel_end; ME_Paragraph *repaint_start = NULL, *repaint_end = NULL; - int nStart, nEnd; + LONG nStart, nEnd; int len = ME_GetTextLength(editor); ME_GetSelectionOfs(editor, &nStart, &nEnd); diff --git a/dll/win32/riched20/para.c b/dll/win32/riched20/para.c index 1ddfe73b59f..2c9e2892189 100644 --- a/dll/win32/riched20/para.c +++ b/dll/win32/riched20/para.c @@ -148,7 +148,7 @@ ME_Row *para_end_row( ME_Paragraph *para ) return &item->member.row; } -void ME_MakeFirstParagraph(ME_TextEditor *editor) +void ME_MakeFirstParagraph(ME_TextEditor *editor, HDC hdc) { ME_Context c; CHARFORMAT2W cf; @@ -160,7 +160,6 @@ void ME_MakeFirstParagraph(ME_TextEditor *editor) ME_Run *run; ME_Style *style; int eol_len; - HDC hdc = ITextHost_TxGetDC( editor->texthost ); ME_InitContext( &c, editor, hdc ); @@ -222,7 +221,6 @@ void ME_MakeFirstParagraph(ME_TextEditor *editor) wine_rb_init( &editor->marked_paras, para_mark_compare ); para_mark_add( editor, para ); ME_DestroyContext(&c); - ITextHost_TxReleaseDC( editor->texthost, hdc ); } static void para_mark_rewrap_paras( ME_TextEditor *editor, ME_Paragraph *first, const ME_Paragraph *end ) @@ -672,7 +670,7 @@ ME_Paragraph *para_split( ME_TextEditor *editor, ME_Run *run, ME_Style *style, para_mark_rewrap( editor, &new_para->prev_para->member.para ); /* we've added the end run, so we need to modify nCharOfs in the next paragraphs */ - editor_propagate_char_ofs( next_para, NULL, eol_len ); + editor_propagate_char_ofs( editor, next_para, NULL, eol_len ); editor->nParagraphs++; return new_para; @@ -775,7 +773,7 @@ ME_Paragraph *para_join( ME_TextEditor *editor, ME_Paragraph *para, BOOL use_fir ME_Remove( para_get_di(next) ); para_destroy( editor, next ); - editor_propagate_char_ofs( para_next( para ), NULL, -end_len ); + editor_propagate_char_ofs( editor, para_next( para ), NULL, -end_len ); ME_CheckCharOffsets(editor); @@ -807,10 +805,10 @@ void ME_DumpParaStyleToBuf(const PARAFORMAT2 *pFmt, char buf[2048]) DUMP_EFFECT(PFM_RTLPARA, "RTL para:"); DUMP_EFFECT(PFM_SIDEBYSIDE, "Side by side:"); DUMP_EFFECT(PFM_TABLE, "Table:"); - DUMP(PFM_OFFSETINDENT, "Offset indent:", "%d", dxStartIndent); - DUMP(PFM_STARTINDENT, "Start indent:", "%d", dxStartIndent); - DUMP(PFM_RIGHTINDENT, "Right indent:", "%d", dxRightIndent); - DUMP(PFM_OFFSET, "Offset:", "%d", dxOffset); + DUMP(PFM_OFFSETINDENT, "Offset indent:", "%ld", dxStartIndent); + DUMP(PFM_STARTINDENT, "Start indent:", "%ld", dxStartIndent); + DUMP(PFM_RIGHTINDENT, "Right indent:", "%ld", dxRightIndent); + DUMP(PFM_OFFSET, "Offset:", "%ld", dxOffset); if (pFmt->dwMask & PFM_ALIGNMENT) { switch (pFmt->wAlignment) { case PFA_LEFT : p += sprintf(p, "Alignment: left\n"); break; @@ -825,12 +823,12 @@ void ME_DumpParaStyleToBuf(const PARAFORMAT2 *pFmt, char buf[2048]) if (pFmt->dwMask & PFM_TABSTOPS) { int i; p += sprintf(p, "\t"); - for (i = 0; i < pFmt->cTabCount; i++) p += sprintf(p, "%x ", pFmt->rgxTabs[i]); + for (i = 0; i < pFmt->cTabCount; i++) p += sprintf(p, "%lx ", pFmt->rgxTabs[i]); p += sprintf(p, "\n"); } - DUMP(PFM_SPACEBEFORE, "Space Before:", "%d", dySpaceBefore); - DUMP(PFM_SPACEAFTER, "Space After:", "%d", dySpaceAfter); - DUMP(PFM_LINESPACING, "Line spacing:", "%d", dyLineSpacing); + DUMP(PFM_SPACEBEFORE, "Space Before:", "%ld", dySpaceBefore); + DUMP(PFM_SPACEAFTER, "Space After:", "%ld", dySpaceAfter); + DUMP(PFM_LINESPACING, "Line spacing:", "%ld", dyLineSpacing); DUMP(PFM_STYLE, "Text style:", "%d", sStyle); DUMP(PFM_LINESPACING, "Line spacing rule:", "%u", bLineSpacingRule); /* bOutlineLevel should be 0 */ diff --git a/dll/win32/riched20/precomp.h b/dll/win32/riched20/precomp.h index 1e8a99192f2..5826e0bcf3a 100644 --- a/dll/win32/riched20/precomp.h +++ b/dll/win32/riched20/precomp.h @@ -6,9 +6,6 @@ #define _INC_WINDOWS #define COM_NO_WINDOWS_H -#define NONAMELESSUNION -#define NONAMELESSSTRUCT - #include "editor.h" #include diff --git a/dll/win32/riched20/reader.c b/dll/win32/riched20/reader.c index e73b8b87e9d..95360d8b9d4 100644 --- a/dll/win32/riched20/reader.c +++ b/dll/win32/riched20/reader.c @@ -75,23 +75,6 @@ static void RTFPutCodePageChar(RTF_Info *info, int c); /* ---------------------------------------------------------------------- */ -/* - * Saves a string on the heap and returns a pointer to it. - */ -static inline char *RTFStrSave(const char *s) -{ - char *p; - - p = heap_alloc (lstrlenA(s) + 1); - if (p == NULL) - return NULL; - return lstrcpyA (p, s); -} - - -/* ---------------------------------------------------------------------- */ - - int _RTFGetChar(RTF_Info *info) { int ch; @@ -129,14 +112,14 @@ RTFDestroyAttrs(RTF_Info *info) while (info->fontList) { fp = info->fontList->rtfNextFont; - heap_free (info->fontList->rtfFName); - heap_free (info->fontList); + free (info->fontList->rtfFName); + free (info->fontList); info->fontList = fp; } while (info->colorList) { cp = info->colorList->rtfNextColor; - heap_free (info->colorList); + free (info->colorList); info->colorList = cp; } while (info->styleList) @@ -146,12 +129,12 @@ RTFDestroyAttrs(RTF_Info *info) while (eltList) { ep = eltList->rtfNextSE; - heap_free (eltList->rtfSEText); - heap_free (eltList); + free (eltList->rtfSEText); + free (eltList); eltList = ep; } - heap_free (info->styleList->rtfSName); - heap_free (info->styleList); + free (info->styleList->rtfSName); + free (info->styleList); info->styleList = sp; } } @@ -162,16 +145,16 @@ RTFDestroy(RTF_Info *info) { if (info->rtfTextBuf) { - heap_free(info->rtfTextBuf); - heap_free(info->pushedTextBuf); + free(info->rtfTextBuf); + free(info->pushedTextBuf); } RTFDestroyAttrs(info); - heap_free(info->cpOutputBuffer); + free(info->cpOutputBuffer); while (info->tableDef) { RTFTable *tableDef = info->tableDef; info->tableDef = tableDef->parent; - heap_free(tableDef); + free(tableDef); } } @@ -215,8 +198,8 @@ void RTFInit(RTF_Info *info) if (info->rtfTextBuf == NULL) /* initialize the text buffers */ { - info->rtfTextBuf = heap_alloc (rtfBufSiz); - info->pushedTextBuf = heap_alloc (rtfBufSiz); + info->rtfTextBuf = malloc (rtfBufSiz); + info->pushedTextBuf = malloc (rtfBufSiz); if (info->rtfTextBuf == NULL || info->pushedTextBuf == NULL) { ERR ("Cannot allocate text buffers.\n"); return; @@ -262,7 +245,7 @@ void RTFInit(RTF_Info *info) if (!info->cpOutputBuffer) { info->dwMaxCPOutputCount = 0x1000; - info->cpOutputBuffer = heap_alloc(info->dwMaxCPOutputCount); + info->cpOutputBuffer = malloc (info->dwMaxCPOutputCount); } info->tableDef = NULL; @@ -813,7 +796,7 @@ static void ReadFontTbl(RTF_Info *info) if (info->rtfClass == rtfEOF) break; } - fp = New (RTFFont); + fp = malloc (sizeof(*fp)); if (fp == NULL) { ERR ("cannot allocate font entry\n"); break; @@ -901,7 +884,7 @@ static void ReadFontTbl(RTF_Info *info) RTFUngetToken (info); } *bp = '\0'; - fp->rtfFName = RTFStrSave (buf); + fp->rtfFName = strdup (buf); if (fp->rtfFName == NULL) ERR ("cannot allocate font name\n"); /* already have next token; don't read one */ @@ -986,7 +969,7 @@ static void ReadColorTbl(RTF_Info *info) continue; } - cp = New (RTFColor); + cp = malloc (sizeof(*cp)); if (cp == NULL) { ERR ("cannot allocate color entry\n"); break; @@ -1036,7 +1019,7 @@ static void ReadStyleSheet(RTF_Info *info) break; if (RTFCheckCM (info, rtfGroup, rtfEndGroup)) break; - sp = New (RTFStyle); + sp = malloc (sizeof(*sp)); if (sp == NULL) { ERR ("cannot allocate stylesheet entry\n"); break; @@ -1104,7 +1087,7 @@ static void ReadStyleSheet(RTF_Info *info) sp->rtfSNextPar = info->rtfParam; continue; } - sep = New (RTFStyleElt); + sep = malloc (sizeof(*sep)); if (sep == NULL) { ERR ("cannot allocate style element\n"); @@ -1114,7 +1097,7 @@ static void ReadStyleSheet(RTF_Info *info) sep->rtfSEMajor = info->rtfMajor; sep->rtfSEMinor = info->rtfMinor; sep->rtfSEParam = info->rtfParam; - sep->rtfSEText = RTFStrSave (info->rtfTextBuf); + sep->rtfSEText = strdup (info->rtfTextBuf); if (sep->rtfSEText == NULL) ERR ("cannot allocate style element text\n"); if (sepLast == NULL) @@ -1149,7 +1132,7 @@ static void ReadStyleSheet(RTF_Info *info) RTFGetToken (info); } *bp = '\0'; - sp->rtfSName = RTFStrSave (buf); + sp->rtfSName = strdup (buf); if (sp->rtfSName == NULL) ERR ("cannot allocate style name\n"); } @@ -2199,10 +2182,7 @@ void LookupInit(void) rp->rtfKHash = Hash (rp->rtfKStr); index = rp->rtfKHash % (ARRAY_SIZE(rtfKey) * 2); - if (!rtfHashTable[index].count) - rtfHashTable[index].value = heap_alloc(sizeof(RTFKey *)); - else - rtfHashTable[index].value = heap_realloc(rtfHashTable[index].value, sizeof(RTFKey *) * (rtfHashTable[index].count + 1)); + rtfHashTable[index].value = realloc(rtfHashTable[index].value, sizeof(RTFKey *) * (rtfHashTable[index].count + 1)); rtfHashTable[index].value[rtfHashTable[index].count++] = rp; } } @@ -2213,7 +2193,7 @@ void LookupCleanup(void) for (i = 0; i < ARRAY_SIZE(rtfKey) * 2; i++) { - heap_free( rtfHashTable[i].value ); + free(rtfHashTable[i].value); rtfHashTable[i].value = NULL; rtfHashTable[i].count = 0; } @@ -2611,7 +2591,7 @@ static void RTFFlushCPOutputBuffer(RTF_Info *info) { int bufferMax = info->dwCPOutputCount * 2 * sizeof(WCHAR); - WCHAR *buffer = heap_alloc(bufferMax); + WCHAR *buffer = malloc(bufferMax); int length; length = MultiByteToWideChar(info->codePage, 0, info->cpOutputBuffer, @@ -2619,7 +2599,7 @@ RTFFlushCPOutputBuffer(RTF_Info *info) info->dwCPOutputCount = 0; RTFPutUnicodeString(info, buffer, length); - heap_free(buffer); + free(buffer); } void @@ -2648,7 +2628,7 @@ RTFPutCodePageChar(RTF_Info *info, int c) if (info->dwCPOutputCount >= info->dwMaxCPOutputCount) { info->dwMaxCPOutputCount *= 2; - info->cpOutputBuffer = heap_realloc(info->cpOutputBuffer, info->dwMaxCPOutputCount); + info->cpOutputBuffer = realloc(info->cpOutputBuffer, info->dwMaxCPOutputCount); } info->cpOutputBuffer[info->dwCPOutputCount++] = c; } diff --git a/dll/win32/riched20/richole.c b/dll/win32/riched20/richole.c index 72840a4cafa..51ae41d2fe7 100644 --- a/dll/win32/riched20/richole.c +++ b/dll/win32/riched20/richole.c @@ -21,7 +21,6 @@ #include -#define NONAMELESSUNION #define COBJMACROS #include "windef.h" @@ -82,7 +81,7 @@ static HRESULT load_typelib(void) hr = LoadRegTypeLib(&LIBID_tom, 1, 0, LOCALE_SYSTEM_DEFAULT, &tl); if (FAILED(hr)) { - ERR("LoadRegTypeLib failed: %08x\n", hr); + ERR("LoadRegTypeLib failed: %08lx\n", hr); return hr; } @@ -121,7 +120,7 @@ static HRESULT get_typeinfo(enum tid_t tid, ITypeInfo **typeinfo) hr = ITypeLib_GetTypeInfoOfGuid(typelib, tid_ids[tid], &ti); if (FAILED(hr)) { - ERR("GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(tid_ids[tid]), hr); + ERR("GetTypeInfoOfGuid(%s) failed: %08lx\n", debugstr_guid(tid_ids[tid]), hr); return hr; } @@ -647,6 +646,9 @@ static void textrange_set_font(ITextRange *range, ITextFont *font) cursor_from_char_ofs( services->editor, start, &from ); cursor_from_char_ofs( services->editor, end, &to ); ME_SetCharFormat( services->editor, &from, &to, &fmt ); + ME_CommitUndo( services->editor ); + ME_WrapMarkedParagraphs( services->editor ); + ME_UpdateScrollBar( services->editor ); } } @@ -805,6 +807,9 @@ static HRESULT set_textfont_prop(ITextFontImpl *font, enum textfont_prop_id prop cursor_from_char_ofs( services->editor, start, &from ); cursor_from_char_ofs( services->editor, end, &to ); ME_SetCharFormat( services->editor, &from, &to, &fmt ); + ME_CommitUndo( services->editor ); + ME_WrapMarkedParagraphs( services->editor ); + ME_UpdateScrollBar( services->editor ); return S_OK; } @@ -889,7 +894,7 @@ static HRESULT textrange_expand(ITextRange *range, LONG unit, LONG *delta) ITextRange_GetStoryLength(range, &expand_end); break; default: - FIXME("unit %d is not supported\n", unit); + FIXME("unit %ld is not supported\n", unit); return E_NOTIMPL; } @@ -984,7 +989,7 @@ static ULONG WINAPI IOleClientSite_fnAddRef(IOleClientSite *iface) { IOleClientSiteImpl *This = impl_from_IOleClientSite(iface); ULONG ref = InterlockedIncrement(&This->ref); - TRACE("(%p)->(%u)\n", This, ref); + TRACE("(%p)->(%lu)\n", This, ref); return ref; } @@ -993,14 +998,14 @@ static ULONG WINAPI IOleClientSite_fnRelease(IOleClientSite *iface) IOleClientSiteImpl *This = impl_from_IOleClientSite(iface); ULONG ref = InterlockedDecrement(&This->ref); - TRACE("(%p)->(%u)\n", This, ref); + TRACE("(%p)->(%lu)\n", This, ref); if (ref == 0) { if (This->child.reole) { list_remove(&This->child.entry); This->child.reole = NULL; } - heap_free(This); + free(This); } return ref; } @@ -1213,7 +1218,7 @@ static const IOleInPlaceSiteVtbl olestvt = static HRESULT CreateOleClientSite( struct text_services *services, IOleClientSite **ret ) { - IOleClientSiteImpl *clientSite = heap_alloc(sizeof *clientSite); + IOleClientSiteImpl *clientSite = malloc(sizeof *clientSite); if (!clientSite) return E_OUTOFMEMORY; @@ -1249,12 +1254,13 @@ IRichEditOle_fnGetClipboardData(IRichEditOle *iface, CHARRANGE *lpchrg, ME_Cursor start; int nChars; - TRACE("(%p,%p,%d)\n", services, lpchrg, reco); + TRACE("(%p,%p,%ld)\n", services, lpchrg, reco); if(!lplpdataobj) return E_INVALIDARG; if(!lpchrg) { - int nFrom, nTo, nStartCur = ME_GetSelectionOfs( services->editor, &nFrom, &nTo ); + LONG nFrom, nTo; + int nStartCur = ME_GetSelectionOfs( services->editor, &nFrom, &nTo ); start = services->editor->pCursors[nStartCur]; nChars = nTo - nFrom; } @@ -1281,7 +1287,7 @@ IRichEditOle_fnGetObject(IRichEditOle *iface, LONG iob, struct re_object *reobj = NULL; LONG count = 0; - TRACE("(%p)->(%x, %p, %x)\n", services, iob, lpreobject, dwFlags); + TRACE("(%p)->(%lx, %p, %lx)\n", services, iob, lpreobject, dwFlags); if (!lpreobject || !lpreobject->cbStruct) return E_INVALIDARG; @@ -1290,7 +1296,7 @@ IRichEditOle_fnGetObject(IRichEditOle *iface, LONG iob, { ME_Cursor cursor; - TRACE("character offset: %d\n", lpreobject->cp); + TRACE("character offset: %ld\n", lpreobject->cp); cursor_from_char_ofs( services->editor, lpreobject->cp, &cursor ); if (!cursor.run->reobj) return E_INVALIDARG; @@ -1319,6 +1325,7 @@ IRichEditOle_fnGetObject(IRichEditOle *iface, LONG iob, } } ME_CopyReObject(lpreobject, &reobj->obj, dwFlags); + lpreobject->cp = run_char_ofs( reobj->run, 0 ); return S_OK; } @@ -1359,6 +1366,7 @@ static HRESULT WINAPI IRichEditOle_fnInsertObject(IRichEditOle *iface, REOBJECT *reo) { struct text_services *services = impl_from_IRichEditOle( iface ); + HRESULT hr; TRACE("(%p,%p)\n", services, reo); @@ -1367,7 +1375,10 @@ IRichEditOle_fnInsertObject(IRichEditOle *iface, REOBJECT *reo) if (reo->cbStruct < sizeof(*reo)) return STG_E_INVALIDPARAMETER; - ME_InsertOLEFromCursor(services->editor, reo, 0); + hr = editor_insert_oleobj(services->editor, reo); + if (hr != S_OK) + return hr; + ME_CommitUndo(services->editor); ME_UpdateRepaint(services->editor, FALSE); return S_OK; @@ -1462,7 +1473,7 @@ static ULONG WINAPI ITextRange_fnRelease(ITextRange *me) ITextRangeImpl *This = impl_from_ITextRange(me); ULONG ref = InterlockedDecrement(&This->ref); - TRACE ("%p ref=%u\n", This, ref); + TRACE ("%p ref=%lu\n", This, ref); if (ref == 0) { if (This->child.reole) @@ -1470,7 +1481,7 @@ static ULONG WINAPI ITextRange_fnRelease(ITextRange *me) list_remove(&This->child.entry); This->child.reole = NULL; } - heap_free(This); + free(This); } return ref; } @@ -1489,7 +1500,7 @@ static HRESULT WINAPI ITextRange_fnGetTypeInfo(ITextRange *me, UINT iTInfo, LCID ITextRangeImpl *This = impl_from_ITextRange(me); HRESULT hr; - TRACE("(%p)->(%u,%d,%p)\n", This, iTInfo, lcid, ppTInfo); + TRACE("(%p)->(%u,%ld,%p)\n", This, iTInfo, lcid, ppTInfo); hr = get_typeinfo(ITextRange_tid, ppTInfo); if (SUCCEEDED(hr)) @@ -1504,7 +1515,7 @@ static HRESULT WINAPI ITextRange_fnGetIDsOfNames(ITextRange *me, REFIID riid, LP ITypeInfo *ti; HRESULT hr; - TRACE("(%p)->(%s, %p, %u, %d, %p)\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, + TRACE("(%p)->(%s, %p, %u, %ld, %p)\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId); hr = get_typeinfo(ITextRange_tid, &ti); @@ -1522,7 +1533,7 @@ static HRESULT WINAPI ITextRange_fnInvoke(ITextRange *me, DISPID dispIdMember, R ITypeInfo *ti; HRESULT hr; - TRACE("(%p)->(%d, %s, %d, %u, %p, %p, %p, %p)\n", This, dispIdMember, debugstr_guid(riid), + TRACE("(%p)->(%ld, %s, %ld, %u, %p, %p, %p, %p)\n", This, dispIdMember, debugstr_guid(riid), lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); hr = get_typeinfo(ITextRange_tid, &ti); @@ -1646,7 +1657,7 @@ static HRESULT WINAPI ITextRange_fnSetChar(ITextRange *me, LONG ch) { ITextRangeImpl *This = impl_from_ITextRange(me); - FIXME("(%p)->(%x): stub\n", This, ch); + FIXME("(%p)->(%lx): stub\n", This, ch); if (!This->child.reole) return CO_E_RELEASED; @@ -1735,7 +1746,7 @@ static HRESULT WINAPI ITextRange_fnSetStart(ITextRange *me, LONG value) { ITextRangeImpl *This = impl_from_ITextRange(me); - TRACE("(%p)->(%d)\n", This, value); + TRACE("(%p)->(%ld)\n", This, value); if (!This->child.reole) return CO_E_RELEASED; @@ -1780,7 +1791,7 @@ static HRESULT WINAPI ITextRange_fnSetEnd(ITextRange *me, LONG value) { ITextRangeImpl *This = impl_from_ITextRange(me); - TRACE("(%p)->(%d)\n", This, value); + TRACE("(%p)->(%ld)\n", This, value); if (!This->child.reole) return CO_E_RELEASED; @@ -1890,7 +1901,7 @@ static HRESULT WINAPI ITextRange_fnCollapse(ITextRange *me, LONG bStart) { ITextRangeImpl *This = impl_from_ITextRange(me); - TRACE("(%p)->(%d)\n", This, bStart); + TRACE("(%p)->(%ld)\n", This, bStart); if (!This->child.reole) return CO_E_RELEASED; @@ -1902,7 +1913,7 @@ static HRESULT WINAPI ITextRange_fnExpand(ITextRange *me, LONG unit, LONG *delta { ITextRangeImpl *This = impl_from_ITextRange(me); - TRACE("(%p)->(%d %p)\n", This, unit, delta); + TRACE("(%p)->(%ld %p)\n", This, unit, delta); if (!This->child.reole) return CO_E_RELEASED; @@ -1914,7 +1925,7 @@ static HRESULT WINAPI ITextRange_fnGetIndex(ITextRange *me, LONG unit, LONG *ind { ITextRangeImpl *This = impl_from_ITextRange(me); - FIXME("(%p)->(%d %p): stub\n", This, unit, index); + FIXME("(%p)->(%ld %p): stub\n", This, unit, index); if (!This->child.reole) return CO_E_RELEASED; @@ -1927,7 +1938,7 @@ static HRESULT WINAPI ITextRange_fnSetIndex(ITextRange *me, LONG unit, LONG inde { ITextRangeImpl *This = impl_from_ITextRange(me); - FIXME("(%p)->(%d %d %d): stub\n", This, unit, index, extend); + FIXME("(%p)->(%ld %ld %ld): stub\n", This, unit, index, extend); if (!This->child.reole) return CO_E_RELEASED; @@ -1957,7 +1968,7 @@ static HRESULT WINAPI ITextRange_fnSetRange(ITextRange *me, LONG anchor, LONG ac { ITextRangeImpl *This = impl_from_ITextRange(me); - TRACE("(%p)->(%d %d)\n", This, anchor, active); + TRACE("(%p)->(%ld %ld)\n", This, anchor, active); if (!This->child.reole) return CO_E_RELEASED; @@ -2088,7 +2099,7 @@ static HRESULT textrange_startof(ITextRange *range, LONG unit, LONG extend, LONG break; } default: - FIXME("unit %d is not supported\n", unit); + FIXME("unit %ld is not supported\n", unit); return E_NOTIMPL; } return hr; @@ -2099,7 +2110,7 @@ static HRESULT WINAPI ITextRange_fnStartOf(ITextRange *me, LONG unit, LONG exten { ITextRangeImpl *This = impl_from_ITextRange(me); - TRACE("(%p)->(%d %d %p)\n", This, unit, extend, delta); + TRACE("(%p)->(%ld %ld %p)\n", This, unit, extend, delta); if (!This->child.reole) return CO_E_RELEASED; @@ -2141,7 +2152,7 @@ static HRESULT textrange_endof(ITextRange *range, ME_TextEditor *editor, LONG un break; } default: - FIXME("unit %d is not supported\n", unit); + FIXME("unit %ld is not supported\n", unit); return E_NOTIMPL; } return hr; @@ -2152,7 +2163,7 @@ static HRESULT WINAPI ITextRange_fnEndOf(ITextRange *me, LONG unit, LONG extend, { ITextRangeImpl *This = impl_from_ITextRange(me); - TRACE("(%p)->(%d %d %p)\n", This, unit, extend, delta); + TRACE("(%p)->(%ld %ld %p)\n", This, unit, extend, delta); if (!This->child.reole) return CO_E_RELEASED; @@ -2215,7 +2226,7 @@ static HRESULT textrange_move(ITextRange *range, ME_TextEditor *editor, LONG uni break; } default: - FIXME("unit %d is not supported\n", unit); + FIXME("unit %ld is not supported\n", unit); return E_NOTIMPL; } if (moved == 0) @@ -2230,7 +2241,7 @@ static HRESULT WINAPI ITextRange_fnMove(ITextRange *me, LONG unit, LONG count, L { ITextRangeImpl *This = impl_from_ITextRange(me); - TRACE("(%p)->(%d %d %p)\n", This, unit, count, delta); + TRACE("(%p)->(%ld %ld %p)\n", This, unit, count, delta); if (!This->child.reole) return CO_E_RELEASED; @@ -2270,7 +2281,7 @@ static HRESULT textrange_movestart(ITextRange *range, ME_TextEditor *editor, LON break; } default: - FIXME("unit %d is not supported\n", unit); + FIXME("unit %ld is not supported\n", unit); return E_NOTIMPL; } if (new_start == old_start) @@ -2286,7 +2297,7 @@ static HRESULT WINAPI ITextRange_fnMoveStart(ITextRange *me, LONG unit, LONG cou { ITextRangeImpl *This = impl_from_ITextRange(me); - TRACE("(%p)->(%d %d %p)\n", This, unit, count, delta); + TRACE("(%p)->(%ld %ld %p)\n", This, unit, count, delta); if (!This->child.reole) return CO_E_RELEASED; @@ -2344,7 +2355,7 @@ static HRESULT textrange_moveend(ITextRange *range, ME_TextEditor *editor, LONG } break; default: - FIXME("unit %d is not supported\n", unit); + FIXME("unit %ld is not supported\n", unit); return E_NOTIMPL; } if (new_end == old_end) @@ -2360,7 +2371,7 @@ static HRESULT WINAPI ITextRange_fnMoveEnd(ITextRange *me, LONG unit, LONG count { ITextRangeImpl *This = impl_from_ITextRange(me); - TRACE("(%p)->(%d %d %p)\n", This, unit, count, delta); + TRACE("(%p)->(%ld %ld %p)\n", This, unit, count, delta); if (!This->child.reole) return CO_E_RELEASED; @@ -2373,7 +2384,7 @@ static HRESULT WINAPI ITextRange_fnMoveWhile(ITextRange *me, VARIANT *charset, L { ITextRangeImpl *This = impl_from_ITextRange(me); - FIXME("(%p)->(%s %d %p): stub\n", This, debugstr_variant(charset), count, delta); + FIXME("(%p)->(%s %ld %p): stub\n", This, debugstr_variant(charset), count, delta); if (!This->child.reole) return CO_E_RELEASED; @@ -2386,7 +2397,7 @@ static HRESULT WINAPI ITextRange_fnMoveStartWhile(ITextRange *me, VARIANT *chars { ITextRangeImpl *This = impl_from_ITextRange(me); - FIXME("(%p)->(%s %d %p): stub\n", This, debugstr_variant(charset), count, delta); + FIXME("(%p)->(%s %ld %p): stub\n", This, debugstr_variant(charset), count, delta); if (!This->child.reole) return CO_E_RELEASED; @@ -2399,7 +2410,7 @@ static HRESULT WINAPI ITextRange_fnMoveEndWhile(ITextRange *me, VARIANT *charset { ITextRangeImpl *This = impl_from_ITextRange(me); - FIXME("(%p)->(%s %d %p): stub\n", This, debugstr_variant(charset), count, delta); + FIXME("(%p)->(%s %ld %p): stub\n", This, debugstr_variant(charset), count, delta); if (!This->child.reole) return CO_E_RELEASED; @@ -2412,7 +2423,7 @@ static HRESULT WINAPI ITextRange_fnMoveUntil(ITextRange *me, VARIANT *charset, L { ITextRangeImpl *This = impl_from_ITextRange(me); - FIXME("(%p)->(%s %d %p): stub\n", This, debugstr_variant(charset), count, delta); + FIXME("(%p)->(%s %ld %p): stub\n", This, debugstr_variant(charset), count, delta); if (!This->child.reole) return CO_E_RELEASED; @@ -2425,7 +2436,7 @@ static HRESULT WINAPI ITextRange_fnMoveStartUntil(ITextRange *me, VARIANT *chars { ITextRangeImpl *This = impl_from_ITextRange(me); - FIXME("(%p)->(%s %d %p): stub\n", This, debugstr_variant(charset), count, delta); + FIXME("(%p)->(%s %ld %p): stub\n", This, debugstr_variant(charset), count, delta); if (!This->child.reole) return CO_E_RELEASED; @@ -2438,7 +2449,7 @@ static HRESULT WINAPI ITextRange_fnMoveEndUntil(ITextRange *me, VARIANT *charset { ITextRangeImpl *This = impl_from_ITextRange(me); - FIXME("(%p)->(%s %d %p): stub\n", This, debugstr_variant(charset), count, delta); + FIXME("(%p)->(%s %ld %p): stub\n", This, debugstr_variant(charset), count, delta); if (!This->child.reole) return CO_E_RELEASED; @@ -2451,7 +2462,7 @@ static HRESULT WINAPI ITextRange_fnFindText(ITextRange *me, BSTR text, LONG coun { ITextRangeImpl *This = impl_from_ITextRange(me); - FIXME("(%p)->(%s %d %x %p): stub\n", This, debugstr_w(text), count, flags, length); + FIXME("(%p)->(%s %ld %lx %p): stub\n", This, debugstr_w(text), count, flags, length); if (!This->child.reole) return CO_E_RELEASED; @@ -2464,7 +2475,7 @@ static HRESULT WINAPI ITextRange_fnFindTextStart(ITextRange *me, BSTR text, LONG { ITextRangeImpl *This = impl_from_ITextRange(me); - FIXME("(%p)->(%s %d %x %p): stub\n", This, debugstr_w(text), count, flags, length); + FIXME("(%p)->(%s %ld %lx %p): stub\n", This, debugstr_w(text), count, flags, length); if (!This->child.reole) return CO_E_RELEASED; @@ -2477,7 +2488,7 @@ static HRESULT WINAPI ITextRange_fnFindTextEnd(ITextRange *me, BSTR text, LONG c { ITextRangeImpl *This = impl_from_ITextRange(me); - FIXME("(%p)->(%s %d %x %p): stub\n", This, debugstr_w(text), count, flags, length); + FIXME("(%p)->(%s %ld %lx %p): stub\n", This, debugstr_w(text), count, flags, length); if (!This->child.reole) return CO_E_RELEASED; @@ -2489,7 +2500,7 @@ static HRESULT WINAPI ITextRange_fnDelete(ITextRange *me, LONG unit, LONG count, { ITextRangeImpl *This = impl_from_ITextRange(me); - FIXME("(%p)->(%d %d %p): stub\n", This, unit, count, delta); + FIXME("(%p)->(%ld %ld %p): stub\n", This, unit, count, delta); if (!This->child.reole) return CO_E_RELEASED; @@ -2550,7 +2561,7 @@ static HRESULT WINAPI ITextRange_fnPaste(ITextRange *me, VARIANT *v, LONG format { ITextRangeImpl *This = impl_from_ITextRange(me); - FIXME("(%p)->(%s %x): stub\n", This, debugstr_variant(v), format); + FIXME("(%p)->(%s %lx): stub\n", This, debugstr_variant(v), format); if (!This->child.reole) return CO_E_RELEASED; @@ -2562,7 +2573,7 @@ static HRESULT WINAPI ITextRange_fnCanPaste(ITextRange *me, VARIANT *v, LONG for { ITextRangeImpl *This = impl_from_ITextRange(me); - FIXME("(%p)->(%s %x %p): stub\n", This, debugstr_variant(v), format, ret); + FIXME("(%p)->(%s %lx %p): stub\n", This, debugstr_variant(v), format, ret); if (!This->child.reole) return CO_E_RELEASED; @@ -2586,7 +2597,7 @@ static HRESULT WINAPI ITextRange_fnChangeCase(ITextRange *me, LONG type) { ITextRangeImpl *This = impl_from_ITextRange(me); - FIXME("(%p)->(%d): stub\n", This, type); + FIXME("(%p)->(%ld): stub\n", This, type); if (!This->child.reole) return CO_E_RELEASED; @@ -2598,7 +2609,7 @@ static HRESULT WINAPI ITextRange_fnGetPoint(ITextRange *me, LONG type, LONG *cx, { ITextRangeImpl *This = impl_from_ITextRange(me); - FIXME("(%p)->(%d %p %p): stub\n", This, type, cx, cy); + FIXME("(%p)->(%ld %p %p): stub\n", This, type, cx, cy); if (!This->child.reole) return CO_E_RELEASED; @@ -2611,7 +2622,7 @@ static HRESULT WINAPI ITextRange_fnSetPoint(ITextRange *me, LONG x, LONG y, LONG { ITextRangeImpl *This = impl_from_ITextRange(me); - FIXME("(%p)->(%d %d %d %d): stub\n", This, x, y, type, extend); + FIXME("(%p)->(%ld %ld %ld %ld): stub\n", This, x, y, type, extend); if (!This->child.reole) return CO_E_RELEASED; @@ -2626,7 +2637,7 @@ static HRESULT WINAPI ITextRange_fnScrollIntoView(ITextRange *me, LONG value) ME_Cursor cursor; int x, y, height; - TRACE("(%p)->(%d)\n", This, value); + TRACE("(%p)->(%ld)\n", This, value); if (!This->child.reole) return CO_E_RELEASED; @@ -2644,7 +2655,7 @@ static HRESULT WINAPI ITextRange_fnScrollIntoView(ITextRange *me, LONG value) cursor_coords( editor, &cursor, &x, &y, &height ); break; default: - FIXME("bStart value %d not handled\n", value); + FIXME("bStart value %ld not handled\n", value); return E_NOTIMPL; } scroll_abs( editor, x, y, TRUE ); @@ -2748,7 +2759,7 @@ static ULONG WINAPI TextFont_AddRef(ITextFont *iface) { ITextFontImpl *This = impl_from_ITextFont(iface); ULONG ref = InterlockedIncrement(&This->ref); - TRACE("(%p)->(%u)\n", This, ref); + TRACE("(%p)->(%lu)\n", This, ref); return ref; } @@ -2757,14 +2768,14 @@ static ULONG WINAPI TextFont_Release(ITextFont *iface) ITextFontImpl *This = impl_from_ITextFont(iface); ULONG ref = InterlockedDecrement(&This->ref); - TRACE("(%p)->(%u)\n", This, ref); + TRACE("(%p)->(%lu)\n", This, ref); if (!ref) { if (This->range) ITextRange_Release(This->range); SysFreeString(This->props[FONT_NAME].str); - heap_free(This); + free(This); } return ref; @@ -2784,7 +2795,7 @@ static HRESULT WINAPI TextFont_GetTypeInfo(ITextFont *iface, UINT iTInfo, LCID l ITextFontImpl *This = impl_from_ITextFont(iface); HRESULT hr; - TRACE("(%p)->(%u,%d,%p)\n", This, iTInfo, lcid, ppTInfo); + TRACE("(%p)->(%u,%ld,%p)\n", This, iTInfo, lcid, ppTInfo); hr = get_typeinfo(ITextFont_tid, ppTInfo); if (SUCCEEDED(hr)) @@ -2799,7 +2810,7 @@ static HRESULT WINAPI TextFont_GetIDsOfNames(ITextFont *iface, REFIID riid, ITypeInfo *ti; HRESULT hr; - TRACE("(%p)->(%s, %p, %u, %d, %p)\n", This, debugstr_guid(riid), + TRACE("(%p)->(%s, %p, %u, %ld, %p)\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId); hr = get_typeinfo(ITextFont_tid, &ti); @@ -2823,7 +2834,7 @@ static HRESULT WINAPI TextFont_Invoke( ITypeInfo *ti; HRESULT hr; - TRACE("(%p)->(%d, %s, %d, %u, %p, %p, %p, %p)\n", This, dispIdMember, debugstr_guid(riid), + TRACE("(%p)->(%ld, %s, %ld, %u, %p, %p, %p, %p)\n", This, dispIdMember, debugstr_guid(riid), lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); hr = get_typeinfo(ITextFont_tid, &ti); @@ -2973,7 +2984,7 @@ static HRESULT WINAPI TextFont_Reset(ITextFont *iface, LONG value) { ITextFontImpl *This = impl_from_ITextFont(iface); - TRACE("(%p)->(%d)\n", This, value); + TRACE("(%p)->(%ld)\n", This, value); /* If font is attached to a range, released or not, we can't reset to undefined */ @@ -3003,7 +3014,7 @@ static HRESULT WINAPI TextFont_Reset(ITextFont *iface, LONG value) case tomUseTwips: return E_INVALIDARG; default: - FIXME("reset mode %d not supported\n", value); + FIXME("reset mode %ld not supported\n", value); } return S_OK; @@ -3030,7 +3041,7 @@ static HRESULT WINAPI TextFont_Reset(ITextFont *iface, LONG value) } } - FIXME("reset mode %d not supported\n", value); + FIXME("reset mode %ld not supported\n", value); return E_NOTIMPL; } @@ -3044,7 +3055,7 @@ static HRESULT WINAPI TextFont_GetStyle(ITextFont *iface, LONG *value) static HRESULT WINAPI TextFont_SetStyle(ITextFont *iface, LONG value) { ITextFontImpl *This = impl_from_ITextFont(iface); - FIXME("(%p)->(%d): stub\n", This, value); + FIXME("(%p)->(%ld): stub\n", This, value); return E_NOTIMPL; } @@ -3058,7 +3069,7 @@ static HRESULT WINAPI TextFont_GetAllCaps(ITextFont *iface, LONG *value) static HRESULT WINAPI TextFont_SetAllCaps(ITextFont *iface, LONG value) { ITextFontImpl *This = impl_from_ITextFont(iface); - TRACE("(%p)->(%d)\n", This, value); + TRACE("(%p)->(%ld)\n", This, value); return set_textfont_propd(This, FONT_ALLCAPS, value); } @@ -3073,7 +3084,7 @@ static HRESULT WINAPI TextFont_SetAnimation(ITextFont *iface, LONG value) { ITextFontImpl *This = impl_from_ITextFont(iface); - TRACE("(%p)->(%d)\n", This, value); + TRACE("(%p)->(%ld)\n", This, value); if (value < tomNoAnimation || value > tomAnimationMax) return E_INVALIDARG; @@ -3091,7 +3102,7 @@ static HRESULT WINAPI TextFont_GetBackColor(ITextFont *iface, LONG *value) static HRESULT WINAPI TextFont_SetBackColor(ITextFont *iface, LONG value) { ITextFontImpl *This = impl_from_ITextFont(iface); - TRACE("(%p)->(%d)\n", This, value); + TRACE("(%p)->(%ld)\n", This, value); return set_textfont_propl(This, FONT_BACKCOLOR, value); } @@ -3105,7 +3116,7 @@ static HRESULT WINAPI TextFont_GetBold(ITextFont *iface, LONG *value) static HRESULT WINAPI TextFont_SetBold(ITextFont *iface, LONG value) { ITextFontImpl *This = impl_from_ITextFont(iface); - TRACE("(%p)->(%d)\n", This, value); + TRACE("(%p)->(%ld)\n", This, value); return set_textfont_propd(This, FONT_BOLD, value); } @@ -3119,7 +3130,7 @@ static HRESULT WINAPI TextFont_GetEmboss(ITextFont *iface, LONG *value) static HRESULT WINAPI TextFont_SetEmboss(ITextFont *iface, LONG value) { ITextFontImpl *This = impl_from_ITextFont(iface); - TRACE("(%p)->(%d)\n", This, value); + TRACE("(%p)->(%ld)\n", This, value); return set_textfont_propd(This, FONT_EMBOSS, value); } @@ -3133,7 +3144,7 @@ static HRESULT WINAPI TextFont_GetForeColor(ITextFont *iface, LONG *value) static HRESULT WINAPI TextFont_SetForeColor(ITextFont *iface, LONG value) { ITextFontImpl *This = impl_from_ITextFont(iface); - TRACE("(%p)->(%d)\n", This, value); + TRACE("(%p)->(%ld)\n", This, value); return set_textfont_propl(This, FONT_FORECOLOR, value); } @@ -3147,7 +3158,7 @@ static HRESULT WINAPI TextFont_GetHidden(ITextFont *iface, LONG *value) static HRESULT WINAPI TextFont_SetHidden(ITextFont *iface, LONG value) { ITextFontImpl *This = impl_from_ITextFont(iface); - TRACE("(%p)->(%d)\n", This, value); + TRACE("(%p)->(%ld)\n", This, value); return set_textfont_propd(This, FONT_HIDDEN, value); } @@ -3161,7 +3172,7 @@ static HRESULT WINAPI TextFont_GetEngrave(ITextFont *iface, LONG *value) static HRESULT WINAPI TextFont_SetEngrave(ITextFont *iface, LONG value) { ITextFontImpl *This = impl_from_ITextFont(iface); - TRACE("(%p)->(%d)\n", This, value); + TRACE("(%p)->(%ld)\n", This, value); return set_textfont_propd(This, FONT_ENGRAVE, value); } @@ -3175,7 +3186,7 @@ static HRESULT WINAPI TextFont_GetItalic(ITextFont *iface, LONG *value) static HRESULT WINAPI TextFont_SetItalic(ITextFont *iface, LONG value) { ITextFontImpl *This = impl_from_ITextFont(iface); - TRACE("(%p)->(%d)\n", This, value); + TRACE("(%p)->(%ld)\n", This, value); return set_textfont_propd(This, FONT_ITALIC, value); } @@ -3203,7 +3214,7 @@ static HRESULT WINAPI TextFont_GetLanguageID(ITextFont *iface, LONG *value) static HRESULT WINAPI TextFont_SetLanguageID(ITextFont *iface, LONG value) { ITextFontImpl *This = impl_from_ITextFont(iface); - TRACE("(%p)->(%d)\n", This, value); + TRACE("(%p)->(%ld)\n", This, value); return set_textfont_propl(This, FONT_LANGID, value); } @@ -3250,7 +3261,7 @@ static HRESULT WINAPI TextFont_GetOutline(ITextFont *iface, LONG *value) static HRESULT WINAPI TextFont_SetOutline(ITextFont *iface, LONG value) { ITextFontImpl *This = impl_from_ITextFont(iface); - TRACE("(%p)->(%d)\n", This, value); + TRACE("(%p)->(%ld)\n", This, value); return set_textfont_propd(This, FONT_OUTLINE, value); } @@ -3278,7 +3289,7 @@ static HRESULT WINAPI TextFont_GetProtected(ITextFont *iface, LONG *value) static HRESULT WINAPI TextFont_SetProtected(ITextFont *iface, LONG value) { ITextFontImpl *This = impl_from_ITextFont(iface); - TRACE("(%p)->(%d)\n", This, value); + TRACE("(%p)->(%ld)\n", This, value); return set_textfont_propd(This, FONT_PROTECTED, value); } @@ -3292,7 +3303,7 @@ static HRESULT WINAPI TextFont_GetShadow(ITextFont *iface, LONG *value) static HRESULT WINAPI TextFont_SetShadow(ITextFont *iface, LONG value) { ITextFontImpl *This = impl_from_ITextFont(iface); - TRACE("(%p)->(%d)\n", This, value); + TRACE("(%p)->(%ld)\n", This, value); return set_textfont_propd(This, FONT_SHADOW, value); } @@ -3320,7 +3331,7 @@ static HRESULT WINAPI TextFont_GetSmallCaps(ITextFont *iface, LONG *value) static HRESULT WINAPI TextFont_SetSmallCaps(ITextFont *iface, LONG value) { ITextFontImpl *This = impl_from_ITextFont(iface); - TRACE("(%p)->(%d)\n", This, value); + TRACE("(%p)->(%ld)\n", This, value); return set_textfont_propd(This, FONT_SMALLCAPS, value); } @@ -3348,7 +3359,7 @@ static HRESULT WINAPI TextFont_GetStrikeThrough(ITextFont *iface, LONG *value) static HRESULT WINAPI TextFont_SetStrikeThrough(ITextFont *iface, LONG value) { ITextFontImpl *This = impl_from_ITextFont(iface); - TRACE("(%p)->(%d)\n", This, value); + TRACE("(%p)->(%ld)\n", This, value); return set_textfont_propd(This, FONT_STRIKETHROUGH, value); } @@ -3362,7 +3373,7 @@ static HRESULT WINAPI TextFont_GetSubscript(ITextFont *iface, LONG *value) static HRESULT WINAPI TextFont_SetSubscript(ITextFont *iface, LONG value) { ITextFontImpl *This = impl_from_ITextFont(iface); - TRACE("(%p)->(%d)\n", This, value); + TRACE("(%p)->(%ld)\n", This, value); return set_textfont_propd(This, FONT_SUBSCRIPT, value); } @@ -3376,7 +3387,7 @@ static HRESULT WINAPI TextFont_GetSuperscript(ITextFont *iface, LONG *value) static HRESULT WINAPI TextFont_SetSuperscript(ITextFont *iface, LONG value) { ITextFontImpl *This = impl_from_ITextFont(iface); - TRACE("(%p)->(%d)\n", This, value); + TRACE("(%p)->(%ld)\n", This, value); return set_textfont_propd(This, FONT_SUPERSCRIPT, value); } @@ -3390,7 +3401,7 @@ static HRESULT WINAPI TextFont_GetUnderline(ITextFont *iface, LONG *value) static HRESULT WINAPI TextFont_SetUnderline(ITextFont *iface, LONG value) { ITextFontImpl *This = impl_from_ITextFont(iface); - TRACE("(%p)->(%d)\n", This, value); + TRACE("(%p)->(%ld)\n", This, value); return set_textfont_propd(This, FONT_UNDERLINE, value); } @@ -3404,7 +3415,7 @@ static HRESULT WINAPI TextFont_GetWeight(ITextFont *iface, LONG *value) static HRESULT WINAPI TextFont_SetWeight(ITextFont *iface, LONG value) { ITextFontImpl *This = impl_from_ITextFont(iface); - TRACE("(%p)->(%d)\n", This, value); + TRACE("(%p)->(%ld)\n", This, value); return set_textfont_propl(This, FONT_WEIGHT, value); } @@ -3478,7 +3489,7 @@ static HRESULT create_textfont(ITextRange *range, const ITextFontImpl *src, ITex ITextFontImpl *font; *ret = NULL; - font = heap_alloc(sizeof(*font)); + font = malloc(sizeof(*font)); if (!font) return E_OUTOFMEMORY; @@ -3531,7 +3542,7 @@ static ULONG WINAPI TextPara_AddRef(ITextPara *iface) { ITextParaImpl *This = impl_from_ITextPara(iface); ULONG ref = InterlockedIncrement(&This->ref); - TRACE("(%p)->(%u)\n", This, ref); + TRACE("(%p)->(%lu)\n", This, ref); return ref; } @@ -3540,12 +3551,12 @@ static ULONG WINAPI TextPara_Release(ITextPara *iface) ITextParaImpl *This = impl_from_ITextPara(iface); ULONG ref = InterlockedDecrement(&This->ref); - TRACE("(%p)->(%u)\n", This, ref); + TRACE("(%p)->(%lu)\n", This, ref); if (!ref) { ITextRange_Release(This->range); - heap_free(This); + free(This); } return ref; @@ -3565,7 +3576,7 @@ static HRESULT WINAPI TextPara_GetTypeInfo(ITextPara *iface, UINT iTInfo, LCID l ITextParaImpl *This = impl_from_ITextPara(iface); HRESULT hr; - TRACE("(%p)->(%u,%d,%p)\n", This, iTInfo, lcid, ppTInfo); + TRACE("(%p)->(%u,%ld,%p)\n", This, iTInfo, lcid, ppTInfo); hr = get_typeinfo(ITextPara_tid, ppTInfo); if (SUCCEEDED(hr)) @@ -3580,7 +3591,7 @@ static HRESULT WINAPI TextPara_GetIDsOfNames(ITextPara *iface, REFIID riid, ITypeInfo *ti; HRESULT hr; - TRACE("(%p)->(%s, %p, %u, %d, %p)\n", This, debugstr_guid(riid), rgszNames, + TRACE("(%p)->(%s, %p, %u, %ld, %p)\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId); hr = get_typeinfo(ITextPara_tid, &ti); @@ -3604,7 +3615,7 @@ static HRESULT WINAPI TextPara_Invoke( ITypeInfo *ti; HRESULT hr; - TRACE("(%p)->(%d, %s, %d, %u, %p, %p, %p, %p)\n", This, dispIdMember, + TRACE("(%p)->(%ld, %s, %ld, %u, %p, %p, %p, %p)\n", This, dispIdMember, debugstr_guid(riid), lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); @@ -3645,7 +3656,7 @@ static HRESULT WINAPI TextPara_IsEqual(ITextPara *iface, ITextPara *para, LONG * static HRESULT WINAPI TextPara_Reset(ITextPara *iface, LONG value) { ITextParaImpl *This = impl_from_ITextPara(iface); - FIXME("(%p)->(%d)\n", This, value); + FIXME("(%p)->(%ld)\n", This, value); return E_NOTIMPL; } @@ -3659,7 +3670,7 @@ static HRESULT WINAPI TextPara_GetStyle(ITextPara *iface, LONG *value) static HRESULT WINAPI TextPara_SetStyle(ITextPara *iface, LONG value) { ITextParaImpl *This = impl_from_ITextPara(iface); - FIXME("(%p)->(%d)\n", This, value); + FIXME("(%p)->(%ld)\n", This, value); return E_NOTIMPL; } @@ -3673,7 +3684,7 @@ static HRESULT WINAPI TextPara_GetAlignment(ITextPara *iface, LONG *value) static HRESULT WINAPI TextPara_SetAlignment(ITextPara *iface, LONG value) { ITextParaImpl *This = impl_from_ITextPara(iface); - FIXME("(%p)->(%d)\n", This, value); + FIXME("(%p)->(%ld)\n", This, value); return E_NOTIMPL; } @@ -3687,7 +3698,7 @@ static HRESULT WINAPI TextPara_GetHyphenation(ITextPara *iface, LONG *value) static HRESULT WINAPI TextPara_SetHyphenation(ITextPara *iface, LONG value) { ITextParaImpl *This = impl_from_ITextPara(iface); - FIXME("(%p)->(%d)\n", This, value); + FIXME("(%p)->(%ld)\n", This, value); return E_NOTIMPL; } @@ -3708,7 +3719,7 @@ static HRESULT WINAPI TextPara_GetKeepTogether(ITextPara *iface, LONG *value) static HRESULT WINAPI TextPara_SetKeepTogether(ITextPara *iface, LONG value) { ITextParaImpl *This = impl_from_ITextPara(iface); - FIXME("(%p)->(%d)\n", This, value); + FIXME("(%p)->(%ld)\n", This, value); return E_NOTIMPL; } @@ -3722,7 +3733,7 @@ static HRESULT WINAPI TextPara_GetKeepWithNext(ITextPara *iface, LONG *value) static HRESULT WINAPI TextPara_SetKeepWithNext(ITextPara *iface, LONG value) { ITextParaImpl *This = impl_from_ITextPara(iface); - FIXME("(%p)->(%d)\n", This, value); + FIXME("(%p)->(%ld)\n", This, value); return E_NOTIMPL; } @@ -3757,7 +3768,7 @@ static HRESULT WINAPI TextPara_GetListAlignment(ITextPara *iface, LONG *value) static HRESULT WINAPI TextPara_SetListAlignment(ITextPara *iface, LONG value) { ITextParaImpl *This = impl_from_ITextPara(iface); - FIXME("(%p)->(%d)\n", This, value); + FIXME("(%p)->(%ld)\n", This, value); return E_NOTIMPL; } @@ -3771,7 +3782,7 @@ static HRESULT WINAPI TextPara_GetListLevelIndex(ITextPara *iface, LONG *value) static HRESULT WINAPI TextPara_SetListLevelIndex(ITextPara *iface, LONG value) { ITextParaImpl *This = impl_from_ITextPara(iface); - FIXME("(%p)->(%d)\n", This, value); + FIXME("(%p)->(%ld)\n", This, value); return E_NOTIMPL; } @@ -3785,7 +3796,7 @@ static HRESULT WINAPI TextPara_GetListStart(ITextPara *iface, LONG *value) static HRESULT WINAPI TextPara_SetListStart(ITextPara *iface, LONG value) { ITextParaImpl *This = impl_from_ITextPara(iface); - FIXME("(%p)->(%d)\n", This, value); + FIXME("(%p)->(%ld)\n", This, value); return E_NOTIMPL; } @@ -3813,7 +3824,7 @@ static HRESULT WINAPI TextPara_GetListType(ITextPara *iface, LONG *value) static HRESULT WINAPI TextPara_SetListType(ITextPara *iface, LONG value) { ITextParaImpl *This = impl_from_ITextPara(iface); - FIXME("(%p)->(%d)\n", This, value); + FIXME("(%p)->(%ld)\n", This, value); return E_NOTIMPL; } @@ -3827,7 +3838,7 @@ static HRESULT WINAPI TextPara_GetNoLineNumber(ITextPara *iface, LONG *value) static HRESULT WINAPI TextPara_SetNoLineNumber(ITextPara *iface, LONG value) { ITextParaImpl *This = impl_from_ITextPara(iface); - FIXME("(%p)->(%d)\n", This, value); + FIXME("(%p)->(%ld)\n", This, value); return E_NOTIMPL; } @@ -3841,7 +3852,7 @@ static HRESULT WINAPI TextPara_GetPageBreakBefore(ITextPara *iface, LONG *value) static HRESULT WINAPI TextPara_SetPageBreakBefore(ITextPara *iface, LONG value) { ITextParaImpl *This = impl_from_ITextPara(iface); - FIXME("(%p)->(%d)\n", This, value); + FIXME("(%p)->(%ld)\n", This, value); return E_NOTIMPL; } @@ -3869,7 +3880,7 @@ static HRESULT WINAPI TextPara_SetIndents(ITextPara *iface, FLOAT StartIndent, F static HRESULT WINAPI TextPara_SetLineSpacing(ITextPara *iface, LONG LineSpacingRule, FLOAT LineSpacing) { ITextParaImpl *This = impl_from_ITextPara(iface); - FIXME("(%p)->(%d %.2f)\n", This, LineSpacingRule, LineSpacing); + FIXME("(%p)->(%ld %.2f)\n", This, LineSpacingRule, LineSpacing); return E_NOTIMPL; } @@ -3911,7 +3922,7 @@ static HRESULT WINAPI TextPara_GetWidowControl(ITextPara *iface, LONG *value) static HRESULT WINAPI TextPara_SetWidowControl(ITextPara *iface, LONG value) { ITextParaImpl *This = impl_from_ITextPara(iface); - FIXME("(%p)->(%d)\n", This, value); + FIXME("(%p)->(%ld)\n", This, value); return E_NOTIMPL; } @@ -3925,7 +3936,7 @@ static HRESULT WINAPI TextPara_GetTabCount(ITextPara *iface, LONG *value) static HRESULT WINAPI TextPara_AddTab(ITextPara *iface, FLOAT tbPos, LONG tbAlign, LONG tbLeader) { ITextParaImpl *This = impl_from_ITextPara(iface); - FIXME("(%p)->(%.2f %d %d)\n", This, tbPos, tbAlign, tbLeader); + FIXME("(%p)->(%.2f %ld %ld)\n", This, tbPos, tbAlign, tbLeader); return E_NOTIMPL; } @@ -3946,7 +3957,7 @@ static HRESULT WINAPI TextPara_DeleteTab(ITextPara *iface, FLOAT pos) static HRESULT WINAPI TextPara_GetTab(ITextPara *iface, LONG iTab, FLOAT *ptbPos, LONG *ptbAlign, LONG *ptbLeader) { ITextParaImpl *This = impl_from_ITextPara(iface); - FIXME("(%p)->(%d %p %p %p)\n", This, iTab, ptbPos, ptbAlign, ptbLeader); + FIXME("(%p)->(%ld %p %p %p)\n", This, iTab, ptbPos, ptbAlign, ptbLeader); return E_NOTIMPL; } @@ -4013,7 +4024,7 @@ static HRESULT create_textpara(ITextRange *range, ITextPara **ret) ITextParaImpl *para; *ret = NULL; - para = heap_alloc(sizeof(*para)); + para = malloc(sizeof(*para)); if (!para) return E_OUTOFMEMORY; @@ -4061,7 +4072,7 @@ static HRESULT WINAPI ITextDocument2Old_fnGetTypeInfo(ITextDocument2Old *iface, struct text_services *services = impl_from_ITextDocument2Old(iface); HRESULT hr; - TRACE("(%p)->(%u,%d,%p)\n", services, iTInfo, lcid, ppTInfo); + TRACE("(%p)->(%u,%ld,%p)\n", services, iTInfo, lcid, ppTInfo); hr = get_typeinfo(ITextDocument_tid, ppTInfo); if (SUCCEEDED(hr)) @@ -4077,7 +4088,7 @@ static HRESULT WINAPI ITextDocument2Old_fnGetIDsOfNames(ITextDocument2Old *iface ITypeInfo *ti; HRESULT hr; - TRACE("(%p)->(%s, %p, %u, %d, %p)\n", services, debugstr_guid(riid), + TRACE("(%p)->(%s, %p, %u, %ld, %p)\n", services, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId); hr = get_typeinfo(ITextDocument_tid, &ti); @@ -4095,7 +4106,7 @@ static HRESULT WINAPI ITextDocument2Old_fnInvoke(ITextDocument2Old *iface, DISPI ITypeInfo *ti; HRESULT hr; - TRACE("(%p)->(%d, %s, %d, %u, %p, %p, %p, %p)\n", services, dispIdMember, + TRACE("(%p)->(%ld, %s, %ld, %u, %p, %p, %p, %p)\n", services, dispIdMember, debugstr_guid(riid), lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); @@ -4205,15 +4216,22 @@ static HRESULT WINAPI ITextDocument2Old_fnSave(ITextDocument2Old *iface, VARIANT static HRESULT WINAPI ITextDocument2Old_fnFreeze(ITextDocument2Old *iface, LONG *pCount) { struct text_services *services = impl_from_ITextDocument2Old(iface); - FIXME("stub %p\n", services); - return E_NOTIMPL; + + if (services->editor->freeze_count < LONG_MAX) services->editor->freeze_count++; + + if (pCount) *pCount = services->editor->freeze_count; + return services->editor->freeze_count != 0 ? S_OK : S_FALSE; } static HRESULT WINAPI ITextDocument2Old_fnUnfreeze(ITextDocument2Old *iface, LONG *pCount) { struct text_services *services = impl_from_ITextDocument2Old(iface); - FIXME("stub %p\n", services); - return E_NOTIMPL; + + if (services->editor->freeze_count && !--services->editor->freeze_count) + ME_RewrapRepaint(services->editor); + + if (pCount) *pCount = services->editor->freeze_count; + return services->editor->freeze_count == 0 ? S_OK : S_FALSE; } static HRESULT WINAPI ITextDocument2Old_fnBeginEditCollection(ITextDocument2Old *iface) @@ -4233,20 +4251,60 @@ static HRESULT WINAPI ITextDocument2Old_fnEndEditCollection(ITextDocument2Old *i static HRESULT WINAPI ITextDocument2Old_fnUndo(ITextDocument2Old *iface, LONG Count, LONG *prop) { struct text_services *services = impl_from_ITextDocument2Old(iface); - FIXME("stub %p\n", services); - return E_NOTIMPL; + LONG actual_undo_count; + + if (prop) *prop = 0; + + switch (Count) + { + case tomFalse: + editor_disable_undo(services->editor); + return S_OK; + default: + if (Count > 0) break; + /* fallthrough */ + case tomTrue: + editor_enable_undo(services->editor); + return S_FALSE; + case tomSuspend: + if (services->editor->undo_ctl_state == undoActive) + { + services->editor->undo_ctl_state = undoSuspended; + } + return S_FALSE; + case tomResume: + services->editor->undo_ctl_state = undoActive; + return S_FALSE; + } + + for (actual_undo_count = 0; actual_undo_count < Count; actual_undo_count++) + { + if (!ME_Undo(services->editor)) break; + } + + if (prop) *prop = actual_undo_count; + return actual_undo_count == Count ? S_OK : S_FALSE; } static HRESULT WINAPI ITextDocument2Old_fnRedo(ITextDocument2Old *iface, LONG Count, LONG *prop) { struct text_services *services = impl_from_ITextDocument2Old(iface); - FIXME("stub %p\n", services); - return E_NOTIMPL; + LONG actual_redo_count; + + if (prop) *prop = 0; + + for (actual_redo_count = 0; actual_redo_count < Count; actual_redo_count++) + { + if (!ME_Redo(services->editor)) break; + } + + if (prop) *prop = actual_redo_count; + return actual_redo_count == Count ? S_OK : S_FALSE; } static HRESULT CreateITextRange(struct text_services *services, LONG start, LONG end, ITextRange** ppRange) { - ITextRangeImpl *txtRge = heap_alloc(sizeof(ITextRangeImpl)); + ITextRangeImpl *txtRge = malloc(sizeof(ITextRangeImpl)); if (!txtRge) return E_OUTOFMEMORY; @@ -4265,7 +4323,7 @@ static HRESULT WINAPI ITextDocument2Old_fnRange(ITextDocument2Old *iface, LONG c { struct text_services *services = impl_from_ITextDocument2Old(iface); - TRACE("%p %p %d %d\n", services, ppRange, cp1, cp2); + TRACE("%p %p %ld %ld\n", services, ppRange, cp1, cp2); if (!ppRange) return E_INVALIDARG; @@ -4295,7 +4353,7 @@ static HRESULT WINAPI ITextDocument2Old_fnSetEffectColor(ITextDocument2Old *ifac { struct text_services *services = impl_from_ITextDocument2Old(iface); - FIXME("(%p)->(%d, 0x%x): stub\n", services, index, cr); + FIXME("(%p)->(%ld, 0x%lx): stub\n", services, index, cr); return E_NOTIMPL; } @@ -4304,7 +4362,7 @@ static HRESULT WINAPI ITextDocument2Old_fnGetEffectColor(ITextDocument2Old *ifac { struct text_services *services = impl_from_ITextDocument2Old(iface); - FIXME("(%p)->(%d, %p): stub\n", services, index, cr); + FIXME("(%p)->(%ld, %p): stub\n", services, index, cr); return E_NOTIMPL; } @@ -4322,7 +4380,7 @@ static HRESULT WINAPI ITextDocument2Old_fnSetCaretType(ITextDocument2Old *iface, { struct text_services *services = impl_from_ITextDocument2Old(iface); - FIXME("(%p)->(%d): stub\n", services, type); + FIXME("(%p)->(%ld): stub\n", services, type); return E_NOTIMPL; } @@ -4340,7 +4398,7 @@ static HRESULT WINAPI ITextDocument2Old_fnReleaseImmContext(ITextDocument2Old *i { struct text_services *services = impl_from_ITextDocument2Old(iface); - FIXME("(%p)->(%d): stub\n", services, context); + FIXME("(%p)->(%ld): stub\n", services, context); return E_NOTIMPL; } @@ -4351,7 +4409,7 @@ static HRESULT WINAPI ITextDocument2Old_fnGetPreferredFont(ITextDocument2Old *if { struct text_services *services = impl_from_ITextDocument2Old(iface); - FIXME("(%p)->(%d, %d, %d, %d, %d, %p, %p, %p): stub\n", services, cp, charrep, options, current_charrep, + FIXME("(%p)->(%ld, %ld, %ld, %ld, %ld, %p, %p, %p): stub\n", services, cp, charrep, options, current_charrep, current_fontsize, bstr, pitch_family, new_fontsize); return E_NOTIMPL; @@ -4370,7 +4428,7 @@ static HRESULT WINAPI ITextDocument2Old_fnSetNotificationMode(ITextDocument2Old { struct text_services *services = impl_from_ITextDocument2Old(iface); - FIXME("(%p)->(0x%x): stub\n", services, mode); + FIXME("(%p)->(0x%lx): stub\n", services, mode); return E_NOTIMPL; } @@ -4380,7 +4438,7 @@ static HRESULT WINAPI ITextDocument2Old_fnGetClientRect(ITextDocument2Old *iface { struct text_services *services = impl_from_ITextDocument2Old(iface); - FIXME("(%p)->(%d, %p, %p, %p, %p): stub\n", services, type, left, top, right, bottom); + FIXME("(%p)->(%ld, %p, %p, %p, %p): stub\n", services, type, left, top, right, bottom); return E_NOTIMPL; } @@ -4425,7 +4483,7 @@ static HRESULT WINAPI ITextDocument2Old_fnCheckTextLimit(ITextDocument2Old *ifac { struct text_services *services = impl_from_ITextDocument2Old(iface); - FIXME("(%p)->(%d, %p): stub\n", services, cch, exceed); + FIXME("(%p)->(%ld, %p): stub\n", services, cch, exceed); return E_NOTIMPL; } @@ -4434,7 +4492,7 @@ static HRESULT WINAPI ITextDocument2Old_fnIMEInProgress(ITextDocument2Old *iface { struct text_services *services = impl_from_ITextDocument2Old(iface); - FIXME("(%p)->(0x%x): stub\n", services, mode); + FIXME("(%p)->(0x%lx): stub\n", services, mode); return E_NOTIMPL; } @@ -4452,7 +4510,7 @@ static HRESULT WINAPI ITextDocument2Old_fnUpdate(ITextDocument2Old *iface, LONG { struct text_services *services = impl_from_ITextDocument2Old(iface); - FIXME("(%p)->(0x%x): stub\n", services, mode); + FIXME("(%p)->(0x%lx): stub\n", services, mode); return E_NOTIMPL; } @@ -4461,7 +4519,7 @@ static HRESULT WINAPI ITextDocument2Old_fnNotify(ITextDocument2Old *iface, LONG { struct text_services *services = impl_from_ITextDocument2Old(iface); - FIXME("(%p)->(%d): stub\n", services, notify); + FIXME("(%p)->(%ld): stub\n", services, notify); return E_NOTIMPL; } @@ -4555,7 +4613,7 @@ static ULONG WINAPI ITextSelection_fnRelease(ITextSelection *me) struct text_selection *This = impl_from_ITextSelection(me); ULONG ref = InterlockedDecrement(&This->ref); if (ref == 0) - heap_free(This); + free(This); return ref; } @@ -4573,7 +4631,7 @@ static HRESULT WINAPI ITextSelection_fnGetTypeInfo(ITextSelection *me, UINT iTIn struct text_selection *This = impl_from_ITextSelection(me); HRESULT hr; - TRACE("(%p)->(%u,%d,%p)\n", This, iTInfo, lcid, ppTInfo); + TRACE("(%p)->(%u,%ld,%p)\n", This, iTInfo, lcid, ppTInfo); hr = get_typeinfo(ITextSelection_tid, ppTInfo); if (SUCCEEDED(hr)) @@ -4588,7 +4646,7 @@ static HRESULT WINAPI ITextSelection_fnGetIDsOfNames(ITextSelection *me, REFIID ITypeInfo *ti; HRESULT hr; - TRACE("(%p)->(%s, %p, %u, %d, %p)\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, + TRACE("(%p)->(%s, %p, %u, %ld, %p)\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId); hr = get_typeinfo(ITextSelection_tid, &ti); @@ -4612,7 +4670,7 @@ static HRESULT WINAPI ITextSelection_fnInvoke( ITypeInfo *ti; HRESULT hr; - TRACE("(%p)->(%d, %s, %d, %u, %p, %p, %p, %p)\n", This, dispIdMember, debugstr_guid(riid), lcid, + TRACE("(%p)->(%ld, %s, %ld, %u, %p, %p, %p, %p)\n", This, dispIdMember, debugstr_guid(riid), lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); hr = get_typeinfo(ITextSelection_tid, &ti); @@ -4661,7 +4719,8 @@ static HRESULT WINAPI ITextSelection_fnSetText(ITextSelection *me, BSTR str) { struct text_selection *This = impl_from_ITextSelection(me); ME_TextEditor *editor; - int len, to, from; + int len; + LONG to, from; TRACE("(%p)->(%s)\n", This, debugstr_w(str)); @@ -4700,7 +4759,7 @@ static HRESULT WINAPI ITextSelection_fnSetChar(ITextSelection *me, LONG ch) { struct text_selection *This = impl_from_ITextSelection(me); - FIXME("(%p)->(%x): stub\n", This, ch); + FIXME("(%p)->(%lx): stub\n", This, ch); if (!This->services) return CO_E_RELEASED; @@ -4773,7 +4832,7 @@ static HRESULT WINAPI ITextSelection_fnSetStart(ITextSelection *me, LONG value) LONG start, end; HRESULT hr; - TRACE("(%p)->(%d)\n", This, value); + TRACE("(%p)->(%ld)\n", This, value); if (!This->services) return CO_E_RELEASED; @@ -4808,7 +4867,7 @@ static HRESULT WINAPI ITextSelection_fnSetEnd(ITextSelection *me, LONG value) LONG start, end; HRESULT hr; - TRACE("(%p)->(%d)\n", This, value); + TRACE("(%p)->(%ld)\n", This, value); if (!This->services) return CO_E_RELEASED; @@ -4927,7 +4986,7 @@ static HRESULT WINAPI ITextSelection_fnCollapse(ITextSelection *me, LONG bStart) LONG start, end; HRESULT hres; - TRACE("(%p)->(%d)\n", This, bStart); + TRACE("(%p)->(%ld)\n", This, bStart); if (!This->services) return CO_E_RELEASED; @@ -4945,7 +5004,7 @@ static HRESULT WINAPI ITextSelection_fnExpand(ITextSelection *me, LONG unit, LON ITextRange *range = NULL; HRESULT hr; - TRACE("(%p)->(%d %p)\n", This, unit, delta); + TRACE("(%p)->(%ld %p)\n", This, unit, delta); if (!This->services) return CO_E_RELEASED; @@ -4960,7 +5019,7 @@ static HRESULT WINAPI ITextSelection_fnGetIndex(ITextSelection *me, LONG unit, L { struct text_selection *This = impl_from_ITextSelection(me); - FIXME("(%p)->(%d %p): stub\n", This, unit, index); + FIXME("(%p)->(%ld %p): stub\n", This, unit, index); if (!This->services) return CO_E_RELEASED; @@ -4973,7 +5032,7 @@ static HRESULT WINAPI ITextSelection_fnSetIndex(ITextSelection *me, LONG unit, L { struct text_selection *This = impl_from_ITextSelection(me); - FIXME("(%p)->(%d %d %d): stub\n", This, unit, index, extend); + FIXME("(%p)->(%ld %ld %ld): stub\n", This, unit, index, extend); if (!This->services) return CO_E_RELEASED; @@ -4985,7 +5044,7 @@ static HRESULT WINAPI ITextSelection_fnSetRange(ITextSelection *me, LONG anchor, { struct text_selection *This = impl_from_ITextSelection(me); - FIXME("(%p)->(%d %d): stub\n", This, anchor, active); + FIXME("(%p)->(%ld %ld): stub\n", This, anchor, active); if (!This->services) return CO_E_RELEASED; @@ -5079,7 +5138,7 @@ static HRESULT WINAPI ITextSelection_fnStartOf(ITextSelection *me, LONG unit, LO ITextRange *range = NULL; HRESULT hr; - TRACE("(%p)->(%d %d %p)\n", This, unit, extend, delta); + TRACE("(%p)->(%ld %ld %p)\n", This, unit, extend, delta); if (!This->services) return CO_E_RELEASED; @@ -5097,7 +5156,7 @@ static HRESULT WINAPI ITextSelection_fnEndOf(ITextSelection *me, LONG unit, LONG ITextRange *range = NULL; HRESULT hr; - TRACE("(%p)->(%d %d %p)\n", This, unit, extend, delta); + TRACE("(%p)->(%ld %ld %p)\n", This, unit, extend, delta); if (!This->services) return CO_E_RELEASED; @@ -5114,7 +5173,7 @@ static HRESULT WINAPI ITextSelection_fnMove(ITextSelection *me, LONG unit, LONG ITextRange *range = NULL; HRESULT hr; - TRACE("(%p)->(%d %d %p)\n", This, unit, count, delta); + TRACE("(%p)->(%ld %ld %p)\n", This, unit, count, delta); if (!This->services) return CO_E_RELEASED; @@ -5132,7 +5191,7 @@ static HRESULT WINAPI ITextSelection_fnMoveStart(ITextSelection *me, LONG unit, ITextRange *range = NULL; HRESULT hr; - TRACE("(%p)->(%d %d %p)\n", This, unit, count, delta); + TRACE("(%p)->(%ld %ld %p)\n", This, unit, count, delta); if (!This->services) return CO_E_RELEASED; @@ -5150,7 +5209,7 @@ static HRESULT WINAPI ITextSelection_fnMoveEnd(ITextSelection *me, LONG unit, LO ITextRange *range = NULL; HRESULT hr; - TRACE("(%p)->(%d %d %p)\n", This, unit, count, delta); + TRACE("(%p)->(%ld %ld %p)\n", This, unit, count, delta); if (!This->services) return CO_E_RELEASED; @@ -5166,7 +5225,7 @@ static HRESULT WINAPI ITextSelection_fnMoveWhile(ITextSelection *me, VARIANT *ch { struct text_selection *This = impl_from_ITextSelection(me); - FIXME("(%p)->(%s %d %p): stub\n", This, debugstr_variant(charset), count, delta); + FIXME("(%p)->(%s %ld %p): stub\n", This, debugstr_variant(charset), count, delta); if (!This->services) return CO_E_RELEASED; @@ -5179,7 +5238,7 @@ static HRESULT WINAPI ITextSelection_fnMoveStartWhile(ITextSelection *me, VARIAN { struct text_selection *This = impl_from_ITextSelection(me); - FIXME("(%p)->(%s %d %p): stub\n", This, debugstr_variant(charset), count, delta); + FIXME("(%p)->(%s %ld %p): stub\n", This, debugstr_variant(charset), count, delta); if (!This->services) return CO_E_RELEASED; @@ -5192,7 +5251,7 @@ static HRESULT WINAPI ITextSelection_fnMoveEndWhile(ITextSelection *me, VARIANT { struct text_selection *This = impl_from_ITextSelection(me); - FIXME("(%p)->(%s %d %p): stub\n", This, debugstr_variant(charset), count, delta); + FIXME("(%p)->(%s %ld %p): stub\n", This, debugstr_variant(charset), count, delta); if (!This->services) return CO_E_RELEASED; @@ -5205,7 +5264,7 @@ static HRESULT WINAPI ITextSelection_fnMoveUntil(ITextSelection *me, VARIANT *ch { struct text_selection *This = impl_from_ITextSelection(me); - FIXME("(%p)->(%s %d %p): stub\n", This, debugstr_variant(charset), count, delta); + FIXME("(%p)->(%s %ld %p): stub\n", This, debugstr_variant(charset), count, delta); if (!This->services) return CO_E_RELEASED; @@ -5218,7 +5277,7 @@ static HRESULT WINAPI ITextSelection_fnMoveStartUntil(ITextSelection *me, VARIAN { struct text_selection *This = impl_from_ITextSelection(me); - FIXME("(%p)->(%s %d %p): stub\n", This, debugstr_variant(charset), count, delta); + FIXME("(%p)->(%s %ld %p): stub\n", This, debugstr_variant(charset), count, delta); if (!This->services) return CO_E_RELEASED; @@ -5231,7 +5290,7 @@ static HRESULT WINAPI ITextSelection_fnMoveEndUntil(ITextSelection *me, VARIANT { struct text_selection *This = impl_from_ITextSelection(me); - FIXME("(%p)->(%s %d %p): stub\n", This, debugstr_variant(charset), count, delta); + FIXME("(%p)->(%s %ld %p): stub\n", This, debugstr_variant(charset), count, delta); if (!This->services) return CO_E_RELEASED; @@ -5244,7 +5303,7 @@ static HRESULT WINAPI ITextSelection_fnFindText(ITextSelection *me, BSTR text, L { struct text_selection *This = impl_from_ITextSelection(me); - FIXME("(%p)->(%s %d %x %p): stub\n", This, debugstr_w(text), count, flags, length); + FIXME("(%p)->(%s %ld %lx %p): stub\n", This, debugstr_w(text), count, flags, length); if (!This->services) return CO_E_RELEASED; @@ -5258,7 +5317,7 @@ static HRESULT WINAPI ITextSelection_fnFindTextStart(ITextSelection *me, BSTR te { struct text_selection *This = impl_from_ITextSelection(me); - FIXME("(%p)->(%s %d %x %p): stub\n", This, debugstr_w(text), count, flags, length); + FIXME("(%p)->(%s %ld %lx %p): stub\n", This, debugstr_w(text), count, flags, length); if (!This->services) return CO_E_RELEASED; @@ -5271,7 +5330,7 @@ static HRESULT WINAPI ITextSelection_fnFindTextEnd(ITextSelection *me, BSTR text { struct text_selection *This = impl_from_ITextSelection(me); - FIXME("(%p)->(%s %d %x %p): stub\n", This, debugstr_w(text), count, flags, length); + FIXME("(%p)->(%s %ld %lx %p): stub\n", This, debugstr_w(text), count, flags, length); if (!This->services) return CO_E_RELEASED; @@ -5284,7 +5343,7 @@ static HRESULT WINAPI ITextSelection_fnDelete(ITextSelection *me, LONG unit, LON { struct text_selection *This = impl_from_ITextSelection(me); - FIXME("(%p)->(%d %d %p): stub\n", This, unit, count, delta); + FIXME("(%p)->(%ld %ld %p): stub\n", This, unit, count, delta); if (!This->services) return CO_E_RELEASED; @@ -5330,7 +5389,7 @@ static HRESULT WINAPI ITextSelection_fnPaste(ITextSelection *me, VARIANT *v, LON { struct text_selection *This = impl_from_ITextSelection(me); - FIXME("(%p)->(%s %x): stub\n", This, debugstr_variant(v), format); + FIXME("(%p)->(%s %lx): stub\n", This, debugstr_variant(v), format); if (!This->services) return CO_E_RELEASED; @@ -5343,7 +5402,7 @@ static HRESULT WINAPI ITextSelection_fnCanPaste(ITextSelection *me, VARIANT *v, { struct text_selection *This = impl_from_ITextSelection(me); - FIXME("(%p)->(%s %x %p): stub\n", This, debugstr_variant(v), format, ret); + FIXME("(%p)->(%s %lx %p): stub\n", This, debugstr_variant(v), format, ret); if (!This->services) return CO_E_RELEASED; @@ -5367,7 +5426,7 @@ static HRESULT WINAPI ITextSelection_fnChangeCase(ITextSelection *me, LONG type) { struct text_selection *This = impl_from_ITextSelection(me); - FIXME("(%p)->(%d): stub\n", This, type); + FIXME("(%p)->(%ld): stub\n", This, type); if (!This->services) return CO_E_RELEASED; @@ -5379,7 +5438,7 @@ static HRESULT WINAPI ITextSelection_fnGetPoint(ITextSelection *me, LONG type, L { struct text_selection *This = impl_from_ITextSelection(me); - FIXME("(%p)->(%d %p %p): stub\n", This, type, cx, cy); + FIXME("(%p)->(%ld %p %p): stub\n", This, type, cx, cy); if (!This->services) return CO_E_RELEASED; @@ -5392,7 +5451,7 @@ static HRESULT WINAPI ITextSelection_fnSetPoint(ITextSelection *me, LONG x, LONG { struct text_selection *This = impl_from_ITextSelection(me); - FIXME("(%p)->(%d %d %d %d): stub\n", This, x, y, type, extend); + FIXME("(%p)->(%ld %ld %ld %ld): stub\n", This, x, y, type, extend); if (!This->services) return CO_E_RELEASED; @@ -5404,7 +5463,7 @@ static HRESULT WINAPI ITextSelection_fnScrollIntoView(ITextSelection *me, LONG v { struct text_selection *This = impl_from_ITextSelection(me); - FIXME("(%p)->(%d): stub\n", This, value); + FIXME("(%p)->(%ld): stub\n", This, value); if (!This->services) return CO_E_RELEASED; @@ -5441,7 +5500,7 @@ static HRESULT WINAPI ITextSelection_fnSetFlags(ITextSelection *me, LONG flags) { struct text_selection *This = impl_from_ITextSelection(me); - FIXME("(%p)->(%x): stub\n", This, flags); + FIXME("(%p)->(%lx): stub\n", This, flags); if (!This->services) return CO_E_RELEASED; @@ -5466,7 +5525,7 @@ static HRESULT WINAPI ITextSelection_fnMoveLeft(ITextSelection *me, LONG unit, L { struct text_selection *This = impl_from_ITextSelection(me); - FIXME("(%p)->(%d %d %d %p): stub\n", This, unit, count, extend, delta); + FIXME("(%p)->(%ld %ld %ld %p): stub\n", This, unit, count, extend, delta); if (!This->services) return CO_E_RELEASED; @@ -5479,7 +5538,7 @@ static HRESULT WINAPI ITextSelection_fnMoveRight(ITextSelection *me, LONG unit, { struct text_selection *This = impl_from_ITextSelection(me); - FIXME("(%p)->(%d %d %d %p): stub\n", This, unit, count, extend, delta); + FIXME("(%p)->(%ld %ld %ld %p): stub\n", This, unit, count, extend, delta); if (!This->services) return CO_E_RELEASED; @@ -5492,7 +5551,7 @@ static HRESULT WINAPI ITextSelection_fnMoveUp(ITextSelection *me, LONG unit, LON { struct text_selection *This = impl_from_ITextSelection(me); - FIXME("(%p)->(%d %d %d %p): stub\n", This, unit, count, extend, delta); + FIXME("(%p)->(%ld %ld %ld %p): stub\n", This, unit, count, extend, delta); if (!This->services) return CO_E_RELEASED; @@ -5505,7 +5564,7 @@ static HRESULT WINAPI ITextSelection_fnMoveDown(ITextSelection *me, LONG unit, L { struct text_selection *This = impl_from_ITextSelection(me); - FIXME("(%p)->(%d %d %d %p): stub\n", This, unit, count, extend, delta); + FIXME("(%p)->(%ld %ld %ld %p): stub\n", This, unit, count, extend, delta); if (!This->services) return CO_E_RELEASED; @@ -5518,7 +5577,7 @@ static HRESULT WINAPI ITextSelection_fnHomeKey(ITextSelection *me, LONG unit, LO { struct text_selection *This = impl_from_ITextSelection(me); - FIXME("(%p)->(%d %d %p): stub\n", This, unit, extend, delta); + FIXME("(%p)->(%ld %ld %p): stub\n", This, unit, extend, delta); if (!This->services) return CO_E_RELEASED; @@ -5531,7 +5590,7 @@ static HRESULT WINAPI ITextSelection_fnEndKey(ITextSelection *me, LONG unit, LON { struct text_selection *This = impl_from_ITextSelection(me); - FIXME("(%p)->(%d %d %p): stub\n", This, unit, extend, delta); + FIXME("(%p)->(%ld %ld %p): stub\n", This, unit, extend, delta); if (!This->services) return CO_E_RELEASED; @@ -5624,7 +5683,7 @@ static const ITextSelectionVtbl tsvt = { static struct text_selection *text_selection_create(struct text_services *services) { - struct text_selection *txtSel = heap_alloc(sizeof *txtSel); + struct text_selection *txtSel = malloc(sizeof *txtSel); if (!txtSel) return NULL; @@ -5702,17 +5761,17 @@ void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize) switch (stgm.tymed) { case TYMED_GDI: - GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect); + GetObjectW(stgm.hBitmap, sizeof(dibsect), &dibsect); pSize->cx = dibsect.dsBm.bmWidth; pSize->cy = dibsect.dsBm.bmHeight; break; case TYMED_ENHMF: - GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh); + GetEnhMetaFileHeader(stgm.hEnhMetaFile, sizeof(emh), &emh); pSize->cx = emh.rclBounds.right - emh.rclBounds.left; pSize->cy = emh.rclBounds.bottom - emh.rclBounds.top; break; default: - FIXME("Unsupported tymed %d\n", stgm.tymed); + FIXME("Unsupported tymed %ld\n", stgm.tymed); break; } ReleaseStgMedium(&stgm); @@ -5726,6 +5785,7 @@ void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize) void draw_ole( ME_Context *c, int x, int y, ME_Run *run, BOOL selected ) { IDataObject* ido; + IViewObject* ivo; FORMATETC fmt; STGMEDIUM stgm; DIBSECTION dibsect; @@ -5738,6 +5798,36 @@ void draw_ole( ME_Context *c, int x, int y, ME_Run *run, BOOL selected ) assert(run->nFlags & MERF_GRAPHICS); assert(run->reobj); + + if (!run->reobj->obj.poleobj) return; + + if (SUCCEEDED(IOleObject_QueryInterface(run->reobj->obj.poleobj, &IID_IViewObject, (void**)&ivo))) + { + HRESULT hr; + RECTL bounds; + + convert_sizel(c, &run->reobj->obj.sizel, &sz); + if (c->editor->nZoomNumerator != 0) + { + sz.cx = MulDiv(sz.cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator); + sz.cy = MulDiv(sz.cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator); + } + + bounds.left = x; + bounds.top = y - sz.cy; + bounds.right = x + sz.cx; + bounds.bottom = y; + + hr = IViewObject_Draw(ivo, DVASPECT_CONTENT, -1, 0, 0, 0, c->hDC, &bounds, NULL, NULL, 0); + if (FAILED(hr)) + { + WARN("failed to draw object: %#08lx\n", hr); + } + + IViewObject_Release(ivo); + return; + } + if (IOleObject_QueryInterface(run->reobj->obj.poleobj, &IID_IDataObject, (void**)&ido) != S_OK) { FIXME("Couldn't get interface\n"); @@ -5765,9 +5855,9 @@ void draw_ole( ME_Context *c, int x, int y, ME_Run *run, BOOL selected ) switch (stgm.tymed) { case TYMED_GDI: - GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect); + GetObjectW(stgm.hBitmap, sizeof(dibsect), &dibsect); hMemDC = CreateCompatibleDC(c->hDC); - old_bm = SelectObject(hMemDC, stgm.u.hBitmap); + old_bm = SelectObject(hMemDC, stgm.hBitmap); if (has_size) { convert_sizel(c, &run->reobj->obj.sizel, &sz); @@ -5787,7 +5877,7 @@ void draw_ole( ME_Context *c, int x, int y, ME_Run *run, BOOL selected ) DeleteDC(hMemDC); break; case TYMED_ENHMF: - GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh); + GetEnhMetaFileHeader(stgm.hEnhMetaFile, sizeof(emh), &emh); if (has_size) { convert_sizel(c, &run->reobj->obj.sizel, &sz); @@ -5805,10 +5895,10 @@ void draw_ole( ME_Context *c, int x, int y, ME_Run *run, BOOL selected ) rc.top = y - sz.cy; rc.right = x + sz.cx; rc.bottom = y; - PlayEnhMetaFile(c->hDC, stgm.u.hEnhMetaFile, &rc); + PlayEnhMetaFile(c->hDC, stgm.hEnhMetaFile, &rc); break; default: - FIXME("Unsupported tymed %d\n", stgm.tymed); + FIXME("Unsupported tymed %ld\n", stgm.tymed); selected = FALSE; break; } @@ -5823,7 +5913,7 @@ void ME_DeleteReObject(struct re_object *reobj) if (reobj->obj.poleobj) IOleObject_Release(reobj->obj.poleobj); if (reobj->obj.pstg) IStorage_Release(reobj->obj.pstg); if (reobj->obj.polesite) IOleClientSite_Release(reobj->obj.polesite); - heap_free(reobj); + free(reobj); } void ME_CopyReObject(REOBJECT *dst, const REOBJECT *src, DWORD flags) diff --git a/dll/win32/riched20/rtf.h b/dll/win32/riched20/rtf.h index 35a0ee878e9..f2d446ac5d3 100644 --- a/dll/win32/riched20/rtf.h +++ b/dll/win32/riched20/rtf.h @@ -1078,13 +1078,6 @@ struct RTFTable # define RTFBorderCellBottom 0x32 # define RTFBorderCellRight 0x33 -/* - * Return pointer to new element of type t, or NULL - * if no memory available. - */ - -# define New(t) (heap_alloc (sizeof (t))) - /* Parser stack size */ # define maxStack 32 @@ -1189,31 +1182,31 @@ struct _RTF_Info { * Public RTF reader routines */ -void RTFInit (RTF_Info *) DECLSPEC_HIDDEN; -void RTFDestroy(RTF_Info *info) DECLSPEC_HIDDEN; -void RTFSetDestinationCallback (RTF_Info *, int, RTFFuncPtr) DECLSPEC_HIDDEN; -void RTFRead (RTF_Info *) DECLSPEC_HIDDEN; -int RTFGetToken (RTF_Info *) DECLSPEC_HIDDEN; /* writer should rarely need this */ -void RTFSetReadHook (RTF_Info *, RTFFuncPtr) DECLSPEC_HIDDEN; -void RTFRouteToken (RTF_Info *) DECLSPEC_HIDDEN; -void RTFSkipGroup (RTF_Info *) DECLSPEC_HIDDEN; -void RTFReadGroup (RTF_Info *) DECLSPEC_HIDDEN; -int RTFCheckCM (const RTF_Info *, int, int) DECLSPEC_HIDDEN; -int RTFCheckCMM (const RTF_Info *, int, int, int) DECLSPEC_HIDDEN; -int RTFCheckMM (const RTF_Info *, int, int) DECLSPEC_HIDDEN; -RTFFont *RTFGetFont (const RTF_Info *, int) DECLSPEC_HIDDEN; -RTFColor *RTFGetColor (const RTF_Info *, int) DECLSPEC_HIDDEN; -int RTFCharToHex ( char) DECLSPEC_HIDDEN; +void RTFInit (RTF_Info *); +void RTFDestroy(RTF_Info *info); +void RTFSetDestinationCallback (RTF_Info *, int, RTFFuncPtr); +void RTFRead (RTF_Info *); +int RTFGetToken (RTF_Info *); /* writer should rarely need this */ +void RTFSetReadHook (RTF_Info *, RTFFuncPtr); +void RTFRouteToken (RTF_Info *); +void RTFSkipGroup (RTF_Info *); +void RTFReadGroup (RTF_Info *); +int RTFCheckCM (const RTF_Info *, int, int); +int RTFCheckCMM (const RTF_Info *, int, int, int); +int RTFCheckMM (const RTF_Info *, int, int); +RTFFont *RTFGetFont (const RTF_Info *, int); +RTFColor *RTFGetColor (const RTF_Info *, int); +int RTFCharToHex ( char); -void RTFFlushOutputBuffer( RTF_Info *info ) DECLSPEC_HIDDEN; -void RTFSetEditStream(RTF_Info *info, ME_InStream *stream) DECLSPEC_HIDDEN; +void RTFFlushOutputBuffer( RTF_Info *info ); +void RTFSetEditStream(RTF_Info *info, ME_InStream *stream); -void WriterInit (RTF_Info *) DECLSPEC_HIDDEN; -int BeginFile (RTF_Info *) DECLSPEC_HIDDEN; +void WriterInit (RTF_Info *); +int BeginFile (RTF_Info *); -int RTFCharSetToCodePage(RTF_Info *info, int charset) DECLSPEC_HIDDEN; +int RTFCharSetToCodePage(RTF_Info *info, int charset); -void LookupInit (void) DECLSPEC_HIDDEN; -void LookupCleanup (void) DECLSPEC_HIDDEN; +void LookupInit (void); +void LookupCleanup (void); #endif diff --git a/dll/win32/riched20/run.c b/dll/win32/riched20/run.c index 51e768f8441..8de2ba345cf 100644 --- a/dll/win32/riched20/run.c +++ b/dll/win32/riched20/run.c @@ -144,7 +144,7 @@ BOOL ME_CanJoinRuns(const ME_Run *run1, const ME_Run *run2) * the document) of the part of the text starting from given place. * Call with only one of para or run non-NULL. */ -void editor_propagate_char_ofs( ME_Paragraph *para, ME_Run *run, int shift ) +void editor_propagate_char_ofs( ME_TextEditor *editor, ME_Paragraph *para, ME_Run *run, int shift ) { assert( !para ^ !run ); @@ -160,7 +160,12 @@ void editor_propagate_char_ofs( ME_Paragraph *para, ME_Run *run, int shift ) do { + /* update position in marked tree, if added */ + if (para->nFlags & MEPF_REWRAP) + para_mark_remove( editor, para ); para->nCharOfs += shift; + if (para->nFlags & MEPF_REWRAP) + para_mark_add( editor, para ); para = para_next( para ); } while (para); } @@ -199,7 +204,7 @@ void ME_CheckCharOffsets(ME_TextEditor *editor) ofs = 0; break; case diRun: - TRACE_(richedit_check)("run, real ofs = %d (+ofsp = %d), counted = %d, len = %d, txt = %s, flags=%08x, fx&mask = %08x\n", + TRACE_(richedit_check)("run, real ofs = %d (+ofsp = %d), counted = %d, len = %d, txt = %s, flags=%08x, fx&mask = %08lx\n", p->member.run.nCharOfs, p->member.run.nCharOfs+ofsp, ofsp+ofs, p->member.run.len, debugstr_run( &p->member.run ), p->member.run.nFlags, @@ -400,7 +405,7 @@ ME_Run *run_insert( ME_TextEditor *editor, ME_Cursor *cursor, ME_Style *style, ME_InsertString( run->para->text, run->nCharOfs, str, len ); ME_InsertBefore( run_get_di( insert_before ), run_get_di( run ) ); TRACE("Shift length:%d\n", len); - editor_propagate_char_ofs( NULL, insert_before, len ); + editor_propagate_char_ofs( editor, NULL, insert_before, len ); para_mark_rewrap( editor, insert_before->para ); /* Move any cursors that were at the end of the previous run to the end of the inserted run */ @@ -902,9 +907,8 @@ void ME_GetCharFormat( ME_TextEditor *editor, const ME_Cursor *from, run_copy_char_fmt( run, &tmp ); assert((tmp.dwMask & dwAttribs) == dwAttribs); - /* reset flags that differ */ - if (fmt->yHeight != tmp.yHeight) fmt->dwMask &= ~CFM_SIZE; + /* reset flags that differ */ if (fmt->dwMask & CFM_FACE) { if (!(tmp.dwMask & CFM_FACE)) diff --git a/dll/win32/riched20/string.c b/dll/win32/riched20/string.c index f89f602f593..5cc3e6b3acf 100644 --- a/dll/win32/riched20/string.c +++ b/dll/win32/riched20/string.c @@ -29,7 +29,7 @@ static int ME_GetOptimalBuffer(int nLen) static ME_String *make_string( void (*free)(ME_String *) ) { - ME_String *s = heap_alloc( sizeof(*s) ); + ME_String *s = malloc( sizeof(*s) ); if (s) s->free = free; return s; @@ -49,23 +49,23 @@ ME_String *ME_MakeStringConst(const WCHAR *str, int len) return s; } -static void heap_string_free(ME_String *s) +static void string_free(ME_String *s) { - heap_free( s->szData ); + free( s->szData ); } /* Create a buffer (uninitialized string) of size nMaxChars */ ME_String *ME_MakeStringEmpty(int nMaxChars) { - ME_String *s = make_string( heap_string_free ); + ME_String *s = make_string( string_free ); if (!s) return NULL; s->nLen = nMaxChars; s->nBuffer = ME_GetOptimalBuffer(s->nLen + 1); - s->szData = heap_alloc( s->nBuffer * sizeof(WCHAR) ); + s->szData = malloc( s->nBuffer * sizeof(WCHAR) ); if (!s->szData) { - heap_free( s ); + free( s ); return NULL; } s->szData[s->nLen] = 0; @@ -97,7 +97,7 @@ void ME_DestroyString(ME_String *s) { if (!s) return; if (s->free) s->free( s ); - heap_free( s ); + free( s ); } BOOL ME_InsertString(ME_String *s, int ofs, const WCHAR *insert, int len) @@ -111,7 +111,7 @@ BOOL ME_InsertString(ME_String *s, int ofs, const WCHAR *insert, int len) if( new_len > s->nBuffer ) { s->nBuffer = ME_GetOptimalBuffer( new_len ); - new = heap_realloc( s->szData, s->nBuffer * sizeof(WCHAR) ); + new = realloc( s->szData, s->nBuffer * sizeof(WCHAR) ); if (!new) return FALSE; s->szData = new; } @@ -213,12 +213,12 @@ ME_CallWordBreakProc(ME_TextEditor *editor, WCHAR *str, INT len, INT start, INT int result; int buffer_size = WideCharToMultiByte(CP_ACP, 0, str, len, NULL, 0, NULL, NULL); - char *buffer = heap_alloc(buffer_size); + char *buffer = malloc(buffer_size); if (!buffer) return 0; WideCharToMultiByte(CP_ACP, 0, str, len, buffer, buffer_size, NULL, NULL); result = editor->pfnWordBreak((WCHAR*)buffer, start, buffer_size, code); - heap_free(buffer); + free(buffer); return result; } } @@ -239,7 +239,7 @@ LPWSTR ME_ToUnicode(LONG codepage, LPVOID psz, INT *len) if(!nChars) return NULL; - if((tmp = heap_alloc( nChars * sizeof(WCHAR) )) != NULL) + if((tmp = malloc(nChars * sizeof(WCHAR))) != NULL) *len = MultiByteToWideChar(codepage, 0, psz, -1, tmp, nChars) - 1; return tmp; } @@ -248,5 +248,5 @@ LPWSTR ME_ToUnicode(LONG codepage, LPVOID psz, INT *len) void ME_EndToUnicode(LONG codepage, LPVOID psz) { if (codepage != CP_UNICODE) - heap_free( psz ); + free(psz); } diff --git a/dll/win32/riched20/style.c b/dll/win32/riched20/style.c index 917a5bd8100..8102ec6e448 100644 --- a/dll/win32/riched20/style.c +++ b/dll/win32/riched20/style.c @@ -120,7 +120,7 @@ BOOL cf2w_to_cfany(CHARFORMAT2W *to, const CHARFORMAT2W *from) ME_Style *ME_MakeStyle(CHARFORMAT2W *style) { - ME_Style *s = heap_alloc(sizeof(*s)); + ME_Style *s = malloc(sizeof(*s)); assert(style->cbSize == sizeof(CHARFORMAT2W)); s->fmt = *style; @@ -264,12 +264,12 @@ void ME_DumpStyleToBuf(CHARFORMAT2W *pFmt, char buf[2048]) p += sprintf(p, "N/A"); if (pFmt->dwMask & CFM_SIZE) - p += sprintf(p, "\nFont size: %d\n", pFmt->yHeight); + p += sprintf(p, "\nFont size: %ld\n", pFmt->yHeight); else p += sprintf(p, "\nFont size: N/A\n"); if (pFmt->dwMask & CFM_OFFSET) - p += sprintf(p, "Char offset: %d\n", pFmt->yOffset); + p += sprintf(p, "Char offset: %ld\n", pFmt->yOffset); else p += sprintf(p, "Char offset: N/A\n"); @@ -429,7 +429,7 @@ void select_style( ME_Context *c, ME_Style *s ) c->orig_font = NULL; } - if (c->current_style) + if (c->current_style && c->current_style->font_cache) { release_font_cache( c->current_style->font_cache ); c->current_style->font_cache = NULL; @@ -448,7 +448,7 @@ void ME_DestroyStyle(ME_Style *s) s->font_cache = NULL; } ScriptFreeCache( &s->script_cache ); - heap_free(s); + free(s); } void ME_AddRefStyle(ME_Style *s) diff --git a/dll/win32/riched20/table.c b/dll/win32/riched20/table.c index c3823e3b493..56614b53e64 100644 --- a/dll/win32/riched20/table.c +++ b/dll/win32/riched20/table.c @@ -546,7 +546,7 @@ void table_move_from_row_start( ME_TextEditor *editor ) struct RTFTable *ME_MakeTableDef(ME_TextEditor *editor) { - RTFTable *tableDef = heap_alloc_zero(sizeof(*tableDef)); + RTFTable *tableDef = calloc(1, sizeof(*tableDef)); if (!editor->bEmulateVersion10) /* v4.1 */ tableDef->gapH = 10; diff --git a/dll/win32/riched20/txthost.c b/dll/win32/riched20/txthost.c index f2560bccd3c..4b9dde834a3 100644 --- a/dll/win32/riched20/txthost.c +++ b/dll/win32/riched20/txthost.c @@ -97,7 +97,7 @@ struct host *host_create( HWND hwnd, CREATESTRUCTW *cs, BOOL emulate_10 ) { struct host *texthost; - texthost = CoTaskMemAlloc(sizeof(*texthost)); + texthost = malloc( sizeof(*texthost) ); if (!texthost) return NULL; texthost->ITextHost_iface.lpVtbl = &textHostVtbl; @@ -164,41 +164,41 @@ static ULONG WINAPI ITextHostImpl_Release( ITextHost2 *iface ) { SetWindowLongPtrW( host->window, 0, 0 ); ITextServices_Release( host->text_srv ); - CoTaskMemFree( host ); + free( host ); } return ref; } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetDC,4) -DECLSPEC_HIDDEN HDC __thiscall ITextHostImpl_TxGetDC( ITextHost2 *iface ) +HDC __thiscall ITextHostImpl_TxGetDC( ITextHost2 *iface ) { struct host *host = impl_from_ITextHost( iface ); return GetDC( host->window ); } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxReleaseDC,8) -DECLSPEC_HIDDEN INT __thiscall ITextHostImpl_TxReleaseDC( ITextHost2 *iface, HDC hdc ) +INT __thiscall ITextHostImpl_TxReleaseDC( ITextHost2 *iface, HDC hdc ) { struct host *host = impl_from_ITextHost( iface ); return ReleaseDC( host->window, hdc ); } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxShowScrollBar,12) -DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxShowScrollBar( ITextHost2 *iface, INT bar, BOOL show ) +BOOL __thiscall ITextHostImpl_TxShowScrollBar( ITextHost2 *iface, INT bar, BOOL show ) { struct host *host = impl_from_ITextHost( iface ); return ShowScrollBar( host->window, bar, show ); } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxEnableScrollBar,12) -DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxEnableScrollBar( ITextHost2 *iface, INT bar, INT arrows ) +BOOL __thiscall ITextHostImpl_TxEnableScrollBar( ITextHost2 *iface, INT bar, INT arrows ) { struct host *host = impl_from_ITextHost( iface ); return EnableScrollBar( host->window, bar, arrows ); } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetScrollRange,20) -DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxSetScrollRange( ITextHost2 *iface, INT bar, LONG min_pos, INT max_pos, BOOL redraw ) +BOOL __thiscall ITextHostImpl_TxSetScrollRange( ITextHost2 *iface, INT bar, LONG min_pos, INT max_pos, BOOL redraw ) { struct host *host = impl_from_ITextHost( iface ); SCROLLINFO info = { .cbSize = sizeof(info), .fMask = SIF_PAGE | SIF_RANGE }; @@ -223,7 +223,7 @@ DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxSetScrollRange( ITextHost2 *ifac } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetScrollPos,16) -DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxSetScrollPos( ITextHost2 *iface, INT bar, INT pos, BOOL redraw ) +BOOL __thiscall ITextHostImpl_TxSetScrollPos( ITextHost2 *iface, INT bar, INT pos, BOOL redraw ) { struct host *host = impl_from_ITextHost( iface ); DWORD style = GetWindowLongW( host->window, GWL_STYLE ); @@ -248,28 +248,28 @@ DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxSetScrollPos( ITextHost2 *iface, } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxInvalidateRect,12) -DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxInvalidateRect( ITextHost2 *iface, const RECT *rect, BOOL mode ) +void __thiscall ITextHostImpl_TxInvalidateRect( ITextHost2 *iface, const RECT *rect, BOOL mode ) { struct host *host = impl_from_ITextHost( iface ); InvalidateRect( host->window, rect, mode ); } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxViewChange,8) -DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxViewChange( ITextHost2 *iface, BOOL update ) +void __thiscall ITextHostImpl_TxViewChange( ITextHost2 *iface, BOOL update ) { struct host *host = impl_from_ITextHost( iface ); if (update) UpdateWindow( host->window ); } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxCreateCaret,16) -DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxCreateCaret( ITextHost2 *iface, HBITMAP bitmap, INT width, INT height ) +BOOL __thiscall ITextHostImpl_TxCreateCaret( ITextHost2 *iface, HBITMAP bitmap, INT width, INT height ) { struct host *host = impl_from_ITextHost( iface ); return CreateCaret( host->window, bitmap, width, height ); } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxShowCaret,8) -DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxShowCaret( ITextHost2 *iface, BOOL show ) +BOOL __thiscall ITextHostImpl_TxShowCaret( ITextHost2 *iface, BOOL show ) { struct host *host = impl_from_ITextHost( iface ); if (show) return ShowCaret( host->window ); @@ -277,27 +277,27 @@ DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxShowCaret( ITextHost2 *iface, BO } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetCaretPos,12) -DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxSetCaretPos( ITextHost2 *iface, INT x, INT y ) +BOOL __thiscall ITextHostImpl_TxSetCaretPos( ITextHost2 *iface, INT x, INT y ) { return SetCaretPos(x, y); } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetTimer,12) -DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxSetTimer( ITextHost2 *iface, UINT id, UINT timeout ) +BOOL __thiscall ITextHostImpl_TxSetTimer( ITextHost2 *iface, UINT id, UINT timeout ) { struct host *host = impl_from_ITextHost( iface ); return SetTimer( host->window, id, timeout, NULL ) != 0; } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxKillTimer,8) -DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxKillTimer( ITextHost2 *iface, UINT id ) +void __thiscall ITextHostImpl_TxKillTimer( ITextHost2 *iface, UINT id ) { struct host *host = impl_from_ITextHost( iface ); KillTimer( host->window, id ); } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxScrollWindowEx,32) -DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxScrollWindowEx( ITextHost2 *iface, INT dx, INT dy, const RECT *scroll, +void __thiscall ITextHostImpl_TxScrollWindowEx( ITextHost2 *iface, INT dx, INT dy, const RECT *scroll, const RECT *clip, HRGN update_rgn, RECT *update_rect, UINT flags ) { @@ -306,7 +306,7 @@ DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxScrollWindowEx( ITextHost2 *ifac } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetCapture,8) -DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxSetCapture( ITextHost2 *iface, BOOL capture ) +void __thiscall ITextHostImpl_TxSetCapture( ITextHost2 *iface, BOOL capture ) { struct host *host = impl_from_ITextHost( iface ); if (capture) SetCapture( host->window ); @@ -314,34 +314,34 @@ DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxSetCapture( ITextHost2 *iface, B } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetFocus,4) -DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxSetFocus( ITextHost2 *iface ) +void __thiscall ITextHostImpl_TxSetFocus( ITextHost2 *iface ) { struct host *host = impl_from_ITextHost( iface ); SetFocus( host->window ); } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetCursor,12) -DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxSetCursor( ITextHost2 *iface, HCURSOR cursor, BOOL text ) +void __thiscall ITextHostImpl_TxSetCursor( ITextHost2 *iface, HCURSOR cursor, BOOL text ) { SetCursor( cursor ); } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxScreenToClient,8) -DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxScreenToClient( ITextHost2 *iface, POINT *pt ) +BOOL __thiscall ITextHostImpl_TxScreenToClient( ITextHost2 *iface, POINT *pt ) { struct host *host = impl_from_ITextHost( iface ); return ScreenToClient( host->window, pt ); } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxClientToScreen,8) -DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxClientToScreen( ITextHost2 *iface, POINT *pt ) +BOOL __thiscall ITextHostImpl_TxClientToScreen( ITextHost2 *iface, POINT *pt ) { struct host *host = impl_from_ITextHost( iface ); return ClientToScreen( host->window, pt ); } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxActivate,8) -DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxActivate( ITextHost2 *iface, LONG *old_state ) +HRESULT __thiscall ITextHostImpl_TxActivate( ITextHost2 *iface, LONG *old_state ) { struct host *host = impl_from_ITextHost( iface ); *old_state = HandleToLong( SetActiveWindow( host->window ) ); @@ -349,14 +349,14 @@ DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxActivate( ITextHost2 *iface, } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxDeactivate,8) -DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxDeactivate( ITextHost2 *iface, LONG new_state ) +HRESULT __thiscall ITextHostImpl_TxDeactivate( ITextHost2 *iface, LONG new_state ) { HWND ret = SetActiveWindow( LongToHandle( new_state ) ); return ret ? S_OK : E_FAIL; } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetClientRect,8) -DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetClientRect( ITextHost2 *iface, RECT *rect ) +HRESULT __thiscall ITextHostImpl_TxGetClientRect( ITextHost2 *iface, RECT *rect ) { struct host *host = impl_from_ITextHost( iface ); @@ -372,20 +372,20 @@ DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetClientRect( ITextHost2 *if } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetViewInset,8) -DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetViewInset( ITextHost2 *iface, RECT *rect ) +HRESULT __thiscall ITextHostImpl_TxGetViewInset( ITextHost2 *iface, RECT *rect ) { SetRectEmpty( rect ); return S_OK; } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetCharFormat,8) -DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetCharFormat( ITextHost2 *iface, const CHARFORMATW **ppCF ) +HRESULT __thiscall ITextHostImpl_TxGetCharFormat( ITextHost2 *iface, const CHARFORMATW **ppCF ) { return E_NOTIMPL; } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetParaFormat,8) -DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetParaFormat( ITextHost2 *iface, const PARAFORMAT **fmt ) +HRESULT __thiscall ITextHostImpl_TxGetParaFormat( ITextHost2 *iface, const PARAFORMAT **fmt ) { struct host *host = impl_from_ITextHost( iface ); *fmt = (const PARAFORMAT *)&host->para_fmt; @@ -393,7 +393,7 @@ DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetParaFormat( ITextHost2 *if } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetSysColor,8) -DECLSPEC_HIDDEN COLORREF __thiscall ITextHostImpl_TxGetSysColor( ITextHost2 *iface, int index ) +COLORREF __thiscall ITextHostImpl_TxGetSysColor( ITextHost2 *iface, int index ) { struct host *host = impl_from_ITextHost( iface ); @@ -402,21 +402,21 @@ DECLSPEC_HIDDEN COLORREF __thiscall ITextHostImpl_TxGetSysColor( ITextHost2 *ifa } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetBackStyle,8) -DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetBackStyle( ITextHost2 *iface, TXTBACKSTYLE *style ) +HRESULT __thiscall ITextHostImpl_TxGetBackStyle( ITextHost2 *iface, TXTBACKSTYLE *style ) { *style = TXTBACK_OPAQUE; return S_OK; } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetMaxLength,8) -DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetMaxLength( ITextHost2 *iface, DWORD *length ) +HRESULT __thiscall ITextHostImpl_TxGetMaxLength( ITextHost2 *iface, DWORD *length ) { *length = INFINITE; return S_OK; } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetScrollBars,8) -DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetScrollBars( ITextHost2 *iface, DWORD *scrollbars ) +HRESULT __thiscall ITextHostImpl_TxGetScrollBars( ITextHost2 *iface, DWORD *scrollbars ) { struct host *host = impl_from_ITextHost( iface ); @@ -425,7 +425,7 @@ DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetScrollBars( ITextHost2 *if } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetPasswordChar,8) -DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetPasswordChar( ITextHost2 *iface, WCHAR *c ) +HRESULT __thiscall ITextHostImpl_TxGetPasswordChar( ITextHost2 *iface, WCHAR *c ) { struct host *host = impl_from_ITextHost( iface ); @@ -434,32 +434,32 @@ DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetPasswordChar( ITextHost2 * } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetAcceleratorPos,8) -DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetAcceleratorPos( ITextHost2 *iface, LONG *pos ) +HRESULT __thiscall ITextHostImpl_TxGetAcceleratorPos( ITextHost2 *iface, LONG *pos ) { *pos = -1; return S_OK; } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetExtent,8) -DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetExtent( ITextHost2 *iface, SIZEL *extent ) +HRESULT __thiscall ITextHostImpl_TxGetExtent( ITextHost2 *iface, SIZEL *extent ) { return E_NOTIMPL; } DEFINE_THISCALL_WRAPPER(ITextHostImpl_OnTxCharFormatChange,8) -DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_OnTxCharFormatChange( ITextHost2 *iface, const CHARFORMATW *pcf ) +HRESULT __thiscall ITextHostImpl_OnTxCharFormatChange( ITextHost2 *iface, const CHARFORMATW *pcf ) { return S_OK; } DEFINE_THISCALL_WRAPPER(ITextHostImpl_OnTxParaFormatChange,8) -DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_OnTxParaFormatChange( ITextHost2 *iface, const PARAFORMAT *ppf ) +HRESULT __thiscall ITextHostImpl_OnTxParaFormatChange( ITextHost2 *iface, const PARAFORMAT *ppf ) { return S_OK; } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetPropertyBits,12) -DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetPropertyBits( ITextHost2 *iface, DWORD mask, DWORD *bits ) +HRESULT __thiscall ITextHostImpl_TxGetPropertyBits( ITextHost2 *iface, DWORD mask, DWORD *bits ) { struct host *host = impl_from_ITextHost( iface ); @@ -468,7 +468,7 @@ DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetPropertyBits( ITextHost2 * } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxNotify,12) -DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxNotify( ITextHost2 *iface, DWORD iNotify, void *pv ) +HRESULT __thiscall ITextHostImpl_TxNotify( ITextHost2 *iface, DWORD iNotify, void *pv ) { struct host *host = impl_from_ITextHost( iface ); UINT id; @@ -525,21 +525,21 @@ DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxNotify( ITextHost2 *iface, DW } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxImmGetContext,4) -DECLSPEC_HIDDEN HIMC __thiscall ITextHostImpl_TxImmGetContext( ITextHost2 *iface ) +HIMC __thiscall ITextHostImpl_TxImmGetContext( ITextHost2 *iface ) { struct host *host = impl_from_ITextHost( iface ); return ImmGetContext( host->window ); } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxImmReleaseContext,8) -DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxImmReleaseContext( ITextHost2 *iface, HIMC context ) +void __thiscall ITextHostImpl_TxImmReleaseContext( ITextHost2 *iface, HIMC context ) { struct host *host = impl_from_ITextHost( iface ); ImmReleaseContext( host->window, context ); } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetSelectionBarWidth,8) -DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetSelectionBarWidth( ITextHost2 *iface, LONG *width ) +HRESULT __thiscall ITextHostImpl_TxGetSelectionBarWidth( ITextHost2 *iface, LONG *width ) { struct host *host = impl_from_ITextHost( iface ); @@ -548,13 +548,13 @@ DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetSelectionBarWidth( ITextHo } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxIsDoubleClickPending,4) -DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxIsDoubleClickPending( ITextHost2 *iface ) +BOOL __thiscall ITextHostImpl_TxIsDoubleClickPending( ITextHost2 *iface ) { return FALSE; } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetWindow,8) -DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetWindow( ITextHost2 *iface, HWND *hwnd ) +HRESULT __thiscall ITextHostImpl_TxGetWindow( ITextHost2 *iface, HWND *hwnd ) { struct host *host = impl_from_ITextHost( iface ); *hwnd = host->window; @@ -562,61 +562,61 @@ DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetWindow( ITextHost2 *iface, } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetForegroundWindow,4) -DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxSetForegroundWindow( ITextHost2 *iface ) +HRESULT __thiscall ITextHostImpl_TxSetForegroundWindow( ITextHost2 *iface ) { return E_NOTIMPL; } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetPalette,4) -DECLSPEC_HIDDEN HPALETTE __thiscall ITextHostImpl_TxGetPalette( ITextHost2 *iface ) +HPALETTE __thiscall ITextHostImpl_TxGetPalette( ITextHost2 *iface ) { return NULL; } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetEastAsianFlags,8) -DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetEastAsianFlags( ITextHost2 *iface, LONG *flags ) +HRESULT __thiscall ITextHostImpl_TxGetEastAsianFlags( ITextHost2 *iface, LONG *flags ) { return E_NOTIMPL; } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetCursor2,12) -DECLSPEC_HIDDEN HCURSOR __thiscall ITextHostImpl_TxSetCursor2( ITextHost2 *iface, HCURSOR cursor, BOOL text ) +HCURSOR __thiscall ITextHostImpl_TxSetCursor2( ITextHost2 *iface, HCURSOR cursor, BOOL text ) { return NULL; } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxFreeTextServicesNotification,4) -DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxFreeTextServicesNotification( ITextHost2 *iface ) +void __thiscall ITextHostImpl_TxFreeTextServicesNotification( ITextHost2 *iface ) { return; } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetEditStyle,12) -DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetEditStyle( ITextHost2 *iface, DWORD item, DWORD *data ) +HRESULT __thiscall ITextHostImpl_TxGetEditStyle( ITextHost2 *iface, DWORD item, DWORD *data ) { return E_NOTIMPL; } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetWindowStyles,12) -DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetWindowStyles( ITextHost2 *iface, DWORD *style, DWORD *ex_style ) +HRESULT __thiscall ITextHostImpl_TxGetWindowStyles( ITextHost2 *iface, DWORD *style, DWORD *ex_style ) { return E_NOTIMPL; } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxShowDropCaret,16) -DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxShowDropCaret( ITextHost2 *iface, BOOL show, HDC hdc, const RECT *rect ) +HRESULT __thiscall ITextHostImpl_TxShowDropCaret( ITextHost2 *iface, BOOL show, HDC hdc, const RECT *rect ) { return E_NOTIMPL; } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxDestroyCaret,4) -DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxDestroyCaret( ITextHost2 *iface ) +HRESULT __thiscall ITextHostImpl_TxDestroyCaret( ITextHost2 *iface ) { return E_NOTIMPL; } DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetHorzExtent,8) -DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetHorzExtent( ITextHost2 *iface, LONG *horz_extent ) +HRESULT __thiscall ITextHostImpl_TxGetHorzExtent( ITextHost2 *iface, LONG *horz_extent ) { return E_NOTIMPL; } @@ -900,7 +900,7 @@ static HRESULT get_lineA( ITextServices *text_srv, WPARAM wparam, LPARAM lparam, sizeA = *(WORD *)lparam; *(WORD *)lparam = 0; if (!sizeA) return S_OK; - buf = heap_alloc( len * sizeof(WCHAR) ); + buf = malloc( len * sizeof(WCHAR) ); if (!buf) return E_OUTOFMEMORY; *(WORD *)buf = len; hr = ITextServices_TxSendMessage( text_srv, EM_GETLINE, wparam, (LPARAM)buf, &len ); @@ -911,7 +911,7 @@ static HRESULT get_lineA( ITextServices *text_srv, WPARAM wparam, LPARAM lparam, if (len < sizeA) ((char *)lparam)[len] = '\0'; *res = len; } - heap_free( buf ); + free( buf ); return hr; } @@ -930,7 +930,7 @@ static HRESULT get_text_rangeA( struct host *host, TEXTRANGEA *rangeA, LRESULT * range.chrg.cpMax = len; if (range.chrg.cpMin >= range.chrg.cpMax) return S_OK; count = range.chrg.cpMax - range.chrg.cpMin + 1; - range.lpstrText = heap_alloc( count * sizeof(WCHAR) ); + range.lpstrText = malloc( count * sizeof(WCHAR) ); if (!range.lpstrText) return E_OUTOFMEMORY; hr = ITextServices_TxSendMessage( host->text_srv, EM_GETTEXTRANGE, 0, (LPARAM)&range, &len ); if (hr == S_OK && len) @@ -944,7 +944,7 @@ static HRESULT get_text_rangeA( struct host *host, TEXTRANGEA *rangeA, LRESULT * rangeA->lpstrText[*res] = '\0'; } } - heap_free( range.lpstrText ); + free( range.lpstrText ); return hr; } @@ -1086,7 +1086,7 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam, HRESULT hr = S_OK; LRESULT res = 0; - TRACE( "enter hwnd %p msg %04x (%s) %lx %lx, unicode %d\n", + TRACE( "enter hwnd %p msg %04x (%s) %Ix %Ix, unicode %d\n", hwnd, msg, get_msg_name(msg), wparam, lparam, unicode ); host = (struct host *)GetWindowLongPtrW( hwnd, 0 ); @@ -1096,7 +1096,7 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam, { CREATESTRUCTW *pcs = (CREATESTRUCTW *)lparam; - TRACE( "WM_NCCREATE: hwnd %p style 0x%08x\n", hwnd, pcs->style ); + TRACE( "WM_NCCREATE: hwnd %p style 0x%08lx\n", hwnd, pcs->style ); return create_windowed_editor( hwnd, pcs, FALSE ); } else return DefWindowProcW( hwnd, msg, wparam, lparam ); @@ -1110,7 +1110,7 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam, res = send_msg_filter( host, msg, &wparam, &lparam ); if (!--host->notify_level && host->defer_release) { - TRACE( "exit (filtered deferred release) hwnd %p msg %04x (%s) %lx %lx -> 0\n", + TRACE( "exit (filtered deferred release) hwnd %p msg %04x (%s) %Ix %Ix -> 0\n", hwnd, msg, get_msg_name(msg), wparam, lparam ); ITextHost2_Release( &host->ITextHost_iface ); return 0; @@ -1118,7 +1118,7 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam, if (res) { - TRACE( "exit (filtered %lu) hwnd %p msg %04x (%s) %lx %lx -> 0\n", + TRACE( "exit (filtered %Iu) hwnd %p msg %04x (%s) %Ix %Ix -> 0\n", res, hwnd, msg, get_msg_name(msg), wparam, lparam ); return 0; } @@ -1144,6 +1144,7 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam, WCHAR *textW = NULL; LONG codepage = unicode ? CP_UNICODE : CP_ACP; int len; + LRESULT evmask; ITextServices_OnTxInPlaceActivate( host->text_srv, NULL ); @@ -1152,7 +1153,10 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam, text = unicode ? (void *)createW->lpszName : (void *)createA->lpszName; textW = ME_ToUnicode( codepage, text, &len ); } + ITextServices_TxSendMessage( host->text_srv, EM_GETEVENTMASK, 0, 0, &evmask ); + ITextServices_TxSendMessage( host->text_srv, EM_SETEVENTMASK, 0, evmask & ~ENM_CHANGE, &evmask ); ITextServices_TxSetText( host->text_srv, textW ); + ITextServices_TxSendMessage( host->text_srv, EM_SETEVENTMASK, 0, evmask, NULL ); if (lparam) ME_EndToUnicode( codepage, textW ); break; } @@ -1310,22 +1314,27 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam, HDC hdc; RECT rc, client, update; PAINTSTRUCT ps; - HBRUSH brush = CreateSolidBrush( ITextHost_TxGetSysColor( &host->ITextHost_iface, COLOR_WINDOW ) ); + HBRUSH brush, old_brush; + LONG view_id; ITextHost_TxGetClientRect( &host->ITextHost_iface, &client ); if (msg == WM_PAINT) { + /* TODO retrieve if the text document is frozen */ hdc = BeginPaint( hwnd, &ps ); update = ps.rcPaint; + view_id = TXTVIEW_ACTIVE; } else { hdc = (HDC)wparam; update = client; + view_id = TXTVIEW_INACTIVE; } - brush = SelectObject( hdc, brush ); + brush = CreateSolidBrush( ITextHost_TxGetSysColor( &host->ITextHost_iface, COLOR_WINDOW ) ); + old_brush = SelectObject( hdc, brush ); /* Erase area outside of the formatting rectangle */ if (update.top < client.top) @@ -1358,8 +1367,9 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam, } ITextServices_TxDraw( host->text_srv, DVASPECT_CONTENT, 0, NULL, NULL, hdc, NULL, NULL, NULL, - &update, NULL, 0, TXTVIEW_ACTIVE ); - DeleteObject( SelectObject( hdc, brush ) ); + &update, NULL, 0, view_id ); + SelectObject( hdc, old_brush ); + DeleteObject( brush ); if (msg == WM_PAINT) EndPaint( hwnd, &ps ); return 0; } @@ -1499,7 +1509,7 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam, if (hr == S_FALSE) res = DefWindowProcW( hwnd, msg, wparam, lparam ); - TRACE( "exit hwnd %p msg %04x (%s) %lx %lx, unicode %d -> %lu\n", + TRACE( "exit hwnd %p msg %04x (%s) %Ix %Ix, unicode %d -> %Iu\n", hwnd, msg, get_msg_name(msg), wparam, lparam, unicode, res ); return res; @@ -1538,7 +1548,7 @@ LRESULT WINAPI RichEdit10ANSIWndProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM { CREATESTRUCTW *pcs = (CREATESTRUCTW *)lparam; - TRACE( "WM_NCCREATE: hwnd %p style 0x%08x\n", hwnd, pcs->style ); + TRACE( "WM_NCCREATE: hwnd %p style 0x%08lx\n", hwnd, pcs->style ); return create_windowed_editor( hwnd, pcs, TRUE ); } return RichEditANSIWndProc( hwnd, msg, wparam, lparam ); @@ -1547,7 +1557,7 @@ LRESULT WINAPI RichEdit10ANSIWndProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM static LRESULT WINAPI REComboWndProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { /* FIXME: Not implemented */ - TRACE( "hwnd %p msg %04x (%s) %08lx %08lx\n", + TRACE( "hwnd %p msg %04x (%s) %08Ix %08Ix\n", hwnd, msg, get_msg_name( msg ), wparam, lparam ); return DefWindowProcW( hwnd, msg, wparam, lparam ); } @@ -1555,7 +1565,7 @@ static LRESULT WINAPI REComboWndProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM static LRESULT WINAPI REListWndProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { /* FIXME: Not implemented */ - TRACE( "hwnd %p msg %04x (%s) %08lx %08lx\n", + TRACE( "hwnd %p msg %04x (%s) %08Ix %08Ix\n", hwnd, msg, get_msg_name( msg ), wparam, lparam ); return DefWindowProcW( hwnd, msg, wparam, lparam ); } @@ -1658,7 +1668,6 @@ BOOL WINAPI DllMain( HINSTANCE instance, DWORD reason, void *reserved ) case DLL_PROCESS_ATTACH: dll_instance = instance; DisableThreadLibraryCalls( instance ); - me_heap = HeapCreate( 0, 0x10000, 0 ); if (!register_classes( instance )) return FALSE; LookupInit(); break; @@ -1672,7 +1681,6 @@ BOOL WINAPI DllMain( HINSTANCE instance, DWORD reason, void *reserved ) if (listbox_registered) UnregisterClassW( L"REListBox20W", 0 ); if (combobox_registered) UnregisterClassW( L"REComboBox20W", 0 ); LookupCleanup(); - HeapDestroy( me_heap ); release_typelib(); break; } diff --git a/dll/win32/riched20/txtsrv.c b/dll/win32/riched20/txtsrv.c index 1e119601e92..db47be0ccc5 100644 --- a/dll/win32/riched20/txtsrv.c +++ b/dll/win32/riched20/txtsrv.c @@ -66,7 +66,7 @@ static ULONG WINAPI ITextServicesImpl_AddRef(IUnknown *iface) struct text_services *services = impl_from_IUnknown( iface ); LONG ref = InterlockedIncrement( &services->ref ); - TRACE( "(%p) ref = %d\n", services, ref ); + TRACE( "(%p) ref = %ld\n", services, ref ); return ref; } @@ -76,13 +76,13 @@ static ULONG WINAPI ITextServicesImpl_Release(IUnknown *iface) struct text_services *services = impl_from_IUnknown( iface ); LONG ref = InterlockedDecrement( &services->ref ); - TRACE( "(%p) ref = %d\n", services, ref ); + TRACE( "(%p) ref = %ld\n", services, ref ); if (!ref) { richole_release_children( services ); ME_DestroyEditor( services->editor ); - CoTaskMemFree( services ); + free( services ); } return ref; } @@ -118,7 +118,7 @@ static ULONG WINAPI fnTextSrv_Release(ITextServices *iface) } DEFINE_THISCALL_WRAPPER(fnTextSrv_TxSendMessage,20) -DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxSendMessage( ITextServices *iface, UINT msg, WPARAM wparam, +HRESULT __thiscall fnTextSrv_TxSendMessage( ITextServices *iface, UINT msg, WPARAM wparam, LPARAM lparam, LRESULT *result ) { struct text_services *services = impl_from_ITextServices( iface ); @@ -151,7 +151,7 @@ static HRESULT update_client_rect( struct text_services *services, const RECT *c } DEFINE_THISCALL_WRAPPER(fnTextSrv_TxDraw,52) -DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxDraw( ITextServices *iface, DWORD aspect, LONG index, void *aspect_info, +HRESULT __thiscall fnTextSrv_TxDraw( ITextServices *iface, DWORD aspect, LONG index, void *aspect_info, DVTARGETDEVICE *td, HDC draw, HDC target, const RECTL *bounds, const RECTL *mf_bounds, RECT *update, BOOL (CALLBACK *continue_fn)(DWORD), DWORD continue_param, @@ -162,13 +162,15 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxDraw( ITextServices *iface, DWORD HDC dc = draw; BOOL rewrap = FALSE; - TRACE( "%p: aspect %d, %d, %p, %p, draw %p, target %p, bounds %s, mf_bounds %s, update %s, %p, %d, view %d\n", + TRACE( "%p: aspect %ld, %ld, %p, %p, draw %p, target %p, bounds %s, mf_bounds %s, update %s, %p, %ld, view %ld\n", services, aspect, index, aspect_info, td, draw, target, wine_dbgstr_rect( (RECT *)bounds ), wine_dbgstr_rect( (RECT *)mf_bounds ), wine_dbgstr_rect( update ), continue_fn, continue_param, view_id ); if (aspect != DVASPECT_CONTENT || aspect_info || td || target || mf_bounds || continue_fn ) FIXME( "Many arguments are ignored\n" ); + if (view_id == TXTVIEW_ACTIVE && services->editor->freeze_count) return E_UNEXPECTED; + hr = update_client_rect( services, (RECT *)bounds ); if (FAILED( hr )) return hr; if (hr == S_OK) rewrap = TRUE; @@ -193,7 +195,7 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxDraw( ITextServices *iface, DWORD } DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetHScroll,24) -DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetHScroll( ITextServices *iface, LONG *min_pos, LONG *max_pos, LONG *pos, +HRESULT __thiscall fnTextSrv_TxGetHScroll( ITextServices *iface, LONG *min_pos, LONG *max_pos, LONG *pos, LONG *page, BOOL *enabled ) { struct text_services *services = impl_from_ITextServices( iface ); @@ -207,7 +209,7 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetHScroll( ITextServices *iface, } DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetVScroll,24) -DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetVScroll( ITextServices *iface, LONG *min_pos, LONG *max_pos, LONG *pos, +HRESULT __thiscall fnTextSrv_TxGetVScroll( ITextServices *iface, LONG *min_pos, LONG *max_pos, LONG *pos, LONG *page, BOOL *enabled ) { struct text_services *services = impl_from_ITextServices( iface ); @@ -221,13 +223,13 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetVScroll( ITextServices *iface, } DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxSetCursor,40) -DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxSetCursor( ITextServices *iface, DWORD aspect, LONG index, +HRESULT __thiscall fnTextSrv_OnTxSetCursor( ITextServices *iface, DWORD aspect, LONG index, void *aspect_info, DVTARGETDEVICE *td, HDC draw, HDC target, const RECT *client, INT x, INT y ) { struct text_services *services = impl_from_ITextServices( iface ); - TRACE( "%p: %d, %d, %p, %p, draw %p target %p client %s pos (%d, %d)\n", services, aspect, index, aspect_info, td, draw, + TRACE( "%p: %ld, %ld, %p, %p, draw %p target %p client %s pos (%d, %d)\n", services, aspect, index, aspect_info, td, draw, target, wine_dbgstr_rect( client ), x, y ); if (aspect != DVASPECT_CONTENT || index || aspect_info || td || draw || target || client) @@ -239,7 +241,7 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxSetCursor( ITextServices *iface } DEFINE_THISCALL_WRAPPER(fnTextSrv_TxQueryHitPoint,44) -DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxQueryHitPoint(ITextServices *iface, DWORD dwDrawAspect, LONG lindex, +HRESULT __thiscall fnTextSrv_TxQueryHitPoint(ITextServices *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd, HDC hdcDraw, HDC hicTargetDev, LPCRECT lprcClient, INT x, INT y, DWORD *pHitResult) @@ -251,7 +253,7 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxQueryHitPoint(ITextServices *ifac } DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxInPlaceActivate,8) -DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxInPlaceActivate( ITextServices *iface, const RECT *client ) +HRESULT __thiscall fnTextSrv_OnTxInPlaceActivate( ITextServices *iface, const RECT *client ) { struct text_services *services = impl_from_ITextServices( iface ); HRESULT hr; @@ -271,7 +273,7 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxInPlaceActivate( ITextServices } DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxInPlaceDeactivate,4) -DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxInPlaceDeactivate(ITextServices *iface) +HRESULT __thiscall fnTextSrv_OnTxInPlaceDeactivate(ITextServices *iface) { struct text_services *services = impl_from_ITextServices( iface ); @@ -281,7 +283,7 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxInPlaceDeactivate(ITextServices } DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxUIActivate,4) -DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxUIActivate(ITextServices *iface) +HRESULT __thiscall fnTextSrv_OnTxUIActivate(ITextServices *iface) { struct text_services *services = impl_from_ITextServices( iface ); @@ -290,7 +292,7 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxUIActivate(ITextServices *iface } DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxUIDeactivate,4) -DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxUIDeactivate(ITextServices *iface) +HRESULT __thiscall fnTextSrv_OnTxUIDeactivate(ITextServices *iface) { struct text_services *services = impl_from_ITextServices( iface ); @@ -299,7 +301,7 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxUIDeactivate(ITextServices *ifa } DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetText,8) -DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetText( ITextServices *iface, BSTR *text ) +HRESULT __thiscall fnTextSrv_TxGetText( ITextServices *iface, BSTR *text ) { struct text_services *services = impl_from_ITextServices( iface ); int length; @@ -322,7 +324,7 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetText( ITextServices *iface, BS } DEFINE_THISCALL_WRAPPER(fnTextSrv_TxSetText,8) -DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxSetText( ITextServices *iface, const WCHAR *text ) +HRESULT __thiscall fnTextSrv_TxSetText( ITextServices *iface, const WCHAR *text ) { struct text_services *services = impl_from_ITextServices( iface ); ME_Cursor cursor; @@ -340,7 +342,7 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxSetText( ITextServices *iface, co } DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetCurTargetX,8) -DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetCurTargetX(ITextServices *iface, LONG *x) +HRESULT __thiscall fnTextSrv_TxGetCurTargetX(ITextServices *iface, LONG *x) { struct text_services *services = impl_from_ITextServices( iface ); @@ -349,7 +351,7 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetCurTargetX(ITextServices *ifac } DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetBaseLinePos,8) -DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetBaseLinePos(ITextServices *iface, LONG *x) +HRESULT __thiscall fnTextSrv_TxGetBaseLinePos(ITextServices *iface, LONG *x) { struct text_services *services = impl_from_ITextServices( iface ); @@ -358,7 +360,7 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetBaseLinePos(ITextServices *ifa } DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetNaturalSize,36) -DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetNaturalSize( ITextServices *iface, DWORD aspect, HDC draw, +HRESULT __thiscall fnTextSrv_TxGetNaturalSize( ITextServices *iface, DWORD aspect, HDC draw, HDC target, DVTARGETDEVICE *td, DWORD mode, const SIZEL *extent, LONG *width, LONG *height ) { @@ -368,7 +370,7 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetNaturalSize( ITextServices *if BOOL rewrap = FALSE; HRESULT hr; - TRACE( "%p: aspect %d, draw %p, target %p, td %p, mode %08x, extent %s, *width %d, *height %d\n", services, + TRACE( "%p: aspect %ld, draw %p, target %p, td %p, mode %08lx, extent %s, *width %ld, *height %ld\n", services, aspect, draw, target, td, mode, wine_dbgstr_point( (POINT *)extent ), *width, *height ); if (aspect != DVASPECT_CONTENT || target || td || mode != TXTNS_FITTOCONTENT ) @@ -398,7 +400,7 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetNaturalSize( ITextServices *if } DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetDropTarget,8) -DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetDropTarget(ITextServices *iface, IDropTarget **ppDropTarget) +HRESULT __thiscall fnTextSrv_TxGetDropTarget(ITextServices *iface, IDropTarget **ppDropTarget) { struct text_services *services = impl_from_ITextServices( iface ); @@ -407,14 +409,14 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetDropTarget(ITextServices *ifac } DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxPropertyBitsChange,12) -DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxPropertyBitsChange( ITextServices *iface, DWORD mask, DWORD bits ) +HRESULT __thiscall fnTextSrv_OnTxPropertyBitsChange( ITextServices *iface, DWORD mask, DWORD bits ) { struct text_services *services = impl_from_ITextServices( iface ); DWORD scrollbars; HRESULT hr; BOOL repaint = FALSE; - TRACE( "%p, mask %08x, bits %08x\n", services, mask, bits ); + TRACE( "%p, mask %08lx, bits %08lx\n", services, mask, bits ); services->editor->props = (services->editor->props & ~mask) | (bits & mask); if (mask & (TXTBIT_WORDWRAP | TXTBIT_MULTILINE)) @@ -471,7 +473,7 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxPropertyBitsChange( ITextServic } DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetCachedSize,12) -DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetCachedSize(ITextServices *iface, DWORD *pdwWidth, DWORD *pdwHeight) +HRESULT __thiscall fnTextSrv_TxGetCachedSize(ITextServices *iface, DWORD *pdwWidth, DWORD *pdwHeight) { struct text_services *services = impl_from_ITextServices( iface ); @@ -581,7 +583,7 @@ HRESULT create_text_services( IUnknown *outer, ITextHost *text_host, IUnknown ** TRACE( "%p %p --> %p\n", outer, text_host, unk ); if (text_host == NULL) return E_POINTER; - services = CoTaskMemAlloc( sizeof(*services) ); + services = malloc( sizeof(*services) ); if (services == NULL) return E_OUTOFMEMORY; services->ref = 1; services->IUnknown_inner.lpVtbl = &textservices_inner_vtbl; diff --git a/dll/win32/riched20/undo.c b/dll/win32/riched20/undo.c index d95ce121234..27637909ebf 100644 --- a/dll/win32/riched20/undo.c +++ b/dll/win32/riched20/undo.c @@ -27,7 +27,7 @@ static void destroy_undo_item( struct undo_item *undo ) switch( undo->type ) { case undo_insert_run: - heap_free( undo->u.insert_run.str ); + free( undo->u.insert_run.str ); ME_ReleaseStyle( undo->u.insert_run.style ); break; case undo_split_para: @@ -37,7 +37,7 @@ static void destroy_undo_item( struct undo_item *undo ) break; } - heap_free( undo ); + free( undo ); } static void empty_redo_stack(ME_TextEditor *editor) @@ -53,7 +53,7 @@ static void empty_redo_stack(ME_TextEditor *editor) void ME_EmptyUndoStack(ME_TextEditor *editor) { struct undo_item *cursor, *cursor2; - if (editor->nUndoMode == umIgnore) + if (editor->nUndoMode == umIgnore) /* NOTE don't use editor_undo_ignored() here! */ return; TRACE("Emptying undo stack\n"); @@ -74,10 +74,10 @@ static struct undo_item *add_undo( ME_TextEditor *editor, enum undo_type type ) struct undo_item *undo, *item; struct list *head; - if (editor->nUndoMode == umIgnore) return NULL; + if (editor_undo_ignored(editor)) return NULL; if (editor->nUndoLimit == 0) return NULL; - undo = heap_alloc( sizeof(*undo) ); + undo = malloc( sizeof(*undo) ); if (!undo) return NULL; undo->type = type; @@ -133,7 +133,7 @@ BOOL add_undo_insert_run( ME_TextEditor *editor, int pos, const WCHAR *str, int struct undo_item *undo = add_undo( editor, undo_insert_run ); if (!undo) return FALSE; - undo->u.insert_run.str = heap_alloc( (len + 1) * sizeof(WCHAR) ); + undo->u.insert_run.str = malloc( (len + 1) * sizeof(WCHAR) ); if (!undo->u.insert_run.str) { ME_EmptyUndoStack( editor ); @@ -229,7 +229,7 @@ void ME_CommitUndo(ME_TextEditor *editor) struct undo_item *item; struct list *head; - if (editor->nUndoMode == umIgnore) + if (editor_undo_ignored(editor)) return; assert(editor->nUndoMode == umAddToUndo); @@ -267,7 +267,7 @@ void ME_ContinueCoalescingTransaction(ME_TextEditor *editor) struct undo_item *item; struct list *head; - if (editor->nUndoMode == umIgnore) + if (editor_undo_ignored(editor)) return; assert(editor->nUndoMode == umAddToUndo); @@ -303,7 +303,7 @@ void ME_CommitCoalescingUndo(ME_TextEditor *editor) struct undo_item *item; struct list *head; - if (editor->nUndoMode == umIgnore) + if (editor_undo_ignored(editor)) return; assert(editor->nUndoMode == umAddToUndo); @@ -323,7 +323,7 @@ void ME_CommitCoalescingUndo(ME_TextEditor *editor) static void ME_PlayUndoItem(ME_TextEditor *editor, struct undo_item *undo) { - if (editor->nUndoMode == umIgnore) + if (editor_undo_ignored(editor)) return; TRACE("Playing undo/redo item, id=%d\n", undo->type); @@ -413,7 +413,7 @@ BOOL ME_Undo(ME_TextEditor *editor) struct list *head; struct undo_item *undo, *cursor2; - if (editor->nUndoMode == umIgnore) return FALSE; + if (editor_undo_ignored(editor)) return FALSE; assert(nMode == umAddToUndo || nMode == umIgnore); head = list_head( &editor->undo_stack ); @@ -453,7 +453,7 @@ BOOL ME_Redo(ME_TextEditor *editor) assert(nMode == umAddToUndo || nMode == umIgnore); - if (editor->nUndoMode == umIgnore) return FALSE; + if (editor_undo_ignored(editor)) return FALSE; head = list_head( &editor->redo_stack ); if (!head) return FALSE; @@ -479,3 +479,17 @@ BOOL ME_Redo(ME_TextEditor *editor) ME_UpdateRepaint(editor, FALSE); return TRUE; } + +void editor_disable_undo(ME_TextEditor *editor) +{ + ME_EmptyUndoStack(editor); + editor->undo_ctl_state = undoDisabled; +} + +void editor_enable_undo(ME_TextEditor *editor) +{ + if (editor->undo_ctl_state == undoDisabled) + { + editor->undo_ctl_state = undoActive; + } +} diff --git a/dll/win32/riched20/wrap.c b/dll/win32/riched20/wrap.c index 9456d54d815..a4d638aec3d 100644 --- a/dll/win32/riched20/wrap.c +++ b/dll/win32/riched20/wrap.c @@ -50,8 +50,8 @@ typedef struct tagME_WrapContext static BOOL get_run_glyph_buffers( ME_Run *run ) { - heap_free( run->glyphs ); - run->glyphs = heap_alloc( run->max_glyphs * (sizeof(WORD) + sizeof(SCRIPT_VISATTR) + sizeof(int) + sizeof(GOFFSET)) ); + free( run->glyphs ); + run->glyphs = malloc( run->max_glyphs * (sizeof(WORD) + sizeof(SCRIPT_VISATTR) + sizeof(int) + sizeof(GOFFSET)) ); if (!run->glyphs) return FALSE; run->vis_attrs = (SCRIPT_VISATTR*)((char*)run->glyphs + run->max_glyphs * sizeof(WORD)); @@ -75,9 +75,9 @@ static HRESULT shape_run( ME_Context *c, ME_Run *run ) if (run->max_clusters < run->len) { - heap_free( run->clusters ); + free( run->clusters ); run->max_clusters = run->len * 2; - run->clusters = heap_alloc( run->max_clusters * sizeof(WORD) ); + run->clusters = malloc( run->max_clusters * sizeof(WORD) ); } select_style( c, run->style ); @@ -136,7 +136,7 @@ static ME_Run *split_run_extents( ME_WrapContext *wc, ME_Run *run, int nVChar ) assert( run->nCharOfs != -1 ); ME_CheckCharOffsets(editor); - TRACE("Before split: %s(%d, %d)\n", debugstr_run( run ), + TRACE("Before split: %s(%ld, %ld)\n", debugstr_run( run ), run->pt.x, run->pt.y); run_split( editor, &cursor ); @@ -153,7 +153,7 @@ static ME_Run *split_run_extents( ME_WrapContext *wc, ME_Run *run, int nVChar ) ME_CheckCharOffsets(editor); - TRACE("After split: %s(%d, %d), %s(%d, %d)\n", + TRACE("After split: %s(%ld, %ld), %s(%ld, %ld)\n", debugstr_run( run ), run->pt.x, run->pt.y, debugstr_run( run2 ), run2->pt.x, run2->pt.y); @@ -250,7 +250,7 @@ static void layout_row( ME_Run *start, ME_Run *last ) if (!num_runs) return; if (num_runs > ARRAY_SIZE( buf ) / 5) - vis_to_log = heap_alloc( num_runs * sizeof(int) * 5 ); + vis_to_log = malloc( num_runs * sizeof(int) * 5 ); log_to_vis = vis_to_log + num_runs; widths = vis_to_log + 2 * num_runs; @@ -274,11 +274,11 @@ static void layout_row( ME_Run *start, ME_Run *last ) for (i = 0, run = start; i < num_runs; run = run_next( run )) { run->pt.x = pos[ log_to_vis[ i ] ]; - TRACE( "%d: x = %d\n", i, run->pt.x ); + TRACE( "%d: x = %ld\n", i, run->pt.x ); i++; } - if (vis_to_log != buf) heap_free( vis_to_log ); + if (vis_to_log != buf) free( vis_to_log ); } static void ME_InsertRowStart( ME_WrapContext *wc, ME_Run *last ) @@ -744,9 +744,9 @@ static HRESULT itemize_para( ME_Context *c, ME_Paragraph *para ) if (items_passed > para->text->nLen + 1) break; /* something else has gone wrong */ items_passed *= 2; if (items == buf) - items = heap_alloc( items_passed * sizeof( *items ) ); + items = malloc( items_passed * sizeof( *items ) ); else - items = heap_realloc( items, items_passed * sizeof( *items ) ); + items = realloc( items, items_passed * sizeof( *items ) ); if (!items) break; } if (FAILED( hr )) goto end; @@ -792,7 +792,7 @@ static HRESULT itemize_para( ME_Context *c, ME_Paragraph *para ) para->nFlags |= MEPF_COMPLEX; end: - if (items != buf) heap_free( items ); + if (items != buf) free( items ); return hr; } @@ -835,6 +835,15 @@ static void ME_WrapTextParagraph( ME_TextEditor *editor, ME_Context *c, ME_Parag if (SUCCEEDED( itemize_para( c, para ) )) shape_para( c, para ); } + else + { + /* If the user has just converted a normal rich editor with already + * existing text into a password input, the text may contain paragraphs + * with MEPF_COMPLEX set. Since we don't really shape any paragraphs + * here, we need to ensure that the MEPF_COMPLEX flag is unset. + */ + para->nFlags &= ~MEPF_COMPLEX; + } wc.context = c; wc.para = para; @@ -1032,7 +1041,7 @@ BOOL wrap_marked_paras_dc( ME_TextEditor *editor, HDC hdc, BOOL invalidate ) ME_InitContext( &c, editor, hdc ); - entry = wine_rb_head( editor->marked_paras.root ); + entry = rb_head( editor->marked_paras.root ); while (entry) { para = WINE_RB_ENTRY_VALUE( entry, ME_Paragraph, marked_entry ); @@ -1045,7 +1054,7 @@ BOOL wrap_marked_paras_dc( ME_TextEditor *editor, HDC hdc, BOOL invalidate ) next_entry = entry; } else - next_entry = wine_rb_next( entry ); + next_entry = rb_next( entry ); c.pt = para->pt; prev_width = para->nWidth; @@ -1076,7 +1085,7 @@ BOOL wrap_marked_paras_dc( ME_TextEditor *editor, HDC hdc, BOOL invalidate ) } entry = next_entry; } - wine_rb_clear( &editor->marked_paras, NULL, NULL ); + wine_rb_destroy( &editor->marked_paras, NULL, NULL ); editor->sizeWindow.cx = c.rcView.right-c.rcView.left; editor->sizeWindow.cy = c.rcView.bottom-c.rcView.top; diff --git a/dll/win32/riched20/writer.c b/dll/win32/riched20/writer.c index 7c7e648f107..70d5290b01e 100644 --- a/dll/win32/riched20/writer.c +++ b/dll/win32/riched20/writer.c @@ -18,8 +18,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#define NONAMELESSUNION - #include "editor.h" #include "rtf.h" @@ -54,7 +52,7 @@ ME_StreamOutRTFText(ME_OutStream *pStream, const WCHAR *text, LONG nChars); static ME_OutStream* ME_StreamOutInit(ME_TextEditor *editor, EDITSTREAM *stream) { - ME_OutStream *pStream = heap_alloc_zero(sizeof(*pStream)); + ME_OutStream *pStream = calloc(1, sizeof(*pStream)); pStream->stream = stream; pStream->stream->dwError = 0; @@ -76,7 +74,7 @@ ME_StreamOutFlush(ME_OutStream *pStream) nWritten = pStream->pos; stream->dwError = stream->pfnCallback(stream->dwCookie, (LPBYTE)pStream->buffer, pStream->pos, &nWritten); - TRACE("error=%u written=%u\n", stream->dwError, nWritten); + TRACE("error=%lu written=%lu\n", stream->dwError, nWritten); if (nWritten == 0 || stream->dwError) return FALSE; /* Don't resend partial chunks if nWritten < pStream->pos */ @@ -92,9 +90,9 @@ static LONG ME_StreamOutFree(ME_OutStream *pStream) { LONG written = pStream->written; - TRACE("total length = %u\n", written); + TRACE("total length = %lu\n", written); - heap_free(pStream); + free(pStream); return written; } @@ -125,11 +123,11 @@ ME_StreamOutPrint(ME_OutStream *pStream, const char *format, ...) { char string[STREAMOUT_BUFFER_SIZE]; /* This is going to be enough */ int len; - __ms_va_list valist; + va_list valist; - __ms_va_start(valist, format); + va_start(valist, format); len = vsnprintf(string, sizeof(string), format, valist); - __ms_va_end(valist); + va_end(valist); return ME_StreamOutMove(pStream, string, len); } @@ -400,9 +398,9 @@ static BOOL stream_out_table_props( ME_TextEditor *editor, ME_OutStream *pStream cell = table_row_first_cell( para ); assert( cell ); if (pFmt->dxOffset) - sprintf(props + strlen(props), "\\trgaph%d", pFmt->dxOffset); + sprintf(props + strlen(props), "\\trgaph%ld", pFmt->dxOffset); if (pFmt->dxStartIndent) - sprintf(props + strlen(props), "\\trleft%d", pFmt->dxStartIndent); + sprintf(props + strlen(props), "\\trleft%ld", pFmt->dxStartIndent); do { ME_Border* borders[4] = { &cell->border.top, &cell->border.left, @@ -434,9 +432,9 @@ static BOOL stream_out_table_props( ME_TextEditor *editor, ME_OutStream *pStream assert( !(para->nFlags & (MEPF_ROWSTART | MEPF_ROWEND | MEPF_CELL)) ); if (pFmt->dxOffset) - sprintf(props + strlen(props), "\\trgaph%d", pFmt->dxOffset); + sprintf(props + strlen(props), "\\trgaph%ld", pFmt->dxOffset); if (pFmt->dxStartIndent) - sprintf(props + strlen(props), "\\trleft%d", pFmt->dxStartIndent); + sprintf(props + strlen(props), "\\trleft%ld", pFmt->dxStartIndent); for (i = 0; i < 4; i++) { if (borders[i]->width) @@ -452,7 +450,7 @@ static BOOL stream_out_table_props( ME_TextEditor *editor, ME_OutStream *pStream } for (i = 0; i < pFmt->cTabCount; i++) { - sprintf(props + strlen(props), "\\cellx%d", pFmt->rgxTabs[i] & 0x00FFFFFF); + sprintf(props + strlen(props), "\\cellx%ld", pFmt->rgxTabs[i] & 0x00FFFFFF); } } if (!ME_StreamOutPrint(pStream, props)) @@ -631,13 +629,13 @@ static BOOL stream_out_para_props( ME_TextEditor *editor, ME_OutStream *pStream, strcat(props, "\\sl-480\\slmult1"); break; case 3: - sprintf(props + strlen(props), "\\sl%d\\slmult0", fmt->dyLineSpacing); + sprintf(props + strlen(props), "\\sl%ld\\slmult0", fmt->dyLineSpacing); break; case 4: - sprintf(props + strlen(props), "\\sl-%d\\slmult0", fmt->dyLineSpacing); + sprintf(props + strlen(props), "\\sl-%ld\\slmult0", fmt->dyLineSpacing); break; case 5: - sprintf(props + strlen(props), "\\sl-%d\\slmult1", fmt->dyLineSpacing * 240 / 20); + sprintf(props + strlen(props), "\\sl-%ld\\slmult1", fmt->dyLineSpacing * 240 / 20); break; } } @@ -663,11 +661,11 @@ static BOOL stream_out_para_props( ME_TextEditor *editor, ME_OutStream *pStream, fmt->dwMask & PFM_TABLE && fmt->wEffects & PFE_TABLE)) { if (fmt->dxOffset) - sprintf(props + strlen(props), "\\li%d", fmt->dxOffset); + sprintf(props + strlen(props), "\\li%ld", fmt->dxOffset); if (fmt->dxStartIndent) - sprintf(props + strlen(props), "\\fi%d", fmt->dxStartIndent); + sprintf(props + strlen(props), "\\fi%ld", fmt->dxStartIndent); if (fmt->dxRightIndent) - sprintf(props + strlen(props), "\\ri%d", fmt->dxRightIndent); + sprintf(props + strlen(props), "\\ri%ld", fmt->dxRightIndent); if (fmt->dwMask & PFM_TABSTOPS) { static const char * const leader[6] = { "", "\\tldot", "\\tlhyph", "\\tlul", "\\tlth", "\\tleq" }; @@ -690,14 +688,14 @@ static BOOL stream_out_para_props( ME_TextEditor *editor, ME_OutStream *pStream, } if (fmt->rgxTabs[i] >> 28 <= 5) strcat(props, leader[fmt->rgxTabs[i] >> 28]); - sprintf(props+strlen(props), "\\tx%d", fmt->rgxTabs[i]&0x00FFFFFF); + sprintf(props+strlen(props), "\\tx%ld", fmt->rgxTabs[i]&0x00FFFFFF); } } } if (fmt->dySpaceAfter) - sprintf(props + strlen(props), "\\sa%d", fmt->dySpaceAfter); + sprintf(props + strlen(props), "\\sa%ld", fmt->dySpaceAfter); if (fmt->dySpaceBefore) - sprintf(props + strlen(props), "\\sb%d", fmt->dySpaceBefore); + sprintf(props + strlen(props), "\\sb%ld", fmt->dySpaceBefore); if (fmt->sStyle != -1) sprintf(props + strlen(props), "\\s%d", fmt->sStyle); @@ -791,12 +789,12 @@ ME_StreamOutRTFCharProps(ME_OutStream *pStream, CHARFORMAT2W *fmt) if (old_fmt->yOffset != fmt->yOffset) { if (fmt->yOffset >= 0) - sprintf(props + strlen(props), "\\up%d", fmt->yOffset); + sprintf(props + strlen(props), "\\up%ld", fmt->yOffset); else - sprintf(props + strlen(props), "\\dn%d", -fmt->yOffset); + sprintf(props + strlen(props), "\\dn%ld", -fmt->yOffset); } if (old_fmt->yHeight != fmt->yHeight) - sprintf(props + strlen(props), "\\fs%d", fmt->yHeight / 10); + sprintf(props + strlen(props), "\\fs%ld", fmt->yHeight / 10); if (old_fmt->sSpacing != fmt->sSpacing) sprintf(props + strlen(props), "\\expnd%u\\expndtw%u", fmt->sSpacing / 5, fmt->sSpacing); if ((old_fmt->dwEffects ^ fmt->dwEffects) & (CFM_SUBSCRIPT | CFM_SUPERSCRIPT)) @@ -953,13 +951,13 @@ static BOOL stream_out_graphics( ME_TextEditor *editor, ME_OutStream *stream, if (FAILED(hr)) goto done; if (med.tymed != TYMED_ENHMF) goto done; - size = GetEnhMetaFileBits( med.u.hEnhMetaFile, 0, NULL ); + size = GetEnhMetaFileBits( med.hEnhMetaFile, 0, NULL ); if (size < FIELD_OFFSET(ENHMETAHEADER, cbPixelFormat)) goto done; - emf_bits = HeapAlloc( GetProcessHeap(), 0, size ); + emf_bits = malloc( size ); if (!emf_bits) goto done; - size = GetEnhMetaFileBits( med.u.hEnhMetaFile, size, (BYTE *)emf_bits ); + size = GetEnhMetaFileBits( med.hEnhMetaFile, size, (BYTE *)emf_bits ); if (size < FIELD_OFFSET(ENHMETAHEADER, cbPixelFormat)) goto done; /* size_in_pixels = (frame_size / 100) * szlDevice / szlMillimeters @@ -988,7 +986,7 @@ static BOOL stream_out_graphics( ME_TextEditor *editor, ME_OutStream *stream, done: ME_DestroyContext( &c ); ITextHost_TxReleaseDC( editor->texthost, hdc ); - HeapFree( GetProcessHeap(), 0, emf_bits ); + free( emf_bits ); ReleaseStgMedium( &med ); IDataObject_Release( data ); return ret; @@ -1157,7 +1155,7 @@ static BOOL ME_StreamOutText(ME_TextEditor *editor, ME_OutStream *pStream, nSize = WideCharToMultiByte(nCodePage, 0, get_text( cursor.run, cursor.nOffset ), nLen, NULL, 0, NULL, NULL); if (nSize > nBufLen) { - buffer = heap_realloc(buffer, nSize); + buffer = realloc(buffer, nSize); nBufLen = nSize; } WideCharToMultiByte(nCodePage, 0, get_text( cursor.run, cursor.nOffset ), @@ -1171,7 +1169,7 @@ static BOOL ME_StreamOutText(ME_TextEditor *editor, ME_OutStream *pStream, cursor.run = run_next_all_paras( cursor.run ); } - heap_free(buffer); + free(buffer); return success; } @@ -1198,7 +1196,7 @@ ME_StreamOut(ME_TextEditor *editor, DWORD dwFormat, EDITSTREAM *stream) int nChars; if (dwFormat & SFF_SELECTION) { - int nStart, nTo; + LONG nStart, nTo; start = editor->pCursors[ME_GetSelectionOfs(editor, &nStart, &nTo)]; nChars = nTo - nStart; } else { diff --git a/media/doc/WINESYNC.txt b/media/doc/WINESYNC.txt index 5b9b547506f..f10f0737bd1 100644 --- a/media/doc/WINESYNC.txt +++ b/media/doc/WINESYNC.txt @@ -168,7 +168,7 @@ dll/win32/query # Synced to WineStaging-4.18 dll/win32/rasapi32 # Synced to WineStaging-3.3 dll/win32/regapi # Synced to WineStaging-5.7 dll/win32/resutils # Synced to WineStaging-3.3 -dll/win32/riched20 # Synced to Wine-6.10 +dll/win32/riched20 # Synced to Wine-10.0 dll/win32/riched32 # Synced to WineStaging-3.3 dll/win32/rpcrt4 # Synced to WineStaging-4.18 dll/win32/rsabase # Synced to WineStaging-3.3 diff --git a/modules/rostests/winetests/riched20/CMakeLists.txt b/modules/rostests/winetests/riched20/CMakeLists.txt index 15c730ab8d0..e37b03809b1 100644 --- a/modules/rostests/winetests/riched20/CMakeLists.txt +++ b/modules/rostests/winetests/riched20/CMakeLists.txt @@ -1,4 +1,5 @@ +remove_definitions(-D__ROS_LONG64__) add_definitions(-DUSE_WINE_TODOS) list(APPEND SOURCE diff --git a/modules/rostests/winetests/riched20/editor.c b/modules/rostests/winetests/riched20/editor.c index 6bac7e0a89b..718cb2bd631 100644 --- a/modules/rostests/winetests/riched20/editor.c +++ b/modules/rostests/winetests/riched20/editor.c @@ -110,6 +110,22 @@ static HWND new_richeditW(HWND parent) { return new_windowW(RICHEDIT_CLASS20W, ES_MULTILINE, parent); } +static WNDCLASSA make_simple_class(WNDPROC wndproc, LPCSTR lpClassName) +{ + WNDCLASSA cls; + cls.style = 0; + cls.lpfnWndProc = wndproc; + cls.cbClsExtra = 0; + cls.cbWndExtra = 0; + cls.hInstance = GetModuleHandleA(0); + cls.hIcon = 0; + cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW); + cls.hbrBackground = GetStockObject(WHITE_BRUSH); + cls.lpszMenuName = NULL; + cls.lpszClassName = lpClassName; + return cls; +} + /* Keeps the window reponsive for the deley_time in seconds. * This is useful for debugging a test to see what is happening. */ static void keep_responsive(time_t delay_time) @@ -318,12 +334,12 @@ static void check_EM_FINDTEXTEX(HWND hwnd, const char *name, struct find_s *f, "EM_FINDTEXTEX(%s,%d) '%s' in range(%d,%d), flags %08x, start at %d\n", name, id, f->needle, f->start, f->end, f->flags, findloc); ok(ftw.chrgText.cpMin == f->expected_loc, - "EM_FINDTEXTEX(%s,%d) '%s' in range(%d,%d), flags %08x, start at %d\n", + "EM_FINDTEXTEX(%s,%d) '%s' in range(%d,%d), flags %08x, start at %ld\n", name, id, f->needle, f->start, f->end, f->flags, ftw.chrgText.cpMin); expected_end_loc = ((f->expected_loc == -1) ? -1 : f->expected_loc + strlen(f->needle)); ok(ftw.chrgText.cpMax == expected_end_loc, - "EM_FINDTEXTEX(%s,%d) '%s' in range(%d,%d), flags %08x, end at %d, expected %d\n", + "EM_FINDTEXTEX(%s,%d) '%s' in range(%d,%d), flags %08x, end at %ld, expected %d\n", name, id, f->needle, f->start, f->end, f->flags, ftw.chrgText.cpMax, expected_end_loc); HeapFree(GetProcessHeap(), 0, (void*)ftw.lpstrText); }else{ @@ -337,12 +353,12 @@ static void check_EM_FINDTEXTEX(HWND hwnd, const char *name, struct find_s *f, "EM_FINDTEXTEX(%s,%d) '%s' in range(%d,%d), flags %08x, start at %d\n", name, id, f->needle, f->start, f->end, f->flags, findloc); ok(fta.chrgText.cpMin == f->expected_loc, - "EM_FINDTEXTEX(%s,%d) '%s' in range(%d,%d), flags %08x, start at %d\n", + "EM_FINDTEXTEX(%s,%d) '%s' in range(%d,%d), flags %08x, start at %ld\n", name, id, f->needle, f->start, f->end, f->flags, fta.chrgText.cpMin); expected_end_loc = ((f->expected_loc == -1) ? -1 : f->expected_loc + strlen(f->needle)); ok(fta.chrgText.cpMax == expected_end_loc, - "EM_FINDTEXTEX(%s,%d) '%s' in range(%d,%d), flags %08x, end at %d, expected %d\n", + "EM_FINDTEXTEX(%s,%d) '%s' in range(%d,%d), flags %08x, end at %ld, expected %d\n", name, id, f->needle, f->start, f->end, f->flags, fta.chrgText.cpMax, expected_end_loc); } } @@ -515,7 +531,7 @@ static void test_EM_LINELENGTH(void) for (i = 0; i < 10; i++) { result = SendMessageA(hwndRichEdit, EM_LINELENGTH, offset_test[i][0], 0); - ok(result == offset_test[i][1], "Length of line at offset %d is %ld, expected %d\n", + ok(result == offset_test[i][1], "Length of line at offset %d is %Id, expected %d\n", offset_test[i][0], result, offset_test[i][1]); } @@ -536,7 +552,7 @@ static void test_EM_LINELENGTH(void) SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text1); for (i = 0; i < ARRAY_SIZE(offset_test1); i++) { result = SendMessageA(hwndRichEdit, EM_LINELENGTH, offset_test1[i][0], 0); - ok(result == offset_test1[i][1], "Length of line at offset %d is %ld, expected %d\n", + ok(result == offset_test1[i][1], "Length of line at offset %d is %Id, expected %d\n", offset_test1[i][0], result, offset_test1[i][1]); } } @@ -548,7 +564,7 @@ static int get_scroll_pos_y(HWND hwnd) { POINT p = {-1, -1}; SendMessageA(hwnd, EM_GETSCROLLPOS, 0, (LPARAM)&p); - ok(p.x != -1 && p.y != -1, "p.x:%d p.y:%d\n", p.x, p.y); + ok(p.x != -1 && p.y != -1, "p.x:%ld p.y:%ld\n", p.x, p.y); return p.y; } @@ -747,30 +763,30 @@ static void test_EM_POSFROMCHAR(void) SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"12345678901234"); SendMessageA(hwndRichEdit, EM_POSFROMCHAR, (WPARAM)&pt, SendMessageA(hwndRichEdit, WM_GETTEXTLENGTH, 0, 0)-1); - ok(pt.x > 1, "pt.x = %d\n", pt.x); + ok(pt.x > 1, "pt.x = %ld\n", pt.x); xpos = pt.x; SendMessageA(hwndRichEdit, EM_POSFROMCHAR, (WPARAM)&pt, SendMessageA(hwndRichEdit, WM_GETTEXTLENGTH, 0, 0)); - ok(pt.x > xpos, "pt.x = %d\n", pt.x); + ok(pt.x > xpos, "pt.x = %ld\n", pt.x); xpos = (rtl ? pt.x + 7 : pt.x); SendMessageA(hwndRichEdit, EM_POSFROMCHAR, (WPARAM)&pt, SendMessageA(hwndRichEdit, WM_GETTEXTLENGTH, 0, 0)+1); - ok(pt.x == xpos, "pt.x = %d\n", pt.x); + ok(pt.x == xpos, "pt.x = %ld\n", pt.x); /* Try a negative position. */ SendMessageA(hwndRichEdit, EM_POSFROMCHAR, (WPARAM)&pt, -1); - ok(pt.x == 1, "pt.x = %d\n", pt.x); + ok(pt.x == 1, "pt.x = %ld\n", pt.x); /* test negative indentation */ SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"{\\rtf1\\pard\\fi-200\\li-200\\f1 TestSomeText\\par}"); SendMessageA(hwndRichEdit, EM_POSFROMCHAR, (WPARAM)&pt, 0); - ok(pt.x == 1, "pt.x = %d\n", pt.x); + ok(pt.x == 1, "pt.x = %ld\n", pt.x); fmt.cbSize = sizeof(fmt); SendMessageA(hwndRichEdit, EM_GETPARAFORMAT, 0, (LPARAM)&fmt); - ok(fmt.dxStartIndent == -400, "got %d\n", fmt.dxStartIndent); - ok(fmt.dxOffset == 200, "got %d\n", fmt.dxOffset); + ok(fmt.dxStartIndent == -400, "got %ld\n", fmt.dxStartIndent); + ok(fmt.dxOffset == 200, "got %ld\n", fmt.dxOffset); ok(fmt.wAlignment == PFA_LEFT, "got %d\n", fmt.wAlignment); DestroyWindow(hwndRichEdit); @@ -809,13 +825,13 @@ static void test_EM_SETCHARFORMAT(void) memset(&cf2, 0, sizeof(CHARFORMAT2A)); cf2.cbSize = sizeof(CHARFORMAT2A); SendMessageA(hwndRichEdit, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2); - ok(cf2.dwMask == CFM_ALL2, "got %08x\n", cf2.dwMask); + ok(cf2.dwMask == CFM_ALL2, "got %08lx\n", cf2.dwMask); expect_effects = CFE_AUTOCOLOR | CFE_AUTOBACKCOLOR; if (cf2.wWeight > 550) expect_effects |= CFE_BOLD; - ok(cf2.dwEffects == expect_effects, "got %08x\n", cf2.dwEffects); - ok(cf2.yOffset == 0, "got %d\n", cf2.yOffset); + ok(cf2.dwEffects == expect_effects, "got %08lx\n", cf2.dwEffects); + ok(cf2.yOffset == 0, "got %ld\n", cf2.yOffset); ok(cf2.sSpacing == 0, "got %d\n", cf2.sSpacing); - ok(cf2.lcid == GetSystemDefaultLCID(), "got %x\n", cf2.lcid); + ok(cf2.lcid == GetSystemDefaultLCID(), "got %lx\n", cf2.lcid); ok(cf2.sStyle == 0, "got %d\n", cf2.sStyle); ok(cf2.wKerning == 0, "got %d\n", cf2.wKerning); ok(cf2.bAnimation == 0, "got %d\n", cf2.bAnimation); @@ -970,9 +986,9 @@ static void test_EM_SETCHARFORMAT(void) (cf2.dwMask & CFM_SUPERSCRIPT) == CFM_SUPERSCRIPT) || (cf2.dwMask & tested_effects[i]) == tested_effects[i]), - "%d, cf2.dwMask == 0x%08x expected mask 0x%08x\n", i, cf2.dwMask, tested_effects[i]); + "%d, cf2.dwMask == 0x%08lx expected mask 0x%08x\n", i, cf2.dwMask, tested_effects[i]); ok((cf2.dwEffects & tested_effects[i]) == 0, - "%d, cf2.dwEffects == 0x%08x expected effect 0x%08x clear\n", i, cf2.dwEffects, tested_effects[i]); + "%d, cf2.dwEffects == 0x%08lx expected effect 0x%08x clear\n", i, cf2.dwEffects, tested_effects[i]); memset(&cf2, 0, sizeof(CHARFORMAT2A)); cf2.cbSize = sizeof(CHARFORMAT2A); @@ -991,9 +1007,9 @@ static void test_EM_SETCHARFORMAT(void) (cf2.dwMask & CFM_SUPERSCRIPT) == CFM_SUPERSCRIPT) || (cf2.dwMask & tested_effects[i]) == tested_effects[i]), - "%d, cf2.dwMask == 0x%08x expected mask 0x%08x\n", i, cf2.dwMask, tested_effects[i]); + "%d, cf2.dwMask == 0x%08lx expected mask 0x%08x\n", i, cf2.dwMask, tested_effects[i]); ok((cf2.dwEffects & tested_effects[i]) == tested_effects[i], - "%d, cf2.dwEffects == 0x%08x expected effect 0x%08x\n", i, cf2.dwEffects, tested_effects[i]); + "%d, cf2.dwEffects == 0x%08lx expected effect 0x%08x\n", i, cf2.dwEffects, tested_effects[i]); memset(&cf2, 0, sizeof(CHARFORMAT2A)); cf2.cbSize = sizeof(CHARFORMAT2A); @@ -1003,9 +1019,9 @@ static void test_EM_SETCHARFORMAT(void) (cf2.dwMask & CFM_SUPERSCRIPT) == CFM_SUPERSCRIPT) || (cf2.dwMask & tested_effects[i]) == tested_effects[i]), - "%d, cf2.dwMask == 0x%08x expected mask 0x%08x\n", i, cf2.dwMask, tested_effects[i]); + "%d, cf2.dwMask == 0x%08lx expected mask 0x%08x\n", i, cf2.dwMask, tested_effects[i]); ok((cf2.dwEffects & tested_effects[i]) == 0, - "%d, cf2.dwEffects == 0x%08x expected effect 0x%08x clear\n", i, cf2.dwEffects, tested_effects[i]); + "%d, cf2.dwEffects == 0x%08lx expected effect 0x%08x clear\n", i, cf2.dwEffects, tested_effects[i]); memset(&cf2, 0, sizeof(CHARFORMAT2A)); cf2.cbSize = sizeof(CHARFORMAT2A); @@ -1015,7 +1031,7 @@ static void test_EM_SETCHARFORMAT(void) (cf2.dwMask & CFM_SUPERSCRIPT) == 0) || (cf2.dwMask & tested_effects[i]) == 0), - "%d, cf2.dwMask == 0x%08x expected mask 0x%08x clear\n", i, cf2.dwMask, tested_effects[i]); + "%d, cf2.dwMask == 0x%08lx expected mask 0x%08x clear\n", i, cf2.dwMask, tested_effects[i]); DestroyWindow(hwndRichEdit); } @@ -1051,9 +1067,9 @@ static void test_EM_SETCHARFORMAT(void) (cf2.dwMask & CFM_SUPERSCRIPT) == CFM_SUPERSCRIPT) || (cf2.dwMask & tested_effects[i]) == tested_effects[i]), - "%d, cf2.dwMask == 0x%08x expected mask 0x%08x\n", i, cf2.dwMask, tested_effects[i]); + "%d, cf2.dwMask == 0x%08lx expected mask 0x%08x\n", i, cf2.dwMask, tested_effects[i]); ok((cf2.dwEffects & tested_effects[i]) == 0, - "%d, cf2.dwEffects == 0x%08x expected effect 0x%08x clear\n", i, cf2.dwEffects, tested_effects[i]); + "%d, cf2.dwEffects == 0x%08lx expected effect 0x%08x clear\n", i, cf2.dwEffects, tested_effects[i]); memset(&cf2, 0, sizeof(CHARFORMAT2A)); cf2.cbSize = sizeof(CHARFORMAT2A); @@ -1063,9 +1079,9 @@ static void test_EM_SETCHARFORMAT(void) (cf2.dwMask & CFM_SUPERSCRIPT) == CFM_SUPERSCRIPT) || (cf2.dwMask & tested_effects[i]) == tested_effects[i]), - "%d, cf2.dwMask == 0x%08x expected mask 0x%08x\n", i, cf2.dwMask, tested_effects[i]); + "%d, cf2.dwMask == 0x%08lx expected mask 0x%08x\n", i, cf2.dwMask, tested_effects[i]); ok((cf2.dwEffects & tested_effects[i]) == tested_effects[i], - "%d, cf2.dwEffects == 0x%08x expected effect 0x%08x\n", i, cf2.dwEffects, tested_effects[i]); + "%d, cf2.dwEffects == 0x%08lx expected effect 0x%08x\n", i, cf2.dwEffects, tested_effects[i]); memset(&cf2, 0, sizeof(CHARFORMAT2A)); cf2.cbSize = sizeof(CHARFORMAT2A); @@ -1075,9 +1091,9 @@ static void test_EM_SETCHARFORMAT(void) (cf2.dwMask & CFM_SUPERSCRIPT) == 0) || (cf2.dwMask & tested_effects[i]) == 0), - "%d, cf2.dwMask == 0x%08x expected mask 0x%08x clear\n", i, cf2.dwMask, tested_effects[i]); + "%d, cf2.dwMask == 0x%08lx expected mask 0x%08x clear\n", i, cf2.dwMask, tested_effects[i]); ok((cf2.dwEffects & tested_effects[i]) == tested_effects[i], - "%d, cf2.dwEffects == 0x%08x expected effect 0x%08x set\n", i, cf2.dwEffects, tested_effects[i]); + "%d, cf2.dwEffects == 0x%08lx expected effect 0x%08x set\n", i, cf2.dwEffects, tested_effects[i]); DestroyWindow(hwndRichEdit); } @@ -1103,9 +1119,9 @@ static void test_EM_SETCHARFORMAT(void) SendMessageA(hwndRichEdit, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2); ok (((cf2.dwMask & CFM_BOLD) == CFM_BOLD), - "%d, cf2.dwMask == 0x%08x expected mask 0x%08x\n", i, cf2.dwMask, CFM_BOLD); + "%d, cf2.dwMask == 0x%08lx expected mask 0x%08x\n", i, cf2.dwMask, CFM_BOLD); ok((cf2.dwEffects & CFE_BOLD) == CFE_BOLD, - "%d, cf2.dwEffects == 0x%08x expected effect 0x%08x\n", i, cf2.dwEffects, CFE_BOLD); + "%d, cf2.dwEffects == 0x%08lx expected effect 0x%08x\n", i, cf2.dwEffects, CFE_BOLD); /* Set two effects on an empty selection */ @@ -1138,9 +1154,9 @@ static void test_EM_SETCHARFORMAT(void) SendMessageA(hwndRichEdit, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2); ok (((cf2.dwMask & (CFM_BOLD|CFM_ITALIC)) == (CFM_BOLD|CFM_ITALIC)), - "%d, cf2.dwMask == 0x%08x expected mask 0x%08x\n", i, cf2.dwMask, (CFM_BOLD|CFM_ITALIC)); + "%d, cf2.dwMask == 0x%08lx expected mask 0x%08x\n", i, cf2.dwMask, (CFM_BOLD|CFM_ITALIC)); ok((cf2.dwEffects & (CFE_BOLD|CFE_ITALIC)) == (CFE_BOLD|CFE_ITALIC), - "%d, cf2.dwEffects == 0x%08x expected effect 0x%08x\n", i, cf2.dwEffects, (CFE_BOLD|CFE_ITALIC)); + "%d, cf2.dwEffects == 0x%08lx expected effect 0x%08x\n", i, cf2.dwEffects, (CFE_BOLD|CFE_ITALIC)); /* Setting the (empty) selection to exactly the same place as before should NOT clear the insertion style! */ @@ -1173,9 +1189,9 @@ static void test_EM_SETCHARFORMAT(void) SendMessageA(hwndRichEdit, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2); ok (((cf2.dwMask & CFM_BOLD) == CFM_BOLD), - "%d, cf2.dwMask == 0x%08x expected mask 0x%08x\n", i, cf2.dwMask, CFM_BOLD); + "%d, cf2.dwMask == 0x%08lx expected mask 0x%08x\n", i, cf2.dwMask, CFM_BOLD); ok((cf2.dwEffects & CFE_BOLD) == CFE_BOLD, - "%d, cf2.dwEffects == 0x%08x expected effect 0x%08x\n", i, cf2.dwEffects, CFE_BOLD); + "%d, cf2.dwEffects == 0x%08lx expected effect 0x%08x\n", i, cf2.dwEffects, CFE_BOLD); /* Moving the selection will clear the insertion style */ SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"wine"); @@ -1208,9 +1224,9 @@ static void test_EM_SETCHARFORMAT(void) SendMessageA(hwndRichEdit, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2); ok(((cf2.dwMask & CFM_BOLD) == CFM_BOLD), - "%d, cf2.dwMask == 0x%08x expected mask 0x%08x\n", i, cf2.dwMask, CFM_BOLD); + "%d, cf2.dwMask == 0x%08lx expected mask 0x%08x\n", i, cf2.dwMask, CFM_BOLD); ok((cf2.dwEffects & CFE_BOLD) == 0, - "%d, cf2.dwEffects == 0x%08x not expecting effect 0x%08x\n", i, cf2.dwEffects, CFE_BOLD); + "%d, cf2.dwEffects == 0x%08lx not expecting effect 0x%08x\n", i, cf2.dwEffects, CFE_BOLD); /* Ditto with EM_EXSETSEL */ SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"wine"); @@ -1245,9 +1261,9 @@ static void test_EM_SETCHARFORMAT(void) SendMessageA(hwndRichEdit, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2); ok (((cf2.dwMask & CFM_BOLD) == CFM_BOLD), - "%d, cf2.dwMask == 0x%08x expected mask 0x%08x\n", i, cf2.dwMask, CFM_BOLD); + "%d, cf2.dwMask == 0x%08lx expected mask 0x%08x\n", i, cf2.dwMask, CFM_BOLD); ok((cf2.dwEffects & CFE_BOLD) == CFE_BOLD, - "%d, cf2.dwEffects == 0x%08x expected effect 0x%08x\n", i, cf2.dwEffects, CFE_BOLD); + "%d, cf2.dwEffects == 0x%08lx expected effect 0x%08x\n", i, cf2.dwEffects, CFE_BOLD); /* show that wWeight is at the correct offset in CHARFORMAT2A */ memset(&cf2, 0, sizeof(cf2)); @@ -1305,8 +1321,8 @@ static void test_EM_SETCHARFORMAT(void) cf2.cbSize = sizeof(CHARFORMAT2A); SendMessageA(hwndRichEdit, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2); ok((cf2.dwMask & (CFM_UNDERLINE | CFM_UNDERLINETYPE)) == (CFM_UNDERLINE | CFM_UNDERLINETYPE), - "got %08x\n", cf2.dwMask); - ok(!(cf2.dwEffects & CFE_UNDERLINE), "got %08x\n", cf2.dwEffects); + "got %08lx\n", cf2.dwMask); + ok(!(cf2.dwEffects & CFE_UNDERLINE), "got %08lx\n", cf2.dwEffects); ok(cf2.bUnderlineType == CFU_UNDERLINE, "got %x\n", cf2.bUnderlineType); /* simply touching bUnderlineType will toggle CFE_UNDERLINE */ @@ -1317,8 +1333,8 @@ static void test_EM_SETCHARFORMAT(void) cf2.cbSize = sizeof(CHARFORMAT2A); SendMessageA(hwndRichEdit, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2); ok((cf2.dwMask & (CFM_UNDERLINE | CFM_UNDERLINETYPE)) == (CFM_UNDERLINE | CFM_UNDERLINETYPE), - "got %08x\n", cf2.dwMask); - ok(cf2.dwEffects & CFE_UNDERLINE, "got %08x\n", cf2.dwEffects); + "got %08lx\n", cf2.dwMask); + ok(cf2.dwEffects & CFE_UNDERLINE, "got %08lx\n", cf2.dwEffects); ok(cf2.bUnderlineType == CFU_UNDERLINE, "got %x\n", cf2.bUnderlineType); /* setting bUnderline to CFU_UNDERLINENONE clears CFE_UNDERLINE */ @@ -1329,8 +1345,8 @@ static void test_EM_SETCHARFORMAT(void) cf2.cbSize = sizeof(CHARFORMAT2A); SendMessageA(hwndRichEdit, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2); ok((cf2.dwMask & (CFM_UNDERLINE | CFM_UNDERLINETYPE)) == (CFM_UNDERLINE | CFM_UNDERLINETYPE), - "got %08x\n", cf2.dwMask); - ok(!(cf2.dwEffects & CFE_UNDERLINE), "got %08x\n", cf2.dwEffects); + "got %08lx\n", cf2.dwMask); + ok(!(cf2.dwEffects & CFE_UNDERLINE), "got %08lx\n", cf2.dwEffects); ok(cf2.bUnderlineType == CFU_UNDERLINENONE, "got %x\n", cf2.bUnderlineType); /* another underline type also sets CFE_UNDERLINE */ @@ -1341,8 +1357,8 @@ static void test_EM_SETCHARFORMAT(void) cf2.cbSize = sizeof(CHARFORMAT2A); SendMessageA(hwndRichEdit, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2); ok((cf2.dwMask & (CFM_UNDERLINE | CFM_UNDERLINETYPE)) == (CFM_UNDERLINE | CFM_UNDERLINETYPE), - "got %08x\n", cf2.dwMask); - ok(cf2.dwEffects & CFE_UNDERLINE, "got %08x\n", cf2.dwEffects); + "got %08lx\n", cf2.dwMask); + ok(cf2.dwEffects & CFE_UNDERLINE, "got %08lx\n", cf2.dwEffects); ok(cf2.bUnderlineType == CFU_UNDERLINEDOUBLE, "got %x\n", cf2.bUnderlineType); /* However explicitly clearing CFE_UNDERLINE results in it remaining cleared */ @@ -1354,8 +1370,8 @@ static void test_EM_SETCHARFORMAT(void) cf2.cbSize = sizeof(CHARFORMAT2A); SendMessageA(hwndRichEdit, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2); ok((cf2.dwMask & (CFM_UNDERLINE | CFM_UNDERLINETYPE)) == (CFM_UNDERLINE | CFM_UNDERLINETYPE), - "got %08x\n", cf2.dwMask); - ok(!(cf2.dwEffects & CFE_UNDERLINE), "got %08x\n", cf2.dwEffects); + "got %08lx\n", cf2.dwMask); + ok(!(cf2.dwEffects & CFE_UNDERLINE), "got %08lx\n", cf2.dwEffects); ok(cf2.bUnderlineType == CFU_UNDERLINEDOUBLE, "got %x\n", cf2.bUnderlineType); /* And turing it back on again by just setting CFE_UNDERLINE */ @@ -1366,8 +1382,8 @@ static void test_EM_SETCHARFORMAT(void) cf2.cbSize = sizeof(CHARFORMAT2A); SendMessageA(hwndRichEdit, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2); ok((cf2.dwMask & (CFM_UNDERLINE | CFM_UNDERLINETYPE)) == (CFM_UNDERLINE | CFM_UNDERLINETYPE), - "got %08x\n", cf2.dwMask); - ok(cf2.dwEffects & CFE_UNDERLINE, "got %08x\n", cf2.dwEffects); + "got %08lx\n", cf2.dwMask); + ok(cf2.dwEffects & CFE_UNDERLINE, "got %08lx\n", cf2.dwEffects); ok(cf2.bUnderlineType == CFU_UNDERLINEDOUBLE, "got %x\n", cf2.bUnderlineType); /* Check setting CFM_ALL2/CFM_EFFECTS2 in CHARFORMAT(A/W). */ @@ -1390,10 +1406,48 @@ static void test_EM_SETCHARFORMAT(void) DestroyWindow(hwndRichEdit); } +/* As the clipboard is a shared resource, it happens (on Windows) that the WM_PASTE + * is a no-op; likely because another app has opened the clipboard for inspection. + * In this case, WM_PASTE does nothing, and doesn't return an error code. + * So retry pasting a couple of times. + * Don't use this function if the paste operation shouldn't change the content of the + * editor (clipboard is empty without selection, edit control is read only...). + * Also impact on undo stack is not managed. + */ +#define send_paste(a) _send_paste(__LINE__, (a)) +static void _send_paste(unsigned int line, HWND wnd) +{ + int retries; + + SendMessageA(wnd, EM_SETMODIFY, FALSE, 0); + + for (retries = 0; retries < 7; retries++) + { + if (retries) Sleep(15); + SendMessageA(wnd, WM_PASTE, 0, 0); + if (SendMessageA(wnd, EM_GETMODIFY, 0, 0)) return; + } + ok_(__FILE__, line)(0, "Failed to paste clipboard content\n"); + { + char classname[256]; + HWND clipwnd = GetOpenClipboardWindow(); + /* Provide a hint as to the source of interference: + * - The class name would typically be CLIPBRDWNDCLASS if the + * clipboard was opened by a Windows application using the + * ole32 API. + * - And it would be __wine_clipboard_manager if it was opened in + * response to a native application. + */ + GetClassNameA(clipwnd, classname, ARRAY_SIZE(classname)); + trace("%p (%s) opened the clipboard\n", clipwnd, classname); + } +} + static void test_EM_SETTEXTMODE(void) { HWND hwndRichEdit = new_richedit(NULL); CHARFORMAT2A cf2, cf2test; + unsigned int len; CHARRANGE cr; int rc = 0; @@ -1463,7 +1517,10 @@ static void test_EM_SETTEXTMODE(void) SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"wine"); /*Paste the italicized "wine" into the control*/ - SendMessageA(hwndRichEdit, WM_PASTE, 0, 0); + send_paste(hwndRichEdit); + + len = SendMessageA(hwndRichEdit, WM_GETTEXTLENGTH, 0, 0); + ok(len == 8 /*winewine*/, "Unexpected text length %u\n", len); /*Select a character from the first "wine" string*/ cr.cpMin = 2; @@ -1484,7 +1541,7 @@ static void test_EM_SETTEXTMODE(void) /*Compare the two formattings*/ ok((cf2.dwMask == cf2test.dwMask) && (cf2.dwEffects == cf2test.dwEffects), - "two formats found in plain text mode - cf2.dwEffects: %x cf2test.dwEffects: %x\n", + "two formats found in plain text mode - cf2.dwEffects: %lx cf2test.dwEffects: %lx\n", cf2.dwEffects, cf2test.dwEffects); /*Test TM_RICHTEXT by: switching back to Rich Text mode printing "wine" in the current format(normal) @@ -1506,7 +1563,7 @@ static void test_EM_SETTEXTMODE(void) SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"wine"); /*Paste italicized "wine" into the control*/ - SendMessageA(hwndRichEdit, WM_PASTE, 0, 0); + send_paste(hwndRichEdit); /*Select text from the first "wine" string*/ cr.cpMin = 1; @@ -1526,7 +1583,7 @@ static void test_EM_SETTEXTMODE(void) /*Test that the two formattings are not the same*/ todo_wine ok((cf2.dwMask == cf2test.dwMask) && (cf2.dwEffects != cf2test.dwEffects), - "expected different formats - cf2.dwMask: %x, cf2test.dwMask: %x, cf2.dwEffects: %x, cf2test.dwEffects: %x\n", + "expected different formats - cf2.dwMask: %lx, cf2test.dwMask: %lx, cf2.dwEffects: %lx, cf2test.dwEffects: %lx\n", cf2.dwMask, cf2test.dwMask, cf2.dwEffects, cf2test.dwEffects); DestroyWindow(hwndRichEdit); @@ -1543,7 +1600,7 @@ static void test_SETPARAFORMAT(void) fmt.wAlignment = PFA_LEFT; ret = SendMessageA(hwndRichEdit, EM_SETPARAFORMAT, 0, (LPARAM)&fmt); - ok(ret != 0, "expected non-zero got %d\n", ret); + ok(ret != 0, "expected non-zero got %ld\n", ret); fmt.cbSize = sizeof(PARAFORMAT2); fmt.dwMask = -1; @@ -1554,8 +1611,8 @@ static void test_SETPARAFORMAT(void) ret &= ~PFM_TABLEROWDELIMITER; fmt.dwMask &= ~PFM_TABLEROWDELIMITER; - ok(ret == expectedMask, "expected %x got %x\n", expectedMask, ret); - ok(fmt.dwMask == expectedMask, "expected %x got %x\n", expectedMask, fmt.dwMask); + ok(ret == expectedMask, "expected %lx got %lx\n", expectedMask, ret); + ok(fmt.dwMask == expectedMask, "expected %lx got %lx\n", expectedMask, fmt.dwMask); /* Test some other paraformat field defaults */ ok( fmt.wNumbering == 0, "got %d\n", fmt.wNumbering ); @@ -1618,7 +1675,7 @@ static void test_TM_PLAINTEXT(void) /*Test that they are the same as plain text allows only one formatting*/ ok((cf2.dwMask == cf2test.dwMask) && (cf2.dwEffects == cf2test.dwEffects), - "two selections' formats differ - cf2.dwMask: %x, cf2test.dwMask %x, cf2.dwEffects: %x, cf2test.dwEffects: %x\n", + "two selections' formats differ - cf2.dwMask: %lx, cf2test.dwMask %lx, cf2.dwEffects: %lx, cf2test.dwEffects: %lx\n", cf2.dwMask, cf2test.dwMask, cf2.dwEffects, cf2test.dwEffects); /*Fill the control with a "wine" string, which when inserted will be bold*/ @@ -1652,7 +1709,7 @@ static void test_TM_PLAINTEXT(void) /*Paste the plain text "wine" string, which should take the insert formatting, which at the moment is bold italics*/ - SendMessageA(hwndRichEdit, WM_PASTE, 0, 0); + send_paste(hwndRichEdit); /*Select the first "wine" string and retrieve its formatting*/ @@ -1671,7 +1728,7 @@ static void test_TM_PLAINTEXT(void) /*Compare the two formattings. They should be the same.*/ ok((cf2.dwMask == cf2test.dwMask) && (cf2.dwEffects == cf2test.dwEffects), - "Copied text retained formatting - cf2.dwMask: %x, cf2test.dwMask: %x, cf2.dwEffects: %x, cf2test.dwEffects: %x\n", + "Copied text retained formatting - cf2.dwMask: %lx, cf2test.dwMask: %lx, cf2.dwEffects: %lx, cf2test.dwEffects: %lx\n", cf2.dwMask, cf2test.dwMask, cf2.dwEffects, cf2test.dwEffects); DestroyWindow(hwndRichEdit); } @@ -1759,7 +1816,7 @@ static void test_EM_GETTEXTRANGE(void) textRange.chrg.cpMin = 4; textRange.chrg.cpMax = 11; result = SendMessageA(hwndRichEdit, EM_GETTEXTRANGE, 0, (LPARAM)&textRange); - ok(result == 7, "EM_GETTEXTRANGE returned %ld\n", result); + ok(result == 7, "EM_GETTEXTRANGE returned %Id\n", result); ok(!strcmp(expect, buffer), "EM_GETTEXTRANGE filled %s\n", buffer); SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text2); @@ -1768,7 +1825,7 @@ static void test_EM_GETTEXTRANGE(void) textRange.chrg.cpMin = 4; textRange.chrg.cpMax = 11; result = SendMessageA(hwndRichEdit, EM_GETTEXTRANGE, 0, (LPARAM)&textRange); - ok(result == 7, "EM_GETTEXTRANGE returned %ld\n", result); + ok(result == 7, "EM_GETTEXTRANGE returned %Id\n", result); ok(!strcmp(expect, buffer), "EM_GETTEXTRANGE filled %s\n", buffer); /* cpMax of text length is used instead of -1 in this case */ @@ -1776,7 +1833,7 @@ static void test_EM_GETTEXTRANGE(void) textRange.chrg.cpMin = 0; textRange.chrg.cpMax = -1; result = SendMessageA(hwndRichEdit, EM_GETTEXTRANGE, 0, (LPARAM)&textRange); - ok(result == strlen(text2), "EM_GETTEXTRANGE returned %ld\n", result); + ok(result == strlen(text2), "EM_GETTEXTRANGE returned %Id\n", result); ok(!strcmp(text2, buffer), "EM_GETTEXTRANGE filled %s\n", buffer); /* cpMin < 0 causes no text to be copied, and 0 to be returned */ @@ -1784,7 +1841,7 @@ static void test_EM_GETTEXTRANGE(void) textRange.chrg.cpMin = -1; textRange.chrg.cpMax = 1; result = SendMessageA(hwndRichEdit, EM_GETTEXTRANGE, 0, (LPARAM)&textRange); - ok(result == 0, "EM_GETTEXTRANGE returned %ld\n", result); + ok(result == 0, "EM_GETTEXTRANGE returned %Id\n", result); ok(!strcmp(text2, buffer), "EM_GETTEXTRANGE filled %s\n", buffer); /* cpMax of -1 is not replaced with text length if cpMin != 0 */ @@ -1792,7 +1849,7 @@ static void test_EM_GETTEXTRANGE(void) textRange.chrg.cpMin = 1; textRange.chrg.cpMax = -1; result = SendMessageA(hwndRichEdit, EM_GETTEXTRANGE, 0, (LPARAM)&textRange); - ok(result == 0, "EM_GETTEXTRANGE returned %ld\n", result); + ok(result == 0, "EM_GETTEXTRANGE returned %Id\n", result); ok(!strcmp(text2, buffer), "EM_GETTEXTRANGE filled %s\n", buffer); /* no end character is copied if cpMax - cpMin < 0 */ @@ -1800,7 +1857,7 @@ static void test_EM_GETTEXTRANGE(void) textRange.chrg.cpMin = 5; textRange.chrg.cpMax = 5; result = SendMessageA(hwndRichEdit, EM_GETTEXTRANGE, 0, (LPARAM)&textRange); - ok(result == 0, "EM_GETTEXTRANGE returned %ld\n", result); + ok(result == 0, "EM_GETTEXTRANGE returned %Id\n", result); ok(!strcmp(text2, buffer), "EM_GETTEXTRANGE filled %s\n", buffer); /* cpMax of text length is used if cpMax > text length*/ @@ -1808,7 +1865,7 @@ static void test_EM_GETTEXTRANGE(void) textRange.chrg.cpMin = 0; textRange.chrg.cpMax = 1000; result = SendMessageA(hwndRichEdit, EM_GETTEXTRANGE, 0, (LPARAM)&textRange); - ok(result == strlen(text2), "EM_GETTEXTRANGE returned %ld\n", result); + ok(result == strlen(text2), "EM_GETTEXTRANGE returned %Id\n", result); ok(!strcmp(text2, buffer), "EM_GETTEXTRANGE filled %s\n", buffer); /* Test with multibyte character */ @@ -1820,7 +1877,7 @@ static void test_EM_GETTEXTRANGE(void) textRange.chrg.cpMin = 4; textRange.chrg.cpMax = 8; result = SendMessageA(hwndRichEdit, EM_GETTEXTRANGE, 0, (LPARAM)&textRange); - ok(result == 5, "EM_GETTEXTRANGE returned %ld\n", result); + ok(result == 5, "EM_GETTEXTRANGE returned %Id\n", result); ok(!strcmp("ef\x8e\xf0g", buffer), "EM_GETTEXTRANGE filled %s\n", buffer); } @@ -1835,20 +1892,41 @@ static void test_EM_GETSELTEXT(void) const char * expect = "bar\rfoo"; char buffer[1024] = {0}; LRESULT result; + BOOL bad_getsel; + DWORD gle; + + SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"a"); + SendMessageA(hwndRichEdit, EM_SETSEL, 0, -1); + SetLastError(0xdeadbeef); + result = SendMessageA(hwndRichEdit, EM_GETSELTEXT, 0, (LPARAM)buffer); + gle = GetLastError(); + ok((result > 0 && gle == 0xdeadbeef) || + broken(result == 0 && gle == ERROR_INVALID_PARAMETER /* Hindi */), + "EM_GETSELTEXT returned %Id gle=%lu\n", result, gle); + bad_getsel = (gle != 0xdeadbeef); + if (bad_getsel) + trace("EM_GETSELTEXT is broken, some tests will be ignored\n"); SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text1); SendMessageA(hwndRichEdit, EM_SETSEL, 4, 11); + SetLastError(0xdeadbeef); result = SendMessageA(hwndRichEdit, EM_GETSELTEXT, 0, (LPARAM)buffer); - ok(result == 7, "EM_GETSELTEXT returned %ld\n", result); - ok(!strcmp(expect, buffer), "EM_GETSELTEXT filled %s\n", buffer); + gle = GetLastError(); + ok(result == 7 || broken(bad_getsel && result == 0), + "EM_GETSELTEXT returned %Id gle=%lu\n", result, gle); + ok(!strcmp(expect, buffer) || broken(bad_getsel && !*buffer), + "EM_GETSELTEXT filled %s gle=%lu\n", buffer, gle); SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text2); SendMessageA(hwndRichEdit, EM_SETSEL, 4, 11); + SetLastError(0xdeadbeef); result = SendMessageA(hwndRichEdit, EM_GETSELTEXT, 0, (LPARAM)buffer); - ok(result == 7, "EM_GETSELTEXT returned %ld\n", result); - ok(!strcmp(expect, buffer), "EM_GETSELTEXT filled %s\n", buffer); + ok(result == 7 || broken(bad_getsel && result == 0), + "EM_GETSELTEXT returned %Id gle=%lu\n", result, gle); + ok(!strcmp(expect, buffer) || broken(bad_getsel && !*buffer), + "EM_GETSELTEXT filled %s gle=%lu\n", buffer, gle); /* Test with multibyte character */ if (!is_lang_japanese) @@ -1858,7 +1936,7 @@ static void test_EM_GETSELTEXT(void) SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"abcdef\x8e\xf0ghijk"); SendMessageA(hwndRichEdit, EM_SETSEL, 4, 8); result = SendMessageA(hwndRichEdit, EM_GETSELTEXT, 0, (LPARAM)buffer); - ok(result == 5, "EM_GETSELTEXT returned %ld\n", result); + ok(result == 5, "EM_GETSELTEXT returned %Id\n", result); ok(!strcmp("ef\x8e\xf0g", buffer), "EM_GETSELTEXT filled %s\n", buffer); } @@ -1883,7 +1961,7 @@ static void test_EM_SETOPTIONS(void) ok(hwndRichEdit != NULL, "class: %s, error: %d\n", RICHEDIT_CLASS20A, (int) GetLastError()); options = SendMessageA(hwndRichEdit, EM_GETOPTIONS, 0, 0); - ok(options == 0, "Incorrect initial options %x\n", options); + ok(options == 0, "Incorrect initial options %lx\n", options); DestroyWindow(hwndRichEdit); hwndRichEdit = CreateWindowA(RICHEDIT_CLASS20A, NULL, @@ -1896,7 +1974,7 @@ static void test_EM_SETOPTIONS(void) options = SendMessageA(hwndRichEdit, EM_GETOPTIONS, 0, 0); /* WS_[VH]SCROLL cause the ECO_AUTO[VH]SCROLL options to be set */ ok(options == (ECO_AUTOVSCROLL|ECO_AUTOHSCROLL), - "Incorrect initial options %x\n", options); + "Incorrect initial options %lx\n", options); /* NEGATIVE TESTING - NO OPTIONS SET */ SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text); @@ -1934,7 +2012,7 @@ static void test_EM_SETOPTIONS(void) SetWindowLongA(hwndRichEdit, GWL_STYLE, dwStyle|optionStyles); options = SendMessageA(hwndRichEdit, EM_GETOPTIONS, 0, 0); ok(options == oldOptions, - "Options set by SetWindowLong (%x -> %x)\n", oldOptions, options); + "Options set by SetWindowLong (%lx -> %lx)\n", oldOptions, options); DestroyWindow(hwndRichEdit); } @@ -3745,14 +3823,14 @@ static void test_WM_SETTEXT(void) #define TEST_SETTEXT(a, b) \ result = SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)a); \ - ok (result == 1, "WM_SETTEXT returned %ld instead of 1\n", result); \ + ok (result == 1, "WM_SETTEXT returned %Id instead of 1\n", result); \ result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buf); \ ok (result == lstrlenA(buf), \ - "WM_GETTEXT returned %ld instead of expected %u\n", \ + "WM_GETTEXT returned %Id instead of expected %u\n", \ result, lstrlenA(buf)); \ result = strcmp(b, buf); \ ok(result == 0, \ - "WM_SETTEXT round trip: strcmp = %ld, text=\"%s\"\n", result, buf); + "WM_SETTEXT round trip: strcmp = %Id, text=\"%s\"\n", result, buf); TEST_SETTEXT(TestItem1, TestItem1) TEST_SETTEXT(TestItem2, TestItem2_after) @@ -3773,13 +3851,13 @@ static void test_WM_SETTEXT(void) #define TEST_SETTEXTW(a, b) \ result = SendMessageW(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)a); \ - ok (result == 1, "WM_SETTEXT returned %ld instead of 1\n", result); \ + ok (result == 1, "WM_SETTEXT returned %Id instead of 1\n", result); \ result = SendMessageW(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)bufW); \ ok (result == lstrlenW(bufW), \ - "WM_GETTEXT returned %ld instead of expected %u\n", \ + "WM_GETTEXT returned %Id instead of expected %u\n", \ result, lstrlenW(bufW)); \ result = lstrcmpW(b, bufW); \ - ok(result == 0, "WM_SETTEXT round trip: strcmp = %ld\n", result); + ok(result == 0, "WM_SETTEXT round trip: strcmp = %Id\n", result); hwndRichEdit = CreateWindowW(RICHEDIT_CLASS20W, NULL, ES_MULTILINE|WS_POPUP|WS_HSCROLL|WS_VSCROLL|WS_VISIBLE, @@ -3795,14 +3873,14 @@ static void test_WM_SETTEXT(void) /* Single-line richedit */ hwndRichEdit = new_richedit_with_style(NULL, 0); result = SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"line1\r\nline2"); - ok(result == 1, "WM_SETTEXT returned %ld, expected 12\n", result); + ok(result == 1, "WM_SETTEXT returned %Id, expected 12\n", result); result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buf); - ok(result == 5, "WM_GETTEXT returned %ld, expected 5\n", result); + ok(result == 5, "WM_GETTEXT returned %Id, expected 5\n", result); ok(!strcmp(buf, "line1"), "WM_GETTEXT returned incorrect string '%s'\n", buf); result = SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"{\\rtf1 ABC\\rtlpar\\par DEF\\par HIJ\\pard\\par}"); - ok(result == 1, "WM_SETTEXT returned %ld, expected 1\n", result); + ok(result == 1, "WM_SETTEXT returned %Id, expected 1\n", result); result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buf); - ok(result == 3, "WM_GETTEXT returned %ld, expected 3\n", result); + ok(result == 3, "WM_GETTEXT returned %Id, expected 3\n", result); ok(!strcmp(buf, "ABC"), "WM_GETTEXT returned incorrect string '%s'\n", buf); DestroyWindow(hwndRichEdit); } @@ -3815,7 +3893,7 @@ static DWORD CALLBACK test_esCallback_written_1(DWORD_PTR dwCookie, LONG *pcb) { char** str = (char**)dwCookie; - ok(*pcb == cb || *pcb == 0, "cb %d, *pcb %d\n", cb, *pcb); + ok(*pcb == cb || *pcb == 0, "cb %ld, *pcb %ld\n", cb, *pcb); *pcb = 0; if (cb > 0) { memcpy(*str, pbBuff, cb); @@ -3862,23 +3940,23 @@ static void test_EM_STREAMOUT(void) ok(r == 12, "streamed text length is %d, expecting 12\n", r); ok(strcmp(buf, TestItem1) == 0, "streamed text different, got %s\n", buf); - ok(result == streamout_written, "got %ld expected %d\n", result, streamout_written); + ok(result == streamout_written, "got %Id expected %ld\n", result, streamout_written); /* RTF mode writes the final end of para \r if it's part of the selection */ p = buf; result = SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_RTF, (LPARAM)&es); ok (count_pars(buf) == 1, "got %s\n", buf); - ok(result == streamout_written, "got %ld expected %d\n", result, streamout_written); + ok(result == streamout_written, "got %Id expected %ld\n", result, streamout_written); p = buf; SendMessageA(hwndRichEdit, EM_SETSEL, 0, 12); result = SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_RTF|SFF_SELECTION, (LPARAM)&es); ok (count_pars(buf) == 0, "got %s\n", buf); - ok(result == streamout_written, "got %ld expected %d\n", result, streamout_written); + ok(result == streamout_written, "got %Id expected %ld\n", result, streamout_written); p = buf; SendMessageA(hwndRichEdit, EM_SETSEL, 0, -1); result = SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_RTF|SFF_SELECTION, (LPARAM)&es); ok (count_pars(buf) == 1, "got %s\n", buf); - ok(result == streamout_written, "got %ld expected %d\n", result, streamout_written); + ok(result == streamout_written, "got %Id expected %ld\n", result, streamout_written); SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)TestItem2); p = buf; @@ -3887,7 +3965,7 @@ static void test_EM_STREAMOUT(void) es.pfnCallback = test_WM_SETTEXT_esCallback; memset(buf, 0, sizeof(buf)); result = SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_TEXT, (LPARAM)&es); - ok(result == streamout_written, "got %ld expected %d\n", result, streamout_written); + ok(result == streamout_written, "got %Id expected %ld\n", result, streamout_written); r = strlen(buf); /* Here again, \r gets converted to \r\n, like WM_GETTEXT */ ok(r == 14, "streamed text length is %d, expecting 14\n", r); @@ -3898,17 +3976,17 @@ static void test_EM_STREAMOUT(void) p = buf; result = SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_RTF, (LPARAM)&es); ok (count_pars(buf) == 2, "got %s\n", buf); - ok(result == streamout_written, "got %ld expected %d\n", result, streamout_written); + ok(result == streamout_written, "got %Id expected %ld\n", result, streamout_written); p = buf; SendMessageA(hwndRichEdit, EM_SETSEL, 0, 13); result = SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_RTF|SFF_SELECTION, (LPARAM)&es); ok (count_pars(buf) == 1, "got %s\n", buf); - ok(result == streamout_written, "got %ld expected %d\n", result, streamout_written); + ok(result == streamout_written, "got %Id expected %ld\n", result, streamout_written); p = buf; SendMessageA(hwndRichEdit, EM_SETSEL, 0, -1); result = SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_RTF|SFF_SELECTION, (LPARAM)&es); ok (count_pars(buf) == 2, "got %s\n", buf); - ok(result == streamout_written, "got %ld expected %d\n", result, streamout_written); + ok(result == streamout_written, "got %Id expected %ld\n", result, streamout_written); SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)TestItem3); p = buf; @@ -3917,7 +3995,7 @@ static void test_EM_STREAMOUT(void) es.pfnCallback = test_WM_SETTEXT_esCallback; memset(buf, 0, sizeof(buf)); result = SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_TEXT, (LPARAM)&es); - ok(result == streamout_written, "got %ld expected %d\n", result, streamout_written); + ok(result == streamout_written, "got %Id expected %ld\n", result, streamout_written); r = strlen(buf); ok(r == 14, "streamed text length is %d, expecting 14\n", r); ok(strcmp(buf, TestItem3) == 0, @@ -3934,7 +4012,7 @@ static void test_EM_STREAMOUT(void) ok(r == 14, "streamed text length is %d, expecting 14\n", r); ok(strcmp(buf, TestItem3) == 0, "streamed text different, got %s\n", buf); - ok(result == 0, "got %ld expected 0\n", result); + ok(result == 0, "got %Id expected 0\n", result); DestroyWindow(hwndRichEdit); @@ -4071,16 +4149,7 @@ static void test_EM_SETTEXTEX(void) * For some reason the scroll position is 0 after EM_SETTEXTEX * with the ST_SELECTION flag only when the control has a parent * window, even though the selection is at the end. */ - cls.style = 0; - cls.lpfnWndProc = DefWindowProcA; - cls.cbClsExtra = 0; - cls.cbWndExtra = 0; - cls.hInstance = GetModuleHandleA(0); - cls.hIcon = 0; - cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW); - cls.hbrBackground = GetStockObject(WHITE_BRUSH); - cls.lpszMenuName = NULL; - cls.lpszClassName = "ParentTestClass"; + cls = make_simple_class(DefWindowProcA, "ParentTestClass"); if(!RegisterClassA(&cls)) assert(0); parent = CreateWindowA(cls.lpszClassName, NULL, WS_POPUP|WS_VISIBLE, @@ -4744,6 +4813,36 @@ static DWORD CALLBACK test_EM_GETMODIFY_esCallback(DWORD_PTR dwCookie, return 0; } +#define open_clipboard(hwnd) open_clipboard_(__LINE__, hwnd) +static BOOL open_clipboard_(int line, HWND hwnd) +{ + DWORD start = GetTickCount(); + while (1) + { + BOOL ret = OpenClipboard(hwnd); + if (ret || GetLastError() != ERROR_ACCESS_DENIED) + return ret; + if (GetTickCount() - start > 100) + { + char classname[256]; + DWORD le = GetLastError(); + HWND clipwnd = GetOpenClipboardWindow(); + /* Provide a hint as to the source of interference: + * - The class name would typically be CLIPBRDWNDCLASS if the + * clipboard was opened by a Windows application using the + * ole32 API. + * - And it would be __wine_clipboard_manager if it was opened in + * response to a native application. + */ + GetClassNameA(clipwnd, classname, ARRAY_SIZE(classname)); + trace_(__FILE__, line)("%p (%s) opened the clipboard\n", clipwnd, classname); + SetLastError(le); + return ret; + } + Sleep(15); + } +} + static void test_EM_GETMODIFY(void) { HWND hwndRichEdit = new_richedit(NULL); @@ -4760,6 +4859,8 @@ static void test_EM_GETMODIFY(void) CHARFORMAT2A cf2; PARAFORMAT2 pf2; EDITSTREAM es; + BOOL r; + HANDLE hclip; HFONT testFont = CreateFontA (0,0,0,0,FW_LIGHT, 0, 0, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | @@ -4841,7 +4942,7 @@ static void test_EM_GETMODIFY(void) SendMessageA(hwndRichEdit, EM_SETMODIFY, FALSE, 0); SendMessageA(hwndRichEdit, EM_SETSEL, 0, 2); SendMessageA(hwndRichEdit, WM_COPY, 0, 0); - SendMessageA(hwndRichEdit, WM_PASTE, 0, 0); + send_paste(hwndRichEdit); result = SendMessageA(hwndRichEdit, EM_GETMODIFY, 0, 0); ok (result != 0, "EM_GETMODIFY returned zero, instead of non-zero when pasting identical text\n"); @@ -4851,7 +4952,7 @@ static void test_EM_GETMODIFY(void) SendMessageA(hwndRichEdit, EM_SETSEL, 0, 2); SendMessageA(hwndRichEdit, WM_COPY, 0, 0); SendMessageA(hwndRichEdit, EM_SETSEL, 0, 3); - SendMessageA(hwndRichEdit, WM_PASTE, 0, 0); + send_paste(hwndRichEdit); result = SendMessageA(hwndRichEdit, EM_GETMODIFY, 0, 0); ok (result != 0, "EM_GETMODIFY returned zero, instead of non-zero when pasting different text\n"); @@ -4880,7 +4981,7 @@ static void test_EM_GETMODIFY(void) cf2.dwEffects = CFE_ITALIC ^ cf2.dwEffects; SendMessageA(hwndRichEdit, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf2); result = SendMessageA(hwndRichEdit, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf2); - ok(result == 1, "EM_SETCHARFORMAT returned %ld instead of 1\n", result); + ok(result == 1, "EM_SETCHARFORMAT returned %Id instead of 1\n", result); result = SendMessageA(hwndRichEdit, EM_GETMODIFY, 0, 0); ok (result != 0, "EM_GETMODIFY returned zero, instead of non-zero for EM_SETCHARFORMAT\n"); @@ -4906,7 +5007,28 @@ static void test_EM_GETMODIFY(void) ok (result != 0, "EM_GETMODIFY returned zero, instead of non-zero for EM_STREAM\n"); + /* Check that the clipboard data is still available after destroying the + * editor window. + */ + SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"Stayin' alive"); + SendMessageA(hwndRichEdit, EM_SETSEL, 8, -1); + SendMessageA(hwndRichEdit, WM_COPY, 0, 0); + DestroyWindow(hwndRichEdit); + + r = open_clipboard(NULL); + ok(r, "OpenClipboard failed le=%lu\n", GetLastError()); + + hclip = GetClipboardData(CF_TEXT); + todo_wine ok(hclip != NULL, "GetClipboardData() failed le=%lu\n", GetLastError()); + if (hclip) + { + const char* str = GlobalLock(hclip); + ok(strcmp(str, "alive") == 0, "unexpected clipboard content: %s\n", str); + GlobalUnlock(hclip); + } + + CloseClipboard(); } struct exsetsel_s { @@ -4956,7 +5078,7 @@ static void check_EM_EXSETSEL(HWND hwnd, const struct exsetsel_s *setsel, int id cr.cpMax = setsel->max; result = SendMessageA(hwnd, EM_EXSETSEL, 0, (LPARAM)&cr); - ok(result == setsel->expected_retval, "EM_EXSETSEL(%d): expected: %ld actual: %ld\n", id, setsel->expected_retval, result); + ok(result == setsel->expected_retval, "EM_EXSETSEL(%d): expected: %Id actual: %Id\n", id, setsel->expected_retval, result); SendMessageA(hwnd, EM_GETSEL, (WPARAM)&start, (LPARAM)&end); @@ -4993,12 +5115,12 @@ static void test_EM_EXSETSEL(void) /* 012345 6 78901 */ cr.cpMin = 4; cr.cpMax = 8; result = SendMessageA(hwndRichEdit, EM_EXSETSEL, 0, (LPARAM)&cr); - ok(result == 8, "EM_EXSETSEL return %ld expected 8\n", result); - result = SendMessageA(hwndRichEdit, EM_GETSELTEXT, sizeof(bufA), (LPARAM)bufA); + ok(result == 8, "EM_EXSETSEL return %Id expected 8\n", result); + result = SendMessageA(hwndRichEdit, EM_GETSELTEXT, 0, (LPARAM)bufA); ok(!strcmp(bufA, "ef\x8e\xf0g"), "EM_GETSELTEXT return incorrect string\n"); SendMessageA(hwndRichEdit, EM_EXGETSEL, 0, (LPARAM)&cr); - ok(cr.cpMin == 4, "Selection start incorrectly: %d expected 4\n", cr.cpMin); - ok(cr.cpMax == 8, "Selection end incorrectly: %d expected 8\n", cr.cpMax); + ok(cr.cpMin == 4, "Selection start incorrectly: %ld expected 4\n", cr.cpMin); + ok(cr.cpMax == 8, "Selection end incorrectly: %ld expected 8\n", cr.cpMax); } DestroyWindow(hwndRichEdit); @@ -5010,7 +5132,7 @@ static void check_EM_SETSEL(HWND hwnd, const struct exsetsel_s *setsel, int id) result = SendMessageA(hwnd, EM_SETSEL, setsel->min, setsel->max); - ok(result == setsel->expected_retval, "EM_SETSEL(%d): expected: %ld actual: %ld\n", id, setsel->expected_retval, result); + ok(result == setsel->expected_retval, "EM_SETSEL(%d): expected: %Id actual: %Id\n", id, setsel->expected_retval, result); SendMessageA(hwnd, EM_GETSEL, (WPARAM)&start, (LPARAM)&end); @@ -5019,6 +5141,23 @@ static void check_EM_SETSEL(HWND hwnd, const struct exsetsel_s *setsel, int id) id, setsel->expected_getsel_start, setsel->expected_getsel_end, start, end); } +/* When the selection is out of the windows view, the scrollbar should move. */ +static void check_EM_SETSEL_multiline(HWND hwnd) +{ + int oldY; + int curY; + const char textwithlines[] = "This is a text\n" + "with lines\n" + "I expect this text\n" + "to be\nlarge\nenough\n"; + + SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)textwithlines); + oldY = get_scroll_pos_y(hwnd); + SendMessageA(hwnd, EM_SETSEL, 59, 59); + curY = get_scroll_pos_y(hwnd); + ok(oldY < curY, "oldY %d >= curY %d\n", oldY, curY); +} + static void test_EM_SETSEL(void) { char buffA[32] = {0}; @@ -5051,14 +5190,16 @@ static void test_EM_SETSEL(void) SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"abcdef\x8e\xf0ghijk"); /* 012345 6 78901 */ result = SendMessageA(hwndRichEdit, EM_SETSEL, 4, 8); - ok(result == 8, "EM_SETSEL return %ld expected 8\n", result); - result = SendMessageA(hwndRichEdit, EM_GETSELTEXT, sizeof(buffA), (LPARAM)buffA); + ok(result == 8, "EM_SETSEL return %Id expected 8\n", result); + result = SendMessageA(hwndRichEdit, EM_GETSELTEXT, 0, (LPARAM)buffA); ok(!strcmp(buffA, "ef\x8e\xf0g"), "EM_GETSELTEXT return incorrect string\n"); result = SendMessageA(hwndRichEdit, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); ok(sel_start == 4, "Selection start incorrectly: %d expected 4\n", sel_start); ok(sel_end == 8, "Selection end incorrectly: %d expected 8\n", sel_end); } + check_EM_SETSEL_multiline(hwndRichEdit); + DestroyWindow(hwndRichEdit); } @@ -5141,8 +5282,8 @@ static void test_EM_REPLACESEL(int redraw) r = SendMessageA(hwndRichEdit, EM_EXGETSEL, 0, (LPARAM)&cr); ok(0 == r, "EM_EXGETSEL returned %d, expected 0\n", r); - ok(cr.cpMin == 10, "EM_EXGETSEL returned cpMin=%d, expected 10\n", cr.cpMin); - ok(cr.cpMax == 10, "EM_EXGETSEL returned cpMax=%d, expected 10\n", cr.cpMax); + ok(cr.cpMin == 10, "EM_EXGETSEL returned cpMin=%ld, expected 10\n", cr.cpMin); + ok(cr.cpMax == 10, "EM_EXGETSEL returned cpMax=%ld, expected 10\n", cr.cpMax); SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); r = strcmp(buffer, "RichEdit1\r\n"); @@ -5158,8 +5299,8 @@ static void test_EM_REPLACESEL(int redraw) r = SendMessageA(hwndRichEdit, EM_EXGETSEL, 0, (LPARAM)&cr); ok(0 == r, "EM_EXGETSEL returned %d, expected 0\n", r); - ok(cr.cpMin == 10, "EM_EXGETSEL returned cpMin=%d, expected 10\n", cr.cpMin); - ok(cr.cpMax == 10, "EM_EXGETSEL returned cpMax=%d, expected 10\n", cr.cpMax); + ok(cr.cpMin == 10, "EM_EXGETSEL returned cpMin=%ld, expected 10\n", cr.cpMin); + ok(cr.cpMax == 10, "EM_EXGETSEL returned cpMax=%ld, expected 10\n", cr.cpMax); /* The following tests show that richedit should handle the special \r\r\n sequence by turning it into a single space on insertion. However, @@ -5172,8 +5313,8 @@ static void test_EM_REPLACESEL(int redraw) ok(2 == r, "EM_REPLACESEL returned %d, expected 4\n", r); r = SendMessageA(hwndRichEdit, EM_EXGETSEL, 0, (LPARAM)&cr); ok(0 == r, "EM_EXGETSEL returned %d, expected 0\n", r); - ok(cr.cpMin == 2, "EM_EXGETSEL returned cpMin=%d, expected 2\n", cr.cpMin); - ok(cr.cpMax == 2, "EM_EXGETSEL returned cpMax=%d, expected 2\n", cr.cpMax); + ok(cr.cpMin == 2, "EM_EXGETSEL returned cpMin=%ld, expected 2\n", cr.cpMin); + ok(cr.cpMax == 2, "EM_EXGETSEL returned cpMax=%ld, expected 2\n", cr.cpMax); /* Test the actual string */ getText.cb = 1024; @@ -5194,8 +5335,8 @@ static void test_EM_REPLACESEL(int redraw) ok(r == 3, "EM_REPLACESEL returned %d, expected 3\n", r); r = SendMessageA(hwndRichEdit, EM_EXGETSEL, 0, (LPARAM)&cr); ok(0 == r, "EM_EXGETSEL returned %d, expected 0\n", r); - ok(cr.cpMin == 1, "EM_EXGETSEL returned cpMin=%d, expected 1\n", cr.cpMin); - ok(cr.cpMax == 1, "EM_EXGETSEL returned cpMax=%d, expected 1\n", cr.cpMax); + ok(cr.cpMin == 1, "EM_EXGETSEL returned cpMin=%ld, expected 1\n", cr.cpMin); + ok(cr.cpMax == 1, "EM_EXGETSEL returned cpMax=%ld, expected 1\n", cr.cpMax); /* Test the actual string */ getText.cb = 1024; @@ -5216,8 +5357,8 @@ static void test_EM_REPLACESEL(int redraw) ok(r == 9, "EM_REPLACESEL returned %d, expected 9\n", r); r = SendMessageA(hwndRichEdit, EM_EXGETSEL, 0, (LPARAM)&cr); ok(0 == r, "EM_EXGETSEL returned %d, expected 0\n", r); - ok(cr.cpMin == 7, "EM_EXGETSEL returned cpMin=%d, expected 7\n", cr.cpMin); - ok(cr.cpMax == 7, "EM_EXGETSEL returned cpMax=%d, expected 7\n", cr.cpMax); + ok(cr.cpMin == 7, "EM_EXGETSEL returned cpMin=%ld, expected 7\n", cr.cpMin); + ok(cr.cpMax == 7, "EM_EXGETSEL returned cpMax=%ld, expected 7\n", cr.cpMax); /* Test the actual string */ getText.cb = 1024; @@ -5238,8 +5379,8 @@ static void test_EM_REPLACESEL(int redraw) ok(r == 5, "EM_REPLACESEL returned %d, expected 5\n", r); r = SendMessageA(hwndRichEdit, EM_EXGETSEL, 0, (LPARAM)&cr); ok(0 == r, "EM_EXGETSEL returned %d, expected 0\n", r); - ok(cr.cpMin == 2, "EM_EXGETSEL returned cpMin=%d, expected 2\n", cr.cpMin); - ok(cr.cpMax == 2, "EM_EXGETSEL returned cpMax=%d, expected 2\n", cr.cpMax); + ok(cr.cpMin == 2, "EM_EXGETSEL returned cpMin=%ld, expected 2\n", cr.cpMin); + ok(cr.cpMax == 2, "EM_EXGETSEL returned cpMax=%ld, expected 2\n", cr.cpMax); /* Test the actual string */ getText.cb = 1024; @@ -5260,8 +5401,8 @@ static void test_EM_REPLACESEL(int redraw) ok(r == 5, "EM_REPLACESEL returned %d, expected 5\n", r); r = SendMessageA(hwndRichEdit, EM_EXGETSEL, 0, (LPARAM)&cr); ok(0 == r, "EM_EXGETSEL returned %d, expected 0\n", r); - ok(cr.cpMin == 3, "EM_EXGETSEL returned cpMin=%d, expected 3\n", cr.cpMin); - ok(cr.cpMax == 3, "EM_EXGETSEL returned cpMax=%d, expected 3\n", cr.cpMax); + ok(cr.cpMin == 3, "EM_EXGETSEL returned cpMin=%ld, expected 3\n", cr.cpMin); + ok(cr.cpMax == 3, "EM_EXGETSEL returned cpMax=%ld, expected 3\n", cr.cpMax); /* Test the actual string */ getText.cb = 1024; @@ -5282,8 +5423,8 @@ static void test_EM_REPLACESEL(int redraw) ok(r == 6, "EM_REPLACESEL returned %d, expected 6\n", r); r = SendMessageA(hwndRichEdit, EM_EXGETSEL, 0, (LPARAM)&cr); ok(0 == r, "EM_EXGETSEL returned %d, expected 0\n", r); - ok(cr.cpMin == 5, "EM_EXGETSEL returned cpMin=%d, expected 5\n", cr.cpMin); - ok(cr.cpMax == 5, "EM_EXGETSEL returned cpMax=%d, expected 5\n", cr.cpMax); + ok(cr.cpMin == 5, "EM_EXGETSEL returned cpMin=%ld, expected 5\n", cr.cpMin); + ok(cr.cpMax == 5, "EM_EXGETSEL returned cpMax=%ld, expected 5\n", cr.cpMax); /* Test the actual string */ getText.cb = 1024; @@ -5304,8 +5445,8 @@ static void test_EM_REPLACESEL(int redraw) ok(2 == r, "EM_REPLACESEL returned %d, expected 2\n", r); r = SendMessageA(hwndRichEdit, EM_EXGETSEL, 0, (LPARAM)&cr); ok(0 == r, "EM_EXGETSEL returned %d, expected 0\n", r); - ok(cr.cpMin == 2, "EM_EXGETSEL returned cpMin=%d, expected 2\n", cr.cpMin); - ok(cr.cpMax == 2, "EM_EXGETSEL returned cpMax=%d, expected 2\n", cr.cpMax); + ok(cr.cpMin == 2, "EM_EXGETSEL returned cpMin=%ld, expected 2\n", cr.cpMin); + ok(cr.cpMax == 2, "EM_EXGETSEL returned cpMax=%ld, expected 2\n", cr.cpMax); /* Test the actual string */ getText.cb = 1024; @@ -5326,8 +5467,8 @@ static void test_EM_REPLACESEL(int redraw) ok(r == 9, "EM_REPLACESEL returned %d, expected 9\n", r); r = SendMessageA(hwndRichEdit, EM_EXGETSEL, 0, (LPARAM)&cr); ok(0 == r, "EM_EXGETSEL returned %d, expected 0\n", r); - ok(cr.cpMin == 7, "EM_EXGETSEL returned cpMin=%d, expected 7\n", cr.cpMin); - ok(cr.cpMax == 7, "EM_EXGETSEL returned cpMax=%d, expected 7\n", cr.cpMax); + ok(cr.cpMin == 7, "EM_EXGETSEL returned cpMin=%ld, expected 7\n", cr.cpMin); + ok(cr.cpMax == 7, "EM_EXGETSEL returned cpMax=%ld, expected 7\n", cr.cpMax); /* Test the actual string */ getText.cb = 1024; @@ -5353,8 +5494,8 @@ static void test_EM_REPLACESEL(int redraw) todo_wine ok(r == 5, "EM_REPLACESEL returned %d, expected 5\n", r); r = SendMessageA(hwndRichEdit, EM_EXGETSEL, 0, (LPARAM)&cr); ok(r == 0, "EM_EXGETSEL returned %d, expected 0\n", r); - ok(cr.cpMin == 4, "EM_EXGETSEL returned cpMin=%d, expected 4\n", cr.cpMin); - ok(cr.cpMax == 4, "EM_EXGETSEL returned cpMax=%d, expected 4\n", cr.cpMax); + ok(cr.cpMin == 4, "EM_EXGETSEL returned cpMin=%ld, expected 4\n", cr.cpMin); + ok(cr.cpMax == 4, "EM_EXGETSEL returned cpMax=%ld, expected 4\n", cr.cpMax); r = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); ok(!strcmp(buffer, "abc\x8e\xf0"), "WM_GETTEXT returned incorrect string\n"); ok(r == 5, "WM_GETTEXT returned %d, expected 5\n", r); @@ -5364,8 +5505,8 @@ static void test_EM_REPLACESEL(int redraw) todo_wine ok(r == 4, "EM_REPLACESEL returned %d, expected 4\n", r); r = SendMessageA(hwndRichEdit, EM_EXGETSEL, 0, (LPARAM)&cr); ok(r == 0, "EM_EXGETSEL returned %d, expected 0\n", r); - todo_wine ok(cr.cpMin == 4, "EM_EXGETSEL returned cpMin=%d, expected 4\n", cr.cpMin); - todo_wine ok(cr.cpMax == 4, "EM_EXGETSEL returned cpMax=%d, expected 4\n", cr.cpMax); + todo_wine ok(cr.cpMin == 4, "EM_EXGETSEL returned cpMin=%ld, expected 4\n", cr.cpMin); + todo_wine ok(cr.cpMax == 4, "EM_EXGETSEL returned cpMax=%ld, expected 4\n", cr.cpMax); r = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); todo_wine ok(!strcmp(buffer, "abc\x8e\xf0"), "WM_GETTEXT returned incorrect string\n"); todo_wine ok(r == 5, "WM_GETTEXT returned %d, expected 5\n", r); @@ -5376,8 +5517,8 @@ static void test_EM_REPLACESEL(int redraw) todo_wine ok(r == 12, "EM_REPLACESEL returned %d, expected 12\n", r); r = SendMessageA(hwndRichEdit, EM_EXGETSEL, 0, (LPARAM)&cr); ok(0 == r, "EM_EXGETSEL returned %d, expected 0\n", r); - todo_wine ok(cr.cpMin == 12, "EM_EXGETSEL returned cpMin=%d, expected 12\n", cr.cpMin); - todo_wine ok(cr.cpMax == 12, "EM_EXGETSEL returned cpMax=%d, expected 12\n", cr.cpMax); + todo_wine ok(cr.cpMin == 12, "EM_EXGETSEL returned cpMin=%ld, expected 12\n", cr.cpMin); + todo_wine ok(cr.cpMax == 12, "EM_EXGETSEL returned cpMax=%ld, expected 12\n", cr.cpMax); SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); todo_wine ok(!strcmp(buffer, "TestSomeText"), "WM_GETTEXT returned incorrect string\n"); @@ -5386,8 +5527,8 @@ static void test_EM_REPLACESEL(int redraw) todo_wine ok(r == 12, "EM_REPLACESEL returned %d, expected 12\n", r); r = SendMessageA(hwndRichEdit, EM_EXGETSEL, 0, (LPARAM)&cr); ok(0 == r, "EM_EXGETSEL returned %d, expected 0\n", r); - todo_wine ok(cr.cpMin == 12, "EM_EXGETSEL returned cpMin=%d, expected 12\n", cr.cpMin); - todo_wine ok(cr.cpMax == 12, "EM_EXGETSEL returned cpMax=%d, expected 12\n", cr.cpMax); + todo_wine ok(cr.cpMin == 12, "EM_EXGETSEL returned cpMin=%ld, expected 12\n", cr.cpMin); + todo_wine ok(cr.cpMax == 12, "EM_EXGETSEL returned cpMax=%ld, expected 12\n", cr.cpMax); SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); todo_wine ok(!strcmp(buffer, "TestSomeText"), "WM_GETTEXT returned incorrect string\n"); @@ -5397,8 +5538,8 @@ static void test_EM_REPLACESEL(int redraw) todo_wine ok(r == 12, "EM_REPLACESEL returned %d, expected 12\n", r); r = SendMessageA(hwndRichEdit, EM_EXGETSEL, 0, (LPARAM)&cr); ok(0 == r, "EM_EXGETSEL returned %d, expected 0\n", r); - todo_wine ok(cr.cpMin == 13, "EM_EXGETSEL returned cpMin=%d, expected 13\n", cr.cpMin); - todo_wine ok(cr.cpMax == 13, "EM_EXGETSEL returned cpMax=%d, expected 13\n", cr.cpMax); + todo_wine ok(cr.cpMin == 13, "EM_EXGETSEL returned cpMin=%ld, expected 13\n", cr.cpMin); + todo_wine ok(cr.cpMax == 13, "EM_EXGETSEL returned cpMax=%ld, expected 13\n", cr.cpMax); SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); todo_wine ok(!strcmp(buffer, "WTestSomeTextne"), "WM_GETTEXT returned incorrect string\n"); @@ -5408,8 +5549,8 @@ static void test_EM_REPLACESEL(int redraw) todo_wine ok(r == 12, "EM_REPLACESEL returned %d, expected 12\n", r); r = SendMessageA(hwndRichEdit, EM_EXGETSEL, 0, (LPARAM)&cr); ok(0 == r, "EM_EXGETSEL returned %d, expected 0\n", r); - todo_wine ok(cr.cpMin == 13, "EM_EXGETSEL returned cpMin=%d, expected 13\n", cr.cpMin); - todo_wine ok(cr.cpMax == 13, "EM_EXGETSEL returned cpMax=%d, expected 13\n", cr.cpMax); + todo_wine ok(cr.cpMin == 13, "EM_EXGETSEL returned cpMin=%ld, expected 13\n", cr.cpMin); + todo_wine ok(cr.cpMax == 13, "EM_EXGETSEL returned cpMax=%ld, expected 13\n", cr.cpMax); SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); todo_wine ok(!strcmp(buffer, "WTestSomeTextne"), "WM_GETTEXT returned incorrect string\n"); @@ -5466,16 +5607,12 @@ static void test_WM_PASTE(void) send_ctrl_key(hwndRichEdit, 'V'); /* Paste */ SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); /* Pasted text should be visible at this step */ - result = strcmp(text1_step1, buffer); - ok(result == 0, - "test paste: strcmp = %i, text='%s'\n", result, buffer); + ok(strcmp(text1_step1, buffer) == 0, "1:Ctrl-V %s\n", wine_dbgstr_a(buffer)); send_ctrl_key(hwndRichEdit, 'Z'); /* Undo */ SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); /* Text should be the same as before (except for \r -> \r\n conversion) */ - result = strcmp(text1_after, buffer); - ok(result == 0, - "test paste: strcmp = %i, text='%s'\n", result, buffer); + ok(strcmp(text1_after, buffer) == 0, "1:Ctrl-Z %s\n", wine_dbgstr_a(buffer)); SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text2); SendMessageA(hwndRichEdit, EM_SETSEL, 8, 13); @@ -5484,21 +5621,15 @@ static void test_WM_PASTE(void) send_ctrl_key(hwndRichEdit, 'V'); /* Paste */ SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); /* Pasted text should be visible at this step */ - result = strcmp(text3, buffer); - ok(result == 0, - "test paste: strcmp = %i\n", result); + ok(strcmp(text3, buffer) == 0, "2:Ctrl-V %s\n", wine_dbgstr_a(buffer)); send_ctrl_key(hwndRichEdit, 'Z'); /* Undo */ SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); /* Text should be the same as before (except for \r -> \r\n conversion) */ - result = strcmp(text2_after, buffer); - ok(result == 0, - "test paste: strcmp = %i\n", result); + ok(strcmp(text2_after, buffer) == 0, "2:Ctrl-Z %s\n", wine_dbgstr_a(buffer)); send_ctrl_key(hwndRichEdit, 'Y'); /* Redo */ SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); /* Text should revert to post-paste state */ - result = strcmp(buffer,text3); - ok(result == 0, - "test paste: strcmp = %i\n", result); + ok(strcmp(buffer,text3) == 0, "2:Ctrl-Y %s\n", wine_dbgstr_a(buffer)); SendMessageA(hwndRichEdit, WM_SETTEXT, 0, 0); /* Send WM_CHAR to simulate Ctrl-V */ @@ -5506,9 +5637,7 @@ static void test_WM_PASTE(void) (MapVirtualKeyA('V', MAPVK_VK_TO_VSC) << 16) | 1); SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); /* Shouldn't paste because pasting is handled by WM_KEYDOWN */ - result = strcmp(buffer,""); - ok(result == 0, - "test paste: strcmp = %i, actual = '%s'\n", result, buffer); + ok(strcmp(buffer, "") == 0, "3:Ctrl-V %s\n", wine_dbgstr_a(buffer)); /* Send keystrokes with WM_KEYDOWN after setting the modifiers * with SetKeyboard state. */ @@ -5520,9 +5649,7 @@ static void test_WM_PASTE(void) (MapVirtualKeyA('V', MAPVK_VK_TO_VSC) << 16) | 1); release_key(VK_CONTROL); SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); - result = strcmp(buffer,"paste"); - ok(result == 0, - "test paste: strcmp = %i, actual = '%s'\n", result, buffer); + ok(strcmp(buffer, "paste") == 0, "VK:Ctrl-V %s\n", wine_dbgstr_a(buffer)); SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text1); SendMessageA(hwndRichEdit, EM_SETSEL, 0, 7); @@ -5532,11 +5659,9 @@ static void test_WM_PASTE(void) (MapVirtualKeyA('C', MAPVK_VK_TO_VSC) << 16) | 1); release_key(VK_CONTROL); SendMessageA(hwndRichEdit, WM_SETTEXT, 0, 0); - SendMessageA(hwndRichEdit, WM_PASTE, 0, 0); + send_paste(hwndRichEdit); SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); - result = strcmp(buffer,"testing"); - ok(result == 0, - "test paste: strcmp = %i, actual = '%s'\n", result, buffer); + ok(strcmp(buffer, "testing") == 0, "VK:Ctrl-C %s\n", wine_dbgstr_a(buffer)); /* Cut with WM_KEYDOWN to simulate Ctrl-X */ SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"cut"); @@ -5549,30 +5674,22 @@ static void test_WM_PASTE(void) (MapVirtualKeyA('X', MAPVK_VK_TO_VSC) << 16) | 1); release_key(VK_CONTROL); SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); - result = strcmp(buffer,""); - ok(result == 0, - "test paste: strcmp = %i, actual = '%s'\n", result, buffer); + ok(strcmp(buffer, "") == 0, "VK:Ctrl-A,X %s\n", wine_dbgstr_a(buffer)); SendMessageA(hwndRichEdit, WM_SETTEXT, 0, 0); - SendMessageA(hwndRichEdit, WM_PASTE, 0, 0); + send_paste(hwndRichEdit); SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); - result = strcmp(buffer,"cut\r\n"); - ok(result == 0, - "test paste: strcmp = %i, actual = '%s'\n", result, buffer); + ok(strcmp(buffer, "cut\r\n") == 0, "VK:paste %s\n", wine_dbgstr_a(buffer)); /* Simulates undo (Ctrl-Z) */ hold_key(VK_CONTROL); SendMessageA(hwndRichEdit, WM_KEYDOWN, 'Z', (MapVirtualKeyA('Z', MAPVK_VK_TO_VSC) << 16) | 1); SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); - result = strcmp(buffer,""); - ok(result == 0, - "test paste: strcmp = %i, actual = '%s'\n", result, buffer); + ok(strcmp(buffer, "") == 0, "VK:Ctrl-Z %s\n", wine_dbgstr_a(buffer)); /* Simulates redo (Ctrl-Y) */ SendMessageA(hwndRichEdit, WM_KEYDOWN, 'Y', (MapVirtualKeyA('Y', MAPVK_VK_TO_VSC) << 16) | 1); SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); - result = strcmp(buffer,"cut\r\n"); - ok(result == 0, - "test paste: strcmp = %i, actual = '%s'\n", result, buffer); + ok(strcmp(buffer, "cut\r\n") == 0, "VK:Ctrl-Y %s\n", wine_dbgstr_a(buffer)); release_key(VK_CONTROL); /* Copy multiline text to clipboard for future use */ @@ -5583,19 +5700,16 @@ static void test_WM_PASTE(void) /* Paste into read-only control */ result = SendMessageA(hwndRichEdit, EM_SETREADONLY, TRUE, 0); + ok(result, "ro:set failed\n"); SendMessageA(hwndRichEdit, WM_PASTE, 0, 0); SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); - result = strcmp(buffer, text3); - ok(result == 0, - "test paste: strcmp = %i, actual = '%s'\n", result, buffer); + ok(strcmp(buffer, text3) == 0, "ro:paste %s\n", wine_dbgstr_a(buffer)); /* Cut from read-only control */ SendMessageA(hwndRichEdit, EM_SETSEL, 0, -1); SendMessageA(hwndRichEdit, WM_CUT, 0, 0); SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); - result = strcmp(buffer, text3); - ok(result == 0, - "test paste: strcmp = %i, actual = '%s'\n", result, buffer); + ok(strcmp(buffer, text3) == 0, "ro:cut %s\n", wine_dbgstr_a(buffer)); /* FIXME: Wine doesn't flush Ole clipboard when window is destroyed so do it manually */ OleFlushClipboard(); @@ -5603,11 +5717,9 @@ static void test_WM_PASTE(void) /* Paste multi-line text into single-line control */ hwndRichEdit = new_richedit_with_style(NULL, 0); - SendMessageA(hwndRichEdit, WM_PASTE, 0, 0); + send_paste(hwndRichEdit); SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); - result = strcmp(buffer, "testing paste"); - ok(result == 0, - "test paste: strcmp = %i, actual = '%s'\n", result, buffer); + ok(strcmp(buffer, "testing paste") == 0, "multi:paste %s\n", wine_dbgstr_a(buffer)); DestroyWindow(hwndRichEdit); } @@ -5665,6 +5777,7 @@ static void test_EM_FORMATRANGE(void) SIZE stringsize; int len; + winetest_push_context("%d", i); SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)fmtstrings[i].string); gtl.flags = GTL_NUMCHARS | GTL_PRECISE; @@ -5696,7 +5809,7 @@ static void test_EM_FORMATRANGE(void) r = SendMessageA(hwndRichEdit, EM_FORMATRANGE, TRUE, (LPARAM)&fr); todo_wine { if (! skip_non_english) - ok(fr.rc.bottom == (stringsize.cy * tpp_y), "Expected bottom to be %d, got %d\n", (stringsize.cy * tpp_y), fr.rc.bottom); + ok(fr.rc.bottom == (stringsize.cy * tpp_y), "Expected bottom to be %ld, got %ld\n", (stringsize.cy * tpp_y), fr.rc.bottom); } if (fmtstrings[i].first) todo_wine { @@ -5715,12 +5828,13 @@ static void test_EM_FORMATRANGE(void) else if (! skip_non_english) ok (r < len, "Expected < %d, got %d\n", len, r); - /* There is at least on more page, but we don't care */ + /* There is at least one more page, but we don't care */ r = SendMessageA(hwndRichEdit, EM_FORMATRANGE, TRUE, 0); todo_wine { ok(r == len, "Expected %d, got %d\n", len, r); } + winetest_pop_context(); } ReleaseDC(NULL, hdc); @@ -5852,6 +5966,7 @@ static void test_EM_STREAMIN(void) char buffer[1024] = {0}, tmp[16]; CHARRANGE range; PARAFORMAT2 fmt; + DWORD len; const char * streamText0 = "{\\rtf1\\fi100\\li200\\rtlpar\\qr TestSomeText}"; const char * streamText0a = "{\\rtf1\\fi100\\li200\\rtlpar\\qr TestSomeText\\par}"; @@ -5902,15 +6017,15 @@ static void test_EM_STREAMIN(void) es.dwError = 0; es.pfnCallback = test_EM_STREAMIN_esCallback; result = SendMessageA(hwndRichEdit, EM_STREAMIN, SF_RTF, (LPARAM)&es); - ok(result == 12, "got %ld, expected %d\n", result, 12); + ok(result == 12, "got %Id, expected %d\n", result, 12); result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); ok (result == 12, - "EM_STREAMIN: Test 0 returned %ld, expected 12\n", result); + "EM_STREAMIN: Test 0 returned %Id, expected 12\n", result); result = strcmp (buffer,"TestSomeText"); ok (result == 0, "EM_STREAMIN: Test 0 set wrong text: Result: %s\n",buffer); - ok(es.dwError == 0, "EM_STREAMIN: Test 0 set error %d, expected %d\n", es.dwError, 0); + ok(es.dwError == 0, "EM_STREAMIN: Test 0 set error %ld, expected %d\n", es.dwError, 0); /* Show that para fmts are ignored */ range.cpMin = 2; range.cpMax = 2; @@ -5918,8 +6033,8 @@ static void test_EM_STREAMIN(void) memset(&fmt, 0xcc, sizeof(fmt)); fmt.cbSize = sizeof(fmt); result = SendMessageA(hwndRichEdit, EM_GETPARAFORMAT, 0, (LPARAM)&fmt); - ok(fmt.dxStartIndent == 0, "got %d\n", fmt.dxStartIndent); - ok(fmt.dxOffset == 0, "got %d\n", fmt.dxOffset); + ok(fmt.dxStartIndent == 0, "got %ld\n", fmt.dxStartIndent); + ok(fmt.dxOffset == 0, "got %ld\n", fmt.dxOffset); ok(fmt.wAlignment == PFA_LEFT, "got %d\n", fmt.wAlignment); ok((fmt.wEffects & PFE_RTLPARA) == 0, "got %x\n", fmt.wEffects); @@ -5929,15 +6044,15 @@ static void test_EM_STREAMIN(void) es.dwError = 0; es.pfnCallback = test_EM_STREAMIN_esCallback; result = SendMessageA(hwndRichEdit, EM_STREAMIN, SF_RTF, (LPARAM)&es); - ok(result == 12, "got %ld, expected %d\n", result, 12); + ok(result == 12, "got %Id, expected %d\n", result, 12); result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); ok (result == 12, - "EM_STREAMIN: Test 0-a returned %ld, expected 12\n", result); + "EM_STREAMIN: Test 0-a returned %Id, expected 12\n", result); result = strcmp (buffer,"TestSomeText"); ok (result == 0, "EM_STREAMIN: Test 0-a set wrong text: Result: %s\n",buffer); - ok(es.dwError == 0, "EM_STREAMIN: Test 0-a set error %d, expected %d\n", es.dwError, 0); + ok(es.dwError == 0, "EM_STREAMIN: Test 0-a set error %ld, expected %d\n", es.dwError, 0); /* This time para fmts are processed */ range.cpMin = 2; range.cpMax = 2; @@ -5945,8 +6060,8 @@ static void test_EM_STREAMIN(void) memset(&fmt, 0xcc, sizeof(fmt)); fmt.cbSize = sizeof(fmt); result = SendMessageA(hwndRichEdit, EM_GETPARAFORMAT, 0, (LPARAM)&fmt); - ok(fmt.dxStartIndent == 300, "got %d\n", fmt.dxStartIndent); - ok(fmt.dxOffset == -100, "got %d\n", fmt.dxOffset); + ok(fmt.dxStartIndent == 300, "got %ld\n", fmt.dxStartIndent); + ok(fmt.dxOffset == -100, "got %ld\n", fmt.dxOffset); ok(fmt.wAlignment == PFA_RIGHT, "got %d\n", fmt.wAlignment); ok((fmt.wEffects & PFE_RTLPARA) == PFE_RTLPARA, "got %x\n", fmt.wEffects); @@ -5955,15 +6070,15 @@ static void test_EM_STREAMIN(void) es.dwError = 0; es.pfnCallback = test_EM_STREAMIN_esCallback; result = SendMessageA(hwndRichEdit, EM_STREAMIN, SF_RTF, (LPARAM)&es); - ok(result == 13, "got %ld, expected %d\n", result, 13); + ok(result == 13, "got %Id, expected %d\n", result, 13); result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); ok (result == 14, - "EM_STREAMIN: Test 0-b returned %ld, expected 14\n", result); + "EM_STREAMIN: Test 0-b returned %Id, expected 14\n", result); result = strcmp (buffer,"TestSomeText\r\n"); ok (result == 0, "EM_STREAMIN: Test 0-b set wrong text: Result: %s\n",buffer); - ok(es.dwError == 0, "EM_STREAMIN: Test 0-b set error %d, expected %d\n", es.dwError, 0); + ok(es.dwError == 0, "EM_STREAMIN: Test 0-b set error %ld, expected %d\n", es.dwError, 0); /* Show that when using SFF_SELECTION the last \par is not ignored. */ ptr = streamText0a; @@ -5971,20 +6086,20 @@ static void test_EM_STREAMIN(void) es.dwError = 0; es.pfnCallback = test_EM_STREAMIN_esCallback; result = SendMessageA(hwndRichEdit, EM_STREAMIN, SF_RTF, (LPARAM)&es); - ok(result == 12, "got %ld, expected %d\n", result, 12); + ok(result == 12, "got %Id, expected %d\n", result, 12); result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); ok (result == 12, - "EM_STREAMIN: Test 0-a returned %ld, expected 12\n", result); + "EM_STREAMIN: Test 0-a returned %Id, expected 12\n", result); result = strcmp (buffer,"TestSomeText"); ok (result == 0, "EM_STREAMIN: Test 0-a set wrong text: Result: %s\n",buffer); - ok(es.dwError == 0, "EM_STREAMIN: Test 0-a set error %d, expected %d\n", es.dwError, 0); + ok(es.dwError == 0, "EM_STREAMIN: Test 0-a set error %ld, expected %d\n", es.dwError, 0); range.cpMin = 0; range.cpMax = -1; result = SendMessageA(hwndRichEdit, EM_EXSETSEL, 0, (LPARAM)&range); - ok (result == 13, "got %ld\n", result); + ok (result == 13, "got %Id\n", result); ptr = streamText0a; es.dwCookie = (DWORD_PTR)&ptr; @@ -5992,104 +6107,104 @@ static void test_EM_STREAMIN(void) es.pfnCallback = test_EM_STREAMIN_esCallback; result = SendMessageA(hwndRichEdit, EM_STREAMIN, SFF_SELECTION | SF_RTF, (LPARAM)&es); - ok(result == 13, "got %ld, expected 13\n", result); + ok(result == 13, "got %Id, expected 13\n", result); result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); ok (result == 14, - "EM_STREAMIN: Test SFF_SELECTION 0-a returned %ld, expected 14\n", result); + "EM_STREAMIN: Test SFF_SELECTION 0-a returned %Id, expected 14\n", result); result = strcmp (buffer,"TestSomeText\r\n"); ok (result == 0, "EM_STREAMIN: Test SFF_SELECTION 0-a set wrong text: Result: %s\n",buffer); - ok(es.dwError == 0, "EM_STREAMIN: Test SFF_SELECTION 0-a set error %d, expected %d\n", es.dwError, 0); + ok(es.dwError == 0, "EM_STREAMIN: Test SFF_SELECTION 0-a set error %ld, expected %d\n", es.dwError, 0); es.dwCookie = (DWORD_PTR)&streamText1; es.dwError = 0; es.pfnCallback = test_EM_STREAMIN_esCallback; result = SendMessageA(hwndRichEdit, EM_STREAMIN, SF_RTF, (LPARAM)&es); - ok(result == 12, "got %ld, expected %d\n", result, 12); + ok(result == 12, "got %Id, expected %d\n", result, 12); result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); ok (result == 12, - "EM_STREAMIN: Test 1 returned %ld, expected 12\n", result); + "EM_STREAMIN: Test 1 returned %Id, expected 12\n", result); result = strcmp (buffer,"TestSomeText"); ok (result == 0, "EM_STREAMIN: Test 1 set wrong text: Result: %s\n",buffer); - ok(es.dwError == 0, "EM_STREAMIN: Test 1 set error %d, expected %d\n", es.dwError, 0); + ok(es.dwError == 0, "EM_STREAMIN: Test 1 set error %ld, expected %d\n", es.dwError, 0); es.dwCookie = (DWORD_PTR)&streamText2; es.dwError = 0; result = SendMessageA(hwndRichEdit, EM_STREAMIN, SF_RTF, (LPARAM)&es); - ok(result == 0, "got %ld, expected %d\n", result, 0); + ok(result == 0, "got %Id, expected %d\n", result, 0); result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); ok (result == 0, - "EM_STREAMIN: Test 2 returned %ld, expected 0\n", result); + "EM_STREAMIN: Test 2 returned %Id, expected 0\n", result); ok(!buffer[0], "EM_STREAMIN: Test 2 set wrong text: Result: %s\n",buffer); - ok(es.dwError == -16, "EM_STREAMIN: Test 2 set error %d, expected %d\n", es.dwError, -16); + ok(es.dwError == -16, "EM_STREAMIN: Test 2 set error %ld, expected %d\n", es.dwError, -16); es.dwCookie = (DWORD_PTR)&streamText3; es.dwError = 0; result = SendMessageA(hwndRichEdit, EM_STREAMIN, SF_RTF, (LPARAM)&es); - ok(result == 0, "got %ld, expected %d\n", result, 0); + ok(result == 0, "got %Id, expected %d\n", result, 0); result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); ok (result == 0, - "EM_STREAMIN: Test 3 returned %ld, expected 0\n", result); + "EM_STREAMIN: Test 3 returned %Id, expected 0\n", result); ok(!buffer[0], "EM_STREAMIN: Test 3 set wrong text: Result: %s\n",buffer); - ok(es.dwError == -16, "EM_STREAMIN: Test 3 set error %d, expected %d\n", es.dwError, -16); + ok(es.dwError == -16, "EM_STREAMIN: Test 3 set error %ld, expected %d\n", es.dwError, -16); es.dwCookie = (DWORD_PTR)&streamTextUTF8BOM; es.dwError = 0; es.pfnCallback = test_EM_STREAMIN_esCallback; result = SendMessageA(hwndRichEdit, EM_STREAMIN, SF_TEXT, (LPARAM)&es); - ok(result == 18, "got %ld, expected %d\n", result, 18); + ok(result == 18, "got %Id, expected %d\n", result, 18); result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); ok(result == 15, - "EM_STREAMIN: Test UTF8WithBOM returned %ld, expected 15\n", result); + "EM_STREAMIN: Test UTF8WithBOM returned %Id, expected 15\n", result); result = strcmp (buffer,"TestUTF8WithBOM"); ok(result == 0, "EM_STREAMIN: Test UTF8WithBOM set wrong text: Result: %s\n",buffer); - ok(es.dwError == 0, "EM_STREAMIN: Test UTF8WithBOM set error %d, expected %d\n", es.dwError, 0); + ok(es.dwError == 0, "EM_STREAMIN: Test UTF8WithBOM set error %ld, expected %d\n", es.dwError, 0); phase = 0; es.dwCookie = (DWORD_PTR)&phase; es.dwError = 0; es.pfnCallback = test_EM_STREAMIN_esCallback_UTF8Split; result = SendMessageA(hwndRichEdit, EM_STREAMIN, SF_TEXT, (LPARAM)&es); - ok(result == 8, "got %ld\n", result); + ok(result == 8, "got %Id\n", result); - WideCharToMultiByte(CP_ACP, 0, UTF8Split_exp, -1, tmp, sizeof(tmp), NULL, NULL); + len = WideCharToMultiByte(CP_ACP, 0, UTF8Split_exp, -1, tmp, sizeof(tmp), NULL, NULL); result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); - ok(result == 3, - "EM_STREAMIN: Test UTF8Split returned %ld\n", result); - result = memcmp (buffer, tmp, 3); + ok(result + 1 == len, + "EM_STREAMIN: Test UTF8Split returned %Id\n", result); + result = memcmp (buffer, tmp, result); ok(result == 0, "EM_STREAMIN: Test UTF8Split set wrong text: Result: %s\n",buffer); - ok(es.dwError == 0, "EM_STREAMIN: Test UTF8Split set error %d, expected %d\n", es.dwError, 0); + ok(es.dwError == 0, "EM_STREAMIN: Test UTF8Split set error %ld, expected %d\n", es.dwError, 0); es.dwCookie = (DWORD_PTR)&cookieForStream4; es.dwError = 0; es.pfnCallback = test_EM_STREAMIN_esCallback2; result = SendMessageA(hwndRichEdit, EM_STREAMIN, SF_TEXT, (LPARAM)&es); - ok(result == length4, "got %ld, expected %d\n", result, length4); + ok(result == length4, "got %Id, expected %d\n", result, length4); result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); ok (result == length4, - "EM_STREAMIN: Test 4 returned %ld, expected %d\n", result, length4); - ok(es.dwError == 0, "EM_STREAMIN: Test 4 set error %d, expected %d\n", es.dwError, 0); + "EM_STREAMIN: Test 4 returned %Id, expected %d\n", result, length4); + ok(es.dwError == 0, "EM_STREAMIN: Test 4 set error %ld, expected %d\n", es.dwError, 0); es.dwCookie = (DWORD_PTR)&cookieForStream5; es.dwError = 0; es.pfnCallback = test_EM_STREAMIN_esCallback2; result = SendMessageA(hwndRichEdit, EM_STREAMIN, SF_TEXT | SF_UNICODE, (LPARAM)&es); - ok(result == sizeof(streamText5), "got %ld, expected %u\n", result, (UINT)sizeof(streamText5)); + ok(result == sizeof(streamText5), "got %Id, expected %u\n", result, (UINT)sizeof(streamText5)); result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); ok (result == length5, - "EM_STREAMIN: Test 5 returned %ld, expected %d\n", result, length5); - ok(es.dwError == 0, "EM_STREAMIN: Test 5 set error %d, expected %d\n", es.dwError, 0); + "EM_STREAMIN: Test 5 returned %Id, expected %d\n", result, length5); + ok(es.dwError == 0, "EM_STREAMIN: Test 5 set error %ld, expected %d\n", es.dwError, 0); DestroyWindow(hwndRichEdit); @@ -6100,7 +6215,7 @@ static void test_EM_STREAMIN(void) es.dwError = 0; es.pfnCallback = test_EM_STREAMIN_esCallback; result = SendMessageA(hwndRichEdit, EM_STREAMIN, SF_TEXT, (LPARAM)&es); - ok(result == 12, "got %ld, expected %d\n", result, 12); + ok(result == 12, "got %Id, expected %d\n", result, 12); result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); ok (!strcmp(buffer, "line1"), "EM_STREAMIN: Unexpected text '%s'\n", buffer); @@ -6112,7 +6227,7 @@ static void test_EM_STREAMIN(void) es.dwError = 0; es.pfnCallback = test_EM_STREAMIN_null_bytes; result = SendMessageA(hwndRichEdit, EM_STREAMIN, SF_RTF, (LPARAM)&es); - ok(result == 16, "got %ld, expected %d\n", result, 16); + ok(result == 16, "got %Id, expected %d\n", result, 16); result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); ok (!strcmp(buffer, "Th is is a test"), "EM_STREAMIN: Unexpected text '%s'\n", buffer); } @@ -6213,7 +6328,7 @@ static void test_unicode_conversions(void) WPARAM wparam = (wm_set_text == WM_SETTEXT) ? 0 : (WPARAM)&stex; \ assert(wm_set_text == WM_SETTEXT || wm_set_text == EM_SETTEXTEX); \ ret = SendMessageA(hwnd, wm_set_text, wparam, (LPARAM)txt); \ - ok(ret, "SendMessageA(%02x) error %u\n", wm_set_text, GetLastError()); \ + ok(ret, "SendMessageA(%02x) error %lu\n", wm_set_text, GetLastError()); \ } while(0) #define expect_textA(hwnd, wm_get_text, txt) \ do { \ @@ -6222,7 +6337,7 @@ static void test_unicode_conversions(void) assert(wm_get_text == WM_GETTEXT || wm_get_text == EM_GETTEXTEX); \ memset(bufA, 0xAA, sizeof(bufA)); \ ret = SendMessageA(hwnd, wm_get_text, wparam, (LPARAM)bufA); \ - ok(ret, "SendMessageA(%02x) error %u\n", wm_get_text, GetLastError()); \ + ok(ret, "SendMessageA(%02x) error %lu\n", wm_get_text, GetLastError()); \ ret = lstrcmpA(bufA, txt); \ ok(!ret, "%02x: strings do not match: expected %s got %s\n", wm_get_text, txt, bufA); \ } while(0) @@ -6233,7 +6348,7 @@ static void test_unicode_conversions(void) WPARAM wparam = (wm_set_text == WM_SETTEXT) ? 0 : (WPARAM)&stex; \ assert(wm_set_text == WM_SETTEXT || wm_set_text == EM_SETTEXTEX); \ ret = SendMessageW(hwnd, wm_set_text, wparam, (LPARAM)txt); \ - ok(ret, "SendMessageW(%02x) error %u\n", wm_set_text, GetLastError()); \ + ok(ret, "SendMessageW(%02x) error %lu\n", wm_set_text, GetLastError()); \ } while(0) #define expect_textW(hwnd, wm_get_text, txt) \ do { \ @@ -6242,7 +6357,7 @@ static void test_unicode_conversions(void) assert(wm_get_text == WM_GETTEXT || wm_get_text == EM_GETTEXTEX); \ memset(bufW, 0xAA, sizeof(bufW)); \ ret = SendMessageW(hwnd, wm_get_text, wparam, (LPARAM)bufW); \ - ok(ret, "SendMessageW(%02x) error %u\n", wm_get_text, GetLastError()); \ + ok(ret, "SendMessageW(%02x) error %lu\n", wm_get_text, GetLastError()); \ ret = lstrcmpW(bufW, txt); \ ok(!ret, "%02x: strings do not match: expected[0] %x got[0] %x\n", wm_get_text, txt[0], bufW[0]); \ } while(0) @@ -6259,7 +6374,7 @@ static void test_unicode_conversions(void) hwnd = CreateWindowExA(0, "RichEdit20W", NULL, WS_POPUP, 0, 0, 200, 60, 0, 0, 0, 0); - ok(hwnd != 0, "CreateWindowExA error %u\n", GetLastError()); + ok(hwnd != 0, "CreateWindowExA error %lu\n", GetLastError()); ret = IsWindowUnicode(hwnd); ok(ret, "RichEdit20W should be unicode under NT\n"); @@ -6319,7 +6434,7 @@ static void test_unicode_conversions(void) hwnd = CreateWindowExA(0, "RichEdit20A", NULL, WS_POPUP, 0, 0, 200, 60, 0, 0, 0, 0); - ok(hwnd != 0, "CreateWindowExA error %u\n", GetLastError()); + ok(hwnd != 0, "CreateWindowExA error %lu\n", GetLastError()); ret = IsWindowUnicode(hwnd); ok(!ret, "RichEdit20A should NOT be unicode\n"); @@ -6367,7 +6482,7 @@ static void test_WM_CHAR(void) /* single-line control must IGNORE carriage returns */ hwnd = CreateWindowExA(0, "RichEdit20W", NULL, WS_POPUP, 0, 0, 200, 60, 0, 0, 0, 0); - ok(hwnd != 0, "CreateWindowExA error %u\n", GetLastError()); + ok(hwnd != 0, "CreateWindowExA error %lu\n", GetLastError()); disable_beep( hwnd ); p = char_list; @@ -6388,7 +6503,7 @@ static void test_WM_CHAR(void) /* multi-line control inserts CR normally */ hwnd = CreateWindowExA(0, "RichEdit20W", NULL, WS_POPUP|ES_MULTILINE, 0, 0, 200, 60, 0, 0, 0, 0); - ok(hwnd != 0, "CreateWindowExA error %u\n", GetLastError()); + ok(hwnd != 0, "CreateWindowExA error %lu\n", GetLastError()); p = char_list; while (*p != '\0') { @@ -6420,7 +6535,7 @@ static void test_EM_GETTEXTLENGTHEX(void) /* single line */ hwnd = CreateWindowExA(0, "RichEdit20W", NULL, WS_POPUP, 0, 0, 200, 60, 0, 0, 0, 0); - ok(hwnd != 0, "CreateWindowExA error %u\n", GetLastError()); + ok(hwnd != 0, "CreateWindowExA error %lu\n", GetLastError()); gtl.flags = GTL_NUMCHARS | GTL_PRECISE | GTL_USECRLF; gtl.codepage = CP_ACP; @@ -6465,7 +6580,7 @@ static void test_EM_GETTEXTLENGTHEX(void) /* multi line */ hwnd = CreateWindowExA(0, "RichEdit20W", NULL, WS_POPUP | ES_MULTILINE, 0, 0, 200, 60, 0, 0, 0, 0); - ok(hwnd != 0, "CreateWindowExA error %u\n", GetLastError()); + ok(hwnd != 0, "CreateWindowExA error %lu\n", GetLastError()); gtl.flags = GTL_NUMCHARS | GTL_PRECISE | GTL_USECRLF; gtl.codepage = CP_ACP; @@ -6550,7 +6665,7 @@ static void test_EM_GETTEXTLENGTHEX(void) gtl.codepage = 1200; ret = SendMessageA(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)>l, 0); ok(ret == E_INVALIDARG, - "GTL_NUMCHARS | GTL_NUMBYTES gave %i, expected %i\n", ret, E_INVALIDARG); + "GTL_NUMCHARS | GTL_NUMBYTES gave %i, expected %li\n", ret, E_INVALIDARG); DestroyWindow(hwnd); } @@ -6581,16 +6696,7 @@ static void test_eventMask(void) int eventMask; /* register class to capture WM_COMMAND */ - cls.style = 0; - cls.lpfnWndProc = ParentMsgCheckProcA; - cls.cbClsExtra = 0; - cls.cbWndExtra = 0; - cls.hInstance = GetModuleHandleA(0); - cls.hIcon = 0; - cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW); - cls.hbrBackground = GetStockObject(WHITE_BRUSH); - cls.lpszMenuName = NULL; - cls.lpszClassName = "EventMaskParentClass"; + cls = make_simple_class(ParentMsgCheckProcA, "EventMaskParentClass"); if(!RegisterClassA(&cls)) assert(0); parent = CreateWindowA(cls.lpszClassName, NULL, WS_POPUP|WS_VISIBLE, @@ -6674,16 +6780,7 @@ static void test_WM_NOTIFY(void) int sel_start, sel_end; /* register class to capture WM_NOTIFY */ - cls.style = 0; - cls.lpfnWndProc = WM_NOTIFY_ParentMsgCheckProcA; - cls.cbClsExtra = 0; - cls.cbWndExtra = 0; - cls.hInstance = GetModuleHandleA(0); - cls.hIcon = 0; - cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW); - cls.hbrBackground = GetStockObject(WHITE_BRUSH); - cls.lpszMenuName = NULL; - cls.lpszClassName = "WM_NOTIFY_ParentClass"; + cls = make_simple_class(WM_NOTIFY_ParentMsgCheckProcA, "WM_NOTIFY_ParentClass"); if(!RegisterClassA(&cls)) assert(0); parent = CreateWindowA(cls.lpszClassName, NULL, WS_POPUP|WS_VISIBLE, @@ -6811,24 +6908,24 @@ static void link_notify_test(const char *desc, int i, HWND hwnd, HWND parent, ok(enlink.nmhdr.hwndFrom == hwnd, "%s test %i: Expected hwnd %p got %p\n", desc, i, hwnd, enlink.nmhdr.hwndFrom); ok(enlink.nmhdr.idFrom == 0, - "%s test %i: Expected idFrom 0 got 0x%lx\n", desc, i, enlink.nmhdr.idFrom); + "%s test %i: Expected idFrom 0 got 0x%Ix\n", desc, i, enlink.nmhdr.idFrom); ok(enlink.msg == msg, "%s test %i: Expected msg 0x%x got 0x%x\n", desc, i, msg, enlink.msg); if (msg == WM_SETCURSOR) { ok(enlink.wParam == 0, - "%s test %i: Expected wParam 0 got 0x%lx\n", desc, i, enlink.wParam); + "%s test %i: Expected wParam 0 got 0x%Ix\n", desc, i, enlink.wParam); } else { ok(enlink.wParam == wParam, - "%s test %i: Expected wParam 0x%lx got 0x%lx\n", desc, i, wParam, enlink.wParam); + "%s test %i: Expected wParam 0x%Ix got 0x%Ix\n", desc, i, wParam, enlink.wParam); } ok(enlink.lParam == MAKELPARAM(CURSOR_CLIENT_X, CURSOR_CLIENT_Y), - "%s test %i: Expected lParam 0x%lx got 0x%lx\n", + "%s test %i: Expected lParam 0x%Ix got 0x%Ix\n", desc, i, MAKELPARAM(CURSOR_CLIENT_X, CURSOR_CLIENT_Y), enlink.lParam); ok(enlink.chrg.cpMin == 0 && enlink.chrg.cpMax == 31, - "%s test %i: Expected link range [0,31) got [%i,%i)\n", desc, i, enlink.chrg.cpMin, enlink.chrg.cpMax); + "%s test %i: Expected link range [0,31) got [%li,%li)\n", desc, i, enlink.chrg.cpMin, enlink.chrg.cpMax); } else { @@ -6909,16 +7006,7 @@ static void test_EN_LINK(void) }; /* register class to capture WM_NOTIFY */ - cls.style = 0; - cls.lpfnWndProc = EN_LINK_ParentMsgCheckProcA; - cls.cbClsExtra = 0; - cls.cbWndExtra = 0; - cls.hInstance = GetModuleHandleA(0); - cls.hIcon = 0; - cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW); - cls.hbrBackground = GetStockObject(WHITE_BRUSH); - cls.lpszMenuName = NULL; - cls.lpszClassName = "EN_LINK_ParentClass"; + cls = make_simple_class(EN_LINK_ParentMsgCheckProcA, "EN_LINK_ParentClass"); if(!RegisterClassA(&cls)) assert(0); parent = CreateWindowA(cls.lpszClassName, NULL, WS_POPUP|WS_VISIBLE, @@ -6971,7 +7059,7 @@ static void test_undo_coalescing(void) /* multi-line control inserts CR normally */ hwnd = CreateWindowExA(0, "RichEdit20W", NULL, WS_POPUP|ES_MULTILINE, 0, 0, 200, 60, 0, 0, 0, 0); - ok(hwnd != 0, "CreateWindowExA error %u\n", GetLastError()); + ok(hwnd != 0, "CreateWindowExA error %lu\n", GetLastError()); disable_beep( hwnd ); result = SendMessageA(hwnd, EM_CANUNDO, 0, 0); @@ -7206,6 +7294,51 @@ static void test_word_movement(void) DestroyWindow(hwnd); } +static void test_word_movement_multiline(void) +{ + DWORD sel_start, sel_end; + LRESULT result; + HWND hwnd; + + /* multi-line control inserts CR normally */ + hwnd = new_richedit(NULL); + + result = SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)"Lorem ipsum\rdolor sit\rnamet"); + ok(result == TRUE, "WM_SETTEXT returned %Iu.\n", result); + SendMessageA(hwnd, EM_SETSEL, 0, 0); + /* [|Lorem ipsum] [dolor sit] [amet] */ + + send_ctrl_key(hwnd, VK_RIGHT); + /* [Lorem |ipsum] [dolor sit] [amet] */ + sel_start = sel_end = 0xdeadbeefUL; + SendMessageA(hwnd, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); + ok(sel_start == sel_end, "expected sel length to be 0, got %lu.\n", sel_end - sel_start); + ok(sel_start == 6, "expected sel_start to be %u, got %lu.\n", 6, sel_start); + + send_ctrl_key(hwnd, VK_RIGHT); + /* [Lorem ipsum|] [dolor sit] [amet] */ + sel_start = sel_end = 0xdeadbeefUL; + SendMessageA(hwnd, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); + ok(sel_start == sel_end, "expected sel length to be 0, got %lu.\n", sel_end - sel_start); + ok(sel_start == 11, "expected sel_start to be %u, got %lu.\n", 11, sel_start); + + send_ctrl_key(hwnd, VK_RIGHT); + /* [Lorem ipsum] [|dolor sit] [amet] */ + sel_start = sel_end = 0xdeadbeefUL; + SendMessageA(hwnd, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); + ok(sel_start == sel_end, "expected sel length to be 0, got %lu.\n", sel_end - sel_start); + ok(sel_start == 12, "expected sel_start to be %u, got %lu.\n", 12, sel_start); + + send_ctrl_key(hwnd, VK_LEFT); + /* [Lorem ipsum|] [dolor sit] [amet] */ + sel_start = sel_end = 0xdeadbeefUL; + SendMessageA(hwnd, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); + ok(sel_start == sel_end, "expected sel length to be 0, got %lu.\n", sel_end - sel_start); + ok(sel_start == 11, "expected sel_start to be %u, got %lu.\n", 11, sel_start); + + DestroyWindow(hwnd); +} + static void test_EM_CHARFROMPOS(void) { HWND hwnd; @@ -7229,32 +7362,34 @@ static void test_EM_CHARFROMPOS(void) point.x = -1; point.y = 40; result = SendMessageA(hwnd, EM_CHARFROMPOS, 0, (LPARAM)&point); - todo_wine ok(result == 34, "expected character index of 34 but got %d\n", result); + ok(result == 34, "expected character index of 34 but got %d\n", result); point.x = 1000; point.y = 0; result = SendMessageA(hwnd, EM_CHARFROMPOS, 0, (LPARAM)&point); - todo_wine ok(result == 33, "expected character index of 33 but got %d\n", result); + ok(result == 33, "expected character index of 33 but got %d\n", result); point.x = 1000; point.y = 36; result = SendMessageA(hwnd, EM_CHARFROMPOS, 0, (LPARAM)&point); - todo_wine ok(result == 39, "expected character index of 39 but got %d\n", result); + ok(result == 39, "expected character index of 39 but got %d\n", result); point.x = 1000; point.y = -1; result = SendMessageA(hwnd, EM_CHARFROMPOS, 0, (LPARAM)&point); + /* This differs from the msftedit result */ todo_wine ok(result == 0, "expected character index of 0 but got %d\n", result); point.x = 1000; point.y = rcClient.bottom + 1; result = SendMessageA(hwnd, EM_CHARFROMPOS, 0, (LPARAM)&point); + /* This differs from the msftedit result */ todo_wine ok(result == 34, "expected character index of 34 but got %d\n", result); point.x = 1000; point.y = rcClient.bottom; result = SendMessageA(hwnd, EM_CHARFROMPOS, 0, (LPARAM)&point); - todo_wine ok(result == 39, "expected character index of 39 but got %d\n", result); + ok(result == 39, "expected character index of 39 but got %d\n", result); DestroyWindow(hwnd); } @@ -7378,7 +7513,7 @@ static void test_autoscroll(void) ok(lines == 1, "%d lines instead of 1\n", lines); ret = SendMessageA(hwnd, EM_GETSCROLLPOS, 0, (LPARAM)&pt); ok(ret == 1, "EM_GETSCROLLPOS returned %d instead of 1\n", ret); - ok(pt.y == 0, "y scroll position is %d after clearing text.\n", pt.y); + ok(pt.y == 0, "y scroll position is %ld after clearing text.\n", pt.y); ret = GetWindowLongA(hwnd, GWL_STYLE); ok(!(ret & WS_VSCROLL), "Scrollbar is still shown (style=%x).\n", (UINT)ret); } @@ -7953,16 +8088,7 @@ static void test_dialogmode(void) int lcount, r; WNDCLASSA cls; - cls.style = 0; - cls.lpfnWndProc = dialog_mode_wnd_proc; - cls.cbClsExtra = 0; - cls.cbWndExtra = 0; - cls.hInstance = GetModuleHandleA(0); - cls.hIcon = 0; - cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW); - cls.hbrBackground = GetStockObject(WHITE_BRUSH); - cls.lpszMenuName = NULL; - cls.lpszClassName = "DialogModeParentClass"; + cls = make_simple_class(dialog_mode_wnd_proc, "DialogModeParentClass"); if(!RegisterClassA(&cls)) assert(0); hwParent = CreateWindowA("DialogModeParentClass", NULL, WS_OVERLAPPEDWINDOW, @@ -8082,7 +8208,7 @@ static void test_dialogmode(void) hwButton = CreateWindowA("BUTTON", "OK", WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON, 100, 100, 50, 20, hwParent, (HMENU)ID_RICHEDITTESTDBUTTON, GetModuleHandleA(0), NULL); - ok(hwButton!=NULL, "CreateWindow failed with error code %d\n", GetLastError()); + ok(hwButton!=NULL, "CreateWindow failed with error code %ld\n", GetLastError()); memset(&dm_messages, 0, sizeof(dm_messages)); r = SendMessageA(hwRichEdit, WM_KEYDOWN, VK_RETURN, 0x1c0001); @@ -8142,7 +8268,7 @@ static void test_dialogmode(void) hwButton = CreateWindowA("BUTTON", "OK", WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON, 100, 100, 50, 20, hwParent, (HMENU)ID_RICHEDITTESTDBUTTON, GetModuleHandleA(0), NULL); - ok(hwButton!=NULL, "CreateWindow failed with error code %d\n", GetLastError()); + ok(hwButton!=NULL, "CreateWindow failed with error code %ld\n", GetLastError()); memset(&dm_messages, 0, sizeof(dm_messages)); r = SendMessageA(hwRichEdit, WM_KEYDOWN, VK_RETURN, 0x1c0001); @@ -8196,7 +8322,7 @@ static void test_dialogmode(void) hwButton = CreateWindowA("BUTTON", "OK", WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON, 100, 100, 50, 20, hwParent, (HMENU)ID_RICHEDITTESTDBUTTON, GetModuleHandleA(0), NULL); - ok(hwButton!=NULL, "CreateWindow failed with error code %d\n", GetLastError()); + ok(hwButton!=NULL, "CreateWindow failed with error code %ld\n", GetLastError()); memset(&dm_messages, 0, sizeof(dm_messages)); r = SendMessageA(hwRichEdit, WM_KEYDOWN, VK_RETURN, 0x1c0001); @@ -8226,7 +8352,7 @@ static void test_dialogmode(void) hwButton = CreateWindowA("BUTTON", "OK", WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON, 100, 100, 50, 20, hwParent, (HMENU)ID_RICHEDITTESTDBUTTON, GetModuleHandleA(0), NULL); - ok(hwButton!=NULL, "CreateWindow failed with error code %d\n", GetLastError()); + ok(hwButton!=NULL, "CreateWindow failed with error code %ld\n", GetLastError()); memset(&dm_messages, 0, sizeof(dm_messages)); r = SendMessageA(hwRichEdit, WM_KEYDOWN, VK_RETURN, 0x1c0001); @@ -8359,7 +8485,7 @@ static void test_enter(void) { /* Set the text to the initial text */ result = SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)testenteritems[i].initialtext); - ok (result == 1, "[%d] WM_SETTEXT returned %ld instead of 1\n", i, result); + ok (result == 1, "[%d] WM_SETTEXT returned %Id instead of 1\n", i, result); /* Send Enter */ SendMessageA(hwndRichEdit, EM_SETSEL, testenteritems[i].cursor, testenteritems[i].cursor); @@ -8414,7 +8540,7 @@ static void test_enter(void) getText.codepage = CP_ACP; result = SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)""); - ok (result == 1, "[%d] WM_SETTEXT returned %ld instead of 1\n", i, result); + ok (result == 1, "[%d] WM_SETTEXT returned %Id instead of 1\n", i, result); SendMessageW(hwndRichEdit, WM_CHAR, 'T', 0); SendMessageW(hwndRichEdit, WM_KEYDOWN, VK_RETURN, 0); @@ -8426,7 +8552,7 @@ static void test_enter(void) ok (result == 0, "[%d] EM_GETTEXTEX, GT_DEFAULT unexpected '%s', expected '%s'\n", i, resultbuf, expectedbuf); result = SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)""); - ok (result == 1, "[%d] WM_SETTEXT returned %ld instead of 1\n", i, result); + ok (result == 1, "[%d] WM_SETTEXT returned %Id instead of 1\n", i, result); SendMessageW(hwndRichEdit, WM_CHAR, 'T', 0); SendMessageW(hwndRichEdit, WM_CHAR, '\r', 0); @@ -8459,7 +8585,7 @@ static void test_WM_CREATE(void) ok(!strcmp(buf, "line1"), "buf = %s\n", buf); res = SendMessageA(rich_edit, EM_GETSEL, 0, 0); - ok(res == 0, "SendMessage(EM_GETSEL) returned %lx\n", res); + ok(res == 0, "SendMessage(EM_GETSEL) returned %Ix\n", res); DestroyWindow(rich_edit); @@ -8472,7 +8598,7 @@ static void test_WM_CREATE(void) ok(!strcmp(buf, "line1\r\nline2"), "buf = %s\n", buf); res = SendMessageA(rich_edit, EM_GETSEL, 0, 0); - ok(res == 0, "SendMessage(EM_GETSEL) returned %lx\n", res); + ok(res == 0, "SendMessage(EM_GETSEL) returned %Ix\n", res); DestroyWindow(rich_edit); } @@ -8522,12 +8648,12 @@ static void test_EM_SETREADONLY(void) res = SendMessageA(richedit, EM_SETREADONLY, TRUE, 0); ok(res == 1, "EM_SETREADONLY\n"); dwStyle = GetWindowLongA(richedit, GWL_STYLE); - ok(dwStyle & ES_READONLY, "got wrong value: 0x%x\n", dwStyle); + ok(dwStyle & ES_READONLY, "got wrong value: 0x%lx\n", dwStyle); res = SendMessageA(richedit, EM_SETREADONLY, FALSE, 0); ok(res == 1, "EM_SETREADONLY\n"); dwStyle = GetWindowLongA(richedit, GWL_STYLE); - ok(!(dwStyle & ES_READONLY), "got wrong value: 0x%x\n", dwStyle); + ok(!(dwStyle & ES_READONLY), "got wrong value: 0x%lx\n", dwStyle); DestroyWindow(richedit); } @@ -8552,8 +8678,8 @@ static void _test_font_size(unsigned line, HWND hwnd, LONG size, LONG expected_s res = SendMessageA(hwnd, EM_SETFONTSIZE, size, 0); SendMessageA(hwnd, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); isundo = SendMessageA(hwnd, EM_CANUNDO, 0, 0); - ok_(__FILE__,line)(res == expected_res, "EM_SETFONTSIZE unexpected return value: %lx.\n", res); - ok_(__FILE__,line)(twips2points(cf.yHeight) == expected_size, "got wrong font size: %d, expected: %d\n", + ok_(__FILE__,line)(res == expected_res, "EM_SETFONTSIZE unexpected return value: %Ix.\n", res); + ok_(__FILE__,line)(twips2points(cf.yHeight) == expected_size, "got wrong font size: %ld, expected: %ld\n", twips2points(cf.yHeight), expected_size); ok_(__FILE__,line)(isundo == expected_undo, "get wrong undo mark: %d, expected: %d.\n", isundo, expected_undo); @@ -8652,11 +8778,11 @@ static void test_alignment_style(void) pf.dwMask = -1; SendMessageW(richedit, EM_GETPARAFORMAT, 0, (LPARAM)&pf); - ok(pf.wAlignment == align_mask[i], "(i = %d) got %d expected %d\n", + ok(pf.wAlignment == align_mask[i], "(i = %d) got %d expected %ld\n", i, pf.wAlignment, align_mask[i]); dwStyle = GetWindowLongW(richedit, GWL_STYLE); ok((i ? (dwStyle & align_style[i]) : (!(dwStyle & 0x0000000f))) , - "(i = %d) didn't set right align style: 0x%x\n", i, dwStyle); + "(i = %d) didn't set right align style: 0x%lx\n", i, dwStyle); /* Based on test_reset_default_para_fmt() */ @@ -8669,13 +8795,13 @@ static void test_alignment_style(void) SendMessageW(richedit, EM_SETPARAFORMAT, 0, (LPARAM)&pf); SendMessageW(richedit, EM_GETPARAFORMAT, 0, (LPARAM)&pf); - ok(pf.wAlignment == new_align, "got %d expect %d\n", pf.wAlignment, new_align); + ok(pf.wAlignment == new_align, "got %d expect %ld\n", pf.wAlignment, new_align); SendMessageW(richedit, EM_SETSEL, 0, -1); SendMessageW(richedit, WM_CUT, 0, 0); SendMessageW(richedit, EM_GETPARAFORMAT, 0, (LPARAM)&pf); - ok(pf.wAlignment == align_mask[i], "got %d expect %d\n", pf.wAlignment, align_mask[i]); + ok(pf.wAlignment == align_mask[i], "got %d expect %ld\n", pf.wAlignment, align_mask[i]); /* Test out of bounds tab count */ pf.dwMask = PFM_TABSTOPS; @@ -8764,6 +8890,8 @@ static void test_rtf(void) 0x201d,0x200e,0x200f,0x200d,0x200c}; const char *pard = "{\\rtf1 ABC\\rtlpar\\par DEF\\par HIJ\\pard\\par}"; const char *highlight = "{\\rtf1{\\colortbl;\\red0\\green0\\blue0;\\red128\\green128\\blue128;\\red192\\green192\\blue192;}\\cf2\\highlight3 foo\\par}"; + const char *crash = "{\\rtf2 {\\par \\pard \\trowd \\cellx6000 \\intbl \\cell \\row \\par \\pard \\li300 \\bullet packages... \\par }"; + const char *crash2 = "{\\rtf1 \\trowd row1 \\intbl \\cell \\row \\par \\trowd row2 \\intbl \\cell \\row}"; HWND edit = new_richeditW( NULL ); EDITSTREAM es; @@ -8777,17 +8905,17 @@ static void test_rtf(void) es.dwError = 0; es.pfnCallback = test_EM_STREAMIN_esCallback; result = SendMessageA( edit, EM_STREAMIN, SF_RTF, (LPARAM)&es ); - ok( result == 11, "got %ld\n", result ); + ok( result == 11, "got %Id\n", result ); result = SendMessageW( edit, WM_GETTEXT, ARRAY_SIZE(buf), (LPARAM)buf ); - ok( result == ARRAY_SIZE(expect_specials), "got %ld\n", result ); + ok( result == ARRAY_SIZE(expect_specials), "got %Id\n", result ); ok( !memcmp( buf, expect_specials, sizeof(expect_specials) ), "got %s\n", wine_dbgstr_w(buf) ); /* Show that \rtlpar propagates to the second paragraph and is reset by \pard in the third. */ es.dwCookie = (DWORD_PTR)&pard; result = SendMessageA( edit, EM_STREAMIN, SF_RTF, (LPARAM)&es ); - ok( result == 11, "got %ld\n", result ); + ok( result == 11, "got %Id\n", result ); fmt.cbSize = sizeof(fmt); SendMessageW( edit, EM_SETSEL, 1, 1 ); @@ -8806,14 +8934,23 @@ static void test_rtf(void) /* Test \highlight */ es.dwCookie = (DWORD_PTR)&highlight; result = SendMessageA( edit, EM_STREAMIN, SF_RTF, (LPARAM)&es ); - ok( result == 3, "got %ld\n", result ); + ok( result == 3, "got %Id\n", result ); SendMessageW( edit, EM_SETSEL, 1, 1 ); memset( &cf, 0, sizeof(cf) ); cf.cbSize = sizeof(cf); SendMessageW( edit, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf ); - ok( (cf.dwEffects & (CFE_AUTOCOLOR | CFE_AUTOBACKCOLOR)) == 0, "got %08x\n", cf.dwEffects ); - ok( cf.crTextColor == RGB(128,128,128), "got %08x\n", cf.crTextColor ); - ok( cf.crBackColor == RGB(192,192,192), "got %08x\n", cf.crBackColor ); + ok( (cf.dwEffects & (CFE_AUTOCOLOR | CFE_AUTOBACKCOLOR)) == 0, "got %08lx\n", cf.dwEffects ); + ok( cf.crTextColor == RGB(128,128,128), "got %08lx\n", cf.crTextColor ); + ok( cf.crBackColor == RGB(192,192,192), "got %08lx\n", cf.crBackColor ); + + /* Test cases that crash */ + es.dwCookie = (DWORD_PTR)&crash; + es.dwError = 0; + SendMessageA( edit, EM_STREAMIN, SF_RTF, (LPARAM)&es ); + + es.dwCookie = (DWORD_PTR)&crash2; + es.dwError = 0; + SendMessageA( edit, EM_STREAMIN, SF_RTF, (LPARAM)&es ); DestroyWindow( edit ); } @@ -8854,13 +8991,13 @@ static void test_eop_char_fmt(void) cf.cbSize = sizeof(cf); cf.dwMask = CFM_SIZE; SendMessageW( edit, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf ); - ok( cf.dwMask & CFM_SIZE, "%d: got %08x\n", i, cf.dwMask ); + ok( cf.dwMask & CFM_SIZE, "%d: got %08lx\n", i, cf.dwMask ); if (i < 6) expect_height = 160; else if (i < 13) expect_height = 250; else if (i < 18) expect_height = 260; else if (i == 18 || i == 25) expect_height = 250; else expect_height = 220; - ok( cf.yHeight == expect_height, "%d: got %d\n", i, cf.yHeight ); + ok( cf.yHeight == expect_height, "%d: got %ld\n", i, cf.yHeight ); } DestroyWindow( edit ); @@ -8892,10 +9029,10 @@ static void test_para_numbering(void) es.dwError = 0; es.pfnCallback = test_EM_STREAMIN_esCallback; result = SendMessageA( edit, EM_STREAMIN, SF_RTF, (LPARAM)&es ); - ok( result == lstrlenW( expect_numbers_txt ), "got %ld\n", result ); + ok( result == lstrlenW( expect_numbers_txt ), "got %Id\n", result ); result = SendMessageW( edit, EM_GETTEXTEX, (WPARAM)&get_text, (LPARAM)buf ); - ok( result == lstrlenW( expect_numbers_txt ), "got %ld\n", result ); + ok( result == lstrlenW( expect_numbers_txt ), "got %Id\n", result ); ok( !lstrcmpW( buf, expect_numbers_txt ), "got %s\n", wine_dbgstr_w(buf) ); SendMessageW( edit, EM_SETSEL, 1, 1 ); @@ -8907,8 +9044,8 @@ static void test_para_numbering(void) ok( fmt.wNumberingStart == 2, "got %d\n", fmt.wNumberingStart ); ok( fmt.wNumberingStyle == PFNS_PERIOD, "got %04x\n", fmt.wNumberingStyle ); ok( fmt.wNumberingTab == 1000, "got %d\n", fmt.wNumberingTab ); - ok( fmt.dxStartIndent == 560, "got %d\n", fmt.dxStartIndent ); - ok( fmt.dxOffset == -200, "got %d\n", fmt.dxOffset ); + ok( fmt.dxStartIndent == 560, "got %ld\n", fmt.dxStartIndent ); + ok( fmt.dxOffset == -200, "got %ld\n", fmt.dxOffset ); /* Second para should have identical fmt */ SendMessageW( edit, EM_SETSEL, 10, 10 ); @@ -8923,13 +9060,13 @@ static void test_para_numbering(void) cf.cbSize = sizeof(cf); cf.dwMask = CFM_SIZE; SendMessageW( edit, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf ); - ok( cf.yHeight == 200, "got %d\n", cf.yHeight ); + ok( cf.yHeight == 200, "got %ld\n", cf.yHeight ); SendMessageW( edit, EM_SETSEL, 18, 19 ); cf.cbSize = sizeof(cf); cf.dwMask = CFM_SIZE; SendMessageW( edit, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf ); - ok( cf.yHeight == 200, "got %d\n", cf.yHeight ); + ok( cf.yHeight == 200, "got %ld\n", cf.yHeight ); DestroyWindow( edit ); } @@ -8951,6 +9088,47 @@ static void fill_reobject_struct(REOBJECT *reobj, LONG cp, LPOLEOBJECT poleobj, reobj->dwUser = user; } +static BOOL change_received = FALSE; + +static LRESULT WINAPI ChangeWatcherWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + if (message == WM_COMMAND && (wParam >> 16) == EN_CHANGE) change_received = TRUE; + return DefWindowProcA(hwnd, message, wParam, lParam); +} + +static LRESULT WINAPI RichEditWithEventsWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + if (message == WM_CREATE) + SendMessageA(hwnd, EM_SETEVENTMASK, 0, ENM_CHANGE); + return CallWindowProcA(richeditProc, hwnd, message, wParam, lParam); +} + +static void test_init_messages(void) +{ + WNDCLASSA cls; + HWND parent, edit; + + /* register class to capture EN_CHANGE */ + cls = make_simple_class(ChangeWatcherWndProc, "ChangeWatcherClass"); + if (!RegisterClassA(&cls)) assert(0); + + /* and a class that sets ENM_CHANGE during WM_CREATE */ + if (!GetClassInfoA(hmoduleRichEdit, RICHEDIT_CLASS20A, &cls)) return; + richeditProc = cls.lpfnWndProc; + cls.lpfnWndProc = RichEditWithEventsWndProc; + cls.lpszClassName = "RichEditWithEvents"; + if (!RegisterClassA(&cls)) assert(0); + + parent = CreateWindowA("ChangeWatcherClass", NULL, WS_POPUP|WS_VISIBLE, + 0, 0, 200, 60, NULL, NULL, NULL, NULL); + ok(parent != 0, "Failed to create parent window\n"); + change_received = FALSE; + edit = new_window("RichEditWithEvents", 0, parent); + ok(change_received == FALSE, "Creating a RichEdit should not make any EN_CHANGE events\n"); + DestroyWindow(edit); + DestroyWindow(parent); +} + static void test_EM_SELECTIONTYPE(void) { HWND hwnd = new_richedit(NULL); @@ -8978,11 +9156,11 @@ static void test_EM_SELECTIONTYPE(void) SendMessageA(hwnd, EM_SETSEL, 0, 1); hr = IRichEditOle_GetClientSite(reole, &clientsite); - ok(hr == S_OK, "IRichEditOle_GetClientSite failed: 0x%08x\n", hr); + ok(hr == S_OK, "IRichEditOle_GetClientSite failed: 0x%08lx\n", hr); fill_reobject_struct(&reo1, REO_CP_SELECTION, NULL, NULL, clientsite, 10, 10, DVASPECT_CONTENT, 0, 1); hr = IRichEditOle_InsertObject(reole, &reo1); - ok(hr == S_OK, "IRichEditOle_InsertObject failed: 0x%08x\n", hr); + ok(hr == S_OK, "IRichEditOle_InsertObject failed: 0x%08lx\n", hr); IOleClientSite_Release(clientsite); SendMessageA(hwnd, EM_SETSEL, 0, 1); @@ -8999,11 +9177,11 @@ static void test_EM_SELECTIONTYPE(void) SendMessageA(hwnd, EM_SETSEL, 2, 3); hr = IRichEditOle_GetClientSite(reole, &clientsite); - ok(hr == S_OK, "IRichEditOle_GetClientSite failed: 0x%08x\n", hr); + ok(hr == S_OK, "IRichEditOle_GetClientSite failed: 0x%08lx\n", hr); fill_reobject_struct(&reo2, REO_CP_SELECTION, NULL, NULL, clientsite, 10, 10, DVASPECT_CONTENT, 0, 2); hr = IRichEditOle_InsertObject(reole, &reo2); - ok(hr == S_OK, "IRichEditOle_InsertObject failed: 0x%08x\n", hr); + ok(hr == S_OK, "IRichEditOle_InsertObject failed: 0x%08lx\n", hr); IOleClientSite_Release(clientsite); SendMessageA(hwnd, EM_SETSEL, 0, 2); @@ -9039,7 +9217,7 @@ static void test_window_classes(void) int i; HWND hwnd; - for (i = 0; i < sizeof(test)/sizeof(test[0]); i++) + for (i = 0; i < ARRAY_SIZE(test); i++) { SetLastError(0xdeadbeef); hwnd = CreateWindowExA(0, test[i].class, NULL, WS_POPUP, 0, 0, 0, 0, 0, 0, 0, NULL); @@ -9048,7 +9226,7 @@ todo_wine_if(!strcmp(test[i].class, "RichEdit50A") || !strcmp(test[i].class, "Ri test[i].class, test[i].success ? "succeed" : "fail"); if (!hwnd) todo_wine - ok(GetLastError() == ERROR_CANNOT_FIND_WND_CLASS, "got %d\n", GetLastError()); + ok(GetLastError() == ERROR_CANNOT_FIND_WND_CLASS, "got %lu\n", GetLastError()); else DestroyWindow(hwnd); } @@ -9057,8 +9235,8 @@ todo_wine START_TEST( editor ) { BOOL ret; - /* Must explicitly LoadLibrary(). The test has no references to functions in - * RICHED20.DLL, so the linker doesn't actually link to it. */ + /* Must explicitly LoadLibrary(). The test has no reference to functions in + * RICHED20.DLL, so the linker does not actually link to it. */ hmoduleRichEdit = LoadLibraryA("riched20.dll"); ok(hmoduleRichEdit != NULL, "error: %d\n", (int) GetLastError()); is_lang_japanese = (PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_JAPANESE); @@ -9109,6 +9287,7 @@ START_TEST( editor ) test_eventMask(); test_undo_coalescing(); test_word_movement(); + test_word_movement_multiline(); test_EM_CHARFROMPOS(); test_SETPARAFORMAT(); test_word_wrap(); @@ -9129,6 +9308,7 @@ START_TEST( editor ) test_background(); test_eop_char_fmt(); test_para_numbering(); + test_init_messages(); test_EM_SELECTIONTYPE(); /* Set the environment variable WINETEST_RICHED20 to keep windows diff --git a/modules/rostests/winetests/riched20/richole.c b/modules/rostests/winetests/riched20/richole.c index 3885eb527fc..d419ab56290 100644 --- a/modules/rostests/winetests/riched20/richole.c +++ b/modules/rostests/winetests/riched20/richole.c @@ -31,11 +31,599 @@ #include #include #include +#include +#include #include +#ifdef __REACTOS__ +#define debugstr_guid wine_dbgstr_guid +#endif + +#define EXPECT_TODO_WINE 0x80000000UL + +struct reolecb_obj +{ + IRichEditOleCallback IRichEditOleCallback_iface; + LONG ref; + int line; + + ULONG expect_queryinsertobject; + + const CLSID *clsid; + IStorage *stg; + LONG cp; + HRESULT queryinsertobject_result; +}; + +static inline struct reolecb_obj *impl_from_IRichEditOleCallback(IRichEditOleCallback *iface) +{ + return CONTAINING_RECORD(iface, struct reolecb_obj, IRichEditOleCallback_iface); +} + +static HRESULT STDMETHODCALLTYPE reolecb_obj_QueryInterface(IRichEditOleCallback *iface, REFIID riid, void **obj) +{ + if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IRichEditOleCallback)) { + IRichEditOleCallback_AddRef(iface); + *obj = iface; + return S_OK; + } + *obj = NULL; + return E_NOINTERFACE; +} + +static ULONG STDMETHODCALLTYPE reolecb_obj_AddRef(IRichEditOleCallback *iface) +{ + struct reolecb_obj *This = impl_from_IRichEditOleCallback(iface); + ULONG ref = InterlockedIncrement(&This->ref); + return ref; +} + +static ULONG STDMETHODCALLTYPE reolecb_obj_Release(IRichEditOleCallback *iface) +{ + struct reolecb_obj *This = impl_from_IRichEditOleCallback(iface); + ULONG ref = InterlockedDecrement(&This->ref); + if (!ref) free(This); + return ref; +} + +static HRESULT STDMETHODCALLTYPE reolecb_obj_GetNewStorage(IRichEditOleCallback *iface, IStorage **stg) +{ + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE reolecb_obj_GetInPlaceContext(IRichEditOleCallback *iface, + IOleInPlaceFrame **frame, + IOleInPlaceUIWindow **doc, + OLEINPLACEFRAMEINFO *frame_info) +{ + return E_INVALIDARG; +} + +static HRESULT STDMETHODCALLTYPE reolecb_obj_ShowContainerUI(IRichEditOleCallback *iface, BOOL show) +{ + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE reolecb_obj_QueryInsertObject(IRichEditOleCallback *iface, CLSID *clsid, + IStorage *stg, LONG cp) +{ + struct reolecb_obj *This = impl_from_IRichEditOleCallback(iface); + ULONG expect = This->expect_queryinsertobject; + + todo_wine_if(expect & EXPECT_TODO_WINE) + ok_(__FILE__,This->line)( expect & ~EXPECT_TODO_WINE, + "unexpected call to IRichEditOleCallback_QueryInsertObject\n"); + if (!(expect & ~EXPECT_TODO_WINE)) return S_OK; + This->expect_queryinsertobject--; + + if (This->clsid && clsid) + ok_(__FILE__,This->line)( IsEqualGUID(This->clsid, clsid), + "QueryInsertObject clsid expected %s, got %s\n", + wine_dbgstr_guid( This->clsid ), wine_dbgstr_guid( clsid )); + else + ok_(__FILE__,This->line)( This->clsid == clsid, + "QueryInsertObject clsid expected %p, got %p\n", This->clsid, clsid ); + ok_(__FILE__,This->line)( This->stg == stg, "QueryInsertObject stg expected %p, got %p\n", This->stg, stg ); + ok_(__FILE__,This->line)( This->cp == cp, "QueryInsertObject cp expected %ld, got %ld\n", This->cp, cp ); + return This->queryinsertobject_result; +} + +static HRESULT STDMETHODCALLTYPE reolecb_obj_DeleteObject(IRichEditOleCallback *iface, IOleObject *oleobj) +{ + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE reolecb_obj_QueryAcceptData(IRichEditOleCallback *iface, IDataObject *dataobj, + CLIPFORMAT *cf_format, DWORD reco, BOOL really, + HGLOBAL metapict) +{ + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE reolecb_obj_ContextSensitiveHelp(IRichEditOleCallback *iface, BOOL enter_mode) +{ + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE reolecb_obj_GetClipboardData(IRichEditOleCallback *iface, CHARRANGE *chrg, + DWORD reco, IDataObject **dataobj) +{ + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE reolecb_obj_GetDragDropEffect(IRichEditOleCallback *iface, BOOL drag, + DWORD key_state, DWORD *effect) +{ + if (effect) *effect = DROPEFFECT_COPY; + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE reolecb_obj_GetContextMenu(IRichEditOleCallback *iface, WORD seltype, + IOleObject *oleobj, CHARRANGE *chrg, HMENU *hmenu) +{ + return E_NOTIMPL; +} + +static const struct IRichEditOleCallbackVtbl reolecb_obj_Vtbl = { + reolecb_obj_QueryInterface, + reolecb_obj_AddRef, + reolecb_obj_Release, + reolecb_obj_GetNewStorage, + reolecb_obj_GetInPlaceContext, + reolecb_obj_ShowContainerUI, + reolecb_obj_QueryInsertObject, + reolecb_obj_DeleteObject, + reolecb_obj_QueryAcceptData, + reolecb_obj_ContextSensitiveHelp, + reolecb_obj_GetClipboardData, + reolecb_obj_GetDragDropEffect, + reolecb_obj_GetContextMenu, +}; + +static HRESULT reolecb_obj_Create(struct reolecb_obj **objptr) +{ + struct reolecb_obj *obj; + + obj = calloc(sizeof(struct reolecb_obj), 1); + if (!obj) return E_OUTOFMEMORY; + +#ifdef __REACTOS__ + obj->IRichEditOleCallback_iface.lpVtbl = (IRichEditOleCallbackVtbl*)&reolecb_obj_Vtbl; +#else + obj->IRichEditOleCallback_iface.lpVtbl = &reolecb_obj_Vtbl; +#endif + obj->ref = 1; + + *objptr = obj; + return S_OK; +} + +static void olecb_expect_QueryInsertObject(struct reolecb_obj *This, int line, ULONG expect, + const CLSID *clsid, IStorage *stg, LONG cp, HRESULT result) +{ + if (!This) return; + + This->line = line; + This->expect_queryinsertobject = expect; + This->clsid = clsid; + This->stg = stg; + This->cp = cp; + This->queryinsertobject_result = result; +} + +static void olecb_check_QueryInsertObject(struct reolecb_obj *This, int line) +{ + if (!This) return; + + todo_wine_if(This->expect_queryinsertobject & EXPECT_TODO_WINE) + ok( !(This->expect_queryinsertobject & ~EXPECT_TODO_WINE), + "expected IRichEditOleCallback_QueryInsertObject to be called\n" ); + + olecb_expect_QueryInsertObject(This, 0, 0, NULL, NULL, 0, S_OK); +} + +DEFINE_GUID(CLSID_testoleobj, 0x4484082e, 0x6d18, 0x4932, 0xa0, 0x86, 0x5b, 0x4d, 0xcf, 0x36, 0xb3, 0xde); + +struct testoleobj { + IOleObject IOleObject_iface; + LONG ref; + int line; + int draw_count; + + IOleClientSite *clientsite; + IOleAdviseHolder *advise_holder; + SIZEL extent; + + IViewObject IViewObject_iface; +}; + +static struct testoleobj *impl_from_IOleObject( IOleObject *iface ) +{ + return CONTAINING_RECORD( iface, struct testoleobj, IOleObject_iface ); +} + +static HRESULT STDMETHODCALLTYPE testoleobj_QueryInterface( IOleObject *iface, REFIID riid, void **obj ) +{ + struct testoleobj *This = impl_from_IOleObject( iface ); + + if (IsEqualGUID( riid, &IID_IUnknown ) || IsEqualGUID( riid, &IID_IOleObject )) + { + *obj = iface; + } + else if (IsEqualGUID( riid, &IID_IViewObject )) + { + *obj = &This->IViewObject_iface; + } + else + { + if (!IsEqualGUID( riid, &IID_IOleLink ) && + !IsEqualGUID( riid, &IID_IRunnableObject ) && + !IsEqualGUID( riid, &IID_IMarshal )) + { + trace( "Unsupported interface: %s\n", debugstr_guid( riid )); + } + *obj = NULL; + return E_NOINTERFACE; + } + + IUnknown_AddRef( (IUnknown *)*obj ); + return S_OK; +} + +static ULONG STDMETHODCALLTYPE testoleobj_AddRef( IOleObject *iface ) +{ + struct testoleobj *This = impl_from_IOleObject( iface ); + ULONG ref = InterlockedIncrement( &This->ref ); + return ref; +} + +static ULONG STDMETHODCALLTYPE testoleobj_Release( IOleObject *iface ) +{ + struct testoleobj *This = impl_from_IOleObject( iface ); + ULONG ref = InterlockedDecrement( &This->ref ); + if (!ref) + { + if (This->advise_holder) + { + IOleAdviseHolder_Release( This->advise_holder ); + This->advise_holder = NULL; + } + if (This->clientsite) + { + IOleClientSite_Release( This->clientsite ); + This->clientsite = NULL; + } + free( This ); + } + return ref; +} + +static HRESULT STDMETHODCALLTYPE testoleobj_IOleObject_SetClientSite( IOleObject *iface, IOleClientSite *clientsite ) +{ + struct testoleobj *This = impl_from_IOleObject( iface ); + + if (This->clientsite != clientsite) + { + if (This->clientsite) IOleClientSite_Release( This->clientsite ); + This->clientsite = clientsite; + if (This->clientsite) IOleClientSite_AddRef( This->clientsite ); + } + + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE testoleobj_IOleObject_GetClientSite( IOleObject *iface, IOleClientSite **clientsite ) +{ + struct testoleobj *This = impl_from_IOleObject( iface ); + + if (This->clientsite) IOleClientSite_AddRef( This->clientsite ); + *clientsite = This->clientsite; + + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE testoleobj_IOleObject_SetHostNames( IOleObject *iface, + LPCOLESTR container_app, + LPCOLESTR container_obj ) +{ + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE testoleobj_IOleObject_Close( IOleObject *iface, DWORD save_option ) +{ + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE testoleobj_IOleObject_SetMoniker( IOleObject *iface, + DWORD which_moniker, IMoniker *mk ) +{ + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE testoleobj_IOleObject_GetMoniker( IOleObject *iface, DWORD assign, + DWORD which_moniker, IMoniker **mk ) +{ + struct testoleobj *This = impl_from_IOleObject( iface ); + + *mk = NULL; + + if (!This->clientsite) return E_UNEXPECTED; + + return IOleClientSite_GetMoniker( This->clientsite, assign, which_moniker, mk ); +} + +static HRESULT STDMETHODCALLTYPE testoleobj_IOleObject_InitFromData( IOleObject *iface, IDataObject *dataobj, + BOOL creation, DWORD reserved ) +{ + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE testoleobj_IOleObject_GetClipboardData( IOleObject *iface, DWORD reserved, + IDataObject **dataobj ) +{ + *dataobj = NULL; + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE testoleobj_IOleObject_DoVerb( IOleObject *iface, LONG verb, MSG *msg, + IOleClientSite *activesite, LONG index, + HWND parentwnd, LPCRECT posrect ) +{ + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE testoleobj_IOleObject_EnumVerbs( IOleObject *iface, IEnumOLEVERB **enumoleverb ) +{ + *enumoleverb = NULL; + return OLEOBJ_E_NOVERBS; +} + +static HRESULT STDMETHODCALLTYPE testoleobj_IOleObject_Update( IOleObject *iface ) +{ + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE testoleobj_IOleObject_IsUpToDate( IOleObject *iface ) +{ + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE testoleobj_IOleObject_GetUserClassID( IOleObject *iface, CLSID *clsid ) +{ + *clsid = CLSID_testoleobj; + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE testoleobj_IOleObject_GetUserType( IOleObject *iface, DWORD form_of_type, LPOLESTR *user_type ) +{ + static const OLECHAR typename[] = L"richole testoleobj"; + + *user_type = CoTaskMemAlloc( sizeof(typename) ); + if (!*user_type) return E_OUTOFMEMORY; + + memcpy( *user_type, typename, sizeof(typename) ); + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE testoleobj_IOleObject_SetExtent( IOleObject *iface, DWORD draw_aspect, SIZEL *sizel ) +{ + struct testoleobj *This = impl_from_IOleObject( iface ); + + if (draw_aspect != DVASPECT_CONTENT) return E_FAIL; + + This->extent = *sizel; + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE testoleobj_IOleObject_GetExtent( IOleObject *iface, DWORD draw_aspect, SIZEL *sizel ) +{ + struct testoleobj *This = impl_from_IOleObject( iface ); + + if (draw_aspect != DVASPECT_CONTENT) return E_FAIL; + + *sizel = This->extent; + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE testoleobj_IOleObject_Advise( IOleObject *iface, IAdviseSink *adv_sink, DWORD *connection ) +{ + struct testoleobj *This = impl_from_IOleObject( iface ); + HRESULT hr = S_OK; + + if (!This->advise_holder) hr = CreateOleAdviseHolder( &This->advise_holder ); + if (SUCCEEDED( hr )) hr = IOleAdviseHolder_Advise( This->advise_holder, adv_sink, connection ); + return hr; +} + +static HRESULT STDMETHODCALLTYPE testoleobj_IOleObject_Unadvise( IOleObject *iface, DWORD connection ) +{ + struct testoleobj *This = impl_from_IOleObject( iface ); + + if (!This->advise_holder) return OLE_E_NOCONNECTION; + return IOleAdviseHolder_Unadvise( This->advise_holder, connection ); +} + +static HRESULT STDMETHODCALLTYPE testoleobj_IOleObject_EnumAdvise( IOleObject *iface, IEnumSTATDATA **enum_advise ) +{ + struct testoleobj *This = impl_from_IOleObject( iface ); + + if (!This->advise_holder) + { + *enum_advise = NULL; + return S_OK; + } + return IOleAdviseHolder_EnumAdvise( This->advise_holder, enum_advise ); +} + +static HRESULT STDMETHODCALLTYPE testoleobj_IOleObject_GetMiscStatus( IOleObject *iface, DWORD aspect, DWORD *status ) +{ + *status = 0; + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE testoleobj_IOleObject_SetColorScheme( IOleObject *iface, LOGPALETTE *palette ) +{ + return E_NOTIMPL; +} + +static const struct IOleObjectVtbl testoleobj_IOleObject_Vtbl = { + testoleobj_QueryInterface, + testoleobj_AddRef, + testoleobj_Release, + testoleobj_IOleObject_SetClientSite, + testoleobj_IOleObject_GetClientSite, + testoleobj_IOleObject_SetHostNames, + testoleobj_IOleObject_Close, + testoleobj_IOleObject_SetMoniker, + testoleobj_IOleObject_GetMoniker, + testoleobj_IOleObject_InitFromData, + testoleobj_IOleObject_GetClipboardData, + testoleobj_IOleObject_DoVerb, + testoleobj_IOleObject_EnumVerbs, + testoleobj_IOleObject_Update, + testoleobj_IOleObject_IsUpToDate, + testoleobj_IOleObject_GetUserClassID, + testoleobj_IOleObject_GetUserType, + testoleobj_IOleObject_SetExtent, + testoleobj_IOleObject_GetExtent, + testoleobj_IOleObject_Advise, + testoleobj_IOleObject_Unadvise, + testoleobj_IOleObject_EnumAdvise, + testoleobj_IOleObject_GetMiscStatus, + testoleobj_IOleObject_SetColorScheme +}; + +static struct testoleobj *impl_from_IViewObject( IViewObject *iface ) +{ + return CONTAINING_RECORD( iface, struct testoleobj, IViewObject_iface ); +} + +static HRESULT STDMETHODCALLTYPE testoleobj_IViewObject_QueryInterface( IViewObject *iface, REFIID riid, void **obj ) +{ + struct testoleobj *This = impl_from_IViewObject( iface ); + return IOleObject_QueryInterface( &This->IOleObject_iface, riid, obj ); +} + +static ULONG STDMETHODCALLTYPE testoleobj_IViewObject_AddRef( IViewObject *iface ) +{ + struct testoleobj *This = impl_from_IViewObject( iface ); + return IOleObject_AddRef( &This->IOleObject_iface ); +} + +static ULONG STDMETHODCALLTYPE testoleobj_IViewObject_Release( IViewObject *iface ) +{ + struct testoleobj *This = impl_from_IViewObject( iface ); + return IOleObject_Release( &This->IOleObject_iface ); +} + +static HRESULT STDMETHODCALLTYPE testoleobj_IViewObject_Draw( IViewObject *iface, DWORD draw_aspect, + LONG index, void *aspect, DVTARGETDEVICE *td, + HDC hdc_target_dev, HDC hdc_draw, + LPCRECTL bounds, LPCRECTL wbounds, + BOOL (CALLBACK *fn_continue)(ULONG_PTR), + ULONG_PTR arg_continue ) +{ + struct testoleobj *This = impl_from_IViewObject( iface ); + SIZEL dpi; + + if (draw_aspect != DVASPECT_CONTENT || index != -1) return E_NOTIMPL; + + ok_(__FILE__,This->line)( td == NULL, "expected td to be NULL, got %p\n", td ); + ok_(__FILE__,This->line)( hdc_target_dev == NULL, "expected hdc_target_dev to be NULL, got %p\n", hdc_target_dev ); + ok_(__FILE__,This->line)( wbounds == NULL, "expected wbounds to be NULL, got %p\n", wbounds ); + + dpi.cx = GetDeviceCaps(hdc_draw, LOGPIXELSX); + dpi.cy = GetDeviceCaps(hdc_draw, LOGPIXELSY); + + ok_(__FILE__,This->line)( bounds->right - bounds->left == MulDiv( This->extent.cx, dpi.cx, 2540 ), + "bounds->right (= %ld) - bounds->left (= %ld) != " + "MulDiv( This->extent.cx (= %ld), dpi.cx (= %ld), 2540 )\n", + bounds->right, bounds->left, This->extent.cx, dpi.cx ); + ok_(__FILE__,This->line)( bounds->bottom - bounds->top == MulDiv( This->extent.cy, dpi.cy, 2540 ), + "bounds->bottom (= %ld) - bounds->top (= %ld) != " + "MulDiv( This->extent.cy (= %ld), dpi.cy (= %ld), 2540 )\n", + bounds->bottom, bounds->top, This->extent.cy, dpi.cy ); + + FillRect( hdc_draw, (const RECT *)bounds, GetStockObject( DKGRAY_BRUSH )); + This->draw_count++; + + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE testoleobj_IViewObject_GetColorSet( IViewObject *iface, DWORD draw_aspect, + LONG index, void *aspect, DVTARGETDEVICE *td, + HDC hdc_target_dev, LOGPALETTE **color_set ) +{ + *color_set = NULL; + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE testoleobj_IViewObject_Freeze( IViewObject *iface, DWORD draw_aspect, + LONG index, void *aspect, DWORD *freeze ) +{ + *freeze = 0; + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE testoleobj_IViewObject_Unfreeze( IViewObject *iface, DWORD freeze ) +{ + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE testoleobj_IViewObject_SetAdvise( IViewObject *iface, DWORD aspects, + DWORD advf, IAdviseSink *adv_sink ) +{ + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE testoleobj_IViewObject_GetAdvise( IViewObject *iface, DWORD *aspects, + DWORD *advf, IAdviseSink **adv_sink ) +{ + *aspects = 0; + *advf = 0; + *adv_sink = NULL; + return E_NOTIMPL; +} + +static const struct IViewObjectVtbl testoleobj_IViewObject_Vtbl = { + testoleobj_IViewObject_QueryInterface, + testoleobj_IViewObject_AddRef, + testoleobj_IViewObject_Release, + testoleobj_IViewObject_Draw, + testoleobj_IViewObject_GetColorSet, + testoleobj_IViewObject_Freeze, + testoleobj_IViewObject_Unfreeze, + testoleobj_IViewObject_SetAdvise, + testoleobj_IViewObject_GetAdvise, +}; + +static HRESULT testoleobj_Create( struct testoleobj **objptr ) +{ + struct testoleobj *obj; + + obj = calloc( sizeof(struct testoleobj), 1 ); + *objptr = obj; + if (!obj) return E_OUTOFMEMORY; + + +#ifdef __REACTOS__ + obj->IOleObject_iface.lpVtbl = (IOleObjectVtbl*)&testoleobj_IOleObject_Vtbl; +#else + obj->IOleObject_iface.lpVtbl = &testoleobj_IOleObject_Vtbl; +#endif + obj->ref = 1; +#ifdef __REACTOS__ + obj->IViewObject_iface.lpVtbl = (IViewObjectVtbl*)&testoleobj_IViewObject_Vtbl; +#else + obj->IViewObject_iface.lpVtbl = &testoleobj_IViewObject_Vtbl; +#endif + + return S_OK; +} static HMODULE hmoduleRichEdit; DEFINE_GUID(GUID_NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +DEFINE_GUID(IID_ITextServices, 0x8d33f740, 0xcf58, 0x11ce, 0xa8, 0x9d, 0x00, 0xaa, 0x00, 0x6c, 0xad, 0xc5); static const WCHAR sysW[] = {'S','y','s','t','e','m',0}; @@ -45,7 +633,7 @@ static void _expect_ref(IUnknown* obj, ULONG ref, int line) ULONG rc; IUnknown_AddRef(obj); rc = IUnknown_Release(obj); - ok_(__FILE__,line)(rc == ref, "expected refcount %d, got %d\n", ref, rc); + ok_(__FILE__,line)(rc == ref, "expected refcount %ld, got %ld\n", ref, rc); } static HWND new_window(LPCSTR lpClassName, DWORD dwStyle, HWND parent) @@ -123,14 +711,14 @@ static void _check_typeinfo(IDispatch* disp, REFIID expected_riid, int line) count = 10; hr = IDispatch_GetTypeInfoCount(disp, &count); - ok_(__FILE__,line)(hr == S_OK, "IDispatch_GetTypeInfoCount failed: 0x%08x.\n", hr); + ok_(__FILE__,line)(hr == S_OK, "IDispatch_GetTypeInfoCount failed: 0x%08lx.\n", hr); ok_(__FILE__,line)(count == 1, "got wrong count: %u.\n", count); hr = IDispatch_GetTypeInfo(disp, 0, LOCALE_SYSTEM_DEFAULT, &typeinfo); - ok_(__FILE__,line)(hr == S_OK, "IDispatch_GetTypeInfo failed: 0x%08x.\n", hr); + ok_(__FILE__,line)(hr == S_OK, "IDispatch_GetTypeInfo failed: 0x%08lx.\n", hr); hr = ITypeInfo_GetTypeAttr(typeinfo, &typeattr); - ok_(__FILE__,line)(hr == S_OK, "ITypeInfo_GetTypeAttr failed: 0x%08x.\n", hr); + ok_(__FILE__,line)(hr == S_OK, "ITypeInfo_GetTypeAttr failed: 0x%08lx.\n", hr); ok_(__FILE__,line)(IsEqualGUID(&typeattr->guid, expected_riid), "Unexpected type guid: %s.\n", wine_dbgstr_guid(&typeattr->guid)); @@ -174,17 +762,17 @@ static void test_Interfaces(void) CHECK_TYPEINFO(txtDoc, &IID_ITextDocument); hres = ITextDocument_GetSelection(txtDoc, NULL); - ok(hres == E_INVALIDARG, "ITextDocument_GetSelection: 0x%x\n", hres); + ok(hres == E_INVALIDARG, "ITextDocument_GetSelection: 0x%lx\n", hres); EXPECT_REF(txtDoc, 4); hres = ITextDocument_GetSelection(txtDoc, &txtSel); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); hres = ITextDocument_QueryInterface(txtDoc, &IID_IUnknown, (void **)&unk); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); hres = ITextSelection_QueryInterface(txtSel, &IID_IUnknown, (void **)&unk2); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); ok(unk != unk2, "unknowns are the same\n"); IUnknown_Release(unk2); IUnknown_Release(unk); @@ -193,7 +781,7 @@ static void test_Interfaces(void) EXPECT_REF(txtSel, 2); hres = ITextDocument_GetSelection(txtDoc, &txtSel2); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); ok(txtSel2 == txtSel, "got %p, %p\n", txtSel, txtSel2); EXPECT_REF(txtDoc, 4); @@ -244,7 +832,7 @@ static void test_Interfaces(void) ITextDocument_Release(txtDoc); IRichEditOle_Release(reOle); refcount = IRichEditOle_Release(reOle); - ok(refcount == 1, "got wrong ref count: %d\n", refcount); + ok(refcount == 1, "got wrong ref count: %ld\n", refcount); DestroyWindow(w); /* Methods should return CO_E_RELEASED if the backing document has @@ -260,7 +848,7 @@ static void test_Interfaces(void) ok(reOle != NULL, "EM_GETOLEINTERFACE\n"); hres = IRichEditOle_QueryInterface(reOle, &IID_ITextDocument2Old, (void **)&txtDoc2Old); - ok(hres == S_OK, "IRichEditOle_QueryInterface failed: 0x%08x.\n", hres); + ok(hres == S_OK, "IRichEditOle_QueryInterface failed: 0x%08lx.\n", hres); ok(txtDoc2Old != NULL, "IRichEditOle_QueryInterface\n"); CHECK_TYPEINFO(txtDoc2Old, &IID_ITextDocument); ITextDocument2Old_Release(txtDoc2Old); @@ -318,7 +906,7 @@ static void test_ITextDocument_Open(void) touch_file(filename); create_interfaces(&w, &reOle, &txtDoc, &txtSel); hres = ITextDocument_Open(txtDoc, &testfile, tomConstantsSingle[i], CP_ACP); - todo_wine ok(hres == S_OK, "ITextDocument_Open: Filename:test.txt Flags:0x%x Codepage:CP_ACP hres:0x%x\n", + todo_wine ok(hres == S_OK, "ITextDocument_Open: Filename:test.txt Flags:0x%x Codepage:CP_ACP hres:0x%lx\n", tomConstantsSingle[i], hres); release_interfaces(&w, &reOle, &txtDoc, &txtSel); DeleteFileW(filename); @@ -326,7 +914,7 @@ static void test_ITextDocument_Open(void) touch_file(filename); create_interfaces(&w, &reOle, &txtDoc, &txtSel); hres = ITextDocument_Open(txtDoc, &testfile, tomConstantsSingle[i], CP_UTF8); - todo_wine ok(hres == S_OK, "ITextDocument_Open: Filename:test.txt Flags:0x%x Codepage:CP_UTF8 hres:0x%x\n", + todo_wine ok(hres == S_OK, "ITextDocument_Open: Filename:test.txt Flags:0x%x Codepage:CP_UTF8 hres:0x%lx\n", tomConstantsSingle[i], hres); release_interfaces(&w, &reOle, &txtDoc, &txtSel); DeleteFileW(filename); @@ -337,7 +925,7 @@ static void test_ITextDocument_Open(void) touch_file(filename); create_interfaces(&w, &reOle, &txtDoc, &txtSel); hres = ITextDocument_Open(txtDoc, &testfile, tomConstantsMulti[i], CP_ACP); - todo_wine ok(hres == S_OK, "ITextDocument_Open: Filename:test.txt Flags:0x%x Codepage:CP_ACP hres:0x%x\n", + todo_wine ok(hres == S_OK, "ITextDocument_Open: Filename:test.txt Flags:0x%x Codepage:CP_ACP hres:0x%lx\n", tomConstantsMulti[i], hres); release_interfaces(&w, &reOle, &txtDoc, &txtSel); DeleteFileW(filename); @@ -345,7 +933,7 @@ static void test_ITextDocument_Open(void) touch_file(filename); create_interfaces(&w, &reOle, &txtDoc, &txtSel); hres = ITextDocument_Open(txtDoc, &testfile, tomConstantsMulti[i], CP_UTF8); - todo_wine ok(hres == S_OK, "ITextDocument_Open: Filename:test.txt Flags:0x%x Codepage:CP_UTF8 hres:0x%x\n", + todo_wine ok(hres == S_OK, "ITextDocument_Open: Filename:test.txt Flags:0x%x Codepage:CP_UTF8 hres:0x%lx\n", tomConstantsMulti[i], hres); release_interfaces(&w, &reOle, &txtDoc, &txtSel); DeleteFileW(filename); @@ -421,7 +1009,7 @@ static void test_ITextDocument_Open(void) DeleteFileW(filename); hres = ITextDocument_Open(txtDoc, &testfile, tomText, CP_ACP); todo_wine { - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); ok(is_existing_file(filename) == TRUE, "a file should be created default\n"); } release_interfaces(&w, &reOle, &txtDoc, &txtSel); @@ -431,8 +1019,8 @@ todo_wine { touch_file(filename); create_interfaces(&w, &reOle, &txtDoc, &txtSel); hres = ITextDocument_Open(txtDoc, &testfile, tomShareDenyRead, CP_ACP); -todo_wine - ok(hres == S_OK, "got 0x%08x\n", hres); + todo_wine + ok(hres == S_OK, "got 0x%08lx\n", hres); SetLastError(0xdeadbeef); hFile = CreateFileW(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); @@ -444,8 +1032,8 @@ todo_wine touch_file(filename); create_interfaces(&w, &reOle, &txtDoc, &txtSel); hres = ITextDocument_Open(txtDoc, &testfile, tomShareDenyWrite, CP_ACP); -todo_wine - ok(hres == S_OK, "got 0x%08x\n", hres); + todo_wine + ok(hres == S_OK, "got 0x%08lx\n", hres); SetLastError(0xdeadbeef); hFile = CreateFileW(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); @@ -458,8 +1046,8 @@ todo_wine create_interfaces(&w, &reOle, &txtDoc, &txtSel); SetLastError(0xdeadbeef); hres = ITextDocument_Open(txtDoc, &testfile, tomShareDenyWrite|tomShareDenyRead, CP_ACP); -todo_wine - ok(hres == S_OK, "got 0x%08x\n", hres); + todo_wine + ok(hres == S_OK, "got 0x%08lx\n", hres); hFile = CreateFileW(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); todo_wine ok(GetLastError() == ERROR_SHARING_VIOLATION, "ITextDocument_Open should fail\n"); @@ -474,8 +1062,8 @@ todo_wine CloseHandle(hFile); create_interfaces(&w, &reOle, &txtDoc, &txtSel); hres = ITextDocument_Open(txtDoc, &testfile, tomReadOnly, CP_ACP); -todo_wine - ok(hres == S_OK, "got 0x%08x\n", hres); + todo_wine + ok(hres == S_OK, "got 0x%08lx\n", hres); result = SendMessageA(w, WM_GETTEXT, 1024, (LPARAM)bufACP); todo_wine ok(result == 12, "ITextDocument_Open: Test ASCII returned %d, expected 12\n", result); result = strcmp(bufACP, chACP); @@ -489,8 +1077,8 @@ todo_wine CloseHandle(hFile); create_interfaces(&w, &reOle, &txtDoc, &txtSel); hres = ITextDocument_Open(txtDoc, &testfile, tomReadOnly, CP_UTF8); -todo_wine - ok(hres == S_OK, "got 0x%08x\n", hres); + todo_wine + ok(hres == S_OK, "got 0x%08lx\n", hres); result = SendMessageA(w, WM_GETTEXT, 1024, (LPARAM)bufACP); todo_wine ok(result == 15, "ITextDocument_Open: Test UTF-8 returned %d, expected 15\n", result); result = strcmp(bufACP, &chUTF8[3]); @@ -504,8 +1092,8 @@ todo_wine CloseHandle(hFile); create_interfaces(&w, &reOle, &txtDoc, &txtSel); hres = ITextDocument_Open(txtDoc, &testfile, tomReadOnly, 1200); -todo_wine - ok(hres == S_OK, "got 0x%08x\n", hres); + todo_wine + ok(hres == S_OK, "got 0x%08lx\n", hres); result = SendMessageW(w, WM_GETTEXT, 1024, (LPARAM)bufUnicode); todo_wine ok(result == 12, "ITextDocument_Open: Test UTF-16 returned %d, expected 12\n", result); result = lstrcmpW(bufUnicode, &chUTF16[1]); @@ -602,73 +1190,73 @@ static void test_GetText(void) /* ITextRange */ hres = ITextDocument_Range(txtDoc, 0, 4, &range); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); hres = ITextRange_GetText(range, &bstr); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); ok(!lstrcmpW(bstr, bufW1), "got wrong text: %s\n", wine_dbgstr_w(bstr)); SysFreeString(bstr); ITextRange_Release(range); hres = ITextDocument_Range(txtDoc, 4, 0, &range); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); hres = ITextRange_GetText(range, &bstr); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); ok(!lstrcmpW(bstr, bufW1), "got wrong text: %s\n", wine_dbgstr_w(bstr)); SysFreeString(bstr); ITextRange_Release(range); hres = ITextDocument_Range(txtDoc, 1, 1, &range); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); hres = ITextRange_GetText(range, &bstr); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); ok(!bstr, "got wrong text: %s\n", wine_dbgstr_w(bstr)); if (!is64bit) { hres = ITextRange_GetText(range, NULL); - ok(hres == E_INVALIDARG, "got 0x%08x\n", hres); + ok(hres == E_INVALIDARG, "got 0x%08lx\n", hres); } ITextRange_Release(range); hres = ITextDocument_Range(txtDoc, 8, 12, &range); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); hres = ITextRange_GetText(range, &bstr); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); ok(!lstrcmpW(bstr, bufW3), "got wrong text: %s\n", wine_dbgstr_w(bstr)); SysFreeString(bstr); ITextRange_Release(range); hres = ITextDocument_Range(txtDoc, 8, 13, &range); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); hres = ITextRange_GetText(range, &bstr); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); ok(!lstrcmpW(bstr, bufW2), "got wrong text: %s\n", wine_dbgstr_w(bstr)); SysFreeString(bstr); ITextRange_Release(range); hres = ITextDocument_Range(txtDoc, 12, 13, &range); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); hres = ITextRange_GetText(range, &bstr); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); ok(!lstrcmpW(bstr, bufW5), "got wrong text: %s\n", wine_dbgstr_w(bstr)); SysFreeString(bstr); ITextRange_Release(range); hres = ITextDocument_Range(txtDoc, 0, -1, &range); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); hres = ITextRange_GetText(range, &bstr); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); ok(!bstr, "got wrong text: %s\n", wine_dbgstr_w(bstr)); ITextRange_Release(range); hres = ITextDocument_Range(txtDoc, -1, 9, &range); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); hres = ITextRange_GetText(range, &bstr); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); ok(!lstrcmpW(bstr, bufW6), "got wrong text: %s\n", wine_dbgstr_w(bstr)); SysFreeString(bstr); @@ -679,22 +1267,22 @@ static void test_GetText(void) if (is64bit) { bstr = (void*)0xdeadbeef; hres = ITextSelection_GetText(txtSel, &bstr); - ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres); -todo_wine + ok(hres == CO_E_RELEASED, "got 0x%08lx\n", hres); + todo_wine ok(bstr == NULL, "got %p\n", bstr); bstr = (void*)0xdeadbeef; hres = ITextRange_GetText(range, &bstr); - ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres); -todo_wine + ok(hres == CO_E_RELEASED, "got 0x%08lx\n", hres); + todo_wine ok(bstr == NULL, "got %p\n", bstr); } else { hres = ITextSelection_GetText(txtSel, NULL); - ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres); + ok(hres == CO_E_RELEASED, "got 0x%08lx\n", hres); hres = ITextRange_GetText(range, NULL); - ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres); + ok(hres == CO_E_RELEASED, "got 0x%08lx\n", hres); } ITextRange_Release(range); @@ -713,28 +1301,28 @@ static void test_ITextDocument_Range(void) create_interfaces(&w, &reOle, &txtDoc, NULL); hres = ITextDocument_Range(txtDoc, 0, 0, &txtRge); - ok(hres == S_OK, "ITextDocument_Range fails 0x%x.\n", hres); + ok(hres == S_OK, "ITextDocument_Range fails 0x%lx.\n", hres); EXPECT_REF(txtRge, 1); hres = ITextDocument_Range(txtDoc, 0, 0, &range2); - ok(hres == S_OK, "ITextDocument_Range fails 0x%x.\n", hres); + ok(hres == S_OK, "ITextDocument_Range fails 0x%lx.\n", hres); ok(range2 != txtRge, "A new pointer should be returned\n"); ITextRange_Release(range2); hres = ITextDocument_Range(txtDoc, 0, 0, NULL); - ok(hres == E_INVALIDARG, "ITextDocument_Range should fail 0x%x.\n", hres); + ok(hres == E_INVALIDARG, "ITextDocument_Range should fail 0x%lx.\n", hres); SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1); hres = ITextDocument_Range(txtDoc, 8, 30, &range2); - ok(hres == S_OK, "ITextDocument_Range fails 0x%x.\n", hres); + ok(hres == S_OK, "ITextDocument_Range fails 0x%lx.\n", hres); hres = ITextRange_GetStart(range2, &value); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(value == 8, "got %d\n", value); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(value == 8, "got %ld\n", value); hres = ITextRange_GetEnd(range2, &value); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(value == 13, "got %d\n", value); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(value == 13, "got %ld\n", value); ITextRange_Release(range2); release_interfaces(&w, &reOle, &txtDoc, NULL); @@ -758,11 +1346,11 @@ static void test_ITextRange_GetChar(void) create_interfaces(&w, &reOle, &txtDoc, NULL); SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1); hres = ITextDocument_Range(txtDoc, first, lim, &txtRge); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); pch = 0xdeadbeef; hres = ITextRange_GetChar(txtRge, &pch); ok(hres == S_OK, "ITextRange_GetChar\n"); - ok(pch == 'T', "got wrong char: %c\n", pch); + ok(pch == 'T', "got wrong char: %c\n", (char)pch); ITextRange_Release(txtRge); release_interfaces(&w, &reOle, &txtDoc, NULL); @@ -770,11 +1358,11 @@ static void test_ITextRange_GetChar(void) create_interfaces(&w, &reOle, &txtDoc, NULL); SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1); hres = ITextDocument_Range(txtDoc, first, lim, &txtRge); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); pch = 0xdeadbeef; hres = ITextRange_GetChar(txtRge, &pch); ok(hres == S_OK, "ITextRange_GetChar\n"); - ok(pch == 'T', "got wrong char: %c\n", pch); + ok(pch == 'T', "got wrong char: %c\n", (char)pch); ITextRange_Release(txtRge); release_interfaces(&w, &reOle, &txtDoc, NULL); @@ -782,11 +1370,11 @@ static void test_ITextRange_GetChar(void) create_interfaces(&w, &reOle, &txtDoc, NULL); SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1); hres = ITextDocument_Range(txtDoc, first, lim, &txtRge); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); pch = 0xdeadbeef; hres = ITextRange_GetChar(txtRge, &pch); ok(hres == S_OK, "ITextRange_GetChar\n"); - ok(pch == '\r', "got wrong char: %c\n", pch); + ok(pch == '\r', "got wrong char: %c\n", (char)pch); ITextRange_Release(txtRge); release_interfaces(&w, &reOle, &txtDoc, NULL); @@ -794,11 +1382,11 @@ static void test_ITextRange_GetChar(void) create_interfaces(&w, &reOle, &txtDoc, NULL); SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1); hres = ITextDocument_Range(txtDoc, first, lim, &txtRge); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); pch = 0xdeadbeef; hres = ITextRange_GetChar(txtRge, &pch); ok(hres == S_OK, "ITextRange_GetChar\n"); - ok(pch == '\r', "got wrong char: %c\n", pch); + ok(pch == '\r', "got wrong char: %c\n", (char)pch); ITextRange_Release(txtRge); release_interfaces(&w, &reOle, &txtDoc, NULL); @@ -806,17 +1394,17 @@ static void test_ITextRange_GetChar(void) SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1); first = 12; lim = 12; hres = ITextDocument_Range(txtDoc, first, lim, &txtRge); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); hres = ITextRange_GetChar(txtRge, NULL); ok(hres == E_INVALIDARG, "ITextRange_GetChar\n"); release_interfaces(&w, &reOle, &txtDoc, NULL); hres = ITextRange_GetChar(txtRge, NULL); - ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres); + ok(hres == CO_E_RELEASED, "got 0x%08lx\n", hres); hres = ITextRange_GetChar(txtRge, &pch); - ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres); + ok(hres == CO_E_RELEASED, "got 0x%08lx\n", hres); ITextRange_Release(txtRge); } @@ -833,9 +1421,9 @@ static void check_range(HWND w, ITextDocument* doc, int first, int lim, si.fMask = SIF_POS | SIF_RANGE; hres = ITextDocument_Range(doc, first, lim, &txtRge); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); hres = ITextRange_ScrollIntoView(txtRge, bStart); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); GetScrollInfo(w, SB_VERT, &si); if (expected_nonzero) { ok(si.nPos != 0, @@ -877,10 +1465,10 @@ static void test_ITextRange_ScrollIntoView(void) check_range(w, txtDoc, 0, 20, tomEnd, 1); hres = ITextDocument_Range(txtDoc, 0, 0, &txtRge); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); release_interfaces(&w, &reOle, &txtDoc, NULL); hres = ITextRange_ScrollIntoView(txtRge, tomStart); - ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres); + ok(hres == CO_E_RELEASED, "got 0x%08lx\n", hres); ITextRange_Release(txtRge); } @@ -903,28 +1491,28 @@ static void test_ITextSelection_GetChar(void) pch = 0xdeadbeef; hres = ITextSelection_GetChar(txtSel, &pch); ok(hres == S_OK, "ITextSelection_GetChar\n"); - ok(pch == 'T', "got wrong char: %c\n", pch); + ok(pch == 'T', "got wrong char: %c\n", (char)pch); first = 0; lim = 0; SendMessageA(w, EM_SETSEL, first, lim); pch = 0xdeadbeef; hres = ITextSelection_GetChar(txtSel, &pch); ok(hres == S_OK, "ITextSelection_GetChar\n"); - ok(pch == 'T', "got wrong char: %c\n", pch); + ok(pch == 'T', "got wrong char: %c\n", (char)pch); first = 12; lim = 12; SendMessageA(w, EM_SETSEL, first, lim); pch = 0xdeadbeef; hres = ITextSelection_GetChar(txtSel, &pch); ok(hres == S_OK, "ITextSelection_GetChar\n"); - ok(pch == '\r', "got wrong char: %c\n", pch); + ok(pch == '\r', "got wrong char: %c\n", (char)pch); first = 13; lim = 13; SendMessageA(w, EM_SETSEL, first, lim); pch = 0xdeadbeef; hres = ITextSelection_GetChar(txtSel, &pch); ok(hres == S_OK, "ITextSelection_GetChar\n"); - ok(pch == '\r', "got wrong char: %c\n", pch); + ok(pch == '\r', "got wrong char: %c\n", (char)pch); hres = ITextSelection_GetChar(txtSel, NULL); ok(hres == E_INVALIDARG, "ITextSelection_GetChar\n"); @@ -932,10 +1520,10 @@ static void test_ITextSelection_GetChar(void) release_interfaces(&w, &reOle, &txtDoc, NULL); hres = ITextSelection_GetChar(txtSel, NULL); - ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres); + ok(hres == CO_E_RELEASED, "got 0x%08lx\n", hres); hres = ITextSelection_GetChar(txtSel, &pch); - ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres); + ok(hres == CO_E_RELEASED, "got 0x%08lx\n", hres); ITextSelection_Release(txtSel); } @@ -947,7 +1535,8 @@ static void test_ITextRange_GetStart_GetEnd(void) ITextDocument *txtDoc = NULL; ITextRange *txtRge = NULL; HRESULT hres; - int first, lim, start, end; + int first, lim; + LONG start, end; static const CHAR test_text1[] = "TestSomeText"; create_interfaces(&w, &reOle, &txtDoc, NULL); @@ -955,206 +1544,206 @@ static void test_ITextRange_GetStart_GetEnd(void) first = 1; lim = 6; hres = ITextDocument_Range(txtDoc, first, lim, &txtRge); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); start = 0xdeadbeef; hres = ITextRange_GetStart(txtRge, &start); ok(hres == S_OK, "ITextRange_GetStart\n"); - ok(start == 1, "got wrong start value: %d\n", start); + ok(start == 1, "got wrong start value: %ld\n", start); end = 0xdeadbeef; hres = ITextRange_GetEnd(txtRge, &end); ok(hres == S_OK, "ITextRange_GetEnd\n"); - ok(end == 6, "got wrong end value: %d\n", end); + ok(end == 6, "got wrong end value: %ld\n", end); ITextRange_Release(txtRge); first = 6; lim = 1; hres = ITextDocument_Range(txtDoc, first, lim, &txtRge); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); start = 0xdeadbeef; hres = ITextRange_GetStart(txtRge, &start); ok(hres == S_OK, "ITextRange_GetStart\n"); - ok(start == 1, "got wrong start value: %d\n", start); + ok(start == 1, "got wrong start value: %ld\n", start); end = 0xdeadbeef; hres = ITextRange_GetEnd(txtRge, &end); ok(hres == S_OK, "ITextRange_GetEnd\n"); - ok(end == 6, "got wrong end value: %d\n", end); + ok(end == 6, "got wrong end value: %ld\n", end); ITextRange_Release(txtRge); first = -1; lim = 13; hres = ITextDocument_Range(txtDoc, first, lim, &txtRge); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); start = 0xdeadbeef; hres = ITextRange_GetStart(txtRge, &start); ok(hres == S_OK, "ITextRange_GetStart\n"); - ok(start == 0, "got wrong start value: %d\n", start); + ok(start == 0, "got wrong start value: %ld\n", start); end = 0xdeadbeef; hres = ITextRange_GetEnd(txtRge, &end); ok(hres == S_OK, "ITextRange_GetEnd\n"); - ok(end == 13, "got wrong end value: %d\n", end); + ok(end == 13, "got wrong end value: %ld\n", end); ITextRange_Release(txtRge); first = 13; lim = 13; hres = ITextDocument_Range(txtDoc, first, lim, &txtRge); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); start = 0xdeadbeef; hres = ITextRange_GetStart(txtRge, &start); ok(hres == S_OK, "ITextRange_GetStart\n"); - ok(start == 12, "got wrong start value: %d\n", start); + ok(start == 12, "got wrong start value: %ld\n", start); end = 0xdeadbeef; hres = ITextRange_GetEnd(txtRge, &end); ok(hres == S_OK, "ITextRange_GetEnd\n"); - ok(end == 12, "got wrong end value: %d\n", end); + ok(end == 12, "got wrong end value: %ld\n", end); /* SetStart */ hres = ITextRange_SetStart(txtRge, 0); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); /* same value */ hres = ITextRange_SetStart(txtRge, 0); - ok(hres == S_FALSE, "got 0x%08x\n", hres); + ok(hres == S_FALSE, "got 0x%08lx\n", hres); hres = ITextRange_SetStart(txtRge, 1); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); /* negative resets to 0, return value is S_FALSE when position wasn't changed */ hres = ITextRange_SetStart(txtRge, -1); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); hres = ITextRange_SetStart(txtRge, -1); - ok(hres == S_FALSE, "got 0x%08x\n", hres); + ok(hres == S_FALSE, "got 0x%08lx\n", hres); hres = ITextRange_SetStart(txtRge, 0); - ok(hres == S_FALSE, "got 0x%08x\n", hres); + ok(hres == S_FALSE, "got 0x%08lx\n", hres); start = -1; hres = ITextRange_GetStart(txtRge, &start); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(start == 0, "got %d\n", start); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(start == 0, "got %ld\n", start); /* greater than initial end, but less than total char count */ hres = ITextRange_SetStart(txtRge, 1); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); hres = ITextRange_SetEnd(txtRge, 3); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); hres = ITextRange_SetStart(txtRge, 10); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); start = 0; hres = ITextRange_GetStart(txtRge, &start); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(start == 10, "got %d\n", start); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(start == 10, "got %ld\n", start); end = 0; hres = ITextRange_GetEnd(txtRge, &end); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(end == 10, "got %d\n", end); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(end == 10, "got %ld\n", end); /* more that total text length */ hres = ITextRange_SetStart(txtRge, 50); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); start = 0; hres = ITextRange_GetStart(txtRge, &start); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(start == 12, "got %d\n", start); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(start == 12, "got %ld\n", start); end = 0; hres = ITextRange_GetEnd(txtRge, &end); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(end == 12, "got %d\n", end); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(end == 12, "got %ld\n", end); /* SetEnd */ hres = ITextRange_SetStart(txtRge, 0); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); /* same value */ hres = ITextRange_SetEnd(txtRge, 5); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); hres = ITextRange_SetEnd(txtRge, 5); - ok(hres == S_FALSE, "got 0x%08x\n", hres); + ok(hres == S_FALSE, "got 0x%08lx\n", hres); /* negative resets to 0 */ hres = ITextRange_SetEnd(txtRge, -1); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); end = -1; hres = ITextRange_GetEnd(txtRge, &end); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(end == 0, "got %d\n", end); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(end == 0, "got %ld\n", end); start = -1; hres = ITextRange_GetStart(txtRge, &start); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(start == 0, "got %d\n", start); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(start == 0, "got %ld\n", start); /* greater than initial end, but less than total char count */ hres = ITextRange_SetStart(txtRge, 3); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); hres = ITextRange_SetEnd(txtRge, 1); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); start = 0; hres = ITextRange_GetStart(txtRge, &start); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(start == 1, "got %d\n", start); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(start == 1, "got %ld\n", start); end = 0; hres = ITextRange_GetEnd(txtRge, &end); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(end == 1, "got %d\n", end); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(end == 1, "got %ld\n", end); /* more than total count */ hres = ITextRange_SetEnd(txtRge, 50); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); start = 0; hres = ITextRange_GetStart(txtRge, &start); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(start == 1, "got %d\n", start); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(start == 1, "got %ld\n", start); end = 0; hres = ITextRange_GetEnd(txtRge, &end); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(end == 13, "got %d\n", end); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(end == 13, "got %ld\n", end); /* zero */ hres = ITextRange_SetEnd(txtRge, 0); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); start = 0; hres = ITextRange_GetStart(txtRge, &start); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(start == 0, "got %d\n", start); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(start == 0, "got %ld\n", start); end = 0; hres = ITextRange_GetEnd(txtRge, &end); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(end == 0, "got %d\n", end); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(end == 0, "got %ld\n", end); release_interfaces(&w, &reOle, &txtDoc, NULL); /* detached range */ hres = ITextRange_SetStart(txtRge, 0); - ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres); + ok(hres == CO_E_RELEASED, "got 0x%08lx\n", hres); hres = ITextRange_SetEnd(txtRge, 3); - ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres); + ok(hres == CO_E_RELEASED, "got 0x%08lx\n", hres); hres = ITextRange_GetStart(txtRge, &start); - ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres); + ok(hres == CO_E_RELEASED, "got 0x%08lx\n", hres); hres = ITextRange_GetStart(txtRge, NULL); - ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres); + ok(hres == CO_E_RELEASED, "got 0x%08lx\n", hres); hres = ITextRange_GetEnd(txtRge, &end); - ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres); + ok(hres == CO_E_RELEASED, "got 0x%08lx\n", hres); hres = ITextRange_GetEnd(txtRge, NULL); - ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres); + ok(hres == CO_E_RELEASED, "got 0x%08lx\n", hres); ITextRange_Release(txtRge); } @@ -1166,7 +1755,8 @@ static void test_ITextSelection_GetStart_GetEnd(void) ITextDocument *txtDoc = NULL; ITextSelection *txtSel = NULL; HRESULT hres; - int first, lim, start, end; + int first, lim; + LONG start, end; static const CHAR test_text1[] = "TestSomeText"; create_interfaces(&w, &reOle, &txtDoc, &txtSel); @@ -1177,190 +1767,190 @@ static void test_ITextSelection_GetStart_GetEnd(void) start = 0xdeadbeef; hres = ITextSelection_GetStart(txtSel, &start); ok(hres == S_OK, "ITextSelection_GetStart\n"); - ok(start == 2, "got wrong start value: %d\n", start); + ok(start == 2, "got wrong start value: %ld\n", start); end = 0xdeadbeef; hres = ITextSelection_GetEnd(txtSel, &end); ok(hres == S_OK, "ITextSelection_GetEnd\n"); - ok(end == 5, "got wrong end value: %d\n", end); + ok(end == 5, "got wrong end value: %ld\n", end); first = 5; lim = 2; SendMessageA(w, EM_SETSEL, first, lim); start = 0xdeadbeef; hres = ITextSelection_GetStart(txtSel, &start); ok(hres == S_OK, "ITextSelection_GetStart\n"); - ok(start == 2, "got wrong start value: %d\n", start); + ok(start == 2, "got wrong start value: %ld\n", start); end = 0xdeadbeef; hres = ITextSelection_GetEnd(txtSel, &end); ok(hres == S_OK, "ITextSelection_GetEnd\n"); - ok(end == 5, "got wrong end value: %d\n", end); + ok(end == 5, "got wrong end value: %ld\n", end); first = 0; lim = -1; SendMessageA(w, EM_SETSEL, first, lim); start = 0xdeadbeef; hres = ITextSelection_GetStart(txtSel, &start); ok(hres == S_OK, "ITextSelection_GetStart\n"); - ok(start == 0, "got wrong start value: %d\n", start); + ok(start == 0, "got wrong start value: %ld\n", start); end = 0xdeadbeef; hres = ITextSelection_GetEnd(txtSel, &end); ok(hres == S_OK, "ITextSelection_GetEnd\n"); - ok(end == 13, "got wrong end value: %d\n", end); + ok(end == 13, "got wrong end value: %ld\n", end); first = 13; lim = 13; SendMessageA(w, EM_SETSEL, first, lim); start = 0xdeadbeef; hres = ITextSelection_GetStart(txtSel, &start); ok(hres == S_OK, "ITextSelection_GetStart\n"); - ok(start == 12, "got wrong start value: %d\n", start); + ok(start == 12, "got wrong start value: %ld\n", start); end = 0xdeadbeef; hres = ITextSelection_GetEnd(txtSel, &end); ok(hres == S_OK, "ITextSelection_GetEnd\n"); - ok(end == 12, "got wrong end value: %d\n", end); + ok(end == 12, "got wrong end value: %ld\n", end); /* SetStart/SetEnd */ hres = ITextSelection_SetStart(txtSel, 0); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); /* same value */ hres = ITextSelection_SetStart(txtSel, 0); - ok(hres == S_FALSE, "got 0x%08x\n", hres); + ok(hres == S_FALSE, "got 0x%08lx\n", hres); hres = ITextSelection_SetStart(txtSel, 1); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); /* negative resets to 0, return value is S_FALSE when position wasn't changed */ hres = ITextSelection_SetStart(txtSel, -1); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); hres = ITextSelection_SetStart(txtSel, -1); - ok(hres == S_FALSE, "got 0x%08x\n", hres); + ok(hres == S_FALSE, "got 0x%08lx\n", hres); hres = ITextSelection_SetStart(txtSel, 0); - ok(hres == S_FALSE, "got 0x%08x\n", hres); + ok(hres == S_FALSE, "got 0x%08lx\n", hres); start = -1; hres = ITextSelection_GetStart(txtSel, &start); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(start == 0, "got %d\n", start); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(start == 0, "got %ld\n", start); /* greater than initial end, but less than total char count */ hres = ITextSelection_SetStart(txtSel, 1); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); hres = ITextSelection_SetEnd(txtSel, 3); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); hres = ITextSelection_SetStart(txtSel, 10); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); start = 0; hres = ITextSelection_GetStart(txtSel, &start); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(start == 10, "got %d\n", start); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(start == 10, "got %ld\n", start); end = 0; hres = ITextSelection_GetEnd(txtSel, &end); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(end == 10, "got %d\n", end); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(end == 10, "got %ld\n", end); /* more that total text length */ hres = ITextSelection_SetStart(txtSel, 50); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); start = 0; hres = ITextSelection_GetStart(txtSel, &start); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(start == 12, "got %d\n", start); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(start == 12, "got %ld\n", start); end = 0; hres = ITextSelection_GetEnd(txtSel, &end); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(end == 12, "got %d\n", end); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(end == 12, "got %ld\n", end); /* SetEnd */ hres = ITextSelection_SetStart(txtSel, 0); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); /* same value */ hres = ITextSelection_SetEnd(txtSel, 5); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); hres = ITextSelection_SetEnd(txtSel, 5); - ok(hres == S_FALSE, "got 0x%08x\n", hres); + ok(hres == S_FALSE, "got 0x%08lx\n", hres); /* negative resets to 0 */ hres = ITextSelection_SetEnd(txtSel, -1); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); end = -1; hres = ITextSelection_GetEnd(txtSel, &end); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(end == 0, "got %d\n", end); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(end == 0, "got %ld\n", end); start = -1; hres = ITextSelection_GetStart(txtSel, &start); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(start == 0, "got %d\n", start); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(start == 0, "got %ld\n", start); /* greater than initial end, but less than total char count */ hres = ITextSelection_SetStart(txtSel, 3); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); hres = ITextSelection_SetEnd(txtSel, 1); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); start = 0; hres = ITextSelection_GetStart(txtSel, &start); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(start == 1, "got %d\n", start); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(start == 1, "got %ld\n", start); end = 0; hres = ITextSelection_GetEnd(txtSel, &end); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(end == 1, "got %d\n", end); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(end == 1, "got %ld\n", end); /* more than total count */ hres = ITextSelection_SetEnd(txtSel, 50); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); start = 0; hres = ITextSelection_GetStart(txtSel, &start); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(start == 1, "got %d\n", start); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(start == 1, "got %ld\n", start); end = 0; hres = ITextSelection_GetEnd(txtSel, &end); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(end == 13, "got %d\n", end); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(end == 13, "got %ld\n", end); /* zero */ hres = ITextSelection_SetEnd(txtSel, 0); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); start = 0; hres = ITextSelection_GetStart(txtSel, &start); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(start == 0, "got %d\n", start); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(start == 0, "got %ld\n", start); end = 0; hres = ITextSelection_GetEnd(txtSel, &end); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(end == 0, "got %d\n", end); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(end == 0, "got %ld\n", end); release_interfaces(&w, &reOle, &txtDoc, NULL); /* detached selection */ hres = ITextSelection_GetStart(txtSel, NULL); - ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres); + ok(hres == CO_E_RELEASED, "got 0x%08lx\n", hres); hres = ITextSelection_GetStart(txtSel, &start); - ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres); + ok(hres == CO_E_RELEASED, "got 0x%08lx\n", hres); hres = ITextSelection_GetEnd(txtSel, NULL); - ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres); + ok(hres == CO_E_RELEASED, "got 0x%08lx\n", hres); hres = ITextSelection_GetEnd(txtSel, &end); - ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres); + ok(hres == CO_E_RELEASED, "got 0x%08lx\n", hres); ITextSelection_Release(txtSel); } @@ -1380,17 +1970,17 @@ static void test_ITextRange_GetDuplicate(void) SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1); first = 0; lim = 4; hres = ITextDocument_Range(txtDoc, first, lim, &txtRge); - ok(hres == S_OK, "ITextDocument_Range fails 0x%x.\n", hres); + ok(hres == S_OK, "ITextDocument_Range fails 0x%lx.\n", hres); hres = ITextRange_GetDuplicate(txtRge, &txtRgeDup); ok(hres == S_OK, "ITextRange_GetDuplicate\n"); ok(txtRgeDup != txtRge, "A new pointer should be returned\n"); hres = ITextRange_GetStart(txtRgeDup, &start); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(start == first, "got wrong value: %d\n", start); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(start == first, "got wrong value: %ld\n", start); hres = ITextRange_GetEnd(txtRgeDup, &end); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(end == lim, "got wrong value: %d\n", end); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(end == lim, "got wrong value: %ld\n", end); ITextRange_Release(txtRgeDup); @@ -1400,10 +1990,10 @@ static void test_ITextRange_GetDuplicate(void) release_interfaces(&w, &reOle, &txtDoc, NULL); hres = ITextRange_GetDuplicate(txtRge, NULL); - ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres); + ok(hres == CO_E_RELEASED, "got 0x%08lx\n", hres); hres = ITextRange_GetDuplicate(txtRge, &txtRgeDup); - ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres); + ok(hres == CO_E_RELEASED, "got 0x%08lx\n", hres); ITextRange_Release(txtRge); } @@ -1423,98 +2013,98 @@ static void test_ITextRange_Collapse(void) first = 4; lim = 8; hres = ITextDocument_Range(txtDoc, first, lim, &txtRge); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); hres = ITextRange_Collapse(txtRge, tomTrue); ok(hres == S_OK, "ITextRange_Collapse\n"); hres = ITextRange_GetStart(txtRge, &start); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(start == 4, "got wrong start value: %d\n", start); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(start == 4, "got wrong start value: %ld\n", start); hres = ITextRange_GetEnd(txtRge, &end); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(end == 4, "got wrong end value: %d\n", end); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(end == 4, "got wrong end value: %ld\n", end); ITextRange_Release(txtRge); hres = ITextDocument_Range(txtDoc, first, lim, &txtRge); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); hres = ITextRange_Collapse(txtRge, tomStart); ok(hres == S_OK, "ITextRange_Collapse\n"); hres = ITextRange_GetStart(txtRge, &start); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(start == 4, "got wrong start value: %d\n", start); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(start == 4, "got wrong start value: %ld\n", start); hres = ITextRange_GetEnd(txtRge, &end); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(end == 4, "got wrong end value: %d\n", end); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(end == 4, "got wrong end value: %ld\n", end); ITextRange_Release(txtRge); hres = ITextDocument_Range(txtDoc, first, lim, &txtRge); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); hres = ITextRange_Collapse(txtRge, tomFalse); ok(hres == S_OK, "ITextRange_Collapse\n"); hres = ITextRange_GetStart(txtRge, &start); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(start == 8, "got wrong start value: %d\n", start); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(start == 8, "got wrong start value: %ld\n", start); hres = ITextRange_GetEnd(txtRge, &end); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(end == 8, "got wrong end value: %d\n", end); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(end == 8, "got wrong end value: %ld\n", end); ITextRange_Release(txtRge); hres = ITextDocument_Range(txtDoc, first, lim, &txtRge); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); hres = ITextRange_Collapse(txtRge, tomEnd); ok(hres == S_OK, "ITextRange_Collapse\n"); hres = ITextRange_GetStart(txtRge, &start); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(start == 8, "got wrong start value: %d\n", start); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(start == 8, "got wrong start value: %ld\n", start); hres = ITextRange_GetEnd(txtRge, &end); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(end == 8, "got wrong end value: %d\n", end); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(end == 8, "got wrong end value: %ld\n", end); ITextRange_Release(txtRge); /* tomStart is the default */ hres = ITextDocument_Range(txtDoc, first, lim, &txtRge); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); hres = ITextRange_Collapse(txtRge, 256); ok(hres == S_OK, "ITextRange_Collapse\n"); hres = ITextRange_GetStart(txtRge, &start); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(start == 4, "got wrong start value: %d\n", start); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(start == 4, "got wrong start value: %ld\n", start); hres = ITextRange_GetEnd(txtRge, &end); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(end == 4, "got wrong end value: %d\n", end); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(end == 4, "got wrong end value: %ld\n", end); ITextRange_Release(txtRge); first = 6; lim = 6; hres = ITextDocument_Range(txtDoc, first, lim, &txtRge); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); hres = ITextRange_Collapse(txtRge, tomEnd); ok(hres == S_FALSE, "ITextRange_Collapse\n"); hres = ITextRange_GetStart(txtRge, &start); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(start == 6, "got wrong start value: %d\n", start); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(start == 6, "got wrong start value: %ld\n", start); hres = ITextRange_GetEnd(txtRge, &end); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(end == 6, "got wrong end value: %d\n", end); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(end == 6, "got wrong end value: %ld\n", end); ITextRange_Release(txtRge); first = 8; lim = 8; hres = ITextDocument_Range(txtDoc, first, lim, &txtRge); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); hres = ITextRange_Collapse(txtRge, tomStart); ok(hres == S_FALSE, "ITextRange_Collapse\n"); hres = ITextRange_GetStart(txtRge, &start); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(start == 8, "got wrong start value: %d\n", start); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(start == 8, "got wrong start value: %ld\n", start); hres = ITextRange_GetEnd(txtRge, &end); - ok(hres == S_OK, "got 0x%08x\n", hres); - ok(end == 8, "got wrong end value: %d\n", end); + ok(hres == S_OK, "got 0x%08lx\n", hres); + ok(end == 8, "got wrong end value: %ld\n", end); release_interfaces(&w, &reOle, &txtDoc, NULL); hres = ITextRange_Collapse(txtRge, tomStart); - ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres); + ok(hres == CO_E_RELEASED, "got 0x%08lx\n", hres); hres = ITextRange_Collapse(txtRge, tomUndefined); - ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres); + ok(hres == CO_E_RELEASED, "got 0x%08lx\n", hres); ITextRange_Release(txtRge); } @@ -1537,61 +2127,61 @@ static void test_ITextSelection_Collapse(void) hres = ITextSelection_Collapse(txtSel, tomTrue); ok(hres == S_OK, "ITextSelection_Collapse\n"); SendMessageA(w, EM_GETSEL, (LPARAM)&start, (WPARAM)&end); - ok(start == 4, "got wrong start value: %d\n", start); - ok(end == 4, "got wrong end value: %d\n", end); + ok(start == 4, "got wrong start value: %ld\n", start); + ok(end == 4, "got wrong end value: %ld\n", end); SendMessageA(w, EM_SETSEL, first, lim); hres = ITextSelection_Collapse(txtSel, tomStart); ok(hres == S_OK, "ITextSelection_Collapse\n"); SendMessageA(w, EM_GETSEL, (LPARAM)&start, (WPARAM)&end); - ok(start == 4, "got wrong start value: %d\n", start); - ok(end == 4, "got wrong end value: %d\n", end); + ok(start == 4, "got wrong start value: %ld\n", start); + ok(end == 4, "got wrong end value: %ld\n", end); SendMessageA(w, EM_SETSEL, first, lim); hres = ITextSelection_Collapse(txtSel, tomFalse); ok(hres == S_OK, "ITextSelection_Collapse\n"); SendMessageA(w, EM_GETSEL, (LPARAM)&start, (WPARAM)&end); - ok(start == 8, "got wrong start value: %d\n", start); - ok(end == 8, "got wrong end value: %d\n", end); + ok(start == 8, "got wrong start value: %ld\n", start); + ok(end == 8, "got wrong end value: %ld\n", end); SendMessageA(w, EM_SETSEL, first, lim); hres = ITextSelection_Collapse(txtSel, tomEnd); ok(hres == S_OK, "ITextSelection_Collapse\n"); SendMessageA(w, EM_GETSEL, (LPARAM)&start, (WPARAM)&end); - ok(start == 8, "got wrong start value: %d\n", start); - ok(end == 8, "got wrong end value: %d\n", end); + ok(start == 8, "got wrong start value: %ld\n", start); + ok(end == 8, "got wrong end value: %ld\n", end); /* tomStart is the default */ SendMessageA(w, EM_SETSEL, first, lim); hres = ITextSelection_Collapse(txtSel, 256); ok(hres == S_OK, "ITextSelection_Collapse\n"); SendMessageA(w, EM_GETSEL, (LPARAM)&start, (WPARAM)&end); - ok(start == 4, "got wrong start value: %d\n", start); - ok(end == 4, "got wrong end value: %d\n", end); + ok(start == 4, "got wrong start value: %ld\n", start); + ok(end == 4, "got wrong end value: %ld\n", end); first = 6; lim = 6; SendMessageA(w, EM_SETSEL, first, lim); hres = ITextSelection_Collapse(txtSel, tomEnd); ok(hres == S_FALSE, "ITextSelection_Collapse\n"); SendMessageA(w, EM_GETSEL, (LPARAM)&start, (WPARAM)&end); - ok(start == 6, "got wrong start value: %d\n", start); - ok(end == 6, "got wrong end value: %d\n", end); + ok(start == 6, "got wrong start value: %ld\n", start); + ok(end == 6, "got wrong end value: %ld\n", end); first = 8; lim = 8; SendMessageA(w, EM_SETSEL, first, lim); hres = ITextSelection_Collapse(txtSel, tomStart); ok(hres == S_FALSE, "ITextSelection_Collapse\n"); SendMessageA(w, EM_GETSEL, (LPARAM)&start, (WPARAM)&end); - ok(start == 8, "got wrong start value: %d\n", start); - ok(end == 8, "got wrong end value: %d\n", end); + ok(start == 8, "got wrong start value: %ld\n", start); + ok(end == 8, "got wrong end value: %ld\n", end); release_interfaces(&w, &reOle, &txtDoc, NULL); hres = ITextSelection_Collapse(txtSel, tomStart); - ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres); + ok(hres == CO_E_RELEASED, "got 0x%08lx\n", hres); hres = ITextSelection_Collapse(txtSel, tomUndefined); - ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres); + ok(hres == CO_E_RELEASED, "got 0x%08lx\n", hres); ITextSelection_Release(txtSel); } @@ -1609,54 +2199,54 @@ static void test_GetClientSite(void) create_interfaces(&w, &reOle, &txtDoc, NULL); hres = IRichEditOle_GetClientSite(reOle, &clientSite); - ok(hres == S_OK, "IRichEditOle_QueryInterface: 0x%08x\n", hres); + ok(hres == S_OK, "IRichEditOle_QueryInterface: 0x%08lx\n", hres); EXPECT_REF(clientSite, 1); hres = IOleClientSite_QueryInterface(clientSite, &IID_IRichEditOle, (void **)&reOle1); - ok(hres == E_NOINTERFACE, "IOleClientSite_QueryInterface: %x\n", hres); + ok(hres == E_NOINTERFACE, "IOleClientSite_QueryInterface: %lx\n", hres); hres = IRichEditOle_GetClientSite(reOle, &clientSite1); - ok(hres == S_OK, "got 0x%08x\n", hres); + ok(hres == S_OK, "got 0x%08lx\n", hres); ok(clientSite != clientSite1, "got %p, %p\n", clientSite, clientSite1); IOleClientSite_Release(clientSite1); hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleClientSite, (void **)&clientSite1); - ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres); + ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08lx\n", hres); ok(clientSite == clientSite1, "Should not return a new pointer.\n"); EXPECT_REF(clientSite, 2); /* IOleWindow interface */ hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleWindow, (void **)&oleWin); - ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres); + ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08lx\n", hres); refcount1 = get_refcount((IUnknown *)clientSite); refcount2 = get_refcount((IUnknown *)oleWin); ok(refcount1 == refcount2, "got wrong ref count.\n"); hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleWindow, (void **)&oleWin1); - ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres); + ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08lx\n", hres); ok(oleWin == oleWin1, "Should not return a new pointer.\n"); refcount1 = get_refcount((IUnknown *)clientSite); refcount2 = get_refcount((IUnknown *)oleWin); ok(refcount1 == refcount2, "got wrong ref count.\n"); hres = IOleWindow_QueryInterface(oleWin, &IID_IOleClientSite, (void **)&clientSite2); - ok(hres == S_OK, "IOleWindow_QueryInterface: 0x%08x\n", hres); + ok(hres == S_OK, "IOleWindow_QueryInterface: 0x%08lx\n", hres); ok(clientSite2 == clientSite1, "got wrong pointer\n"); /* IOleInPlaceSite interface */ hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleInPlaceSite, (void **)&olePlace); - ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres); + ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08lx\n", hres); refcount1 = get_refcount((IUnknown *)olePlace); refcount2 = get_refcount((IUnknown *)clientSite); ok(refcount1 == refcount2, "got wrong ref count.\n"); hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleInPlaceSite, (void **)&olePlace1); - ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres); + ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08lx\n", hres); ok(olePlace == olePlace1, "Should not return a new pointer.\n"); IOleInPlaceSite_Release(olePlace1); hres = IOleWindow_QueryInterface(oleWin, &IID_IOleInPlaceSite, (void **)&olePlace1); - ok(hres == S_OK, "IOleWindow_QueryInterface: 0x%08x\n", hres); + ok(hres == S_OK, "IOleWindow_QueryInterface: 0x%08lx\n", hres); refcount1 = get_refcount((IUnknown *)olePlace1); refcount2 = get_refcount((IUnknown *)oleWin); ok(refcount1 == refcount2, "got wrong ref count.\n"); @@ -1683,16 +2273,16 @@ static void test_IOleWindow_GetWindow(void) create_interfaces(&w, &reOle, &txtDoc, NULL); hres = IRichEditOle_GetClientSite(reOle, &clientSite); - ok(hres == S_OK, "IRichEditOle_QueryInterface: 0x%08x\n", hres); + ok(hres == S_OK, "IRichEditOle_QueryInterface: 0x%08lx\n", hres); hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleWindow, (void **)&oleWin); - ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres); + ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08lx\n", hres); hres = IOleWindow_GetWindow(oleWin, &hwnd); - ok(hres == S_OK, "IOleClientSite_GetWindow: 0x%08x\n", hres); + ok(hres == S_OK, "IOleClientSite_GetWindow: 0x%08lx\n", hres); ok(w == hwnd, "got wrong pointer\n"); hres = IOleWindow_GetWindow(oleWin, NULL); - ok(hres == E_INVALIDARG, "IOleClientSite_GetWindow: 0x%08x\n", hres); + ok(hres == E_INVALIDARG, "IOleClientSite_GetWindow: 0x%08lx\n", hres); IOleWindow_Release(oleWin); IOleClientSite_Release(clientSite); @@ -1711,16 +2301,16 @@ static void test_IOleInPlaceSite_GetWindow(void) create_interfaces(&w, &reOle, &txtDoc, NULL); hres = IRichEditOle_GetClientSite(reOle, &clientSite); - ok(hres == S_OK, "IRichEditOle_QueryInterface: 0x%08x\n", hres); + ok(hres == S_OK, "IRichEditOle_QueryInterface: 0x%08lx\n", hres); hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleInPlaceSite, (void **)&olePlace); - ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres); + ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08lx\n", hres); hres = IOleInPlaceSite_GetWindow(olePlace, &hwnd); - ok(hres == S_OK, "IOleInPlaceSite_GetWindow: 0x%08x\n", hres); + ok(hres == S_OK, "IOleInPlaceSite_GetWindow: 0x%08lx\n", hres); ok(w == hwnd, "got wrong pointer.\n"); hres = IOleInPlaceSite_GetWindow(olePlace, NULL); - ok(hres == E_INVALIDARG, "IOleInPlaceSite_GetWindow: 0x%08x\n", hres); + ok(hres == E_INVALIDARG, "IOleInPlaceSite_GetWindow: 0x%08lx\n", hres); IOleInPlaceSite_Release(olePlace); IOleClientSite_Release(clientSite); @@ -1746,11 +2336,11 @@ static void test_GetFont(void) SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1); hr = ITextDocument_GetSelection(doc, &selection); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); hr = ITextSelection_GetFont(selection, &font); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); hr = ITextSelection_GetFont(selection, &font2); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); ok(font != font2, "got %p, %p\n", font, font2); ITextFont_Release(font2); ITextFont_Release(font); @@ -1760,17 +2350,17 @@ static void test_GetFont(void) EXPECT_REF(doc, 3); hr = ITextDocument_Range(doc, 0, 4, &range); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); EXPECT_REF(reOle, 3); EXPECT_REF(doc, 3); EXPECT_REF(range, 1); hr = ITextRange_GetFont(range, NULL); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); hr = ITextRange_GetFont(range, &font); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); EXPECT_REF(reOle, 3); EXPECT_REF(doc, 3); @@ -1778,7 +2368,7 @@ static void test_GetFont(void) EXPECT_REF(font, 1); hr = ITextRange_GetFont(range, &font2); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); ok(font != font2, "got %p, %p\n", font, font2); EXPECT_REF(reOle, 3); @@ -1791,27 +2381,27 @@ static void test_GetFont(void) /* set different font style within a range */ hr = ITextFont_GetItalic(font, NULL); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); hr = ITextFont_GetSize(font, NULL); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); size = 0.0; hr = ITextFont_GetSize(font, &size); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); ok(size > 0.0, "size %.2f\n", size); value = 0; hr = ITextFont_GetLanguageID(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == GetSystemDefaultLCID(), "got lcid %x, user lcid %x\n", value, + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == GetSystemDefaultLCID(), "got lcid %lx, user lcid %lx\n", value, GetSystemDefaultLCID()); /* range is non-italic */ value = tomTrue; hr = ITextFont_GetItalic(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); cf.cbSize = sizeof(CHARFORMAT2A); cf.dwMask = CFM_ITALIC|CFM_SIZE; @@ -1825,22 +2415,22 @@ static void test_GetFont(void) /* now range is partially italicized */ value = tomFalse; hr = ITextFont_GetItalic(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomUndefined, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomUndefined, "got %ld\n", value); size = 0.0; hr = ITextFont_GetSize(font, &size); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); ok(size == tomUndefined, "size %.2f\n", size); ITextFont_Release(font); release_interfaces(&hwnd, &reOle, &doc, NULL); hr = ITextRange_GetFont(range, NULL); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); hr = ITextRange_GetFont(range, &font2); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); ITextRange_Release(range); } @@ -1863,17 +2453,17 @@ static void test_GetPara(void) EXPECT_REF(doc, 3); hr = ITextDocument_Range(doc, 0, 4, &range); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); EXPECT_REF(reOle, 3); EXPECT_REF(doc, 3); EXPECT_REF(range, 1); hr = ITextRange_GetPara(range, NULL); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); hr = ITextRange_GetPara(range, ¶); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); EXPECT_REF(reOle, 3); EXPECT_REF(doc, 3); @@ -1881,7 +2471,7 @@ static void test_GetPara(void) EXPECT_REF(para, 1); hr = ITextRange_GetPara(range, ¶2); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); ok(para != para2, "got %p, %p\n", para, para2); EXPECT_REF(reOle, 3); @@ -1898,7 +2488,7 @@ static void test_GetPara(void) EXPECT_REF(selection, 2); hr = ITextSelection_GetPara(selection, ¶); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); EXPECT_REF(reOle, 3); EXPECT_REF(doc, 3); @@ -1906,7 +2496,7 @@ static void test_GetPara(void) EXPECT_REF(para, 1); hr = ITextSelection_GetPara(selection, ¶2); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); ok(para != para2, "got %p, %p\n", para, para2); ITextPara_Release(para); @@ -1914,16 +2504,16 @@ static void test_GetPara(void) release_interfaces(&hwnd, &reOle, &doc, NULL); hr = ITextRange_GetPara(range, NULL); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); hr = ITextRange_GetPara(range, ¶); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); hr = ITextSelection_GetPara(selection, NULL); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); hr = ITextSelection_GetPara(selection, ¶); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); ITextSelection_Release(selection); ITextRange_Release(range); @@ -1946,32 +2536,32 @@ static void test_dispatch(void) range = NULL; hr = ITextDocument_Range(doc, 0, 0, &range); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); ok(range != NULL, "got %p\n", range); dispid = 123; nameW = (WCHAR*)testnameW; hr = ITextRange_GetIDsOfNames(range, &IID_NULL, &nameW, 1, LOCALE_USER_DEFAULT, &dispid); - ok(hr == DISP_E_UNKNOWNNAME, "got 0x%08x\n", hr); - ok(dispid == DISPID_UNKNOWN, "got %d\n", dispid); + ok(hr == DISP_E_UNKNOWNNAME, "got 0x%08lx\n", hr); + ok(dispid == DISPID_UNKNOWN, "got %ld\n", dispid); dispid = 123; nameW = (WCHAR*)testname2W; hr = ITextRange_GetIDsOfNames(range, &IID_NULL, &nameW, 1, LOCALE_USER_DEFAULT, &dispid); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(dispid == DISPID_VALUE, "got %d\n", dispid); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(dispid == DISPID_VALUE, "got %ld\n", dispid); release_interfaces(&hwnd, &reOle, &doc, NULL); /* try dispatch methods on detached range */ hr = ITextRange_GetTypeInfoCount(range, &count); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); dispid = 123; nameW = (WCHAR*)testname2W; hr = ITextRange_GetIDsOfNames(range, &IID_NULL, &nameW, 1, LOCALE_USER_DEFAULT, &dispid); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(dispid == DISPID_VALUE, "got %d\n", dispid); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(dispid == DISPID_VALUE, "got %ld\n", dispid); ITextRange_Release(range); } @@ -1984,64 +2574,64 @@ static void test_detached_font_getters(ITextFont *font, BOOL duplicate) BSTR str; hr = ITextFont_GetBold(font, NULL); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); hr = ITextFont_GetBold(font, &value); - ok(hr == hrexp, "got 0x%08x\n", hr); + ok(hr == hrexp, "got 0x%08lx\n", hr); hr = ITextFont_GetForeColor(font, NULL); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); hr = ITextFont_GetForeColor(font, &value); - ok(hr == hrexp, "got 0x%08x\n", hr); + ok(hr == hrexp, "got 0x%08lx\n", hr); hr = ITextFont_GetItalic(font, NULL); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); hr = ITextFont_GetItalic(font, &value); - ok(hr == hrexp, "got 0x%08x\n", hr); + ok(hr == hrexp, "got 0x%08lx\n", hr); hr = ITextFont_GetLanguageID(font, NULL); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); hr = ITextFont_GetLanguageID(font, &value); - ok(hr == hrexp, "got 0x%08x\n", hr); + ok(hr == hrexp, "got 0x%08lx\n", hr); hr = ITextFont_GetName(font, NULL); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); hr = ITextFont_GetName(font, &str); - ok(hr == hrexp, "got 0x%08x\n", hr); + ok(hr == hrexp, "got 0x%08lx\n", hr); hr = ITextFont_GetSize(font, NULL); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); hr = ITextFont_GetSize(font, &size); - ok(hr == hrexp, "got 0x%08x\n", hr); + ok(hr == hrexp, "got 0x%08lx\n", hr); hr = ITextFont_GetStrikeThrough(font, NULL); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); hr = ITextFont_GetStrikeThrough(font, &value); - ok(hr == hrexp, "got 0x%08x\n", hr); + ok(hr == hrexp, "got 0x%08lx\n", hr); hr = ITextFont_GetSubscript(font, NULL); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); hr = ITextFont_GetSubscript(font, &value); - ok(hr == hrexp, "got 0x%08x\n", hr); + ok(hr == hrexp, "got 0x%08lx\n", hr); hr = ITextFont_GetSuperscript(font, NULL); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); hr = ITextFont_GetSuperscript(font, &value); - ok(hr == hrexp, "got 0x%08x\n", hr); + ok(hr == hrexp, "got 0x%08lx\n", hr); hr = ITextFont_GetUnderline(font, NULL); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); hr = ITextFont_GetUnderline(font, &value); - ok(hr == hrexp, "got 0x%08x\n", hr); + ok(hr == hrexp, "got 0x%08lx\n", hr); } static void test_textfont_global_defaults(ITextFont *font) @@ -2053,124 +2643,124 @@ static void test_textfont_global_defaults(ITextFont *font) value = tomUndefined; hr = ITextFont_GetAllCaps(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); value = tomUndefined; hr = ITextFont_GetAnimation(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); value = tomUndefined; hr = ITextFont_GetBackColor(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomAutoColor, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomAutoColor, "got %ld\n", value); value = tomUndefined; hr = ITextFont_GetBold(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomFalse || value == tomTrue, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomFalse || value == tomTrue, "got %ld\n", value); value = tomUndefined; hr = ITextFont_GetEmboss(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); value = tomUndefined; hr = ITextFont_GetForeColor(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomAutoColor, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomAutoColor, "got %ld\n", value); value = tomUndefined; hr = ITextFont_GetHidden(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); value = tomUndefined; hr = ITextFont_GetEngrave(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); value = tomUndefined; hr = ITextFont_GetItalic(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); valuef = 1.0; hr = ITextFont_GetKerning(font, &valuef); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); ok(valuef == 0.0, "got %.2f\n", valuef); value = tomUndefined; hr = ITextFont_GetLanguageID(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == GetSystemDefaultLCID(), "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == GetSystemDefaultLCID(), "got %ld\n", value); str = NULL; hr = ITextFont_GetName(font, &str); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); ok(!lstrcmpW(sysW, str), "%s\n", wine_dbgstr_w(str)); SysFreeString(str); value = tomUndefined; hr = ITextFont_GetOutline(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); valuef = 1.0; hr = ITextFont_GetPosition(font, &valuef); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); ok(valuef == 0.0, "got %.2f\n", valuef); value = tomUndefined; hr = ITextFont_GetProtected(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); value = tomUndefined; hr = ITextFont_GetShadow(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); valuef = 0.0; hr = ITextFont_GetSize(font, &valuef); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); ok(valuef >= 0.0, "got %.2f\n", valuef); value = tomUndefined; hr = ITextFont_GetSmallCaps(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); valuef = 1.0; hr = ITextFont_GetSpacing(font, &valuef); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); ok(valuef == 0.0, "got %.2f\n", valuef); value = tomUndefined; hr = ITextFont_GetStrikeThrough(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); value = tomUndefined; hr = ITextFont_GetSubscript(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); value = tomUndefined; hr = ITextFont_GetSuperscript(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); value = tomUndefined; hr = ITextFont_GetUnderline(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); value = tomUndefined; hr = ITextFont_GetWeight(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == FW_NORMAL || value == FW_BOLD, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == FW_NORMAL || value == FW_BOLD, "got %ld\n", value); } static void test_textfont_undefined(ITextFont *font) @@ -2181,118 +2771,118 @@ static void test_textfont_undefined(ITextFont *font) value = tomFalse; hr = ITextFont_GetAllCaps(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomUndefined, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomUndefined, "got %ld\n", value); value = tomFalse; hr = ITextFont_GetAnimation(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomUndefined, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomUndefined, "got %ld\n", value); value = tomFalse; hr = ITextFont_GetBackColor(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomUndefined, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomUndefined, "got %ld\n", value); value = tomFalse; hr = ITextFont_GetBold(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomUndefined, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomUndefined, "got %ld\n", value); value = tomFalse; hr = ITextFont_GetEmboss(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomUndefined, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomUndefined, "got %ld\n", value); value = tomFalse; hr = ITextFont_GetForeColor(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomUndefined, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomUndefined, "got %ld\n", value); value = tomFalse; hr = ITextFont_GetHidden(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomUndefined, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomUndefined, "got %ld\n", value); value = tomFalse; hr = ITextFont_GetEngrave(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomUndefined, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomUndefined, "got %ld\n", value); value = tomFalse; hr = ITextFont_GetItalic(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomUndefined, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomUndefined, "got %ld\n", value); valuef = 0.0; hr = ITextFont_GetKerning(font, &valuef); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); ok(valuef == tomUndefined, "got %.2f\n", valuef); value = tomFalse; hr = ITextFont_GetLanguageID(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomUndefined, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomUndefined, "got %ld\n", value); value = tomFalse; hr = ITextFont_GetOutline(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomUndefined, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomUndefined, "got %ld\n", value); valuef = 0.0; hr = ITextFont_GetPosition(font, &valuef); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); ok(valuef == tomUndefined, "got %.2f\n", valuef); value = tomFalse; hr = ITextFont_GetProtected(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomUndefined, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomUndefined, "got %ld\n", value); value = tomFalse; hr = ITextFont_GetShadow(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomUndefined, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomUndefined, "got %ld\n", value); valuef = 0.0; hr = ITextFont_GetSize(font, &valuef); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); ok(valuef == tomUndefined, "got %.2f\n", valuef); value = tomFalse; hr = ITextFont_GetSmallCaps(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomUndefined, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomUndefined, "got %ld\n", value); valuef = 0.0; hr = ITextFont_GetSpacing(font, &valuef); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); ok(valuef == tomUndefined, "got %.2f\n", valuef); value = tomFalse; hr = ITextFont_GetStrikeThrough(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomUndefined, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomUndefined, "got %ld\n", value); value = tomFalse; hr = ITextFont_GetSubscript(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomUndefined, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomUndefined, "got %ld\n", value); value = tomFalse; hr = ITextFont_GetSuperscript(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomUndefined, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomUndefined, "got %ld\n", value); value = tomFalse; hr = ITextFont_GetUnderline(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomUndefined, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomUndefined, "got %ld\n", value); value = tomFalse; hr = ITextFont_GetWeight(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomUndefined, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomUndefined, "got %ld\n", value); } static inline FLOAT twips_to_points(LONG value) @@ -2320,39 +2910,39 @@ static void test_ITextFont(void) SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1); hr = ITextDocument_Range(doc, 0, 10, &range); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); hr = ITextRange_GetFont(range, &font); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); hr = ITextFont_Reset(font, tomUseTwips); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); hr = ITextFont_Reset(font, tomUsePoints); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); hr = ITextFont_GetName(font, NULL); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); /* default font size unit is point */ size = 0.0; hr = ITextFont_GetSize(font, &size); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); /* set to some non-zero values */ hr = ITextFont_SetPosition(font, 20.0); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); hr = ITextFont_SetKerning(font, 10.0); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); position = 0.0; hr = ITextFont_GetPosition(font, &position); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); kerning = 0.0; hr = ITextFont_GetKerning(font, &kerning); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); memset(&cf, 0, sizeof(cf)); cf.cbSize = sizeof(cf); @@ -2362,31 +2952,31 @@ static void test_ITextFont(void) SendMessageA(hwnd, EM_SETSEL, 0, 10); ret = SendMessageA(hwnd, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); ok(ret, "got %d\n", ret); - ok(size == twips_to_points(cf.yHeight), "got yHeight %d, size %.2f\n", cf.yHeight, size); - ok(position == twips_to_points(cf.yOffset), "got yOffset %d, position %.2f\n", cf.yOffset, position); + ok(size == twips_to_points(cf.yHeight), "got yHeight %ld, size %.2f\n", cf.yHeight, size); + ok(position == twips_to_points(cf.yOffset), "got yOffset %ld, position %.2f\n", cf.yOffset, position); ok(kerning == twips_to_points(cf.wKerning), "got wKerning %d, kerning %.2f\n", cf.wKerning, kerning); hr = ITextFont_Reset(font, tomUseTwips); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); hr = ITextFont_Reset(font, tomUsePoints); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); hr = ITextFont_GetDuplicate(font, &font2); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); hr = ITextFont_Reset(font2, tomUseTwips); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); hr = ITextFont_Reset(font2, tomUsePoints); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); ITextFont_Release(font2); /* default font name */ str = NULL; hr = ITextFont_GetName(font, &str); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); ok(!lstrcmpW(str, sysW), "got %s\n", wine_dbgstr_w(str)); SysFreeString(str); @@ -2403,7 +2993,7 @@ static void test_ITextFont(void) /* still original name */ str = NULL; hr = ITextFont_GetName(font, &str); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); ok(!lstrcmpW(str, sysW), "got %s\n", wine_dbgstr_w(str)); SysFreeString(str); @@ -2413,7 +3003,7 @@ static void test_ITextFont(void) str = NULL; hr = ITextFont_GetName(font, &str); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); ok(!lstrcmpW(str, sysW), "got %s\n", wine_dbgstr_w(str)); SysFreeString(str); @@ -2424,18 +3014,18 @@ static void test_ITextFont(void) str = NULL; hr = ITextFont_GetName(font, &str); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); ok(!lstrcmpW(str, arialW), "got %s\n", wine_dbgstr_w(str)); SysFreeString(str); /* GetDuplicate() */ hr = ITextFont_GetDuplicate(font, NULL); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); EXPECT_REF(range, 2); font2 = NULL; hr = ITextFont_GetDuplicate(font, &font2); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); EXPECT_REF(range, 2); /* set whole range to italic */ @@ -2449,75 +3039,75 @@ static void test_ITextFont(void) value = tomFalse; hr = ITextFont_GetItalic(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomTrue, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomTrue, "got %ld\n", value); /* duplicate retains original value */ value = tomTrue; hr = ITextFont_GetItalic(font2, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); /* get a duplicate from a cloned font */ hr = ITextFont_GetDuplicate(font2, &font3); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); ITextFont_Release(font3); ITextRange_Release(range); release_interfaces(&hwnd, &reOle, &doc, NULL); hr = ITextFont_GetDuplicate(font, NULL); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); test_detached_font_getters(font, FALSE); test_detached_font_getters(font2, TRUE); /* get a duplicate of detached font */ hr = ITextFont_GetDuplicate(font2, &font3); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); ITextFont_Release(font3); /* reset detached font to undefined */ value = tomUndefined; hr = ITextFont_GetBold(font2, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value != tomUndefined, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value != tomUndefined, "got %ld\n", value); /* reset to undefined for detached font */ hr = ITextFont_Reset(font2, tomUndefined); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); test_textfont_undefined(font2); /* font is detached, default means global TOM defaults */ hr = ITextFont_Reset(font2, tomDefault); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); test_textfont_global_defaults(font2); hr = ITextFont_GetDuplicate(font2, &font3); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); test_textfont_global_defaults(font2); hr = ITextFont_Reset(font2, tomApplyNow); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); test_textfont_global_defaults(font2); hr = ITextFont_Reset(font2, tomApplyLater); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); test_textfont_global_defaults(font2); hr = ITextFont_Reset(font2, tomTrackParms); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); test_textfont_global_defaults(font2); hr = ITextFont_SetItalic(font2, tomUndefined); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); hr = ITextFont_GetItalic(font2, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); hr = ITextFont_Reset(font2, tomCacheParms); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); test_textfont_global_defaults(font2); ITextFont_Release(font3); @@ -2525,11 +3115,11 @@ static void test_ITextFont(void) font2 = (void*)0xdeadbeef; hr = ITextFont_GetDuplicate(font, &font2); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); ok(font2 == NULL, "got %p\n", font2); hr = ITextFont_Reset(font, tomDefault); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); ITextFont_Release(font); @@ -2538,32 +3128,32 @@ static void test_ITextFont(void) SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1); hr = ITextDocument_Range(doc, 0, 10, &range); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); hr = ITextRange_GetFont(range, &font); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); value = tomUndefined; hr = ITextFont_GetBold(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value != tomUndefined, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value != tomUndefined, "got %ld\n", value); /* reset to undefined for attached font */ hr = ITextFont_Reset(font, tomUndefined); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); value = tomUndefined; hr = ITextFont_GetBold(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value != tomUndefined, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value != tomUndefined, "got %ld\n", value); /* tomCacheParms/tomTrackParms */ hr = ITextFont_Reset(font, tomCacheParms); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); hr = ITextFont_GetItalic(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); memset(&cf, 0, sizeof(cf)); cf.cbSize = sizeof(CHARFORMAT2A); @@ -2576,65 +3166,65 @@ static void test_ITextFont(void) /* still cached value */ hr = ITextFont_GetItalic(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); hr = ITextFont_Reset(font, tomTrackParms); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); hr = ITextFont_GetItalic(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomTrue, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomTrue, "got %ld\n", value); /* switch back to cache - value retained */ hr = ITextFont_Reset(font, tomCacheParms); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); hr = ITextFont_GetItalic(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomTrue, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomTrue, "got %ld\n", value); /* tomApplyLater */ hr = ITextFont_Reset(font, tomApplyLater); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); hr = ITextFont_SetItalic(font, tomFalse); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); hr = ITextFont_GetItalic(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); cf.dwEffects = 0; SendMessageA(hwnd, EM_SETSEL, 0, 10); ret = SendMessageA(hwnd, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); ok(ret, "got %d\n", ret); - ok((cf.dwEffects & CFE_ITALIC) == CFE_ITALIC, "got 0x%08x\n", cf.dwEffects); + ok((cf.dwEffects & CFE_ITALIC) == CFE_ITALIC, "got 0x%08lx\n", cf.dwEffects); hr = ITextFont_Reset(font, tomApplyNow); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); cf.dwEffects = 0; SendMessageA(hwnd, EM_SETSEL, 0, 10); ret = SendMessageA(hwnd, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); ok(ret, "got %d\n", ret); - ok((cf.dwEffects & CFE_ITALIC) == 0, "got 0x%08x\n", cf.dwEffects); + ok((cf.dwEffects & CFE_ITALIC) == 0, "got 0x%08lx\n", cf.dwEffects); hr = ITextFont_SetItalic(font, tomUndefined); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); hr = ITextFont_GetItalic(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); hr = ITextFont_SetItalic(font, tomAutoColor); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); cf.dwEffects = 0; SendMessageA(hwnd, EM_SETSEL, 0, 10); ret = SendMessageA(hwnd, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); ok(ret, "got %d\n", ret); - ok((cf.dwEffects & CFE_ITALIC) == 0, "got 0x%08x\n", cf.dwEffects); + ok((cf.dwEffects & CFE_ITALIC) == 0, "got 0x%08lx\n", cf.dwEffects); ITextRange_Release(range); ITextFont_Release(font); @@ -2655,41 +3245,41 @@ static void test_Delete(void) SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1); hr = ITextDocument_Range(doc, 0, 4, &range); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); hr = ITextDocument_Range(doc, 1, 2, &range2); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); hr = ITextRange_GetEnd(range, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == 4, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == 4, "got %ld\n", value); /* unit type doesn't matter is count is 0 */ value = 0; hr = ITextRange_Delete(range2, tomSentence, 0, &value); todo_wine { - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == 1, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == 1, "got %ld\n", value); } value = 1; hr = ITextRange_Delete(range2, tomCharacter, 0, &value); todo_wine { - ok(hr == S_FALSE, "got 0x%08x\n", hr); - ok(value == 0, "got %d\n", value); + ok(hr == S_FALSE, "got 0x%08lx\n", hr); + ok(value == 0, "got %ld\n", value); } hr = ITextRange_GetEnd(range, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); -todo_wine - ok(value == 3, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + todo_wine + ok(value == 3, "got %ld\n", value); hr = ITextRange_GetStart(range2, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == 1, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == 1, "got %ld\n", value); hr = ITextRange_GetEnd(range2, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); -todo_wine - ok(value == 1, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + todo_wine + ok(value == 1, "got %ld\n", value); ITextRange_Release(range); ITextRange_Release(range2); @@ -2712,72 +3302,72 @@ static void test_SetText(void) SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1); hr = ITextDocument_Range(doc, 0, 4, &range); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); hr = ITextDocument_Range(doc, 0, 4, &range2); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); value = 1; hr = ITextRange_GetStart(range2, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == 0, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == 0, "got %ld\n", value); value = 0; hr = ITextRange_GetEnd(range2, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == 4, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == 4, "got %ld\n", value); hr = ITextRange_SetText(range, NULL); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); value = 1; hr = ITextRange_GetEnd(range2, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == 0, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == 0, "got %ld\n", value); str = SysAllocString(textW); hr = ITextRange_SetText(range, str); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); SysFreeString(str); value = 1; hr = ITextRange_GetStart(range, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == 0, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == 0, "got %ld\n", value); value = 0; hr = ITextRange_GetEnd(range, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == 9, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == 9, "got %ld\n", value); value = 1; hr = ITextRange_GetStart(range2, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == 0, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == 0, "got %ld\n", value); value = 0; hr = ITextRange_GetEnd(range2, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == 0, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == 0, "got %ld\n", value); str = SysAllocStringLen(NULL, 0); hr = ITextRange_SetText(range, str); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); value = 1; hr = ITextRange_GetEnd(range, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == 0, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == 0, "got %ld\n", value); SysFreeString(str); ITextRange_Release(range2); release_interfaces(&hwnd, &reOle, &doc, NULL); hr = ITextRange_SetText(range, NULL); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); str = SysAllocStringLen(NULL, 0); hr = ITextRange_SetText(range, str); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); SysFreeString(str); ITextRange_Release(range); @@ -2799,93 +3389,93 @@ static void test_InRange(void) SendMessageA(hwnd, EM_SETSEL, 1, 2); hr = ITextDocument_Range(doc, 0, 4, &range); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); hr = ITextDocument_Range(doc, 0, 4, &range2); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); /* matches selection */ hr = ITextDocument_Range(doc, 1, 2, &range3); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); hr = ITextRange_InRange(range, NULL, NULL); - ok(hr == S_FALSE, "got 0x%08x\n", hr); + ok(hr == S_FALSE, "got 0x%08lx\n", hr); value = tomTrue; hr = ITextRange_InRange(range, NULL, &value); - ok(hr == S_FALSE, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == S_FALSE, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); hr = ITextRange_InRange(range, range2, NULL); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); value = tomFalse; hr = ITextRange_InRange(range, range2, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomTrue, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomTrue, "got %ld\n", value); /* selection */ hr = ITextSelection_InRange(selection, NULL, NULL); - ok(hr == S_FALSE, "got 0x%08x\n", hr); + ok(hr == S_FALSE, "got 0x%08lx\n", hr); value = tomTrue; hr = ITextSelection_InRange(selection, NULL, &value); - ok(hr == S_FALSE, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == S_FALSE, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); hr = ITextSelection_InRange(selection, range2, NULL); - ok(hr == S_FALSE, "got 0x%08x\n", hr); + ok(hr == S_FALSE, "got 0x%08lx\n", hr); value = tomTrue; hr = ITextSelection_InRange(selection, range2, &value); - ok(hr == S_FALSE, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == S_FALSE, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); value = tomTrue; hr = ITextSelection_InRange(selection, range3, &value); - ok(hr == S_FALSE, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == S_FALSE, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); /* seems to work on ITextSelection ranges only */ value = tomFalse; hr = ITextSelection_InRange(selection, (ITextRange*)selection, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomTrue, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomTrue, "got %ld\n", value); release_interfaces(&hwnd, &reOle, &doc, NULL); hr = ITextRange_InRange(range, NULL, NULL); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); value = tomTrue; hr = ITextRange_InRange(range, NULL, &value); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); hr = ITextRange_InRange(range, range2, NULL); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); value = tomTrue; hr = ITextRange_InRange(range, range2, &value); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); /* selection */ hr = ITextSelection_InRange(selection, NULL, NULL); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); value = tomTrue; hr = ITextSelection_InRange(selection, NULL, &value); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); hr = ITextSelection_InRange(selection, range2, NULL); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); value = tomTrue; hr = ITextSelection_InRange(selection, range2, &value); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); ITextRange_Release(range); ITextRange_Release(range2); @@ -2909,98 +3499,98 @@ static void test_ITextRange_IsEqual(void) SendMessageA(hwnd, EM_SETSEL, 1, 2); hr = ITextDocument_Range(doc, 0, 4, &range); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); hr = ITextDocument_Range(doc, 0, 4, &range2); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); /* matches selection */ hr = ITextDocument_Range(doc, 1, 2, &range3); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); hr = ITextRange_IsEqual(range, NULL, NULL); - ok(hr == S_FALSE, "got 0x%08x\n", hr); + ok(hr == S_FALSE, "got 0x%08lx\n", hr); value = tomTrue; hr = ITextRange_IsEqual(range, NULL, &value); - ok(hr == S_FALSE, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == S_FALSE, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); hr = ITextRange_IsEqual(range, range2, NULL); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); value = tomFalse; hr = ITextRange_IsEqual(range, range2, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomTrue, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomTrue, "got %ld\n", value); value = tomTrue; hr = ITextRange_IsEqual(range, range3, &value); - ok(hr == S_FALSE, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == S_FALSE, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); /* selection */ hr = ITextSelection_IsEqual(selection, NULL, NULL); - ok(hr == S_FALSE, "got 0x%08x\n", hr); + ok(hr == S_FALSE, "got 0x%08lx\n", hr); value = tomTrue; hr = ITextSelection_IsEqual(selection, NULL, &value); - ok(hr == S_FALSE, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == S_FALSE, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); hr = ITextSelection_IsEqual(selection, range2, NULL); - ok(hr == S_FALSE, "got 0x%08x\n", hr); + ok(hr == S_FALSE, "got 0x%08lx\n", hr); value = tomTrue; hr = ITextSelection_IsEqual(selection, range2, &value); - ok(hr == S_FALSE, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == S_FALSE, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); value = tomTrue; hr = ITextSelection_IsEqual(selection, range3, &value); - ok(hr == S_FALSE, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == S_FALSE, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); /* seems to work on ITextSelection ranges only */ value = tomFalse; hr = ITextSelection_IsEqual(selection, (ITextRange*)selection, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomTrue, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomTrue, "got %ld\n", value); release_interfaces(&hwnd, &reOle, &doc, NULL); hr = ITextRange_IsEqual(range, NULL, NULL); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); value = tomTrue; hr = ITextRange_IsEqual(range, NULL, &value); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); hr = ITextRange_IsEqual(range, range2, NULL); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); value = tomTrue; hr = ITextRange_IsEqual(range, range2, &value); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); /* selection */ hr = ITextSelection_IsEqual(selection, NULL, NULL); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); value = tomTrue; hr = ITextSelection_IsEqual(selection, NULL, &value); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); hr = ITextSelection_IsEqual(selection, range2, NULL); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); value = tomTrue; hr = ITextSelection_IsEqual(selection, range2, &value); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); ITextRange_Release(range); ITextRange_Release(range2); @@ -3008,13 +3598,25 @@ static void test_ITextRange_IsEqual(void) ITextSelection_Release(selection); } +static int get_scroll_pos_y(HWND hwnd) +{ + POINT p = {-1, -1}; + SendMessageA(hwnd, EM_GETSCROLLPOS, 0, (LPARAM)&p); + ok(p.x != -1 && p.y != -1, "p.x:%ld p.y:%ld\n", p.x, p.y); + return p.y; +} + static void test_Select(void) { static const CHAR test_text1[] = "TestSomeText"; + static const CHAR test_text2[] = "text\nwith\nbreak\n" + "lines\ntest\ntest\n"; IRichEditOle *reOle = NULL; ITextDocument *doc = NULL; ITextSelection *selection; ITextRange *range; + int scroll_pos1; + int scroll_pos2; LONG value; HRESULT hr; HWND hwnd; @@ -3024,29 +3626,42 @@ static void test_Select(void) SendMessageA(hwnd, EM_SETSEL, 1, 2); hr = ITextDocument_Range(doc, 0, 4, &range); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); + scroll_pos1 = get_scroll_pos_y(hwnd); hr = ITextRange_Select(range); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); + scroll_pos2 = get_scroll_pos_y(hwnd); + ok(scroll_pos1 == scroll_pos2, "%d != %d\n", scroll_pos1, scroll_pos2); value = 1; hr = ITextSelection_GetStart(selection, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == 0, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == 0, "got %ld\n", value); hr = ITextRange_Select(range); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); hr = ITextSelection_Select(selection); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); + + SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text2); + SendMessageA(hwnd, EM_SETSEL, 1, 2); + hr = ITextDocument_Range(doc, 10, 16, &range); + ok(hr == S_OK, "got 0x%08lx\n", hr); + scroll_pos1 = get_scroll_pos_y(hwnd); + hr = ITextRange_Select(range); + ok(hr == S_OK, "got 0x%08lx\n", hr); + scroll_pos2 = get_scroll_pos_y(hwnd); + ok(scroll_pos1 != scroll_pos2, "%d == %d\n", scroll_pos1, scroll_pos2); release_interfaces(&hwnd, &reOle, &doc, NULL); hr = ITextRange_Select(range); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); hr = ITextSelection_Select(selection); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); ITextRange_Release(range); ITextSelection_Release(selection); @@ -3068,41 +3683,41 @@ static void test_GetStoryType(void) SendMessageA(hwnd, EM_SETSEL, 1, 2); hr = ITextDocument_Range(doc, 0, 4, &range); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); hr = ITextRange_GetStoryType(range, NULL); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); value = tomTextFrameStory; hr = ITextRange_GetStoryType(range, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomUnknownStory, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomUnknownStory, "got %ld\n", value); hr = ITextSelection_GetStoryType(selection, NULL); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); value = tomTextFrameStory; hr = ITextSelection_GetStoryType(selection, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomUnknownStory, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomUnknownStory, "got %ld\n", value); release_interfaces(&hwnd, &reOle, &doc, NULL); hr = ITextRange_GetStoryType(range, NULL); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); value = 123; hr = ITextRange_GetStoryType(range, &value); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); - ok(value == 123, "got %d\n", value); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); + ok(value == 123, "got %ld\n", value); hr = ITextSelection_GetStoryType(selection, NULL); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); value = 123; hr = ITextSelection_GetStoryType(selection, &value); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); - ok(value == 123, "got %d\n", value); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); + ok(value == 123, "got %ld\n", value); ITextRange_Release(range); ITextSelection_Release(selection); @@ -3125,68 +3740,68 @@ static void test_SetFont(void) SendMessageA(hwnd, EM_SETSEL, 1, 2); hr = ITextDocument_Range(doc, 0, 4, &range); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); hr = ITextDocument_Range(doc, 5, 2, &range2); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); EXPECT_REF(range, 1); hr = ITextRange_GetFont(range, &font); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); EXPECT_REF(range, 2); EXPECT_REF(range2, 1); hr = ITextRange_GetFont(range2, &font2); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); EXPECT_REF(range2, 2); hr = ITextRange_SetFont(range, NULL); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); /* setting same font, no-op */ EXPECT_REF(range, 2); hr = ITextRange_SetFont(range, font); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); EXPECT_REF(range, 2); EXPECT_REF(range2, 2); EXPECT_REF(range, 2); hr = ITextRange_SetFont(range, font2); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); EXPECT_REF(range2, 2); EXPECT_REF(range, 2); /* originally range 0-4 is non-italic */ value = tomTrue; hr = ITextFont_GetItalic(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomFalse, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomFalse, "got %ld\n", value); /* set range 5-2 to italic, then set this font to range 0-4 */ hr = ITextFont_SetItalic(font2, tomTrue); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); hr = ITextRange_SetFont(range, font2); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); value = tomFalse; hr = ITextFont_GetItalic(font, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == tomTrue, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == tomTrue, "got %ld\n", value); release_interfaces(&hwnd, &reOle, &doc, NULL); hr = ITextRange_SetFont(range, NULL); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); hr = ITextRange_SetFont(range, font); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); hr = ITextSelection_SetFont(selection, NULL); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); hr = ITextSelection_SetFont(selection, font); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); ITextFont_Release(font); ITextFont_Release(font2); @@ -3212,9 +3827,9 @@ static void fill_reobject_struct(REOBJECT *reobj, LONG cp, LPOLEOBJECT poleobj, reobj->dwUser = user; } -#define CHECK_REOBJECT_STRUCT(reole,index,flags,cp,poleobj,pstg,polesite,user) \ - _check_reobject_struct(reole, index, flags, cp, poleobj, pstg, polesite, user, __LINE__) -static void _check_reobject_struct(IRichEditOle *reole, LONG index, DWORD flags, LONG cp, +#define CHECK_REOBJECT_STRUCT(reole,index,flags,cp,cp_check,poleobj,pstg,polesite,user) \ + _check_reobject_struct(reole, index, flags, cp, cp_check, poleobj, pstg, polesite, user, __LINE__) +static void _check_reobject_struct(IRichEditOle *reole, LONG index, DWORD flags, LONG cp, LONG cp_check, LPOLEOBJECT poleobj, LPSTORAGE pstg, LPOLECLIENTSITE polesite, DWORD user, int line) { REOBJECT reobj; @@ -3223,28 +3838,44 @@ static void _check_reobject_struct(IRichEditOle *reole, LONG index, DWORD flags, reobj.cbStruct = sizeof(reobj); reobj.cp = cp; hr = IRichEditOle_GetObject(reole, index, &reobj, flags); - ok(hr == S_OK, "IRichEditOle_GetObject failed: %#x.\n", hr); + ok(hr == S_OK, "IRichEditOle_GetObject failed: %#lx.\n", hr); + ok_(__FILE__,line)(reobj.cp == cp_check, "expected cp = %ld, got %ld.\n", cp_check, reobj.cp); ok_(__FILE__,line)(reobj.poleobj == poleobj, "got wrong object interface.\n"); ok_(__FILE__,line)(reobj.pstg == pstg, "got wrong storage interface.\n"); ok_(__FILE__,line)(reobj.polesite == polesite, "got wrong site interface.\n"); ok_(__FILE__,line)(reobj.dwUser == user, "got wrong user-defined value.\n"); } -#define INSERT_REOBJECT(reole,reobj,cp,user) \ - _insert_reobject(reole, reobj, cp, user, __LINE__) -static void _insert_reobject(IRichEditOle *reole, REOBJECT *reobj, LONG cp, DWORD user, int line) +#define INSERT_REOBJECT(callback,reole,reobj,cp,user) \ + _insert_reobject(callback, reole, reobj, cp, user, __LINE__) +static void _insert_reobject(struct reolecb_obj *callback, IRichEditOle *reole, + REOBJECT *reobj, LONG cp, DWORD user, int line) { IOleClientSite *clientsite; HRESULT hr; + + olecb_expect_QueryInsertObject(callback, line, 1, + &CLSID_NULL, NULL, REO_CP_SELECTION /* cp overridden */, S_OK); hr = IRichEditOle_GetClientSite(reole, &clientsite); - ok_(__FILE__,line)(hr == S_OK, "IRichEditOle_GetClientSite got hr %#x.\n", hr); + ok_(__FILE__,line)(hr == S_OK, "IRichEditOle_GetClientSite got hr %#lx.\n", hr); fill_reobject_struct(reobj, cp, NULL, NULL, clientsite, 10, 10, DVASPECT_CONTENT, 0, user); hr = IRichEditOle_InsertObject(reole, reobj); - ok_(__FILE__,line)(hr == S_OK, "IRichEditOle_InsertObject got hr %#x.\n", hr); + ok_(__FILE__,line)(hr == S_OK, "IRichEditOle_InsertObject got hr %#lx.\n", hr); IOleClientSite_Release(clientsite); + olecb_check_QueryInsertObject(callback, line); } -static void test_InsertObject(void) +static void flush_dispatch_messages(void) +{ + MSG msg; + while (PeekMessageW( &msg, NULL, 0, 0, PM_REMOVE )) + { + TranslateMessage( &msg ); + DispatchMessageW( &msg ); + } +} + +static void subtest_InsertObject(struct reolecb_obj *callback) { static CHAR test_text1[] = "abcdefg"; IRichEditOle *reole = NULL; @@ -3252,7 +3883,7 @@ static void test_InsertObject(void) REOBJECT reo1, reo2, reo3, received_reo; HRESULT hr; HWND hwnd; - const WCHAR *expected_string; + const WCHAR *expected_string, *string; const CHAR *expected_stringA; ITextSelection *selection; IDataObject *dataobject; @@ -3266,126 +3897,171 @@ static void test_InsertObject(void) LONG count, result; ITextRange *range; BSTR bstr; + struct testoleobj *testobj; + IOleClientSite *clientsite; + REOBJECT reobj; + BOOL bad_getsel; + DWORD gle; create_interfaces(&hwnd, &reole, &doc, &selection); + if (callback) + { + LRESULT sendres = SendMessageA(hwnd, EM_SETOLECALLBACK, 0, (LPARAM)&callback->IRichEditOleCallback_iface); + ok( !!sendres, "EM_SETOLECALLBACK should succeed\n" ); + } + + SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)"a"); + SendMessageA(hwnd, EM_SETSEL, 0, -1); + *bufferA = '\0'; + SetLastError(0xdeadbeef); + result = SendMessageA(hwnd, EM_GETSELTEXT, 0, (LPARAM)bufferA); + gle = GetLastError(); + ok((result > 0 && gle == 0xdeadbeef) || + broken(result == 0 && gle == ERROR_INVALID_PARAMETER /* Hindi */), + "EM_GETSELTEXT returned %ld gle=%lu\n", result, gle); + bad_getsel = (gle != 0xdeadbeef); + if (bad_getsel) + trace("EM_GETSELTEXT is broken, some tests will be ignored\n"); + SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1); hr = IRichEditOle_InsertObject(reole, NULL); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); /* insert object1 in (0, 1)*/ SendMessageA(hwnd, EM_SETSEL, 0, 1); - INSERT_REOBJECT(reole, &reo1, REO_CP_SELECTION, 1); + INSERT_REOBJECT(callback, reole, &reo1, REO_CP_SELECTION, 1); count = IRichEditOle_GetObjectCount(reole); - ok(count == 1, "got wrong object count: %d\n", count); + ok(count == 1, "got wrong object count: %ld\n", count); /* insert object2 in (2, 3)*/ SendMessageA(hwnd, EM_SETSEL, 2, 3); - INSERT_REOBJECT(reole, &reo2, REO_CP_SELECTION, 2); + INSERT_REOBJECT(callback, reole, &reo2, REO_CP_SELECTION, 2); count = IRichEditOle_GetObjectCount(reole); - ok(count == 2, "got wrong object count: %d\n", count); + ok(count == 2, "got wrong object count: %ld\n", count); /* insert object3 in (1, 2)*/ SendMessageA(hwnd, EM_SETSEL, 1, 2); - INSERT_REOBJECT(reole, &reo3, REO_CP_SELECTION, 3); + INSERT_REOBJECT(callback, reole, &reo3, REO_CP_SELECTION, 3); count = IRichEditOle_GetObjectCount(reole); - ok(count == 3, "got wrong object count: %d\n", count); + ok(count == 3, "got wrong object count: %ld\n", count); + + if (callback) + { + /* (fail to) insert object1 in (3, 4)*/ + SendMessageA(hwnd, EM_SETSEL, 3, 4); + + hr = IRichEditOle_GetClientSite(reole, &clientsite); + ok(hr == S_OK, "IRichEditOle_GetClientSite got hr %#lx.\n", hr); + + olecb_expect_QueryInsertObject(callback, __LINE__, 1, + &CLSID_NULL, NULL, REO_CP_SELECTION, S_FALSE); + fill_reobject_struct(&reobj, REO_CP_SELECTION, NULL, NULL, clientsite, 10, 10, DVASPECT_CONTENT, 0, 0); + hr = IRichEditOle_InsertObject(reole, &reobj); + ok(hr == S_FALSE, "IRichEditOle_InsertObject got hr %#lx.\n", hr); + olecb_check_QueryInsertObject(callback, __LINE__); + + IOleClientSite_Release(clientsite); + + count = IRichEditOle_GetObjectCount(reole); + ok(count == 3, "got wrong object count: %ld\n", count); + } /* tests below show that order of rebject (from 0 to 2) is: reo1,reo3,reo2 */ - CHECK_REOBJECT_STRUCT(reole, 0, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo1.polesite, 1); - CHECK_REOBJECT_STRUCT(reole, 1, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo3.polesite, 3); - CHECK_REOBJECT_STRUCT(reole, 2, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo2.polesite, 2); + CHECK_REOBJECT_STRUCT(reole, 0, REO_GETOBJ_ALL_INTERFACES, 0, 0, NULL, NULL, reo1.polesite, 1); + CHECK_REOBJECT_STRUCT(reole, 1, REO_GETOBJ_ALL_INTERFACES, 0, 1, NULL, NULL, reo3.polesite, 3); + CHECK_REOBJECT_STRUCT(reole, 2, REO_GETOBJ_ALL_INTERFACES, 0, 2, NULL, NULL, reo2.polesite, 2); hr = IRichEditOle_GetObject(reole, 2, NULL, REO_GETOBJ_ALL_INTERFACES); - ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08lx\n", hr); received_reo.cbStruct = 0; hr = IRichEditOle_GetObject(reole, 2, &received_reo, REO_GETOBJ_ALL_INTERFACES); - ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08lx\n", hr); - CHECK_REOBJECT_STRUCT(reole, 2, REO_GETOBJ_PSTG, 0, NULL, NULL, NULL, 2); - CHECK_REOBJECT_STRUCT(reole, 2, REO_GETOBJ_POLESITE, 0, NULL, NULL, reo2.polesite, 2); + CHECK_REOBJECT_STRUCT(reole, 2, REO_GETOBJ_PSTG, 0, 2, NULL, NULL, NULL, 2); + CHECK_REOBJECT_STRUCT(reole, 2, REO_GETOBJ_POLESITE, 0, 2, NULL, NULL, reo2.polesite, 2); hr = IRichEditOle_GetObject(reole, 3, &received_reo, REO_GETOBJ_POLESITE); - ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08lx\n", hr); hr = IRichEditOle_GetObject(reole, 4, &received_reo, REO_GETOBJ_POLESITE); - ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08lx\n", hr); hr = IRichEditOle_GetObject(reole, 1024, &received_reo, REO_GETOBJ_POLESITE); - ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08lx\n", hr); hr = IRichEditOle_GetObject(reole, -10, &received_reo, REO_GETOBJ_POLESITE); - ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08lx\n", hr); /* received_reo will be zeroed before be used */ received_reo.cbStruct = sizeof(received_reo); received_reo.polesite = (IOleClientSite *)0xdeadbeef; hr = IRichEditOle_GetObject(reole, 2, &received_reo, REO_GETOBJ_NO_INTERFACES); - ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr); - ok(received_reo.polesite == (IOleClientSite *)NULL, "Got wrong site interface.\n"); + ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08lx\n", hr); + ok(received_reo.polesite == NULL, "Got wrong site interface.\n"); - CHECK_REOBJECT_STRUCT(reole, REO_IOB_USE_CP, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo1.polesite, 1); - CHECK_REOBJECT_STRUCT(reole, REO_IOB_USE_CP, REO_GETOBJ_ALL_INTERFACES, 1, NULL, NULL, reo3.polesite, 3); - CHECK_REOBJECT_STRUCT(reole, REO_IOB_USE_CP, REO_GETOBJ_ALL_INTERFACES, 2, NULL, NULL, reo2.polesite, 2); + CHECK_REOBJECT_STRUCT(reole, REO_IOB_USE_CP, REO_GETOBJ_ALL_INTERFACES, 0, 0, NULL, NULL, reo1.polesite, 1); + CHECK_REOBJECT_STRUCT(reole, REO_IOB_USE_CP, REO_GETOBJ_ALL_INTERFACES, 1, 1, NULL, NULL, reo3.polesite, 3); + CHECK_REOBJECT_STRUCT(reole, REO_IOB_USE_CP, REO_GETOBJ_ALL_INTERFACES, 2, 2, NULL, NULL, reo2.polesite, 2); received_reo.cbStruct = sizeof(received_reo); received_reo.polesite = (IOleClientSite *)0xdeadbeef; received_reo.dwUser = 4; received_reo.cp = 4; hr = IRichEditOle_GetObject(reole, REO_IOB_USE_CP, &received_reo, REO_GETOBJ_ALL_INTERFACES); - ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08lx\n", hr); ok(received_reo.polesite == (IOleClientSite *)0xdeadbeef, "Got wrong site interface.\n"); - ok(received_reo.dwUser == 4, "Got wrong user-defined value: %d.\n", received_reo.dwUser); + ok(received_reo.dwUser == 4, "Got wrong user-defined value: %ld.\n", received_reo.dwUser); SendMessageA(hwnd, EM_SETSEL, 0, 1); - CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo1.polesite, 1); + CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 0, 0, NULL, NULL, reo1.polesite, 1); SendMessageA(hwnd, EM_SETSEL, 1, 2); - CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo3.polesite, 3); + CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 0, 1, NULL, NULL, reo3.polesite, 3); SendMessageA(hwnd, EM_SETSEL, 2, 3); - CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo2.polesite, 2); + CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 0, 2, NULL, NULL, reo2.polesite, 2); SendMessageA(hwnd, EM_SETSEL, 0, 2); - CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo1.polesite, 1); + CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 0, 0, NULL, NULL, reo1.polesite, 1); SendMessageA(hwnd, EM_SETSEL, 1, 3); - CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo3.polesite, 3); + CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 0, 1, NULL, NULL, reo3.polesite, 3); SendMessageA(hwnd, EM_SETSEL, 2, 0); - CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo1.polesite, 1); + CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 0, 0, NULL, NULL, reo1.polesite, 1); SendMessageA(hwnd, EM_SETSEL, 0, 6); - CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo1.polesite, 1); + CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 0, 0, NULL, NULL, reo1.polesite, 1); SendMessageA(hwnd, EM_SETSEL, 4, 5); received_reo.cbStruct = sizeof(received_reo); received_reo.cp = 0; hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo, REO_GETOBJ_ALL_INTERFACES); - ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08lx\n", hr); SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1); /* "abc|d|efg" */ - INSERT_REOBJECT(reole, &reo1, 3, 1); - INSERT_REOBJECT(reole, &reo2, 5, 2); + INSERT_REOBJECT(callback, reole, &reo1, 3, 1); + INSERT_REOBJECT(callback, reole, &reo2, 5, 2); SendMessageW(hwnd, EM_SETSEL, 2, 3); result = SendMessageW(hwnd, EM_SELECTIONTYPE, 0, 0); - ok(result == SEL_TEXT, "Got selection type: %x.\n", result); + ok(result == SEL_TEXT, "Got selection type: %lx.\n", result); SendMessageW(hwnd, EM_SETSEL, 3, 4); result = SendMessageW(hwnd, EM_SELECTIONTYPE, 0, 0); - todo_wine ok(result == SEL_OBJECT, "Got selection type: %x.\n", result); - todo_wine CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 1, NULL, NULL, reo1.polesite, 1); + ok(result == SEL_OBJECT, "Got selection type: %lx.\n", result); + CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 1, 3, NULL, NULL, reo1.polesite, 1); SendMessageW(hwnd, EM_SETSEL, 2, 4); result = SendMessageW(hwnd, EM_SELECTIONTYPE, 0, 0); - todo_wine ok(result == (SEL_TEXT | SEL_OBJECT), "Got selection type: %x.\n", result); + ok(result == (SEL_TEXT | SEL_OBJECT), "Got selection type: %lx.\n", result); SendMessageW(hwnd, EM_SETSEL, 5, 6); - todo_wine CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 1, NULL, NULL, reo2.polesite, 2); + CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 1, 5, NULL, NULL, reo2.polesite, 2); #ifdef __REACTOS__ expected_string = L"abc\xfffc"L"d\xfffc"L"efg"; @@ -3399,29 +4075,53 @@ static void test_InsertObject(void) gettextex.lpDefaultChar = NULL; gettextex.lpUsedDefChar = NULL; result = SendMessageW(hwnd, EM_GETTEXTEX, (WPARAM)&gettextex, (LPARAM)buffer); - ok(result == lstrlenW(expected_string), "Got wrong length: %d.\n", result); + ok(result == lstrlenW(expected_string), "Got wrong length: %ld.\n", result); todo_wine ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer)); gettextex.flags = GT_RAWTEXT; memset(buffer, 0, sizeof(buffer)); result = SendMessageW(hwnd, EM_GETTEXTEX, (WPARAM)&gettextex, (LPARAM)buffer); - ok(result == lstrlenW(expected_string), "Got wrong length: %d.\n", result); + ok(result == lstrlenW(expected_string), "Got wrong length: %ld.\n", result); todo_wine ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer)); + gettextex.flags = GT_NOHIDDENTEXT; + memset(buffer, 0, sizeof(buffer)); + result = SendMessageW(hwnd, EM_GETTEXTEX, (WPARAM)&gettextex, (LPARAM)buffer); + ok(result == lstrlenW(expected_string), "Got wrong length: %ld.\n", result); + todo_wine ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer)); + + gettextex.flags = GT_SELECTION; + memset(buffer, 0, sizeof(buffer)); + SendMessageW(hwnd, EM_SETSEL, 0, -1); + result = SendMessageW(hwnd, EM_GETTEXTEX, (WPARAM)&gettextex, (LPARAM)buffer); + ok(result == lstrlenW(expected_string), "Got wrong length: %ld.\n", result); + todo_wine ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer)); + + expected_string = L"abc d efg"; + gettextex.flags = GT_USECRLF; + memset(buffer, 0, sizeof(buffer)); + result = SendMessageW(hwnd, EM_GETTEXTEX, (WPARAM)&gettextex, (LPARAM)buffer); + ok(result == lstrlenW(expected_string), "Got wrong length: %ld.\n", result); + ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer)); + expected_stringA = "abc d efg"; memset(bufferA, 0, sizeof(bufferA)); SendMessageA(hwnd, EM_SETSEL, 0, -1); - result = SendMessageA(hwnd, EM_GETSELTEXT, (WPARAM)sizeof(bufferA), (LPARAM)bufferA); - ok(result == strlen(expected_stringA), "Got wrong length: %d.\n", result); - todo_wine ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA); + SetLastError(0xdeadbeef); + result = SendMessageA(hwnd, EM_GETSELTEXT, 0, (LPARAM)bufferA); + gle = GetLastError(); + ok(result == strlen(expected_stringA) || broken(bad_getsel && result == 0), + "Got wrong length: %ld (gle %lu)\n", result, gle); + ok(!strcmp(bufferA, expected_stringA) || broken(bad_getsel && !*bufferA), + "Got wrong content: %s (gle %lu)\n", bufferA, gle); memset(bufferA, 0, sizeof(bufferA)); textrange.lpstrText = bufferA; textrange.chrg.cpMin = 0; textrange.chrg.cpMax = 11; result = SendMessageA(hwnd, EM_GETTEXTRANGE, 0, (LPARAM)&textrange); - ok(result == strlen(expected_stringA), "Got wrong length: %d.\n", result); - todo_wine ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA); + ok(result == strlen(expected_stringA), "Got wrong length: %ld.\n", result); + ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA); #ifdef __REACTOS__ expected_string = L"abc\xfffc"L"d\xfffc"L"efg\r"; @@ -3430,53 +4130,55 @@ static void test_InsertObject(void) #endif hr = ITextDocument_Range(doc, 0, 11, &range); - ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(hr == S_OK, "Got hr %#lx.\n", hr); hr = ITextRange_GetText(range, &bstr); - ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(hr == S_OK, "Got hr %#lx.\n", hr); ok(lstrlenW(bstr) == lstrlenW(expected_string), "Got wrong length: %d.\n", lstrlenW(bstr)); todo_wine ok(!lstrcmpW(bstr, expected_string), "Got text: %s.\n", wine_dbgstr_w(bstr)); SysFreeString(bstr); hr = ITextRange_SetRange(range, 3, 4); - ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(hr == S_OK, "Got hr %#lx.\n", hr); hr = ITextRange_GetChar(range, &result); - ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(result == 0xfffc, "Got char: %c\n", result); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + todo_wine ok(result == 0xfffc, "Got char: %lc\n", (WCHAR)result); ITextRange_Release(range); SendMessageW(hwnd, EM_SETSEL, 0, -1); hr = ITextSelection_GetText(selection, &bstr); - ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(hr == S_OK, "Got hr %#lx.\n", hr); ok(lstrlenW(bstr) == lstrlenW(expected_string), "Got wrong length: %d.\n", lstrlenW(bstr)); todo_wine ok(!lstrcmpW(bstr, expected_string), "Got text: %s.\n", wine_dbgstr_w(bstr)); SysFreeString(bstr); SendMessageW(hwnd, EM_SETSEL, 3, 4); result = 0; hr = ITextSelection_GetChar(selection, &result); - ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(result == 0xfffc, "Got char: %c\n", result); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + todo_wine ok(result == 0xfffc, "Got char: %lc\n", (WCHAR)result); SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)""); result = SendMessageW(hwnd, EM_SETTEXTMODE, (WPARAM)TM_PLAINTEXT, 0); - ok(!result, "Got result %x.\n", result); + ok(!result, "Got result %lx.\n", result); /* "abc|d|efg" */ SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1); - INSERT_REOBJECT(reole, &reo1, 3, 1); - INSERT_REOBJECT(reole, &reo2, 5, 2); + INSERT_REOBJECT(callback, reole, &reo1, 3, 1); + INSERT_REOBJECT(callback, reole, &reo2, 5, 2); expected_string = L"abc d efg"; charrange.cpMin = 0; charrange.cpMax = 11; hr = IRichEditOle_GetClipboardData(reole, &charrange, 1, &dataobject); - ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(hr == S_OK, "Got hr %#lx.\n", hr); formatetc.cfFormat = CF_UNICODETEXT; formatetc.dwAspect = DVASPECT_CONTENT; formatetc.ptd = NULL; formatetc.tymed = TYMED_HGLOBAL; formatetc.lindex = -1; hr = IDataObject_GetData(dataobject, &formatetc, &stgmedium); - ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(lstrlenW(stgmedium.hGlobal) == lstrlenW(expected_string), "Got wrong length: %d.\n", result); - todo_wine ok(!lstrcmpW(stgmedium.hGlobal, expected_string), "Got wrong content: %s.\n", debugstr_w(stgmedium.hGlobal)); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + string = GlobalLock(stgmedium.hGlobal); + ok(lstrlenW(string) == lstrlenW(expected_string), "Got wrong length: %d.\n", lstrlenW(string)); + ok(!lstrcmpW(string, expected_string), "Got wrong content: %s.\n", debugstr_w(string)); + GlobalUnlock(stgmedium.hGlobal); #ifdef __REACTOS__ expected_string = L"abc\xfffc"L"d\xfffc"L"efg"; @@ -3490,29 +4192,33 @@ static void test_InsertObject(void) gettextex.lpDefaultChar = NULL; gettextex.lpUsedDefChar = NULL; result = SendMessageW(hwnd, EM_GETTEXTEX, (WPARAM)&gettextex, (LPARAM)buffer); - ok(result == lstrlenW(expected_string), "Got wrong length: %d.\n", result); + ok(result == lstrlenW(expected_string), "Got wrong length: %ld.\n", result); todo_wine ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer)); gettextex.flags = GT_RAWTEXT; memset(buffer, 0, sizeof(buffer)); result = SendMessageW(hwnd, EM_GETTEXTEX, (WPARAM)&gettextex, (LPARAM)buffer); - ok(result == lstrlenW(expected_string), "Got wrong length: %d.\n", result); + ok(result == lstrlenW(expected_string), "Got wrong length: %ld.\n", result); todo_wine ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer)); expected_stringA = "abc d efg"; memset(bufferA, 0, sizeof(bufferA)); SendMessageA(hwnd, EM_SETSEL, 0, -1); - result = SendMessageA(hwnd, EM_GETSELTEXT, (WPARAM)sizeof(bufferA), (LPARAM)bufferA); - ok(result == strlen(expected_stringA), "Got wrong length: %d.\n", result); - todo_wine ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA); + SetLastError(0xdeadbeef); + result = SendMessageA(hwnd, EM_GETSELTEXT, 0, (LPARAM)bufferA); + gle = GetLastError(); + ok(result == strlen(expected_stringA) || broken(bad_getsel && result == 0), + "Got wrong length: %ld (gle %lu)\n", result, gle); + ok(!strcmp(bufferA, expected_stringA) || broken(bad_getsel && !*bufferA), + "Got wrong content: %s (gle %lu)\n", bufferA, gle); memset(bufferA, 0, sizeof(bufferA)); textrange.lpstrText = bufferA; textrange.chrg.cpMin = 0; textrange.chrg.cpMax = 11; result = SendMessageA(hwnd, EM_GETTEXTRANGE, 0, (LPARAM)&textrange); - ok(result == strlen(expected_stringA), "Got wrong length: %d.\n", result); - todo_wine ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA); + ok(result == strlen(expected_stringA), "Got wrong length: %ld.\n", result); + ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA); #ifdef __REACTOS__ expected_string = L"abc\xfffc"L"d\xfffc"L"efg"; @@ -3521,34 +4227,126 @@ static void test_InsertObject(void) #endif hr = ITextDocument_Range(doc, 0, 11, &range); - ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(hr == S_OK, "Got hr %#lx.\n", hr); hr = ITextRange_GetText(range, &bstr); - ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(hr == S_OK, "Got hr %#lx.\n", hr); todo_wine ok(lstrlenW(bstr) == lstrlenW(expected_string), "Got wrong length: %d.\n", lstrlenW(bstr)); todo_wine ok(!lstrcmpW(bstr, expected_string), "Got text: %s.\n", wine_dbgstr_w(bstr)); SysFreeString(bstr); hr = ITextRange_SetRange(range, 3, 4); - ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(hr == S_OK, "Got hr %#lx.\n", hr); hr = ITextRange_GetChar(range, &result); - ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(result == 0xfffc, "Got char: %c\n", result); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + todo_wine ok(result == 0xfffc, "Got char: %lc\n", (WCHAR)result); ITextRange_Release(range); SendMessageW(hwnd, EM_SETSEL, 0, -1); hr = ITextSelection_GetText(selection, &bstr); - ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(hr == S_OK, "Got hr %#lx.\n", hr); todo_wine ok(lstrlenW(bstr) == lstrlenW(expected_string), "Got wrong length: %d.\n", lstrlenW(bstr)); todo_wine ok(!lstrcmpW(bstr, expected_string), "Got text: %s.\n", wine_dbgstr_w(bstr)); SysFreeString(bstr); SendMessageW(hwnd, EM_SETSEL, 3, 4); result = 0; hr = ITextSelection_GetChar(selection, &result); - ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(result == 0xfffc, "Got char: %c\n", result); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + todo_wine ok(result == 0xfffc, "Got char: %lc\n", (WCHAR)result); + + hr = testoleobj_Create(&testobj); + ok(hr == S_OK, "testoleobj_Create got hr %#lx.\n", hr); + testobj->extent.cx = 800; + testobj->extent.cy = 400; + + SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)""); + testobj->draw_count = 0; + testobj->line = __LINE__; + + hr = IRichEditOle_GetClientSite(reole, &clientsite); + ok(hr == S_OK, "IRichEditOle_GetClientSite got hr %#lx.\n", hr); + hr = IOleObject_SetClientSite(&testobj->IOleObject_iface, clientsite); + ok(hr == S_OK, "IOleObject_SetClientSite got hr %#lx.\n", hr); + + olecb_expect_QueryInsertObject(callback, __LINE__, 1, + &CLSID_testoleobj, NULL, REO_CP_SELECTION, S_OK); + fill_reobject_struct(&reobj, REO_CP_SELECTION, &testobj->IOleObject_iface, NULL, clientsite, 800, 400, DVASPECT_CONTENT, 0, 0); + reobj.clsid = CLSID_testoleobj; + hr = IRichEditOle_InsertObject(reole, &reobj); + ok(hr == S_OK, "IRichEditOle_InsertObject got hr %#lx.\n", hr); + olecb_check_QueryInsertObject(callback, __LINE__); + + IOleClientSite_Release(clientsite); + + testobj->line = __LINE__; + UpdateWindow(hwnd); + testobj->line = __LINE__; + flush_dispatch_messages(); + ok(testobj->draw_count != 0, "expected draw_count to be nonzero, got %d\n", testobj->draw_count); + + SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)""); + testobj->draw_count = 0; + testobj->line = __LINE__; + + hr = IRichEditOle_GetClientSite(reole, &clientsite); + ok(hr == S_OK, "IRichEditOle_GetClientSite got hr %#lx.\n", hr); + hr = IOleObject_SetClientSite(&testobj->IOleObject_iface, clientsite); + ok(hr == S_OK, "IOleObject_SetClientSite got hr %#lx.\n", hr); + + olecb_expect_QueryInsertObject(callback, __LINE__, 1, + &CLSID_testoleobj, NULL, REO_CP_SELECTION, S_OK); + fill_reobject_struct(&reobj, REO_CP_SELECTION, &testobj->IOleObject_iface, NULL, clientsite, 0, 0, DVASPECT_CONTENT, 0, 0); + reobj.clsid = CLSID_testoleobj; + hr = IRichEditOle_InsertObject(reole, &reobj); + ok(hr == S_OK, "IRichEditOle_InsertObject got hr %#lx.\n", hr); + olecb_check_QueryInsertObject(callback, __LINE__); + + memset(&reobj, 0xcc, sizeof(reobj)); + reobj.cbStruct = sizeof(reobj); + hr = IRichEditOle_GetObject(reole, 0, &reobj, REO_GETOBJ_NO_INTERFACES); + ok(hr == S_OK, "IRichEditOle_GetObject got hr %#lx.\n", hr); + ok(reobj.sizel.cx == 800, "expected reobj.sizel.cx to be %ld, got %ld\n", 800L, reobj.sizel.cx); + ok(reobj.sizel.cy == 400, "expected reobj.sizel.cy to be %ld, got %ld\n", 400L, reobj.sizel.cy); + IOleClientSite_Release(clientsite); + + testobj->line = __LINE__; + UpdateWindow(hwnd); + testobj->line = __LINE__; + flush_dispatch_messages(); + ok(testobj->draw_count != 0, "expected draw_count to be nonzero, got %d\n", testobj->draw_count); + + SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)""); + IOleObject_Release(&testobj->IOleObject_iface); + + if (callback) + { + LRESULT sendres = SendMessageA(hwnd, EM_SETOLECALLBACK, 0, 0); + ok( !!sendres, "EM_SETOLECALLBACK should succeed\n" ); + } release_interfaces(&hwnd, &reole, &doc, &selection); } +static void test_InsertObject(void) +{ + struct reolecb_obj *callback; + HRESULT hr; + ULONG ref; + + subtest_InsertObject(NULL); + + hr = reolecb_obj_Create(&callback); + ok(SUCCEEDED(hr), "reolecb_obj_Create returned %#lx\n", hr); + if (SUCCEEDED(hr)) + { + subtest_InsertObject(callback); + ref = IRichEditOleCallback_Release(&callback->IRichEditOleCallback_iface); + ok(ref == 0, "expected IRichEditOleCallback recount to be 0, got %lu\n", ref); + } + else + { + skip("cannot test InsertObject with callback\n"); + } +} + static void test_GetStoryLength(void) { static const CHAR test_text1[] = "TestSomeText"; @@ -3565,53 +4363,53 @@ static void test_GetStoryLength(void) SendMessageA(hwnd, EM_SETSEL, 1, 2); hr = ITextDocument_Range(doc, 0, 4, &range); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); hr = ITextRange_GetStoryLength(range, NULL); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); value = 0; hr = ITextRange_GetStoryLength(range, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == 13, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == 13, "got %ld\n", value); hr = ITextSelection_GetStoryLength(selection, NULL); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); value = 0; hr = ITextSelection_GetStoryLength(selection, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == 13, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == 13, "got %ld\n", value); SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)""); value = 0; hr = ITextRange_GetStoryLength(range, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == 1, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == 1, "got %ld\n", value); value = 0; hr = ITextSelection_GetStoryLength(selection, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == 1, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == 1, "got %ld\n", value); release_interfaces(&hwnd, &reOle, &doc, NULL); hr = ITextRange_GetStoryLength(range, NULL); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); value = 100; hr = ITextRange_GetStoryLength(range, &value); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); - ok(value == 100, "got %d\n", value); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); + ok(value == 100, "got %ld\n", value); hr = ITextSelection_GetStoryLength(selection, NULL); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); value = 100; hr = ITextSelection_GetStoryLength(selection, &value); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); - ok(value == 100, "got %d\n", value); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); + ok(value == 100, "got %ld\n", value); ITextSelection_Release(selection); ITextRange_Release(range); @@ -3634,15 +4432,15 @@ static void test_ITextSelection_GetDuplicate(void) SendMessageA(hwnd, EM_SETSEL, 1, 2); hr = ITextSelection_GetDuplicate(selection, NULL); - ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr); EXPECT_REF(selection, 2); hr = ITextSelection_GetDuplicate(selection, &range); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); hr = ITextSelection_GetDuplicate(selection, &range2); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); ok(range != range2, "got %p, %p\n", range, range2); EXPECT_REF(selection, 2); @@ -3653,39 +4451,39 @@ static void test_ITextSelection_GetDuplicate(void) value = 0; hr = ITextRange_GetStart(range, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == 1, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == 1, "got %ld\n", value); value = 0; hr = ITextRange_GetEnd(range, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == 2, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == 2, "got %ld\n", value); SendMessageA(hwnd, EM_SETSEL, 2, 3); value = 0; hr = ITextRange_GetStart(range, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == 1, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == 1, "got %ld\n", value); value = 0; hr = ITextRange_GetEnd(range, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == 2, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == 2, "got %ld\n", value); hr = ITextRange_QueryInterface(range, &IID_ITextSelection, (void**)&sel2); - ok(hr == E_NOINTERFACE, "got 0x%08x\n", hr); + ok(hr == E_NOINTERFACE, "got 0x%08lx\n", hr); release_interfaces(&hwnd, &reOle, &doc, NULL); hr = ITextSelection_GetDuplicate(selection, NULL); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); hr = ITextSelection_GetDuplicate(selection, &range); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); hr = ITextRange_GetFont(range, &font); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); ITextSelection_Release(selection); ITextRange_Release(range); @@ -3698,9 +4496,9 @@ static void _reset_range(ITextRange *range, LONG start, LONG end, int line) HRESULT hr; hr = ITextRange_SetStart(range, start); - ok_(__FILE__,line)(hr == S_OK, "SetStart failed: 0x%08x\n", hr); + ok_(__FILE__,line)(hr == S_OK, "SetStart failed: 0x%08lx\n", hr); hr = ITextRange_SetEnd(range, end); - ok_(__FILE__,line)(hr == S_OK, "SetEnd failed: 0x%08x\n", hr); + ok_(__FILE__,line)(hr == S_OK, "SetEnd failed: 0x%08lx\n", hr); } #define CHECK_RANGE(range,expected_start,expected_end) \ @@ -3711,12 +4509,12 @@ static void _check_range(ITextRange* range, LONG expected_start, LONG expected_e LONG value; hr = ITextRange_GetStart(range, &value); - ok_(__FILE__,line)(hr == S_OK, "GetStart failed: 0x%08x\n", hr); - ok_(__FILE__,line)(value == expected_start, "Expected start %d got %d\n", + ok_(__FILE__,line)(hr == S_OK, "GetStart failed: 0x%08lx\n", hr); + ok_(__FILE__,line)(value == expected_start, "Expected start %ld got %ld\n", expected_start, value); hr = ITextRange_GetEnd(range, &value); - ok_(__FILE__,line)(hr == S_OK, "GetEnd failed: 0x%08x\n", hr); - ok_(__FILE__,line)(value == expected_end, "Expected end %d got %d\n", + ok_(__FILE__,line)(hr == S_OK, "GetEnd failed: 0x%08lx\n", hr); + ok_(__FILE__,line)(value == expected_end, "Expected end %ld got %ld\n", expected_end, value); } @@ -3727,9 +4525,9 @@ static void _reset_selection(ITextSelection *selection, LONG start, LONG end, in HRESULT hr; hr = ITextSelection_SetStart(selection, start); - ok_(__FILE__,line)(hr == S_OK, "SetStart failed: 0x%08x\n", hr); + ok_(__FILE__,line)(hr == S_OK, "SetStart failed: 0x%08lx\n", hr); hr = ITextSelection_SetEnd(selection, end); - ok_(__FILE__,line)(hr == S_OK, "SetEnd failed: 0x%08x\n", hr); + ok_(__FILE__,line)(hr == S_OK, "SetEnd failed: 0x%08lx\n", hr); } #define CHECK_SELECTION(selection,expected_start,expected_end) \ @@ -3740,12 +4538,12 @@ static void _check_selection(ITextSelection *selection, LONG expected_start, LON LONG value; hr = ITextSelection_GetStart(selection, &value); - ok_(__FILE__,line)(hr == S_OK, "GetStart failed: 0x%08x\n", hr); - ok_(__FILE__,line)(value == expected_start, "Expected start %d got %d\n", + ok_(__FILE__,line)(hr == S_OK, "GetStart failed: 0x%08lx\n", hr); + ok_(__FILE__,line)(value == expected_start, "Expected start %ld got %ld\n", expected_start, value); hr = ITextSelection_GetEnd(selection, &value); - ok_(__FILE__,line)(hr == S_OK, "GetEnd failed: 0x%08x\n", hr); - ok_(__FILE__,line)(value == expected_end, "Expected end %d got %d\n", + ok_(__FILE__,line)(hr == S_OK, "GetEnd failed: 0x%08lx\n", hr); + ok_(__FILE__,line)(value == expected_end, "Expected end %ld got %ld\n", expected_end, value); } @@ -3763,31 +4561,31 @@ static void test_ITextRange_SetRange(void) ITextDocument_Range(txtDoc, 0, 0, &txtRge); hr = ITextRange_SetRange(txtRge, 2, 4); - ok(hr == S_OK, "got 0x%08x.\n", hr); + ok(hr == S_OK, "got 0x%08lx.\n", hr); CHECK_RANGE(txtRge, 2, 4); hr = ITextRange_SetRange(txtRge, 2, 4); - ok(hr == S_FALSE, "got 0x%08x.\n", hr); + ok(hr == S_FALSE, "got 0x%08lx.\n", hr); CHECK_RANGE(txtRge, 2, 4); hr = ITextRange_SetRange(txtRge, 4, 2); - ok(hr == S_FALSE, "got 0x%08x.\n", hr); + ok(hr == S_FALSE, "got 0x%08lx.\n", hr); CHECK_RANGE(txtRge, 2, 4); hr = ITextRange_SetRange(txtRge, 14, 14); - ok(hr == S_OK, "got 0x%08x.\n", hr); + ok(hr == S_OK, "got 0x%08lx.\n", hr); CHECK_RANGE(txtRge, 12, 12); hr = ITextRange_SetRange(txtRge, 15, 15); - ok(hr == S_FALSE, "got 0x%08x.\n", hr); + ok(hr == S_FALSE, "got 0x%08lx.\n", hr); CHECK_RANGE(txtRge, 12, 12); hr = ITextRange_SetRange(txtRge, 14, 1); - ok(hr == S_OK, "got 0x%08x.\n", hr); + ok(hr == S_OK, "got 0x%08lx.\n", hr); CHECK_RANGE(txtRge, 1, 13); hr = ITextRange_SetRange(txtRge, -1, 4); - ok(hr == S_OK, "got 0x%08x.\n", hr); + ok(hr == S_OK, "got 0x%08lx.\n", hr); CHECK_RANGE(txtRge, 0, 4); ITextRange_Release(txtRge); @@ -3810,14 +4608,14 @@ static void test_Expand(void) SendMessageA(hwnd, EM_SETSEL, 1, 2); hr = ITextDocument_Range(doc, 0, 4, &range); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); hr = ITextRange_Expand(range, tomStory, NULL); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); CHECK_RANGE(range, 0, 13); hr = ITextSelection_Expand(selection, tomStory, NULL); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); CHECK_SELECTION(selection, 0, 13); RESET_RANGE(range, 1, 2); @@ -3825,29 +4623,29 @@ static void test_Expand(void) value = 0; hr = ITextRange_Expand(range, tomStory, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == 12, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == 12, "got %ld\n", value); CHECK_RANGE(range, 0, 13); value = 0; hr = ITextSelection_Expand(selection, tomStory, &value); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(value == 12, "got %d\n", value); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(value == 12, "got %ld\n", value); CHECK_SELECTION(selection, 0, 13); release_interfaces(&hwnd, &reole, &doc, NULL); hr = ITextRange_Expand(range, tomStory, NULL); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); hr = ITextRange_Expand(range, tomStory, &value); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); hr = ITextSelection_Expand(selection, tomStory, NULL); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); hr = ITextSelection_Expand(selection, tomStory, &value); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); ITextSelection_Release(selection); ITextRange_Release(range); @@ -3869,99 +4667,99 @@ static void test_MoveEnd_story(void) SendMessageA(hwnd, EM_SETSEL, 1, 2); hr = ITextDocument_Range(doc, 1, 2, &range); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); hr = ITextRange_MoveEnd(range, tomStory, 0, &delta); - ok(hr == S_FALSE, "got 0x%08x\n", hr); - ok(delta == 0, "got %d\n", delta); + ok(hr == S_FALSE, "got 0x%08lx\n", hr); + ok(delta == 0, "got %ld\n", delta); CHECK_RANGE(range, 1, 2); hr = ITextRange_MoveEnd(range, tomStory, -1, &delta); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(delta == -1, "got %d\n", delta); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(delta == -1, "got %ld\n", delta); CHECK_RANGE(range, 0, 0); hr = ITextRange_MoveEnd(range, tomStory, 1, &delta); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(delta == 1, "got %d\n", delta); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(delta == 1, "got %ld\n", delta); CHECK_RANGE(range, 0, 12); hr = ITextRange_MoveEnd(range, tomStory, 1, &delta); - ok(hr == S_FALSE, "got 0x%08x\n", hr); - ok(delta == 0, "got %d\n", delta); + ok(hr == S_FALSE, "got 0x%08lx\n", hr); + ok(delta == 0, "got %ld\n", delta); CHECK_RANGE(range, 0, 12); RESET_RANGE(range, 1, 2); hr = ITextRange_MoveEnd(range, tomStory, 3, &delta); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(delta == 1, "got %d\n", delta); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(delta == 1, "got %ld\n", delta); CHECK_RANGE(range, 1, 12); RESET_RANGE(range, 2, 3); hr = ITextRange_MoveEnd(range, tomStory, -3, &delta); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(delta == -1, "got %d\n", delta); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(delta == -1, "got %ld\n", delta); CHECK_RANGE(range, 0, 0); hr = ITextRange_MoveEnd(range, tomStory, -1, &delta); - ok(hr == S_FALSE, "got 0x%08x\n", hr); - ok(delta == 0, "got %d\n", delta); + ok(hr == S_FALSE, "got 0x%08lx\n", hr); + ok(delta == 0, "got %ld\n", delta); CHECK_RANGE(range, 0, 0); hr = ITextSelection_MoveEnd(selection, tomStory, 0, &delta); - ok(hr == S_FALSE, "got 0x%08x\n", hr); - ok(delta == 0, "got %d\n", delta); + ok(hr == S_FALSE, "got 0x%08lx\n", hr); + ok(delta == 0, "got %ld\n", delta); CHECK_SELECTION(selection, 1, 2); hr = ITextSelection_MoveEnd(selection, tomStory, -1, &delta); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(delta == -1, "got %d\n", delta); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(delta == -1, "got %ld\n", delta); CHECK_SELECTION(selection, 0, 0); hr = ITextSelection_MoveEnd(selection, tomStory, 1, &delta); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(delta == 1, "got %d\n", delta); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(delta == 1, "got %ld\n", delta); CHECK_SELECTION(selection, 0, 12); hr = ITextSelection_MoveEnd(selection, tomStory, 1, &delta); - ok(hr == S_FALSE, "got 0x%08x\n", hr); - ok(delta == 0, "got %d\n", delta); + ok(hr == S_FALSE, "got 0x%08lx\n", hr); + ok(delta == 0, "got %ld\n", delta); CHECK_SELECTION(selection, 0, 12); RESET_SELECTION(selection, 1, 2); hr = ITextSelection_MoveEnd(selection, tomStory, 3, &delta); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(delta == 1, "got %d\n", delta); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(delta == 1, "got %ld\n", delta); CHECK_SELECTION(selection, 1, 12); RESET_SELECTION(selection, 2, 3); hr = ITextSelection_MoveEnd(selection, tomStory, -3, &delta); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(delta == -1, "got %d\n", delta); + ok(hr == S_OK, "got 0x%08lx\n", hr); + ok(delta == -1, "got %ld\n", delta); CHECK_SELECTION(selection, 0, 0); hr = ITextSelection_MoveEnd(selection, tomStory, -1, &delta); - ok(hr == S_FALSE, "got 0x%08x\n", hr); - ok(delta == 0, "got %d\n", delta); + ok(hr == S_FALSE, "got 0x%08lx\n", hr); + ok(delta == 0, "got %ld\n", delta); CHECK_SELECTION(selection, 0, 0); release_interfaces(&hwnd, &reole, &doc, NULL); hr = ITextRange_MoveEnd(range, tomStory, 1, NULL); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); hr = ITextRange_MoveEnd(range, tomStory, 1, &delta); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); hr = ITextSelection_MoveEnd(selection, tomStory, 1, NULL); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); hr = ITextSelection_MoveEnd(selection, tomStory, 1, &delta); - ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr); + ok(hr == CO_E_RELEASED, "got 0x%08lx\n", hr); ITextSelection_Release(selection); ITextRange_Release(range); @@ -3980,15 +4778,15 @@ static void test_character_movestart(ITextRange *range, int textlen, int i, int expected_start = textlen; expected_delta = expected_start - i; hr = ITextRange_SetRange(range, i, j); - ok(SUCCEEDED(hr), "got 0x%08x\n", hr); + ok(SUCCEEDED(hr), "got 0x%08lx\n", hr); hr = ITextRange_MoveStart(range, tomCharacter, target - i, &delta); if (expected_start == i) { - ok(hr == S_FALSE, "(%d,%d) move by %d got hr=0x%08x\n", i, j, target - i, hr); - ok(delta == 0, "(%d,%d) move by %d got delta %d\n", i, j, target - i, delta); + ok(hr == S_FALSE, "(%d,%d) move by %ld got hr=0x%08lx\n", i, j, target - i, hr); + ok(delta == 0, "(%d,%d) move by %ld got delta %ld\n", i, j, target - i, delta); CHECK_RANGE(range, i, j); } else { - ok(hr == S_OK, "(%d,%d) move by %d got hr=0x%08x\n", i, j, target - i, hr); - ok(delta == expected_delta, "(%d,%d) move by %d got delta %d\n", i, j, target - i, delta); + ok(hr == S_OK, "(%d,%d) move by %ld got hr=0x%08lx\n", i, j, target - i, hr); + ok(delta == expected_delta, "(%d,%d) move by %ld got delta %ld\n", i, j, target - i, delta); if (expected_start <= j) CHECK_RANGE(range, expected_start, j); else @@ -4009,15 +4807,15 @@ static void test_character_moveend(ITextRange *range, int textlen, int i, int j, expected_end = textlen + 1; expected_delta = expected_end - j; hr = ITextRange_SetRange(range, i, j); - ok(SUCCEEDED(hr), "got 0x%08x\n", hr); + ok(SUCCEEDED(hr), "got 0x%08lx\n", hr); hr = ITextRange_MoveEnd(range, tomCharacter, target - j, &delta); if (expected_end == j) { - ok(hr == S_FALSE, "(%d,%d) move by %d got hr=0x%08x\n", i, j, target - j, hr); - ok(delta == 0, "(%d,%d) move by %d got delta %d\n", i, j, target - j, delta); + ok(hr == S_FALSE, "(%d,%d) move by %ld got hr=0x%08lx\n", i, j, target - j, hr); + ok(delta == 0, "(%d,%d) move by %ld got delta %ld\n", i, j, target - j, delta); CHECK_RANGE(range, i, j); } else { - ok(hr == S_OK, "(%d,%d) move by %d got hr=0x%08x\n", i, j, target - j, hr); - ok(delta == expected_delta, "(%d,%d) move by %d got delta %d\n", i, j, target - j, delta); + ok(hr == S_OK, "(%d,%d) move by %ld got hr=0x%08lx\n", i, j, target - j, hr); + ok(delta == expected_delta, "(%d,%d) move by %ld got delta %ld\n", i, j, target - j, delta); if (i <= expected_end) CHECK_RANGE(range, i, expected_end); else @@ -4058,15 +4856,15 @@ static void test_character_move(ITextRange *range, int textlen, int i, int j, LO } hr = ITextRange_SetRange(range, i, j); - ok(SUCCEEDED(hr), "got 0x%08x\n", hr); + ok(SUCCEEDED(hr), "got 0x%08lx\n", hr); hr = ITextRange_Move(range, tomCharacter, move_by, &delta); if (expected_delta == 0) { - ok(hr == S_FALSE, "(%d,%d) move by %d got hr=0x%08x\n", i, j, move_by, hr); - ok(delta == 0, "(%d,%d) move by %d got delta %d\n", i, j, move_by, delta); + ok(hr == S_FALSE, "(%d,%d) move by %ld got hr=0x%08lx\n", i, j, move_by, hr); + ok(delta == 0, "(%d,%d) move by %ld got delta %ld\n", i, j, move_by, delta); CHECK_RANGE(range, expected_location, expected_location); } else { - ok(hr == S_OK, "(%d,%d) move by %d got hr=0x%08x\n", i, j, move_by, hr); - ok(delta == expected_delta, "(%d,%d) move by %d got delta %d\n", i, j, move_by, delta); + ok(hr == S_OK, "(%d,%d) move by %ld got hr=0x%08lx\n", i, j, move_by, hr); + ok(delta == expected_delta, "(%d,%d) move by %ld got delta %ld\n", i, j, move_by, delta); CHECK_RANGE(range, expected_location, expected_location); } } @@ -4077,22 +4875,22 @@ static void test_character_startof(ITextRange *range, int textlen, int i, int j) LONG delta; hr = ITextRange_SetRange(range, i, j); - ok(SUCCEEDED(hr), "got 0x%08x\n", hr); + ok(SUCCEEDED(hr), "got 0x%08lx\n", hr); hr = ITextRange_StartOf(range, tomCharacter, tomMove, &delta); if (i == j) { - ok(hr == S_FALSE, "(%d,%d) tomMove got hr=0x%08x\n", i, j, hr); - ok(delta == 0, "(%d,%d) tomMove got delta %d\n", i, j, delta); + ok(hr == S_FALSE, "(%d,%d) tomMove got hr=0x%08lx\n", i, j, hr); + ok(delta == 0, "(%d,%d) tomMove got delta %ld\n", i, j, delta); } else { - ok(hr == S_OK, "(%d,%d) tomMove got hr=0x%08x\n", i, j, hr); - ok(delta == -1, "(%d,%d) tomMove got delta %d\n", i, j, delta); + ok(hr == S_OK, "(%d,%d) tomMove got hr=0x%08lx\n", i, j, hr); + ok(delta == -1, "(%d,%d) tomMove got delta %ld\n", i, j, delta); } CHECK_RANGE(range, i, i); hr = ITextRange_SetRange(range, i, j); - ok(SUCCEEDED(hr), "got 0x%08x\n", hr); + ok(SUCCEEDED(hr), "got 0x%08lx\n", hr); hr = ITextRange_StartOf(range, tomCharacter, tomExtend, &delta); - ok(hr == S_FALSE, "(%d,%d) tomExtend got hr=0x%08x\n", i, j, hr); - ok(delta == 0, "(%d,%d) tomExtend got delta %d\n", i, j, delta); + ok(hr == S_FALSE, "(%d,%d) tomExtend got hr=0x%08lx\n", i, j, hr); + ok(delta == 0, "(%d,%d) tomExtend got delta %ld\n", i, j, delta); CHECK_RANGE(range, i, j); } @@ -4103,7 +4901,7 @@ static void test_character_endof(ITextRange *range, int textlen, int i, int j) LONG delta; hr = ITextRange_SetRange(range, i, j); - ok(SUCCEEDED(hr), "got 0x%08x\n", hr); + ok(SUCCEEDED(hr), "got 0x%08lx\n", hr); hr = ITextRange_EndOf(range, tomCharacter, tomMove, &delta); /* A character "end", apparently cannot be before the very first character */ @@ -4112,23 +4910,23 @@ static void test_character_endof(ITextRange *range, int textlen, int i, int j) ++end; if (i == end) { - ok(hr == S_FALSE, "(%d,%d) tomMove got hr=0x%08x\n", i, j, hr); - ok(delta == 0, "(%d,%d) tomMove got delta %d\n", i, j, delta); + ok(hr == S_FALSE, "(%d,%d) tomMove got hr=0x%08lx\n", i, j, hr); + ok(delta == 0, "(%d,%d) tomMove got delta %ld\n", i, j, delta); } else { - ok(hr == S_OK, "(%d,%d) tomMove got hr=0x%08x\n", i, j, hr); - ok(delta == 1, "(%d,%d) tomMove got delta %d\n", i, j, delta); + ok(hr == S_OK, "(%d,%d) tomMove got hr=0x%08lx\n", i, j, hr); + ok(delta == 1, "(%d,%d) tomMove got delta %ld\n", i, j, delta); } CHECK_RANGE(range, end, end); hr = ITextRange_SetRange(range, i, j); - ok(SUCCEEDED(hr), "got 0x%08x\n", hr); + ok(SUCCEEDED(hr), "got 0x%08lx\n", hr); hr = ITextRange_EndOf(range, tomCharacter, tomExtend, &delta); if (0 < j) { - ok(hr == S_FALSE, "(%d,%d) tomExtend got hr=0x%08x\n", i, j, hr); - ok(delta == 0, "(%d,%d) tomExtend got delta %d\n", i, j, delta); + ok(hr == S_FALSE, "(%d,%d) tomExtend got hr=0x%08lx\n", i, j, hr); + ok(delta == 0, "(%d,%d) tomExtend got delta %ld\n", i, j, delta); } else { - ok(hr == S_OK, "(%d,%d) tomExtend got hr=0x%08x\n", i, j, hr); - ok(delta == 1, "(%d,%d) tomExtend got delta %d\n", i, j, delta); + ok(hr == S_OK, "(%d,%d) tomExtend got hr=0x%08lx\n", i, j, hr); + ok(delta == 1, "(%d,%d) tomExtend got delta %ld\n", i, j, delta); } CHECK_RANGE(range, i, end); } @@ -4149,7 +4947,7 @@ static void test_character_movement(void) SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1); hr = ITextDocument_Range(doc, 0, 0, &range); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); /* Exhaustive test of every possible combination of (start,end) locations, * against every possible target location to move to. */ @@ -4171,6 +4969,35 @@ static void test_character_movement(void) ITextRange_Release(range); } +static BOOL open_clipboard(HWND hwnd) +{ + DWORD start = GetTickCount(); + while (1) + { + BOOL ret = OpenClipboard(hwnd); + if (ret || GetLastError() != ERROR_ACCESS_DENIED) + return ret; + if (GetTickCount() - start > 100) + { + char classname[256]; + DWORD le = GetLastError(); + HWND clipwnd = GetOpenClipboardWindow(); + /* Provide a hint as to the source of interference: + * - The class name would typically be CLIPBRDWNDCLASS if the + * clipboard was opened by a Windows application using the + * ole32 API. + * - And it would be __wine_clipboard_manager if it was opened in + * response to a native application. + */ + GetClassNameA(clipwnd, classname, ARRAY_SIZE(classname)); + trace("%p (%s) opened the clipboard\n", clipwnd, classname); + SetLastError(le); + return ret; + } + Sleep(15); + } +} + #define CLIPBOARD_RANGE_CONTAINS(range, start, end, expected) _clipboard_range_contains(range, start, end, expected, __LINE__, 0); #define TODO_CLIPBOARD_RANGE_CONTAINS(range, start, end, expected) _clipboard_range_contains(range, start, end, expected, __LINE__, 1); static void _clipboard_range_contains(ITextRange *range, LONG start, LONG end, const char *expected, int line, int todo) @@ -4181,12 +5008,12 @@ static void _clipboard_range_contains(ITextRange *range, LONG start, LONG end, c const char *clipboard_text; hr = ITextRange_SetRange(range, start, end); - ok_(__FILE__,line)(SUCCEEDED(hr), "SetRange failed: 0x%08x\n", hr); + ok_(__FILE__,line)(SUCCEEDED(hr), "SetRange failed: 0x%08lx\n", hr); hr = ITextRange_Copy(range, NULL); - ok_(__FILE__,line)(hr == S_OK, "Copy failed: 0x%08x\n", hr); + ok_(__FILE__,line)(hr == S_OK, "Copy failed: 0x%08lx\n", hr); - clipboard_open = OpenClipboard(NULL); - ok_(__FILE__,line)(clipboard_open, "OpenClipboard failed: %d\n", GetLastError()); + clipboard_open = open_clipboard(NULL); + ok_(__FILE__,line)(clipboard_open, "OpenClipboard failed: %ld\n", GetLastError()); global = GetClipboardData(CF_TEXT); ok_(__FILE__,line)(global != NULL, "GetClipboardData failed: %p\n", global); clipboard_text = GlobalLock(global); @@ -4217,7 +5044,7 @@ static void test_clipboard(void) SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)text_in); hr = ITextDocument_Range(doc, 0, 0, &range); - ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08lx\n", hr); CLIPBOARD_RANGE_CONTAINS(range, 0, 5, "ab\r\n c") CLIPBOARD_RANGE_CONTAINS(range, 0, 0, "ab\r\n c") @@ -4231,26 +5058,556 @@ static void test_clipboard(void) /* Cut can be undone */ hr = ITextRange_SetRange(range, 0, 1); - ok(SUCCEEDED(hr), "SetRange failed: 0x%08x\n", hr); + ok(SUCCEEDED(hr), "SetRange failed: 0x%08lx\n", hr); hr = ITextRange_Cut(range, NULL); - ok(hr == S_OK, "Cut failed: 0x%08x\n", hr); + ok(hr == S_OK, "Cut failed: 0x%08lx\n", hr); CLIPBOARD_RANGE_CONTAINS(range, 0, 4, "b\r\n c"); hr = ITextDocument_Undo(doc, 1, NULL); - todo_wine ok(hr == S_OK, "Undo failed: 0x%08x\n", hr); - TODO_CLIPBOARD_RANGE_CONTAINS(range, 0, 5, "ab\r\n c"); + ok(hr == S_OK, "Undo failed: 0x%08lx\n", hr); + CLIPBOARD_RANGE_CONTAINS(range, 0, 5, "ab\r\n c"); /* Cannot cut when read-only */ SendMessageA(hwnd, EM_SETREADONLY, TRUE, 0); hr = ITextRange_SetRange(range, 0, 1); - ok(SUCCEEDED(hr), "SetRange failed: 0x%08x\n", hr); + ok(SUCCEEDED(hr), "SetRange failed: 0x%08lx\n", hr); hr = ITextRange_Cut(range, NULL); - ok(hr == E_ACCESSDENIED, "got 0x%08x\n", hr); + ok(hr == E_ACCESSDENIED, "got 0x%08lx\n", hr); release_interfaces(&hwnd, &reole, &doc, NULL); ITextSelection_Release(selection); ITextRange_Release(range); } +static void subtest_undo(const char *dummy_text) +{ + static const char *text_seq[] = { + "", + "1-alpha", + "2-beta", + "3-gamma", + "4-delta", + "5-epsilon", + "6-zeta", + "7-eta", + }; + static LONG seq[] = { -1, -2, -3, -1, 1, 2, 3, 1, -5, 2, -1, 3, 1, 0 }; + LONG i = 0, stack_pos = 0; + IRichEditOle *reole = NULL; + ITextDocument *doc = NULL; + ITextSelection *selection; + char buffer[1024] = ""; + HRESULT hr; + HWND hwnd; + LONG count = 0; + + winetest_push_context("(%Iu)", dummy_text ? strlen(dummy_text) : 0); + + create_interfaces(&hwnd, &reole, &doc, &selection); + + for (i = -2; i <= 2; i++) + { + if (i != tomFalse && i != tomTrue) + { + hr = ITextDocument_Undo(doc, i, NULL); + todo_wine_if(i >= 1) + ok(hr == (i >= 1 ? S_OK : S_FALSE), "(%ld@0) Undo: %#lx\n", i, hr); + + count = 0xcccccccc; + hr = ITextDocument_Undo(doc, i, &count); + todo_wine_if(i >= 1) + ok(hr == (i >= 1 ? S_OK : S_FALSE), "(%ld@0) Undo: %#lx\n", i, hr); + todo_wine_if(i >= 1) + ok(count == (i >= 1 ? i : 0), "(%ld@0) Expected %ld, got %ld\n", i, i >= 0 ? i : 0, count); + } + + hr = ITextDocument_Redo(doc, i, NULL); + ok(hr == (i == 0 ? S_OK : S_FALSE), "(%ld@0) Redo: %#lx\n", i, hr); + + count = 0xcccccccc; + hr = ITextDocument_Redo(doc, i, &count); + ok(hr == (i == 0 ? S_OK : S_FALSE), "(%ld@0) Redo: %#lx\n", i, hr); + ok(count == 0, "(%ld@0) got %ld\n", i, count); + } + + while (stack_pos < ARRAY_SIZE(text_seq) - 1) + { + stack_pos++; + if (dummy_text) + { + hr = ITextDocument_Undo(doc, tomSuspend, NULL); + ok(hr == S_FALSE, "(@%ld) Undo: %#lx\n", stack_pos, hr); + if (SUCCEEDED(hr)) + { + SendMessageA(hwnd, EM_SETSEL, 0, 0); + SendMessageA(hwnd, EM_REPLACESEL, TRUE, (LPARAM)dummy_text); + SendMessageA(hwnd, EM_SETSEL, 0, strlen(dummy_text)); + SendMessageA(hwnd, EM_REPLACESEL, TRUE, (LPARAM)""); + hr = ITextDocument_Undo(doc, tomResume, NULL); + ok(hr == S_FALSE, "(@%ld) Undo: %#lx\n", stack_pos, hr); + } + } + SendMessageA(hwnd, EM_SETSEL, 0, -1); + SendMessageA(hwnd, EM_REPLACESEL, TRUE, (LPARAM)text_seq[stack_pos]); + } + + for (i = 0; i < ARRAY_SIZE(seq); i++) + { + LONG expect_count; + + memset(buffer, 0, sizeof(buffer)); + SendMessageA(hwnd, WM_GETTEXT, ARRAY_SIZE(buffer), (LPARAM)buffer); + ok(strcmp(buffer, text_seq[stack_pos]) == 0, "Expected %s, got %s\n", + wine_dbgstr_a(text_seq[stack_pos]), wine_dbgstr_a(buffer)); + + if (!seq[i]) break; + + count = 0xcccccccc; + expect_count = labs(stack_pos - min(max(stack_pos + seq[i], 0), (LONG)ARRAY_SIZE(seq) - 1)); + if (seq[i] < 0) + { + hr = ITextDocument_Undo(doc, -seq[i], &count); + ok(hr == S_OK, "(%ld@%ld) Undo: %#lx\n", i, stack_pos, hr); + ok(count == expect_count, "(%ld@%ld) Expected %ld, got %ld\n", i, stack_pos, expect_count, count); + stack_pos -= count; + } + else + { + hr = ITextDocument_Redo(doc, seq[i], &count); + ok(hr == (expect_count ? S_OK : S_FALSE), "(%ld@%ld) Redo: %#lx\n", i, stack_pos, hr); + ok(count == expect_count, "(%ld@%ld) Expected %ld, got %ld\n", i, stack_pos, expect_count, count); + stack_pos += count; + } + + if (FAILED(hr) || count <= 0) break; + } + + release_interfaces(&hwnd, &reole, &doc, &selection); + winetest_pop_context(); +} + +static void test_undo(void) +{ + subtest_undo(NULL); + subtest_undo("dummy 12345"); +} + +#define ok_msg_result(h,m,w,l,r) ok_msg_result_(__LINE__,#m,h,m,w,l,r) +static void ok_msg_result_(int line, const char *desc, HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam, LRESULT expect) +{ + LRESULT lresult = SendMessageA(hwnd, message, wparam, lparam); + ok_(__FILE__,line)(lresult == expect, "%s: Expected %Id, got %Id\n", desc, expect, lresult); +} + +enum editorUndoState { + firstUndoState = 0, + undoStateActive = 0, + undoStateSuspended = 1, + undoStateDisabled = 2, + numUndoStates = 3, +}; + +enum editorUndoStateAction { + firstUndoAction = 0, + undoActionNoOp = 0, + undoActionEnable = 1, + undoActionDisable = 2, + undoActionSuspend = 3, + undoActionResume = 4, + numUndoActions = 5 +}; + +enum editorUndoStateTestFlags { + undoTestUseWindowMessages = 0x1, + undoTestResetUndoLimit = 0x2, + undoTestDoFirstUndo = 0x4, + undoTestDoFirstRedo = 0x8, + undoTestDoSecondUndoAfterEnable = 0x10, + undoTestMaxFlag = 0x20, +}; + +struct undo_test +{ + HWND hwnd; + ITextDocument *doc; + int test_flags; + enum editorUndoState undo_ctl_state; + LONG_PTR undo_limit; + BOOL last_undo_status; + BOOL last_redo_status; +}; + +static HRESULT perform_editor_undo_state_action(struct undo_test *inst, enum editorUndoStateAction action, LONG *count) +{ + HRESULT hr = S_OK; + + if (count) *count = 0xcccccccc; + + switch (action) + { + case undoActionNoOp: + if (count) *count = 0; + break; + case undoActionEnable: + if (inst->test_flags & undoTestResetUndoLimit) + { + LONG_PTR cur_undo_limit = SendMessageA(inst->hwnd, EM_SETUNDOLIMIT, inst->undo_limit, 0); + ok(cur_undo_limit == inst->undo_limit, "Expected undo limit %Id, got %Id\n", + inst->undo_limit, cur_undo_limit); + if (count) *count = 0; + } + else + { + hr = ITextDocument_Undo(inst->doc, tomTrue, count); + ok(hr == S_FALSE, "Undo: %#lx\n", hr); + } + if (SUCCEEDED(hr)) + { + if (inst->undo_ctl_state == undoStateDisabled) + { + inst->undo_ctl_state = undoStateActive; + } + inst->last_undo_status = TRUE; + } + break; + case undoActionDisable: + hr = ITextDocument_Undo(inst->doc, tomFalse, count); + ok(hr == S_OK, "Undo: %#lx\n", hr); + if (SUCCEEDED(hr)) + { + inst->undo_ctl_state = undoStateDisabled; + inst->last_undo_status = FALSE; + inst->last_redo_status = FALSE; + } + break; + case undoActionSuspend: + hr = ITextDocument_Undo(inst->doc, tomSuspend, count); + ok(hr == S_FALSE, "Undo: %#lx\n", hr); + if (SUCCEEDED(hr) && inst->undo_ctl_state == undoStateActive) + { + inst->undo_ctl_state = undoStateSuspended; + } + break; + case undoActionResume: + hr = ITextDocument_Undo(inst->doc, tomResume, count); + ok(hr == S_FALSE, "Undo: %#lx\n", hr); + if (SUCCEEDED(hr)) + { + inst->undo_ctl_state = undoStateActive; + } + break; + default: + ok(0, "unreachable\n"); + break; + } + + if (count) + { + ok(*count == 0, "Got %ld\n", *count); + } + return hr; +} + +static HRESULT set_editor_undo_state(struct undo_test *inst, enum editorUndoState state) +{ + HRESULT hr = S_OK; + if (inst->undo_ctl_state == state) return hr; + switch (state) + { + case undoStateActive: + if (FAILED(hr = perform_editor_undo_state_action(inst, undoActionEnable, NULL))) break; + if (FAILED(hr = perform_editor_undo_state_action(inst, undoActionResume, NULL))) break; + break; + case undoStateSuspended: + if (FAILED(hr = perform_editor_undo_state_action(inst, undoActionEnable, NULL))) break; + if (FAILED(hr = perform_editor_undo_state_action(inst, undoActionSuspend, NULL))) break; + break; + case undoStateDisabled: + if (FAILED(hr = perform_editor_undo_state_action(inst, undoActionDisable, NULL))) break; + break; + default: + ok(0, "unreachable\n"); + break; + } + ok(inst->undo_ctl_state == state, "expected state %d, got %d\n", state, inst->undo_ctl_state); + ok(SUCCEEDED(hr), "cannot set state to %d: %#lx\n", undoStateActive, hr); + return hr; +} + +#define perform_undo(i,c) perform_undo_(i,c,__LINE__) +static BOOL perform_undo_(struct undo_test *inst, BOOL can_undo, int line) +{ + LONG count; + HRESULT hr; + BOOL result, expect; + + if (inst->test_flags & undoTestUseWindowMessages) + { + LRESULT lres = SendMessageA(inst->hwnd, EM_UNDO, 0, 0); + ok_(__FILE__, line)(lres == FALSE || lres == TRUE, "unexpected LRESULT %#Ix\n", lres); + result = lres; + } + else + { + count = 0xcccccccc; + hr = ITextDocument_Undo(inst->doc, 1, &count); + ok_(__FILE__, line)(SUCCEEDED(hr), "got hr %#lx\n", hr); + ok_(__FILE__, line)(count == (hr == S_OK), "expected count %d, got %ld\n", hr == S_OK, count); + result = hr == S_OK && count > 0; + } + + expect = FALSE; + if (inst->undo_ctl_state == undoStateActive) + { + if (can_undo) inst->last_undo_status = TRUE; + expect = inst->last_undo_status; + } + todo_wine_if(!can_undo && !result && expect) + ok_(__FILE__, line)(result == expect, "state %d: expected %d, got %d\n", inst->undo_ctl_state, expect, result); + + return can_undo && result; +} + +#define perform_redo(i,c) perform_redo_(i,c,__LINE__) +static BOOL perform_redo_(struct undo_test *inst, BOOL can_redo, int line) +{ + LONG count; + HRESULT hr; + BOOL result, expect; + + if (inst->test_flags & undoTestUseWindowMessages) + { + LRESULT lres = SendMessageA(inst->hwnd, EM_REDO, 0, 0); + ok_(__FILE__, line)(lres == FALSE || lres == TRUE, "unexpected LRESULT %#Ix\n", lres); + result = lres; + } + else + { + count = 0xcccccccc; + hr = ITextDocument_Redo(inst->doc, 1, &count); + ok_(__FILE__, line)(SUCCEEDED(hr), "got hr %#lx\n", hr); + ok_(__FILE__, line)(count == (hr == S_OK), "expected count %d, got %ld\n", hr == S_OK, count); + result = hr == S_OK && count > 0; + } + + expect = FALSE; + if (inst->undo_ctl_state == undoStateActive) + { + if (can_redo) inst->last_redo_status = TRUE; + expect = inst->last_redo_status; + } + todo_wine_if(!can_redo && !result && expect) + ok_(__FILE__, line)(result == expect, "state %d: expected %d, got %d\n", inst->undo_ctl_state, expect, result); + + return can_redo && result; +} + +static HRESULT subtest_undo_control(struct undo_test *inst, enum editorUndoStateAction action) +{ + LONG undo_count, redo_count, count; + static const char text_foo[] = "foo"; + static const char text_bar[] = "bar"; + static const char *last_text, *last_text2; + char buffer[1024] = ""; + HRESULT hr; + + SendMessageA(inst->hwnd, EM_EMPTYUNDOBUFFER, 0, 0); + undo_count = redo_count = 0; + ok_msg_result(inst->hwnd, EM_CANUNDO, 0, 0, undo_count > 0); + ok_msg_result(inst->hwnd, EM_CANREDO, 0, 0, redo_count > 0); + + SendMessageA(inst->hwnd, WM_SETTEXT, 0, (LPARAM)(last_text = "")); + SendMessageA(inst->hwnd, WM_GETTEXT, ARRAY_SIZE(buffer), (LPARAM)buffer); + last_text = ""; + ok(strcmp(buffer, last_text) == 0, + "Expected %s, got %s\n", wine_dbgstr_a(""), wine_dbgstr_a(buffer)); + + SendMessageA(inst->hwnd, EM_SETSEL, 0, -1); + SendMessageA(inst->hwnd, EM_REPLACESEL, TRUE, (LPARAM)(last_text = text_foo)); + if (inst->undo_ctl_state == undoStateActive) undo_count++, redo_count = 0; + ok_msg_result(inst->hwnd, EM_CANUNDO, 0, 0, undo_count > 0); + ok_msg_result(inst->hwnd, EM_CANREDO, 0, 0, redo_count > 0); + SendMessageA(inst->hwnd, WM_GETTEXT, ARRAY_SIZE(buffer), (LPARAM)buffer); + ok(strcmp(buffer, last_text) == 0, "Expected %s, got %s\n", wine_dbgstr_a(text_foo), wine_dbgstr_a(buffer)); + + hr = perform_editor_undo_state_action(inst, action, &count); + ok(SUCCEEDED(hr), "got %#lx\n", hr); + if (FAILED(hr)) return hr; + if (inst->undo_ctl_state == undoStateDisabled) undo_count = redo_count = 0; + ok_msg_result(inst->hwnd, EM_CANUNDO, 0, 0, undo_count > 0); + ok_msg_result(inst->hwnd, EM_CANREDO, 0, 0, redo_count > 0); + + if (inst->test_flags & undoTestDoFirstUndo) + { + if (perform_undo(inst, undo_count > 0)) undo_count--, redo_count++, last_text = ""; + ok_msg_result(inst->hwnd, EM_CANUNDO, 0, 0, undo_count > 0); + ok_msg_result(inst->hwnd, EM_CANREDO, 0, 0, redo_count > 0); + SendMessageA(inst->hwnd, WM_GETTEXT, ARRAY_SIZE(buffer), (LPARAM)buffer); + ok(strcmp(buffer, last_text) == 0, "Expected %s, got %s\n", wine_dbgstr_a(last_text), wine_dbgstr_a(buffer)); + } + + if (inst->test_flags & undoTestDoSecondUndoAfterEnable) + { + hr = perform_editor_undo_state_action(inst, undoActionEnable, &count); + ok(SUCCEEDED(hr), "got %#lx\n", hr); + if (FAILED(hr)) return hr; + ok_msg_result(inst->hwnd, EM_CANUNDO, 0, 0, undo_count > 0); + ok_msg_result(inst->hwnd, EM_CANREDO, 0, 0, redo_count > 0); + + if (perform_undo(inst, undo_count > 0)) undo_count--, redo_count++, last_text = ""; + ok_msg_result(inst->hwnd, EM_CANUNDO, 0, 0, undo_count > 0); + ok_msg_result(inst->hwnd, EM_CANREDO, 0, 0, redo_count > 0); + SendMessageA(inst->hwnd, WM_GETTEXT, ARRAY_SIZE(buffer), (LPARAM)buffer); + ok(strcmp(buffer, last_text) == 0, "Expected %s, got %s\n", wine_dbgstr_a(last_text), wine_dbgstr_a(buffer)); + } + + if (inst->test_flags & undoTestDoFirstRedo) + { + if (perform_redo(inst, redo_count > 0)) undo_count++, redo_count--, last_text = text_foo; + ok_msg_result(inst->hwnd, EM_CANUNDO, 0, 0, undo_count > 0); + ok_msg_result(inst->hwnd, EM_CANREDO, 0, 0, redo_count > 0); + SendMessageA(inst->hwnd, WM_GETTEXT, ARRAY_SIZE(buffer), (LPARAM)buffer); + ok(strcmp(buffer, last_text) == 0, "Expected %s, got %s\n", wine_dbgstr_a(last_text), wine_dbgstr_a(buffer)); + } + + SendMessageA(inst->hwnd, EM_SETSEL, 0, -1); + SendMessageA(inst->hwnd, EM_REPLACESEL, TRUE, (LPARAM)(last_text2 = text_bar)); + if (inst->undo_ctl_state == undoStateActive) undo_count++, redo_count = 0; + ok_msg_result(inst->hwnd, EM_CANUNDO, 0, 0, undo_count > 0); + ok_msg_result(inst->hwnd, EM_CANREDO, 0, 0, redo_count > 0); + SendMessageA(inst->hwnd, WM_GETTEXT, ARRAY_SIZE(buffer), (LPARAM)buffer); + ok(strcmp(buffer, last_text2) == 0, "Expected %s, got %s\n", wine_dbgstr_a(last_text2), wine_dbgstr_a(buffer)); + + if (perform_undo(inst, undo_count > 0)) undo_count--, redo_count++, last_text2 = last_text; + ok_msg_result(inst->hwnd, EM_CANUNDO, 0, 0, undo_count > 0); + ok_msg_result(inst->hwnd, EM_CANREDO, 0, 0, redo_count > 0); + SendMessageA(inst->hwnd, WM_GETTEXT, ARRAY_SIZE(buffer), (LPARAM)buffer); + ok(strcmp(buffer, last_text2) == 0, "Expected %s, got %s\n", wine_dbgstr_a(last_text2), wine_dbgstr_a(buffer)); + + if (perform_redo(inst, redo_count > 0)) undo_count++, redo_count--, last_text2 = text_bar; + ok_msg_result(inst->hwnd, EM_CANUNDO, 0, 0, undo_count > 0); + ok_msg_result(inst->hwnd, EM_CANREDO, 0, 0, redo_count > 0); + SendMessageA(inst->hwnd, WM_GETTEXT, ARRAY_SIZE(buffer), (LPARAM)buffer); + ok(strcmp(buffer, last_text2) == 0, "Expected %s, got %s\n", wine_dbgstr_a(last_text2), wine_dbgstr_a(buffer)); + + return S_OK; +} + +static void test_undo_control(void) +{ + enum editorUndoState state0; + enum editorUndoStateAction action0, action1; + IRichEditOle *reole = NULL; + ITextSelection *selection; + struct undo_test inst = { NULL }; + HRESULT hr; + + create_interfaces(&inst.hwnd, &reole, &inst.doc, &selection); + inst.undo_ctl_state = undoStateActive; + inst.last_undo_status = TRUE; + inst.last_redo_status = TRUE; + inst.undo_limit = SendMessageA(inst.hwnd, EM_SETUNDOLIMIT, 100, 0); + ok(inst.undo_limit >= 1, "Message EM_SETUNDOLIMIT returned %#Ix\n", inst.undo_limit); + + if (SUCCEEDED(ITextDocument_Undo(inst.doc, 1, NULL))) + { + for (inst.test_flags = 0; inst.test_flags < undoTestMaxFlag; inst.test_flags++) + { + for (state0 = firstUndoState; state0 < numUndoStates; state0++) + { + for (action0 = firstUndoAction; action0 < numUndoActions; action0++) + { + for (action1 = firstUndoAction; action1 < numUndoActions; action1++) + { + winetest_push_context("%x:%d:%d >?:%d", inst.test_flags, state0, action0, action1); + hr = set_editor_undo_state(&inst, state0); + winetest_pop_context(); + + if (FAILED(hr)) continue; + + winetest_push_context("%x:%d:%d+>?:%d", inst.test_flags, state0, action0, action1); + hr = subtest_undo_control(&inst, action0); + winetest_pop_context(); + + if (FAILED(hr)) continue; + + winetest_push_context("%x:%d:%d>%d:%d+", inst.test_flags, state0, action0, inst.undo_ctl_state, action1); + subtest_undo_control(&inst, action1); + winetest_pop_context(); + } + } + } + } + } + + release_interfaces(&inst.hwnd, &reole, &inst.doc, &selection); +} + +static void test_freeze(void) +{ + ITextSelection *selection = NULL; + DWORD lasterr, style1, style2; + IRichEditOle *reole = NULL; + ITextDocument *doc = NULL; + HRESULT hr; + LONG count; + HWND hwnd; + + create_interfaces(&hwnd, &reole, &doc, &selection); + + SetLastError(0xdeadbeef); + style1 = GetWindowLongW(hwnd, GWL_STYLE); + lasterr = GetLastError(); + ok(lasterr == 0xdeadbeefUL, "GetLastError() returned %#lx\n", lasterr); + + count = 0xdeadbeef; + hr = ITextDocument_Freeze(doc, &count); + ok(hr == S_OK, "ITextDocument_Freeze returned %#lx\n", hr); + ok(count == 1, "expected count to be %d, got %ld\n", 1, count); + + style2 = GetWindowLongW(hwnd, GWL_STYLE); + ok(style2 == style1, "expected window style to not change from %#lx, got %#lx\n", style1, style2); + + count = 0xdeadbeef; + hr = ITextDocument_Freeze(doc, &count); + ok(hr == S_OK, "ITextDocument_Freeze returned %#lx\n", hr); + ok(count == 2, "expected count to be %d, got %ld\n", 2, count); + + count = 0xdeadbeef; + hr = ITextDocument_Unfreeze(doc, &count); + ok(hr == S_FALSE, "ITextDocument_Unfreeze returned %#lx\n", hr); + ok(count == 1, "expected count to be %d, got %ld\n", 1, count); + + count = 0xdeadbeef; + hr = ITextDocument_Unfreeze(doc, &count); + ok(hr == S_OK, "ITextDocument_Unfreeze returned %#lx\n", hr); + ok(count == 0, "expected count to be %d, got %ld\n", 0, count); + + count = 0xdeadbeef; + hr = ITextDocument_Unfreeze(doc, &count); + ok(hr == S_OK, "ITextDocument_Unfreeze returned %#lx\n", hr); + ok(count == 0, "expected count to be %d, got %ld\n", 0, count); + + count = 0xdeadbeef; + hr = ITextDocument_Freeze(doc, &count); + ok(hr == S_OK, "ITextDocument_Freeze returned %#lx\n", hr); + ok(count == 1, "expected count to be %d, got %ld\n", 1, count); + + count = 0xdeadbeef; + hr = ITextDocument_Unfreeze(doc, &count); + ok(hr == S_OK, "ITextDocument_Unfreeze returned %#lx\n", hr); + ok(count == 0, "expected count to be %d, got %ld\n", 0, count); + + count = 0xdeadbeef; + hr = ITextDocument_Freeze(doc, NULL); + ok(hr == S_OK, "ITextDocument_Freeze returned %#lx\n", hr); + + count = 0xdeadbeef; + hr = ITextDocument_Unfreeze(doc, NULL); + ok(hr == S_OK, "ITextDocument_Unfreeze returned %#lx\n", hr); + + release_interfaces(&hwnd, &reole, &doc, &selection); +} + START_TEST(richole) { /* Must explicitly LoadLibrary(). The test has no references to functions in @@ -4292,4 +5649,7 @@ START_TEST(richole) test_MoveEnd_story(); test_character_movement(); test_clipboard(); + test_undo(); + test_undo_control(); + test_freeze(); } diff --git a/modules/rostests/winetests/riched20/txtsrv.c b/modules/rostests/winetests/riched20/txtsrv.c index 1f789da8a37..0b4ac6c2369 100644 --- a/modules/rostests/winetests/riched20/txtsrv.c +++ b/modules/rostests/winetests/riched20/txtsrv.c @@ -38,6 +38,27 @@ #include #include +#define DEFINE_EXPECT(func) \ + static UINT called_count_ ## func = 0 + +#define INCREASE_CALL_COUNTER(func) \ + do { \ + called_count_ ## func++; \ + }while(0) + +#define CHECK_CALLED(func) \ + do { \ + ok(called_count_ ## func, "expected " #func "\n"); \ + }while(0) + +#define CHECK_NOT_CALLED(func) \ + do { \ + ok(!called_count_ ## func, "unexpected " #func "\n"); \ + }while(0) + +#define CLEAR_COUNTER(func) \ + called_count_ ## func = 0 + static HMODULE hmoduleRichEdit; static IID *pIID_ITextServices; static IID *pIID_ITextHost; @@ -81,6 +102,10 @@ static ITextServicesVtbl itextServicesStdcallVtbl; /************************************************************************/ /* ITextHost implementation for conformance testing. */ +DEFINE_EXPECT(ITextHostImpl_TxViewChange); +DEFINE_EXPECT(ITextHostImpl_TxScrollWindowEx); +DEFINE_EXPECT(ITextHostImpl_TxGetClientRect); + typedef struct ITextHostTestImpl { ITextHost ITextHost_iface; @@ -173,7 +198,7 @@ static BOOL __thiscall ITextHostImpl_TxSetScrollRange(ITextHost *iface, INT fnBa INT nMaxPos, BOOL fRedraw) { ITextHostTestImpl *This = impl_from_ITextHost(iface); - TRACECALL("Call to TxSetScrollRange(%p, fnBar=%d, nMinPos=%d, nMaxPos=%d, fRedraw=%d)\n", + TRACECALL("Call to TxSetScrollRange(%p, fnBar=%d, nMinPos=%ld, nMaxPos=%d, fRedraw=%d)\n", This, fnBar, nMinPos, nMaxPos, fRedraw); return FALSE; } @@ -198,6 +223,7 @@ static void __thiscall ITextHostImpl_TxViewChange(ITextHost *iface, BOOL fUpdate ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxViewChange(%p, fUpdate=%d)\n", This, fUpdate); + INCREASE_CALL_COUNTER(ITextHostImpl_TxViewChange); } static BOOL __thiscall ITextHostImpl_TxCreateCaret(ITextHost *iface, HBITMAP hbmp, INT xWidth, INT yHeight) @@ -244,6 +270,7 @@ static void __thiscall ITextHostImpl_TxScrollWindowEx(ITextHost *iface, INT dx, ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxScrollWindowEx(%p, %d, %d, %p, %p, %p, %p, %d)\n", This, dx, dy, lprcScroll, lprcClip, hRgnUpdate, lprcUpdate, fuScroll); + INCREASE_CALL_COUNTER(ITextHostImpl_TxScrollWindowEx); } static void __thiscall ITextHostImpl_TxSetCapture(ITextHost *iface, BOOL fCapture) @@ -289,7 +316,7 @@ static HRESULT __thiscall ITextHostImpl_TxActivate(ITextHost *iface, LONG *plOld static HRESULT __thiscall ITextHostImpl_TxDeactivate(ITextHost *iface, LONG lNewState) { ITextHostTestImpl *This = impl_from_ITextHost(iface); - TRACECALL("Call to TxDeactivate(%p, lNewState=%d)\n", This, lNewState); + TRACECALL("Call to TxDeactivate(%p, lNewState=%ld)\n", This, lNewState); return E_NOTIMPL; } @@ -297,6 +324,7 @@ static HRESULT __thiscall ITextHostImpl_TxGetClientRect(ITextHost *iface, LPRECT { ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxGetClientRect(%p, prc=%p)\n", This, prc); + INCREASE_CALL_COUNTER(ITextHostImpl_TxGetClientRect); *prc = This->client_rect; return S_OK; } @@ -392,7 +420,7 @@ static HRESULT __thiscall ITextHostImpl_OnTxParaFormatChange(ITextHost *iface, c static HRESULT __thiscall ITextHostImpl_TxGetPropertyBits(ITextHost *iface, DWORD dwMask, DWORD *pdwBits) { ITextHostTestImpl *This = impl_from_ITextHost(iface); - TRACECALL("Call to TxGetPropertyBits(%p, dwMask=0x%08x, pdwBits=%p)\n", + TRACECALL("Call to TxGetPropertyBits(%p, dwMask=0x%08lx, pdwBits=%p)\n", This, dwMask, pdwBits); *pdwBits = This->props & dwMask; return S_OK; @@ -400,10 +428,12 @@ static HRESULT __thiscall ITextHostImpl_TxGetPropertyBits(ITextHost *iface, DWOR static int en_vscroll_sent; static int en_update_sent; +static int en_change_sent; +static int en_selchange_sent; static HRESULT __thiscall ITextHostImpl_TxNotify( ITextHost *iface, DWORD code, void *data ) { ITextHostTestImpl *This = impl_from_ITextHost(iface); - TRACECALL( "Call to TxNotify(%p, code = %#x, data = %p)\n", This, code, data ); + TRACECALL( "Call to TxNotify(%p, code = %#lx, data = %p)\n", This, code, data ); switch (code) { case EN_VSCROLL: @@ -414,6 +444,15 @@ static HRESULT __thiscall ITextHostImpl_TxNotify( ITextHost *iface, DWORD code, en_update_sent++; ok( !data, "got %p\n", data ); break; + case EN_CHANGE: + en_change_sent++; + todo_wine + ok( data != NULL, "got %p\n", data ); + break; + case EN_SELCHANGE: + en_selchange_sent++; + ok( data != NULL, "got %p\n", data ); + break; } return S_OK; } @@ -620,7 +659,7 @@ static BOOL init_texthost(ITextServices **txtserv, ITextHost **ret) memset(&dummyTextHost->char_format, 0, sizeof(dummyTextHost->char_format)); dummyTextHost->char_format.cbSize = sizeof(dummyTextHost->char_format); dummyTextHost->char_format.dwMask = CFM_ALL2; - dummyTextHost->scrollbars = 0; + dummyTextHost->scrollbars = ES_AUTOVSCROLL; dummyTextHost->props = 0; hf = GetStockObject(DEFAULT_GUI_FONT); hf_to_cf(hf, &dummyTextHost->char_format); @@ -629,8 +668,8 @@ static BOOL init_texthost(ITextServices **txtserv, ITextHost **ret) CreateTextServices which is then queried to obtain a ITextServices object. */ result = pCreateTextServices(NULL, &dummyTextHost->ITextHost_iface, &init); - ok(result == S_OK, "Did not return S_OK when created (result = %x)\n", result); - ok(dummyTextHost->refCount == 1, "host ref %d\n", dummyTextHost->refCount); + ok(result == S_OK, "Did not return S_OK when created (result = %lx)\n", result); + ok(dummyTextHost->refCount == 1, "host ref %ld\n", dummyTextHost->refCount); if (result != S_OK) { CoTaskMemFree(dummyTextHost); win_skip("CreateTextServices failed.\n"); @@ -638,7 +677,7 @@ static BOOL init_texthost(ITextServices **txtserv, ITextHost **ret) } result = IUnknown_QueryInterface(init, pIID_ITextServices, (void**)txtserv); - ok((result == S_OK) && (*txtserv != NULL), "Querying interface failed (result = %x, txtserv = %p)\n", result, *txtserv); + ok((result == S_OK) && (*txtserv != NULL), "Querying interface failed (result = %lx, txtserv = %p)\n", result, *txtserv); IUnknown_Release(init); if (!((result == S_OK) && (*txtserv != NULL))) { CoTaskMemFree(dummyTextHost); @@ -682,21 +721,21 @@ static void test_TxGetText(void) return; hres = ITextServices_TxGetText(txtserv, &rettext); - ok(hres == S_OK, "ITextServices_TxGetText failed (result = %x)\n", hres); + ok(hres == S_OK, "ITextServices_TxGetText failed (result = %lx)\n", hres); SysFreeString(rettext); hres = ITextServices_TxSetText(txtserv, L"abcdefg"); - ok(hres == S_OK, "Got hres: %#x.\n", hres); + ok(hres == S_OK, "Got hres: %#lx.\n", hres); hres = ITextServices_QueryInterface(txtserv, &IID_IRichEditOle, (void **)&reole); - ok(hres == S_OK, "Got hres: %#x.\n", hres); + ok(hres == S_OK, "Got hres: %#lx.\n", hres); hres = IRichEditOle_GetClientSite(reole, &clientsite); - ok(hres == S_OK, "Got hres: %#x.\n", hres); + ok(hres == S_OK, "Got hres: %#lx.\n", hres); expected_string = L"abc\xfffc""defg"; fill_reobject_struct(&reobject, 3, NULL, NULL, clientsite, 10, 10, DVASPECT_CONTENT, 0, 1); hres = IRichEditOle_InsertObject(reole, &reobject); - ok(hres == S_OK, "Got hres: %#x.\n", hres); + ok(hres == S_OK, "Got hres: %#lx.\n", hres); hres = ITextServices_TxGetText(txtserv, &rettext); - ok(hres == S_OK, "Got hres: %#x.\n", hres); + ok(hres == S_OK, "Got hres: %#lx.\n", hres); ok(lstrlenW(rettext) == lstrlenW(expected_string), "Got wrong length: %d.\n", lstrlenW(rettext)); todo_wine ok(!lstrcmpW(rettext, expected_string), "Got wrong content: %s.\n", debugstr_w(rettext)); SysFreeString(rettext); @@ -719,10 +758,10 @@ static void test_TxSetText(void) return; hres = ITextServices_TxSetText(txtserv, settext); - ok(hres == S_OK, "ITextServices_TxSetText failed (result = %x)\n", hres); + ok(hres == S_OK, "ITextServices_TxSetText failed (result = %lx)\n", hres); hres = ITextServices_TxGetText(txtserv, &rettext); - ok(hres == S_OK, "ITextServices_TxGetText failed (result = %x)\n", hres); + ok(hres == S_OK, "ITextServices_TxGetText failed (result = %lx)\n", hres); ok(SysStringLen(rettext) == 4, "String returned of wrong length (expected 4, got %d)\n", SysStringLen(rettext)); @@ -734,10 +773,10 @@ static void test_TxSetText(void) /* Null-pointer should behave the same as empty-string */ hres = ITextServices_TxSetText(txtserv, 0); - ok(hres == S_OK, "ITextServices_TxSetText failed (result = %x)\n", hres); + ok(hres == S_OK, "ITextServices_TxSetText failed (result = %lx)\n", hres); hres = ITextServices_TxGetText(txtserv, &rettext); - ok(hres == S_OK, "ITextServices_TxGetText failed (result = %x)\n", hres); + ok(hres == S_OK, "ITextServices_TxGetText failed (result = %lx)\n", hres); ok(SysStringLen(rettext) == 0, "String returned of wrong length (expected 0, got %d)\n", SysStringLen(rettext)); @@ -753,13 +792,13 @@ static void _check_txgetnaturalsize(HRESULT res, LONG width, LONG height, HDC hd RECT expected_rect = rect; LONG expected_width, expected_height; - DrawTextW(hdc, string, -1, &expected_rect, DT_LEFT | DT_CALCRECT | DT_NOCLIP | DT_EDITCONTROL | DT_WORDBREAK); + DrawTextW(hdc, string, -1, &expected_rect, DT_LEFT | DT_CALCRECT | DT_NOCLIP | DT_EDITCONTROL); expected_width = expected_rect.right - expected_rect.left; expected_height = expected_rect.bottom - expected_rect.top; - ok_(__FILE__,line)(res == S_OK, "ITextServices_TxGetNaturalSize failed: 0x%08x.\n", res); + ok_(__FILE__,line)(res == S_OK, "ITextServices_TxGetNaturalSize failed: 0x%08lx.\n", res); todo_wine ok_(__FILE__,line)(width >= expected_width && width <= expected_width + 1, - "got wrong width: %d, expected: %d {+1}.\n", width, expected_width); - ok_(__FILE__,line)(height == expected_height, "got wrong height: %d, expected: %d.\n", + "got wrong width: %ld, expected: %ld {+1}.\n", width, expected_width); + ok_(__FILE__,line)(height == expected_height, "got wrong height: %ld, expected: %ld.\n", height, expected_height); } @@ -793,11 +832,11 @@ static void test_TxGetNaturalSize(void) hf = GetStockObject(DEFAULT_GUI_FONT); hf_to_cf(hf, &cf); result = ITextServices_TxSendMessage(txtserv, EM_SETCHARFORMAT, SCF_DEFAULT, (LPARAM)&cf, &lresult); - ok(result == S_OK, "ITextServices_TxSendMessage failed: 0x%08x.\n", result); + ok(result == S_OK, "ITextServices_TxSendMessage failed: 0x%08lx.\n", result); SelectObject(hdcDraw, hf); result = ITextServices_TxSetText(txtserv, test_text); - ok(result == S_OK, "ITextServices_TxSetText failed: 0x%08x.\n", result); + ok(result == S_OK, "ITextServices_TxSetText failed: 0x%08lx.\n", result); extent.cx = -1; extent.cy = -1; width = rect.right - rect.left; @@ -815,15 +854,20 @@ static void test_TxGetNaturalSize(void) static void test_TxDraw(void) { ITextServices *txtserv; + ITextDocument *txtdoc; ITextHost *host; HRESULT hr; RECT client = {0, 0, 100, 100}; ITextHostTestImpl *host_impl; + LONG freeze_count; HDC hdc; if (!init_texthost(&txtserv, &host)) return; + hr = ITextServices_QueryInterface( txtserv, &IID_ITextDocument, (void **)&txtdoc ); + ok( hr == S_OK, "ITextServices_QueryInterface (ITextDocument) returned %#lx\n", hr ); + host_impl = impl_from_ITextHost( host ); host_impl->window = CreateWindowExA( 0, "static", NULL, WS_POPUP | WS_VISIBLE, 0, 0, 400, 400, 0, 0, 0, NULL ); @@ -835,30 +879,48 @@ static void test_TxDraw(void) hr = ITextServices_TxDraw( txtserv, DVASPECT_CONTENT, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, TXTVIEW_INACTIVE ); - ok( hr == E_INVALIDARG, "got %08x\n", hr ); + ok( hr == E_INVALIDARG, "got %08lx\n", hr ); hr = ITextServices_TxDraw( txtserv, DVASPECT_CONTENT, 0, NULL, NULL, hdc, NULL, NULL, NULL, NULL, NULL, 0, TXTVIEW_INACTIVE ); - ok( hr == E_INVALIDARG, "got %08x\n", hr ); + ok( hr == E_INVALIDARG, "got %08lx\n", hr ); hr = ITextServices_TxDraw( txtserv, DVASPECT_CONTENT, 0, NULL, NULL, NULL, NULL, (RECTL *)&client, NULL, NULL, NULL, 0, TXTVIEW_INACTIVE ); - ok( hr == E_FAIL, "got %08x\n", hr ); + ok( hr == E_FAIL, "got %08lx\n", hr ); hr = ITextServices_TxDraw( txtserv, DVASPECT_CONTENT, 0, NULL, NULL, hdc, NULL, (RECTL *)&client, NULL, NULL, NULL, 0, TXTVIEW_INACTIVE ); - ok( hr == S_OK, "got %08x\n", hr ); + ok( hr == S_OK, "got %08lx\n", hr ); hr = ITextServices_TxDraw( txtserv, DVASPECT_CONTENT, 0, NULL, NULL, hdc, NULL, (RECTL *)&client, NULL, NULL, NULL, 0, TXTVIEW_ACTIVE ); - ok( hr == S_OK, "got %08x\n", hr ); + ok( hr == S_OK, "got %08lx\n", hr ); hr = ITextServices_OnTxInPlaceActivate( txtserv, &client ); - ok( hr == S_OK, "got %08x\n", hr ); + ok( hr == S_OK, "got %08lx\n", hr ); hr = ITextServices_TxDraw( txtserv, DVASPECT_CONTENT, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, TXTVIEW_INACTIVE ); - ok( hr == S_OK, "got %08x\n", hr ); + ok( hr == S_OK, "got %08lx\n", hr ); + + freeze_count = 0xdeadbeef; + hr = ITextDocument_Freeze( txtdoc, &freeze_count ); + ok( hr == S_OK, "ITextDocument_Freeze returned %#lx\n", hr ); + ok( freeze_count == 1, "expected count to be %d, got %ld\n", 1, freeze_count ); + + hr = ITextServices_TxDraw( txtserv, DVASPECT_CONTENT, 0, NULL, NULL, hdc, NULL, (RECTL *)&client, NULL, + NULL, NULL, 0, TXTVIEW_INACTIVE ); + ok( hr == S_OK, "got %08lx\n", hr ); + hr = ITextServices_TxDraw( txtserv, DVASPECT_CONTENT, 0, NULL, NULL, hdc, NULL, (RECTL *)&client, NULL, + NULL, NULL, 0, TXTVIEW_ACTIVE ); + ok( hr == E_UNEXPECTED, "got %08lx\n", hr ); + + freeze_count = 0xdeadbeef; + hr = ITextDocument_Unfreeze( txtdoc, &freeze_count ); + ok( hr == S_OK, "ITextDocument_Unfreeze returned %#lx\n", hr ); + ok( freeze_count == 0, "expected count to be %d, got %ld\n", 0, freeze_count ); hr = ITextServices_OnTxInPlaceDeactivate( txtserv ); ReleaseDC( host_impl->window, hdc ); + ITextDocument_Release(txtdoc); ITextServices_Release(txtserv); DestroyWindow( host_impl->window ); ITextHost_Release(host); @@ -929,15 +991,15 @@ static void test_COM(void) /* COM aggregation */ hr = pCreateTextServices(&unk_obj.IUnknown_iface, &texthost.ITextHost_iface, &unk_obj.inner_unk); - ok(hr == S_OK, "CreateTextServices failed: %08x\n", hr); + ok(hr == S_OK, "CreateTextServices failed: %08lx\n", hr); hr = IUnknown_QueryInterface(unk_obj.inner_unk, pIID_ITextServices, (void**)&textsrv); - ok(hr == S_OK, "QueryInterface for IID_ITextServices failed: %08x\n", hr); + ok(hr == S_OK, "QueryInterface for IID_ITextServices failed: %08lx\n", hr); refcount = ITextServices_AddRef(textsrv); ok(refcount == unk_obj.ref, "CreateTextServices just pretends to support COM aggregation\n"); refcount = ITextServices_Release(textsrv); ok(refcount == unk_obj.ref, "CreateTextServices just pretends to support COM aggregation\n"); refcount = ITextServices_Release(textsrv); - ok(refcount == 19, "Refcount should be back at 19 but is %u\n", refcount); + ok(refcount == 19, "Refcount should be back at 19 but is %lu\n", refcount); IUnknown_Release(unk_obj.inner_unk); } @@ -963,92 +1025,92 @@ static void test_QueryInterface(void) return; refcount = get_refcount((IUnknown *)txtserv); - ok(refcount == 1, "got wrong ref count: %d\n", refcount); + ok(refcount == 1, "got wrong ref count: %ld\n", refcount); /* IID_IRichEditOle */ hres = ITextServices_QueryInterface(txtserv, &IID_IRichEditOle, (void **)&txtsrv_reole); - ok(hres == S_OK, "ITextServices_QueryInterface: 0x%08x\n", hres); + ok(hres == S_OK, "ITextServices_QueryInterface: 0x%08lx\n", hres); refcount = get_refcount((IUnknown *)txtserv); - ok(refcount == 2, "got wrong ref count: %d\n", refcount); + ok(refcount == 2, "got wrong ref count: %ld\n", refcount); refcount = get_refcount((IUnknown *)txtsrv_reole); - ok(refcount == 2, "got wrong ref count: %d\n", refcount); + ok(refcount == 2, "got wrong ref count: %ld\n", refcount); hres = ITextServices_QueryInterface( txtserv, &IID_IUnknown, (void **)&unk ); - ok( hres == S_OK, "got 0x%08x\n", hres ); + ok( hres == S_OK, "got 0x%08lx\n", hres ); hres = IRichEditOle_QueryInterface( txtsrv_reole, &IID_IUnknown, (void **)&unk2 ); - ok( hres == S_OK, "got 0x%08x\n", hres ); + ok( hres == S_OK, "got 0x%08lx\n", hres ); ok( unk == unk2, "unknowns differ\n" ); IUnknown_Release( unk2 ); IUnknown_Release( unk ); hres = IRichEditOle_QueryInterface(txtsrv_reole, &IID_ITextDocument, (void **)&txtdoc); - ok(hres == S_OK, "IRichEditOle_QueryInterface: 0x%08x\n", hres); + ok(hres == S_OK, "IRichEditOle_QueryInterface: 0x%08lx\n", hres); refcount = get_refcount((IUnknown *)txtserv); - ok(refcount == 3, "got wrong ref count: %d\n", refcount); + ok(refcount == 3, "got wrong ref count: %ld\n", refcount); refcount = get_refcount((IUnknown *)txtsrv_reole); - ok(refcount == 3, "got wrong ref count: %d\n", refcount); + ok(refcount == 3, "got wrong ref count: %ld\n", refcount); ITextDocument_Release(txtdoc); refcount = get_refcount((IUnknown *)txtserv); - ok(refcount == 2, "got wrong ref count: %d\n", refcount); + ok(refcount == 2, "got wrong ref count: %ld\n", refcount); hres = IRichEditOle_QueryInterface(txtsrv_reole, &IID_ITextDocument2Old, (void **)&txtdoc2old); - ok(hres == S_OK, "IRichEditOle_QueryInterface: 0x%08x\n", hres); + ok(hres == S_OK, "IRichEditOle_QueryInterface: 0x%08lx\n", hres); refcount = get_refcount((IUnknown *)txtserv); - ok(refcount == 3, "got wrong ref count: %d\n", refcount); + ok(refcount == 3, "got wrong ref count: %ld\n", refcount); refcount = get_refcount((IUnknown *)txtsrv_reole); - ok(refcount == 3, "got wrong ref count: %d\n", refcount); + ok(refcount == 3, "got wrong ref count: %ld\n", refcount); ITextDocument2Old_Release(txtdoc2old); refcount = get_refcount((IUnknown *)txtserv); - ok(refcount == 2, "got wrong ref count: %d\n", refcount); + ok(refcount == 2, "got wrong ref count: %ld\n", refcount); IRichEditOle_Release(txtsrv_reole); refcount = get_refcount((IUnknown *)txtserv); - ok(refcount == 1, "got wrong ref count: %d\n", refcount); + ok(refcount == 1, "got wrong ref count: %ld\n", refcount); /* IID_ITextDocument */ hres = ITextServices_QueryInterface(txtserv, &IID_ITextDocument, (void **)&txtsrv_txtdoc); - ok(hres == S_OK, "ITextServices_QueryInterface: 0x%08x\n", hres); + ok(hres == S_OK, "ITextServices_QueryInterface: 0x%08lx\n", hres); refcount = get_refcount((IUnknown *)txtserv); - ok(refcount == 2, "got wrong ref count: %d\n", refcount); + ok(refcount == 2, "got wrong ref count: %ld\n", refcount); refcount = get_refcount((IUnknown *)txtsrv_txtdoc); - ok(refcount == 2, "got wrong ref count: %d\n", refcount); + ok(refcount == 2, "got wrong ref count: %ld\n", refcount); hres = ITextDocument_QueryInterface(txtsrv_txtdoc, &IID_IRichEditOle, (void **)&reole); - ok(hres == S_OK, "ITextDocument_QueryInterface: 0x%08x\n", hres); + ok(hres == S_OK, "ITextDocument_QueryInterface: 0x%08lx\n", hres); refcount = get_refcount((IUnknown *)txtserv); - ok(refcount == 3, "got wrong ref count: %d\n", refcount); + ok(refcount == 3, "got wrong ref count: %ld\n", refcount); refcount = get_refcount((IUnknown *)txtsrv_txtdoc); - ok(refcount == 3, "got wrong ref count: %d\n", refcount); + ok(refcount == 3, "got wrong ref count: %ld\n", refcount); IRichEditOle_Release(reole); refcount = get_refcount((IUnknown *)txtserv); - ok(refcount == 2, "got wrong ref count: %d\n", refcount); + ok(refcount == 2, "got wrong ref count: %ld\n", refcount); ITextDocument_Release(txtsrv_txtdoc); refcount = get_refcount((IUnknown *)txtserv); - ok(refcount == 1, "got wrong ref count: %d\n", refcount); + ok(refcount == 1, "got wrong ref count: %ld\n", refcount); /* ITextDocument2Old */ hres = ITextServices_QueryInterface(txtserv, &IID_ITextDocument2Old, (void **)&txtsrv_txtdoc2old); - ok(hres == S_OK, "ITextServices_QueryInterface: 0x%08x\n", hres); + ok(hres == S_OK, "ITextServices_QueryInterface: 0x%08lx\n", hres); refcount = get_refcount((IUnknown *)txtserv); - ok(refcount == 2, "got wrong ref count: %d\n", refcount); + ok(refcount == 2, "got wrong ref count: %ld\n", refcount); refcount = get_refcount((IUnknown *)txtsrv_txtdoc2old); - ok(refcount == 2, "got wrong ref count: %d\n", refcount); + ok(refcount == 2, "got wrong ref count: %ld\n", refcount); hres = ITextDocument2Old_QueryInterface(txtsrv_txtdoc2old, &IID_IRichEditOle, (void **)&reole); - ok(hres == S_OK, "ITextDocument2Old_QueryInterface: 0x%08x\n", hres); + ok(hres == S_OK, "ITextDocument2Old_QueryInterface: 0x%08lx\n", hres); refcount = get_refcount((IUnknown *)txtserv); - ok(refcount == 3, "got wrong ref count: %d\n", refcount); + ok(refcount == 3, "got wrong ref count: %ld\n", refcount); refcount = get_refcount((IUnknown *)txtsrv_txtdoc2old); - ok(refcount == 3, "got wrong ref count: %d\n", refcount); + ok(refcount == 3, "got wrong ref count: %ld\n", refcount); IRichEditOle_Release(reole); refcount = get_refcount((IUnknown *)txtserv); - ok(refcount == 2, "got wrong ref count: %d\n", refcount); + ok(refcount == 2, "got wrong ref count: %ld\n", refcount); ITextDocument2Old_Release(txtsrv_txtdoc2old); refcount = get_refcount((IUnknown *)txtserv); - ok(refcount == 1, "got wrong ref count: %d\n", refcount); + ok(refcount == 1, "got wrong ref count: %ld\n", refcount); ITextServices_Release(txtserv); ITextHost_Release(host); @@ -1069,13 +1131,13 @@ static void test_default_format(void) cf2.cbSize = sizeof(CHARFORMAT2W); result = ITextServices_TxSendMessage(txtserv, EM_GETCHARFORMAT, SCF_DEFAULT, (LPARAM)&cf2, &lresult); - ok(result == S_OK, "ITextServices_TxSendMessage failed: 0x%08x.\n", result); + ok(result == S_OK, "ITextServices_TxSendMessage failed: 0x%08lx.\n", result); ITextHostImpl_TxGetCharFormat(host, &host_cf); ok(!lstrcmpW(host_cf->szFaceName, cf2.szFaceName), "got wrong font name: %s.\n", wine_dbgstr_w(cf2.szFaceName)); - ok(cf2.yHeight == host_cf->yHeight, "got wrong yHeight: %d, expected %d.\n", cf2.yHeight, host_cf->yHeight); + ok(cf2.yHeight == host_cf->yHeight, "got wrong yHeight: %ld, expected %ld.\n", cf2.yHeight, host_cf->yHeight); expected_effects = (cf2.dwEffects & ~(CFE_AUTOCOLOR | CFE_AUTOBACKCOLOR)); - ok(host_cf->dwEffects == expected_effects, "got wrong dwEffects: %x, expected %x.\n", cf2.dwEffects, expected_effects); + ok(host_cf->dwEffects == expected_effects, "got wrong dwEffects: %lx, expected %lx.\n", cf2.dwEffects, expected_effects); ok(cf2.bPitchAndFamily == host_cf->bPitchAndFamily, "got wrong bPitchAndFamily: %x, expected %x.\n", cf2.bPitchAndFamily, host_cf->bPitchAndFamily); ok(cf2.bCharSet == host_cf->bCharSet, "got wrong bCharSet: %x, expected %x.\n", cf2.bCharSet, host_cf->bCharSet); @@ -1100,17 +1162,17 @@ static void test_TxGetScroll(void) host_impl = impl_from_ITextHost( host ); ret = ITextServices_TxGetHScroll(txtserv, NULL, NULL, NULL, NULL, NULL); - ok(ret == S_OK, "ITextServices_TxGetHScroll failed: 0x%08x.\n", ret); + ok(ret == S_OK, "ITextServices_TxGetHScroll failed: 0x%08lx.\n", ret); ret = ITextServices_TxGetVScroll(txtserv, NULL, NULL, NULL, NULL, NULL); - ok(ret == S_OK, "ITextServices_TxGetVScroll failed: 0x%08x.\n", ret); + ok(ret == S_OK, "ITextServices_TxGetVScroll failed: 0x%08lx.\n", ret); ret = ITextServices_TxGetVScroll( txtserv, &min_pos, &max_pos, &pos, &page, &enabled ); - ok( ret == S_OK, "ITextServices_TxGetHScroll failed: 0x%08x.\n", ret ); - ok( min_pos == 0, "got %d\n", min_pos ); - ok( max_pos == 0, "got %d\n", max_pos ); - ok( pos == 0, "got %d\n", pos ); - ok( page == 0, "got %d\n", page ); + ok( ret == S_OK, "ITextServices_TxGetHScroll failed: 0x%08lx.\n", ret ); + ok( min_pos == 0, "got %ld\n", min_pos ); + ok( max_pos == 0, "got %ld\n", max_pos ); + ok( pos == 0, "got %ld\n", pos ); + ok( page == 0, "got %ld\n", page ); ok( !enabled, "got %d\n", enabled ); host_impl->scrollbars = WS_VSCROLL; @@ -1121,26 +1183,26 @@ static void test_TxGetScroll(void) 0, 0, 400, 400, 0, 0, 0, NULL ); host_impl->client_rect = client; ret = ITextServices_OnTxInPlaceActivate( txtserv, &client ); - ok( ret == S_OK, "got 0x%08x.\n", ret ); + ok( ret == S_OK, "got 0x%08lx.\n", ret ); ret = ITextServices_TxGetVScroll( txtserv, &min_pos, &max_pos, &pos, &page, &enabled ); - ok( ret == S_OK, "ITextServices_TxGetHScroll failed: 0x%08x.\n", ret ); - ok( min_pos == 0, "got %d\n", min_pos ); -todo_wine - ok( max_pos == 0, "got %d\n", max_pos ); - ok( pos == 0, "got %d\n", pos ); - ok( page == client.bottom, "got %d\n", page ); + ok( ret == S_OK, "ITextServices_TxGetHScroll failed: 0x%08lx.\n", ret ); + ok( min_pos == 0, "got %ld\n", min_pos ); + todo_wine + ok( max_pos == 0, "got %ld\n", max_pos ); + ok( pos == 0, "got %ld\n", pos ); + ok( page == client.bottom, "got %ld\n", page ); ok( !enabled, "got %d\n", enabled ); ret = ITextServices_TxSetText( txtserv, lorem ); - ok( ret == S_OK, "got 0x%08x.\n", ret ); + ok( ret == S_OK, "got 0x%08lx.\n", ret ); ret = ITextServices_TxGetVScroll( txtserv, &min_pos, &max_pos, &pos, &page, &enabled ); - ok( ret == S_OK, "ITextServices_TxGetHScroll failed: 0x%08x.\n", ret ); - ok( min_pos == 0, "got %d\n", min_pos ); - ok( max_pos > client.bottom, "got %d\n", max_pos ); - ok( pos == 0, "got %d\n", pos ); - ok( page == client.bottom, "got %d\n", page ); + ok( ret == S_OK, "ITextServices_TxGetHScroll failed: 0x%08lx.\n", ret ); + ok( min_pos == 0, "got %ld\n", min_pos ); + ok( max_pos > client.bottom, "got %ld\n", max_pos ); + ok( pos == 0, "got %ld\n", pos ); + ok( page == client.bottom, "got %ld\n", page ); ok( enabled, "got %d\n", enabled ); host_impl->scrollbars = WS_VSCROLL | ES_DISABLENOSCROLL; @@ -1148,12 +1210,12 @@ todo_wine ITextServices_TxSetText( txtserv, L"short" ); ret = ITextServices_TxGetVScroll( txtserv, &min_pos, &max_pos, &pos, &page, &enabled ); - ok( ret == S_OK, "ITextServices_TxGetHScroll failed: 0x%08x.\n", ret ); - ok( min_pos == 0, "got %d\n", min_pos ); -todo_wine - ok( max_pos == 0, "got %d\n", max_pos ); - ok( pos == 0, "got %d\n", pos ); - ok( page == client.bottom, "got %d\n", page ); + ok( ret == S_OK, "ITextServices_TxGetHScroll failed: 0x%08lx.\n", ret ); + ok( min_pos == 0, "got %ld\n", min_pos ); + todo_wine + ok( max_pos == 0, "got %ld\n", max_pos ); + ok( pos == 0, "got %ld\n", pos ); + ok( page == client.bottom, "got %ld\n", page ); ok( !enabled, "got %d\n", enabled ); DestroyWindow( host_impl->window ); @@ -1183,33 +1245,33 @@ static void test_notifications( void ) 0, 0, 400, 400, 0, 0, 0, NULL ); host_impl->client_rect = client; hr = ITextServices_OnTxInPlaceActivate( txtserv, &client ); - ok( hr == S_OK, "got 0x%08x.\n", hr ); + ok( hr == S_OK, "got 0x%08lx.\n", hr ); hr = ITextServices_TxSendMessage( txtserv, EM_SETEVENTMASK, 0, ENM_SCROLL, &res ); - ok( hr == S_OK, "got %08x\n", hr ); + ok( hr == S_OK, "got %08lx\n", hr ); /* check EN_VSCROLL notification is sent */ en_vscroll_sent = 0; hr = ITextServices_TxSendMessage( txtserv, WM_VSCROLL, SB_LINEDOWN, 0, &res ); - ok( hr == S_OK, "got %08x\n", hr ); + ok( hr == S_OK, "got %08lx\n", hr ); ok( en_vscroll_sent == 1, "got %d\n", en_vscroll_sent ); hr = ITextServices_TxSendMessage( txtserv, WM_VSCROLL, SB_BOTTOM, 0, &res ); - ok( hr == S_OK, "got %08x\n", hr ); + ok( hr == S_OK, "got %08lx\n", hr ); ok( en_vscroll_sent == 2, "got %d\n", en_vscroll_sent ); /* but not when the thumb is moved */ hr = ITextServices_TxSendMessage( txtserv, WM_VSCROLL, MAKEWPARAM( SB_THUMBTRACK, 0 ), 0, &res ); - ok( hr == S_OK, "got %08x\n", hr ); + ok( hr == S_OK, "got %08lx\n", hr ); hr = ITextServices_TxSendMessage( txtserv, WM_VSCROLL, MAKEWPARAM( SB_THUMBPOSITION, 0 ), 0, &res ); - ok( hr == S_OK, "got %08x\n", hr ); + ok( hr == S_OK, "got %08lx\n", hr ); ok( en_vscroll_sent == 2, "got %d\n", en_vscroll_sent ); /* EN_UPDATE is sent by TxDraw() */ en_update_sent = 0; hr = ITextServices_TxDraw( txtserv, DVASPECT_CONTENT, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, TXTVIEW_ACTIVE ); - ok( hr == S_OK, "got %08x\n", hr ); + ok( hr == S_OK, "got %08lx\n", hr ); ok( en_update_sent == 1, "got %d\n", en_update_sent ); DestroyWindow( host_impl->window ); @@ -1217,6 +1279,181 @@ static void test_notifications( void ) ITextHost_Release( host ); } +static void test_set_selection_message( void ) +{ + ITextServices *txtserv; + ITextHost *host; + CHARRANGE range; + LRESULT result; + HRESULT hr; + + if (!init_texthost(&txtserv, &host)) + return; + + ITextServices_TxSetText(txtserv, L""); + + if (winetest_debug > 1) trace("TxSendMessage EM_SETEVENTMASK"); + + hr = ITextServices_TxSendMessage( txtserv, EM_SETEVENTMASK, 0, ENM_CHANGE | ENM_SELCHANGE, &result ); + ok( hr == S_OK, "got %08lx\n", hr ); + + if (winetest_debug > 1) trace("TxSendMessage EM_SETSEL 0 20"); + + CLEAR_COUNTER(ITextHostImpl_TxViewChange); + en_change_sent = 0; + en_selchange_sent = 0; + + hr = ITextServices_TxSendMessage(txtserv, EM_SETSEL, 0, 20, &result); + ok( hr == S_OK, "got %08lx\n", hr ); + + CHECK_CALLED(ITextHostImpl_TxViewChange); + ok(en_change_sent == 0, "got %d\n", en_change_sent); + todo_wine + ok(en_selchange_sent == 0, "got %d\n", en_selchange_sent); + + hr = ITextServices_TxSendMessage(txtserv, EM_EXGETSEL, 0, (LPARAM)&range, &result); ok( hr == S_OK, "got %08lx\n", hr ); trace("getsel: %lu, %lu\n", range.cpMin, range.cpMax); + + if (winetest_debug > 1) trace("TxSendMessage EM_SETSELEX 0 20"); + + CLEAR_COUNTER(ITextHostImpl_TxViewChange); + en_change_sent = 0; + en_selchange_sent = 0; + + range.cpMin = 0; + range.cpMax = 20; + hr = ITextServices_TxSendMessage(txtserv, EM_EXSETSEL, 0, (LPARAM)&range, &result); + ok( hr == S_OK, "got %08lx\n", hr ); + + CHECK_CALLED(ITextHostImpl_TxViewChange); + ok(en_change_sent == 0, "got %d\n", en_change_sent); + ok(en_selchange_sent == 0, "got %d\n", en_selchange_sent); + + if (winetest_debug > 1) trace("TxSetText"); + + CLEAR_COUNTER(ITextHostImpl_TxViewChange); + en_change_sent = 0; + en_selchange_sent = 0; + + hr = ITextServices_TxSendMessage(txtserv, EM_EXGETSEL, 0, (LPARAM)&range, &result); ok( hr == S_OK, "got %08lx\n", hr ); trace("getsel: %lu, %lu\n", range.cpMin, range.cpMax); + + ITextServices_TxSetText(txtserv, lorem); + + hr = ITextServices_TxSendMessage(txtserv, EM_EXGETSEL, 0, (LPARAM)&range, &result); ok( hr == S_OK, "got %08lx\n", hr ); trace("getsel: %lu, %lu\n", range.cpMin, range.cpMax); + + CHECK_CALLED(ITextHostImpl_TxViewChange); + ok(en_change_sent == 1, "got %d\n", en_change_sent); + todo_wine + ok(en_selchange_sent == 0, "got %d\n", en_selchange_sent); + + if (winetest_debug > 1) trace("TxSendMessage EM_SETSEL 0 20"); + + CLEAR_COUNTER(ITextHostImpl_TxViewChange); + en_change_sent = 0; + en_selchange_sent = 0; + + hr = ITextServices_TxSendMessage(txtserv, EM_SETSEL, 0, 20, &result); + ok( hr == S_OK, "got %08lx\n", hr ); + + CHECK_CALLED(ITextHostImpl_TxViewChange); + ok(en_change_sent == 0, "got %d\n", en_change_sent); + ok(en_selchange_sent == 1, "got %d\n", en_selchange_sent); + + hr = ITextServices_TxSendMessage(txtserv, EM_EXGETSEL, 0, (LPARAM)&range, &result); ok( hr == S_OK, "got %08lx\n", hr ); trace("getsel: %lu, %lu\n", range.cpMin, range.cpMax); + + if (winetest_debug > 1) trace("TxSendMessage EM_SETSELEX 0 20"); + + CLEAR_COUNTER(ITextHostImpl_TxViewChange); + en_change_sent = 0; + en_selchange_sent = 0; + + range.cpMin = 0; + range.cpMax = 20; + hr = ITextServices_TxSendMessage(txtserv, EM_EXSETSEL, 0, (LPARAM)&range, &result); + ok( hr == S_OK, "got %08lx\n", hr ); + + CHECK_CALLED(ITextHostImpl_TxViewChange); + ok(en_change_sent == 0, "got %d\n", en_change_sent); + ok(en_selchange_sent == 0, "got %d\n", en_selchange_sent); + + hr = ITextServices_TxSendMessage(txtserv, EM_EXGETSEL, 0, (LPARAM)&range, &result); ok( hr == S_OK, "got %08lx\n", hr ); trace("getsel: %lu, %lu\n", range.cpMin, range.cpMax); + + if (winetest_debug > 1) trace("release interfaces"); + + ITextServices_Release( txtserv ); + ITextHost_Release( host ); +} + +static void test_scrollcaret( void ) +{ + ITextServices *txtserv; + ITextHost *host; + LRESULT result; + HRESULT hr; + + if (!init_texthost(&txtserv, &host)) + return; + + hr = ITextServices_TxSendMessage(txtserv, EM_SCROLLCARET, 0, 0, &result); + ok( hr == S_OK, "got %08lx\n", hr ); + + ITextServices_Release( txtserv ); + ITextHost_Release( host ); +} + +static void test_inplace_active( BOOL active ) +{ + ITextServices *txtserv; + ITextHost *host; + LRESULT result; + HRESULT hr; + + ITextHostTestImpl *host_impl; + if (!init_texthost(&txtserv, &host)) + return; + + host_impl = impl_from_ITextHost( host ); + host_impl->window = CreateWindowExA( 0, "static", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 100, 100, 0, 0, 0, NULL ); + host_impl->client_rect = (RECT) { 0, 0, 150, 150 }; + host_impl->scrollbars = WS_VSCROLL | ES_AUTOVSCROLL; + host_impl->props = TXTBIT_MULTILINE | TXTBIT_RICHTEXT | TXTBIT_WORDWRAP; + ITextServices_OnTxPropertyBitsChange( txtserv, TXTBIT_SCROLLBARCHANGE | TXTBIT_MULTILINE | TXTBIT_RICHTEXT | TXTBIT_WORDWRAP, host_impl->props ); + + CLEAR_COUNTER(ITextHostImpl_TxScrollWindowEx); + CLEAR_COUNTER(ITextHostImpl_TxGetClientRect); + + if (active) { + hr = ITextServices_OnTxInPlaceActivate( txtserv, &host_impl->client_rect ); + ok( hr == S_OK, "got %08lx\n", hr ); + } + + hr = ITextServices_TxSendMessage(txtserv, EM_SETEVENTMASK, 0, ENM_REQUESTRESIZE, &result); + ok( hr == S_OK, "got %08lx\n", hr ); + + hr = ITextServices_TxDraw( txtserv, DVASPECT_CONTENT, 0, NULL, NULL, GetDC(host_impl->window), NULL, (RECTL *)&host_impl->client_rect, NULL, NULL, NULL, 0, TXTVIEW_INACTIVE ); + ok( hr == S_OK, "got %08lx\n", hr ); + + hr = ITextServices_TxSendMessage(txtserv, EM_SETSEL, 0, -1, &result); + ok( hr == S_OK, "got %08lx\n", hr ); + + hr = ITextServices_TxSendMessage(txtserv, EM_REPLACESEL, TRUE, (LPARAM) lorem, &result); + ok( hr == S_OK, "got %08lx\n", hr ); + + hr = ITextServices_TxDraw( txtserv, DVASPECT_CONTENT, 0, NULL, NULL, GetDC(host_impl->window), NULL, (RECTL *)&host_impl->client_rect, NULL, NULL, NULL, 0, TXTVIEW_INACTIVE ); + ok( hr == S_OK, "got %08lx\n", hr ); + + if (active) { + CHECK_CALLED(ITextHostImpl_TxScrollWindowEx); + CHECK_CALLED(ITextHostImpl_TxGetClientRect); + } else { + CHECK_NOT_CALLED(ITextHostImpl_TxScrollWindowEx); + CHECK_NOT_CALLED(ITextHostImpl_TxGetClientRect); + } + + DestroyWindow( host_impl->window ); + ITextServices_Release( txtserv ); + ITextHost_Release( host ); +} + START_TEST( txtsrv ) { ITextServices *txtserv; @@ -1250,6 +1487,10 @@ START_TEST( txtsrv ) test_default_format(); test_TxGetScroll(); test_notifications(); + test_set_selection_message(); + test_scrollcaret(); + test_inplace_active(TRUE); + test_inplace_active(FALSE); } if (wrapperCodeMem) VirtualFree(wrapperCodeMem, 0, MEM_RELEASE); } diff --git a/sdk/include/reactos/wine/rbtree.h b/sdk/include/reactos/wine/rbtree.h index 8130deb5d34..6c42fa1003e 100644 --- a/sdk/include/reactos/wine/rbtree.h +++ b/sdk/include/reactos/wine/rbtree.h @@ -23,43 +23,37 @@ #ifndef __WINE_WINE_RBTREE_H #define __WINE_WINE_RBTREE_H -#ifdef __GNUC__ -# define WINE_RB_ENTRY_VALUE(element, type, field) ({ \ - const typeof(((type *)0)->field) *__ptr = (element); \ - (type *)((char *)__ptr - offsetof(type, field)); }) -#else -# define WINE_RB_ENTRY_VALUE(element, type, field) \ - ((type *)((char *)(element) - offsetof(type, field))) -#endif +#define RB_ENTRY_VALUE(element, type, field) \ + ((type *)((char *)(element) - offsetof(type, field))) -struct wine_rb_entry +struct rb_entry { - struct wine_rb_entry *parent; - struct wine_rb_entry *left; - struct wine_rb_entry *right; + struct rb_entry *parent; + struct rb_entry *left; + struct rb_entry *right; unsigned int flags; }; -typedef int (*wine_rb_compare_func_t)(const void *key, const struct wine_rb_entry *entry); +typedef int (*rb_compare_func_t)(const void *key, const struct rb_entry *entry); -struct wine_rb_tree +struct rb_tree { - wine_rb_compare_func_t compare; - struct wine_rb_entry *root; + rb_compare_func_t compare; + struct rb_entry *root; }; -typedef void (wine_rb_traverse_func_t)(struct wine_rb_entry *entry, void *context); +typedef void (rb_traverse_func_t)(struct rb_entry *entry, void *context); -#define WINE_RB_FLAG_RED 0x1 +#define RB_FLAG_RED 0x1 -static inline int wine_rb_is_red(struct wine_rb_entry *entry) +static inline int rb_is_red(struct rb_entry *entry) { - return entry && (entry->flags & WINE_RB_FLAG_RED); + return entry && (entry->flags & RB_FLAG_RED); } -static inline void wine_rb_rotate_left(struct wine_rb_tree *tree, struct wine_rb_entry *e) +static inline void rb_rotate_left(struct rb_tree *tree, struct rb_entry *e) { - struct wine_rb_entry *right = e->right; + struct rb_entry *right = e->right; if (!e->parent) tree->root = right; @@ -75,9 +69,9 @@ static inline void wine_rb_rotate_left(struct wine_rb_tree *tree, struct wine_rb e->parent = right; } -static inline void wine_rb_rotate_right(struct wine_rb_tree *tree, struct wine_rb_entry *e) +static inline void rb_rotate_right(struct rb_tree *tree, struct rb_entry *e) { - struct wine_rb_entry *left = e->left; + struct rb_entry *left = e->left; if (!e->parent) tree->root = left; @@ -93,42 +87,42 @@ static inline void wine_rb_rotate_right(struct wine_rb_tree *tree, struct wine_r e->parent = left; } -static inline void wine_rb_flip_color(struct wine_rb_entry *entry) +static inline void rb_flip_color(struct rb_entry *entry) { - entry->flags ^= WINE_RB_FLAG_RED; - entry->left->flags ^= WINE_RB_FLAG_RED; - entry->right->flags ^= WINE_RB_FLAG_RED; + entry->flags ^= RB_FLAG_RED; + entry->left->flags ^= RB_FLAG_RED; + entry->right->flags ^= RB_FLAG_RED; } -static inline struct wine_rb_entry *wine_rb_head(struct wine_rb_entry *iter) +static inline struct rb_entry *rb_head(struct rb_entry *iter) { if (!iter) return NULL; while (iter->left) iter = iter->left; return iter; } -static inline struct wine_rb_entry *wine_rb_tail(struct wine_rb_entry *iter) +static inline struct rb_entry *rb_tail(struct rb_entry *iter) { if (!iter) return NULL; while (iter->right) iter = iter->right; return iter; } -static inline struct wine_rb_entry *wine_rb_next(struct wine_rb_entry *iter) +static inline struct rb_entry *rb_next(struct rb_entry *iter) { - if (iter->right) return wine_rb_head(iter->right); + if (iter->right) return rb_head(iter->right); while (iter->parent && iter->parent->right == iter) iter = iter->parent; return iter->parent; } -static inline struct wine_rb_entry *wine_rb_prev(struct wine_rb_entry *iter) +static inline struct rb_entry *rb_prev(struct rb_entry *iter) { - if (iter->left) return wine_rb_tail(iter->left); + if (iter->left) return rb_tail(iter->left); while (iter->parent && iter->parent->left == iter) iter = iter->parent; return iter->parent; } -static inline struct wine_rb_entry *wine_rb_postorder_head(struct wine_rb_entry *iter) +static inline struct rb_entry *rb_postorder_head(struct rb_entry *iter) { if (!iter) return NULL; @@ -139,70 +133,65 @@ static inline struct wine_rb_entry *wine_rb_postorder_head(struct wine_rb_entry } } -static inline struct wine_rb_entry *wine_rb_postorder_next(struct wine_rb_entry *iter) +static inline struct rb_entry *rb_postorder_next(struct rb_entry *iter) { if (!iter->parent) return NULL; if (iter == iter->parent->right || !iter->parent->right) return iter->parent; - return wine_rb_postorder_head(iter->parent->right); + return rb_postorder_head(iter->parent->right); } /* iterate through the tree */ -#define WINE_RB_FOR_EACH(cursor, tree) \ - for ((cursor) = wine_rb_head((tree)->root); (cursor); (cursor) = wine_rb_next(cursor)) +#define RB_FOR_EACH(cursor, tree) \ + for ((cursor) = rb_head((tree)->root); (cursor); (cursor) = rb_next(cursor)) /* iterate through the tree using a tree entry */ -#define WINE_RB_FOR_EACH_ENTRY(elem, tree, type, field) \ - for ((elem) = WINE_RB_ENTRY_VALUE(wine_rb_head((tree)->root), type, field); \ - (elem) != WINE_RB_ENTRY_VALUE(0, type, field); \ - (elem) = WINE_RB_ENTRY_VALUE(wine_rb_next(&elem->field), type, field)) +#define RB_FOR_EACH_ENTRY(elem, tree, type, field) \ + for ((elem) = RB_ENTRY_VALUE(rb_head((tree)->root), type, field); \ + (elem) != RB_ENTRY_VALUE(0, type, field); \ + (elem) = RB_ENTRY_VALUE(rb_next(&elem->field), type, field)) /* iterate through the tree using using postorder, making it safe to free the entry */ -#define WINE_RB_FOR_EACH_DESTRUCTOR(cursor, cursor2, tree) \ - for ((cursor) = wine_rb_postorder_head((tree)->root); \ - (cursor) && (((cursor2) = wine_rb_postorder_next(cursor)) || 1); \ +#define RB_FOR_EACH_DESTRUCTOR(cursor, cursor2, tree) \ + for ((cursor) = rb_postorder_head((tree)->root); \ + (cursor) && (((cursor2) = rb_postorder_next(cursor)) || 1); \ (cursor) = (cursor2)) /* iterate through the tree using a tree entry and postorder, making it safe to free the entry */ -#define WINE_RB_FOR_EACH_ENTRY_DESTRUCTOR(elem, elem2, tree, type, field) \ - for ((elem) = WINE_RB_ENTRY_VALUE(wine_rb_postorder_head((tree)->root), type, field); \ - (elem) != WINE_RB_ENTRY_VALUE(0, type, field) \ - && (((elem2) = WINE_RB_ENTRY_VALUE(wine_rb_postorder_next(&(elem)->field), type, field)) || 1); \ +#define RB_FOR_EACH_ENTRY_DESTRUCTOR(elem, elem2, tree, type, field) \ + for ((elem) = RB_ENTRY_VALUE(rb_postorder_head((tree)->root), type, field); \ + (elem) != RB_ENTRY_VALUE(0, type, field) \ + && (((elem2) = RB_ENTRY_VALUE(rb_postorder_next(&(elem)->field), type, field)) || 1); \ (elem) = (elem2)) -static inline void wine_rb_postorder(struct wine_rb_tree *tree, wine_rb_traverse_func_t *callback, void *context) +static inline void rb_postorder(struct rb_tree *tree, rb_traverse_func_t *callback, void *context) { - struct wine_rb_entry *iter, *next; - WINE_RB_FOR_EACH_DESTRUCTOR(iter, next, tree) callback(iter, context); + struct rb_entry *iter, *next; + RB_FOR_EACH_DESTRUCTOR(iter, next, tree) callback(iter, context); } -static inline void wine_rb_init(struct wine_rb_tree *tree, wine_rb_compare_func_t compare) +static inline void rb_init(struct rb_tree *tree, rb_compare_func_t compare) { tree->compare = compare; tree->root = NULL; } -static inline void wine_rb_for_each_entry(struct wine_rb_tree *tree, wine_rb_traverse_func_t *callback, void *context) +static inline void rb_for_each_entry(struct rb_tree *tree, rb_traverse_func_t *callback, void *context) { - struct wine_rb_entry *iter; - WINE_RB_FOR_EACH(iter, tree) callback(iter, context); + struct rb_entry *iter; + RB_FOR_EACH(iter, tree) callback(iter, context); } -static inline void wine_rb_clear(struct wine_rb_tree *tree, wine_rb_traverse_func_t *callback, void *context) +static inline void rb_destroy(struct rb_tree *tree, rb_traverse_func_t *callback, void *context) { /* Note that we use postorder here because the callback will likely free the entry. */ - if (callback) wine_rb_postorder(tree, callback, context); + if (callback) rb_postorder(tree, callback, context); tree->root = NULL; } -static inline void wine_rb_destroy(struct wine_rb_tree *tree, wine_rb_traverse_func_t *callback, void *context) +static inline struct rb_entry *rb_get(const struct rb_tree *tree, const void *key) { - wine_rb_clear(tree, callback, context); -} - -static inline struct wine_rb_entry *wine_rb_get(const struct wine_rb_tree *tree, const void *key) -{ - struct wine_rb_entry *entry = tree->root; + struct rb_entry *entry = tree->root; while (entry) { int c = tree->compare(key, entry); @@ -212,9 +201,9 @@ static inline struct wine_rb_entry *wine_rb_get(const struct wine_rb_tree *tree, return NULL; } -static inline int wine_rb_put(struct wine_rb_tree *tree, const void *key, struct wine_rb_entry *entry) +static inline int rb_put(struct rb_tree *tree, const void *key, struct rb_entry *entry) { - struct wine_rb_entry **iter = &tree->root, *parent = tree->root; + struct rb_entry **iter = &tree->root, *parent = tree->root; while (*iter) { @@ -227,19 +216,19 @@ static inline int wine_rb_put(struct wine_rb_tree *tree, const void *key, struct else iter = &parent->right; } - entry->flags = WINE_RB_FLAG_RED; + entry->flags = RB_FLAG_RED; entry->parent = parent; entry->left = NULL; entry->right = NULL; *iter = entry; - while (wine_rb_is_red(entry->parent)) + while (rb_is_red(entry->parent)) { if (entry->parent == entry->parent->parent->left) { - if (wine_rb_is_red(entry->parent->parent->right)) + if (rb_is_red(entry->parent->parent->right)) { - wine_rb_flip_color(entry->parent->parent); + rb_flip_color(entry->parent->parent); entry = entry->parent->parent; } else @@ -247,18 +236,18 @@ static inline int wine_rb_put(struct wine_rb_tree *tree, const void *key, struct if (entry == entry->parent->right) { entry = entry->parent; - wine_rb_rotate_left(tree, entry); + rb_rotate_left(tree, entry); } - entry->parent->flags &= ~WINE_RB_FLAG_RED; - entry->parent->parent->flags |= WINE_RB_FLAG_RED; - wine_rb_rotate_right(tree, entry->parent->parent); + entry->parent->flags &= ~RB_FLAG_RED; + entry->parent->parent->flags |= RB_FLAG_RED; + rb_rotate_right(tree, entry->parent->parent); } } else { - if (wine_rb_is_red(entry->parent->parent->left)) + if (rb_is_red(entry->parent->parent->left)) { - wine_rb_flip_color(entry->parent->parent); + rb_flip_color(entry->parent->parent); entry = entry->parent->parent; } else @@ -266,23 +255,23 @@ static inline int wine_rb_put(struct wine_rb_tree *tree, const void *key, struct if (entry == entry->parent->left) { entry = entry->parent; - wine_rb_rotate_right(tree, entry); + rb_rotate_right(tree, entry); } - entry->parent->flags &= ~WINE_RB_FLAG_RED; - entry->parent->parent->flags |= WINE_RB_FLAG_RED; - wine_rb_rotate_left(tree, entry->parent->parent); + entry->parent->flags &= ~RB_FLAG_RED; + entry->parent->parent->flags |= RB_FLAG_RED; + rb_rotate_left(tree, entry->parent->parent); } } } - tree->root->flags &= ~WINE_RB_FLAG_RED; + tree->root->flags &= ~RB_FLAG_RED; return 0; } -static inline void wine_rb_remove(struct wine_rb_tree *tree, struct wine_rb_entry *entry) +static inline void rb_remove(struct rb_tree *tree, struct rb_entry *entry) { - struct wine_rb_entry *iter, *child, *parent, *w; + struct rb_entry *iter, *child, *parent, *w; int need_fixup; if (entry->right && entry->left) @@ -302,7 +291,7 @@ static inline void wine_rb_remove(struct wine_rb_tree *tree, struct wine_rb_entr if (child) child->parent = iter->parent; parent = iter->parent; - need_fixup = !wine_rb_is_red(iter); + need_fixup = !rb_is_red(iter); if (entry != iter) { @@ -321,32 +310,32 @@ static inline void wine_rb_remove(struct wine_rb_tree *tree, struct wine_rb_entr if (need_fixup) { - while (parent && !wine_rb_is_red(child)) + while (parent && !rb_is_red(child)) { if (child == parent->left) { w = parent->right; - if (wine_rb_is_red(w)) + if (rb_is_red(w)) { - w->flags &= ~WINE_RB_FLAG_RED; - parent->flags |= WINE_RB_FLAG_RED; - wine_rb_rotate_left(tree, parent); + w->flags &= ~RB_FLAG_RED; + parent->flags |= RB_FLAG_RED; + rb_rotate_left(tree, parent); w = parent->right; } - if (wine_rb_is_red(w->left) || wine_rb_is_red(w->right)) + if (rb_is_red(w->left) || rb_is_red(w->right)) { - if (!wine_rb_is_red(w->right)) + if (!rb_is_red(w->right)) { - w->left->flags &= ~WINE_RB_FLAG_RED; - w->flags |= WINE_RB_FLAG_RED; - wine_rb_rotate_right(tree, w); + w->left->flags &= ~RB_FLAG_RED; + w->flags |= RB_FLAG_RED; + rb_rotate_right(tree, w); w = parent->right; } - w->flags = (w->flags & ~WINE_RB_FLAG_RED) | (parent->flags & WINE_RB_FLAG_RED); - parent->flags &= ~WINE_RB_FLAG_RED; + w->flags = (w->flags & ~RB_FLAG_RED) | (parent->flags & RB_FLAG_RED); + parent->flags &= ~RB_FLAG_RED; if (w->right) - w->right->flags &= ~WINE_RB_FLAG_RED; - wine_rb_rotate_left(tree, parent); + w->right->flags &= ~RB_FLAG_RED; + rb_rotate_left(tree, parent); child = NULL; break; } @@ -354,45 +343,79 @@ static inline void wine_rb_remove(struct wine_rb_tree *tree, struct wine_rb_entr else { w = parent->left; - if (wine_rb_is_red(w)) + if (rb_is_red(w)) { - w->flags &= ~WINE_RB_FLAG_RED; - parent->flags |= WINE_RB_FLAG_RED; - wine_rb_rotate_right(tree, parent); + w->flags &= ~RB_FLAG_RED; + parent->flags |= RB_FLAG_RED; + rb_rotate_right(tree, parent); w = parent->left; } - if (wine_rb_is_red(w->left) || wine_rb_is_red(w->right)) + if (rb_is_red(w->left) || rb_is_red(w->right)) { - if (!wine_rb_is_red(w->left)) + if (!rb_is_red(w->left)) { - w->right->flags &= ~WINE_RB_FLAG_RED; - w->flags |= WINE_RB_FLAG_RED; - wine_rb_rotate_left(tree, w); + w->right->flags &= ~RB_FLAG_RED; + w->flags |= RB_FLAG_RED; + rb_rotate_left(tree, w); w = parent->left; } - w->flags = (w->flags & ~WINE_RB_FLAG_RED) | (parent->flags & WINE_RB_FLAG_RED); - parent->flags &= ~WINE_RB_FLAG_RED; + w->flags = (w->flags & ~RB_FLAG_RED) | (parent->flags & RB_FLAG_RED); + parent->flags &= ~RB_FLAG_RED; if (w->left) - w->left->flags &= ~WINE_RB_FLAG_RED; - wine_rb_rotate_right(tree, parent); + w->left->flags &= ~RB_FLAG_RED; + rb_rotate_right(tree, parent); child = NULL; break; } } - w->flags |= WINE_RB_FLAG_RED; + w->flags |= RB_FLAG_RED; child = parent; parent = child->parent; } - if (child) child->flags &= ~WINE_RB_FLAG_RED; + if (child) child->flags &= ~RB_FLAG_RED; } - if (tree->root) tree->root->flags &= ~WINE_RB_FLAG_RED; + if (tree->root) tree->root->flags &= ~RB_FLAG_RED; } -static inline void wine_rb_remove_key(struct wine_rb_tree *tree, const void *key) +static inline void rb_remove_key(struct rb_tree *tree, const void *key) { - struct wine_rb_entry *entry = wine_rb_get(tree, key); - if (entry) wine_rb_remove(tree, entry); + struct rb_entry *entry = rb_get(tree, key); + if (entry) rb_remove(tree, entry); } +static inline void rb_replace(struct rb_tree *tree, struct rb_entry *dst, struct rb_entry *src) +{ + if (!(src->parent = dst->parent)) + tree->root = src; + else if (dst->parent->left == dst) + dst->parent->left = src; + else + dst->parent->right = src; + + if ((src->left = dst->left)) + src->left->parent = src; + if ((src->right = dst->right)) + src->right->parent = src; + src->flags = dst->flags; +} + +/* old names for backwards compatibility */ +#define wine_rb_entry rb_entry +#define wine_rb_tree rb_tree +#define wine_rb_init rb_init +#define wine_rb_for_each_entry rb_for_each_entry +#define wine_rb_destroy rb_destroy +#define wine_rb_get rb_get +#define wine_rb_put rb_put +#define wine_rb_remove rb_remove +#define wine_rb_remove_key rb_remove_key +#define wine_rb_replace rb_replace +#define WINE_RB_ENTRY_VALUE RB_ENTRY_VALUE +#define WINE_RB_FOR_EACH_ENTRY RB_FOR_EACH_ENTRY +#define WINE_RB_FOR_EACH_ENTRY_DESTRUCTOR RB_FOR_EACH_ENTRY_DESTRUCTOR +#ifdef __REACTOS__ +#define wine_rb_clear rb_destroy +#endif + #endif /* __WINE_WINE_RBTREE_H */ diff --git a/sdk/tools/winesync/riched20.cfg b/sdk/tools/winesync/riched20.cfg new file mode 100644 index 00000000000..719f26bad5e --- /dev/null +++ b/sdk/tools/winesync/riched20.cfg @@ -0,0 +1,6 @@ +directories: + dlls/riched20: dll/win32/riched20 + dlls/riched20/tests: modules/rostests/winetests/riched20 +files: null +tags: + wine: wine-10.0