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  * Copyright (C) 2009, 2011 Alonso Laurent (alonso@loria.fr)
00004  * Copyright (C) 2006, 2007 Andrew Ziem
00005  * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
00006  * Copyright (C) 2004 Marc Maurer (uwog@uwog.net)
00007  * Copyright (C) 2003-2005 William Lachance (william.lachance@sympatico.ca)
00008  *
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Library General Public
00011  * License as published by the Free Software Foundation; either
00012  * version 2 of the License, or (at your option) any later version.
00013  *
00014  * This library is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017  * Library General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU Library General Public
00020  * License along with this library; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
00022  *
00023  * For further information visit http://libwps.sourceforge.net
00024  */
00025 
00026 /* "This product is not manufactured, approved, or supported by
00027  * Corel Corporation or Corel Corporation Limited."
00028  */
00029 
00030 #ifndef WPS_LIST_H
00031 #  define WPS_LIST_H
00032 
00033 #include <iostream>
00034 #include <vector>
00035 
00036 #include <libwpd/WPXString.h>
00037 #include <libwps_internal.h>
00038 
00039 class WPXPropertyList;
00040 class WPXDocumentInterface;
00041 
00043 class WPSList
00044 {
00045 public:
00047         struct Level
00048         {
00049 
00051                 Level() : m_labelIndent(0.0), m_labelWidth(0.0), m_startValue(0), m_type(libwps::NONE),
00052                         m_prefix(""), m_suffix(""), m_bullet(""), m_sendToInterface(false) { }
00053 
00055                 bool isDefault() const
00056                 {
00057                         return m_type ==libwps::NONE;
00058                 }
00060                 bool isNumeric() const
00061                 {
00062                         return m_type !=libwps::NONE && m_type != libwps::BULLET;
00063                 }
00065                 void addTo(WPXPropertyList &propList, int startVal) const;
00066 
00068                 bool isSendToInterface() const
00069                 {
00070                         return m_sendToInterface;
00071                 }
00073                 void resetSendToInterface() const
00074                 {
00075                         m_sendToInterface = false;
00076                 }
00077 
00079                 int getStartValue() const
00080                 {
00081                         return m_startValue <= 0 ? 1 : m_startValue;
00082                 }
00083 
00085                 int cmp(Level const &levl) const;
00086 
00088                 friend std::ostream &operator<<(std::ostream &o, Level const &ft);
00089 
00090                 double m_labelIndent ;
00091                 double m_labelWidth ;
00093                 int m_startValue;
00095                 libwps::NumberingType m_type;
00096                 WPXString m_prefix ,
00097                           m_suffix,
00098                           m_bullet ;
00099 
00100         protected:
00102                 mutable bool m_sendToInterface;
00103         };
00104 
00106         WPSList() : m_levels(), m_actLevel(-1), m_actualIndices(), m_nextIndices(),
00107                 m_id(-1), m_previousId (-1) {}
00108 
00110         int getId() const
00111         {
00112                 return m_id;
00113         }
00114 
00119         int getPreviousId() const
00120         {
00121                 return m_previousId;
00122         }
00123 
00125         void setId(int newId);
00126 
00128         int numLevels() const
00129         {
00130                 return m_levels.size();
00131         }
00133         void set(int levl, Level const &level);
00134 
00136         void setLevel(int levl) const;
00138         void openElement() const;
00140         void closeElement() const {}
00141 
00143         bool isNumeric(int levl) const;
00144 
00146         bool mustSendLevel(int level) const;
00147 
00149         void sendTo(WPXDocumentInterface &docInterface, int level) const;
00150 
00151 protected:
00152         std::vector<Level> m_levels;
00153 
00154         mutable int m_actLevel;
00155         mutable std::vector<int> m_actualIndices, m_nextIndices;
00156         mutable int m_id, m_previousId;
00157 };
00158 
00159 #endif
00160 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */