Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <accfrmobjslist.hxx>
31 : : #include <accmap.hxx>
32 : : #include <acccontext.hxx>
33 : :
34 : : #include <pagefrm.hxx>
35 : : #include <sortedobjs.hxx>
36 : : #include <anchoredobject.hxx>
37 : :
38 : : using namespace ::sw::access;
39 : :
40 : 1214 : SwAccessibleChildSList_const_iterator::SwAccessibleChildSList_const_iterator(
41 : : const SwAccessibleChildSList& rLst,
42 : : SwAccessibleMap& rAccMap )
43 : : : rList( rLst ),
44 : 1214 : aCurr( rList.GetFrm().GetLower() ),
45 : 1214 : nNextObj( 0 )
46 : : {
47 [ + + ]: 1214 : if( !aCurr.GetSwFrm() )
48 : : {
49 : 254 : const SwFrm& rFrm = rList.GetFrm();
50 [ - + ]: 254 : if( rFrm.IsPageFrm() )
51 : : {
52 : 0 : const SwPageFrm& rPgFrm = static_cast< const SwPageFrm& >( rFrm );
53 : 0 : const SwSortedObjs *pObjs = rPgFrm.GetSortedObjs();
54 [ # # ][ # # ]: 0 : if( pObjs && pObjs->Count() )
[ # # ]
55 : : {
56 : 0 : aCurr = (*pObjs)[nNextObj++]->GetDrawObj();
57 : : }
58 : : }
59 [ + + ]: 254 : else if( rFrm.IsTxtFrm() )
60 : : {
61 : 190 : const SwSortedObjs *pObjs = rFrm.GetDrawObjs();
62 [ + - ][ + + ]: 190 : if ( pObjs && pObjs->Count() )
[ + + ]
63 : : {
64 : 26 : aCurr = (*pObjs)[nNextObj++]->GetDrawObj();
65 [ + + ][ + - ]: 52 : while( aCurr.IsValid() && !aCurr.IsBoundAsChar() )
[ + + ]
66 : : {
67 : 26 : aCurr = (nNextObj < pObjs->Count())
68 : 0 : ? (*pObjs)[nNextObj++]->GetDrawObj()
69 [ - + ]: 26 : : static_cast< const SdrObject *>( 0 );
70 : : }
71 : : }
72 [ + - ]: 190 : if ( !aCurr.IsValid() )
73 : : {
74 : : ::rtl::Reference < SwAccessibleContext > xAccImpl =
75 [ + - ]: 190 : rAccMap.GetContextImpl( &rFrm, sal_False );
76 [ + + ]: 190 : if( xAccImpl.is() )
77 : : {
78 : 134 : SwAccessibleContext* pAccImpl = xAccImpl.get();
79 [ + - ][ + - ]: 134 : aCurr = SwAccessibleChild( pAccImpl->GetAdditionalAccessibleChild( 0 ) );
[ + - ]
80 : 134 : ++nNextObj;
81 : 190 : }
82 : : }
83 : : }
84 : : }
85 : :
86 [ + + ]: 1214 : if( rList.IsVisibleChildrenOnly() )
87 : : {
88 : : // Find the first visible
89 [ + - ][ + + ]: 2272 : while( aCurr.IsValid() &&
[ + - ][ - + ]
[ - + ]
90 [ + - ]: 500 : !aCurr.AlwaysIncludeAsChild() &&
91 [ + - ][ + - ]: 1136 : !aCurr.GetBox( rAccMap ).IsOver( rList.GetVisArea() ) )
[ + + ][ # # ]
92 : : {
93 : 0 : next();
94 : : }
95 : : }
96 : 1214 : }
97 : :
98 : 1326 : SwAccessibleChildSList_const_iterator& SwAccessibleChildSList_const_iterator::next()
99 : : {
100 : 1326 : bool bNextTaken( true );
101 [ + + ][ - + ]: 1326 : if( aCurr.GetDrawObject() || aCurr.GetWindow() )
[ + + ]
102 : : {
103 : 26 : bNextTaken = false;
104 : : }
105 [ + - ]: 1300 : else if( aCurr.GetSwFrm() )
106 : : {
107 : 1300 : aCurr = aCurr.GetSwFrm()->GetNext();
108 [ + + ]: 1300 : if( !aCurr.GetSwFrm() )
109 : : {
110 : 914 : bNextTaken = false;
111 : : }
112 : : }
113 : :
114 [ + + ]: 1326 : if( !bNextTaken )
115 : : {
116 : 940 : const SwFrm& rFrm = rList.GetFrm();
117 [ + + ]: 940 : if( rFrm.IsPageFrm() )
118 : : {
119 : 242 : const SwPageFrm& rPgFrm = static_cast< const SwPageFrm& >( rFrm );
120 : 242 : const SwSortedObjs *pObjs = rPgFrm.GetSortedObjs();
121 : 52 : aCurr = ( pObjs && nNextObj < pObjs->Count() )
122 : 26 : ? (*pObjs)[nNextObj++]->GetDrawObj()
123 [ + + + + ]: 320 : : static_cast< const SdrObject *>( 0 );
124 : : }
125 [ - + ]: 698 : else if( rFrm.IsTxtFrm() )
126 : : {
127 : 0 : const SwSortedObjs* pObjs = rFrm.GetDrawObjs();
128 [ # # ]: 0 : const sal_uInt32 nObjsCount = pObjs ? pObjs->Count() : 0;
129 : : aCurr = ( pObjs && nNextObj < nObjsCount )
130 : 0 : ? (*pObjs)[nNextObj++]->GetDrawObj()
131 [ # # ][ # # ]: 0 : : static_cast< const SdrObject *>( 0 );
132 [ # # ][ # # ]: 0 : while( aCurr.IsValid() && !aCurr.IsBoundAsChar() )
[ # # ]
133 : : {
134 : : aCurr = ( nNextObj < nObjsCount )
135 : 0 : ? (*pObjs)[nNextObj++]->GetDrawObj()
136 [ # # ]: 0 : : static_cast< const SdrObject *>( 0 );
137 : : }
138 [ # # ]: 0 : if ( !aCurr.IsValid() )
139 : : {
140 : : ::rtl::Reference < SwAccessibleContext > xAccImpl =
141 [ # # ]: 0 : rList.GetAccMap().GetContextImpl( &rFrm, sal_False );
142 [ # # ]: 0 : if( xAccImpl.is() )
143 : : {
144 : 0 : SwAccessibleContext* pAccImpl = xAccImpl.get();
145 [ # # ][ # # ]: 0 : aCurr = SwAccessibleChild( pAccImpl->GetAdditionalAccessibleChild( nNextObj - nObjsCount ) );
[ # # ]
146 : 0 : ++nNextObj;
147 : 0 : }
148 : : }
149 : : }
150 : : }
151 : :
152 : 1326 : return *this;
153 : : }
154 : :
155 : 614 : SwAccessibleChildSList_const_iterator& SwAccessibleChildSList_const_iterator::next_visible()
156 : : {
157 : 614 : next();
158 [ + - ][ + + ]: 1492 : while( aCurr.IsValid() &&
[ + - ][ - + ]
[ - + ]
159 [ + - ]: 132 : !aCurr.AlwaysIncludeAsChild() &&
160 [ + - ][ + - ]: 746 : !aCurr.GetBox( rList.GetAccMap() ).IsOver( rList.GetVisArea() ) )
[ + + ][ # # ]
161 : : {
162 : 0 : next();
163 : : }
164 : :
165 : 614 : return *this;
166 : : }
167 : :
168 : 1326 : SwAccessibleChildSList_const_iterator& SwAccessibleChildSList_const_iterator::operator++()
169 : : {
170 [ + + ]: 1326 : return rList.IsVisibleChildrenOnly() ? next_visible() : next();
171 : : }
172 : :
173 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|