Converting indentations to spaces when saving as .TXT?
-
- Posts: 57
- Joined: Tue Jul 13, 2010 10:50 pm
Converting indentations to spaces when saving as .TXT?
Hi! I have a RichViewEdit where some paragraphs are indented. Now, when I export the document to plain text (.TXT), the paragraph indentations should automatically be converted to spaces. Is there an option to do this automatically or do I have to write an OnSaveItemToFile event-handler?
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Posts: 57
- Joined: Tue Jul 13, 2010 10:50 pm
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
This code adds 3 spaces at the beginning of paragraphs having the first line indented.
Problems:
1) This code does not add spaces for paragraphs started from a non-text item.
2) Unlike the standard text saving procedure, this code does not make a special processing when saving text of SYMBOL_CHARSET's font, like "Symbol" or "Windgdings"
3) This code ignores CodePage parameter of SaveText. You can store this code page in a global variable, and use it instead of CP_ACP.
Actually, I think that creating a modified copy is a better approach.
Code: Select all
procedure TForm3.RichViewEdit1SaveItemToFile(Sender: TCustomRichView;
const Path: string; RVData: TCustomRVData; ItemNo: Integer;
SaveFormat: TRVSaveFormat; Unicode: Boolean; var OutStr: TRVRawByteString;
var DoDefault: Boolean);
begin
if SaveFormat<>rvsfText then
exit;
if not RVData.IsParaStart(ItemNo) or
(RVData.GetRVStyle.ParaStyles[RVData.GetItemPara(ItemNo)].FirstIndent<=0) then
exit;
DoDefault := False;
if Sender.Style.TextStyles[RVData.GetItemStyle(ItemNo)].Unicode then begin
OutStr := ' '#0' '#0' '#0+OutStr;
if not Unicode then
OutStr := RVU_UnicodeToAnsi(CP_ACP, OutStr);
end
else begin
OutStr := ' '+OutStr;
if Unicode then
OutStr := RVU_AnsiToUnicode(RVData.GetItemCodePage(ItemNo), OutStr);
end;
end;
1) This code does not add spaces for paragraphs started from a non-text item.
2) Unlike the standard text saving procedure, this code does not make a special processing when saving text of SYMBOL_CHARSET's font, like "Symbol" or "Windgdings"
3) This code ignores CodePage parameter of SaveText. You can store this code page in a global variable, and use it instead of CP_ACP.
Actually, I think that creating a modified copy is a better approach.