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 bInPagePreview ); 56 private: 57 static sw::access::SwAccessibleChild GetChild( SwAccessibleMap& rAccMap, 58 const SwRect& rVisArea, 59 const SwFrm& rFrm, 60 sal_Int32& rPos, 61 sal_Bool bInPagePreview); 62 63 static sal_Bool GetChildIndex( SwAccessibleMap& rAccMap, 64 const SwRect& rVisArea, 65 const SwFrm& rFrm, 66 const sw::access::SwAccessibleChild& rChild, 67 sal_Int32& rPos, 68 sal_Bool bInPagePreview ); 69 70 static sw::access::SwAccessibleChild GetChildAtPixel( const SwRect& rVisArea, 71 const SwFrm& rFrm, 72 const Point& rPos, 73 sal_Bool bInPagePreview, 74 SwAccessibleMap& rAccMap ); 75 76 static void GetChildren( SwAccessibleMap& rAccMap, 77 const SwRect& rVisArea, 78 const SwFrm& rFrm, 79 ::std::list< sw::access::SwAccessibleChild >& rChildren, 80 sal_Bool bInPagePreview ); 81 82 protected: 83 84 sal_Bool IsEditable( ViewShell *pVSh ) const; 85 86 sal_Bool IsOpaque( ViewShell *pVSh ) const; 87 88 sal_Bool IsShowing( const SwAccessibleMap& rAccMap, 89 const sw::access::SwAccessibleChild& rFrmOrObj ) const; 90 inline sal_Bool IsShowing( const SwRect& rFrm ) const; 91 inline sal_Bool IsShowing( const SwAccessibleMap& rAccMap ) const; 92 93 inline sal_Bool IsInPagePreview() const 94 { 95 return mbIsInPagePreview; 96 } 97 98 inline void ClearFrm() 99 { 100 mpFrm = 0; 101 } 102 103 SwAccessibleFrame( const SwRect& rVisArea, 104 const SwFrm *pFrm, 105 sal_Bool bIsPagePreview ); 106 virtual ~SwAccessibleFrame(); 107 108 public: 109 // Return the SwFrm this context is attached to. 110 const SwFrm* GetFrm() const { return mpFrm; }; 111 112 static const SwFrm* GetParent( const sw::access::SwAccessibleChild& rFrmOrObj, 113 sal_Bool bInPagePreview ); 114 115 sal_Int32 GetChildIndex( SwAccessibleMap& rAccMap, 116 const sw::access::SwAccessibleChild& rChild ) const; 117 118 protected: 119 120 // Return the bounding box of the frame clipped to the vis area. If 121 // no frame is specified, use this' frame. 122 SwRect GetBounds( const SwAccessibleMap& rAccMap, 123 const SwFrm *pFrm = 0 ); 124 125 // Return the upper that has a context attached. This might be 126 // another one than the immediate upper. 127 inline const SwFrm *GetParent() const; 128 129 // Return the lower count or the nth lower, there the lowers have a 130 // not be same one as the SwFrm's lowers 131 sal_Int32 GetChildCount( SwAccessibleMap& rAccMap ) const; 132 sw::access::SwAccessibleChild GetChild( SwAccessibleMap& rAccMap, 133 sal_Int32 nPos ) const; 134 sw::access::SwAccessibleChild GetChildAtPixel( const Point& rPos, 135 SwAccessibleMap& rAccMap ) const; 136 void GetChildren( SwAccessibleMap& rAccMap, 137 ::std::list< sw::access::SwAccessibleChild >& rChildren ) const; 138 139 inline void SetVisArea( const SwRect& rNewVisArea ) 140 { 141 maVisArea = rNewVisArea; 142 } 143 144 inline const SwRect& GetVisArea() const 145 { 146 return maVisArea; 147 } 148 149 150 String GetFormattedPageNumber() const; 151 }; 152 153 inline sal_Bool SwAccessibleFrame::IsShowing( const SwRect& rFrm ) const 154 { 155 return rFrm.IsOver( maVisArea ); 156 } 157 158 inline sal_Bool SwAccessibleFrame::IsShowing( const SwAccessibleMap& rAccMap ) const 159 { 160 sw::access::SwAccessibleChild aFrmOrObj( GetFrm() ); 161 return IsShowing( rAccMap, aFrmOrObj ); 162 } 163 164 inline const SwFrm *SwAccessibleFrame::GetParent() const 165 { 166 sw::access::SwAccessibleChild aFrmOrObj( GetFrm() ); 167 return GetParent( aFrmOrObj, IsInPagePreview() ); 168 } 169 170 #endif 171 172