00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef FL_AUTONUM_H
00023 #define FL_AUTONUM_H
00024
00025 #include "ut_types.h"
00026 #include "ut_misc.h"
00027 #include "ut_vector.h"
00028 #include "pt_Types.h"
00029 #include "fl_AutoLists.h"
00030
00031 #if defined(__MINGW32__)
00032 #undef snprintf
00033 #define _GLIBCXX_USE_C99_DYNAMIC 1
00034 #endif
00035
00036 #include <vector>
00037
00038
00039 class fl_BlockLayout;
00040 class fl_Layout;
00041 class PD_Document;
00042 class FV_View;
00043 class UT_UTF8String;
00044
00045 class ABI_EXPORT fl_AutoNum
00046 {
00047 public:
00048 fl_AutoNum( UT_uint32 id,
00049 UT_uint32 start,
00050 PL_StruxDocHandle pItem,
00051 fl_AutoNum * pParent,
00052 const gchar * lDelim,
00053 const gchar * lDecimal,
00054 FL_ListType lType,
00055 PD_Document * pDoc,
00056 FV_View * pView);
00057
00058 fl_AutoNum( UT_uint32 id,
00059 UT_uint32 parent_id,
00060 FL_ListType lType,
00061 UT_uint32 start,
00062 const gchar * lDelim,
00063 const gchar * lDecimal,
00064 PD_Document * pDoc,
00065 FV_View * pView);
00066
00067 ~fl_AutoNum();
00068
00069 void fixHierarchy(void);
00070
00071 const UT_UCSChar * getLabel(PL_StruxDocHandle) const;
00072 void addItem(PL_StruxDocHandle pItem);
00073 FL_ListType getType() const;
00074 UT_uint32 getValue(PL_StruxDocHandle) const;
00075 UT_uint32 getLevel() const { return m_iLevel; }
00076 UT_uint32 getNumLabels() const;
00077 bool checkReference(fl_AutoNum * pAuto);
00078
00079 void setLevel(UT_uint32 level) { m_iLevel = level; }
00080 UT_sint32 getPositionInList( PL_StruxDocHandle pItem, UT_uint32 depth) const;
00081 void setListType(FL_ListType lType);
00082 void setDelim(const gchar * pszDelim);
00083 const gchar * getDelim() const;
00084 void setDecimal(const gchar * pszDecimal);
00085 const gchar * getDecimal() const;
00086 bool isDirty() const;
00087 UT_uint16 getStartValue() const { return m_iStartValue; }
00088
00089 UT_uint32 getStartValue32() const;
00090 void setStartValue(UT_uint32 start);
00091
00092 void insertFirstItem(PL_StruxDocHandle pItem,
00093 PL_StruxDocHandle pLast,
00094 UT_uint32 depth,
00095 bool bDoFix=true);
00096 void insertItem(PL_StruxDocHandle pItem, PL_StruxDocHandle pBefore, bool bDoFix = true);
00097 void prependItem(PL_StruxDocHandle pItem, PL_StruxDocHandle pAfter, bool bDoFix = true);
00098 void removeItem(PL_StruxDocHandle pItem);
00099 PL_StruxDocHandle getParentItem() const;
00100 void setParentItem(PL_StruxDocHandle pItem);
00101 bool isContainedByList(PL_StruxDocHandle pItem);
00102 PL_StruxDocHandle getNthBlock(UT_uint32 i);
00103 PL_StruxDocHandle getPrevInList(PL_StruxDocHandle pItem);
00104
00105 bool isItem(PL_StruxDocHandle pItem) const;
00106 bool doesItemHaveLabel(fl_BlockLayout * pItem);
00107 bool isEmpty(void);
00108 PL_StruxDocHandle getFirstItem(void) const;
00109 PL_StruxDocHandle getLastItem(void);
00110 bool isLastOnLevel(PL_StruxDocHandle pItem);
00111
00112 fl_AutoNum * getParent(void) const { return m_pParent; }
00113 fl_AutoNum * getActiveParent(void);
00114 fl_AutoNum * getAutoNumFromSdh(PL_StruxDocHandle sdh);
00115 const fl_AutoNum * getAutoNumFromSdh(PL_StruxDocHandle sdh) const;
00116 void fixListOrder(void);
00117 void markAsDirty(void);
00118 void findAndSetParentItem(void);
00119 void setAsciiOffset(UT_uint32 new_asciioffset);
00120
00121 void update(UT_uint32 start);
00122 bool isUpdating(void) { return m_bUpdatingItems; }
00123 UT_uint32 getID() const { return m_iID; }
00124 UT_uint32 getParentID() const { return m_iParentID; }
00125 bool isIDSomeWhere(UT_uint32 ID);
00126 static char * dec2roman(UT_sint32 value, bool lower);
00127 static char * dec2ascii(UT_sint32 value, UT_uint32 offset);
00128 static void dec2hebrew(UT_UCSChar labelStr[], UT_uint32 * insPoint, UT_sint32 value);
00129 void getAttributes(std::vector<UT_UTF8String>&v,
00130 bool bEscapeXML);
00131
00132 PL_StruxDocHandle getLastItemInHeiracy(void);
00133 protected:
00134 void _setParent(fl_AutoNum * pParent);
00135 void _setParentID(UT_uint32 iParentID);
00136 void _calculateLabelStr(UT_uint32 depth);
00137 void _getLabelstr( UT_UCSChar labelStr[],
00138 UT_uint32 * insPoint,
00139 UT_uint32 depth,
00140 PL_StruxDocHandle pLayout) const;
00141 void _updateItems(UT_uint32 start, PL_StruxDocHandle notMe );
00142 UT_uint32 _getLevelValue(fl_AutoNum * pAutoNum);
00143
00144 fl_AutoNum * m_pParent;
00145
00146 UT_Vector m_pItems;
00147 PD_Document * m_pDoc;
00148 FV_View * m_pView;
00149 FL_ListType m_List_Type;
00150 UT_uint32 m_iID;
00151 UT_uint32 m_iParentID;
00152 UT_uint32 m_iLevel;
00153 UT_uint32 m_iStartValue;
00154 UT_uint16 m_iAsciiOffset;
00155 bool m_bUpdatingItems;
00156 bool m_bDirty;
00157 UT_sint32 m_ioffset;
00158 gchar m_pszDecimal[80];
00159 gchar m_pszDelim[80];
00160 gchar m_pszIndent[80];
00161 bool m_bWordMultiStyle;
00162 PL_StruxDocHandle m_pParentItem;
00163 };
00164
00165 #endif