1 /* 2 For general Scribus (>=1.3.2) copyright and licensing information please refer 3 to the COPYING file provided with the program. Following this notice may exist 4 a copyright and/or license notice that predates the release of Scribus 1.3.2 5 for which a new license (GPL+exception) is in place. 6 */ 7 #ifndef SCTEXTSTRUCT_H 8 #define SCTEXTSTRUCT_H 9 10 #ifdef HAVE_CONFIG_H 11 #include "scconfig.h" 12 #endif 13 14 #include "scribusapi.h" 15 16 #include <QString> 17 18 #include "scfonts.h" 19 #include "style.h" 20 #include "styles/charstyle.h" 21 #include "styles/paragraphstyle.h" 22 23 class PageItem; 24 class Mark; 25 class ScribusDoc; 26 27 /* Strucure for Pageitem Text */ 28 29 30 /* 31 * sctext.h 32 * Scribus 33 * 34 * Created by Andreas Vox on 29.07.05. 35 * Copyright 2005 under GPL2. All rights reserved. 36 * 37 */ 38 39 // from charstlye.h ScStyleFlags 40 enum LayoutFlags { 41 ScLayout_None = 0, 42 ScLayout_BulletNum = 1 << 0, // marks list layout glyphs 43 ScLayout_FixedSpace = 1 << 1, // marks a fixed space 44 ScLayout_ExpandingSpace= 1 << 2, // marks an expanding space 45 ScLayout_ImplicitSpace = 1 << 3, // marks an implicit space 46 ScLayout_TabLeaders = 1 << 4, // marks a tab with fillchar 47 ScLayout_HyphenationPossible = 1 << 7, // marks possible hyphenation point 48 ScLayout_DropCap = 1 << 11, 49 ScLayout_SuppressSpace = 1 << 12, // internal use in PageItem (Suppresses spaces when in Block alignment) 50 ScLayout_SoftHyphenVisible = 1 << 13, // marks when a possible hyphenation point is used (st end of line) 51 ScLayout_StartOfLine = 1 << 14, // marks the start of line 52 ScLayout_Underlined = 1 << 15, // marks underlined glyphs 53 ScLayout_LineBoundary = 1 << 16, // marks possible line breaking point 54 ScLayout_RightToLeft = 1 << 17, // marks right-to-left glyph 55 ScLayout_SmallCap = 1 << 18, // marks small caps glyph 56 ScLayout_CJKFence = 1 << 19, // marks CJK fence glyph that needs spacing adjustment at start of line 57 ScLayout_NoBreakAfter = 1 << 20, // marks glyphs after which a line break cannot occur 58 ScLayout_NoBreakBefore = 1 << 21, // marks glyphs before which a line break cannot occur 59 ScLayout_JustificationTracking = 1 << 22, // marks place of tracking in justification (e.g. for Thai) 60 ScLayout_CJKLatinSpace = 1 << 23 // marks place of space between CJK and latin letter 61 }; 62 63 64 /** 65 * simple class to abstract from inline pageitems. You will need a ITextContext 66 * to get meaningfull data about the InlineFrame, for other purposes it is opaque 67 */ 68 class SCRIBUS_API InlineFrame 69 { 70 int m_object_id; 71 public: InlineFrame(int id)72 InlineFrame(int id) : m_object_id(id) {} getInlineCharID()73 int getInlineCharID() const { return m_object_id; } 74 PageItem* getPageItem(ScribusDoc* doc) const; 75 }; 76 77 78 /** 79 * Holds information about expansion points in a text source: pagenumber, counters, list bulllet, ... 80 */ 81 class SCRIBUS_API ExpansionPoint 82 { 83 public: 84 enum ExpansionType { 85 Invalid, 86 PageNumber, 87 PageCount, 88 ListBullet, 89 ListCounter, 90 Note, // foot or endnote number 91 Anchor, // usually invisible 92 PageRef, 93 Lookup, // generic lookup 94 SectionRef, 95 MarkCE // deprecated 96 } ; 97 ExpansionPoint(ExpansionType t)98 ExpansionPoint(ExpansionType t) : m_type(t), m_name(), m_mark(0) {} ExpansionPoint(ExpansionType t,QString name)99 ExpansionPoint(ExpansionType t, QString name) : m_type(t), m_name(name), m_mark(0) {} ExpansionPoint(Mark * mrk)100 ExpansionPoint(Mark* mrk) : m_type(MarkCE), m_name(), m_mark(mrk) {} 101 getType()102 ExpansionType getType() const { return m_type; } getName()103 QString getName() const { return m_name; } getMark()104 Mark* getMark() const { return m_mark; } 105 private: 106 ExpansionType m_type; 107 QString m_name; 108 Mark* m_mark; 109 }; 110 111 112 /** 113 * This struct stores a positioned glyph. This is the result of the layout process. 114 */ 115 struct SCRIBUS_API GlyphLayout { 116 float xadvance; 117 float yadvance; 118 float xoffset; 119 float yoffset; 120 double scaleV; 121 double scaleH; 122 uint glyph; 123 GlyphLayoutGlyphLayout124 GlyphLayout() : xadvance(0.0f), yadvance(0.0f), xoffset(0.0f), yoffset(0.0f), 125 scaleV(1.0), scaleH(1.0), glyph(0) 126 { } 127 }; 128 129 class SCRIBUS_API ScText : public CharStyle 130 { 131 public: 132 ParagraphStyle* parstyle; // only for parseps 133 int embedded; 134 Mark* mark; 135 QChar ch; ScText()136 ScText() : 137 CharStyle(), 138 parstyle(nullptr), 139 embedded(0), mark(nullptr), ch() {} ScText(const ScText & other)140 ScText(const ScText& other) : 141 CharStyle(other), 142 parstyle(nullptr), 143 embedded(other.embedded), mark(nullptr), ch(other.ch) 144 { 145 if (other.parstyle) 146 parstyle = new ParagraphStyle(*other.parstyle); 147 if (other.mark) 148 setNewMark(other.mark); 149 } 150 ~ScText(); 151 152 bool hasObject(ScribusDoc *doc) const; 153 //returns true if given MRK is found, if MRK is nullptr then any mark returns true 154 bool hasMark(const Mark * mrk = nullptr) const; 155 QList<PageItem*> getGroupedItems(ScribusDoc *doc); 156 PageItem* getItem(ScribusDoc *doc); 157 private: 158 void setNewMark(Mark* mrk); 159 }; 160 161 162 /** @brief First Line Offset Policy 163 * Set wether the first line offset is based on max glyph height 164 * or some of predefined height. 165 * I put a prefix because it could easily conflict 166 */ 167 enum FirstLineOffsetPolicy 168 { 169 FLOPRealGlyphHeight = 0, // Historical 170 FLOPFontAscent = 1, 171 FLOPLineSpacing = 2, 172 FLOPBaselineGrid = 3 173 }; 174 175 176 #endif // SCTEXTSTRUCT_H 177 178