update dev300-m58
[ooovba.git] / sw / source / core / access / accfrmobjslist.cxx
blob8b69b01375343691224e81ccae0375690f5c683a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: accfrmobjslist.cxx,v $
10 * $Revision: 1.7 $
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_sw.hxx"
35 #include <pagefrm.hxx>
36 // OD 2004-05-24 #i28701#
37 #include <sortedobjs.hxx>
38 #include <accfrmobjslist.hxx>
41 SwFrmOrObjSList_const_iterator::SwFrmOrObjSList_const_iterator(
42 const SwFrmOrObjSList& rLst, sal_Bool ) :
43 rList( rLst ), aCurr( rList.pFrm->GetLower() ), nNextObj( 0 )
45 if( !aCurr.GetSwFrm() )
47 if( rList.pFrm->IsPageFrm() )
49 const SwPageFrm *pPgFrm =
50 static_cast< const SwPageFrm * >( rList.pFrm );
51 const SwSortedObjs *pObjs = pPgFrm->GetSortedObjs();
52 if( pObjs && pObjs->Count() )
53 aCurr = (*pObjs)[nNextObj++]->GetDrawObj();
55 else if( rList.pFrm->IsTxtFrm() )
57 const SwSortedObjs *pObjs = rList.pFrm->GetDrawObjs();
58 if( pObjs && pObjs->Count() )
60 aCurr = (*pObjs)[nNextObj++]->GetDrawObj();
61 while( aCurr.IsValid() && !aCurr.IsBoundAsChar() )
62 aCurr = (nNextObj < pObjs->Count())
63 ? (*pObjs)[nNextObj++]->GetDrawObj()
64 : static_cast< const SdrObject *>( 0 );
69 if( rList.bVisibleOnly )
71 // Find the first visible
72 while( aCurr.IsValid() &&
73 !aCurr.GetBox().IsOver( rList.aVisArea ) )
74 next();
78 SwFrmOrObjSList_const_iterator& SwFrmOrObjSList_const_iterator::next()
80 sal_Bool bGetSdrObject = sal_False;
81 if( aCurr.GetSdrObject() )
83 bGetSdrObject = sal_True;
85 else if( aCurr.GetSwFrm() )
87 aCurr = aCurr.GetSwFrm()->GetNext();
88 if( !aCurr.GetSwFrm() )
89 bGetSdrObject = sal_True;
92 if( bGetSdrObject )
94 if( rList.pFrm->IsPageFrm() )
96 const SwPageFrm *pPgFrm =
97 static_cast< const SwPageFrm * >( rList.pFrm );
98 const SwSortedObjs *pObjs = pPgFrm->GetSortedObjs();
99 aCurr = (pObjs && nNextObj < pObjs->Count())
100 ? (*pObjs)[nNextObj++]->GetDrawObj()
101 : static_cast< const SdrObject *>( 0 );
103 else if( rList.pFrm->IsTxtFrm() )
105 const SwSortedObjs *pObjs = rList.pFrm->GetDrawObjs();
106 aCurr = (pObjs && nNextObj < pObjs->Count())
107 ? (*pObjs)[nNextObj++]->GetDrawObj()
108 : static_cast< const SdrObject *>( 0 );
109 while( aCurr.IsValid() && !aCurr.IsBoundAsChar() )
110 aCurr = (nNextObj < pObjs->Count())
111 ? (*pObjs)[nNextObj++]->GetDrawObj()
112 : static_cast< const SdrObject *>( 0 );
116 return *this;
119 SwFrmOrObjSList_const_iterator& SwFrmOrObjSList_const_iterator::next_visible()
121 next();
122 while( aCurr.IsValid() &&
123 !aCurr.GetBox().IsOver( rList.aVisArea ) )
124 next();
126 return *this;