fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / sd / source / core / PageListWatcher.cxx
blobcd4f9ffe62bb9937e505a0f11cd5bf9314f09843
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "PageListWatcher.hxx"
23 #include "sdpage.hxx"
24 #include <tools/debug.hxx>
25 #include <svx/svdmodel.hxx>
27 //////////////////////////////////////////////////////////////////////////////
29 void ImpPageListWatcher::ImpRecreateSortedPageListOnDemand()
31 // clear vectors
32 maPageVectorStandard.clear();
33 maPageVectorNotes.clear();
34 mpHandoutPage = 0L;
35 mnVisiblePageCount = -1;
37 // build up vectors again
38 const sal_uInt32 nPageCount(ImpGetPageCount());
40 for(sal_uInt32 a(0L); a < nPageCount; a++)
42 SdPage* pCandidate = ImpGetPage(a);
43 DBG_ASSERT(pCandidate, "ImpPageListWatcher::ImpRecreateSortedPageListOnDemand: Invalid PageList in Model (!)");
45 switch(pCandidate->GetPageKind())
47 case PK_STANDARD:
49 maPageVectorStandard.push_back(pCandidate);
50 if (!pCandidate->IsExcluded()) mnVisiblePageCount++;
51 break;
53 case PK_NOTES:
55 maPageVectorNotes.push_back(pCandidate);
56 break;
58 case PK_HANDOUT:
60 DBG_ASSERT(!mpHandoutPage, "ImpPageListWatcher::ImpRecreateSortedPageListOnDemand: Two Handout pages in PageList of Model (!)");
61 mpHandoutPage = pCandidate;
62 break;
67 // set to valid
68 mbPageListValid = sal_True;
71 ImpPageListWatcher::ImpPageListWatcher(const SdrModel& rModel)
72 : mrModel(rModel),
73 mpHandoutPage(0L),
74 mbPageListValid(sal_False)
78 ImpPageListWatcher::~ImpPageListWatcher()
82 SdPage* ImpPageListWatcher::GetSdPage(PageKind ePgKind, sal_uInt32 nPgNum)
84 SdPage* pRetval(0L);
86 if(!mbPageListValid)
88 ImpRecreateSortedPageListOnDemand();
91 switch(ePgKind)
93 case PK_STANDARD:
95 if( nPgNum < (sal_uInt32)maPageVectorStandard.size() )
96 pRetval = maPageVectorStandard[nPgNum];
97 else
99 DBG_ASSERT(nPgNum <= maPageVectorStandard.size(),
100 "ImpPageListWatcher::GetSdPage(PK_STANDARD): access out of range");
101 DBG_WARNING2 (" %d > %d",
102 nPgNum, nPgNum<maPageVectorStandard.size());
104 break;
106 case PK_NOTES:
108 if( nPgNum < (sal_uInt32)maPageVectorNotes.size() )
109 pRetval = maPageVectorNotes[nPgNum];
110 else
112 DBG_ASSERT(nPgNum <= maPageVectorNotes.size(),
113 "ImpPageListWatcher::GetSdPage(PK_NOTES): access out of range");
114 DBG_WARNING2(" %d > %d",
115 nPgNum, nPgNum<maPageVectorNotes.size());
117 break;
119 case PK_HANDOUT:
121 // #11420# for models used to transfer drawing shapes via clipboard its ok to not have a handout page
122 DBG_ASSERT(nPgNum == 0L, "ImpPageListWatcher::GetSdPage: access to non existing handout page (!)");
123 if (nPgNum == 0)
124 pRetval = mpHandoutPage;
125 else
127 DBG_ASSERT(nPgNum == 0L,
128 "ImpPageListWatcher::GetSdPage: access to non existing handout page (!)");
130 break;
134 return pRetval;
137 sal_uInt32 ImpPageListWatcher::GetSdPageCount(PageKind ePgKind)
139 sal_uInt32 nRetval(0L);
141 if(!mbPageListValid)
143 ImpRecreateSortedPageListOnDemand();
146 switch(ePgKind)
148 case PK_STANDARD:
150 nRetval = maPageVectorStandard.size();
151 break;
153 case PK_NOTES:
155 nRetval = maPageVectorNotes.size();
156 break;
158 case PK_HANDOUT:
160 if(mpHandoutPage)
162 nRetval = 1L;
165 break;
169 return nRetval;
173 sal_uInt32 ImpPageListWatcher::GetVisibleSdPageCount()
175 sal_uInt32 nVisiblePageCount = 0;
177 // build up vectors again
178 const sal_uInt32 nPageCount(ImpGetPageCount());
180 for(sal_uInt32 a(0L); a < nPageCount; a++)
182 SdPage* pCandidate = ImpGetPage(a);
183 if ((pCandidate->GetPageKind() == PK_STANDARD)&&(!pCandidate->IsExcluded())) nVisiblePageCount++;
185 return nVisiblePageCount;
188 //////////////////////////////////////////////////////////////////////////////
190 sal_uInt32 ImpDrawPageListWatcher::ImpGetPageCount() const
192 return (sal_uInt32)mrModel.GetPageCount();
195 SdPage* ImpDrawPageListWatcher::ImpGetPage(sal_uInt32 nIndex) const
197 return (SdPage*)mrModel.GetPage((sal_uInt16)nIndex);
200 ImpDrawPageListWatcher::ImpDrawPageListWatcher(const SdrModel& rModel)
201 : ImpPageListWatcher(rModel)
205 ImpDrawPageListWatcher::~ImpDrawPageListWatcher()
209 //////////////////////////////////////////////////////////////////////////////
211 sal_uInt32 ImpMasterPageListWatcher::ImpGetPageCount() const
213 return (sal_uInt32)mrModel.GetMasterPageCount();
216 SdPage* ImpMasterPageListWatcher::ImpGetPage(sal_uInt32 nIndex) const
218 return (SdPage*)mrModel.GetMasterPage((sal_uInt16)nIndex);
221 ImpMasterPageListWatcher::ImpMasterPageListWatcher(const SdrModel& rModel)
222 : ImpPageListWatcher(rModel)
226 ImpMasterPageListWatcher::~ImpMasterPageListWatcher()
230 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */