1
#ifndef KWFRAMELAYOUT_H
2
#define KWFRAMELAYOUT_H
17
// Maybe all that data should go into a KWHeaderFooterFrameSet
18
// (or rather a base class shared by KWFootNoteFrameSet....)
19
struct HeaderFooterFrameset {
20
enum OddEvenAll { Even, Odd, All };
22
HeaderFooterFrameset( KWTextFrameSet* fs, int start, int end,
23
double spacing, OddEvenAll oea = All );
25
// Frameset. Also gives the type (header, footer, footnote).
26
KWTextFrameSet* m_frameset;
28
// Future features - but already used for "first page" stuff
30
int m_endAtPage; // (-1 for no end)
33
OddEvenAll m_oddEvenAll;
38
// Space between this frame and the next one
39
// (the one at bottom for headers, the one on top for footers/footnotes).
40
// e.g. ptHeaderBodySpacing for headers/footers
43
// Minimum Y value - for footnotes
46
// True once the footnote has been correctly positionned and
47
// shouldn't be moved by checkFootNotes anymore.
50
// frame number for the given page.... -1 if no frame on that page
51
int frameNumberForPage( int page /* 0-based! */ ) const
53
if ( page < m_startAtPage || ( m_endAtPage != -1 && page > m_endAtPage ) )
55
int pg = page - m_startAtPage; // always >=0
56
// Note that 'page' is 0-based. This is why "Odd" looks for even numbers, and "Even" looks for odd numbers :}
57
switch (m_oddEvenAll) {
59
// we test page, not bg: even/odd is for the absolute page number, too confusing otherwise
61
return pg / 2; // page 0[+start] -> frame 0, page 2[+start] -> frame 1
66
return pg / 2; // page 1 -> 0, page 3 -> 1
70
return pg; // page 0[+start] -> frame 0, etc.
76
// the last frame we need, layout() will delete any frame after that
77
int lastFrameNumber( int lastPage ) const
79
if ( lastPage < m_startAtPage )
80
return -1; // we need none
82
if ( m_endAtPage > -1 )
83
pg = QMIN( m_endAtPage, pg );
84
pg -= m_startAtPage; // always >=0
86
switch (m_oddEvenAll) {
89
return pg / 2; // page 0 and 1 -> 0. page 2 and 3 -> 1.
91
return pg; // page 0 -> 0 etc. ;)
98
bool deleteFramesAfterLast( int lastPage );
103
* @param doc the KWDocument we're layouting
104
* @param headersFooters list of header and footer HFFs (see definition of HeaderFooterFrameset)
105
* @param footnotes list of footnotes framesets HFFs
106
* @param endnotes list of endnotes framesets HFFs
108
KWFrameLayout( KWDocument* doc, QPtrList<HeaderFooterFrameset>& headersFooters,
109
QPtrList<HeaderFooterFrameset>& footnotes, QPtrList<HeaderFooterFrameset>& endnotes )
110
: m_headersFooters( headersFooters ), m_footnotes( footnotes ), m_endnotes( endnotes ), m_doc( doc )
113
enum { DontRemovePages = 1 };
115
* The main method of this file. Do the frame layout.
116
* @param mainTextFrameSet if set, its frames will be resized. Usually: set in WP mode, not set in DTP mode.
117
* @param numColumns number of columns to create for the main textframeset. Only relevant if mainTextFrameSet!=0.
118
* @param fromPage first page to layout ( 0-based )
119
* @param toPage last page to layout ( 0-based )
120
* @param flags see enum above
122
void layout( KWFrameSet* mainTextFrameSet, int numColumns,
123
int fromPage, int toPage, uint flags );
126
void resizeOrCreateHeaderFooter( KWTextFrameSet* headerFooter, uint frameNumber, const KoRect& rect );
127
KoRect firstColumnRect( KWFrameSet* mainTextFrameSet, int pageNum, int numColumns ) const;
128
enum HasFootNotes { NoFootNote, WithFootNotes, NoChange };
129
bool resizeMainTextFrame( KWFrameSet* mainTextFrameSet, int pageNum, int numColumns, double ptColumnWidth, double ptColumnSpacing, double left, double top, double bottom, HasFootNotes hasFootNotes );
130
void checkFootNotes();
133
// A _ref_ to a list. Must remain alive as long as this object.
134
QPtrList<HeaderFooterFrameset>& m_headersFooters;
135
QPtrList<HeaderFooterFrameset>& m_footnotes;
136
QPtrList<HeaderFooterFrameset>& m_endnotes;
137
QMap<KWFrameSet *, bool> m_framesetsToUpdate;
139
int m_lastMainFramePage;