1 /************************************************************************/ 2 /* */ 3 /* Fields: parts of the document that are calculated in stead of typed */ 4 /* by the user. */ 5 /* */ 6 /************************************************************************/ 7 8 # ifndef DOC_FIELD_H 9 # define DOC_FIELD_H 10 11 # include <utilMemoryBuffer.h> 12 # include <docDocumentField.h> 13 # include <docEditPosition.h> 14 # include <textAttribute.h> 15 # include <utilPropMask.h> 16 17 struct BufferItem; 18 struct BufferDocument; 19 struct DocumentSelection; 20 struct DocumentPosition; 21 struct RecalculateFields; 22 23 /************************************************************************/ 24 /* */ 25 /* Kind of field. Is an index in a descriptive array of field kinds. */ 26 /* */ 27 /* Fields in the 'Ted' sense are not necessarily fields in the 'Word' */ 28 /* sense. Everything inside the text, that can possibly result in */ 29 /* a piece of document, but is possibly under the control of the */ 30 /* application is a field in the sense of 'Ted'. */ 31 /* */ 32 /* FieldKindInformation: */ 33 /* a) The (case insensitive) string that identifies the field in the */ 34 /* field instructions. NOTE that the notion of a field is abused */ 35 /* by 'Ted' for a few things that are not fields in MS-Word. */ 36 /* b) Some things that are a destination in RTF are stored as a field */ 37 /* in Ted. This is the control word of the destination. */ 38 /* c) The maximum level in the block hierarchy that certainly holds */ 39 /* the result/content of this kind of field. */ 40 /* d) Tells whether this kind of field is a field in the RTF file. */ 41 /* e) Tells whether this kind of field is a destination in the RTF */ 42 /* file. */ 43 /* f1) Recalculate a TEXT level field. */ 44 /* The standard workhorse docRecalculateParaStringTextParticules() */ 45 /* can be used for all substitutions that simply return a string. */ 46 /* In its turn it uses fki->fkiCalculateTextString() to obtain */ 47 /* the string. Other particule avluators might decide to do */ 48 /* something similar. */ 49 /* f2) Recalculate the string for a TEXT level field. */ 50 /* g) When to recalculate fields in the text. */ 51 /* h) Is the field result editable such as with a HYPERLINK or */ 52 /* readonly such as with a PAGEREF? */ 53 /* i) Is a field if this kind constrained to a single paragraph. */ 54 /* */ 55 /************************************************************************/ 56 57 /* f1 */ 58 typedef int (*CALCULATE_TEXT_PARTICULES)( 59 int * pCalculated, 60 int * pPartShift, 61 int * pStroffShift, 62 struct BufferItem * paraBi, 63 int part, 64 int partCount, 65 struct DocumentField * df, 66 const struct RecalculateFields * rf ); 67 68 /* f2 */ 69 typedef int (*CALCULATE_TEXT_STRING)( 70 int * pCalculated, 71 MemoryBuffer * mbResult, 72 const struct DocumentField * df, 73 const struct RecalculateFields * rf ); 74 75 /* g */ 76 # define FIELDdoNOTHING 0 77 # define FIELDdoNEVER 0 78 # define FIELDdoDOC_FORMATTED (1<<0) 79 # define FIELDdoPAGE_NUMBER (1<<1) 80 # define FIELDdoDOC_INFO (1<<2) 81 # define FIELDdoDOC_COMPLETE (1<<3) 82 # define FIELDdoCHFTN (1<<4) 83 # define FIELDdoLISTTEXT (1<<5) 84 # define FIELDdoSEQ (1<<6) 85 # define FIELDdoTOC (1<<7) /* Have their own call */ 86 87 typedef struct FieldKindInformation 88 { 89 const char * fkiLabel; /* a */ 90 int fkiLevel; /* c */ 91 int fkiIsFieldInRtf; /* d */ 92 int fkiIsDestinationInRtf; /* e */ 93 CALCULATE_TEXT_PARTICULES fkiCalculateTextParticules; /* f1 */ 94 CALCULATE_TEXT_STRING fkiCalculateTextString; /* f2 */ 95 unsigned int fkiCalculateWhen; /* g */ 96 unsigned int fkiResultEditable; /* h */ 97 unsigned int fkiSingleParagraph; /* i */ 98 const char * fkiRtfTag; /* b */ 99 } FieldKindInformation; 100 101 /************************************************************************/ 102 /* */ 103 /* Field Kind Information. */ 104 /* */ 105 /************************************************************************/ 106 107 extern const FieldKindInformation DOC_FieldKinds[]; 108 extern const int DOC_FieldKindCount; 109 110 /************************************************************************/ 111 /* */ 112 /* Administrative routines. */ 113 /* */ 114 /************************************************************************/ 115 116 extern int docSuggestNewBookmarkName( 117 MemoryBuffer * markName, 118 const struct BufferDocument * bd, 119 const struct DocumentSelection * ds ); 120 121 extern int docMakeBookmarkUnique( 122 const struct BufferDocument * bd, 123 MemoryBuffer * markName ); 124 125 extern int docFieldKindFromInstructions( const DocumentField * df ); 126 127 extern DocumentField * docFindFieldForPosition( 128 struct BufferDocument * bd, 129 const struct DocumentPosition * dp ); 130 131 extern DocumentField * docFindTypedFieldForPosition( 132 struct BufferDocument * bd, 133 const struct DocumentPosition * dp, 134 int kind, 135 int lastOne ); 136 137 extern DocumentField * docFindTypedFieldInSelection( 138 struct BufferDocument * bd, 139 const struct DocumentSelection * ds, 140 int kind, 141 int lastOne ); 142 143 extern int docSetHyperlinkAttribute( TextAttribute * taSet, 144 PropertyMask * taSetMask, 145 struct BufferDocument * bd ); 146 147 extern int docRemoveHyperlinkAttribute( TextAttribute * taSet, 148 PropertyMask * taSetMask, 149 struct BufferDocument * bd ); 150 151 # endif /* DOC_FIELD_H */ 152