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 <libwpd/libwpd.h>
00042 
00043 #include "libmwaw_internal.hxx"
00044 #include "MWAWList.hxx"
00045 
00046 class WPXPropertyList;
00047 class WPXPropertyListVector;
00048 
00050 struct MWAWTabStop {
00052   enum Alignment { LEFT, RIGHT, CENTER, DECIMAL, BAR };
00054   MWAWTabStop(double position = 0.0, Alignment alignment = LEFT, uint16_t leaderCharacter='\0', uint16_t decimalCharacter = '.')  :
00055     m_position(position), m_alignment(alignment), m_leaderCharacter(leaderCharacter), m_decimalCharacter(decimalCharacter) {
00056   }
00058   void addTo(WPXPropertyListVector &propList, double decalX=0.0) const;
00060   bool operator==(MWAWTabStop const &tabs) const {
00061     return cmp(tabs)==0;
00062   }
00064   bool operator!=(MWAWTabStop const &tabs) const {
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     return cmp(p)==0;
00101   }
00103   bool operator!=(MWAWParagraph const &p) const {
00104     return cmp(p)!=0;
00105   }
00107   int cmp(MWAWParagraph const &p) const;
00109   double getMarginsWidth() const;
00111   bool hasBorders() const;
00113   bool hasDifferentBorders() const;
00115   void resizeBorders(size_t newSize) {
00116     MWAWBorder empty;
00117     empty.m_style=MWAWBorder::None;
00118     m_borders.resize(newSize, empty);
00119   }
00121   void setInterline(double value, WPXUnit unit, LineSpacingType type=Fixed) {
00122     m_spacings[0]=value;
00123     m_spacingsInterlineUnit=unit;
00124     m_spacingsInterlineType=type;
00125   }
00127   void addTo(WPXPropertyList &propList, bool inTable) const;
00129   void addTabsTo(WPXPropertyListVector &propList, double decalX=0.0) const;
00130 
00132   void insert(MWAWParagraph const &para);
00134   friend std::ostream &operator<<(std::ostream &o, MWAWParagraph const &ft);
00135 
00141   Variable<double> m_margins[3]; // 0: first line left, 1: left, 2: right
00143   Variable<WPXUnit> m_marginsUnit;
00149   Variable<double> m_spacings[3]; // 0: interline, 1: before, 2: after
00151   Variable<WPXUnit> m_spacingsInterlineUnit;
00153   Variable<LineSpacingType> m_spacingsInterlineType;
00155   Variable<std::vector<MWAWTabStop> > m_tabs;
00157   Variable<bool> m_tabsRelativeToLeftMargin;
00158 
00160   Variable<Justification> m_justify;
00162   Variable<int> m_breakStatus; // BITS: 1: unbreakable, 2: dont break after
00163 
00165   Variable<int> m_listLevelIndex;
00167   Variable<int> m_listId;
00169   Variable<int> m_listStartValue;
00171   Variable<MWAWListLevel> m_listLevel;
00172 
00174   Variable<MWAWColor> m_backgroundColor;
00175 
00177   std::vector<Variable<MWAWBorder> > m_borders;
00178 
00180   std::string m_extra;
00181 };
00182 #endif
00183 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: