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 <accfrmobjmap.hxx>
31 : : #include <accframe.hxx>
32 : : #include <accmap.hxx>
33 : : #include <acccontext.hxx>
34 : :
35 : : #include <viewsh.hxx>
36 : : #include <doc.hxx>
37 : : #include <frmfmt.hxx>
38 : : #include <pagefrm.hxx>
39 : : #include <txtfrm.hxx>
40 : : #include <node.hxx>
41 : : #include <sortedobjs.hxx>
42 : : #include <anchoredobject.hxx>
43 : :
44 : : #include <svx/svdobj.hxx>
45 : :
46 : : using namespace sw::access;
47 : :
48 : 4 : SwAccessibleChildMap::SwAccessibleChildMap( const SwRect& rVisArea,
49 : : const SwFrm& rFrm,
50 : : SwAccessibleMap& rAccMap )
51 [ + - ]: 4 : : nHellId( rAccMap.GetShell()->GetDoc()->GetHellId() )
52 [ + - ]: 8 : , nControlsId( rAccMap.GetShell()->GetDoc()->GetControlsId() )
53 : : {
54 [ + - ][ + - ]: 4 : const bool bVisibleChildrenOnly = SwAccessibleChild( &rFrm ).IsVisibleChildrenOnly();
55 : :
56 : 4 : sal_uInt32 nPos = 0;
57 [ + - ][ + - ]: 4 : SwAccessibleChild aLower( rFrm.GetLower() );
58 [ + - ][ + + ]: 8 : while( aLower.GetSwFrm() )
59 : : {
60 [ + - ][ + - ]: 16 : if ( !bVisibleChildrenOnly ||
[ + - ][ + - ]
61 [ + - ]: 4 : aLower.AlwaysIncludeAsChild() ||
62 [ + - ][ + - ]: 8 : aLower.GetBox( rAccMap ).IsOver( rVisArea ) )
[ + - ][ # # ]
63 : : {
64 [ + - ]: 4 : insert( nPos++, SwAccessibleChildMapKey::TEXT, aLower );
65 : : }
66 : :
67 [ + - ][ + - ]: 4 : aLower = aLower.GetSwFrm()->GetNext();
68 : : }
69 : :
70 [ + - ]: 4 : if ( rFrm.IsPageFrm() )
71 : : {
72 : : OSL_ENSURE( bVisibleChildrenOnly, "page frame within tab frame???" );
73 : : const SwPageFrm *pPgFrm =
74 : 4 : static_cast< const SwPageFrm * >( &rFrm );
75 : 4 : const SwSortedObjs *pObjs = pPgFrm->GetSortedObjs();
76 [ + - ]: 4 : if ( pObjs )
77 : : {
78 [ + - ][ + + ]: 8 : for( sal_uInt16 i=0; i<pObjs->Count(); i++ )
79 : : {
80 [ + - ][ + - ]: 4 : aLower = (*pObjs)[i]->GetDrawObj();
[ + - ]
81 [ + - ][ + - ]: 4 : if ( aLower.GetBox( rAccMap ).IsOver( rVisArea ) )
[ + - ]
82 : : {
83 [ + - ][ + - ]: 4 : insert( aLower.GetDrawObject(), aLower );
84 : : }
85 : : }
86 : : }
87 : : }
88 [ # # ]: 0 : else if( rFrm.IsTxtFrm() )
89 : : {
90 : 0 : const SwSortedObjs *pObjs = rFrm.GetDrawObjs();
91 [ # # ]: 0 : if ( pObjs )
92 : : {
93 [ # # ][ # # ]: 0 : for( sal_uInt16 i=0; i<pObjs->Count(); i++ )
94 : : {
95 [ # # ][ # # ]: 0 : aLower = (*pObjs)[i]->GetDrawObj();
[ # # ]
96 [ # # ][ # # ]: 0 : if ( aLower.IsBoundAsChar() &&
[ # # ][ # # ]
[ # # ][ # # ]
97 : 0 : ( !bVisibleChildrenOnly ||
98 [ # # ]: 0 : aLower.AlwaysIncludeAsChild() ||
99 [ # # ][ # # ]: 0 : aLower.GetBox( rAccMap ).IsOver( rVisArea ) ) )
[ # # ][ # # ]
100 : : {
101 [ # # ][ # # ]: 0 : insert( aLower.GetDrawObject(), aLower );
102 : : }
103 : : }
104 : : }
105 : :
106 : : {
107 : : ::rtl::Reference < SwAccessibleContext > xAccImpl =
108 [ # # ]: 0 : rAccMap.GetContextImpl( &rFrm, sal_False );
109 [ # # ]: 0 : if( xAccImpl.is() )
110 : : {
111 : 0 : SwAccessibleContext* pAccImpl = xAccImpl.get();
112 [ # # ][ # # ]: 0 : if ( pAccImpl &&
[ # # ]
113 [ # # ]: 0 : pAccImpl->HasAdditionalAccessibleChildren() )
114 : : {
115 : : std::vector< Window* >* pAdditionalChildren =
116 [ # # ][ # # ]: 0 : new std::vector< Window* >();
117 [ # # ]: 0 : pAccImpl->GetAdditionalAccessibleChildren( pAdditionalChildren );
118 : :
119 : 0 : sal_Int32 nCounter( 0 );
120 [ # # ][ # # ]: 0 : for ( std::vector< Window* >::iterator aIter = pAdditionalChildren->begin();
121 : 0 : aIter != pAdditionalChildren->end();
122 : : ++aIter )
123 : : {
124 [ # # ]: 0 : aLower = (*aIter);
125 [ # # ]: 0 : insert( ++nCounter, SwAccessibleChildMapKey::XWINDOW, aLower );
126 : : }
127 : :
128 [ # # ]: 0 : delete pAdditionalChildren;
129 : : }
130 : 0 : }
131 : : }
132 : : }
133 : 4 : }
134 : :
135 : 4 : ::std::pair< SwAccessibleChildMap::iterator, bool > SwAccessibleChildMap::insert(
136 : : const sal_uInt32 nPos,
137 : : const SwAccessibleChildMapKey::LayerId eLayerId,
138 : : const SwAccessibleChild& rLower )
139 : : {
140 : 4 : SwAccessibleChildMapKey aKey( eLayerId, nPos );
141 [ + - ]: 4 : value_type aEntry( aKey, rLower );
142 [ + - ]: 4 : return _SwAccessibleChildMap::insert( aEntry );
143 : : }
144 : :
145 : 4 : ::std::pair< SwAccessibleChildMap::iterator, bool > SwAccessibleChildMap::insert(
146 : : const SdrObject *pObj,
147 : : const SwAccessibleChild& rLower )
148 : : {
149 [ + - ]: 4 : const SdrLayerID nLayer = pObj->GetLayer();
150 : : SwAccessibleChildMapKey::LayerId eLayerId =
151 : : (nHellId == nLayer)
152 : : ? SwAccessibleChildMapKey::HELL
153 : : : ( (nControlsId == nLayer)
154 : : ? SwAccessibleChildMapKey::CONTROLS
155 [ + - ][ - + ]: 4 : : SwAccessibleChildMapKey::HEAVEN );
156 [ + - ]: 4 : SwAccessibleChildMapKey aKey( eLayerId, pObj->GetOrdNum() );
157 [ + - ]: 4 : value_type aEntry( aKey, rLower );
158 [ + - ]: 4 : return _SwAccessibleChildMap::insert( aEntry );
159 : : }
160 : :
161 : 254 : /* static */ sal_Bool SwAccessibleChildMap::IsSortingRequired( const SwFrm& rFrm )
162 : : {
163 : 254 : return ( rFrm.IsPageFrm() &&
164 : 56 : static_cast< const SwPageFrm& >( rFrm ).GetSortedObjs() ) ||
165 : 250 : ( rFrm.IsTxtFrm() &&
166 [ - + ][ + + : 560 : rFrm.GetDrawObjs() );
+ + + + ]
167 : : }
168 : :
169 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|