Subversion Repositories Scribus

Rev

Rev 21718 | Rev 22518 | Go to most recent revision | 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
 
21563 jghali 27
/* Strucure 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
59
        ScLayout_JustificationTracking = 1 << 22 // marks place of tracking in justification (e.g. for Thai)
18524 avox 60
};
4670 avox 61
 
62
 
5691 avox 63
/**
21563 jghali 64
 * simple class to abstract from inline pageitems. You will need a ITextContext
65
 * to get meaningfull data about the InlineFrame, for other purposes it is opaque
66
 */
67
class SCRIBUS_API InlineFrame
68
{
69
        int m_object_id;
70
public:
71
        InlineFrame(int id) : m_object_id(id) {}
72
        int getInlineCharID() const { return m_object_id; }
73
        PageItem* getPageItem(ScribusDoc* doc) const;
74
};
75
 
76
 
77
/**
78
 * Holds information about expansion points in a text source: pagenumber, counters, list bulllet, ...
79
 */
80
class SCRIBUS_API ExpansionPoint
81
{
82
public:
83
        enum ExpansionType {
84
                Invalid,
85
                PageNumber,
86
                PageCount,
87
                ListBullet,
88
                ListCounter,
89
                Note,   // foot or endnote number
90
                Anchor,  // usually invisible   
91
                PageRef,
92
                Lookup, // generic lookup
93
                SectionRef,
94
                MarkCE // deprecated
95
        } ;
96
 
21718 craig 97
        ExpansionPoint(ExpansionType t) : m_type(t), m_name(), m_mark(0) {}
98
        ExpansionPoint(ExpansionType t, QString name) : m_type(t), m_name(name), m_mark(0) {}
21563 jghali 99
        ExpansionPoint(Mark* mrk) : m_type(MarkCE), m_name(), m_mark(mrk) {}
100
 
101
        ExpansionType getType() const { return m_type; }
102
        QString getName() const { return m_name; }
103
        Mark* getMark() const { return m_mark; }
104
private:
105
        ExpansionType m_type;
106
        QString m_name;
107
        Mark* m_mark;
108
};
109
 
110
 
111
/**
5691 avox 112
 * This struct stores a positioned glyph. This is the result of the layout process.
113
 */
114
struct SCRIBUS_API GlyphLayout {
115
        float xadvance;
116
        float yadvance;
117
        float xoffset;
118
        float yoffset;
119
        double scaleV;
120
        double scaleH;
121
        uint glyph;
6144 avox 122
 
5691 avox 123
        GlyphLayout() : xadvance(0.0f), yadvance(0.0f), xoffset(0.0f), yoffset(0.0f),
21563 jghali 124
                scaleV(1.0), scaleH(1.0), glyph(0)
6144 avox 125
        { }
4670 avox 126
};
127
 
4689 mrdocs 128
class SCRIBUS_API ScText : public CharStyle
4670 avox 129
{
130
public:
5691 avox 131
        ParagraphStyle* parstyle; // only for parseps
17407 fschmid 132
        int embedded;
17826 craig 133
        Mark* mark;
9737 jghali 134
        QChar ch;
21107 craig 135
        ScText() :
8775 cbradney 136
                CharStyle(),
21107 craig 137
                parstyle(NULL),
18987 avox 138
                embedded(0), mark(NULL), ch() {}
21107 craig 139
        ScText(const ScText& other) :
7005 avox 140
                CharStyle(other),
21107 craig 141
                parstyle(NULL),
17826 craig 142
                embedded(other.embedded), mark(NULL), ch(other.ch)
6144 avox 143
        {
144
                if (other.parstyle)
145
                        parstyle = new ParagraphStyle(*other.parstyle);
17826 craig 146
                if (other.mark)
147
                        setNewMark(other.mark);
6144 avox 148
        }
5691 avox 149
        ~ScText();
16600 jghali 150
 
17407 fschmid 151
        bool hasObject(ScribusDoc *doc) const;
17826 craig 152
        //returns true if given MRK is found, if MRK is NULL then any mark returns true
153
        bool hasMark(Mark * MRK = NULL) const;
17407 fschmid 154
        QList<PageItem*> getGroupedItems(ScribusDoc *doc);
155
        PageItem* getItem(ScribusDoc *doc);
17826 craig 156
private:
157
        void setNewMark(Mark* mrk);
3878 cbradney 158
};
5184 avox 159
 
12269 cbradney 160
 
161
/** @brief First Line Offset Policy
162
 * Set wether the first line offset is based on max glyph height
163
 * or some of predefined height.
164
 * I put a prefix because it could easily conflict
165
 */
166
enum FirstLineOffsetPolicy
167
{
168
    FLOPRealGlyphHeight = 0, // Historical
17760 jghali 169
    FLOPFontAscent       = 1,
170
    FLOPLineSpacing  = 2,
171
        FLOPBaselineGrid = 3
12269 cbradney 172
};
173
 
174
 
3878 cbradney 175
#endif // SCTEXTSTRUCT_H
176