1 /* This file is part of the Calligra project
2  * Copyright (C) 2008, 2010 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; either
7  * version 2 of the License, or (at your option) any later version.
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 KWPageManagerPrivate_H
20 #define KWPageManagerPrivate_H
21 
22 #include "KWPageStyle.h"
23 #include "KWPage.h"
24 
25 #include <QHash>
26 #include <QMap>
27 
28 class KWPageManagerPrivate
29 {
30 public:
31     struct Page
32     {
PagePage33         Page()
34             : pageSide(KWPage::Right),
35             orientation(KoPageFormat::Portrait),
36             textDirection(KoText::InheritDirection),
37             pageNumber(1),
38             autoGenerated(0)
39         {
40         }
41         KWPageStyle style;
42         KWPage::PageSide pageSide;
43         KoPageFormat::Orientation orientation;
44         KoText::Direction textDirection;
45         uint pageNumber : 20; // set by the append-page and overwritten by the text-layout
46         uint autoGenerated : 1; // bool to signify words having generated it
47         uint padding : 11;
48         QRectF contentRect;
49     };
50 
51     KWPageManagerPrivate();
52 
53     void setPageOffset(int pageNum, qreal offset);
54     qreal pageOffset(int pageNum) const;
55 
56     void setVisiblePageNumber(int pageId, int newPageNumber);
57 
58     void insertPage(const Page &page);
59 
60     // use a sorted map to find page the identifier for page objects based on the page number.
61     QMap<int, int> pageNumbers; // page number to pageId
62 
63     // use a fast access hash to store the page objects, sorted by their identifier
64     QHash<int, Page> pages; // pageId to page struct
65 
66     QMap<int, int> visiblePageNumbers;
67 
68     int lastId; // pageIds are distributed serially,
69 
70     QHash<QString, KWPageStyle> pageStyles;
71     QHash<QString, QString> pageStyleNames; // map display-name to name
72     KoInsets padding;
73     KWPageStyle defaultPageStyle;
74     QHash<int, qreal> pageOffsets;
75     QHash<int, qreal> pageHeights;
76 };
77 
78 #endif
79