How to add doc and docx support in ActionTest ribbon demo?
Posted: Mon Dec 10, 2012 3:54 am
How to add doc and docx support in ActionTest ribbon demo?How can i spread the filter?
Support forums for TRichView, ScaleRichView, Report Workshop and RVMedia components
https://writeally.com/forums/
Code: Select all
DocConverters, DocXConverters: Boolean;
Code: Select all
function FindConverter(Converters: TRVOfficeCnvList; const Filter, DLL: String): Integer;
var i: Integer;
begin
Result := -1;
for i := 0 to Converters.Count-1 do
if (Filter = AnsiLowerCase(Converters[i].Filter)) and
(AnsiPos(DLL, AnsiLowerCase(Converters[i].Path))>0) then begin
Result := i;
exit;
end;
end;
const CNVDLL = 'wordcnvpxy.cnv';
procedure TForm3.InitDocFilters;
begin
DocConverters :=
(FindConverter(rvc.ImportConverters, '*.doc', CNVDLL)>=0) and
(FindConverter(rvc.ExportConverters, '*.doc', CNVDLL)>=0);
DocXConverters :=
(FindConverter(rvc.ImportConverters, '*.docx', CNVDLL)>=0) and
(FindConverter(rvc.ExportConverters, '*.docx', CNVDLL)>=0);
if DocConverters then
rvActionsResource.rvActionOpen1.CustomFilter := 'Microsoft Word 97-2003 Document|*.doc';
if DocXConverters then begin
if DocConverters then
rvActionsResource.rvActionOpen1.CustomFilter :=
rvActionsResource.rvActionOpen1.CustomFilter+'|';
rvActionsResource.rvActionOpen1.CustomFilter :=
rvActionsResource.rvActionOpen1.CustomFilter+'Microsoft Word 2007+ Document|*.docx';
end;
rvActionsResource.rvActionSaveAs1.CustomFilter := rvActionsResource.rvActionOpen1.CustomFilter;
end;
Code: Select all
procedure TForm3.RVAControlPanel1CustomFileOperation(Sender: TrvAction;
Edit: TCustomRichViewEdit; const FileName: string;
Operation: TRVAFileOperation; var SaveFormat: TrvFileSaveFilter;
var CustomFilterIndex: Integer; var Success: Boolean);
var Ext: String;
Index: Integer;
begin
Success := False;
Ext := '';
case CustomFilterIndex of
1:
if DocConverters then
Ext := '*.doc'
else if DocXConverters then
Ext := '*.docx';
2:
if DocConverters and DocXConverters then
Ext := '*.docx';
end;
if Ext='' then
exit;
case Operation of
rvafoOpen:
Success := rvc.ImportRV(FileName, Edit, FindConverter(rvc.ImportConverters, Ext, CNVDLL));
rvafoSave:
Success := rvc.ExportRV(FileName, Edit, FindConverter(rvc.ExportConverters, Ext, CNVDLL));
end;
end;