MWAWParagraph.hxx
Go to the documentation of this file.
00001 /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
00002 
00003 /* libmwaw
00004 * Version: MPL 2.0 / LGPLv2+
00005 *
00006 * The contents of this file are subject to the Mozilla Public License Version
00007 * 2.0 (the "License"); you may not use this file except in compliance with
00008 * the License or as specified alternatively below. You may obtain a copy of
00009 * the License at http://www.mozilla.org/MPL/
00010 *
00011 * Software distributed under the License is distributed on an "AS IS" basis,
00012 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013 * for the specific language governing rights and limitations under the
00014 * License.
00015 *
00016 * Major Contributor(s):
00017 * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
00018 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
00019 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
00020 * Copyright (C) 2006, 2007 Andrew Ziem
00021 * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
00022 *
00023 *
00024 * All Rights Reserved.
00025 *
00026 * For minor contributions see the git repository.
00027 *
00028 * Alternatively, the contents of this file may be used under the terms of
00029 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
00030 * in which case the provisions of the LGPLv2+ are applicable
00031 * instead of those above.
00032 */
00033 
00034 #ifndef MWAW_PARAGRAPH
00035 #  define MWAW_PARAGRAPH
00036 
00037 #include <assert.h>
00038 #include <iostream>
00039 #include <vector>
00040 
00041 #include <librevenge/librevenge.h>
00042 
00043 #include "libmwaw_internal.hxx"
00044 #include "MWAWList.hxx"
00045 
00047 struct MWAWTabStop {
00049   enum Alignment { LEFT, RIGHT, CENTER, DECIMAL, BAR };
00051   MWAWTabStop(double position = 0.0, Alignment alignment = LEFT, uint16_t leaderCharacter='\0', uint16_t decimalCharacter = '.')  :
00052     m_position(position), m_alignment(alignment), m_leaderCharacter(leaderCharacter), m_decimalCharacter(decimalCharacter)
00053   {
00054   }
00056   void addTo(librevenge::RVNGPropertyListVector &propList, double decalX=0.0) const;
00058   bool operator==(MWAWTabStop const &tabs) const
00059   {
00060     return cmp(tabs)==0;
00061   }
00063   bool operator!=(MWAWTabStop const &tabs) const
00064   {
00065     return cmp(tabs)!=0;
00066   }
00068   friend std::ostream &operator<<(std::ostream &o, MWAWTabStop const &ft);
00070   int cmp(MWAWTabStop const &tabs) const;
00072   double m_position;
00074   Alignment m_alignment;
00076   uint16_t m_leaderCharacter;
00078   uint16_t m_decimalCharacter;
00079 };
00080 
00082 class MWAWParagraph
00083 {
00084 public:
00086   enum { NoBreakBit = 0x1, NoBreakWithNextBit=0x2 };
00088   enum Justification { JustificationLeft, JustificationFull, JustificationCenter,
00089                        JustificationRight, JustificationFullAllLines
00090                      };
00092   enum LineSpacingType { Fixed, AtLeast};
00093 
00095   MWAWParagraph();
00097   virtual ~MWAWParagraph();
00099   bool operator==(MWAWParagraph const &p) const
00100   {
00101     return cmp(p)==0;
00102   }
00104   bool operator!=(MWAWParagraph const &p) const
00105   {
00106     return cmp(p)!=0;
00107   }
00109   int cmp(MWAWParagraph const &p) const;
00111   double getMarginsWidth() const;
00113   bool hasBorders() const;
00115   bool hasDifferentBorders() const;
00117   void resizeBorders(size_t newSize)
00118   {
00119     MWAWBorder empty;
00120     empty.m_style=MWAWBorder::None;
00121     m_borders.resize(newSize, empty);
00122   }
00124   void setInterline(double value, librevenge::RVNGUnit unit, LineSpacingType type=Fixed)
00125   {
00126     m_spacings[0]=value;
00127     m_spacingsInterlineUnit=unit;
00128     m_spacingsInterlineType=type;
00129   }
00131   void addTo(librevenge::RVNGPropertyList &propList, bool inTable) const;
00132 
00134   void insert(MWAWParagraph const &para);
00136   friend std::ostream &operator<<(std::ostream &o, MWAWParagraph const &ft);
00137 
00143   MWAWVariable<double> m_margins[3]; // 0: first line left, 1: left, 2: right
00145   MWAWVariable<librevenge::RVNGUnit> m_marginsUnit;
00151   MWAWVariable<double> m_spacings[3]; // 0: interline, 1: before, 2: after
00153   MWAWVariable<librevenge::RVNGUnit> m_spacingsInterlineUnit;
00155   MWAWVariable<LineSpacingType> m_spacingsInterlineType;
00157   MWAWVariable<std::vector<MWAWTabStop> > m_tabs;
00159   MWAWVariable<bool> m_tabsRelativeToLeftMargin;
00160 
00162   MWAWVariable<Justification> m_justify;
00164   MWAWVariable<int> m_breakStatus; // BITS: 1: unbreakable, 2: dont break after
00165 
00167   MWAWVariable<int> m_listLevelIndex;
00169   MWAWVariable<int> m_listId;
00171   MWAWVariable<int> m_listStartValue;
00173   MWAWVariable<MWAWListLevel> m_listLevel;
00174 
00176   MWAWVariable<MWAWColor> m_backgroundColor;
00177 
00179   std::vector<MWAWVariable<MWAWBorder> > m_borders;
00180 
00182   std::string m_styleName;
00184   std::string m_extra;
00185 };
00186 #endif
00187 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: