Scribus
Open source desktop publishing at your fingertips
sctextstruct.h
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 /* Struktur fuer 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_HyphenationPossible=128, //Hyphenation possible here (Soft Hyphen)
43  ScLayout_DropCap = 2048,
44  ScLayout_SuppressSpace = 4096,//internal use in PageItem (Suppresses spaces when in Block alignment)
45  ScLayout_SoftHyphenVisible=8192, //Soft Hyphen visible at line end
46  ScLayout_StartOfLine = 16384
47 };
48 
49 
54 struct SCRIBUS_API GlyphLayout {
55  float xadvance;
56  float yadvance;
57  float xoffset;
58  float yoffset;
59  double scaleV;
60  double scaleH;
61  uint glyph;
62  GlyphLayout* more;
63 
64  GlyphLayout() : xadvance(0.0f), yadvance(0.0f), xoffset(0.0f), yoffset(0.0f),
65  scaleV(1.0), scaleH(1.0), glyph(0), more(NULL)
66  { }
67  GlyphLayout(const GlyphLayout& o) : xadvance(o.xadvance), yadvance(o.yadvance), xoffset(o.xoffset), yoffset(o.yoffset),
68  scaleV(o.scaleH), scaleH(o.scaleV), glyph(o.glyph), more(NULL)
69  { }
70  virtual ~GlyphLayout()
71  { }
72  double wide() const
73  {
74  double ret = 0;
75  for(const GlyphLayout* p=this; p; p=p->more)
76  ret += p->xadvance;
77  return ret;
78  }
79  GlyphLayout* last()
80  {
81  if (more)
82  return more->last();
83  else
84  return this;
85  }
86  void shrink()
87  {
88  if (more) {
89  more->shrink();
90  delete more;
91  more = NULL;
92  }
93  }
94  void grow()
95  {
96  if (!more) {
97  more = new GlyphLayout();
98  }
99  }
100  virtual void growWithTabLayout();
101 };
102 
103 struct SCRIBUS_API TabLayout : public GlyphLayout
104 {
105  QChar fillChar;
106 };
107 
108 
109 class SCRIBUS_API ScText : public CharStyle
110 {
111 public:
112  ParagraphStyle* parstyle; // only for parseps
113  GlyphLayout glyph;
114  int embedded;
115  Mark* mark;
116  QChar ch;
117  ScText() :
118  CharStyle(),
119  parstyle(NULL), glyph(),
120  embedded(0), mark(NULL), ch() {}
121  ScText(const ScText& other) :
122  CharStyle(other),
123  parstyle(NULL), glyph(other.glyph),
124  embedded(other.embedded), mark(NULL), ch(other.ch)
125  {
126  glyph.more = NULL;
127  GlyphLayout *layout = &glyph;
128  const GlyphLayout *otherLayout = &other.glyph;
129  while (otherLayout->more)
130  {
131  layout->more = new GlyphLayout(*otherLayout->more);
132  layout = layout->more;
133  otherLayout = otherLayout->more;
134  }
135  if (other.parstyle)
136  parstyle = new ParagraphStyle(*other.parstyle);
137  if (other.mark)
138  setNewMark(other.mark);
139  }
140  ~ScText();
141 
142  bool hasObject(ScribusDoc *doc) const;
143  //returns true if given MRK is found, if MRK is NULL then any mark returns true
144  bool hasMark(Mark * MRK = NULL) const;
145  QList<PageItem*> getGroupedItems(ScribusDoc *doc);
146  PageItem* getItem(ScribusDoc *doc);
147 private:
148  void setNewMark(Mark* mrk);
149 };
150 
151 
157 enum FirstLineOffsetPolicy
158 {
159  FLOPRealGlyphHeight = 0, // Historical
160  FLOPFontAscent = 1,
161  FLOPLineSpacing = 2,
162  FLOPBaselineGrid = 3
163 };
164 
165 
166 #endif // SCTEXTSTRUCT_H
167 
Definition: sctextstruct.h:103
Definition: charstyle.h:78
Definition: sctextstruct.h:109
Definition: paragraphstyle.h:27
Definition: marks.h:40
the Document Class
Definition: scribusdoc.h:90
Definition: pageitem.h:92
Definition: sctextstruct.h:54