xref: /aoo41x/main/sw/source/core/access/accframe.cxx (revision 4d7c9de0)
1efeef26fSAndrew Rist /**************************************************************
2efeef26fSAndrew Rist  *
3efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5efeef26fSAndrew Rist  * distributed with this work for additional information
6efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10efeef26fSAndrew Rist  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist  *
13efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17efeef26fSAndrew Rist  * specific language governing permissions and limitations
18efeef26fSAndrew Rist  * under the License.
19efeef26fSAndrew Rist  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <hintids.hxx>
30cdf0e10cSrcweir #include <editeng/brshitem.hxx>
31cdf0e10cSrcweir #include <flyfrm.hxx>
32cdf0e10cSrcweir #include <rootfrm.hxx>
33cdf0e10cSrcweir #include <txtfrm.hxx>
34cdf0e10cSrcweir #include <sectfrm.hxx>
35cdf0e10cSrcweir #include <pagefrm.hxx>
36cdf0e10cSrcweir #include <section.hxx>
37cdf0e10cSrcweir #include <viewsh.hxx>
38cdf0e10cSrcweir #include <viewopt.hxx>
39cdf0e10cSrcweir #include <doc.hxx>
40cdf0e10cSrcweir #include <frmatr.hxx>
41cdf0e10cSrcweir #include <pagefrm.hxx>
42cdf0e10cSrcweir #include <pagedesc.hxx>
43cdf0e10cSrcweir #include <fmtanchr.hxx>
44cdf0e10cSrcweir #include <fldbas.hxx>
45cdf0e10cSrcweir #include <dcontact.hxx>
46cdf0e10cSrcweir #include <accmap.hxx>
47cdf0e10cSrcweir #include <accfrmobjslist.hxx>
48cdf0e10cSrcweir #include <accfrmobjmap.hxx>
49cdf0e10cSrcweir #include <accframe.hxx>
50cdf0e10cSrcweir 
51cdf0e10cSrcweir using namespace sw::access;
52cdf0e10cSrcweir 
53cdf0e10cSrcweir // Regarding visibilily (or in terms of accessibility: regarding the showing
54cdf0e10cSrcweir // state): A frame is visible and therfor contained in the tree if its frame
55cdf0e10cSrcweir // size overlaps with the visible area. The bounding box however is the
56cdf0e10cSrcweir // frame's paint area.
GetChildCount(SwAccessibleMap & rAccMap,const SwRect & rVisArea,const SwFrm * pFrm,sal_Bool bInPagePreview)57cdf0e10cSrcweir /* static */ sal_Int32 SwAccessibleFrame::GetChildCount( SwAccessibleMap& rAccMap,
58cdf0e10cSrcweir                                                          const SwRect& rVisArea,
59cdf0e10cSrcweir                                                          const SwFrm *pFrm,
60cdf0e10cSrcweir                                                          sal_Bool bInPagePreview )
61cdf0e10cSrcweir {
62cdf0e10cSrcweir 	sal_Int32 nCount = 0;
63cdf0e10cSrcweir 
64*ca62e2c2SSteve Yin     // const SwAccessibleChildSList aVisList( rVisArea, *pFrm, rAccMap );
65*ca62e2c2SSteve Yin     const SwAccessibleChildSList aVisList( pFrm->PaintArea(), *pFrm, rAccMap );
66*ca62e2c2SSteve Yin 
67cdf0e10cSrcweir     SwAccessibleChildSList::const_iterator aIter( aVisList.begin() );
68cdf0e10cSrcweir 	while( aIter != aVisList.end() )
69cdf0e10cSrcweir 	{
70cdf0e10cSrcweir         const SwAccessibleChild& rLower = *aIter;
71cdf0e10cSrcweir 		if( rLower.IsAccessible( bInPagePreview ) )
72cdf0e10cSrcweir 		{
73cdf0e10cSrcweir 			nCount++;
74cdf0e10cSrcweir 		}
75cdf0e10cSrcweir 		else if( rLower.GetSwFrm() )
76cdf0e10cSrcweir 		{
77cdf0e10cSrcweir 			// There are no unaccessible SdrObjects that count
78cdf0e10cSrcweir             nCount += GetChildCount( rAccMap,
79cdf0e10cSrcweir                                      rVisArea, rLower.GetSwFrm(),
80cdf0e10cSrcweir                                      bInPagePreview );
81cdf0e10cSrcweir 		}
82cdf0e10cSrcweir 		++aIter;
83cdf0e10cSrcweir 	}
84cdf0e10cSrcweir 
85cdf0e10cSrcweir     return nCount;
86cdf0e10cSrcweir }
87cdf0e10cSrcweir 
GetChild(SwAccessibleMap & rAccMap,const SwRect & rVisArea,const SwFrm & rFrm,sal_Int32 & rPos,sal_Bool bInPagePreview)88cdf0e10cSrcweir /* static */ SwAccessibleChild SwAccessibleFrame::GetChild(
89cdf0e10cSrcweir                                                 SwAccessibleMap& rAccMap,
90cdf0e10cSrcweir                                                 const SwRect& rVisArea,
91cdf0e10cSrcweir                                                 const SwFrm& rFrm,
92cdf0e10cSrcweir                                                 sal_Int32& rPos,
93cdf0e10cSrcweir                                                 sal_Bool bInPagePreview )
94cdf0e10cSrcweir {
95cdf0e10cSrcweir     SwAccessibleChild aRet;
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 	if( rPos >= 0 )
98cdf0e10cSrcweir 	{
99cdf0e10cSrcweir         if( SwAccessibleChildMap::IsSortingRequired( rFrm ) )
100cdf0e10cSrcweir 		{
101cdf0e10cSrcweir 			// We need a sorted list here
102cdf0e10cSrcweir             const SwAccessibleChildMap aVisMap( rVisArea, rFrm, rAccMap );
103cdf0e10cSrcweir             SwAccessibleChildMap::const_iterator aIter( aVisMap.begin() );
104cdf0e10cSrcweir 			while( aIter != aVisMap.end() && !aRet.IsValid() )
105cdf0e10cSrcweir 			{
106cdf0e10cSrcweir                 const SwAccessibleChild& rLower = (*aIter).second;
107cdf0e10cSrcweir 				if( rLower.IsAccessible( bInPagePreview ) )
108cdf0e10cSrcweir 				{
109cdf0e10cSrcweir 					if( 0 == rPos )
110cdf0e10cSrcweir 						aRet = rLower;
111cdf0e10cSrcweir 					else
112cdf0e10cSrcweir 						rPos--;
113cdf0e10cSrcweir 				}
114cdf0e10cSrcweir 				else if( rLower.GetSwFrm() )
115cdf0e10cSrcweir 				{
116cdf0e10cSrcweir 					// There are no unaccessible SdrObjects that count
117cdf0e10cSrcweir                     aRet = GetChild( rAccMap,
118cdf0e10cSrcweir                                      rVisArea, *(rLower.GetSwFrm()), rPos,
119cdf0e10cSrcweir                                      bInPagePreview );
120cdf0e10cSrcweir 				}
121cdf0e10cSrcweir 				++aIter;
122cdf0e10cSrcweir 			}
123cdf0e10cSrcweir 		}
124cdf0e10cSrcweir 		else
125cdf0e10cSrcweir 		{
126cdf0e10cSrcweir 			// The unsorted list is sorted enough, because it return lower
127cdf0e10cSrcweir 			// frames in the correct order.
128cdf0e10cSrcweir             const SwAccessibleChildSList aVisList( rVisArea, rFrm, rAccMap );
129cdf0e10cSrcweir             SwAccessibleChildSList::const_iterator aIter( aVisList.begin() );
130cdf0e10cSrcweir 			while( aIter != aVisList.end() && !aRet.IsValid() )
131cdf0e10cSrcweir 			{
132cdf0e10cSrcweir                 const SwAccessibleChild& rLower = *aIter;
133cdf0e10cSrcweir 				if( rLower.IsAccessible( bInPagePreview ) )
134cdf0e10cSrcweir 				{
135cdf0e10cSrcweir 					if( 0 == rPos )
136cdf0e10cSrcweir 						aRet = rLower;
137cdf0e10cSrcweir 					else
138cdf0e10cSrcweir 						rPos--;
139cdf0e10cSrcweir 				}
140cdf0e10cSrcweir 				else if( rLower.GetSwFrm() )
141cdf0e10cSrcweir 				{
142cdf0e10cSrcweir 					// There are no unaccessible SdrObjects that count
143cdf0e10cSrcweir                     aRet = GetChild( rAccMap,
144cdf0e10cSrcweir                                      rVisArea, *(rLower.GetSwFrm()), rPos,
145cdf0e10cSrcweir                                      bInPagePreview );
146cdf0e10cSrcweir 				}
147cdf0e10cSrcweir 				++aIter;
148cdf0e10cSrcweir 			}
149cdf0e10cSrcweir 		}
150cdf0e10cSrcweir 	}
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 	return aRet;
153cdf0e10cSrcweir }
154cdf0e10cSrcweir 
GetChildIndex(SwAccessibleMap & rAccMap,const SwRect & rVisArea,const SwFrm & rFrm,const SwAccessibleChild & rChild,sal_Int32 & rPos,sal_Bool bInPagePreview)155cdf0e10cSrcweir /* static */ sal_Bool SwAccessibleFrame::GetChildIndex(
156cdf0e10cSrcweir                                                 SwAccessibleMap& rAccMap,
157cdf0e10cSrcweir                                                 const SwRect& rVisArea,
158cdf0e10cSrcweir                                                 const SwFrm& rFrm,
159cdf0e10cSrcweir                                                 const SwAccessibleChild& rChild,
160cdf0e10cSrcweir                                                 sal_Int32& rPos,
161cdf0e10cSrcweir                                                 sal_Bool bInPagePreview )
162cdf0e10cSrcweir {
163cdf0e10cSrcweir 	sal_Bool bFound = sal_False;
164cdf0e10cSrcweir 
165cdf0e10cSrcweir     if( SwAccessibleChildMap::IsSortingRequired( rFrm ) )
166cdf0e10cSrcweir 	{
167cdf0e10cSrcweir 		// We need a sorted list here
168*ca62e2c2SSteve Yin         // const SwAccessibleChildMap aVisMap( rVisArea, rFrm, rAccMap );
169*ca62e2c2SSteve Yin         const SwAccessibleChildMap aVisMap( rFrm.PaintArea(), rFrm, rAccMap );
170cdf0e10cSrcweir         SwAccessibleChildMap::const_iterator aIter( aVisMap.begin() );
171cdf0e10cSrcweir 		while( aIter != aVisMap.end() && !bFound )
172cdf0e10cSrcweir 		{
173cdf0e10cSrcweir             const SwAccessibleChild& rLower = (*aIter).second;
174cdf0e10cSrcweir 			if( rLower.IsAccessible( bInPagePreview ) )
175cdf0e10cSrcweir 			{
176cdf0e10cSrcweir 				if( rChild == rLower )
177cdf0e10cSrcweir 					bFound = sal_True;
178cdf0e10cSrcweir 				else
179cdf0e10cSrcweir 					rPos++;
180cdf0e10cSrcweir 			}
181cdf0e10cSrcweir 			else if( rLower.GetSwFrm() )
182cdf0e10cSrcweir 			{
183cdf0e10cSrcweir 				// There are no unaccessible SdrObjects that count
184cdf0e10cSrcweir                 bFound = GetChildIndex( rAccMap,
185cdf0e10cSrcweir                                         rVisArea, *(rLower.GetSwFrm()), rChild,
186cdf0e10cSrcweir                                         rPos, bInPagePreview );
187cdf0e10cSrcweir 			}
188cdf0e10cSrcweir 			++aIter;
189cdf0e10cSrcweir 		}
190cdf0e10cSrcweir 	}
191cdf0e10cSrcweir 	else
192cdf0e10cSrcweir 	{
193cdf0e10cSrcweir 		// The unsorted list is sorted enough, because it return lower
194cdf0e10cSrcweir 		// frames in the correct order.
195*ca62e2c2SSteve Yin 
196*ca62e2c2SSteve Yin         // const SwAccessibleChildSList aVisList( rVisArea, rFrm, rAccMap );
197*ca62e2c2SSteve Yin         const SwAccessibleChildSList aVisList( rFrm.PaintArea(), rFrm, rAccMap );
198*ca62e2c2SSteve Yin 
199cdf0e10cSrcweir         SwAccessibleChildSList::const_iterator aIter( aVisList.begin() );
200cdf0e10cSrcweir 		while( aIter != aVisList.end() && !bFound )
201cdf0e10cSrcweir 		{
202cdf0e10cSrcweir             const SwAccessibleChild& rLower = *aIter;
203cdf0e10cSrcweir 			if( rLower.IsAccessible( bInPagePreview ) )
204cdf0e10cSrcweir 			{
205cdf0e10cSrcweir 				if( rChild == rLower )
206cdf0e10cSrcweir 					bFound = sal_True;
207cdf0e10cSrcweir 				else
208cdf0e10cSrcweir 					rPos++;
209cdf0e10cSrcweir 			}
210cdf0e10cSrcweir 			else if( rLower.GetSwFrm() )
211cdf0e10cSrcweir 			{
212cdf0e10cSrcweir 				// There are no unaccessible SdrObjects that count
213cdf0e10cSrcweir                 bFound = GetChildIndex( rAccMap,
214cdf0e10cSrcweir                                         rVisArea, *(rLower.GetSwFrm()), rChild,
215cdf0e10cSrcweir                                         rPos, bInPagePreview );
216cdf0e10cSrcweir 			}
217cdf0e10cSrcweir 			++aIter;
218cdf0e10cSrcweir 		}
219cdf0e10cSrcweir 	}
220cdf0e10cSrcweir 
221cdf0e10cSrcweir 	return bFound;
222cdf0e10cSrcweir }
223cdf0e10cSrcweir 
GetChildAtPixel(const SwRect & rVisArea,const SwFrm & rFrm,const Point & rPixPos,sal_Bool bInPagePreview,SwAccessibleMap & rAccMap)224cdf0e10cSrcweir SwAccessibleChild SwAccessibleFrame::GetChildAtPixel( const SwRect& rVisArea,
225cdf0e10cSrcweir                                           const SwFrm& rFrm,
226cdf0e10cSrcweir                                           const Point& rPixPos,
227cdf0e10cSrcweir                                           sal_Bool bInPagePreview,
228cdf0e10cSrcweir                                           SwAccessibleMap& rAccMap )
229cdf0e10cSrcweir {
230cdf0e10cSrcweir     SwAccessibleChild aRet;
231cdf0e10cSrcweir 
232cdf0e10cSrcweir     if( SwAccessibleChildMap::IsSortingRequired( rFrm ) )
233cdf0e10cSrcweir 	{
234cdf0e10cSrcweir 		// We need a sorted list here, and we have to reverse iterate,
235cdf0e10cSrcweir 		// because objects in front should be returned.
236cdf0e10cSrcweir         const SwAccessibleChildMap aVisMap( rVisArea, rFrm, rAccMap );
237cdf0e10cSrcweir         SwAccessibleChildMap::const_reverse_iterator aRIter( aVisMap.rbegin() );
238cdf0e10cSrcweir 		while( aRIter != aVisMap.rend() && !aRet.IsValid() )
239cdf0e10cSrcweir 		{
240cdf0e10cSrcweir             const SwAccessibleChild& rLower = (*aRIter).second;
241cdf0e10cSrcweir 			// A frame is returned if it's frame size is inside the visarea
242cdf0e10cSrcweir 			// and the positiion is inside the frame's paint area.
243cdf0e10cSrcweir 			if( rLower.IsAccessible( bInPagePreview ) )
244cdf0e10cSrcweir 			{
245cdf0e10cSrcweir                 SwRect aLogBounds( rLower.GetBounds( rAccMap ) );
246cdf0e10cSrcweir 				if( !aLogBounds.IsEmpty() )
247cdf0e10cSrcweir 				{
248cdf0e10cSrcweir                     Rectangle aPixBounds( rAccMap.CoreToPixel( aLogBounds.SVRect() ) );
249cdf0e10cSrcweir 					if( aPixBounds.IsInside( rPixPos ) )
250cdf0e10cSrcweir 						aRet = rLower;
251cdf0e10cSrcweir 				}
252cdf0e10cSrcweir 			}
253cdf0e10cSrcweir 			else if( rLower.GetSwFrm() )
254cdf0e10cSrcweir 			{
255cdf0e10cSrcweir 				// There are no unaccessible SdrObjects that count
256cdf0e10cSrcweir                 aRet = GetChildAtPixel( rVisArea, *(rLower.GetSwFrm()), rPixPos,
257cdf0e10cSrcweir                                         bInPagePreview, rAccMap );
258cdf0e10cSrcweir 			}
259cdf0e10cSrcweir 			aRIter++;
260cdf0e10cSrcweir 		}
261cdf0e10cSrcweir 	}
262cdf0e10cSrcweir 	else
263cdf0e10cSrcweir 	{
264cdf0e10cSrcweir 		// The unsorted list is sorted enough, because it returns lower
265cdf0e10cSrcweir 		// frames in the correct order. Morover, we can iterate forward,
266cdf0e10cSrcweir 		// because the lowers don't overlap!
267cdf0e10cSrcweir         const SwAccessibleChildSList aVisList( rVisArea, rFrm, rAccMap );
268cdf0e10cSrcweir         SwAccessibleChildSList::const_iterator aIter( aVisList.begin() );
269cdf0e10cSrcweir 		while( aIter != aVisList.end() && !aRet.IsValid() )
270cdf0e10cSrcweir 		{
271cdf0e10cSrcweir             const SwAccessibleChild& rLower = *aIter;
272cdf0e10cSrcweir 			// A frame is returned if it's frame size is inside the visarea
273cdf0e10cSrcweir 			// and the positiion is inside the frame's paint area.
274cdf0e10cSrcweir 			if( rLower.IsAccessible( bInPagePreview ) )
275cdf0e10cSrcweir 			{
276cdf0e10cSrcweir                 SwRect aLogBounds( rLower.GetBounds( rAccMap ) );
277cdf0e10cSrcweir 				if( !aLogBounds.IsEmpty() )
278cdf0e10cSrcweir 				{
279cdf0e10cSrcweir                     Rectangle aPixBounds( rAccMap.CoreToPixel( aLogBounds.SVRect() ) );
280cdf0e10cSrcweir 					if( aPixBounds.IsInside( rPixPos ) )
281cdf0e10cSrcweir 						aRet = rLower;
282cdf0e10cSrcweir 				}
283cdf0e10cSrcweir 			}
284cdf0e10cSrcweir 			else if( rLower.GetSwFrm() )
285cdf0e10cSrcweir 			{
286cdf0e10cSrcweir 				// There are no unaccessible SdrObjects that count
287cdf0e10cSrcweir                 aRet = GetChildAtPixel( rVisArea, *(rLower.GetSwFrm()), rPixPos,
288cdf0e10cSrcweir                                    bInPagePreview, rAccMap );
289cdf0e10cSrcweir 			}
290cdf0e10cSrcweir 			++aIter;
291cdf0e10cSrcweir 		}
292cdf0e10cSrcweir 	}
293cdf0e10cSrcweir 
294cdf0e10cSrcweir 	return aRet;
295cdf0e10cSrcweir }
296cdf0e10cSrcweir 
GetChildren(SwAccessibleMap & rAccMap,const SwRect & rVisArea,const SwFrm & rFrm,::std::list<SwAccessibleChild> & rChildren,sal_Bool bInPagePreview)297cdf0e10cSrcweir /* static */ void SwAccessibleFrame::GetChildren( SwAccessibleMap& rAccMap,
298cdf0e10cSrcweir                                                   const SwRect& rVisArea,
299cdf0e10cSrcweir                                                   const SwFrm& rFrm,
300cdf0e10cSrcweir                                                   ::std::list< SwAccessibleChild >& rChildren,
301cdf0e10cSrcweir                                                   sal_Bool bInPagePreview )
302cdf0e10cSrcweir {
303cdf0e10cSrcweir     if( SwAccessibleChildMap::IsSortingRequired( rFrm ) )
304cdf0e10cSrcweir 	{
305cdf0e10cSrcweir 		// We need a sorted list here
306cdf0e10cSrcweir         const SwAccessibleChildMap aVisMap( rVisArea, rFrm, rAccMap );
307cdf0e10cSrcweir         SwAccessibleChildMap::const_iterator aIter( aVisMap.begin() );
308cdf0e10cSrcweir 		while( aIter != aVisMap.end() )
309cdf0e10cSrcweir 		{
310cdf0e10cSrcweir             const SwAccessibleChild& rLower = (*aIter).second;
311cdf0e10cSrcweir 			if( rLower.IsAccessible( bInPagePreview ) )
312cdf0e10cSrcweir 			{
313cdf0e10cSrcweir 				rChildren.push_back( rLower );
314cdf0e10cSrcweir 			}
315cdf0e10cSrcweir 			else if( rLower.GetSwFrm() )
316cdf0e10cSrcweir 			{
317cdf0e10cSrcweir 				// There are no unaccessible SdrObjects that count
318cdf0e10cSrcweir                 GetChildren( rAccMap, rVisArea, *(rLower.GetSwFrm()),
319cdf0e10cSrcweir                              rChildren, bInPagePreview );
320cdf0e10cSrcweir 			}
321cdf0e10cSrcweir 			++aIter;
322cdf0e10cSrcweir 		}
323cdf0e10cSrcweir 	}
324cdf0e10cSrcweir 	else
325cdf0e10cSrcweir 	{
326cdf0e10cSrcweir 		// The unsorted list is sorted enough, because it return lower
327cdf0e10cSrcweir 		// frames in the correct order.
328cdf0e10cSrcweir         const SwAccessibleChildSList aVisList( rVisArea, rFrm, rAccMap );
329cdf0e10cSrcweir         SwAccessibleChildSList::const_iterator aIter( aVisList.begin() );
330cdf0e10cSrcweir 		while( aIter != aVisList.end() )
331cdf0e10cSrcweir 		{
332cdf0e10cSrcweir             const SwAccessibleChild& rLower = *aIter;
333cdf0e10cSrcweir 			if( rLower.IsAccessible( bInPagePreview ) )
334cdf0e10cSrcweir 			{
335cdf0e10cSrcweir 				rChildren.push_back( rLower );
336cdf0e10cSrcweir 			}
337cdf0e10cSrcweir 			else if( rLower.GetSwFrm() )
338cdf0e10cSrcweir 			{
339cdf0e10cSrcweir 				// There are no unaccessible SdrObjects that count
340cdf0e10cSrcweir                 GetChildren( rAccMap, rVisArea, *(rLower.GetSwFrm()),
341cdf0e10cSrcweir                              rChildren, bInPagePreview );
342cdf0e10cSrcweir 			}
343cdf0e10cSrcweir 			++aIter;
344cdf0e10cSrcweir 		}
345cdf0e10cSrcweir 	}
346cdf0e10cSrcweir }
347cdf0e10cSrcweir 
GetBounds(const SwAccessibleMap & rAccMap,const SwFrm * pFrm)348cdf0e10cSrcweir SwRect SwAccessibleFrame::GetBounds( const SwAccessibleMap& rAccMap,
349cdf0e10cSrcweir                                      const SwFrm *pFrm )
350cdf0e10cSrcweir {
351cdf0e10cSrcweir 	if( !pFrm )
352cdf0e10cSrcweir 		pFrm = GetFrm();
353cdf0e10cSrcweir 
354cdf0e10cSrcweir     SwAccessibleChild aFrm( pFrm );
355cdf0e10cSrcweir     SwRect aBounds( aFrm.GetBounds( rAccMap ).Intersection( maVisArea ) );
356cdf0e10cSrcweir 	return aBounds;
357cdf0e10cSrcweir }
358cdf0e10cSrcweir 
IsEditable(ViewShell * pVSh) const359cdf0e10cSrcweir sal_Bool SwAccessibleFrame::IsEditable( ViewShell *pVSh ) const
360cdf0e10cSrcweir {
361cdf0e10cSrcweir 	const SwFrm *pFrm = GetFrm();
362cdf0e10cSrcweir 	if( !pFrm )
363cdf0e10cSrcweir 		return sal_False;
364cdf0e10cSrcweir 
365cdf0e10cSrcweir 	ASSERT( pVSh, "no view shell" );
366cdf0e10cSrcweir 	if( pVSh && (pVSh->GetViewOptions()->IsReadonly() ||
367cdf0e10cSrcweir 			     pVSh->IsPreView()) )
368cdf0e10cSrcweir 		return sal_False;
369cdf0e10cSrcweir 
370cdf0e10cSrcweir 	if( !pFrm->IsRootFrm() && pFrm->IsProtected() )
371cdf0e10cSrcweir 		return sal_False;
372cdf0e10cSrcweir 
373cdf0e10cSrcweir 	return sal_True;
374cdf0e10cSrcweir }
375cdf0e10cSrcweir 
IsOpaque(ViewShell * pVSh) const376cdf0e10cSrcweir sal_Bool SwAccessibleFrame::IsOpaque( ViewShell *pVSh ) const
377cdf0e10cSrcweir {
378cdf0e10cSrcweir     SwAccessibleChild aFrm( GetFrm() );
379cdf0e10cSrcweir 	if( !aFrm.GetSwFrm() )
380cdf0e10cSrcweir 		return sal_False;
381cdf0e10cSrcweir 
382cdf0e10cSrcweir 	ASSERT( pVSh, "no view shell" );
383cdf0e10cSrcweir 	if( !pVSh )
384cdf0e10cSrcweir 		return sal_False;
385cdf0e10cSrcweir 
386cdf0e10cSrcweir 	const SwViewOption *pVOpt = pVSh->GetViewOptions();
387cdf0e10cSrcweir 	do
388cdf0e10cSrcweir 	{
389cdf0e10cSrcweir 		const SwFrm *pFrm = aFrm.GetSwFrm();
390cdf0e10cSrcweir 		if( pFrm->IsRootFrm() )
391cdf0e10cSrcweir 			return sal_True;
392cdf0e10cSrcweir 
393cdf0e10cSrcweir 		if( pFrm->IsPageFrm() && !pVOpt->IsPageBack() )
394cdf0e10cSrcweir 			return sal_False;
395cdf0e10cSrcweir 
396cdf0e10cSrcweir 		const SvxBrushItem &rBack = pFrm->GetAttrSet()->GetBackground();
397cdf0e10cSrcweir         if( !rBack.GetColor().GetTransparency() ||
398cdf0e10cSrcweir 			 rBack.GetGraphicPos() != GPOS_NONE )
399cdf0e10cSrcweir 			return sal_True;
400cdf0e10cSrcweir 
401cdf0e10cSrcweir         /// OD 20.08.2002 #99657#
402cdf0e10cSrcweir         ///     If a fly frame has a transparent background color, we have
403cdf0e10cSrcweir         ///     to consider the background.
404cdf0e10cSrcweir         ///     But a background color "no fill"/"auto fill" has *not* to be considered.
405cdf0e10cSrcweir         if( pFrm->IsFlyFrm() &&
406cdf0e10cSrcweir             (rBack.GetColor().GetTransparency() != 0) &&
407cdf0e10cSrcweir             (rBack.GetColor() != COL_TRANSPARENT)
408cdf0e10cSrcweir           )
409cdf0e10cSrcweir             return sal_True;
410cdf0e10cSrcweir 
411cdf0e10cSrcweir 		if( pFrm->IsSctFrm() )
412cdf0e10cSrcweir 		{
413cdf0e10cSrcweir 			const SwSection* pSection = ((SwSectionFrm*)pFrm)->GetSection();
414cdf0e10cSrcweir 			if( pSection && ( TOX_HEADER_SECTION == pSection->GetType() ||
415cdf0e10cSrcweir 				TOX_CONTENT_SECTION == pSection->GetType() ) &&
416cdf0e10cSrcweir                 !pVOpt->IsReadonly() &&
417cdf0e10cSrcweir                 SwViewOption::IsIndexShadings() )
418cdf0e10cSrcweir 				return sal_True;
419cdf0e10cSrcweir 		}
420cdf0e10cSrcweir 		if( pFrm->IsFlyFrm() )
421cdf0e10cSrcweir             aFrm = static_cast<const SwFlyFrm*>(pFrm)->GetAnchorFrm();
422cdf0e10cSrcweir 		else
423cdf0e10cSrcweir 			aFrm = pFrm->GetUpper();
424cdf0e10cSrcweir 	} while( aFrm.GetSwFrm() && !aFrm.IsAccessible( IsInPagePreview() ) );
425cdf0e10cSrcweir 
426cdf0e10cSrcweir 	return sal_False;
427cdf0e10cSrcweir }
428cdf0e10cSrcweir 
SwAccessibleFrame(const SwRect & rVisArea,const SwFrm * pF,sal_Bool bIsPagePreview)429cdf0e10cSrcweir SwAccessibleFrame::SwAccessibleFrame( const SwRect& rVisArea,
430cdf0e10cSrcweir 									  const SwFrm *pF,
431cdf0e10cSrcweir                                       sal_Bool bIsPagePreview ) :
432cdf0e10cSrcweir 	maVisArea( rVisArea ),
433cdf0e10cSrcweir 	mpFrm( pF ),
434*ca62e2c2SSteve Yin     mbIsInPagePreview( bIsPagePreview ),
435*ca62e2c2SSteve Yin     bIsAccDocUse( sal_False )
436cdf0e10cSrcweir {
437cdf0e10cSrcweir }
438cdf0e10cSrcweir 
~SwAccessibleFrame()439cdf0e10cSrcweir SwAccessibleFrame::~SwAccessibleFrame()
440cdf0e10cSrcweir {
441cdf0e10cSrcweir }
442cdf0e10cSrcweir 
GetParent(const SwAccessibleChild & rFrmOrObj,sal_Bool bInPagePreview)443cdf0e10cSrcweir /* static */ const SwFrm* SwAccessibleFrame::GetParent( const SwAccessibleChild& rFrmOrObj,
444cdf0e10cSrcweir                                                         sal_Bool bInPagePreview )
445cdf0e10cSrcweir {
446cdf0e10cSrcweir     return rFrmOrObj.GetParent( bInPagePreview );
447cdf0e10cSrcweir }
448cdf0e10cSrcweir 
GetFormattedPageNumber() const449cdf0e10cSrcweir String SwAccessibleFrame::GetFormattedPageNumber() const
450cdf0e10cSrcweir {
451cdf0e10cSrcweir 	sal_uInt16 nPageNum = GetFrm()->GetVirtPageNum();
452cdf0e10cSrcweir 	sal_uInt32 nFmt = GetFrm()->FindPageFrm()->GetPageDesc()
453cdf0e10cSrcweir 							  ->GetNumType().GetNumberingType();
454cdf0e10cSrcweir 	if( SVX_NUM_NUMBER_NONE == nFmt )
455cdf0e10cSrcweir 		nFmt = SVX_NUM_ARABIC;
456cdf0e10cSrcweir 
457cdf0e10cSrcweir 	String sRet( FormatNumber( nPageNum, nFmt ) );
458cdf0e10cSrcweir 	return sRet;
459cdf0e10cSrcweir }
460cdf0e10cSrcweir 
GetChildCount(SwAccessibleMap & rAccMap) const461cdf0e10cSrcweir sal_Int32 SwAccessibleFrame::GetChildCount( SwAccessibleMap& rAccMap ) const
462cdf0e10cSrcweir {
463cdf0e10cSrcweir     return GetChildCount( rAccMap, maVisArea, mpFrm, IsInPagePreview() );
464cdf0e10cSrcweir }
465cdf0e10cSrcweir 
GetChild(SwAccessibleMap & rAccMap,sal_Int32 nPos) const466cdf0e10cSrcweir sw::access::SwAccessibleChild SwAccessibleFrame::GetChild(
467cdf0e10cSrcweir                                                 SwAccessibleMap& rAccMap,
468cdf0e10cSrcweir                                                 sal_Int32 nPos ) const
469cdf0e10cSrcweir {
470cdf0e10cSrcweir     return SwAccessibleFrame::GetChild( rAccMap, maVisArea, *mpFrm, nPos, IsInPagePreview() );
471cdf0e10cSrcweir }
472cdf0e10cSrcweir 
GetChildIndex(SwAccessibleMap & rAccMap,const sw::access::SwAccessibleChild & rChild) const473cdf0e10cSrcweir sal_Int32 SwAccessibleFrame::GetChildIndex( SwAccessibleMap& rAccMap,
474cdf0e10cSrcweir                                             const sw::access::SwAccessibleChild& rChild ) const
475cdf0e10cSrcweir {
476cdf0e10cSrcweir     sal_Int32 nPos = 0;
477cdf0e10cSrcweir     return GetChildIndex( rAccMap, maVisArea, *mpFrm, rChild, nPos, IsInPagePreview() )
478cdf0e10cSrcweir            ? nPos
479cdf0e10cSrcweir            : -1L;
480cdf0e10cSrcweir }
481cdf0e10cSrcweir 
GetChildAtPixel(const Point & rPos,SwAccessibleMap & rAccMap) const482cdf0e10cSrcweir sw::access::SwAccessibleChild SwAccessibleFrame::GetChildAtPixel(
483cdf0e10cSrcweir                                                 const Point& rPos,
484cdf0e10cSrcweir                                                 SwAccessibleMap& rAccMap ) const
485cdf0e10cSrcweir {
486cdf0e10cSrcweir     return GetChildAtPixel( maVisArea, *mpFrm, rPos, IsInPagePreview(), rAccMap );
487cdf0e10cSrcweir }
488cdf0e10cSrcweir 
GetChildren(SwAccessibleMap & rAccMap,::std::list<sw::access::SwAccessibleChild> & rChildren) const489cdf0e10cSrcweir void SwAccessibleFrame::GetChildren( SwAccessibleMap& rAccMap,
490cdf0e10cSrcweir                                      ::std::list< sw::access::SwAccessibleChild >& rChildren ) const
491cdf0e10cSrcweir {
492cdf0e10cSrcweir     GetChildren( rAccMap, maVisArea, *mpFrm, rChildren, IsInPagePreview() );
493cdf0e10cSrcweir }
494cdf0e10cSrcweir 
IsShowing(const SwAccessibleMap & rAccMap,const sw::access::SwAccessibleChild & rFrmOrObj) const495cdf0e10cSrcweir sal_Bool SwAccessibleFrame::IsShowing( const SwAccessibleMap& rAccMap,
496cdf0e10cSrcweir                                        const sw::access::SwAccessibleChild& rFrmOrObj ) const
497cdf0e10cSrcweir {
498cdf0e10cSrcweir     return IsShowing( rFrmOrObj.GetBox( rAccMap ) );
499cdf0e10cSrcweir }
500cdf0e10cSrcweir 
501