Page 1 of 1
block edit after print
Posted: Tue Feb 16, 2021 7:28 pm
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.
Re: block edit after print
Posted: Wed Feb 17, 2021 9:08 am
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\
Re: block edit after print
Posted: Wed Feb 17, 2021 9:14 am
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.
Re: block edit after print
Posted: Wed Feb 17, 2021 2:08 pm
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
Re: block edit after print
Posted: Wed Feb 17, 2021 3:10 pm
by tiagosis
Else, how can I test if there are protected passages in the text?
Re: block edit after print
Posted: Thu Feb 18, 2021 8:29 am
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)
Re: block edit after print
Posted: Thu Feb 18, 2021 1:32 pm
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?
Re: block edit after print
Posted: Thu Feb 18, 2021 5:36 pm
by Sergey Tkachenko
In which format do you save?
These protection options can be stored only in RVF format.
Re: block edit after print
Posted: Mon Feb 22, 2021 3:42 pm
by tiagosis
i save in RTF
Re: block edit after print
Posted: Tue Feb 23, 2021 3:03 pm
by Sergey Tkachenko
Unfortunately, these protection options cannot be saved in RTF