1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "accfrmobjmap.hxx"
22 #include "acccontext.hxx"
26 #include <IDocumentDrawModelAccess.hxx>
27 #include <pagefrm.hxx>
28 #include <sortedobjs.hxx>
29 #include <anchoredobject.hxx>
31 #include <svx/svdobj.hxx>
33 using namespace sw::access
;
35 SwAccessibleChildMap::SwAccessibleChildMap( const SwRect
& rVisArea
,
36 const SwFrame
& rFrame
,
37 SwAccessibleMap
& rAccMap
)
38 : mnHellId( rAccMap
.GetShell()->GetDoc()->getIDocumentDrawModelAccess().GetHellId() )
39 , mnControlsId( rAccMap
.GetShell()->GetDoc()->getIDocumentDrawModelAccess().GetControlsId() )
41 const bool bVisibleChildrenOnly
= SwAccessibleChild( &rFrame
).IsVisibleChildrenOnly();
44 SwAccessibleChild
aLower( rFrame
.GetLower() );
45 while( aLower
.GetSwFrame() )
47 if ( !bVisibleChildrenOnly
||
48 aLower
.AlwaysIncludeAsChild() ||
49 aLower
.GetBox( rAccMap
).Overlaps( rVisArea
) )
51 insert( nPos
++, SwAccessibleChildMapKey::TEXT
, aLower
);
54 aLower
= aLower
.GetSwFrame()->GetNext();
57 if ( rFrame
.IsPageFrame() )
59 OSL_ENSURE( bVisibleChildrenOnly
, "page frame within tab frame???" );
60 const SwPageFrame
*pPgFrame
=
61 static_cast< const SwPageFrame
* >( &rFrame
);
62 const SwSortedObjs
*pObjs
= pPgFrame
->GetSortedObjs();
65 for(const SwAnchoredObject
* pObj
: *pObjs
)
67 aLower
= pObj
->GetDrawObj();
68 if ( aLower
.GetBox( rAccMap
).Overlaps( rVisArea
) )
70 insert( aLower
.GetDrawObject(), aLower
);
75 else if( rFrame
.IsTextFrame() )
77 const SwSortedObjs
*pObjs
= rFrame
.GetDrawObjs();
80 for(const SwAnchoredObject
* pObj
: *pObjs
)
82 aLower
= pObj
->GetDrawObj();
83 if ( aLower
.IsBoundAsChar() &&
84 ( !bVisibleChildrenOnly
||
85 aLower
.AlwaysIncludeAsChild() ||
86 aLower
.GetBox( rAccMap
).Overlaps( rVisArea
) ) )
88 insert( aLower
.GetDrawObject(), aLower
);
94 ::rtl::Reference
< SwAccessibleContext
> xAccImpl
=
95 rAccMap
.GetContextImpl( &rFrame
, false );
98 SwAccessibleContext
* pAccImpl
= xAccImpl
.get();
100 pAccImpl
->HasAdditionalAccessibleChildren() )
102 std::vector
< vcl::Window
* > aAdditionalChildren
;
103 pAccImpl
->GetAdditionalAccessibleChildren( &aAdditionalChildren
);
105 sal_Int32
nCounter( 0 );
106 for ( const auto& rpChild
: aAdditionalChildren
)
109 insert( ++nCounter
, SwAccessibleChildMapKey::XWINDOW
, aLower
);
117 std::pair
< SwAccessibleChildMap::iterator
, bool > SwAccessibleChildMap::insert(
118 const sal_uInt32 nPos
,
119 const SwAccessibleChildMapKey::LayerId eLayerId
,
120 const SwAccessibleChild
& rLower
)
122 SwAccessibleChildMapKey
aKey( eLayerId
, nPos
);
123 return emplace( aKey
, rLower
);
126 std::pair
< SwAccessibleChildMap::iterator
, bool > SwAccessibleChildMap::insert(
127 const SdrObject
*pObj
,
128 const SwAccessibleChild
& rLower
)
130 const SdrLayerID nLayer
= pObj
->GetLayer();
131 SwAccessibleChildMapKey::LayerId eLayerId
=
133 ? SwAccessibleChildMapKey::HELL
134 : ( (mnControlsId
== nLayer
)
135 ? SwAccessibleChildMapKey::CONTROLS
136 : SwAccessibleChildMapKey::HEAVEN
);
137 SwAccessibleChildMapKey
aKey( eLayerId
, pObj
->GetOrdNum() );
138 return emplace( aKey
, rLower
);
141 bool SwAccessibleChildMap::IsSortingRequired( const SwFrame
& rFrame
)
143 return ( rFrame
.IsPageFrame() &&
144 static_cast< const SwPageFrame
& >( rFrame
).GetSortedObjs() ) ||
145 ( rFrame
.IsTextFrame() &&
146 rFrame
.GetDrawObjs() );
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */