Scribus
Open source desktop publishing at your fingertips
textwriter.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  /***************************************************************************
8  * Copyright (C) 2009 by Andreas Vox *
9  * avox@scribus.info *
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  * This program is distributed in the hope that it will be useful, *
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19  * GNU General Public License for more details. *
20  * *
21  * You should have received a copy of the GNU General Public License *
22  * along with this program; if not, write to the *
23  * Free Software Foundation, Inc., *
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
25  ***************************************************************************/
26 
27 #ifndef TEXTWRITER_H
28 #define TEXTWRITER_H
29 
30 #include <QString>
31 #include <QMap>
32 #include "scconfig.h"
33 #include "scribusapi.h"
34 
35 #include "styles/charstyle.h"
36 #include "styles/paragraphstyle.h"
37 #include "styles/styleset.h"
38 
39 class ScribusDoc;
40 class PageItem;
41 class ScColor;
42 
46 class SCRIBUS_API TextWriter
47 {
48 public:
49  TextWriter(ScribusDoc* doc);
55  void open(PageItem* textframe);
61  void close();
65  CharStyle getCurrentCharStyle();
69  ParagraphStyle getCurrentStyle();
73  void setCharStyle(const CharStyle& cstyle);
74  void setCharStyle(const QString& name);
80  void setStyle(const ParagraphStyle& pstyle);
81  void setStyle(const QString& name);
85  void appendText(const QString& text);
86 
90  void defineCharStyle(const QString name, const CharStyle& cstyle);
94  void defineStyle(const QString& name, const ParagraphStyle& pstyle);
100  void defineFont(const QString& name, const QString& family, const QString& variant, bool bold=false, bool italic=false);
104  void defineColor(const QString& name, const ScColor& color);
105  ScribusDoc* currentDoc();
106 
107 private:
108  ScribusDoc* document;
109  PageItem* frame;
110 
111  CharStyle currentCharStyle;
112  ParagraphStyle currentParStyle;
113 
114  int styledUptoPos;
115  void setStyles();
116 
117  StyleSet<CharStyle> charStyles;
118  StyleSet<ParagraphStyle> parStyles;
119 
120  // for resolving name conflicts:
121  QMap<QString, QString> parStyleMap;
122  QMap<QString, QString> charStyleMap;
123  QMap<QString, QString> fontMap;
124  QMap<QString, QString> colorMap;
125 };
126 
127 #endif
Definition: sccolor.h:51
Definition: charstyle.h:78
Definition: textwriter.h:46
Definition: paragraphstyle.h:27
the Document Class
Definition: scribusdoc.h:90
Definition: pageitem.h:92