Commit Graph

775 Commits

Author SHA1 Message Date
Dylan Smith 0362b1b087 richedit: Improve efficiency of ME_IsCandidateAnURL.
The code was previously getting the same text in the loop from the
editor, and it was converting each of the prefixes to compare against
for each URL candidate.
2009-08-12 17:34:44 +02:00
Dylan Smith 82e102107c richedit: ME_GetTextW must use source and destination lengths.
Before a single length was used for the number of characters to retrieve
from the text, and to keep track of the size of the buffer.  These are
not equivalent, since there is a possible end of line conversion.
2009-08-12 17:32:16 +02:00
Dylan Smith 46b84aed4a richedit: Added function to get selection cursors in order.
Previously the only convenient way to get the start and end of the
selection was through offsets, which eventually need to get converted
back into items in the linked list storing the text.  The new function
will help with eliminating these inefficiencies.
2009-08-12 17:29:30 +02:00
Dylan Smith be0fb1ef5d richedit: Make the ME_GetCursorOfs function more flexible.
This function will make it easier to work with ME_Cursor objects, which
should be used in a lot of places instead of character offsets (which
often require seeking through the linked lists to perform operations
with).
2009-08-12 17:29:20 +02:00
Dylan Smith 314bd5ca85 richedit: Update paragraph on saved cursor when inserting table start.
Since the table row start is inserted after the rest of the table is
inserted, the cursor is saved, and temporarily moved to the start of the
row to insert the table row start paragraph.  Unfortunately the
paragraph in saved cursor becomes invalid during this insertion and
needs to be updated, so this code introduced a regression once
paragraphs started to be stored in cursors.
2009-08-11 12:31:18 +02:00
Dylan Smith 114a64ce5d richedit: Added missing style releases.
Style objects are referenced counted in richedit controls, so I tried to
make sure styles were released properly.  This can be checked using with
the all_refs global reference count to see if everything is cleaned up.
2009-08-10 17:10:34 +02:00
Dylan Smith fc618ab041 richedit: Add closing actions for IRichEditOle_fnInsertObject.
Previously inserting the object didn't result in the text being wrapped,
which would cause an assertion error when this is checked for during
repainting the text.  It is also important to invalidate the affected
areas of text, update the scrollbar, and end the creation of undo
transactions for this insertion.
2009-08-10 17:10:24 +02:00
Dylan Smith 71cb069246 richedit: Use richedit class string macros from public headers. 2009-08-10 17:10:14 +02:00
Dylan Smith 832ffe108c richedit: Remove header function declarations with no definition. 2009-08-10 17:09:53 +02:00
Dylan Smith 6782627624 richedit: Implement ME_DITypesEqual using a switch statment. 2009-08-10 17:09:46 +02:00
Dylan Smith e306b91392 richedit: Avoid comparing padding in cursor structures on memcmp. 2009-08-07 14:57:24 +02:00
Dylan Smith 05c730fd4c richedit: Prevent using uninitialized nAvailWidth in initialization. 2009-08-03 16:00:34 +02:00
Dylan Smith c4b023b1b6 richedit: Prevent buffer overflows in WM_GETTEXT.
The application AutoGK was getting the length of the text with
WM_GETTEXTLENGTH to allocate an appropriate buffer size, but then
claimed the buffer was twice the size when sending WM_GETTEXTEX.  This
caused the memcpy call to overflow the actual buffer since the count
is based on the size of the buffer alone, regardless of the amount of
text retrieved.
2009-08-03 16:00:16 +02:00
Dylan Smith 3d89e29155 richedit: Handle NULL buffer or 0 buffer length in ME_GetTextEx.
ME_GetTextEx directly handles EM_GETTEXTEX, and previously a NULL buffer
would be dereferenced, and a 0 buffer length would cause nCount an
underflow in the nCount value which would allow a buffer overflow to
occur.
2009-08-03 15:59:57 +02:00
Dylan Smith 0deb3d04ed richedit: Scrollinfo stored as 16-bit values externally.
The application Blitzin2 was sending WM_VSCROLL messages to the
richedit control directly, when normally this message is supposed to
be a notification sent after the scrollinfo is set.  Native richedit
controls always use the 16-bit value passed to this message to set the
scroll position for SB_THUMBPOSITION, rather than trying to find a
32-bit value through GetScrollInfo like I had previously done.
2009-07-22 11:08:33 +02:00
Dylan Smith e364a4406a richedit: Added missing return to ME_EnsureVisible.
The missing return was to prevent automatic vertically scrolling when
style for it is not set, but is set for the horizontal scrollbar. I
initially missed this by testing with no autoscrolling on either
scrollbar.
2009-07-21 10:47:13 +02:00
Dylan Smith c6cf567706 richedit: Properly restore style after end of rtf group.
Rich text files have groupings of text, where styles are pushed onto
the stack when encountering a start of the group, then popped at the
end of the group.  This was being handled improperly before, because a
single styleChanged flag was being stored to keep track of whether the
style needed to be restored at the end of a group. This fails to work
properly since the single flag isn't keeping track of all the levels
of the stack, so some styles are not restored properly.
2009-07-20 12:18:43 +02:00
Dylan Smith dde41d5c13 richedit: Handle missing colours in rtf colour table.
When a colour table entry is empty, then the default colour is used.
For an incomplete colour table entry 0 is used for the missing colours.

Previously the -1 value used internally for missing colours was being
converted into white, where it should be using the default colour that
is normally black.

This bug could be seen by loading the following rich text into wordpad:
{\rtf{\colortbl;;}\cf1 text}
2009-07-17 15:40:35 +02:00
Dylan Smith f59e41e8d5 richedit: Keep scrollbars hidden without WS_HSCROLL & WS_VSCROLL. 2009-07-17 12:37:17 +02:00
Dylan Smith eddccdd1f2 richedit: Initially disable scrollbars for ES_DISABLENOSCROLL.
Previously after initial window creation of a richedit control with the
ES_DISABLENOSCROLL window style flag the scrollbar would be shown but
not disabled.  This patch fixes this issue by explicitly disabling and
showing the scrollbar.
2009-07-17 12:37:03 +02:00
Dylan Smith 140fee1790 richedit: Prevent autoscrolling without ES_AUTO[VH]SCROLL style.
When the richedit control is created without the ES_AUTOHSCROLL or the
ES_AUTOVSCROLL, then scrolling isn't done automatically when moving the
cursor with the arrow keys, drag selecting with the mouse, or even from
using the EM_SCROLLCARET (based on testing using a modified version of
wordpad).
2009-07-17 11:22:07 +02:00
Dylan Smith e7fd0b46b0 richedit: Add more tests for WM_SETTEXT RTF support. 2009-07-13 10:48:05 +02:00
Dylan Smith 88c2b90aa6 richedit: Support ascii RTF in WM_SETTEXT even for unicode messages.
WM_SETTEXT seems to check for {\rtf or {\urtf to determine if it is an
ascii RTF string, even if it is a unicode message.  So I removed the
check to see if it is a unicode message, and added a check for {\urtf.
2009-07-13 10:48:01 +02:00
Alexandre Julliard eb08df3a90 riched20: Add appropriate stdcall decorations to assembly functions. 2009-06-15 13:42:26 +02:00
Alexandre Julliard 3fe51326cd riched20: Move the textHostVtbl definition to work around Mac OS X breakage with __ASM_GLOBAL_FUNC. 2009-06-13 12:20:10 +02:00
Austin Lund 1643679476 riched20/test: Added a test for TxDraw. 2009-06-03 16:04:49 +02:00
Austin Lund 33534916a3 riched20: If DataObjectImpl_EnumFormatEtc returns E_NOTIMPL then ensure that returned pointers are nulled. 2009-06-02 12:09:12 +02:00
Francois Gouget 19020b9ef5 riched20: Make some functions static. 2009-05-26 14:25:12 +02:00
Francois Gouget e5f5bd1153 riched20: RTFPeekToken(), RTFExpandStyle() and RTFHexToChar() are unused so remove them. 2009-05-26 14:25:06 +02:00
Francois Gouget 1914d256a6 riched20: RTF{G,S}et{In,Out}putName() are unused so remove them as well as the corresponding _RTF_Info fields. 2009-05-26 14:10:46 +02:00
Francois Gouget 3d6c53b972 riched20: Make ME_GetCursorCoordinates() static and remove ME_MustBeWrapped() as it is unused. 2009-05-26 14:10:32 +02:00
Francois Gouget 61a8b94634 riched20: ME_MakeString() is unused so remove it. 2009-05-15 10:28:20 +02:00
Francois Gouget 8a46d0eaf5 Assorted spelling fixes. 2009-05-04 12:53:29 +02:00
Massimo Del Fedele 078989d463 richedit20: Test for fonttbl streamout. 2009-04-27 13:24:27 +02:00
Massimo Del Fedele 6f17327728 riched20: Fix placement of crlf on font table streamout. 2009-04-27 13:24:09 +02:00
Dylan Smith 234f167d9d richedit: Null terminate streamed out rich text. 2009-04-24 11:52:15 +02:00
Michael Stefaniuc b747284797 riched20/tests: Use better types than long. 2009-04-20 14:12:29 +02:00
Paul Vriens 30041c283a riched20/tests: Remove the todo_wine logic where appropriate. 2009-04-03 17:06:41 +02:00
Paul Vriens e96fb0fa50 riched20/tests: Fix and extend EM_FORMATRANGE tests. 2009-03-24 12:58:26 +01:00
Dylan Smith 78a7ea5a39 richedit: Properly handle lack of semicolon after font name in rtf.
This was partially handled by ungetting the end group token (i.e. '}')
so that it was read again at the proper place.  Unfortunately there is a
read hook that maintains a stackTop variable, which is decremented when
receiving this end group token.  Therefore stackTop would get
decremented twice, and the rich text file would end prematurely.

This is fixed by incrementing the stackTop variable to compensate for it
being decremented twice.
2009-03-24 10:27:34 +01:00
Dylan Smith caca486029 richedit: Add bounds checks for EM_GETTEXTRANGE with tests.
Wine was not doing bounds checks for EM_GETTEXTRANGE, which was causing
a crash in Bug 17822.  The added tests would cause a crash without the
added bounds checks in the richedit code.

The bounds checks I put in HandleMessage, since ME_GetTextRange is also
called for ME_GETSELTEXT which should not have bounds checks, since it
uses the selection range.

When the ME_GETTEXTRANGE message returns 0, no text is copied, not even
the NULL terminating charter.  This differs from EM_GETSELTEXT which
will copy the NULL terminating character when no text is selected.  This
behaviour is consistent with native richedit controls.
2009-03-23 13:26:28 +01:00
Dylan Smith 1a2ccfe9c7 richedit: Count graphics towards line width.
Images that are inserted into richedit controls store a space for the
text, since that is the character returned when getting the plain text
from the control.

When calculating the width of a line, the space character is skipped,
but images should not be skipped.  This can be seen by inserting an
image into wordpad on a line by it's own, then centering the line.  The
image will start from the center rather than being centered in the
control.
2009-03-11 13:03:30 +01:00
Michael Stefaniuc 43046481f7 include: Change long to LONG in tom.idl. 2009-03-10 12:06:10 +01:00
Dylan Smith fdb3749138 richedit: Respect manually added links when autourldetect is disabled.
EM_SETCHARFORMAT can be used to make text links.  Automatic URL
detection being enable would cause these links to be removed if the text
is not a URL, so this must be prevented.

Previously checks were made for AutoURLDetect_bEnable before calling
ME_UpdateSelectionLinkAttribute, or ME_UpdateLinkAttribute.  This is
more error prone than checking for this within the function, so one call
was missing this check.

ME_SetCursor also didn't respect this behaviour, since it wouldn't set
the cursor to the hand when hovering over a link without automatic URL
detection disabled.
2009-03-09 12:28:33 +01:00
Francois Gouget 96848a0605 Remove spaces before '\n's. 2009-03-09 12:05:58 +01:00
Dylan Smith bcd8dc93a2 richedit: Avoid calling ITextHost_TxNotify with EN_MSGFILTER.
The documentation for TxNotify says that it is not called with the
EN_MSGFILTER notification, so I made sure ME_FilterEvent didn't call
this method.
2009-03-06 12:49:04 +01:00
Dylan Smith b441bb2e4c richedit: Avoid crashing if TxSendMessage is called with NULL plresult. 2009-02-26 15:13:25 +01:00
Dylan Smith 88eb1b5b6c richedit: EM_SETOPTIONS modify format rect when selbar setting change.
Before the code was modifying the format rect to compensate for space
being added or removed for the selection bar, but this should only
happen when the ECO_SELECTIONBAR setting bit changes.
2009-02-26 12:11:18 +01:00
Dylan Smith 73e0c5ea8b richedit: Never wrap for single line controls.
I tested without the ES_MULTILINE style, and found that wrapping
doesn't occur where it normally would.
2009-02-24 16:57:28 +01:00
Dylan Smith 963407a9ef richedit: EM_SHOWSCROLLBAR hides scrollbars for less than page of text.
When all the text fits on the screen, the scrollbars are not shown from
EM_SHOWSCROLLBAR.  The message instead adds support for the specified
scrollbar when lParam is TRUE, so that the scrollbar will be shown when
sufficient text is in the document.
2009-02-24 16:57:28 +01:00