kword

KWPageManager.h
1/* This file is part of the KOffice project
2 * Copyright (C) 2005 Thomas Zander <zander@kde.org>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; version 2.
7
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Library General Public License for more details.
12 *
13 * You should have received a copy of the GNU Library General Public License
14 * along with this library; see the file COPYING.LIB. If not, write to
15 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 * Boston, MA 02110-1301, USA.
17 */
18#ifndef kw_pagemanager_h
19#define kw_pagemanager_h
20
21#include "KoPageLayout.h"
22
23#include <tqptrlist.h>
24
25class KWPage;
26class KoPoint;
27class KoRect;
28
33class KWPageManager {
34public:
35 KWPageManager();
36
38 int pageNumber(const KoRect *rect) const;
40 int pageNumber(const KoRect &rect) const;
42 int pageNumber(const KoPoint &point) const;
46 int pageNumber(double ptY) const;
48 int pageCount() const;
50 int lastPageNumber() const;
52 KWPage* page(int pageNumber) const;
54 KWPage* page(const KoRect &rect) const;
56 KWPage* page(const KoRect *frame) const;
58 KWPage* page(const KoPoint &point) const;
60 KWPage* page(double ptY) const;
61
68 double topOfPage(int pageNumber) const; // in pt
75 double bottomOfPage(int pageNumber) const; // in pt
76
78 void setStartPage(int startPage);
79
81 int startPage() const { return m_firstPage; }
82
88 void setOnlyAllowAppend(bool appendOnly) { m_onlyAllowAppend = appendOnly; }
93 bool onlyAllowAppend() { return m_onlyAllowAppend; }
94
105
107 void removePage(int pageNumber);
109 void removePage(KWPage *page);
110
112 const KoPageLayout pageLayout(int pageNumber) const;
113
114 void setDefaultPage(const KoPageLayout &layout);
115
122 KoPoint clipToDocument(const KoPoint &point);
123
124private:
126 double pageOffset(int pageNumber, bool bottom) const;
128 class PageList : public TQPtrList<KWPage> {
129 protected:
130 virtual int compareItems(TQPtrCollection::Item a, TQPtrCollection::Item b);
131 };
132
133 PageList m_pageList;
134 int m_firstPage;
135 bool m_onlyAllowAppend; // true for WP style documents.
136
137 KoPageLayout m_defaultPageLayout;
138
139friend class KWPage;
140};
141
142#endif
const KoPageLayout pageLayout(int pageNumber) const
return the effective pageLayout of pageNumber combining the default and the page specific ones
void setOnlyAllowAppend(bool appendOnly)
Register if new pages can only be appended after the last one and not somewhere in between.
double topOfPage(int pageNumber) const
Return the y-offset in this document of the top of page with pageNumber Note that pageNumber is NOT a...
KWPage * insertPage(int pageNumber)
Inserts a new page at the specified position in the document.
KoPoint clipToDocument(const KoPoint &point)
Returns the argument point, with altered coordinats if the point happens to be outside all pages.
void setStartPage(int startPage)
Set a new startpage for this document, renumbering all pages already added.
int pageNumber(const KoRect *rect) const
return pageNumber of frame, pagenumbers for a normal document start at 1.
KWPage * page(int pageNumber) const
return the KWPage of a specific page number. Returns 0 if page does not exist.
bool onlyAllowAppend()
return if new pages can only be appended after the last one and not somewhere in between.
KWPage * appendPage()
Append a new page at the end of the document.
int pageCount() const
return total number of pages in this document.
void removePage(int pageNumber)
Remove the page with pageNumber renumbering all pages after pages already added.
double bottomOfPage(int pageNumber) const
Return the y-offset in this document of the bottom of page with pageNumber Note that pageNumber is NO...
int startPage() const
return the first pagenumber of this document
int lastPageNumber() const
return the highest page number we have in this document.
This class represents a printed page of the document.
Definition KWPage.h:30