Page 1 of 1
saveAs and export
Posted: Wed May 25, 2016 4:14 pm
by wandogau
Hello,
why are there to filters in RichViewActions, one for saving and one for exporting?
The Problem, I run into is, if I open a file (docx) and want to save it, the normal way, there is no Chance, because ffeDocX is not in the export-filter.
I'm sure I'll find a way around, but maybe I just have'nt understand the reasons behind it?
Best regards
Marco (wandogau)
Posted: Wed May 25, 2016 8:55 pm
by Sergey Tkachenko
New, Open, Save, SaveAs actions work together. When you open a document in certain format, it will be saved in the same format (by Save), or a dialog suggests to save a new file in the same format (by SaveAs). The actions store information about document opened in each editor, and this information is updated when you create a new document, open an existing document, or save under a new name or format.
But Export action works independently. It simply creates a new file, without updating information about a document in the editor.
Another such an independent action is InsertFile.
Currently, TRichView does not have method for reading DocX files, so you cannot open it, so DocX is not included in the list of formats supported by the Open action.
You can only insert DocX file in InsertFile action, if the proper converter is installed on the computer (the actions use TRVOfficeConverter component internally)
Posted: Fri May 27, 2016 1:28 pm
by wandogau
Hello Sergey,
okay, I understand.
but, I added the Office-converters to the open and also to the save-filter.
in open filter I get
docm, cox, and doc formats,
in save I get only
docm and doc
on my machine here. Is that correct?
So, I can let the user open a docx file, but there's is no Chance to save it as a docx.
Is there a way of forcing the saveAs-dialog to popup? What I mean: I open a docx file via ActionOpen, and, if the user tries to save it, I want to have the saveAs-dialog displayed, so that the user can chose another format.
Best regards and looking for your answer
Marco (wandogau)
Posted: Fri May 27, 2016 7:07 pm
by Sergey Tkachenko
In RichViewActions, office-converters can be used only in "Insert File" and "Export" actions.
They are not used in "Open" and "SaveAs" actions.
For these actions, you can implement additional formats yourself, see
http://www.trichview.com/help-actions/t ... ration.htm
Posted: Fri May 27, 2016 9:23 pm
by wandogau
Hello Sergey,
Sergey Tkachenko wrote:They are not used in "Open" and "SaveAs" actions.
For these actions, you can implement additional formats yourself,...
Sorry, I believe that I have not explained clearly what I mean:
I did the following:
Code: Select all
actionSaveAs.filter := [ffeRTF, ffeTextANSI, ffeTextUnicode, ffeCustom];
actionSaveAs.customFilter := rvConverter.getExportfilter;
actionOpen.filter := [ffiRTF,ffiTextANSI,ffiTextUnicode,ffiTextAuto,ffiCustom];
actionOpen.customFilter := rvConverter.getImportfilter;
and
Code: Select all
procedure TMainForm.ControlPanelCustomFileOperation(Sender: TrvAction;
Edit: TCustomRichViewEdit; const FileName: String;
Operation: TRVAFileOperation; var SaveFormat: TrvFileSaveFilter;
var CustomFilterIndex: Integer; var Success: Boolean);
begin
case operation of
rvafoOpen:
// here I have three Options in CustomFilter: docx, docm, doc
success := rvConverter.ImportRV (
filename, edit, customFilterIndex - 1);
rvafosave:
// here are only two Options in customFilter, docm and doc
// does it depend on my machine, or do I have understood something wrong?
success := rvConverter.ExportRV (
filename, edit, customFilterIndex -1);
end;
end;
The latest officeConverters are installed and work properly.
Best regards
Marco (wandogau)
Posted: Mon May 30, 2016 9:14 am
by Sergey Tkachenko
The set of converters and their indexes in the list may vary from computer to computer.
So you cannot rely in their index, you my detect format by the extension.
DocX import converters can be installed from
http://www.microsoft.com/en-US/download ... .aspx?id=3
If you want, I can make an example that will open DocX files via TRVOfficeConverter, and save them using SaveDocX method.
However, I do not recommend to use this feature in a real application, because converters do not import many information that TRichView (or MS Word) stores in DocX files, so currently I recommend using DocX only for export format.
Posted: Mon May 30, 2016 12:47 pm
by wandogau
Hello Sergey,
okay, now I understand.
Most of our users will have stored only text in a docx-file, maybe with some bold or underline attributes - so the Import via officeConverter should work here.
But, a last question regarding this Topic:
I've imported a file via actionOpen1.loadFile..., by passing ffiCustom and the corresponding filter index - all works okay.
If the user now tries to save this file, I want to force the saveAs-Dialog coming up, so that a Format like RTF or RVF can be selected.
But, how can I do this - because, if user just clicks on save, no saveAs-dialog will popup, because filename etc. are stored correctly. So what do I have to Change, to force the saveAs-dialog to popup?
Best regards and many thanks for your help
Marco (wandogau)