F:/KPlato/koffice/libs/kotext/KoTextFormatter.h

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2001 David Faure <faure@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
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     // Called after formatting a paragraph
00043     virtual void postFormat( KoTextParag* parag );
00044 
00045     KoHyphenator* hyphenator() {
00046         return m_hyphenator;
00047     }
00048 private:
00049     KoHyphenator* m_hyphenator;
00050 };
00051 
00052 // Internal class for KoTextFormatter, holds all the temporary data
00053 // KoTextFormatter is basically the settings and the algorithm being used
00054 // KoTextFormatterCore is where the formatting really happens
00055 class KoTextFormatterCore
00056 {
00057 public:
00058     KoTextFormatterCore( KoTextFormatter* settings, KoTextDocument *doc, KoTextParag *parag, int start );
00059 
00060     bool format();
00061 
00062     // widthUsed is the width of the wider line (with the current
00063     // word-breaking, margins included, but e.g. centering not included).
00064     // Unused in KWord currently, this is however used by KPresenter's
00065     // "resize object to fit contents" feature.
00066     int widthUsed() const { return wused; }
00067     int resultY() const { return y; }
00068 
00069 protected:
00070     // Return ww (in LU) and pixelww (in pixels)
00071     // Should be called only once per char
00072     QPair<int, int> determineCharWidth();
00073 
00074     KoTextParagLineStart *koFormatLine(
00075         KoTextZoomHandler *zh,
00076         KoTextParag * /*parag*/, KoTextString *string, KoTextParagLineStart *line,
00077         KoTextStringChar *startChar, KoTextStringChar *lastChar, int align, int space );
00078  // TODO RTL SUPPORT
00079 #if 0
00080     KoTextParagLineStart *koBidiReorderLine(
00081         KoTextZoomHandler *zh,
00082         KoTextParag * /*parag*/, 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     // Total left margin for a given line
00090     // Takes into account parag's leftmargin, firstlinemargin and counter,
00091     // but not adjustMargins (application hook)
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; // always 0 currently
00101     int wused; // see widthUsed
00102     int y;
00103     int availableWidth;
00104     int maxY;
00105 
00106     // When moving a big item down, we might want to rollback
00107     // to the 'best position for it' if we can't make it fit anywhere else.
00108     QPair<int,int> maxAvailableWidth; // first=y  second=available width
00109 
00110     // Information on current char
00111     KoTextStringChar *c;
00112     int i; // index number (in the paragraph)
00113     int x; // X position (in LU)
00114 };
00115 
00116 #endif

Généré le Wed Nov 22 23:41:09 2006 pour KPlato par  doxygen 1.5.1-p1