kword

KWFrameLayout.h
1/* This file is part of the KOffice project
2 * Copyright (C) 2002 David Faure <faure@kde.org>
3 * Copyright (C) 2005 Thomas Zander <zander@kde.org>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; version 2.
8
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19#ifndef KWFRAMELAYOUT_H
20#define KWFRAMELAYOUT_H
21
22#include <tqptrlist.h>
23#include <kdebug.h>
24#include <KoRect.h>
25#include <tqmap.h>
26
27class KWDocument;
28class KWFrameSet;
29class KWTextFrameSet;
30class KoRect;
31
32class KWFrameLayout
33{
34public:
35 // Maybe all that data should go into a KWHeaderFooterFrameSet
36 // (or rather a base class shared by KWFootNoteFrameSet....)
37 struct HeaderFooterFrameset {
38 enum OddEvenAll { Even, Odd, All };
39
40 HeaderFooterFrameset( KWTextFrameSet* fs, int start, int end,
41 double spacing, OddEvenAll oea = All );
42
43 // Frameset. Also gives the type (header, footer, footnote).
44 KWTextFrameSet* m_frameset;
45
46 // Future features - but already used for "first page" stuff
47 int m_startAtPage;
48 int m_endAtPage; // (-1 for no end)
49
50 // Odd/even/all
51 OddEvenAll m_oddEvenAll;
52
53 // Height in pt
54 double m_height;
55
56 // Space between this frame and the next one
57 // (the one at bottom for headers, the one on top for footers/footnotes).
58 // e.g. ptHeaderBodySpacing for headers/footers
59 double m_spacing;
60
61 // Minimum Y value - for footnotes
62 double m_minY;
63
64 // True once the footnote has been correctly positionned and
65 // shouldn't be moved by checkFootNotes anymore.
66 bool m_positioned;
67
68 // frame number for the given page.... -1 if no frame on that page
69 // The first frame is number 0.
70 int frameNumberForPage( int page ) const;
71 // The last frame we need (0-based), layout() will delete any frame after that
72 int lastFrameNumber( int lastPage ) const;
73
74 void debug();
75 bool deleteFramesAfterLast( int lastPage );
76 };
77
85 KWFrameLayout( KWDocument* doc, TQPtrList<HeaderFooterFrameset>& headersFooters,
86 TQPtrList<HeaderFooterFrameset>& footnotes, TQPtrList<HeaderFooterFrameset>& endnotes )
87 : m_headersFooters( headersFooters ), m_footnotes( footnotes ), m_endnotes( endnotes ), m_doc( doc )
88 {}
89
90 enum { DontRemovePages = 1 };
99 void layout( KWFrameSet* mainTextFrameSet, int numColumns,
100 int fromPage, int toPage, uint flags );
101
102protected:
103 void resizeOrCreateHeaderFooter( KWTextFrameSet* headerFooter, uint frameNumber, const KoRect& rect );
104 KoRect firstColumnRect( KWFrameSet* mainTextFrameSet, int pageNum, int numColumns ) const;
105 enum HasFootNotes { NoFootNote, WithFootNotes, NoChange };
106 bool resizeMainTextFrame( KWFrameSet* mainTextFrameSet, int pageNum, int numColumns, double ptColumnWidth, double ptColumnSpacing, double left, double top, double bottom, HasFootNotes hasFootNotes );
107 void checkFootNotes();
108
109private:
110 // A _ref_ to a list. Must remain alive as long as this object.
111 TQPtrList<HeaderFooterFrameset>& m_headersFooters;
112 TQPtrList<HeaderFooterFrameset>& m_footnotes;
113 TQPtrList<HeaderFooterFrameset>& m_endnotes;
114 TQMap<KWFrameSet *, bool> m_framesetsToUpdate;
115 KWDocument* m_doc;
116 int m_lastMainFramePage;
117};
118
119#endif
Class: KWFrameSet Base type, a frameset holds content as well as frames to show that content.
Definition KWFrameSet.h:62
Class: KWTextFrameSet Contains text (KoTextObject) and frames to display that text.