Back to index

scribus-ng  1.3.4.dfsg+svn20071115
paragraphstyle.h
Go to the documentation of this file.
00001 /*
00002  For general Scribus (>=1.3.2) copyright and licensing information please refer
00003  to the COPYING file provided with the program. Following this notice may exist
00004  a copyright and/or license notice that predates the release of Scribus 1.3.2
00005  for which a new license (GPL+exception) is in place.
00006  */
00007 /***************************************************************************
00008 *                                                                         *
00009 *   This program is free software; you can redistribute it and/or modify  *
00010 *   it under the terms of the GNU General Public License as published by  *
00011 *   the Free Software Foundation; either version 2 of the License, or     *
00012 *   (at your option) any later version.                                   *
00013 *                                                                         *
00014 ***************************************************************************/
00015 
00016 #ifndef PARAGRAPHSTYLE_H
00017 #define PARAGRAPHSTYLE_H
00018 
00019 #include "style.h"
00020 #include "charstyle.h"
00021 #include "styles/stylecontextproxy.h"
00022 
00023 
00024 class ResourceCollection;
00025 
00026 
00027 class SCRIBUS_API ParagraphStyle : public Style
00028 {
00029 public:
00030        enum LineSpacingMode { 
00031               FixedLineSpacing        = 0, 
00032               AutomaticLineSpacing    = 1,
00033               BaselineGridLineSpacing = 2
00034        };
00035        enum AlignmentType {
00036               Leftaligned  = 0,
00037               Centered     = 1,
00038               Rightaligned = 2,
00039               Justified    = 3,
00040               Extended     = 4
00041        };
00042        enum OpticalMarginType {
00043               OM_None  = 0,
00044               OM_LeftProtruding    = 1,
00045               OM_RightProtruding   = 2,
00046               OM_LeftHangingPunct  = 4,
00047               OM_RightHangingPunct = 8,
00048               OM_Default           = OM_RightProtruding + OM_LeftHangingPunct + OM_RightHangingPunct
00049        };
00050        enum HyphenationMode {
00051               NoHyphenation        = 0,
00052               ManualHyphenation    = 1,
00053               AutomaticHyphenation = 2
00054        };
00055        struct TabRecord
00056        {
00057               double tabPosition;
00058               int tabType;
00059               QChar tabFillChar;
00060               bool operator==(const TabRecord& other) const {
00061                      return tabPosition==other.tabPosition && tabType==other.tabType && tabFillChar == other.tabFillChar;
00062               }
00063               bool operator<(const TabRecord& other)  const { return tabPosition < other.tabPosition; }
00064               bool operator<=(const TabRecord& other) const { return tabPosition <= other.tabPosition; }
00065               bool operator>(const TabRecord& other)  const { return tabPosition > other.tabPosition; }
00066               bool operator>=(const TabRecord& other) const { return tabPosition >= other.tabPosition; }
00067        };
00068 
00069        ParagraphStyle();
00070        ParagraphStyle(const ParagraphStyle& other);
00071        ParagraphStyle& operator=(const ParagraphStyle& other);
00072        ~ParagraphStyle();
00073 
00074        static const Xml_string saxxDefaultElem;
00075        static void  desaxeRules(const Xml_string& prefixPattern, desaxe::Digester& ruleset, Xml_string elemtag = saxxDefaultElem);
00076        
00077        virtual void saxx(SaxHandler& handler, const Xml_string& elemtag) const;
00078        virtual void saxx(SaxHandler& handler)                     const { saxx(handler, saxxDefaultElem); }
00079        
00080 
00081        void getNamedResources(ResourceCollection& lists) const;
00082        void replaceNamedResources(ResourceCollection& newNames);
00083 
00084        QString displayName() const;
00085 
00086        void setContext(const StyleContext* context);
00087        void update(const StyleContext*);
00088        
00089        bool equiv(const Style& other) const;
00090        
00091        void applyStyle(const ParagraphStyle& other);
00092        void eraseStyle(const ParagraphStyle& other);
00093        void setStyle(const ParagraphStyle& other);
00094        void erase() { eraseStyle(*this); }
00095 
00096        StyleContext* charStyleContext() { return & cstyleContext; }
00097        const StyleContext* charStyleContext() const { return & cstyleContext; }
00098        CharStyle & charStyle() { return cstyle; }
00099        const CharStyle& charStyle() const { return cstyle; }
00103        void breakImplicitCharStyleInheritance(bool val = true);
00108        void repairImplicitCharStyleInheritance();
00109        
00112 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
00113        const attr_TYPE attr_GETTER() const { validate(); return m_##attr_NAME; }
00114 #include "paragraphstyle.attrdefs.cxx"
00115 #undef ATTRDEF
00116        
00119 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
00120        void set##attr_NAME(attr_TYPE v) { m_##attr_NAME = v; inh_##attr_NAME = false; }
00121 #include "paragraphstyle.attrdefs.cxx"
00122 #undef ATTRDEF
00123        void appendTabValue(const TabRecord& tab) { validate(); m_TabValues.append(tab); inh_TabValues = false; }
00124        
00125        
00128 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
00129        void reset##attr_NAME() { m_##attr_NAME = attr_DEFAULT; inh_##attr_NAME = true; }
00130 #include "paragraphstyle.attrdefs.cxx"
00131 #undef ATTRDEF
00132        
00134 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
00135        bool isInh##attr_NAME() const { return inh_##attr_NAME; }
00136 #include "paragraphstyle.attrdefs.cxx"
00137 #undef ATTRDEF
00138        
00139        
00141 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
00142        bool isDef##attr_NAME() const { \
00143               if ( !inh_##attr_NAME ) return true; \
00144               const ParagraphStyle * par = dynamic_cast<const ParagraphStyle*>(parentStyle()); \
00145               return par && par->isDef##attr_NAME(); \
00146        }
00147 #include "paragraphstyle.attrdefs.cxx"
00148 #undef ATTRDEF
00149        
00150        
00151 private:
00152               
00153        // member declarations:
00154        StyleContextProxy cstyleContext;
00155        bool cstyleContextIsInh;
00156        CharStyle cstyle;
00157        
00158 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
00159               attr_TYPE m_##attr_NAME; \
00160                      bool inh_##attr_NAME;
00161 #include "paragraphstyle.attrdefs.cxx"
00162 #undef ATTRDEF
00163               
00164 };
00165 
00166 #endif