InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
CXMLImportOptionsService.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Ryan Gano
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //========================================================================================
23 
24 #include "IXMLImportOptionsService.h"
25 
26 #include "K2Pair.h"
27 #include "K2Vector.tpp"
28 
34 
39 
40 //----------------------------------------------------------------------------------------
41 // XMLImportOptionsDefaultServiceProvider
42 //----------------------------------------------------------------------------------------
43 class CXMLImportOptionsServiceProvider : public CPMUnknown<IXMLImportOptionsService>
44 {
45 public:
47 
48  // Use this to set each piece of data listed below
49  virtual void Initialize(IDocument *doc);
50  virtual K2Vector<int32> WarnOfChange(IXMLImportOptionsService *changedService, IControlView *controlView, int32 which);
51  virtual void CommitChanges();
52 
53  virtual PMString GetGroupName() const {return fGroupName;}
54  virtual int32 GetUIElementsCount() const {return fUIElementCount;}
55  virtual bool16 IsNthElementEnabled(int32 n) const {return fStoredEnableState[n];}
56  virtual IXMLImportOptionsService::kUIElementType GetNthElementType(int32 n) const {return static_cast<IXMLImportOptionsService::kUIElementType>(fStoredType[n]);}
57  virtual PMString GetNthElementName(int32 n) const {return fElementName[n];}
58 
59  // Used for getting/setting the stored bool value (checkbox)
60  virtual bool16 GetNthElementBoolValue(int32 n) const {return fStoredValue[n].second;}
61  virtual void SetNthElementBoolValue(int32 n, bool16 newValue) {fStoredValue[n].second = newValue;}
62 
63  // Used for getting/setting the stored int value (popup or radio group)
64  virtual int32 GetNthElementIntValue(int32 n) const {return fStoredValue[n].first;}
65  virtual void SetNthElementIntValue(int32 n, int32 selected) {fStoredValue[n].first = selected;}
66 
67  // Used for getting/setting the filename (filename group)
68  virtual IDFile GetNthElementFileName(int32 n) const {return fStoredFileName[n];}
69  virtual void SetNthElementFileName(int32 n, IDFile fileName) {fStoredFileName[n] = fileName;}
70 
71  // Used for getting the default text (filename group)
72  virtual PMString GetNthElementDefaultText(int32 n) const {return fStoredDefaultText[n];}
73 
74  virtual void GetNthFileTypeInfo(int32 n, PMString &typeName, PMString &extension) const
75  {
76  typeName = fStoredFileType[n].first;
77  extension = fStoredFileType[n].second;
78  }
79 
80  // Used to determine whether the control should be indented
81  virtual bool16 ShouldIndentNthControl(int32 n) const {return fIndented[n];}
82 
83  // Used for only the popup
84  virtual void GetNthElementPopupValueList(int32 n, K2Vector<PMString> &valueList) const {valueList = fValueList[n];}
85 
86 protected:
87  // Use the following methods to quickly add new UI elements or to clear the list of known elements
88  void AddCheckbox(const PMString &name, bool16 enabled, bool16 state, bool16 indent = kFalse);
89  void AddPopup(const PMString &name, const K2Vector<PMString> &values, bool16 enabled, int32 selection, bool16 indent = kFalse);
90  void AddRadioGroup(const PMString &name, const K2Vector<PMString> &values, bool16 enabled, int32 selection, bool16 indent = kFalse);
91  void AddFileName(const PMString name, const IDFile &fileName, const PMString &defaultText, const PMString &fileTypeFamily, const PMString &fileTypeExtension, bool16 enabled, bool16 state, bool16 indent);
92  void ClearData();
93 
94  // These store the state information for each of the controls this service is in charge of
95  // These values can be changed while the dialog is running
96  mutable K2Vector<StoredValuePair> fStoredValue; // Store the current value or selected state
97  K2Vector<bool16> fStoredEnableState; // Store whether this element is currently enabled or not
98  K2Vector<IDFile> fStoredFileName; // Store the fiilename information for each object
99  K2Vector<PMString> fStoredDefaultText; // Store the default text information for each object
100  K2Vector<FileTypeData> fStoredFileType; // Store the filetype information for files
101 
102  // These values cannot be changed while the dialog is running
103  K2Vector<int32> fStoredType; // Store what type of element this is
104  PMString fGroupName; // Store the name of the group this service represents
105  int32 fUIElementCount; // Store the number of elements in this group
106  K2Vector<PMString> fElementName; // Store the name of each element
107  K2Vector<K2Vector<PMString> > fValueList; // Store the value list for popups and radio buttons
108  K2Vector<bool16> fIndented; // Store whether or not this control should be indented
109 
110 private:
111  int32 AddDefaultElement(IXMLImportOptionsService::kUIElementType type, bool16 enabled, bool16 indent);
112 };