xref: /AOO41X/main/sw/source/core/access/accframe.hxx (revision 5ff14ef2c455a7c2a39819566d74aed4bcc9528e)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _ACCFRAME_HXX
24 #define _ACCFRAME_HXX
25 
26 #include <swrect.hxx>
27 
28 #include <sal/types.h>
29 #include <tools/string.hxx>
30 
31 #include <list>
32 #include <accfrmobj.hxx>
33 
34 class SwAccessibleMap;
35 class SwFrm;
36 class ViewShell;
37 namespace sw { namespace access {
38     class SwAccessibleChild;
39 }}
40 
41 // Any method of this class must be called with an acquired solar mutex!
42 
43 class SwAccessibleFrame
44 {
45 	SwRect maVisArea;
46     const SwFrm* mpFrm;
47     const sal_Bool mbIsInPagePreview;
48 
49 protected:
50     // --> OD 2007-06-29 #i77106#
51     // method needs to be called by new class <SwAccessibleTableColHeaders>
52     static sal_Int32 GetChildCount( SwAccessibleMap& rAccMap,
53                                     const SwRect& rVisArea,
54 									const SwFrm *pFrm,
55                                     sal_Bool bInPagePreviewr );
56 
57 // private:
58     static sw::access::SwAccessibleChild GetChild( SwAccessibleMap& rAccMap,
59                                                    const SwRect& rVisArea,
60                                                    const SwFrm& rFrm,
61                                                    sal_Int32& rPos,
62                                                    sal_Bool bInPagePreview);
63 
64     static sal_Bool GetChildIndex( SwAccessibleMap& rAccMap,
65                                    const SwRect& rVisArea,
66                                    const SwFrm& rFrm,
67                                    const sw::access::SwAccessibleChild& rChild,
68                                    sal_Int32& rPos,
69                                    sal_Bool bInPagePreview );
70 
71     static sw::access::SwAccessibleChild GetChildAtPixel( const SwRect& rVisArea,
72                                                           const SwFrm& rFrm,
73                                                           const Point& rPos,
74                                                           sal_Bool bInPagePreview,
75                                                           SwAccessibleMap& rAccMap );
76 
77     static void GetChildren( SwAccessibleMap& rAccMap,
78                              const SwRect& rVisArea,
79                              const SwFrm& rFrm,
80                              ::std::list< sw::access::SwAccessibleChild >& rChildren,
81                              sal_Bool bInPagePreview );
82 
83 protected:
84 
85 	sal_Bool IsEditable( ViewShell *pVSh ) const;
86 
87 	sal_Bool IsOpaque( ViewShell *pVSh ) const;
88 
89     sal_Bool IsShowing( const SwAccessibleMap& rAccMap,
90                         const sw::access::SwAccessibleChild& rFrmOrObj ) const;
91 	inline sal_Bool IsShowing( const SwRect& rFrm ) const;
92     inline sal_Bool IsShowing( const SwAccessibleMap& rAccMap ) const;
93 
94     inline sal_Bool IsInPagePreview() const
95     {
96         return mbIsInPagePreview;
97     }
98 
99     inline void ClearFrm()
100     {
101         mpFrm = 0;
102     }
103 
104 	SwAccessibleFrame( const SwRect& rVisArea,
105 					   const SwFrm *pFrm,
106                        sal_Bool bIsPagePreview );
107 	virtual ~SwAccessibleFrame();
108 
109 	//IAccessibility2 Implementation 2009-----
110 	// MT: Move to private area?
111 	sal_Bool bIsAccDocUse;
112 	//-----IAccessibility2 Implementation 2009
113 
114 
115 public:
116 	// Return the SwFrm this context is attached to.
117     const SwFrm* GetFrm() const { return mpFrm; };
118 
119     static const SwFrm* GetParent( const sw::access::SwAccessibleChild& rFrmOrObj,
120                                    sal_Bool bInPagePreview );
121 
122     sal_Int32 GetChildIndex( SwAccessibleMap& rAccMap,
123                              const sw::access::SwAccessibleChild& rChild ) const;
124 
125 protected:
126 
127 	// Return the bounding box of the frame clipped to the vis area. If
128 	// no frame is specified, use this' frame.
129     SwRect GetBounds( const SwAccessibleMap& rAccMap,
130                       const SwFrm *pFrm = 0 );
131 
132 	// Return the upper that has a context attached. This might be
133 	// another one than the immediate upper.
134 	inline const SwFrm *GetParent() const;
135 
136 	// Return the lower count or the nth lower, there the lowers have a
137 	// not be same one as the SwFrm's lowers
138     sal_Int32 GetChildCount( SwAccessibleMap& rAccMap ) const;
139     sw::access::SwAccessibleChild GetChild( SwAccessibleMap& rAccMap,
140                                             sal_Int32 nPos ) const;
141     sw::access::SwAccessibleChild GetChildAtPixel( const Point& rPos,
142                                                    SwAccessibleMap& rAccMap ) const;
143     void GetChildren( SwAccessibleMap& rAccMap,
144                       ::std::list< sw::access::SwAccessibleChild >& rChildren ) const;
145 
146     inline void SetVisArea( const SwRect& rNewVisArea )
147     {
148         maVisArea = rNewVisArea;
149     }
150 
151     inline const SwRect& GetVisArea() const
152     {
153         return maVisArea;
154     }
155 
156 
157 	String GetFormattedPageNumber() const;
158 };
159 
160 inline sal_Bool SwAccessibleFrame::IsShowing( const SwRect& rFrm ) const
161 {
162 	return rFrm.IsOver( maVisArea );
163 }
164 
165 inline sal_Bool SwAccessibleFrame::IsShowing( const SwAccessibleMap& rAccMap ) const
166 {
167     sw::access::SwAccessibleChild aFrmOrObj( GetFrm() );
168     return IsShowing( rAccMap, aFrmOrObj );
169 }
170 
171 inline const SwFrm *SwAccessibleFrame::GetParent() const
172 {
173     sw::access::SwAccessibleChild aFrmOrObj( GetFrm() );
174 	return GetParent( aFrmOrObj, IsInPagePreview()  );
175 }
176 
177 #endif
178 
179