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 
33 using 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 ).IsOver( rVisArea ) )
50  {
51  insert( nPos++, SwAccessibleChildMapKey::TEXT, aLower );
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 ).IsOver( 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 ).IsOver( 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 &&
100  pAccImpl->HasAdditionalAccessibleChildren() )
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 
117 std::pair< SwAccessibleChildMap::iterator, bool > SwAccessibleChildMap::insert(
118  const sal_uInt32 nPos,
119  const SwAccessibleChildMapKey::LayerId eLayerId,
120  const SwAccessibleChild& rLower )
121 {
122  SwAccessibleChildMapKey aKey( eLayerId, nPos );
123  return emplace( aKey, rLower );
124 }
125 
126 std::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: */
Base class of the Writer layout elements.
Definition: frame.hxx:295
const SwSortedObjs * GetDrawObjs() const
Definition: frame.hxx:543
const SdrLayerID mnControlsId
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
wrapper class for the positioning of Writer fly frames and drawing objects
::rtl::Reference< SwAccessibleContext > GetContextImpl(const SwFrame *pFrame, bool bCreate=true)
Definition: accmap.cxx:1976
bool IsTextFrame() const
Definition: frame.hxx:1210
void GetAdditionalAccessibleChildren(std::vector< vcl::Window * > *pChildren)
#i88070# - get all additional accessible children
std::pair< iterator, bool > emplace(Args &&...args)
bool IsVisibleChildrenOnly() const
Definition: accfrmobj.cxx:202
std::pair< iterator, bool > insert(const sal_uInt32 nPos, const SwAccessibleChildMapKey::LayerId eLayerId, const sw::access::SwAccessibleChild &rLower)
Shell * GetShell()
const SwSortedObjs * GetSortedObjs() const
Definition: pagefrm.hxx:118
bool HasAdditionalAccessibleChildren()
SwAccessibleChildMap(const SwRect &rVisArea, const SwFrame &rFrame, SwAccessibleMap &rAccMap)
sal_uInt32 GetOrdNum() const
A page of the document layout.
Definition: pagefrm.hxx:40
virtual SdrLayerID GetLayer() const
static bool IsSortingRequired(const SwFrame &rFrame)
SwFrame * GetLower()
Definition: findfrm.cxx:169
bool IsPageFrame() const
Definition: frame.hxx:1154
sal_Int32 nPos
class for collecting anchored objects
Definition: sortedobjs.hxx:48
const SdrLayerID mnHellId