kword

KWFrameLayout.h

00001 /* This file is part of the KOffice project
00002  * Copyright (C) 2002 David Faure <faure@kde.org>
00003  * Copyright (C) 2005 Thomas Zander <zander@kde.org>
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Library General Public
00007  * License as published by the Free Software Foundation; version 2.
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 #ifndef KWFRAMELAYOUT_H
00020 #define KWFRAMELAYOUT_H
00021 
00022 #include <qptrlist.h>
00023 #include <kdebug.h>
00024 #include <KoRect.h>
00025 #include <qmap.h>
00026 
00027 class KWDocument;
00028 class KWFrameSet;
00029 class KWTextFrameSet;
00030 class KoRect;
00031 
00032 class KWFrameLayout
00033 {
00034 public:
00035     // Maybe all that data should go into a KWHeaderFooterFrameSet
00036     // (or rather a base class shared by KWFootNoteFrameSet....)
00037     struct HeaderFooterFrameset {
00038         enum OddEvenAll { Even, Odd, All };
00039 
00040         HeaderFooterFrameset( KWTextFrameSet* fs, int start, int end,
00041                               double spacing, OddEvenAll oea = All );
00042 
00043         // Frameset. Also gives the type (header, footer, footnote).
00044         KWTextFrameSet* m_frameset;
00045 
00046         // Future features - but already used for "first page" stuff
00047         int m_startAtPage;
00048         int m_endAtPage; // (-1 for no end)
00049 
00050         // Odd/even/all
00051         OddEvenAll m_oddEvenAll;
00052 
00053         // Height in pt
00054         double m_height;
00055 
00056         // Space between this frame and the next one
00057         // (the one at bottom for headers, the one on top for footers/footnotes).
00058         // e.g. ptHeaderBodySpacing for headers/footers
00059         double m_spacing;
00060 
00061         // Minimum Y value - for footnotes
00062         double m_minY;
00063 
00064         // True once the footnote has been correctly positionned and
00065         // shouldn't be moved by checkFootNotes anymore.
00066         bool m_positioned;
00067 
00068         // frame number for the given page.... -1 if no frame on that page
00069         // The first frame is number 0.
00070         int frameNumberForPage( int page ) const;
00071         // The last frame we need (0-based), layout() will delete any frame after that
00072         int lastFrameNumber( int lastPage ) const;
00073 
00074         void debug();
00075         bool deleteFramesAfterLast( int lastPage );
00076     };
00077 
00085     KWFrameLayout( KWDocument* doc, QPtrList<HeaderFooterFrameset>& headersFooters,
00086                    QPtrList<HeaderFooterFrameset>& footnotes, QPtrList<HeaderFooterFrameset>& endnotes )
00087         : m_headersFooters( headersFooters ), m_footnotes( footnotes ), m_endnotes( endnotes ), m_doc( doc )
00088         {}
00089 
00090     enum { DontRemovePages = 1 };
00099     void layout( KWFrameSet* mainTextFrameSet, int numColumns,
00100                  int fromPage, int toPage, uint flags );
00101 
00102 protected:
00103     void resizeOrCreateHeaderFooter( KWTextFrameSet* headerFooter, uint frameNumber, const KoRect& rect );
00104     KoRect firstColumnRect( KWFrameSet* mainTextFrameSet, int pageNum, int numColumns ) const;
00105     enum HasFootNotes { NoFootNote, WithFootNotes, NoChange };
00106     bool resizeMainTextFrame( KWFrameSet* mainTextFrameSet, int pageNum, int numColumns, double ptColumnWidth, double ptColumnSpacing, double left, double top, double bottom, HasFootNotes hasFootNotes );
00107     void checkFootNotes();
00108 
00109 private:
00110     // A _ref_ to a list. Must remain alive as long as this object.
00111     QPtrList<HeaderFooterFrameset>& m_headersFooters;
00112     QPtrList<HeaderFooterFrameset>& m_footnotes;
00113     QPtrList<HeaderFooterFrameset>& m_endnotes;
00114     QMap<KWFrameSet *, bool> m_framesetsToUpdate;
00115     KWDocument* m_doc;
00116     int m_lastMainFramePage;
00117 };
00118 
00119 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys