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 #ifndef ITEXTSOURCE_H 9 #define ITEXTSOURCE_H 10 11 #include "scribusapi.h" 12 #include "sctextstruct.h" 13 14 class CharStyle; 15 class ParagraphStyle; 16 class InlineFrame; 17 class GlyphCluster; 18 class ScribusDoc; 19 20 21 class SCRIBUS_API ITextSource { 22 23 public: 24 25 virtual int length() const = 0; 26 virtual QChar text(int pos) const = 0; 27 virtual QString text(int pos, uint len) const = 0; 28 29 /// Checks if it's the start of a paragraph or "block" 30 virtual bool isBlockStart(int pos) const = 0; 31 32 /// Returns a blockstart position > pos. 33 /// You may lie here, i.e. lump blocks together or just return the end of the text 34 virtual int nextBlockStart(int pos) const = 0; 35 36 virtual const CharStyle& charStyle(int pos) const = 0; 37 virtual const ParagraphStyle& paragraphStyle(int pos) const = 0; 38 39 virtual void setCharStyle(int pos, uint len, const CharStyle& style) = 0; 40 virtual void setStyle(int pos, const ParagraphStyle& style) = 0; 41 42 virtual LayoutFlags flags(int pos) const = 0; 43 virtual bool hasFlag(int pos, LayoutFlags flag) const = 0; 44 virtual void setFlag(int pos, LayoutFlags flag) = 0; 45 virtual void clearFlag(int pos, LayoutFlags flag) = 0; 46 47 virtual bool hasObject(int pos) const = 0; 48 virtual InlineFrame object(int pos) const = 0; 49 virtual bool hasExpansionPoint(int pos) const = 0; 50 virtual ExpansionPoint expansionPoint(int pos) const = 0; 51 parent()52 virtual const ITextSource* parent() const { return nullptr; } parentPos()53 virtual int parentPos() const { return 0; } 54 original()55 const ITextSource* original() const 56 { 57 return parent() == nullptr? this : parent()->original(); 58 } 59 originalStartPos()60 const int originalStartPos() const 61 { 62 return parent() == nullptr? 0 : parent()->parent() == nullptr? parentPos() : parent()->originalStartPos(); 63 } 64 }; 65 66 67 #endif // ITEXTSOURCE_H 68