Code: Select all
function IsPlainText(rv: TCustomRichView): Boolean;
var
i, StyleNo, StyleNo2, ParaNo: Integer;
s: TRVUnicodeString;
begin
// if empty, then returning True
if rv.ItemCount = 0 then
begin
Result := True;
exit;
end;
Result := False;
// checking for a background bitmap
if (rv.BackgroundStyle<>bsNoBitmap) and not rv.BackgroundBitmap.Empty then
exit;
// finding the starting text and paragraph styles
StyleNo := rv.GetItemStyle(0);
if StyleNo = rvsTab then
StyleNo := TRVTabItemInfo(rv.GetItem(0)).TextStyleNo;
if StyleNo < 0 then
exit;
ParaNo := rv.GetItemPara(0);
for i := 0 to rv.ItemCount - 1 do
begin
// checking paragraph
if rv.GetItemPara(i) <> ParaNo then
exit;
// checking checkpoints, tags, tooltips
if (rv.GetItemCheckpoint(i) <> nil) or (rv.GetItemTag(i) <> '') then
exit;
rv.GetItemExtraStrProperty(i, rvespHint, s);
if s <> '' then
exit;
// checking text style
StyleNo2 := rv.GetItemStyle(i);
if StyleNo2 = rvsTab then
StyleNo2 := TRVTabItemInfo(rv.GetItem(i)).TextStyleNo;
if StyleNo <> StyleNo2 then
exit;
end;
Result := True;
end;
This function does not check text and paragraph attributes themselves (even if they have colored background and borders).