WPSList.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
00002 /* libwps
00003  * Version: MPL 2.0 / LGPLv2.1+
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  *
00009  * Major Contributor(s):
00010  * Copyright (C) 2009, 2011 Alonso Laurent (alonso@loria.fr)
00011  * Copyright (C) 2006, 2007 Andrew Ziem
00012  * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
00013  * Copyright (C) 2004 Marc Maurer (uwog@uwog.net)
00014  * Copyright (C) 2003-2005 William Lachance (william.lachance@sympatico.ca)
00015  *
00016  * For minor contributions see the git repository.
00017  *
00018  * Alternatively, the contents of this file may be used under the terms
00019  * of the GNU Lesser General Public License Version 2.1 or later
00020  * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
00021  * applicable instead of those above.
00022  *
00023  * For further information visit http://libwps.sourceforge.net
00024  */
00025 
00026 #ifndef WPS_LIST_H
00027 #  define WPS_LIST_H
00028 
00029 #include <iostream>
00030 #include <vector>
00031 
00032 #include <librevenge/librevenge.h>
00033 #include "libwps_internal.h"
00034 
00036 class WPSList
00037 {
00038 public:
00040         struct Level
00041         {
00042 
00044                 Level() : m_labelIndent(0.0), m_labelWidth(0.0), m_startValue(-1), m_type(libwps::NONE),
00045                         m_prefix(""), m_suffix(""), m_bullet(""), m_sendToInterface(false) { }
00046 
00048                 bool isDefault() const
00049                 {
00050                         return m_type ==libwps::NONE;
00051                 }
00053                 bool isNumeric() const
00054                 {
00055                         return m_type !=libwps::NONE && m_type != libwps::BULLET;
00056                 }
00058                 void addTo(librevenge::RVNGPropertyList &propList, int startVal) const;
00059 
00061                 bool isSendToInterface() const
00062                 {
00063                         return m_sendToInterface;
00064                 }
00066                 void resetSendToInterface() const
00067                 {
00068                         m_sendToInterface = false;
00069                 }
00070 
00072                 int getStartValue() const
00073                 {
00074                         return m_startValue <= -1 ? 1 : m_startValue;
00075                 }
00076 
00078                 int cmp(Level const &levl) const;
00079 
00081                 int cmpType(Level const &levl) const;
00082 
00084                 friend std::ostream &operator<<(std::ostream &o, Level const &ft);
00085 
00086                 double m_labelIndent ;
00087                 double m_labelWidth ;
00089                 int m_startValue;
00091                 libwps::NumberingType m_type;
00092                 librevenge::RVNGString m_prefix ,
00093                            m_suffix,
00094                            m_bullet ;
00095 
00096         protected:
00098                 mutable bool m_sendToInterface;
00099         };
00100 
00102         WPSList() : m_levels(), m_actLevel(-1), m_actualIndices(), m_nextIndices(),
00103                 m_id(-1), m_previousId(-1) {}
00104 
00106         int getId() const
00107         {
00108                 return m_id;
00109         }
00110 
00115         int getPreviousId() const
00116         {
00117                 return m_previousId;
00118         }
00119 
00121         void setId(int newId);
00122 
00124         int numLevels() const
00125         {
00126                 return int(m_levels.size());
00127         }
00129         void set(int levl, Level const &level);
00130 
00132         void setLevel(int levl) const;
00134         void openElement() const;
00136         void closeElement() const {}
00137 
00139         bool isNumeric(int levl) const;
00140 
00142         bool mustSendLevel(int level) const;
00143 
00145         void addLevelTo(int level, librevenge::RVNGPropertyList &propList) const;
00146 
00147 protected:
00148         std::vector<Level> m_levels;
00149 
00150         mutable int m_actLevel;
00151         mutable std::vector<int> m_actualIndices, m_nextIndices;
00152         mutable int m_id, m_previousId;
00153 };
00154 
00155 #endif
00156 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */