Inserting paragraphs on the fly
Inserting paragraphs on the fly
I wish to process the contents of a DBRichView component and, depending on a flag, substitute certain text markers for new paragraphs while the document is being loaded.
I am trying to do this in the OnItemAction event handler. I´m not sure if this is the best place to do so, and to be honest, results are not what I want. The only way I can get a new paragraph to start is to do a PageBreakBefore on the current item. Could somebody give me an example or point me in the right direction?
Thanks
I am trying to do this in the OnItemAction event handler. I´m not sure if this is the best place to do so, and to be honest, results are not what I want. The only way I can get a new paragraph to start is to do a PageBreakBefore on the current item. Could somebody give me an example or point me in the right direction?
Thanks
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Note: when you modify document in TDBRichView, the changed document will not be saved back to the field, because TDBRichView cannot do it.
If you need to save changes, use TDBRichViewEdit.
The best place to modify document in DBRichView before displaying is OnLoadDocument event. The document is loaded, but not displayed yet.
Before modifying document, please read "Valid Documents" topic in the help file, because it's very easy to create incorrect document using methods described below.
To make item i to start a new paragraph:
rv.GetItem(i).SameAsPrev := False;
To change paragraph style of item:
rv.GetItem(i).ParaNo := NewParaNo (see the rule #1 in that help topic)
If you need to save changes, use TDBRichViewEdit.
The best place to modify document in DBRichView before displaying is OnLoadDocument event. The document is loaded, but not displayed yet.
Before modifying document, please read "Valid Documents" topic in the help file, because it's very easy to create incorrect document using methods described below.
To make item i to start a new paragraph:
rv.GetItem(i).SameAsPrev := False;
To change paragraph style of item:
rv.GetItem(i).ParaNo := NewParaNo (see the rule #1 in that help topic)
Sergey:
Thank you very much for your prompt reply. The processing that I wish to perform on the document is for display purposes only, the source (in the database) must remain intact.
Since we´re at it, there is another fix that I wish to perform on the document. Depending on the text to be displayed, I sometimes get orphan opening parenthesis. I need to find these parenthesis and push them to the next line (break line before, but within same paragraph) so that these opening parenthesis stay glued to the immediately following word. Just to be sure, the event to perform this would also be OnLoadDocument? And once I find the parenthesis that I wish to push down to the next line, all that would be needed would be to make the BR property (of the respective item) equal true? Once again, thank you for your help
Paulo
Thank you very much for your prompt reply. The processing that I wish to perform on the document is for display purposes only, the source (in the database) must remain intact.
Since we´re at it, there is another fix that I wish to perform on the document. Depending on the text to be displayed, I sometimes get orphan opening parenthesis. I need to find these parenthesis and push them to the next line (break line before, but within same paragraph) so that these opening parenthesis stay glued to the immediately following word. Just to be sure, the event to perform this would also be OnLoadDocument? And once I find the parenthesis that I wish to push down to the next line, all that would be needed would be to make the BR property (of the respective item) equal true? Once again, thank you for your help
Paulo
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Sergey:
I downloaded your example and tested the code in my application. Your code works like a clock, but I still have one problem to solve. How can I determine the item´s line number, along with the next line´s line number? If the parênthesis is the last char on the current line, then and only then will I want to drop it to the next line along with the following item... Thanks a lot for your help (and patience)
Paulo
I downloaded your example and tested the code in my application. Your code works like a clock, but I still have one problem to solve. How can I determine the item´s line number, along with the next line´s line number? If the parênthesis is the last char on the current line, then and only then will I want to drop it to the next line along with the following item... Thanks a lot for your help (and patience)
Paulo
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Yes, you are right (of course). So my question should be: where is the best place (event) to place code that analyzes the final layout of text on the RICHVIEW control so as to make these adjustments?
Another question: how can I trigger a refresh of the current contents of the field to which my DBRichView controls is attached without having to navigate to the next or previous record?
Once again, thanks !
Paulo
Another question: how can I trigger a refresh of the current contents of the field to which my DBRichView controls is attached without having to navigate to the next or previous record?
Once again, thanks !
Paulo
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
As I understand, you want to make changes in formatted document (only in formatted document you can get information about line wrapping).where is the best place (event) to place code that analyzes the final layout of text on the RICHVIEW control so as to make these adjustments?
In this case, you cannot use OnLoadDocument, because it is called before the document is formatted (and displayed).
Probably, table.AfterScroll event should work, try it.
Access to formatting information is not documented.
I'll try to explain the basics.
RichView.RVData.DrawItems is a list of TRVDrawLineInfo objects (DLines unit)
These objects represent formatting in the document.
Each non-text item corresponds to one such object.
Text item corresponds to one or more (if it is wrapped) such objects.
This object has properties:
ItemNo - index of item linked to this object
Offs - offset in this item (valid for text)
Length - length of text (valid for text)
(meaning of (ItemNo,Offs) is similar to parameters of SetSelectionBounds)
FromNewLine - true if this items starts a new line (not necessary a paragraph or <BR>, it may be a result of word wrapping)
This information is enough to determine which character is the last character in each line.
table.Refresh, I think.Another question: how can I trigger a refresh of the current contents of the field to which my DBRichView controls is attached without having to navigate to the next or previous record?