kword

KWPageManager.h

00001 /* This file is part of the KOffice project
00002  * Copyright (C) 2005 Thomas Zander <zander@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; version 2.
00007 
00008  * This library is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011  * Library General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU Library General Public License
00014  * along with this library; see the file COPYING.LIB.  If not, write to
00015  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016  * Boston, MA 02110-1301, USA.
00017  */
00018 #ifndef kw_pagemanager_h
00019 #define kw_pagemanager_h
00020 
00021 #include "KoPageLayout.h"
00022 
00023 #include <qptrlist.h>
00024 
00025 class KWPage;
00026 class KoPoint;
00027 class KoRect;
00028 
00033 class KWPageManager {
00034 public:
00035     KWPageManager();
00036 
00038     int pageNumber(const KoRect *rect) const;
00040     int pageNumber(const KoRect &rect) const;
00042     int pageNumber(const KoPoint &point) const;
00046     int pageNumber(double ptY) const;
00048     int pageCount() const;
00050     int lastPageNumber() const;
00052     KWPage* page(int pageNumber) const;
00054     KWPage* page(const KoRect &rect) const;
00056     KWPage* page(const KoRect *frame) const;
00058     KWPage* page(const KoPoint &point) const;
00060     KWPage* page(double ptY) const;
00061 
00068     double topOfPage(int pageNumber) const; // in pt
00075     double bottomOfPage(int pageNumber) const; // in pt
00076 
00078     void setStartPage(int startPage);
00079 
00081     int startPage() const { return m_firstPage; }
00082 
00088     void setOnlyAllowAppend(bool appendOnly) { m_onlyAllowAppend = appendOnly; }
00093     bool onlyAllowAppend() { return m_onlyAllowAppend; }
00094 
00102     KWPage* insertPage(int pageNumber);
00104     KWPage* appendPage();
00105 
00107     void removePage(int pageNumber);
00109     void removePage(KWPage *page);
00110 
00112     const KoPageLayout pageLayout(int pageNumber) const;
00113 
00114     void setDefaultPage(const KoPageLayout &layout);
00115 
00122     KoPoint clipToDocument(const KoPoint &point);
00123 
00124 private:
00126     double pageOffset(int pageNumber, bool bottom) const;
00128     class PageList : public QPtrList<KWPage> {
00129     protected:
00130         virtual int compareItems(QPtrCollection::Item a, QPtrCollection::Item b);
00131     };
00132 
00133     PageList m_pageList;
00134     int m_firstPage;
00135     bool m_onlyAllowAppend; // true for WP style documents.
00136 
00137     KoPageLayout m_defaultPageLayout;
00138 
00139 friend class KWPage;
00140 };
00141 
00142 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys