xref: /trunk/main/sw/source/core/access/accframe.hxx (revision 4d7c9de0)
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 
IsInPagePreview() const94     inline sal_Bool IsInPagePreview() const
95     {
96         return mbIsInPagePreview;
97     }
98 
ClearFrm()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 	// MT: Move to private area?
110 	sal_Bool bIsAccDocUse;
111 
112 
113 public:
114 	// Return the SwFrm this context is attached to.
GetFrm() const115     const SwFrm* GetFrm() const { return mpFrm; };
116 
117     static const SwFrm* GetParent( const sw::access::SwAccessibleChild& rFrmOrObj,
118                                    sal_Bool bInPagePreview );
119 
120     sal_Int32 GetChildIndex( SwAccessibleMap& rAccMap,
121                              const sw::access::SwAccessibleChild& rChild ) const;
122 
123 protected:
124 
125 	// Return the bounding box of the frame clipped to the vis area. If
126 	// no frame is specified, use this' frame.
127     SwRect GetBounds( const SwAccessibleMap& rAccMap,
128                       const SwFrm *pFrm = 0 );
129 
130 	// Return the upper that has a context attached. This might be
131 	// another one than the immediate upper.
132 	inline const SwFrm *GetParent() const;
133 
134 	// Return the lower count or the nth lower, there the lowers have a
135 	// not be same one as the SwFrm's lowers
136     sal_Int32 GetChildCount( SwAccessibleMap& rAccMap ) const;
137     sw::access::SwAccessibleChild GetChild( SwAccessibleMap& rAccMap,
138                                             sal_Int32 nPos ) const;
139     sw::access::SwAccessibleChild GetChildAtPixel( const Point& rPos,
140                                                    SwAccessibleMap& rAccMap ) const;
141     void GetChildren( SwAccessibleMap& rAccMap,
142                       ::std::list< sw::access::SwAccessibleChild >& rChildren ) const;
143 
SetVisArea(const SwRect & rNewVisArea)144     inline void SetVisArea( const SwRect& rNewVisArea )
145     {
146         maVisArea = rNewVisArea;
147     }
148 
GetVisArea() const149     inline const SwRect& GetVisArea() const
150     {
151         return maVisArea;
152     }
153 
154 
155 	String GetFormattedPageNumber() const;
156 };
157 
IsShowing(const SwRect & rFrm) const158 inline sal_Bool SwAccessibleFrame::IsShowing( const SwRect& rFrm ) const
159 {
160 	return rFrm.IsOver( maVisArea );
161 }
162 
IsShowing(const SwAccessibleMap & rAccMap) const163 inline sal_Bool SwAccessibleFrame::IsShowing( const SwAccessibleMap& rAccMap ) const
164 {
165     sw::access::SwAccessibleChild aFrmOrObj( GetFrm() );
166     return IsShowing( rAccMap, aFrmOrObj );
167 }
168 
GetParent() const169 inline const SwFrm *SwAccessibleFrame::GetParent() const
170 {
171     sw::access::SwAccessibleChild aFrmOrObj( GetFrm() );
172 	return GetParent( aFrmOrObj, IsInPagePreview()  );
173 }
174 
175 #endif
176 
177