1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26
27 #include <accfrmobjmap.hxx>
28 #include <accframe.hxx>
29 #include <accmap.hxx>
30 #include <acccontext.hxx>
31
32 #include <viewsh.hxx>
33 #include <doc.hxx>
34 #include <frmfmt.hxx>
35 #include <pagefrm.hxx>
36 #include <txtfrm.hxx>
37 #include <node.hxx>
38 #include <sortedobjs.hxx>
39 #include <anchoredobject.hxx>
40
41 #include <svx/svdobj.hxx>
42
43 using namespace sw::access;
44
SwAccessibleChildMap(const SwRect & rVisArea,const SwFrm & rFrm,SwAccessibleMap & rAccMap)45 SwAccessibleChildMap::SwAccessibleChildMap( const SwRect& rVisArea,
46 const SwFrm& rFrm,
47 SwAccessibleMap& rAccMap )
48 : nHellId( rAccMap.GetShell()->GetDoc()->GetHellId() )
49 , nControlsId( rAccMap.GetShell()->GetDoc()->GetControlsId() )
50 {
51 const bool bVisibleChildrenOnly = SwAccessibleChild( &rFrm ).IsVisibleChildrenOnly();
52
53 sal_uInt32 nPos = 0;
54 SwAccessibleChild aLower( rFrm.GetLower() );
55 while( aLower.GetSwFrm() )
56 {
57 if ( !bVisibleChildrenOnly ||
58 aLower.AlwaysIncludeAsChild() ||
59 aLower.GetBox( rAccMap ).IsOver( rVisArea ) )
60 {
61 insert( nPos++, SwAccessibleChildMapKey::TEXT, aLower );
62 }
63
64 aLower = aLower.GetSwFrm()->GetNext();
65 }
66
67 if ( rFrm.IsPageFrm() )
68 {
69 ASSERT( bVisibleChildrenOnly, "page frame within tab frame???" );
70 const SwPageFrm *pPgFrm =
71 static_cast< const SwPageFrm * >( &rFrm );
72 const SwSortedObjs *pObjs = pPgFrm->GetSortedObjs();
73 if ( pObjs )
74 {
75 for( sal_uInt16 i=0; i<pObjs->Count(); i++ )
76 {
77 aLower = (*pObjs)[i]->GetDrawObj();
78 if ( aLower.GetBox( rAccMap ).IsOver( rVisArea ) )
79 {
80 insert( aLower.GetDrawObject(), aLower );
81 }
82 }
83 }
84 }
85 else if( rFrm.IsTxtFrm() )
86 {
87 const SwSortedObjs *pObjs = rFrm.GetDrawObjs();
88 if ( pObjs )
89 {
90 for( sal_uInt16 i=0; i<pObjs->Count(); i++ )
91 {
92 aLower = (*pObjs)[i]->GetDrawObj();
93 if ( aLower.IsBoundAsChar() &&
94 ( !bVisibleChildrenOnly ||
95 aLower.AlwaysIncludeAsChild() ||
96 aLower.GetBox( rAccMap ).IsOver( rVisArea ) ) )
97 {
98 insert( aLower.GetDrawObject(), aLower );
99 }
100 }
101 }
102
103 {
104 ::vos::ORef < SwAccessibleContext > xAccImpl =
105 rAccMap.GetContextImpl( &rFrm, sal_False );
106 if( xAccImpl.isValid() )
107 {
108 SwAccessibleContext* pAccImpl = xAccImpl.getBodyPtr();
109 if ( pAccImpl &&
110 pAccImpl->HasAdditionalAccessibleChildren() )
111 {
112 std::vector< Window* >* pAdditionalChildren =
113 new std::vector< Window* >();
114 pAccImpl->GetAdditionalAccessibleChildren( pAdditionalChildren );
115
116 sal_Int32 nCounter( 0 );
117 for ( std::vector< Window* >::iterator aIter = pAdditionalChildren->begin();
118 aIter != pAdditionalChildren->end();
119 ++aIter )
120 {
121 aLower = (*aIter);
122 insert( ++nCounter, SwAccessibleChildMapKey::XWINDOW, aLower );
123 }
124
125 delete pAdditionalChildren;
126 }
127 }
128 }
129 }
130 }
131
insert(const sal_uInt32 nPos,const SwAccessibleChildMapKey::LayerId eLayerId,const SwAccessibleChild & rLower)132 ::std::pair< SwAccessibleChildMap::iterator, bool > SwAccessibleChildMap::insert(
133 const sal_uInt32 nPos,
134 const SwAccessibleChildMapKey::LayerId eLayerId,
135 const SwAccessibleChild& rLower )
136 {
137 SwAccessibleChildMapKey aKey( eLayerId, nPos );
138 value_type aEntry( aKey, rLower );
139 return _SwAccessibleChildMap::insert( aEntry );
140 }
141
insert(const SdrObject * pObj,const SwAccessibleChild & rLower)142 ::std::pair< SwAccessibleChildMap::iterator, bool > SwAccessibleChildMap::insert(
143 const SdrObject *pObj,
144 const SwAccessibleChild& rLower )
145 {
146 const SdrLayerID nLayer = pObj->GetLayer();
147 SwAccessibleChildMapKey::LayerId eLayerId =
148 (nHellId == nLayer)
149 ? SwAccessibleChildMapKey::HELL
150 : ( (nControlsId == nLayer)
151 ? SwAccessibleChildMapKey::CONTROLS
152 : SwAccessibleChildMapKey::HEAVEN );
153 SwAccessibleChildMapKey aKey( eLayerId, pObj->GetOrdNum() );
154 value_type aEntry( aKey, rLower );
155 return _SwAccessibleChildMap::insert( aEntry );
156 }
157
IsSortingRequired(const SwFrm & rFrm)158 /* static */ sal_Bool SwAccessibleChildMap::IsSortingRequired( const SwFrm& rFrm )
159 {
160 return ( rFrm.IsPageFrm() &&
161 static_cast< const SwPageFrm& >( rFrm ).GetSortedObjs() ) ||
162 ( rFrm.IsTxtFrm() &&
163 rFrm.GetDrawObjs() );
164 }
165
166