LibreOffice Module sw (master) 1
accfrmobjmap.cxx
Go to the documentation of this file.
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 <accmap.hxx>
22#include "acccontext.hxx"
23
24#include <viewsh.hxx>
25#include <doc.hxx>
27#include <pagefrm.hxx>
28#include <sortedobjs.hxx>
29#include <anchoredobject.hxx>
30
31#include <svx/svdobj.hxx>
32
33using namespace sw::access;
34
36 const SwFrame& rFrame,
37 SwAccessibleMap& rAccMap )
38 : mnHellId( rAccMap.GetShell()->GetDoc()->getIDocumentDrawModelAccess().GetHellId() )
39 , mnControlsId( rAccMap.GetShell()->GetDoc()->getIDocumentDrawModelAccess().GetControlsId() )
40{
41 const bool bVisibleChildrenOnly = SwAccessibleChild( &rFrame ).IsVisibleChildrenOnly();
42
43 sal_uInt32 nPos = 0;
44 SwAccessibleChild aLower( rFrame.GetLower() );
45 while( aLower.GetSwFrame() )
46 {
47 if ( !bVisibleChildrenOnly ||
48 aLower.AlwaysIncludeAsChild() ||
49 aLower.GetBox( rAccMap ).Overlaps( rVisArea ) )
50 {
52 }
53
54 aLower = aLower.GetSwFrame()->GetNext();
55 }
56
57 if ( rFrame.IsPageFrame() )
58 {
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();
63 if ( pObjs )
64 {
65 for(const SwAnchoredObject* pObj : *pObjs)
66 {
67 aLower = pObj->GetDrawObj();
68 if ( aLower.GetBox( rAccMap ).Overlaps( rVisArea ) )
69 {
70 insert( aLower.GetDrawObject(), aLower );
71 }
72 }
73 }
74 }
75 else if( rFrame.IsTextFrame() )
76 {
77 const SwSortedObjs *pObjs = rFrame.GetDrawObjs();
78 if ( pObjs )
79 {
80 for(const SwAnchoredObject* pObj : *pObjs)
81 {
82 aLower = pObj->GetDrawObj();
83 if ( aLower.IsBoundAsChar() &&
84 ( !bVisibleChildrenOnly ||
85 aLower.AlwaysIncludeAsChild() ||
86 aLower.GetBox( rAccMap ).Overlaps( rVisArea ) ) )
87 {
88 insert( aLower.GetDrawObject(), aLower );
89 }
90 }
91 }
92
93 {
95 rAccMap.GetContextImpl( &rFrame, false );
96 if( xAccImpl.is() )
97 {
98 SwAccessibleContext* pAccImpl = xAccImpl.get();
99 if ( pAccImpl &&
101 {
102 std::vector< vcl::Window* > aAdditionalChildren;
103 pAccImpl->GetAdditionalAccessibleChildren( &aAdditionalChildren );
104
105 sal_Int32 nCounter( 0 );
106 for ( const auto& rpChild : aAdditionalChildren )
107 {
108 aLower = rpChild;
109 insert( ++nCounter, SwAccessibleChildMapKey::XWINDOW, aLower );
110 }
111 }
112 }
113 }
114 }
115}
116
117std::pair< SwAccessibleChildMap::iterator, bool > SwAccessibleChildMap::insert(
118 const sal_uInt32 nPos,
120 const SwAccessibleChild& rLower )
121{
122 SwAccessibleChildMapKey aKey( eLayerId, nPos );
123 return emplace( aKey, rLower );
124}
125
126std::pair< SwAccessibleChildMap::iterator, bool > SwAccessibleChildMap::insert(
127 const SdrObject *pObj,
128 const SwAccessibleChild& rLower )
129{
130 const SdrLayerID nLayer = pObj->GetLayer();
132 (mnHellId == nLayer)
134 : ( (mnControlsId == nLayer)
137 SwAccessibleChildMapKey aKey( eLayerId, pObj->GetOrdNum() );
138 return emplace( aKey, rLower );
139}
140
142{
143 return ( rFrame.IsPageFrame() &&
144 static_cast< const SwPageFrame& >( rFrame ).GetSortedObjs() ) ||
145 ( rFrame.IsTextFrame() &&
146 rFrame.GetDrawObjs() );
147}
148
149/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt32 GetOrdNum() const
virtual SdrLayerID GetLayer() const
SwAccessibleChildMap(const SwRect &rVisArea, const SwFrame &rFrame, SwAccessibleMap &rAccMap)
const SdrLayerID mnHellId
static bool IsSortingRequired(const SwFrame &rFrame)
const SdrLayerID mnControlsId
std::pair< iterator, bool > emplace(Args &&... args)
std::pair< iterator, bool > insert(const sal_uInt32 nPos, const SwAccessibleChildMapKey::LayerId eLayerId, const sw::access::SwAccessibleChild &rLower)
void GetAdditionalAccessibleChildren(std::vector< vcl::Window * > *pChildren)
#i88070# - get all additional accessible children
bool HasAdditionalAccessibleChildren()
::rtl::Reference< SwAccessibleContext > GetContextImpl(const SwFrame *pFrame, bool bCreate=true)
Definition: accmap.cxx:1914
wrapper class for the positioning of Writer fly frames and drawing objects
Base class of the Writer layout elements.
Definition: frame.hxx:315
bool IsTextFrame() const
Definition: frame.hxx:1240
SwFrame * GetNext()
Definition: frame.hxx:682
bool IsPageFrame() const
Definition: frame.hxx:1184
const SwSortedObjs * GetDrawObjs() const
Definition: frame.hxx:568
SwFrame * GetLower()
Definition: findfrm.cxx:196
A page of the document layout.
Definition: pagefrm.hxx:60
const SwSortedObjs * GetSortedObjs() const
Definition: pagefrm.hxx:136
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
bool Overlaps(const SwRect &rRect) const
Definition: swrect.hxx:374
class for collecting anchored objects
Definition: sortedobjs.hxx:49
SwRect GetBox(const SwAccessibleMap &rAccMap) const
Definition: accfrmobj.cxx:213
const SwFrame * GetSwFrame() const
Definition: accfrmobj.hxx:63
bool AlwaysIncludeAsChild() const
indicating, if accessible child is included even, if the corresponding object is not visible.
Definition: accfrmobj.cxx:290
bool IsVisibleChildrenOnly() const
Definition: accfrmobj.cxx:193
const SdrObject * GetDrawObject() const
Definition: accfrmobj.hxx:64
sal_uInt16 nPos
Shell * GetShell()