Hi, Sergey.
I want to change a text fragment from an text item.
For example in an item I have text: "It's a wonderles world" with charset, let's say, 200. I want to change the word "wonderles" with "wonderful" (same length) but with charset, let's say, 250. So I will obtain 3 items: "It's a " and " world" with charset 200 and "wonderful" with charset 250.
Question is: how can I do this so it executes as fast as possible (I make a lot of changes to large texts)? And in both situations: with or without Undo.
I was thinking of using the text fragment ("wonderful") to make a rtf as string, convert it to a stream and then insert it over the old selected text ("wonderles") with InsertRTFFromStreamEd; but it's too slow (especially in table cells where I have to enter in edit mode even if I don't need Undo).
Thank you in advance for any idea.
Best regards.
change text in an item
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
With undo: select the word to change (SetSelectionBounds) and apply a new style (ApplyTextStyle, or ApplyStyleConversion).
If the text is inside table cell, initialize cell editing before calling SetSelectionBounds:
If the text is inside table cell, initialize cell editing before calling SetSelectionBounds:
Code: Select all
var RVData: TCustomRVFormattedData;
RVData := TCustomRVData(Cell.Edit);
RVData.SetSelectionBounds(...);
RichViewEdit1.ApplyTextStyle(...);
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
With undo: I have to create a new style (for ApplyTextStyle), copy the style of the current text item with Assign, change the charset and then check if it's not a duplicate. If I don't check, on some texts it will have a lot of duplicates. And, if I check, on other texts it will take a lot of time: tenth of thousand of words changed x hundreds (maybe thousands) of styles checked. I entend to make the program work even on slower computers. You know better than me how fast is IsEqual function so please tell me if it's worth implementing...
Without undo: It's a good idea but I didn't make anything like this until now. In RootEditor is simple to copy items but I didn't know how to "rebuild" a table (maybe with another tables in it). If you're sure that this method is faster than the one with undo maybe you can show me how...
Thank you.
Without undo: It's a good idea but I didn't make anything like this until now. In RootEditor is simple to copy items but I didn't know how to "rebuild" a table (maybe with another tables in it). If you're sure that this method is faster than the one with undo maybe you can show me how...
Thank you.
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact: