trichview.support
Re: Apply new style to entire document |
Author |
Message |
Sergey Tkachenko |
Posted: 11/26/2004 22:01:11 Hi, If you want an operation which can be undone/redone, the only way is selecting and calling ApplyTextStyle. Another way - assigning text style to each text item. It can be done by assigning to (undocumented) item property StyleNo: RVData.GetItem(i).StyleNo := NewStyleNo. But you must check if the old text style and new text style have the same value of Unicode property, otherwise the document will be damaged. Even if no Unicode styles existed in your document initially, they can appear when reading/pasting RTF, if RichViewEdit.RTFReadProperties.UnicodeMode<>rvruNoUnicode. For changing text styles of all items, you can create a recursive procedure iterating all items in all RVDatas (there are many examples posted in this newsgroup, and there is one in the help file, the topic "Controls, Documents, Items"). But you can use an undocumented callback procedure (mentioned by David), it's simpler: procedure TForm3.SetStyleProc(RVData: TCustomRVData; ItemNo: Integer; var UserData1: Integer; const UserData2: String; var ContinueEnum: Boolean); begin if (RVData.GetItemStyle(ItemNo)>=0) and (RVData.GetRVStyle.TextStyles[UserData1].Unicode= RVData.GetRVStyle.TextStyles[RVData.GetItemStyle(ItemNo)].Unicode) then begin RVData.GetItem(ItemNo).StyleNo := UserData1; RVData.SetItemTag(ItemNo, 0); end; ContinueEnum := True; end; var StyleNo: Integer; begin StyleNo := 0; RichViewEdit1.RVData.EnumItems(SetStyleProc, StyleNo, ''); RichViewEdit1.ClearUndo; RichViewEdit1.Format; end; This example does not change styles with different value of Unicode property. If you need it, I can modify this example. > Sorry. I accidentally hit send before I was finished. > > I need to programmatically change the text style of an entire document. > I can do this with select all with the obvious side effects, but I'm > looking for a better way. > > Thanks, > Gerry > > > > > Gerry Weaver wrote: > > Hi, > > > > Is there a way to apply a particular text style to an entire document? I > > need to have some predefined / canned formats for documents. > > > > Thanks, > > Gerry |
Powered by ABC Amber Outlook Express Converter