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 .
20 #include "accfrmobjslist.hxx"
22 #include "acccontext.hxx"
24 #include <pagefrm.hxx>
25 #include <sortedobjs.hxx>
26 #include <anchoredobject.hxx>
28 using namespace ::sw::access
;
30 SwAccessibleChildSList_const_iterator::SwAccessibleChildSList_const_iterator(
31 const SwAccessibleChildSList
& rLst
,
32 SwAccessibleMap
& rAccMap
)
34 m_aCurr( m_rList
.GetFrame().GetLower() ),
37 if( !m_aCurr
.GetSwFrame() )
39 const SwFrame
& rFrame
= m_rList
.GetFrame();
40 if( rFrame
.IsPageFrame() )
42 const SwPageFrame
& rPgFrame
= static_cast< const SwPageFrame
& >( rFrame
);
43 const SwSortedObjs
*pObjs
= rPgFrame
.GetSortedObjs();
44 if( pObjs
&& pObjs
->size() )
46 m_aCurr
= (*pObjs
)[m_nNextObj
++]->GetDrawObj();
49 else if( rFrame
.IsTextFrame() )
51 const SwSortedObjs
*pObjs
= rFrame
.GetDrawObjs();
52 if ( pObjs
&& pObjs
->size() )
54 m_aCurr
= (*pObjs
)[m_nNextObj
++]->GetDrawObj();
55 while( m_aCurr
.IsValid() && !m_aCurr
.IsBoundAsChar() )
57 m_aCurr
= (m_nNextObj
< pObjs
->size())
58 ? (*pObjs
)[m_nNextObj
++]->GetDrawObj()
59 : static_cast< const SdrObject
*>( nullptr );
62 if ( !m_aCurr
.IsValid() )
64 ::rtl::Reference
< SwAccessibleContext
> xAccImpl
=
65 rAccMap
.GetContextImpl( &rFrame
, false );
68 SwAccessibleContext
* pAccImpl
= xAccImpl
.get();
69 m_aCurr
= SwAccessibleChild( pAccImpl
->GetAdditionalAccessibleChild( 0 ) );
76 if( m_rList
.IsVisibleChildrenOnly() )
78 // Find the first visible
79 while( m_aCurr
.IsValid() &&
80 !m_aCurr
.AlwaysIncludeAsChild() &&
81 !m_aCurr
.GetBox( rAccMap
).Overlaps( m_rList
.GetVisArea() ) )
88 SwAccessibleChildSList_const_iterator
& SwAccessibleChildSList_const_iterator::next()
90 bool bNextTaken( true );
91 if( m_aCurr
.GetDrawObject() || m_aCurr
.GetWindow() )
95 else if( m_aCurr
.GetSwFrame() )
97 m_aCurr
= m_aCurr
.GetSwFrame()->GetNext();
98 if( !m_aCurr
.GetSwFrame() )
106 const SwFrame
& rFrame
= m_rList
.GetFrame();
107 if( rFrame
.IsPageFrame() )
109 const SwPageFrame
& rPgFrame
= static_cast< const SwPageFrame
& >( rFrame
);
110 const SwSortedObjs
*pObjs
= rPgFrame
.GetSortedObjs();
111 m_aCurr
= ( pObjs
&& m_nNextObj
< pObjs
->size() )
112 ? (*pObjs
)[m_nNextObj
++]->GetDrawObj()
113 : static_cast< const SdrObject
*>( nullptr );
115 else if( rFrame
.IsTextFrame() )
117 const SwSortedObjs
* pObjs
= rFrame
.GetDrawObjs();
118 const size_t nObjsCount
= pObjs
? pObjs
->size() : 0;
119 m_aCurr
= ( pObjs
&& m_nNextObj
< nObjsCount
)
120 ? (*pObjs
)[m_nNextObj
++]->GetDrawObj()
121 : static_cast< const SdrObject
*>( nullptr );
122 while( m_aCurr
.IsValid() && !m_aCurr
.IsBoundAsChar() )
124 m_aCurr
= ( m_nNextObj
< nObjsCount
)
125 ? (*pObjs
)[m_nNextObj
++]->GetDrawObj()
126 : static_cast< const SdrObject
*>( nullptr );
128 if ( !m_aCurr
.IsValid() )
130 ::rtl::Reference
< SwAccessibleContext
> xAccImpl
=
131 m_rList
.GetAccMap().GetContextImpl( &rFrame
, false );
134 SwAccessibleContext
* pAccImpl
= xAccImpl
.get();
135 m_aCurr
= SwAccessibleChild( pAccImpl
->GetAdditionalAccessibleChild( m_nNextObj
- nObjsCount
) );
145 SwAccessibleChildSList_const_iterator
& SwAccessibleChildSList_const_iterator::next_visible()
148 while( m_aCurr
.IsValid() &&
149 !m_aCurr
.AlwaysIncludeAsChild() &&
150 !m_aCurr
.GetBox( m_rList
.GetAccMap() ).Overlaps( m_rList
.GetVisArea() ) )
158 SwAccessibleChildSList_const_iterator
& SwAccessibleChildSList_const_iterator::operator++()
160 return m_rList
.IsVisibleChildrenOnly() ? next_visible() : next();
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */