block edit after print

General TRichView support forum. Please post your questions here
Post Reply
tiagosis
Posts: 41
Joined: Thu Apr 13, 2017 5:34 pm

block edit after print

Post by tiagosis »

hello, is it possible for me to block changes to a certain block of texts?
I would like to block the editing of texts always after printing, so that even the point where it was printed could no longer be changed, but that there is the possibility of breaking the line after the printed point and continue editing and so on.
Sergey Tkachenko
Site Admin
Posts: 17554
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: block edit after print

Post by Sergey Tkachenko »

As for me, the only simple and reliable solution is moving the printed part to a read-only TRichViewEdit or in TRichView, and to allow entering the rest of text in a separate editor. Seriously, consider using this method.

If you still want to use a single editor, it may be not very simple.
I can describe properties that can help.

Options of paragraph styles.
Protection of text styles.
TRVExtraItemProperty lists properties of non-text items.

Pay attention to

paragraph style Options:
- rvpaoReadOnly: makes the paragraph read-only, but does not protect from its deletion as whole (if it does not contain delete-protected items), and does not protect from adding new paragraphs when pressing Enter at the beginning/end of the paragraph.
- rvpaoDoNotWantReturns: blocks Enter keys in the paragraph
- rvpaoStyleProtect: protects from changing paragraph style (such as changing paragraph alignment)

text Protection options: rvprStyleProtect, rvprModifyProtect, rvprDeleteProtect, rvprDoNotAutoSwitch, rvprSticking, rvprStickToTop

non-text item property: rvepDeleteProtect, rvepResizable

---

Conclusion:
- protecting the whole paragraph is possible: [rvpaoReadOnly, rvpaoDoNotWantReturns, rvpaoStyleProtect], and delete-protect at least one item in each paragraph.
- or you can protect all text items [rvprStyleProtect, rvprModifyProtect, rvprDeleteProtect, rvprDoNotAutoSwitch, rvprSticking, rvprStickToTop]. But there is a problem for non-text items. While you can protect them from deletion and resizing, (if paragraphs are not protected) you cannot protect from insertion content before or after non-text items.

PS: the simplest way to apply changes in text and paragraph styles is ApplyStyleConversion + OnStyleConversion, and ApplyParaStyleConversion + OnParaStyleConversion, see the demos in TRichView\Demos\*\Editors\Editor 2, or a similar demo in ScaleRichView\Demos\*\RVDemos\Editors\Editor 2\
Sergey Tkachenko
Site Admin
Posts: 17554
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: block edit after print

Post by Sergey Tkachenko »

By the way, if you use incremental printing feature, and want to allow to enter text to the end of the last line, it may be not good.

Obviously, you cannot use it for centered, right-aligned and distributed paragraphs (if the last line is distributed as well), because new text in the last line will shift the text.
But even for left-aligned text, new text can change line breaking.

For example, text before printing.
Hello world
Then the user added text:
Hello worldwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
You can see, "world" was moved to the next line.
tiagosis
Posts: 41
Joined: Thu Apr 13, 2017 5:34 pm

Re: block edit after print

Post by tiagosis »

I implemented the lock using: ProtectionOptions = [rvprModifyProtect, rvprDeleteProtect, rvprStyleProtect, rvprDoNotAutoSwitch, rvprStickToTop,rvprSticking];
but control + enter is still able to disorganize the text, any idea how to block control + enter?
thanks
tiagosis
Posts: 41
Joined: Thu Apr 13, 2017 5:34 pm

Re: block edit after print

Post by tiagosis »

Else, how can I test if there are protected passages in the text?
Sergey Tkachenko
Site Admin
Posts: 17554
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: block edit after print

Post by Sergey Tkachenko »

Use one more text protection option, rvprParaStartProtect, it protects from Enter.

There are no visual differences in protected text. You can use TRVStyle.OnDrawStyleText to modify text drawing, if its protection is not empty. For example, you can draw a border around it.
For TSRichViewEdit, assign this event manually in code (SRichViewEdit1.RichViewEdit.Style.OnDrawStyleText)
tiagosis
Posts: 41
Joined: Thu Apr 13, 2017 5:34 pm

Re: block edit after print

Post by tiagosis »

the protection works when I send protection, so I save the text and when I reload "rvprParaStartProtect" it stops working, the text can be broken with enter at the beginning, what could I be doing to get around this?
Sergey Tkachenko
Site Admin
Posts: 17554
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: block edit after print

Post by Sergey Tkachenko »

In which format do you save?
These protection options can be stored only in RVF format.
tiagosis
Posts: 41
Joined: Thu Apr 13, 2017 5:34 pm

Re: block edit after print

Post by tiagosis »

i save in RTF
Sergey Tkachenko
Site Admin
Posts: 17554
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: block edit after print

Post by Sergey Tkachenko »

Unfortunately, these protection options cannot be saved in RTF
Post Reply