xref: /trunk/main/sd/source/core/PageListWatcher.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef PAGE_LIST_WATCHER_HXX
29 #define PAGE_LIST_WATCHER_HXX
30 
31 #include "pres.hxx"
32 #include <sal/types.h>
33 #include <vector>
34 
35 class SdPage;
36 class SdrModel;
37 
38 /** Maintain a map of page indices to page objects for faster access that
39     remains valid during deletions and insertions of pages (#109538#).
40 */
41 class ImpPageListWatcher
42 {
43 protected:
44     // typedefs for a vector of SdPages
45     typedef ::std::vector< SdPage* > SdPageVector;
46 
47     const SdrModel&                 mrModel;
48 
49     SdPageVector                    maPageVectorStandard;
50     SdPageVector                    maPageVectorNotes;
51     SdPage*                         mpHandoutPage;
52 
53     sal_Bool                        mbPageListValid;
54 
55     void ImpRecreateSortedPageListOnDemand();
56     virtual sal_uInt32 ImpGetPageCount() const = 0;
57 
58     /** Return the page with the given index.
59         @param nIndex
60             When given an invalid index then NULL is returned.
61     */
62     virtual SdPage* ImpGetPage (sal_uInt32 nIndex) const = 0;
63 
64 public:
65     ImpPageListWatcher(const SdrModel& rModel);
66     virtual ~ImpPageListWatcher();
67 
68     void Invalidate() { mbPageListValid = sal_False; }
69     SdPage* GetSdPage(PageKind ePgKind, sal_uInt32 nPgNum = 0L);
70     sal_uInt32 GetSdPageCount(PageKind ePgKind);
71 };
72 
73 //////////////////////////////////////////////////////////////////////////////
74 
75 class ImpDrawPageListWatcher : public ImpPageListWatcher
76 {
77 protected:
78     virtual sal_uInt32 ImpGetPageCount() const;
79     virtual SdPage* ImpGetPage(sal_uInt32 nIndex) const;
80 
81 public:
82     ImpDrawPageListWatcher(const SdrModel& rModel);
83     virtual ~ImpDrawPageListWatcher();
84 };
85 
86 //////////////////////////////////////////////////////////////////////////////
87 
88 class ImpMasterPageListWatcher : public ImpPageListWatcher
89 {
90 protected:
91     virtual sal_uInt32 ImpGetPageCount() const;
92     virtual SdPage* ImpGetPage(sal_uInt32 nIndex) const;
93 
94 public:
95     ImpMasterPageListWatcher(const SdrModel& rModel);
96     virtual ~ImpMasterPageListWatcher();
97 };
98 
99 #endif
100