Commit Graph

739 Commits

Author SHA1 Message Date
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
Dylan Smith f28988684e richedit: Return FALSE for EM_LINESCROLL with single line control. 2009-02-24 16:57:28 +01:00
Dylan Smith 5f51221d9c richedit: Fixed scrollbar visiblility calculation after SetScrollInfo.
The scrollbar visibility can be changed from SetScrollRange or
SetScrollInfo, but the visiblity that is a result of these calls are
not consistent with the calculation made by richedit controls to
decide whether to show or hide the scrollbars.
2009-02-24 16:57:28 +01:00
Dylan Smith a0466e2c0e richedit: Don't show vertical scrollbar for single line controls.
The vertical scrollbar is not shown when the ES_MULTILINE style isn't
used, unless ES_DISBALENOSCROLL is also used.
2009-02-24 16:57:28 +01:00
Dylan Smith b9b9835f93 richedit: Added missing initialization of nAvailWidth for ME_TextEditor. 2009-02-24 16:57:27 +01:00
Dylan Smith 3903a110fb richedit: Removed unused ME_Document structure.
The ME_TextBuffer structure is what is used to store the document (as
a linked list), so the ME_Document structure isn't being used.  There
was also a document pointer in the ME_Paragraph structure that was
also unused, so I removed it because it is probably related to this
used structure.
2009-02-17 12:46:56 +01:00
Francois Gouget f250f4fa04 Assorted spelling fixes. 2009-02-11 15:56:02 +01:00
Dylan Smith ecb6c2169c richedit: Store paragraph in cursors.
This prevents some needless searching for the start of the paragraph
from a run stored in a cursor.  Usually a pointer to the paragraph is
already available when the cursor is set anyway.
2009-02-10 12:59:09 +01:00
Andrew Talbot edca49f6aa riched20: Remove unused functions. 2009-02-09 13:21:21 +01:00
Dylan Smith c8b4455565 richedit: Removed ME_StrRelPos, ME_StrRelPos2, & ME_PosToVPos functions.
These functions were just being used for addition, so it was simpler to
remove the functions and modify the places it was used.

The ME_StrRelPos2 and ME_PosToVPos were just simple wrappers around
ME_StrRelPos, and ME_PosToVPos wasn't being used.
2009-02-09 13:05:13 +01:00
Dylan Smith 1eb0f73ab0 richedit: Got rid of ME_GetCharFwd and ME_GetCharBack.
These two functions were being used for simple operations, to get the
first or last character when pre-computing flags for splitting runs.

The call to ME_GetCharBack wasn't even giving the correct result, it
would always return -1 since it is being called with nPos of 0.

This patch simplifies the code by removing the functions and getting the
characters directly from the string.
2009-02-09 13:05:13 +01:00
Dylan Smith 5f15de0690 richedit: Removed ME_StrLen and ME_StrVLen field access functions.
These functions were probably previously needed because of some wierd
special handling of backspace characters, but currently there is no
reason why the nLen field can't be accessed directly.

Having to functions that just access the string length field just causes
slightly more effort for someone to look at the code, because they need
to enter the function to find out what it actually is doing.
2009-02-09 13:05:13 +01:00
Dylan Smith f148d82093 richedit: Got rid of useless function ME_VPosToPos.
The function was just returning the second parameter.  It had some
commented out code that indicated that previously backslashes weren't
included in the length.  Native wordpad doesn't handle backspaces in a
special way, so this must have been an internal representation that
complicated finding the position of characters.
2009-02-09 13:05:12 +01:00
Dylan Smith d306b6b5e9 richedit: Removed some conditions that are always taken.
ME_GetCursorCoordinates had two conditions that were always taken.  The
first condition was if(pCursor->pRun->type == diRun) was following an
assertion making the exact same check.  The next one, if(row), should
always be taken, otherwise the richedit controls are in a corrupt state,
therefore an assertion is more appropriate.
2009-02-09 13:05:12 +01:00
Dylan Smith 4b7e8f185b richedit: Avoid duplication in make string functions using ME_MakeStringB.
I found that ME_MakeStringB was previously unused, and that the other
ME_MakeString functions repeated code that was already in ME_MakeStringB.
Making ME_MakeStringB static and using it to avoid duplicate code seemed
like a better idea than removing the function.
2009-02-09 13:05:12 +01:00
Dylan Smith f53f40bcb3 richedit: Prevent string trunction due to NULL characters. 2009-02-09 13:05:12 +01:00
Dylan Smith 1ceb903f9d richedit: Simplified ME_UpdateSelectionLinkAttribute. 2009-02-09 13:05:12 +01:00
Dylan Smith 71d797c55c richedit: Directly get start and end of text on Ctrl-Home or Ctrl-End.
Previously it found the start or end by traversing the linked lists of
run, rows, paragraphs, and cells from the current position of the
cursors.  Clearly it is better to get the start or end directly to make
it a constant time operation.
2009-02-09 13:05:12 +01:00
Dylan Smith c2c2c1117e richedit: Wrap even when message says not to repaint.
Wrapping is needed to be done even when repainting isn't done since
later messages expect line breaks to reflect the current text.  Some
message can specify not to paint the sceen, but this should prevent
wrapping from being done.
2009-02-09 13:05:12 +01:00
Michael Stefaniuc fb9b95b7a9 riched20: Fix some Win64 compiler warnings.
- A HWND can be safely marshaled over a LONG as its payload is not
  a pointer but a user handle.
- Use GetWindowLongPtr instead of GetWindowLong to retrieve a pointer.
2009-02-09 12:06:20 +01:00
Dylan Smith 5c91d5356e richedit: Avoided searching for adjacent paragraphs through runs.
When finding an adjacent paragraph, the next_para and prev_para pointers
should be used because they are direct pointers, a constant time
operation.  Instead I found some places in the code that searched through
the general linked list to get to an adjacent paragraph, which is a linear
time operation, depending on the number of rows and runs in between
paragraphs.
2009-02-06 14:54:01 +01:00
Dylan Smith 5a84e193c2 richedit: Removed incorrect FIXME comment.
The fixme comment is suggesting wrapping a paragraph within a function
that is for moving the selection cursor up or down a line when the up
or down keys are pressed.  The contents fo paragraph aren't being
changed, so there is no need to wrap the paragraph.
2009-02-06 14:50:27 +01:00
Dylan Smith e082dd3042 richedit: Add paragraph field to wrap context to avoid searching for it.
More case of searching for the paragraph through the linked list when
is was already previously available.  Since each wrap context is used
for wrapping each paragraph, I decided to add the reference to the
paragarph in the structure.
2009-02-06 14:50:27 +01:00
Dylan Smith d20e057d8e richedit: Accept paragraph as parameter for ME_CharOfsFromRunOfs.
Rather than get the paragraph from the run, the function allows the
caller to provide the paragraph, since it is already available.  This
reduces unnecessary traversals of lists that take longer as more runs
and rows are in the paragraph.
2009-02-06 14:50:27 +01:00
Dylan Smith 12ca50db7a richedit: Get the paragraph with ME_RunOfsFromCharOfs.
The ME_RunOfsFromCharOfs function finds the paragraph before finding the
run and offset within the run, so the function may as well be able to
return this paragraph to the caller.  Many callers to the function
instead find the paragraph from the run, which ends up unnecessarily
traversing a linked list of runs within the paragraph.
2009-02-06 14:50:27 +01:00
Dylan Smith a5bfa1a2ab richedit: Properly destroy context in two places.
Whenever ME_InitContext is called, ME_DestroyContext should be used to
clean it up.  This way the context can be extended easily by modifying
those two functions.  Instead, these two places of code just released
the DC, without using ME_DestroyContext, so the created brush for the
margin was not deleted.
2009-02-06 14:50:27 +01:00
Dylan Smith ea9e062b6c richedit: Removed unnecessary calls to ME_WrapMarkedParagraphs.
These calls to ME_WrapMarkedParagraphs never do anything, and don't make
sense to be called in these places. These places are for ME_MoveCaret,
and ME_ArrowHome, which both don't involve any text being modified, and
all (direct and indirect) calls to these functions are done after the
text has already been wrapped.
2009-02-06 14:50:27 +01:00
Dylan Smith a490e155dc richedit: Simplified the character length delete protection.
The value for nMaxChars can be found easier by using ME_GetTextLength.
2009-02-06 14:50:27 +01:00
Dylan Smith 95d82484e1 richedit: Fixed EM_FINDTEXT to pass todo tests.
There was a bug in ME_FindText which would cause the final caracter
offset to be incorrect when a paragraph was crossed while matching
characters.  The problem was the character offset of the wrong
paragraph was used in the calculation of the start offset of the
match.
2009-02-02 15:21:45 +01:00
Dylan Smith 8662c6fe7b richedit: Implement EM_GETTEXTMODE.
The text mode is already stored, and EM_SETTEXTMODE already exists.

There was however a bug in EM_MakeEditor that could cause TM_PLAINTEXT
and TM_RICHEDIT to be set at the same time.  This was corrected to ensure
EM_GETTEXTMODE returned the proper mode being used.
2009-02-02 15:21:44 +01:00
Dylan Smith 1a3551b630 richedit: Use width from EM_SETTARGETDEVICE for wrapping.
The width for EM_SETTARGETDEVICE is used by some applications to set the
wrapping width to a certain distance in twips.  This can be used even
though the target device is ignored.
2009-02-02 15:21:44 +01:00
Michael Stefaniuc d1a7e41b71 riched20: Remove superfluous pointer casts. 2009-01-30 11:45:23 +01:00
Alasdair Sinclair 0e543a715c riched20/tests: Fix missing void in empty parameter list. 2009-01-30 11:43:31 +01:00
Marcus Meissner a09621b00f riched20: Handle more missing allocs gracefully (Coverity). 2009-01-29 12:45:23 +01:00
Marcus Meissner 605a40e477 riched20: Handle NULL fp more gracefully (Coverity). 2009-01-29 12:45:15 +01:00
Marcus Meissner 9eb4c73ae3 riched20: Handle cp NULL more gracefully (Coverity). 2009-01-29 12:45:07 +01:00
Marcus Meissner 3d8fd826e1 riched20: Exit the loop instead of crashing (Coverity). 2009-01-29 12:45:00 +01:00