Subversion Repositories Scribus

Rev

Rev 18047 | Rev 20528 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
17827 craig 1
#ifndef MARKS_H
2
#define MARKS_H
3
 
4
#include "QString"
5
#include "scribusapi.h"
6
#include "desaxe/saxiohelper.h"
7
#include "desaxe/simple_actions.h"
8
 
9
class Mark;
10
class PageItem;
11
class TextNote;
12
 
13
enum MarkType
14
{
15
        MARKNoType = -1, //undefinied mark type (wrong situation!)
16
        MARKAnchorType = 0, //empty anchor mark, useful for creating references to it
17
        MARK2ItemType = 1, //reference to page item ID
18
        MARK2MarkType = 2, //reference other mark
19
        MARKVariableTextType = 3,//mark contain dynamic text
20
        MARKNoteMasterType = 4,  //mark contain footnote reference
21
        MARKNoteFrameType = 5,  //mark used internally in note frame at beginning of note`s text
18047 craig 22
        MARKIndexType = 6, // index entry
23
        MARKBullNumType = 7
17827 craig 24
};
25
 
26
struct MarkData
27
{
28
        QString strtxt;
29
        PageItem* itemPtr;
30
        QString destmarkName;
31
        MarkType destmarkType;
32
        TextNote* notePtr;
33
        //fields used for resolving to pointers for load and copy
34
        QString itemName;
35
        MarkType markTyp;
36
 
37
        MarkData() : strtxt(""), itemPtr(NULL), destmarkName(""), destmarkType(MARKNoType), notePtr(NULL), itemName(""), markTyp(MARKNoType) {}
38
};
39
 
40
class SCRIBUS_API Mark
41
{
42
        friend class ScribusDoc;
43
        friend class ScribusMainWindow;
18047 craig 44
        friend class BulNumMark;
17827 craig 45
        //only ScribusDoc && ScribusMainWindow can create and delete marks
46
private:
47
        Mark() : label(""), OwnPage(-1), typ(MARKNoType), data() {}
48
        Mark(const Mark& other) : label(other.label), OwnPage(other.OwnPage), typ(other.typ), data(other.data) {}
18524 avox 49
 
17827 craig 50
public:
51
        QString label;
52
        int OwnPage;
53
 
54
        void setValues(QString l, int p, MarkType t, MarkData d) { label = l; OwnPage = p; typ = t; data = d; }
55
        const MarkType getType() { return typ; }
56
        void setType(MarkType t) { typ = t; }
57
        const MarkData getData() { return data; }
58
        void setData(const MarkData d) { data = d; }
59
        PageItem* getItemPtr() { return data.itemPtr; }
60
        void setItemPtr( PageItem* ptr ) { data.itemPtr = ptr; }
61
        const QString getItemName() { return data.itemName; }
62
        void setItemName( const QString name ) { data.itemName = name; }
63
 
64
        //for marks to marks - return label and type of target mark by reference
65
        const void getMark(QString &l, MarkType &t) { l = data.destmarkName; t = data.destmarkType; }
66
        //for marks to marks - set label and type of target mark from mark pointer
67
        void setMark(Mark* mP)
68
        {
69
                if (mP == NULL)
70
                {
71
                        data.destmarkName = "";
72
                        data.destmarkType = MARKNoType;
73
                }
74
                else
75
                {
76
                        data.destmarkName = mP->label;
77
                        data.destmarkType = mP->getType();
78
                }
79
        }
80
        void setMark(QString l, MarkType t) { data.destmarkName = l; data.destmarkType = t; }
81
        const MarkType getMarkType() { return data.markTyp; }
82
        void setMarkType(MarkType t) { data.markTyp = t; }
83
        const QString getString() { return data.strtxt; }
84
        void setString( const QString str ) { data.strtxt = str; }
85
        TextNote* getNotePtr() { return data.notePtr; }
86
        void setNotePtr(TextNote *note) { data.notePtr = note; }
87
 
88
        bool hasItemPtr() { return data.itemPtr != NULL; }
89
        bool hasString() { return !data.strtxt.isEmpty(); }
90
        bool hasMark() { return data.destmarkName != ""; }
18047 craig 91
        bool isUnique() { return ((typ != MARKVariableTextType) && (typ != MARKIndexType) && (typ != MARKBullNumType)); }
17827 craig 92
        bool isNoteType() { return ((typ == MARKNoteMasterType) || (typ==MARKNoteFrameType)); }
93
        bool isType(const MarkType t) { return t==typ; }
94
 
18524 avox 95
    virtual ~Mark() {}
96
 
17827 craig 97
protected:
98
        MarkType typ;
99
        MarkData data;
100
};
101
 
18047 craig 102
class SCRIBUS_API BulNumMark : public Mark
103
{
104
public:
105
        BulNumMark() : Mark() { label = "BullNumMark"; typ = MARKBullNumType; }
106
        ~BulNumMark() {}
107
};
108
 
17827 craig 109
#endif // MARKS_H