WPCubed Product Support

Schutz von Tabellenzellen

wpsupport

Da bietet sich der Absatz Schutz an:

call.ASet(WPAT_ParProtected, 1);

Diesen schutz muss man noch aktivieren:

WP.ProtectedProp := WP.ProtectedProp + [ppParProtected];

Dies sind die flags:

TProtectProps = (
   ppParProtected,
   // the complete paragraph cannot be deleted --> WPAT_ParProtected
   ppCheckAllText, // Trigger event for the complete text
   ppAllExceptForEditFields,
   // Only allow editing in edit fields. Cursor jumps between edit fields
   ppNoNewParagraphsInEditFields,
   // Do not allow par insertion/deletion in EditFields
   ppProtected, // Text with the style afsProtected cannot be overridden
   ppHidden, // Text which uses the style 'hidden'
   ppIsInsertpoint, // Protect the field start or end markers (wpobjMergeField)
   ppIsMergedText,
   // used to be 'ppAutomatic', The oposite of  ppAllExceptForEditFields
   ppIsBookmark, // Protect the bookmark start or end markers (wpobjBookmark)
   ppIsTextObject, // Protect the fields (such as PAGE numbers) (wpobjTextObj)
   ppIsImageObject, // Protected the images (wpobjImage)
   ppProtectionTextObjects, // WPTools 7: used with TWPTextObj.Mode 'wpobjWithinProtected'
   ppIsInvisible, ppAllowEditAtTextEnd, // Allow typing at text end
   // These flags are not checked in "function TWPRTFEngineBasis.IsProtected()"
   ppProtectSelectedTextToo,
   ppProtectSelectedWholeTextToo, // Also protect text if whole text is selected
   // Must be combined with  ppProtectSelectedTextToo
   ppDontProtectAttributes,
   // V5.15 - if defined it is possible to change the attributes of protected text
   // ppDontCopyProtectedAttribute - obsolte, see ClipboardOptions
   ppDontUseAttrOfProtected,
   // do not use the charattr if the text is protected
   ppNoEditAfterProtection,
   // Do not allow editing at the end of the paragraph if the last char is protected
   ppInsertBetweenProtectedPar,
   // Allow the insertion between protected paragraphs
   ppIsTextObjectCustom, // Protect the fields, but not "PAGE", "NUMPAGES"
   // obsolete: ppNotUsedForSpellAsYouGo  // any text which is protected is not spellchecked!
   ppBookmarkKeepStructure,
   // Used with ppIsBookmark. Recreate Bookmark structure
   ppInsertpointKeepStructure,
   // Used with ppIsInsertpoint. Recreate Field structure
   ppIsHyperlink,
   // Protect the hyperlink start or end markers (wpobjHyperlink)
   ppNoEditBeforeProtection
   // Disable insertion if protected text is first in paragraph
   );
#2 ♥ 0
2.5k Views 2 users read 3 min

Hallo, ich habe den folgenden Code:

procedure TDesignerForm.btnTabelle_erzeugenClick(Sender: TObject);
var
table, row, cell: TParagraph;
block : TWPRTFDataBlock;
i, c, SpaltenAnzahl: Integer;
begin
// Anzahl der Spalten aus dem Edit-Feld holen
SpaltenAnzahl := StrToIntDef(edtSpalten.Text, 5); // Standardwert: 5 Spalten
try
block := WP.BodyText;
block.Clear(true);
table := block.AppendNewPar(true);
table.ParagraphType := wpIsTable;
// Erste Reihe mit Namen der Spalten
row := table.AppendChild;
row.ParagraphType := wpIsTableRow;
for c := 1 to SpaltenAnzahl do
begin
cell := row.AppendNewCell;
cell.SetText('Spalte ' + IntToStr(c));
// Rahmen
cell.ASet(WPAT_BorderFlags, WPBRD_DRAW_All4);
cell.ParProtected := True;
end;
// Weitere Reihen mit Beispielinhalt
for i := 1 to 2 do
begin
row := table.AppendChild;
row.ParagraphType := wpIsTableRow;
for c := 1 to SpaltenAnzahl do
begin
cell := row.AppendNewCell;
cell.SetText(Format('%d - %d', [i, c]));
// Rahmen
cell.ASet(WPAT_BorderFlags, WPBRD_DRAW_All4);
end;
end;
WP.ReformatAll(true, true);
finally
end;
end;

Ich habe den Code aus Ihrem Demo-Beispiel verwendet, um die Tabelle zu erstellen. In Zeile 27 versuche ich, die Spaltenüberschriften der Tabelle vor der Bearbeitung zu schützen. Aber ohne Erfolg. Was ist der richtige Weg, dies zu tun? Danke im Voraus.

#1 ♥ 0