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