1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: PageListWatcher.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include "PageListWatcher.hxx"
37 #include <tools/debug.hxx>
38 #include <svx/svdmodel.hxx>
40 //////////////////////////////////////////////////////////////////////////////
43 void ImpPageListWatcher::ImpRecreateSortedPageListOnDemand()
46 maPageVectorStandard
.clear();
47 maPageVectorNotes
.clear();
50 // build up vectors again
51 const sal_uInt32
nPageCount(ImpGetPageCount());
53 for(sal_uInt32
a(0L); a
< nPageCount
; a
++)
55 SdPage
* pCandidate
= ImpGetPage(a
);
56 DBG_ASSERT(pCandidate
, "ImpPageListWatcher::ImpRecreateSortedPageListOnDemand: Invalid PageList in Model (!)");
58 switch(pCandidate
->GetPageKind())
62 maPageVectorStandard
.push_back(pCandidate
);
67 maPageVectorNotes
.push_back(pCandidate
);
72 DBG_ASSERT(!mpHandoutPage
, "ImpPageListWatcher::ImpRecreateSortedPageListOnDemand: Two Handout pages in PageList of Model (!)");
73 mpHandoutPage
= pCandidate
;
80 mbPageListValid
= sal_True
;
83 ImpPageListWatcher::ImpPageListWatcher(const SdrModel
& rModel
)
86 mbPageListValid(sal_False
)
90 ImpPageListWatcher::~ImpPageListWatcher()
94 SdPage
* ImpPageListWatcher::GetSdPage(PageKind ePgKind
, sal_uInt32 nPgNum
)
100 ImpRecreateSortedPageListOnDemand();
107 if( nPgNum
< (sal_uInt32
)maPageVectorStandard
.size() )
108 pRetval
= maPageVectorStandard
[nPgNum
];
111 DBG_ASSERT(nPgNum
<= maPageVectorStandard
.size(),
112 "ImpPageListWatcher::GetSdPage(PK_STANDARD): access out of range");
113 DBG_WARNING2 (" %d > %d",
114 nPgNum
, nPgNum
<maPageVectorStandard
.size());
120 if( nPgNum
< (sal_uInt32
)maPageVectorNotes
.size() )
121 pRetval
= maPageVectorNotes
[nPgNum
];
124 DBG_ASSERT(nPgNum
<= maPageVectorNotes
.size(),
125 "ImpPageListWatcher::GetSdPage(PK_NOTES): access out of range");
126 DBG_WARNING2(" %d > %d",
127 nPgNum
, nPgNum
<maPageVectorNotes
.size());
133 // #11420# for models used to transfer drawing shapes via clipboard its
134 // ok to not have a handout page
135 // DBG_ASSERT(mpHandoutPage, "ImpPageListWatcher::GetSdPage: access to non existing handout page (!)");
136 DBG_ASSERT(nPgNum
== 0L, "ImpPageListWatcher::GetSdPage: access to non existing handout page (!)");
138 pRetval
= mpHandoutPage
;
141 DBG_ASSERT(nPgNum
== 0L,
142 "ImpPageListWatcher::GetSdPage: access to non existing handout page (!)");
151 sal_uInt32
ImpPageListWatcher::GetSdPageCount(PageKind ePgKind
)
153 sal_uInt32
nRetval(0L);
157 ImpRecreateSortedPageListOnDemand();
164 nRetval
= maPageVectorStandard
.size();
169 nRetval
= maPageVectorNotes
.size();
186 //////////////////////////////////////////////////////////////////////////////
188 sal_uInt32
ImpDrawPageListWatcher::ImpGetPageCount() const
190 return (sal_uInt32
)mrModel
.GetPageCount();
193 SdPage
* ImpDrawPageListWatcher::ImpGetPage(sal_uInt32 nIndex
) const
195 return (SdPage
*)mrModel
.GetPage((sal_uInt16
)nIndex
);
198 ImpDrawPageListWatcher::ImpDrawPageListWatcher(const SdrModel
& rModel
)
199 : ImpPageListWatcher(rModel
)
203 ImpDrawPageListWatcher::~ImpDrawPageListWatcher()
207 //////////////////////////////////////////////////////////////////////////////
209 sal_uInt32
ImpMasterPageListWatcher::ImpGetPageCount() const
211 return (sal_uInt32
)mrModel
.GetMasterPageCount();
214 SdPage
* ImpMasterPageListWatcher::ImpGetPage(sal_uInt32 nIndex
) const
216 return (SdPage
*)mrModel
.GetMasterPage((sal_uInt16
)nIndex
);
219 ImpMasterPageListWatcher::ImpMasterPageListWatcher(const SdrModel
& rModel
)
220 : ImpPageListWatcher(rModel
)
224 ImpMasterPageListWatcher::~ImpMasterPageListWatcher()