1 /* This file is part of the KDE project
2  * Copyright (C) 2011 Smit Patel <smitpatel24@gmail.com>
3  * Copyright (C) 2011 Gopalakrishna Bhat A <gopalakbhat@gmail.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB.  If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20 #ifndef TOCBIBGENERATORINFO_H
21 #define TOCBIBGENERATORINFO_H
22 
23 #include <KoText.h>
24 
25 const int INVALID_OUTLINE_LEVEL = 0;
26 
27 class KoXmlWriter;
28 
29 class KRITATEXT_EXPORT IndexEntry
30 {
31 public:
32     enum IndexEntryName {UNKNOWN, LINK_START, CHAPTER, SPAN, TEXT, TAB_STOP, PAGE_NUMBER, LINK_END, BIBLIOGRAPHY};
33 
34     explicit IndexEntry(const QString &_styleName, IndexEntryName _name = IndexEntry::UNKNOWN);
35     virtual IndexEntry *clone();
36     virtual ~IndexEntry();
37     virtual void addAttributes(KoXmlWriter * writer) const;
38     void saveOdf(KoXmlWriter * writer) const;
39 
40     QString styleName;
41     IndexEntryName name;
42 };
43 
44 
45 class IndexEntryLinkStart : public IndexEntry
46 {
47 public:
48     explicit IndexEntryLinkStart(const QString &_styleName);
49     IndexEntry *clone() override;
50 };
51 
52 
53 class IndexEntryChapter : public IndexEntry
54 {
55 public:
56     explicit IndexEntryChapter(const QString &_styleName);
57     IndexEntry *clone() override;
58     void addAttributes(KoXmlWriter* writer) const override;
59 
60     QString display;
61     int outlineLevel;
62 };
63 
64 
65 class  KRITATEXT_EXPORT IndexEntrySpan : public IndexEntry
66 {
67 public:
68     explicit IndexEntrySpan(const QString &_styleName);
69     IndexEntry *clone() override;
70     void addAttributes(KoXmlWriter* writer) const override;
71 
72     QString text;
73 };
74 
75 
76 class IndexEntryText : public IndexEntry
77 {
78 public:
79     explicit IndexEntryText(const QString &_styleName);
80     IndexEntry *clone() override;
81 };
82 
83 
84 class KRITATEXT_EXPORT IndexEntryTabStop : public IndexEntry
85 {
86 public:
87     explicit IndexEntryTabStop(const QString &_styleName);
88     IndexEntry *clone() override;
89     void addAttributes(KoXmlWriter* writer) const override;
90     // for saving let's save the original unit,
91     // for KoText::Tab we need to convert to PostScript points
92     void setPosition(const QString &position);
93 
94     KoText::Tab tab;
95     QString m_position;
96 };
97 
98 
99 class IndexEntryPageNumber : public IndexEntry
100 {
101 public:
102     explicit IndexEntryPageNumber(const QString &_styleName);
103     IndexEntry *clone() override;
104 };
105 
106 
107 class IndexEntryLinkEnd : public IndexEntry
108 {
109 public:
110     explicit IndexEntryLinkEnd(const QString &_styleName);
111     IndexEntry *clone() override;
112 };
113 
114 class KRITATEXT_EXPORT TocEntryTemplate
115 {
116 public:
117     TocEntryTemplate();
118     TocEntryTemplate(const TocEntryTemplate &other);
119     void saveOdf(KoXmlWriter * writer) const;
120 
121     int outlineLevel;
122     QString styleName;
123     int styleId;
124     QList<IndexEntry*> indexEntries;
125 };
126 
127 
128 class KRITATEXT_EXPORT IndexTitleTemplate
129 {
130 public:
131     void saveOdf(KoXmlWriter * writer) const;
132 
133     QString styleName;
134     int styleId;
135     QString text;
136 };
137 
138 
139 class KRITATEXT_EXPORT IndexSourceStyle
140 {
141 public:
142     IndexSourceStyle(const IndexSourceStyle& indexSourceStyle);
143     IndexSourceStyle();
144     void saveOdf(KoXmlWriter * writer) const;
145 
146     QString styleName;
147     int styleId;
148 };
149 
150 
151 class KRITATEXT_EXPORT IndexSourceStyles
152 {
153 public:
154     IndexSourceStyles();
155     IndexSourceStyles(const IndexSourceStyles &indexSourceStyles);
156     void saveOdf(KoXmlWriter * writer) const;
157 
158     int outlineLevel;
159     QList<IndexSourceStyle> styles;
160 };
161 
162 class KRITATEXT_EXPORT IndexEntryBibliography : public IndexEntry
163 {
164 public:
165     explicit IndexEntryBibliography(const QString &_styleName);
166     IndexEntry *clone() override;
167     void addAttributes(KoXmlWriter* writer) const override;
168 
169     QString dataField;
170 };
171 
172 class KRITATEXT_EXPORT BibliographyEntryTemplate
173 {
174 public:
175     BibliographyEntryTemplate();
176     BibliographyEntryTemplate(const BibliographyEntryTemplate &other);
177     void saveOdf(KoXmlWriter * writer) const;
178 
179     QString styleName;
180     int styleId;
181     QList<IndexEntry*> indexEntries;
182     QString bibliographyType;
183 };
184 
185 Q_DECLARE_METATYPE(IndexEntry::IndexEntryName)
186 #endif // TOCBIBGENERATORINFO_H
187