Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 :
21 : #include <accfrmobjslist.hxx>
22 : #include <accmap.hxx>
23 : #include <acccontext.hxx>
24 :
25 : #include <pagefrm.hxx>
26 : #include <sortedobjs.hxx>
27 : #include <anchoredobject.hxx>
28 :
29 : using namespace ::sw::access;
30 :
31 0 : SwAccessibleChildSList_const_iterator::SwAccessibleChildSList_const_iterator(
32 : const SwAccessibleChildSList& rLst,
33 : SwAccessibleMap& rAccMap )
34 : : rList( rLst ),
35 0 : aCurr( rList.GetFrm().GetLower() ),
36 0 : nNextObj( 0 )
37 : {
38 0 : if( !aCurr.GetSwFrm() )
39 : {
40 0 : const SwFrm& rFrm = rList.GetFrm();
41 0 : if( rFrm.IsPageFrm() )
42 : {
43 0 : const SwPageFrm& rPgFrm = static_cast< const SwPageFrm& >( rFrm );
44 0 : const SwSortedObjs *pObjs = rPgFrm.GetSortedObjs();
45 0 : if( pObjs && pObjs->Count() )
46 : {
47 0 : aCurr = (*pObjs)[nNextObj++]->GetDrawObj();
48 : }
49 : }
50 0 : else if( rFrm.IsTxtFrm() )
51 : {
52 0 : const SwSortedObjs *pObjs = rFrm.GetDrawObjs();
53 0 : if ( pObjs && pObjs->Count() )
54 : {
55 0 : aCurr = (*pObjs)[nNextObj++]->GetDrawObj();
56 0 : while( aCurr.IsValid() && !aCurr.IsBoundAsChar() )
57 : {
58 0 : aCurr = (nNextObj < pObjs->Count())
59 0 : ? (*pObjs)[nNextObj++]->GetDrawObj()
60 0 : : static_cast< const SdrObject *>( 0 );
61 : }
62 : }
63 0 : if ( !aCurr.IsValid() )
64 : {
65 : ::rtl::Reference < SwAccessibleContext > xAccImpl =
66 0 : rAccMap.GetContextImpl( &rFrm, sal_False );
67 0 : if( xAccImpl.is() )
68 : {
69 0 : SwAccessibleContext* pAccImpl = xAccImpl.get();
70 0 : aCurr = SwAccessibleChild( pAccImpl->GetAdditionalAccessibleChild( 0 ) );
71 0 : ++nNextObj;
72 0 : }
73 : }
74 : }
75 : }
76 :
77 0 : if( rList.IsVisibleChildrenOnly() )
78 : {
79 : // Find the first visible
80 0 : while( aCurr.IsValid() &&
81 0 : !aCurr.AlwaysIncludeAsChild() &&
82 0 : !aCurr.GetBox( rAccMap ).IsOver( rList.GetVisArea() ) )
83 : {
84 0 : next();
85 : }
86 : }
87 0 : }
88 :
89 0 : SwAccessibleChildSList_const_iterator& SwAccessibleChildSList_const_iterator::next()
90 : {
91 0 : bool bNextTaken( true );
92 0 : if( aCurr.GetDrawObject() || aCurr.GetWindow() )
93 : {
94 0 : bNextTaken = false;
95 : }
96 0 : else if( aCurr.GetSwFrm() )
97 : {
98 0 : aCurr = aCurr.GetSwFrm()->GetNext();
99 0 : if( !aCurr.GetSwFrm() )
100 : {
101 0 : bNextTaken = false;
102 : }
103 : }
104 :
105 0 : if( !bNextTaken )
106 : {
107 0 : const SwFrm& rFrm = rList.GetFrm();
108 0 : if( rFrm.IsPageFrm() )
109 : {
110 0 : const SwPageFrm& rPgFrm = static_cast< const SwPageFrm& >( rFrm );
111 0 : const SwSortedObjs *pObjs = rPgFrm.GetSortedObjs();
112 0 : aCurr = ( pObjs && nNextObj < pObjs->Count() )
113 0 : ? (*pObjs)[nNextObj++]->GetDrawObj()
114 0 : : static_cast< const SdrObject *>( 0 );
115 : }
116 0 : else if( rFrm.IsTxtFrm() )
117 : {
118 0 : const SwSortedObjs* pObjs = rFrm.GetDrawObjs();
119 0 : const sal_uInt32 nObjsCount = pObjs ? pObjs->Count() : 0;
120 : aCurr = ( pObjs && nNextObj < nObjsCount )
121 0 : ? (*pObjs)[nNextObj++]->GetDrawObj()
122 0 : : static_cast< const SdrObject *>( 0 );
123 0 : while( aCurr.IsValid() && !aCurr.IsBoundAsChar() )
124 : {
125 : aCurr = ( nNextObj < nObjsCount )
126 0 : ? (*pObjs)[nNextObj++]->GetDrawObj()
127 0 : : static_cast< const SdrObject *>( 0 );
128 : }
129 0 : if ( !aCurr.IsValid() )
130 : {
131 : ::rtl::Reference < SwAccessibleContext > xAccImpl =
132 0 : rList.GetAccMap().GetContextImpl( &rFrm, sal_False );
133 0 : if( xAccImpl.is() )
134 : {
135 0 : SwAccessibleContext* pAccImpl = xAccImpl.get();
136 0 : aCurr = SwAccessibleChild( pAccImpl->GetAdditionalAccessibleChild( nNextObj - nObjsCount ) );
137 0 : ++nNextObj;
138 0 : }
139 : }
140 : }
141 : }
142 :
143 0 : return *this;
144 : }
145 :
146 0 : SwAccessibleChildSList_const_iterator& SwAccessibleChildSList_const_iterator::next_visible()
147 : {
148 0 : next();
149 0 : while( aCurr.IsValid() &&
150 0 : !aCurr.AlwaysIncludeAsChild() &&
151 0 : !aCurr.GetBox( rList.GetAccMap() ).IsOver( rList.GetVisArea() ) )
152 : {
153 0 : next();
154 : }
155 :
156 0 : return *this;
157 : }
158 :
159 0 : SwAccessibleChildSList_const_iterator& SwAccessibleChildSList_const_iterator::operator++()
160 : {
161 0 : return rList.IsVisibleChildrenOnly() ? next_visible() : next();
162 : }
163 :
164 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|