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 "accframe.hxx"
22 #include <accmap.hxx>
23 #include "acccontext.hxx"
24 
25 #include <viewsh.hxx>
26 #include <doc.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 
40  const SwFrame& rFrame,
41  SwAccessibleMap& rAccMap )
42  : mnHellId( rAccMap.GetShell()->GetDoc()->getIDocumentDrawModelAccess().GetHellId() )
43  , mnControlsId( rAccMap.GetShell()->GetDoc()->getIDocumentDrawModelAccess().GetControlsId() )
44 {
45  const bool bVisibleChildrenOnly = SwAccessibleChild( &rFrame ).IsVisibleChildrenOnly();
46 
47  sal_uInt32 nPos = 0;
48  SwAccessibleChild aLower( rFrame.GetLower() );
49  while( aLower.GetSwFrame() )
50  {
51  if ( !bVisibleChildrenOnly ||
52  aLower.AlwaysIncludeAsChild() ||
53  aLower.GetBox( rAccMap ).IsOver( rVisArea ) )
54  {
55  insert( nPos++, SwAccessibleChildMapKey::TEXT, aLower );
56  }
57 
58  aLower = aLower.GetSwFrame()->GetNext();
59  }
60 
61  if ( rFrame.IsPageFrame() )
62  {
63  OSL_ENSURE( bVisibleChildrenOnly, "page frame within tab frame???" );
64  const SwPageFrame *pPgFrame =
65  static_cast< const SwPageFrame * >( &rFrame );
66  const SwSortedObjs *pObjs = pPgFrame->GetSortedObjs();
67  if ( pObjs )
68  {
69  for(const SwAnchoredObject* pObj : *pObjs)
70  {
71  aLower = pObj->GetDrawObj();
72  if ( aLower.GetBox( rAccMap ).IsOver( rVisArea ) )
73  {
74  insert( aLower.GetDrawObject(), aLower );
75  }
76  }
77  }
78  }
79  else if( rFrame.IsTextFrame() )
80  {
81  const SwSortedObjs *pObjs = rFrame.GetDrawObjs();
82  if ( pObjs )
83  {
84  for(const SwAnchoredObject* pObj : *pObjs)
85  {
86  aLower = pObj->GetDrawObj();
87  if ( aLower.IsBoundAsChar() &&
88  ( !bVisibleChildrenOnly ||
89  aLower.AlwaysIncludeAsChild() ||
90  aLower.GetBox( rAccMap ).IsOver( rVisArea ) ) )
91  {
92  insert( aLower.GetDrawObject(), aLower );
93  }
94  }
95  }
96 
97  {
99  rAccMap.GetContextImpl( &rFrame, false );
100  if( xAccImpl.is() )
101  {
102  SwAccessibleContext* pAccImpl = xAccImpl.get();
103  if ( pAccImpl &&
104  pAccImpl->HasAdditionalAccessibleChildren() )
105  {
106  std::vector< vcl::Window* > aAdditionalChildren;
107  pAccImpl->GetAdditionalAccessibleChildren( &aAdditionalChildren );
108 
109  sal_Int32 nCounter( 0 );
110  for ( const auto& rpChild : aAdditionalChildren )
111  {
112  aLower = rpChild;
113  insert( ++nCounter, SwAccessibleChildMapKey::XWINDOW, aLower );
114  }
115  }
116  }
117  }
118  }
119 }
120 
121 std::pair< SwAccessibleChildMap::iterator, bool > SwAccessibleChildMap::insert(
122  const sal_uInt32 nPos,
123  const SwAccessibleChildMapKey::LayerId eLayerId,
124  const SwAccessibleChild& rLower )
125 {
126  SwAccessibleChildMapKey aKey( eLayerId, nPos );
127  return emplace( aKey, rLower );
128 }
129 
130 std::pair< SwAccessibleChildMap::iterator, bool > SwAccessibleChildMap::insert(
131  const SdrObject *pObj,
132  const SwAccessibleChild& rLower )
133 {
134  const SdrLayerID nLayer = pObj->GetLayer();
136  (mnHellId == nLayer)
138  : ( (mnControlsId == nLayer)
141  SwAccessibleChildMapKey aKey( eLayerId, pObj->GetOrdNum() );
142  return emplace( aKey, rLower );
143 }
144 
146 {
147  return ( rFrame.IsPageFrame() &&
148  static_cast< const SwPageFrame& >( rFrame ).GetSortedObjs() ) ||
149  ( rFrame.IsTextFrame() &&
150  rFrame.GetDrawObjs() );
151 }
152 
153 /* 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:1938
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:204
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