1 /* AbiWord
2  * Copyright (C) 2000 AbiSource, Inc.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301 USA.
18  */
19 #ifndef FIELD_H
20 #define FIELD_H
21 
22 #include "ut_types.h"
23 #include "ut_xml.h"
24 #include "pf_Frag_Object.h"
25 #include "pf_Frag_Text.h"
26 #include "pt_Types.h"
27 
28 class fl_BlockLayout;
29 class pf_Frag_Object;
30 
31 /*!
32  \note This class will eventually have subclasses to implement the different
33  types of fields.
34 */
35 
36 class ABI_EXPORT fd_Field
37 {
38  public:
39     // TBD: convention for naming
40     typedef enum _FieldType
41 	{
42 	        FD_None,
43 		FD_Test,
44 		FD_MartinTest,
45 		FD_Time,
46 		FD_PageNumber,
47 		FD_PageCount,
48 		FD_ListLabel,
49 		FD_FileName,
50 		FD_Date,
51 
52 		FD_Date_MMDDYY,
53 		FD_Date_DDMMYY,
54 		FD_Date_MDY,
55 		FD_Date_MthDY,
56 		FD_Date_DFL,
57 		FD_Date_NTDFL,
58 		FD_Date_Wkday,
59 		FD_Date_DOY,
60 
61 		FD_Time_MilTime,
62 		FD_Time_AMPM,
63 		FD_Time_Zone,
64 		FD_Time_Epoch,
65 
66 		FD_Table_sum_rows,
67 		FD_Table_sum_cols,
68 
69 		FD_DateTime_Custom,
70 
71 		FD_Doc_WordCount,
72 		FD_Doc_CharCount,
73 		FD_Doc_LineCount,
74 		FD_Doc_ParaCount,
75 		FD_Doc_NbspCount,
76 
77 		FD_App_Version,
78 		FD_App_ID,
79 		FD_App_Options,
80 		FD_App_Target,
81 		FD_App_CompileTime,
82 		FD_App_CompileDate,
83 
84 		FD_Endnote_Ref,
85 		FD_Endnote_Anchor,
86 
87 		FD_Footnote_Ref,
88 		FD_Footnote_Anchor,
89 
90 		FD_PageReference,
91 		FD_MailMerge,
92 
93 		FD_Meta_Title,
94 		FD_Meta_Creator,
95 		FD_Meta_Subject,
96 		FD_Meta_Publisher,
97 		FD_Meta_Date,
98                 FD_Meta_Date_Last_Changed,
99 		FD_Meta_Type,
100 		FD_Meta_Language,
101 		FD_Meta_Rights,
102 		FD_Meta_Keywords,
103 		FD_Meta_Contributor,
104 		FD_Meta_Coverage,
105 		FD_Meta_Description,
106 
107 		__last_field_dont_use__
108 	} FieldType;
109     fd_Field(pf_Frag_Object& fO, pt_PieceTable * pt, FieldType fieldType, const gchar *pParam);
110     virtual							~fd_Field(void);
111     bool							update(void);
112     void							setBlock(fl_BlockLayout * pBlock);
113     fl_BlockLayout *				getBlock( void) const;
114 	FieldType						getFieldType(void) const;
115 	gchar *						getValue(void) const;
116 	void							setValue(const gchar * szValue);
getParameter(void)117 	const gchar * 				getParameter(void) const {return static_cast<const gchar *>(m_pParameter);};
118     // probably need different types of update
119     // which are overridden in the appropriate subclass
120     // eg positionChangeUpdate
121     //    referenceChangeUpdate
122  protected:
123     bool							_deleteSpan(void);
124     void							_throwChangeRec(PT_DocPosition docPos);
125     fl_BlockLayout * m_pBlock;
126     // will need some more helper functions in here eg. to test
127     // whether text has changed to avoid unnecessary updates
128  private:
129     pf_Frag_Object& m_fragObject;
130     pt_PieceTable *	m_pPieceTable;
131     UT_uint32 m_updateCount;
132     FieldType m_iFieldType;
133 	gchar * m_szValue;
134 	gchar * m_pParameter;
135 };
136 
137 #endif
138 
139 
140 
141 
142