• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

fl_AutoNum.h

Go to the documentation of this file.
00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */
00002 /* AbiWord
00003  * Copyright (C) 1998,1999 AbiSource, Inc.
00004  * BIDI Copyright (c) 2001,2002 Tomas Frydrych, Yaacov Akiba Slama
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00019  * 02111-1307, USA.
00020  */
00021 
00022 #ifndef FL_AUTONUM_H
00023 #define FL_AUTONUM_H
00024 
00025 #include <string>
00026 
00027 #include "ut_types.h"
00028 #include "ut_misc.h"
00029 #include "ut_vector.h"
00030 #include "pt_Types.h"
00031 #include "fl_AutoLists.h"
00032 
00033 #if defined(__MINGW32__)
00034 #undef snprintf
00035 #define _GLIBCXX_USE_C99_DYNAMIC 1
00036 #endif
00037 
00038 #include <vector>
00039 
00040 // fwd. decl.
00041 class fl_BlockLayout;
00042 class fl_Layout;
00043 class pf_Frag_Strux;
00044 class PD_Document;
00045 class FV_View;
00046 class UT_UTF8String;
00047 
00048 class ABI_EXPORT fl_AutoNum
00049 {
00050 public:
00051     fl_AutoNum( UT_uint32 id,
00052                 UT_uint32 start,
00053                 pf_Frag_Strux* pItem,
00054                 fl_AutoNum * pParent,
00055                 const gchar * lDelim,
00056                 const gchar * lDecimal,
00057                 FL_ListType lType,
00058                 PD_Document * pDoc,
00059                 FV_View * pView);
00060 
00061     fl_AutoNum( UT_uint32 id,
00062                 UT_uint32 parent_id,
00063                 FL_ListType lType,
00064                 UT_uint32 start,
00065                 const gchar * lDelim,
00066                 const gchar * lDecimal,
00067                 PD_Document * pDoc,
00068                 FV_View * pView);
00069 
00070     ~fl_AutoNum();
00071 
00072     void                        fixHierarchy(void);
00073 
00074     const UT_UCSChar *          getLabel(pf_Frag_Strux*) const;
00075     void                        addItem(pf_Frag_Strux* pItem);
00076     FL_ListType                 getType() const;
00077     UT_uint32                   getValue(pf_Frag_Strux*) const;
00078     UT_uint32                   getLevel() const { return m_iLevel; }
00079     UT_uint32                   getNumLabels() const;
00080     bool                        checkReference(fl_AutoNum * pAuto);
00081 
00082     void                        setLevel(UT_uint32 level) { m_iLevel = level; }
00083     UT_sint32                   getPositionInList( pf_Frag_Strux* pItem, UT_uint32 depth) const;
00084     void                        setListType(FL_ListType lType);
00085     void                        setDelim(const gchar * pszDelim);
00086     void                        setDelim(const std::string & delim)
00087     {
00088         setDelim(delim.c_str());
00089     }
00090     const gchar *           getDelim() const;
00091     void                        setDecimal(const gchar * pszDecimal);
00092     void                        setDecimal(const std::string & decimal)
00093     {
00094         setDecimal(decimal.c_str());
00095     }
00096     const gchar *           getDecimal() const;
00097     bool                        isDirty() const;
00098     UT_uint16                   getStartValue() const { return m_iStartValue; }
00099 
00100     UT_uint32                   getStartValue32() const;
00101     void                        setStartValue(UT_uint32 start);
00102 
00103     void                        insertFirstItem(pf_Frag_Strux* pItem,
00104                                                 pf_Frag_Strux* pLast,
00105                                                 UT_uint32 depth,
00106                                                 bool bDoFix=true);
00107     void                        insertItem(pf_Frag_Strux* pItem, pf_Frag_Strux* pBefore, bool bDoFix = true);
00108     void                        prependItem(pf_Frag_Strux* pItem, pf_Frag_Strux* pAfter, bool bDoFix = true);
00109     void                        removeItem(pf_Frag_Strux* pItem);
00110     pf_Frag_Strux*          getParentItem() const;
00111     void                        setParentItem(pf_Frag_Strux* pItem);
00112     bool                                 isContainedByList(pf_Frag_Strux* pItem) const;
00113     pf_Frag_Strux*          getNthBlock(UT_sint32 i) const;
00114     pf_Frag_Strux*          getPrevInList(pf_Frag_Strux* pItem) const;
00115 
00116     bool                    isItem(pf_Frag_Strux* pItem) const;
00117     bool                        doesItemHaveLabel(fl_BlockLayout * pItem) const;
00118     bool                    isEmpty(void) const;
00119     pf_Frag_Strux*          getFirstItem(void) const;
00120     pf_Frag_Strux*          getLastItem(void) const;
00121     bool                        isLastOnLevel(pf_Frag_Strux* pItem) const;
00122 
00123     fl_AutoNum *                getParent(void) const { return m_pParent; }
00124     fl_AutoNum *                getActiveParent(void) const;
00125     fl_AutoNum *                getAutoNumFromSdh(pf_Frag_Strux* sdh);
00126     const fl_AutoNum *          getAutoNumFromSdh(pf_Frag_Strux* sdh) const;
00127     void                        fixListOrder(void);
00128     void                        markAsDirty(void);
00129     void                        findAndSetParentItem(void);
00130     void                        setAsciiOffset(UT_uint32 new_asciioffset);
00131 
00132     void                        update(UT_uint32 start);
00133     bool                        isUpdating(void) const { return m_bUpdatingItems; }
00134     UT_uint32                   getID() const { return m_iID; }
00135     UT_uint32                   getParentID() const { return m_iParentID; }
00136     bool                        isIDSomeWhere(UT_uint32 ID) const;
00137     static char *               dec2roman(UT_sint32 value, bool lower);
00138     static char *               dec2ascii(UT_sint32 value, UT_uint32 offset);
00139     static void                 dec2hebrew(UT_UCSChar labelStr[], UT_uint32 * insPoint, UT_sint32 value);
00140     void                        getAttributes(std::vector<UT_UTF8String>&v,
00141                                               bool bEscapeXML) const;
00142     PD_Document *               getDoc(void) const
00143     {return m_pDoc;}
00144     pf_Frag_Strux*           getLastItemInHeiracy(void) const;
00145 protected:
00146     void                        _setParent(fl_AutoNum * pParent);
00147     void                        _setParentID(UT_uint32 iParentID);
00148     void                        _calculateLabelStr(UT_uint32 depth);
00149     void                        _getLabelstr(   UT_UCSChar labelStr[],
00150                                                 UT_uint32 * insPoint,
00151                                                 UT_uint32 depth,
00152                                                 pf_Frag_Strux* pLayout) const;
00153     bool                        _updateItems(UT_sint32 start, pf_Frag_Strux* notMe );
00154     UT_uint32                   _getLevelValue(fl_AutoNum * pAutoNum) const;
00155 
00156     fl_AutoNum *                m_pParent;
00157 
00158     UT_GenericVector<pf_Frag_Strux*> m_pItems;
00159     PD_Document *               m_pDoc;
00160     FV_View *                   m_pView;
00161     FL_ListType                 m_List_Type;
00162     UT_uint32                   m_iID;
00163     UT_uint32                   m_iParentID;
00164     UT_uint32                   m_iLevel;
00165     UT_uint32                   m_iStartValue;
00166     UT_uint16                   m_iAsciiOffset;
00167     bool                        m_bUpdatingItems;
00168     bool                        m_bDirty;
00169     UT_sint32                   m_ioffset;
00170     gchar                   m_pszDecimal[80]; // BAD BAD HARDCODED ARRAY LENGTHS
00171     gchar                   m_pszDelim[80];
00172     gchar                   m_pszIndent[80];
00173     bool                        m_bWordMultiStyle;
00174     pf_Frag_Strux*          m_pParentItem;
00175 };
00176 
00177 #endif

Generated on Sun May 27 2012 for AbiWord by  doxygen 1.7.1