1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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"
24 #include <tools/debug.hxx>
25 #include <svx/svdmodel.hxx>
27 //////////////////////////////////////////////////////////////////////////////
29 void ImpPageListWatcher::ImpRecreateSortedPageListOnDemand()
32 maPageVectorStandard
.clear();
33 maPageVectorNotes
.clear();
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())
49 maPageVectorStandard
.push_back(pCandidate
);
50 if (!pCandidate
->IsExcluded()) mnVisiblePageCount
++;
55 maPageVectorNotes
.push_back(pCandidate
);
60 DBG_ASSERT(!mpHandoutPage
, "ImpPageListWatcher::ImpRecreateSortedPageListOnDemand: Two Handout pages in PageList of Model (!)");
61 mpHandoutPage
= pCandidate
;
68 mbPageListValid
= sal_True
;
71 ImpPageListWatcher::ImpPageListWatcher(const SdrModel
& rModel
)
74 mbPageListValid(sal_False
)
78 ImpPageListWatcher::~ImpPageListWatcher()
82 SdPage
* ImpPageListWatcher::GetSdPage(PageKind ePgKind
, sal_uInt32 nPgNum
)
88 ImpRecreateSortedPageListOnDemand();
95 if( nPgNum
< (sal_uInt32
)maPageVectorStandard
.size() )
96 pRetval
= maPageVectorStandard
[nPgNum
];
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());
108 if( nPgNum
< (sal_uInt32
)maPageVectorNotes
.size() )
109 pRetval
= maPageVectorNotes
[nPgNum
];
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());
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 (!)");
124 pRetval
= mpHandoutPage
;
127 DBG_ASSERT(nPgNum
== 0L,
128 "ImpPageListWatcher::GetSdPage: access to non existing handout page (!)");
137 sal_uInt32
ImpPageListWatcher::GetSdPageCount(PageKind ePgKind
)
139 sal_uInt32
nRetval(0L);
143 ImpRecreateSortedPageListOnDemand();
150 nRetval
= maPageVectorStandard
.size();
155 nRetval
= maPageVectorNotes
.size();
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: */