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 *                                                                         *
9 *   This program is free software; you can redistribute it and/or modify  *
10 *   it under the terms of the GNU General Public License as published by  *
11 *   the Free Software Foundation; either version 2 of the License, or     *
12 *   (at your option) any later version.                                   *
13 *                                                                         *
14 ***************************************************************************/
15 
16 
17 #ifndef SHAPEDTEXT_H
18 #define SHAPEDTEXT_H
19 
20 #include <QList>
21 #include <QSharedPointer>
22 
23 #include "itextcontext.h"
24 #include "itextsource.h"
25 #include "glyphcluster.h"
26 
27 
28 
29 
30 class ShapedTextImplementation;
31 
32 /**
33  * This class holds the shaped glyphs for a range of characters. The glyphs are always in logical order.
34  */
35 class ShapedText
36 {
37     QSharedPointer<ShapedTextImplementation> p_impl;
38 	ShapedText(ShapedTextImplementation* p_impl);
39 
40 	friend class ShapedTextImplementation;
41 
42 public:
43 	ShapedText(ITextSource* src, int firstChar, int lastChar, ITextContext* ctx = nullptr);
44 	ShapedText(const ShapedText& other);
45 
46 	static ShapedText Invalid;
47 	bool isValid() const;
48 
49 	bool needsContext() const;
50 	void needsContext(bool);
51 
52 	// original text and link to styles
53 	const ITextSource* source() const;
54 	int firstChar() const;
55 	int lastChar() const;
56 
57 	// shaped clusters
58 	const QList<GlyphCluster>& glyphs() const;
59 	QList<GlyphCluster>& glyphs();
60 
61 	/** only possible if it also cleanly splits the textsource and glyphs */
62 	bool canSplit(int charPos) const;
63 	ShapedText split(int charPos);
64 	/** only possible if they are adjacent pieces of the same text source */
65 	bool canCombine(const ShapedText& other) const;
66 	void combine(ShapedText& other);
67 };
68 
69 
70 #endif
71