How to protect parts of a text against changes?
I have a text which contains sections that must not be changed by the user.
Innenputz 2lagig Leibung B 24 cm UP Kalkzement-Putzm. D 20mm OP Kalkzement-Putzm. gefilzt
2-lagiges Innenputzsystem DIN 18550-2 auf Leibung, Breite Leibung '24' cm, Putzgrund Mauerwerk, Unterputz DIN EN 998-1 aus Kalkzement-Putzmörtel, Druckfestigkeitsklasse CS II (1,5 bis 5 N/mm2), Dicke Unterputz 20 mm, Oberputz aus Kalkzement-Putzmörtel, Putzoberfläche Qualitätsstufe 2 (Q2), gefilzt, übliche Beanspruchung, Arbeitshöhe der zu bearbeitenden oder zu bekleidenden Fläche bis 3,5 m über der Standfläche des hierfür erforderlichen Gerüstes, Ausführung im Erdgeschoss.
The highlighted text Breite Leibung '24' must not be changed.
I tried par.CharAttrModify( WPAT_ParProtected, 1, wpSetValue, startPos, posLen ); - But this doesn't work because CharAttrModify allows only a small set of WPAT_Code to be modified.
How can I protected parts of a text?
Edit:
During the creation of the document, the highlighted text is later converted to a hyperlink with the following code:
textObj := WP.TextObjects.InsertClass( '', 0, 0, wpobjOpening, par, startPos );
if Assigned( textObj ) then
begin
textObj._SetObjType( wpobjHyperlink );
textObj.name := linkName;
textObj.Source := textObj.name;
textObj.Mode := textObj.Mode + [ wpobjLockEmbeddedText ]; // Doesn't work either
textObjClosing := WP.TextObjects.InsertClass( '', 0, 0, wpobjClosing, par, endPos );
if Assigned( textObjClosing ) then
begin
textObjClosing._SetObjType( wpobjHyperlink );
textObjClosing.name := textObj.name;
textObjClosing.SetTag( textObj.NewTag );
end;
Inc( offset );
end;
Inc( offset );
So I tried adding the wpobjLockEmbeddedText option to textObj.Mode - According to the help file wpobjLockEmbeddedText is used to "temporaily used to prohibit changing embedded text." But this doesn't seem to have an effect either.
I saw that the TWPTextObjType which is used in textObj._SetObjType has a wpobjTextProtection - So instead of a wpobjHyperlink text object I tried creating a wpobjTextProtection text object to check if the embedded text inside the text object is protected, but this also doesn't work.
WP.ProtectedProp is set to [ ppParProtect, ppProtected, ppIsHyperlink ] - I was hoping that ppIsHyperlink will protect hyperlinks, but it seems that it will only protect "the hyperlink start or end markers" according to the help file.