Rev 25179 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4430 | cbradney | 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 | */ |
||
3878 | cbradney | 7 | #ifndef SCTEXTSTRUCT_H |
8 | #define SCTEXTSTRUCT_H |
||
9 | |||
10 | #ifdef HAVE_CONFIG_H |
||
11 | #include "scconfig.h" |
||
12 | #endif |
||
13 | |||
4689 | mrdocs | 14 | #include "scribusapi.h" |
15 | |||
10028 | cbradney | 16 | #include <QString> |
3878 | cbradney | 17 | |
5559 | avox | 18 | #include "scfonts.h" |
5691 | avox | 19 | #include "style.h" |
8337 | avox | 20 | #include "styles/charstyle.h" |
21 | #include "styles/paragraphstyle.h" |
||
5559 | avox | 22 | |
3878 | cbradney | 23 | class PageItem; |
17826 | craig | 24 | class Mark; |
17407 | fschmid | 25 | class ScribusDoc; |
3878 | cbradney | 26 | |
24665 | jghali | 27 | /* Structure for Pageitem Text */ |
4670 | avox | 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 | |||
18524 | avox | 39 | // from charstlye.h ScStyleFlags |
40 | enum LayoutFlags { |
||
41 | ScLayout_None = 0, |
||
21563 | jghali | 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 |
||
22178 | jghali | 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 |
||
23709 | jghali | 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 |
||
18524 | avox | 61 | }; |
4670 | avox | 62 | |
63 | |||
5691 | avox | 64 | /** |
21563 | jghali | 65 | * simple class to abstract from inline pageitems. You will need a ITextContext |
24665 | jghali | 66 | * to get meaningful data about the InlineFrame, for other purposes it is opaque |
21563 | jghali | 67 | */ |
68 | class SCRIBUS_API InlineFrame |
||
69 | { |
||
70 | public: |
||
25179 | jghali | 71 | explicit InlineFrame(int id) : m_object_id(id) {} |
21563 | jghali | 72 | int getInlineCharID() const { return m_object_id; } |
25179 | jghali | 73 | PageItem* getPageItem(const ScribusDoc* doc) const; |
74 | |||
75 | private: |
||
76 | int m_object_id; |
||
21563 | jghali | 77 | }; |
78 | |||
79 | |||
80 | /** |
||
81 | * Holds information about expansion points in a text source: pagenumber, counters, list bulllet, ... |
||
82 | */ |
||
83 | class SCRIBUS_API ExpansionPoint |
||
84 | { |
||
85 | public: |
||
25210 | jghali | 86 | enum ExpansionType |
87 | { |
||
21563 | jghali | 88 | Invalid, |
89 | PageNumber, |
||
90 | PageCount, |
||
91 | ListBullet, |
||
92 | ListCounter, |
||
93 | Note, // foot or endnote number |
||
94 | Anchor, // usually invisible |
||
95 | PageRef, |
||
96 | Lookup, // generic lookup |
||
97 | SectionRef, |
||
98 | MarkCE // deprecated |
||
99 | } ; |
||
100 | |||
25179 | jghali | 101 | ExpansionPoint(ExpansionType t) : m_type(t) {} |
102 | ExpansionPoint(ExpansionType t, QString name) : m_type(t), m_name(name) {} |
||
103 | ExpansionPoint(Mark* mrk) : m_type(MarkCE), m_mark(mrk) {} |
||
21563 | jghali | 104 | |
105 | ExpansionType getType() const { return m_type; } |
||
106 | QString getName() const { return m_name; } |
||
107 | Mark* getMark() const { return m_mark; } |
||
25179 | jghali | 108 | |
21563 | jghali | 109 | private: |
25179 | jghali | 110 | ExpansionType m_type { Invalid }; |
21563 | jghali | 111 | QString m_name; |
25179 | jghali | 112 | Mark* m_mark { nullptr }; |
21563 | jghali | 113 | }; |
114 | |||
115 | |||
116 | /** |
||
5691 | avox | 117 | * This struct stores a positioned glyph. This is the result of the layout process. |
118 | */ |
||
25179 | jghali | 119 | struct SCRIBUS_API GlyphLayout |
120 | { |
||
121 | GlyphLayout() = default; |
||
122 | |||
123 | float xadvance { 0.0f }; |
||
124 | float yadvance { 0.0f }; |
||
125 | float xoffset { 0.0f }; |
||
126 | float yoffset { 0.0f }; |
||
127 | double scaleV { 1.0 }; |
||
128 | double scaleH { 1.0 }; |
||
129 | uint glyph { 0 }; |
||
4670 | avox | 130 | }; |
131 | |||
4689 | mrdocs | 132 | class SCRIBUS_API ScText : public CharStyle |
4670 | avox | 133 | { |
134 | public: |
||
25179 | jghali | 135 | ScText() : CharStyle() {} |
136 | |||
21107 | craig | 137 | ScText(const ScText& other) : |
7005 | avox | 138 | CharStyle(other), |
25179 | jghali | 139 | embedded(other.embedded), |
140 | ch(other.ch) |
||
6144 | avox | 141 | { |
142 | if (other.parstyle) |
||
143 | parstyle = new ParagraphStyle(*other.parstyle); |
||
17826 | craig | 144 | if (other.mark) |
145 | setNewMark(other.mark); |
||
6144 | avox | 146 | } |
16600 | jghali | 147 | |
25179 | jghali | 148 | ~ScText() override; |
149 | |||
150 | ParagraphStyle* parstyle { nullptr }; // only for parseps |
||
151 | int embedded { 0 }; |
||
152 | Mark* mark { nullptr }; |
||
153 | QChar ch; |
||
154 | |||
155 | bool hasObject(const ScribusDoc *doc) const; |
||
22518 | craig | 156 | //returns true if given MRK is found, if MRK is nullptr then any mark returns true |
23440 | jghali | 157 | bool hasMark(const Mark * mrk = nullptr) const; |
25179 | jghali | 158 | QList<PageItem*> getGroupedItems(const ScribusDoc *doc) const; |
159 | PageItem* getItem(const ScribusDoc *doc) const; |
||
160 | |||
17826 | craig | 161 | private: |
162 | void setNewMark(Mark* mrk); |
||
3878 | cbradney | 163 | }; |
5184 | avox | 164 | |
12269 | cbradney | 165 | |
166 | /** @brief First Line Offset Policy |
||
24665 | jghali | 167 | * Set whether the first line offset is based on max glyph height |
12269 | cbradney | 168 | * or some of predefined height. |
169 | * I put a prefix because it could easily conflict |
||
170 | */ |
||
171 | enum FirstLineOffsetPolicy |
||
172 | { |
||
173 | FLOPRealGlyphHeight = 0, // Historical |
||
17760 | jghali | 174 | FLOPFontAscent = 1, |
175 | FLOPLineSpacing = 2, |
||
176 | FLOPBaselineGrid = 3 |
||
12269 | cbradney | 177 | }; |
178 | |||
179 | |||
3878 | cbradney | 180 | #endif // SCTEXTSTRUCT_H |
181 |