00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef kotextformatter_h
00021 #define kotextformatter_h
00022
00023 #include "KoRichText.h"
00024 class KoTextZoomHandler;
00025 class KoHyphenator;
00026
00034 class KOTEXT_EXPORT KoTextFormatter : public KoTextFormatterBase
00035 {
00036 public:
00037 KoTextFormatter();
00038 virtual ~KoTextFormatter();
00039
00040 virtual bool format( KoTextDocument *doc, KoTextParag *parag, int start, const QMap<int, KoTextParagLineStart*> &oldLineStarts, int& y, int& widthUsed );
00041
00042
00043 virtual void postFormat( KoTextParag* parag );
00044
00045 KoHyphenator* hyphenator() {
00046 return m_hyphenator;
00047 }
00048 private:
00049 KoHyphenator* m_hyphenator;
00050 };
00051
00052
00053
00054
00055 class KoTextFormatterCore
00056 {
00057 public:
00058 KoTextFormatterCore( KoTextFormatter* settings, KoTextDocument *doc, KoTextParag *parag, int start );
00059
00060 bool format();
00061
00062
00063
00064
00065
00066 int widthUsed() const { return wused; }
00067 int resultY() const { return y; }
00068
00069 protected:
00070
00071
00072 QPair<int, int> determineCharWidth();
00073
00074 KoTextParagLineStart *koFormatLine(
00075 KoTextZoomHandler *zh,
00076 KoTextParag * , KoTextString *string, KoTextParagLineStart *line,
00077 KoTextStringChar *startChar, KoTextStringChar *lastChar, int align, int space );
00078
00079 #if 0
00080 KoTextParagLineStart *koBidiReorderLine(
00081 KoTextZoomHandler *zh,
00082 KoTextParag * , KoTextString *text, KoTextParagLineStart *line,
00083 KoTextStringChar *startChar, KoTextStringChar *lastChar, int align, int space );
00084 #endif
00085
00086 void moveChar( KoTextStringChar& chr, KoTextZoomHandler *zh,
00087 int deltaX, int deltaPixelX );
00088
00089
00090
00091
00092 int leftMargin( bool firstLine, bool includeFirstLineMargin = true ) const;
00093 int rightMargin( bool firstLine ) const;
00094
00095
00096 private:
00097 KoTextFormatter* settings;
00098 KoTextDocument* doc;
00099 KoTextParag* parag;
00100 int start;
00101 int wused;
00102 int y;
00103 int availableWidth;
00104 int maxY;
00105
00106
00107
00108 QPair<int,int> maxAvailableWidth;
00109
00110
00111 KoTextStringChar *c;
00112 int i;
00113 int x;
00114 };
00115
00116 #endif