LibreOffice Module sd (master) 1
PageListWatcher.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include "PageListWatcher.hxx"
21
22#include <sdpage.hxx>
23#include <tools/debug.hxx>
24#include <svx/svdmodel.hxx>
25#include <sal/log.hxx>
26
28{
29 // clear vectors
31 maPageVectorNotes.clear();
32 mpHandoutPage = nullptr;
33
34 // build up vectors again
35 const sal_uInt32 nPageCount(ImpGetPageCount());
36
37 for(sal_uInt32 a(0); a < nPageCount; a++)
38 {
39 SdPage* pCandidate = ImpGetPage(a);
40 DBG_ASSERT(pCandidate, "ImpPageListWatcher::ImpRecreateSortedPageListOnDemand: Invalid PageList in Model (!)");
41
42 switch(pCandidate->GetPageKind())
43 {
45 {
46 maPageVectorStandard.push_back(pCandidate);
47 break;
48 }
49 case PageKind::Notes:
50 {
51 maPageVectorNotes.push_back(pCandidate);
52 break;
53 }
55 {
56 DBG_ASSERT(!mpHandoutPage, "ImpPageListWatcher::ImpRecreateSortedPageListOnDemand: Two Handout pages in PageList of Model (!)");
57 mpHandoutPage = pCandidate;
58 break;
59 }
60 }
61 }
62
63 // set to valid
64 mbPageListValid = true;
65}
66
68 : mrModel(rModel)
69 , mpHandoutPage(nullptr)
70 , mbPageListValid(false)
71{
72}
73
75{
76}
77
78SdPage* ImpPageListWatcher::GetSdPage(PageKind ePgKind, sal_uInt32 nPgNum)
79{
80 SdPage* pRetval(nullptr);
81
83 {
85 }
86
87 switch(ePgKind)
88 {
90 {
91 if( nPgNum < static_cast<sal_uInt32>(maPageVectorStandard.size()) )
92 pRetval = maPageVectorStandard[nPgNum];
93 else
94 {
95 SAL_INFO( "sd.core",
96 "ImpPageListWatcher::GetSdPage(PageKind::Standard): page number " << nPgNum << " >= " << maPageVectorStandard.size() );
97 }
98 break;
99 }
100 case PageKind::Notes:
101 {
102 if( nPgNum < static_cast<sal_uInt32>(maPageVectorNotes.size()) )
103 pRetval = maPageVectorNotes[nPgNum];
104 else
105 {
106 SAL_INFO( "sd.core",
107 "ImpPageListWatcher::GetSdPage(PageKind::Notes): page number " << nPgNum << " >= " << maPageVectorNotes.size() );
108 }
109 break;
110 }
112 {
113 // #11420# for models used to transfer drawing shapes via clipboard it's ok to not have a handout page
114 DBG_ASSERT(nPgNum == 0, "ImpPageListWatcher::GetSdPage: access to non existing handout page (!)");
115 if (nPgNum == 0)
116 pRetval = mpHandoutPage;
117 else
118 {
119 DBG_ASSERT(nPgNum == 0,
120 "ImpPageListWatcher::GetSdPage: access to non existing handout page (!)");
121 }
122 break;
123 }
124 }
125
126 return pRetval;
127}
128
130{
131 sal_uInt32 nRetval(0);
132
133 if(!mbPageListValid)
134 {
136 }
137
138 switch(ePgKind)
139 {
141 {
142 nRetval = maPageVectorStandard.size();
143 break;
144 }
145 case PageKind::Notes:
146 {
147 nRetval = maPageVectorNotes.size();
148 break;
149 }
151 {
152 if(mpHandoutPage)
153 {
154 nRetval = 1;
155 }
156
157 break;
158 }
159 }
160
161 return nRetval;
162}
163
165{
166 sal_uInt32 nVisiblePageCount = 0;
167
168 // build up vectors again
169 const sal_uInt32 nPageCount(ImpGetPageCount());
170
171 for(sal_uInt32 a(0); a < nPageCount; a++)
172 {
173 SdPage* pCandidate = ImpGetPage(a);
174 if ((pCandidate->GetPageKind() == PageKind::Standard)&&(!pCandidate->IsExcluded())) nVisiblePageCount++;
175 }
176 return nVisiblePageCount;
177}
178
180{
181 return static_cast<sal_uInt32>(mrModel.GetPageCount());
182}
183
185{
186 return const_cast<SdPage*>(static_cast<const SdPage*>(mrModel.GetPage(static_cast<sal_uInt16>(nIndex))));
187}
188
190: ImpPageListWatcher(rModel)
191{
192}
193
195{
196}
197
199{
200 return static_cast<sal_uInt32>(mrModel.GetMasterPageCount());
201}
202
204{
205 return const_cast<SdPage*>(static_cast<const SdPage*>(mrModel.GetMasterPage(static_cast<sal_uInt16>(nIndex))));
206}
207
209: ImpPageListWatcher(rModel)
210{
211}
212
214{
215}
216
217/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ChartModel & mrModel
ImpDrawPageListWatcher(const SdrModel &rModel)
virtual ~ImpDrawPageListWatcher() override
virtual SdPage * ImpGetPage(sal_uInt32 nIndex) const override
Return the page with the given index.
virtual sal_uInt32 ImpGetPageCount() const override
virtual ~ImpMasterPageListWatcher() override
ImpMasterPageListWatcher(const SdrModel &rModel)
virtual SdPage * ImpGetPage(sal_uInt32 nIndex) const override
Return the page with the given index.
virtual sal_uInt32 ImpGetPageCount() const override
Maintain a map of page indices to page objects for faster access that remains valid during deletions ...
SdPageVector maPageVectorNotes
SdPageVector maPageVectorStandard
virtual SdPage * ImpGetPage(sal_uInt32 nIndex) const =0
Return the page with the given index.
virtual sal_uInt32 ImpGetPageCount() const =0
virtual ~ImpPageListWatcher()
sal_uInt32 GetSdPageCount(PageKind ePgKind)
SdPage * GetSdPage(PageKind ePgKind, sal_uInt32 nPgNum)
sal_uInt32 GetVisibleSdPageCount() const
void ImpRecreateSortedPageListOnDemand()
ImpPageListWatcher(const SdrModel &rModel)
const SdrModel & mrModel
PageKind GetPageKind() const
Definition: sdpage.hxx:205
bool IsExcluded() const
Definition: sdpage.hxx:223
const SdrPage * GetMasterPage(sal_uInt16 nPgNum) const
sal_uInt16 GetMasterPageCount() const
const SdrPage * GetPage(sal_uInt16 nPgNum) const
sal_uInt16 GetPageCount() const
#define DBG_ASSERT(sCon, aError)
sal_Int32 nIndex
uno_Any a
#define SAL_INFO(area, stream)
PageKind
Definition: pres.hxx:45