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