GetAllText WordWrap Returns?
GetAllText WordWrap Returns?
Hi folks,
i've a problem with the GetAllText function if i want only the plain-text of a document. If i'm tipping a long text with the property wordwrap = true then ther will be carriage return(line feeds)'s shown but if i'm getting the text with GetAllText they won't be exportet. Is there a clue to get them?
Greetings, ThY
i've a problem with the GetAllText function if i want only the plain-text of a document. If i'm tipping a long text with the property wordwrap = true then ther will be carriage return(line feeds)'s shown but if i'm getting the text with GetAllText they won't be exportet. Is there a clue to get them?
Greetings, ThY
-
- Site Admin
- Posts: 17554
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17554
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
This function uses undocumented methods.
1) Include RV_Defs.inc in your unit, it contains RVUNICODESTR define:
Include in uses: CRVFData, DLines, RVTable, RVItem.
2) A helper function
3) Main function
How to use:
1) Include RV_Defs.inc in your unit, it contains RVUNICODESTR define:
Code: Select all
{$I RV_Defs.inc}
2) A helper function
Code: Select all
// Converting text from internal representation to String
function ConvertItemTextToString(const ItemText: TRVRawByteString;
UnicodeItem: Boolean; CodePage: Cardinal): String;
begin
{$IFDEF RVUNICODESTR} // <-- declared in RV_Defs.inc
// Delphi 2009+: String is Unicode
if UnicodeItem then
Result := RVU_RawUnicodeToWideString(ItemText)
else
Result := RVU_RawUnicodeToWideString(
RVU_AnsiToUnicode(CodePage, ItemText));
{$ELSE}
// Delphi 4-2007: String is ANSI
if UnicodeItem then
Result := RVU_UnicodeToAnsi(CodePage, ItemText)
else
Result := ItemText;
{$ENDIF}
end;
Code: Select all
function GetFormattedText(RVData: TCustomRVFormattedData): String;
var i, r, c, ItemNo, StyleNo: Integer;
table: TRVTableItemInfo;
begin
Result := '';
for i := 0 to RVData.DrawItems.Count-1 do begin
if (i>0) and RVData.DrawItems[i].FromNewLine then
Result := Result+#13#10;
ItemNo := RVData.DrawItems[i].ItemNo;
StyleNo := RVData.GetItemStyle(ItemNo);
if StyleNo=rvsTab then
Result := Result+#9
else if StyleNo=rvsTable then begin
table := TRVTableItemInfo(RVData.GetItem(ItemNo));
for r := 0 to table.RowCount-1 do
for c := 0 to table.ColCount-1 do begin
if table.Cells[r,c]<>nil then
Result := Result + GetFormattedText(TCustomRVFormattedData(table.Cells[r,c].GetRVData));
if not ((r=table.RowCount-1) and (c=table.ColCount-1)) then
Result := Result+#13#10;
end;
end
else if StyleNo>=0 then
Result := Result+ConvertItemTextToString(
RVData.DrawItems.GetString(i, RVData.Items),
RVData.GetRVStyle.TextStyles[StyleNo].Unicode,
RVData.GetItemCodePage(ItemNo));
end;
end;
Code: Select all
Memo1.Lines.Text := GetFormattedText(RichViewEdit1.RVData)
-
- Site Admin
- Posts: 17554
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17554
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Uh, sorry there was a mistake/bug in my code.Sergey Tkachenko wrote:?
GetFormattedText, like GetAllText, returns a plain text.
The only differences
- GetFormattedText adds more line break characters in places of line wrapping;
- GetFormattedText does not include text representation of non-text items (except for tabs and tables)