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 #ifndef INCLUDED_SW_SOURCE_CORE_ACCESS_ACCFRMOBJMAP_HXX
21 #define INCLUDED_SW_SOURCE_CORE_ACCESS_ACCFRMOBJMAP_HXX
22 
23 #include <tools/gen.hxx>
24 #include <svx/svdtypes.hxx>
25 #include "accfrmobj.hxx"
26 #include <map>
27 
28 class SwAccessibleMap;
29 class SwRect;
30 class SwFrame;
31 class SdrObject;
32 
33 class SwAccessibleChildMapKey
34 {
35 public:
36     enum LayerId { INVALID, HELL, TEXT, HEAVEN, CONTROLS, XWINDOW };
37 
SwAccessibleChildMapKey()38     SwAccessibleChildMapKey()
39         : m_eLayerId( INVALID )
40         , m_nOrdNum( 0 )
41         , m_nPosNum( 0, 0 )
42     {}
43 
SwAccessibleChildMapKey(LayerId eId,sal_uInt32 nOrd)44     SwAccessibleChildMapKey( LayerId eId, sal_uInt32 nOrd )
45         : m_eLayerId( eId )
46         , m_nOrdNum( nOrd )
47         , m_nPosNum( 0, 0 )
48     {}
49 
operator ()(const SwAccessibleChildMapKey & r1,const SwAccessibleChildMapKey & r2) const50     bool operator()( const SwAccessibleChildMapKey& r1,
51                             const SwAccessibleChildMapKey& r2 ) const
52     {
53         if(r1.m_eLayerId == r2.m_eLayerId)
54         {
55             if(r1.m_nPosNum == r2.m_nPosNum)
56                 return r1.m_nOrdNum < r2.m_nOrdNum;
57             else
58             {
59                 if(r1.m_nPosNum.getY() == r2.m_nPosNum.getY())
60                     return r1.m_nPosNum.getX() < r2.m_nPosNum.getX();
61                 else
62                     return r1.m_nPosNum.getY() < r2.m_nPosNum.getY();
63             }
64         }
65         else
66             return r1.m_eLayerId < r2.m_eLayerId;
67     }
68 
69     /* MT: Need to get this position parameter stuff in dev300 somehow...
70     //This methods are used to insert an object to the map, adding a position parameter.
71     std::pair< iterator, bool > insert( sal_uInt32 nOrd, Point nPos,
72                                           const SwFrameOrObj& rLower );
73     std::pair< iterator, bool > insert( const SdrObject *pObj,
74                                           const SwFrameOrObj& rLower,
75                                           const SwDoc *pDoc,
76                                           Point nPos);
77     */
78 
79 private:
80     LayerId m_eLayerId;
81     sal_uInt32 m_nOrdNum;
82     Point m_nPosNum;
83 };
84 
85 
86 class SwAccessibleChildMap
87 {
88 public:
89     typedef SwAccessibleChildMapKey                                             key_type;
90     typedef sw::access::SwAccessibleChild                                       mapped_type;
91     typedef std::pair<const key_type,mapped_type>                               value_type;
92     typedef SwAccessibleChildMapKey                                             key_compare;
93     typedef std::map<key_type,mapped_type,key_compare>::iterator                iterator;
94     typedef std::map<key_type,mapped_type,key_compare>::const_iterator          const_iterator;
95     typedef std::map<key_type,mapped_type,key_compare>::const_reverse_iterator  const_reverse_iterator;
96 
97 private:
98     const SdrLayerID mnHellId;
99     const SdrLayerID mnControlsId;
100     std::map<key_type,mapped_type,key_compare> maMap;
101 
102     std::pair< iterator, bool > insert( const sal_uInt32 nPos,
103                                           const SwAccessibleChildMapKey::LayerId eLayerId,
104                                           const sw::access::SwAccessibleChild& rLower );
105     std::pair< iterator, bool > insert( const SdrObject* pObj,
106                                           const sw::access::SwAccessibleChild& rLower );
107 
108 public:
109     SwAccessibleChildMap( const SwRect& rVisArea,
110                           const SwFrame& rFrame,
111                           SwAccessibleMap& rAccMap );
112 
113     static bool IsSortingRequired( const SwFrame& rFrame );
114 
cbegin() const115     const_iterator cbegin() const { return maMap.cbegin(); }
cend() const116     const_iterator cend() const { return maMap.cend(); }
crbegin() const117     const_reverse_iterator crbegin() const { return maMap.crbegin(); }
crend() const118     const_reverse_iterator crend() const { return maMap.crend(); }
119 
120     template<class... Args>
emplace(Args &&...args)121     std::pair<iterator,bool> emplace(Args&&... args) { return maMap.emplace(std::forward<Args>(args)...); }
122 };
123 
124 #endif
125 
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
127