InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
SDKFileSaveChooser Class Reference

#include <SDKFileHelper.h>

Inheritance diagram for SDKFileSaveChooser:
SDKFileHelper

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
 

Detailed Description

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.

See Also
ShuksanID.h for available FileTypeInfoID's
FileTypeRegistry for access to FileTypeInfo
ISaveFileDialog
kSaveFileDialogBoss

Constructor & Destructor Documentation

SDKFileSaveChooser::SDKFileSaveChooser ()

Constuctor

SDKFileSaveChooser::~SDKFileSaveChooser ()
virtual

Destructor

Member Function Documentation

void SDKFileSaveChooser::AddFilter (const FileTypeInfoIDfileTypeInfoID,
const PMStringfilterName 
)

Add filter by FileTypeInfoID, if the FileTypeRegistry knows about the kind of file you want use this call.

Parameters
fileTypeInfoIDIN FileTypeRegistry ID, for example kXMLFileTypeInfoID, see ShuksanID.h for available IDs.
filterNameIN name displayed in the UI to let the user to apply the filter (must be translatable strings).
Postcondition
the user will be able to apply this filter to control the files shown by SDKFileSaveChooser::ShowDialog.
void SDKFileSaveChooser::AddFilter (const SysOSType & macFileCreator,
const SysOSType & macFileType,
const PMStringextension,
const PMStringfilterName 
)

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.

Parameters
macFileCreatorIN Mac file creator, 'CWIE' for example.
macFileTypeIN Mac file type, 'TEXT' or 'JPEG' for example.
extensionIN file extension, "txt" or "jpg" for example.
filterNameIN name displayed in the UI to let the user to apply the filter (must be translatable strings).
Postcondition
the user will be able to apply this filter to control the files shown by SDKFileSaveChooser::ShowDialog.
int32 SDKFileSaveChooser::GetFilterIndex ()

Get the selected index of fileter combo box.

Returns
the selected index of fileter control, or -1.
void SDKFileSaveChooser::SetFilename (const PMStringfilename)

Set the name of the file suggested to the user.

Parameters
filenameIN 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 PMStringtitle)

Set the title of the dialog.

Parameters
titleIN 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).

Postcondition
SDKFileHelper::IsChosen is kTrue if a file was chosen, kFalse otherwise.
SDKFileHelper::GetIDFile contains the chosen file if SDKFileHelper::IsChosen is kTrue.
SDKFileHelper::GetPath contains the path to the chosen file if SDKFileHelper::IsChosen is kTrue.
See Also
ISaveFileDialog
kSaveFileDialogBoss