WPSParagraph.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_PARAGRAPH
00027 #  define WPS_PARAGRAPH
00028 
00029 #include <iostream>
00030 
00031 #include <vector>
00032 
00033 #include "libwps_internal.h"
00034 
00035 #include "WPSList.h"
00036 
00037 struct WPSTabStop
00038 {
00039         enum Alignment { LEFT, RIGHT, CENTER, DECIMAL, BAR };
00040         WPSTabStop(double position = 0.0, Alignment alignment = LEFT, uint16_t leaderCharacter='\0', uint8_t leaderNumSpaces = 0)  :
00041                 m_position(position), m_alignment(alignment), m_leaderCharacter(leaderCharacter), m_leaderNumSpaces(leaderNumSpaces)
00042         {
00043         }
00044         void addTo(librevenge::RVNGPropertyListVector &propList, double decalX=0.0) const;
00046         friend std::ostream &operator<<(std::ostream &o, WPSTabStop const &ft);
00047         double m_position;
00048         Alignment m_alignment;
00049         uint16_t m_leaderCharacter;
00050         uint8_t m_leaderNumSpaces;
00051 };
00052 
00054 struct WPSParagraph
00055 {
00056         typedef WPSList::Level ListLevel;
00058         enum LineSpacingType { Fixed, AtLeast };
00059 
00061         WPSParagraph() : m_spacingsInterlineUnit(librevenge::RVNG_PERCENT), m_spacingsInterlineType(Fixed), m_tabs(), m_justify(libwps::JustificationLeft),
00062                 m_breakStatus(0), m_listLevelIndex(0), m_listLevel(), m_backgroundColor(WPSColor::white()),
00063                 m_border(0), m_borderStyle(), m_extra("")
00064         {
00065                 for (int i = 0; i < 3; i++) m_margins[i] = m_spacings[i] = 0.0;
00066                 m_spacings[0] = 1.0; // interline normal
00067         }
00068         // destructor
00069         virtual ~WPSParagraph() {}
00071         void addTo(librevenge::RVNGPropertyList &propList, bool inTable) const;
00073         void setInterline(double value, librevenge::RVNGUnit unit, LineSpacingType type=Fixed)
00074         {
00075                 m_spacings[0]=value;
00076                 m_spacingsInterlineUnit=unit;
00077                 m_spacingsInterlineType=type;
00078         }
00080         friend std::ostream &operator<<(std::ostream &o, WPSParagraph const &ft);
00081 
00087         double m_margins[3]; // 0: first line left, 1: left, 2: right
00093         double m_spacings[3]; // 0: interline, 1: before, 2: after
00095         librevenge::RVNGUnit m_spacingsInterlineUnit;
00097         LineSpacingType m_spacingsInterlineType;
00099         std::vector<WPSTabStop> m_tabs;
00100 
00102         libwps::Justification m_justify;
00104         int m_breakStatus; // BITS: 1: unbreakable, 2: dont break after
00105 
00107         int m_listLevelIndex;
00109         ListLevel m_listLevel;
00110 
00112         WPSColor m_backgroundColor;
00113 
00115         int m_border;
00117         WPSBorder m_borderStyle;
00118 
00120         std::string m_extra;
00121 };
00122 #endif
00123 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */