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

Public Member Functions

 SnpShareAppResources ()
 
virtual ~SnpShareAppResources ()
 
ErrorCode ExportAppWorkspace ()
 
ErrorCode ExportPrefsPanel ()
 
ErrorCode ExportPrefsAndDefaults ()
 
ErrorCode ExportTextStyles ()
 
ErrorCode ExportObjectStyles ()
 
ErrorCode ExportXMLTagsAndPrefs ()
 
ErrorCode ExportSwatches ()
 
ErrorCode ImportToApp ()
 
ErrorCode ImportToAppWithOptions ()
 

Detailed Description

  • How to export and import application preferences, text styles, XML tags, object styles, and swatches.

This code contains seven export methods and two import method. The seven export methods show how to export the previously mentioned application resources as INX Snippets. The two import methods import any one of these INX Snippets into the application. The difference is ImportToAppWithOptions() shows how to set import options before importing.

For simplicity the 7 exports all write out a file named SnpShareAppResources.xml in the users application preference folder. The import methods read in this file, updating the specified resources.

Note: This also runs in InCopy, but you will run into several instances of an assert in the debug build. The assert is related to the scriptability of a UI color used in InCopy. It's a bug, but it's safe to ignore.

Constructor & Destructor Documentation

SnpShareAppResources::SnpShareAppResources ()
inline

Constructor.

virtual SnpShareAppResources::~SnpShareAppResources ()
inlinevirtual

Destructor.

Member Function Documentation

ErrorCode SnpShareAppResources::ExportAppWorkspace ()
Shows how to exort all preference objects in the scripting DOM

Returns
kSuccess on success, or kFailure or another ErrorCode value identifying the error.
Postcondition
Creates SnpShareAppResources.xml in the user's preference folder.
ErrorCode SnpShareAppResources::ExportObjectStyles ()
Shows how to export all object styles.

Returns
kSuccess on success, or kFailure or another ErrorCode value identifying the error.
Postcondition
Creates SnpShareAppResources.xml in the user's preference folder.
ErrorCode SnpShareAppResources::ExportPrefsAndDefaults ()
Shows how to export everything except some excluded set of objects.  In this case

the excluded set is taken from AppPrefsListElementTypes.h, which holds a list off

all InDesign's native list element types of preference objects.  This includes list of

items such as paragraph and character styles, swatches, XML tags, etc.

Returns
kSuccess on success, or kFailure or another ErrorCode value identifying the error.
Postcondition
Creates SnpShareAppResources.xml in the user's preference folder.
ErrorCode SnpShareAppResources::ExportPrefsPanel ()
Shows how to limit an export to some set of scripting preference objects.  In this

case it exports everything that is known to live in the preferences panel.

Returns
kSuccess on success, or kFailure or another ErrorCode value identifying the error.
Postcondition
Creates SnpShareAppResources.xml in the user's preference folder.
ErrorCode SnpShareAppResources::ExportSwatches ()
Shows how to export all swatches in the swatches panel.

Returns
kSuccess on success, or kFailure or another ErrorCode value identifying the error.
Postcondition
Creates SnpShareAppResources.xml in the user's preference folder.
ErrorCode SnpShareAppResources::ExportTextStyles ()
Shows how to export all character and paragraph styles.

Returns
kSuccess on success, or kFailure or another ErrorCode value identifying the error.
Postcondition
Creates SnpShareAppResources.xml in the user's preference folder.
ErrorCode SnpShareAppResources::ExportXMLTagsAndPrefs ()
Shows how to export all XML tags and related preferences.

Returns
kSuccess on success, or kFailure or another ErrorCode value identifying the error.
Postcondition
Creates SnpShareAppResources.xml in the user's preference folder.
ErrorCode SnpShareAppResources::ImportToApp ()
Imports the INX Snippets back into the application.

Precondition
A valid INX snippet named SnpShareAppResources.xml should exist in the users preference folder. Run one of the export routines to create one.
Returns
kSuccess on success, or kFailure or another ErrorCode value identifying the error.
Postcondition
The application defaults and preferences should be updated.
ErrorCode SnpShareAppResources::ImportToAppWithOptions ()
Temporarily sets IAppPrefsImportOptions and Imports the INX Snippets back into the application.

The IAppPrefsImportOptions interface is used to specify a policy for dealing with matching and 

non-matching existing items in lists.  For example, if you have three Paragraph Styles A,B, and C, 

what happens if you import Paragraph Styles B and C.  You could or delete A. And, you could keep 

or replace B and C.

Precondition
A valid INX snippet named SnpShareAppResources.xml should exist in the users preference folder. Run one of the export routines to create one.
Returns
kSuccess on success, or kFailure or another ErrorCode value identifying the error.
Postcondition
The application defaults and preferences should be updated.