![]() | InDesign SDK 20.5 |
#include <SDKFileHelper.h>

Public Member Functions | |
| SDKFileSaveChooser () | |
| virtual | ~SDKFileSaveChooser () |
| void | AddFilter (const FileTypeInfoID &fileTypeInfoID, const PMString &filterName) |
| void | AddFilter (const SysOSType &macFileCreator, const SysOSType &macFileType, const PMString &extension, const PMString &filterName) |
| void | SetTitle (const PMString &title) |
| void | SetFilename (const PMString &filename) |
| int32 | GetFilterIndex () |
| void | ShowDialog () |
Public Member Functions inherited from SDKFileHelper | |
| SDKFileHelper (const PMString &path) | |
| SDKFileHelper (const IDFile &file) | |
| virtual | ~SDKFileHelper () |
| bool16 | IsExisting () const |
| bool16 | IsChosen () const |
| PMString | GetPath () const |
| IDFile | GetIDFile () const |
| IDFile | GetAbsoluteFromRelative (const PMString &relativePath) const |
| PMString | GetParentFolderAsString () const |
Additional Inherited Members | |
Static Public Member Functions inherited from SDKFileHelper | |
| static bool16 | isMacPosixPathEnabled () |
Protected Member Functions inherited from SDKFileHelper | |
| SDKFileHelper () | |
| void | initFromString () |
| void | initFromSysFile () |
| void | traceInitializeDiagnostics (int32 e) const |
| PMString | calcDefaultFileName () const |
| void | setChosen (bool16 chsen) |
| void | setIDFile (const IDFile &file) |
| void | setPath (const PMString &path) |
| PMString | absoluteFromRelative (const PMString &folder, const PMString &path) const |
| bool16 | isAbsolutePath (const PMString &path) const |
| bool16 | isUnixPath (const PMString &path) const |
| bool16 | isMacPath (const PMString &path) const |
| bool16 | isWinPath (const PMString &path) const |
| PMString | getMinusLastElement (const PMString &path) const |
| PMString | getMinusFirstElement (const PMString &path) const |
| PMString | getAsMacPath (const PMString &path) const |
| PMString | getAsWinPath (const PMString &path) const |
Provides a mechanism for the user to choose a file to be saved to and allows filtering of the files presented, note this class does not actually save the file, it just lets the user choose a file.
The code below pops a file save chooser dialog for a publication file (an InDesign document if you are running under InDesign, an InCopy document if you are running under InCopy).
SDKFileSaveChooser fileChooser; fileChooser.ShowDialog(); if (fileChooser.IsChosen()) { IDFile chosenFile = fileChooser.GetIDFile(); }
The code below pops a file save chooser for a jpg or gif file.
SDKFileSaveChooser fileChooser; fileChooser.AddFilter(kJPEGFileTypeInfoID, "JPEG file(jpg)"); fileChooser.AddFilter(kGIFFileTypeInfoID, "GIF file(gif)"); fileChooser.ShowDialog(); if (fileChooser.IsChosen()) { IDFile chosenFile = fileChooser.GetIDFile(); }
Note that the filter names, e.g. "JPEG files(jpg)", must be translatable string keys with a value in a StringTable.
| SDKFileSaveChooser::SDKFileSaveChooser | ( | ) |
Constuctor
| virtual |
Destructor
| void SDKFileSaveChooser::AddFilter | ( | const FileTypeInfoID & | fileTypeInfoID, |
| const PMString & | filterName | ||
| ) |
Add filter by FileTypeInfoID, if the FileTypeRegistry knows about the kind of file you want use this call.
| fileTypeInfoID | IN FileTypeRegistry ID, for example kXMLFileTypeInfoID, see ShuksanID.h for available IDs. |
| filterName | IN name displayed in the UI to let the user to apply the filter (must be translatable strings). |
| void SDKFileSaveChooser::AddFilter | ( | const SysOSType & | macFileCreator, |
| const SysOSType & | macFileType, | ||
| const PMString & | extension, | ||
| const PMString & | filterName | ||
| ) |
Add filter by macFileCreator, macFileType and extension, if you know the specific Mac file creator, Mac file type and the Win file extension you want you can use this call. It's worth checking if the FileTypeRegistry has a FileTypeInfoID for the kind of file you want before using this call, then you can avoid hard wiring file creator, type and extension information in your code.
| macFileCreator | IN Mac file creator, 'CWIE' for example. |
| macFileType | IN Mac file type, 'TEXT' or 'JPEG' for example. |
| extension | IN file extension, "txt" or "jpg" for example. |
| filterName | IN name displayed in the UI to let the user to apply the filter (must be translatable strings). |
| int32 SDKFileSaveChooser::GetFilterIndex | ( | ) |
Get the selected index of fileter combo box.
| void SDKFileSaveChooser::SetFilename | ( | const PMString & | filename | ) |
Set the name of the file suggested to the user.
| filename | IN name of the file suggested to the user as the file to save to (translatable string keys passed here will be translated before display in the dialog). |
| void SDKFileSaveChooser::SetTitle | ( | const PMString & | title | ) |
Set the title of the dialog.
| title | IN dialog title (translatable string). |
| void SDKFileSaveChooser::ShowDialog | ( | ) |
Pops a file browse dialog to allow the user to choose a file to be saved to. If any filters have been specified by the caller (SDKFileSaveChooser::AddFilter, SDKFileSaveChooser::AddAllFiles), the user will be able to apply them to control the files shown in the chooser. Otherwise a filter will be applied that will show publication documents (InDesign documents under InDesign, InCopy documents under InCopy).