merge the formfield patch from ooo-build
[ooovba.git] / sw / source / core / access / accfrmobj.hxx
blob2e08d933721cec51983517c8356aced16e47bf17
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: accfrmobj.hxx,v $
10 * $Revision: 1.16 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _ACCFRMOBJ_HXX
31 #define _ACCFRMOBJ_HXX
32 #include <flyfrm.hxx>
33 #include <pagefrm.hxx>
34 #include <dflyobj.hxx>
35 #include <swtable.hxx>
37 class SwFrmOrObj
39 const SdrObject *pObj;
40 const SwFrm *pFrm;
42 inline void Init( const SdrObject *pO );
43 inline void Init( const SwFrm *pF );
45 public:
47 inline SwFrmOrObj();
48 inline SwFrmOrObj( const SdrObject *pO );
49 inline SwFrmOrObj( const SwFrm *pF );
50 inline SwFrmOrObj( const SwFrm *pF, const SdrObject *pO );
51 inline SwFrmOrObj( const SwFrmOrObj& r );
53 inline SwFrmOrObj& operator=( const SwFrmOrObj& r );
54 inline SwFrmOrObj& operator=( const SdrObject *pO );
55 inline SwFrmOrObj& operator=( const SwFrm *pF );
57 inline sal_Bool operator==( const SwFrmOrObj& r ) const;
58 inline sal_Bool operator==( const SdrObject *pO ) const;
59 inline sal_Bool operator==( const SwFrm *pF ) const;
61 inline sal_Bool IsValid() const;
63 inline const SdrObject *GetSdrObject() const;
64 inline const SwFrm *GetSwFrm() const;
66 sal_Bool IsAccessible( sal_Bool bPagePreview ) const;
67 sal_Bool IsBoundAsChar() const;
68 inline sal_Bool IsVisibleChildrenOnly() const;
69 inline SwRect GetBox() const;
70 inline SwRect GetBounds() const;
73 inline void SwFrmOrObj::Init( const SdrObject *pO )
75 pObj = pO;
76 // #110094#-1
77 pFrm = pObj && pObj->ISA(SwVirtFlyDrawObj)
78 ? static_cast < const SwVirtFlyDrawObj * >( pObj )->GetFlyFrm()
79 : 0;
82 inline void SwFrmOrObj::Init( const SwFrm *pF )
84 pFrm = pF;
85 pObj = pFrm && pFrm->IsFlyFrm()
86 ? static_cast < const SwFlyFrm * >( pFrm )->GetVirtDrawObj()
87 : 0;
90 inline SwFrmOrObj::SwFrmOrObj() :
91 pObj( 0 ), pFrm( 0 )
94 inline SwFrmOrObj::SwFrmOrObj( const SdrObject *pO )
96 Init( pO );
99 inline SwFrmOrObj::SwFrmOrObj( const SwFrm *pF )
101 Init( pF );
104 inline SwFrmOrObj::SwFrmOrObj( const SwFrm *pF, const SdrObject *pO )
106 if( pF )
107 Init( pF );
108 else
109 Init( pO );
110 ASSERT( (!pF || pF == pFrm) && (!pO || pO == pObj),
111 "invalid frame/object combination" );
115 inline SwFrmOrObj::SwFrmOrObj( const SwFrmOrObj& r ) :
116 pObj( r.pObj ), pFrm( r.pFrm )
119 inline SwFrmOrObj& SwFrmOrObj::operator=( const SwFrmOrObj& r )
121 pObj = r.pObj;
122 pFrm = r.pFrm;
123 return *this;
126 inline SwFrmOrObj& SwFrmOrObj::operator=( const SdrObject *pO )
128 Init( pO );
129 return *this;
132 inline SwFrmOrObj& SwFrmOrObj::operator=( const SwFrm *pF )
134 Init( pF );
135 return *this;
138 inline sal_Bool SwFrmOrObj::operator==( const SwFrmOrObj& r ) const
140 return pObj == r.pObj && pFrm == r.pFrm;
143 inline sal_Bool SwFrmOrObj::operator==( const SdrObject *pO ) const
145 return pObj == pO;
148 inline sal_Bool SwFrmOrObj::operator==( const SwFrm *pF ) const
150 return pFrm == pF;
153 inline sal_Bool SwFrmOrObj::IsValid() const
155 return pObj != 0 || pFrm != 0;
158 inline const SdrObject *SwFrmOrObj::GetSdrObject() const
160 return pObj;
163 inline const SwFrm *SwFrmOrObj::GetSwFrm() const
165 return pFrm;
168 inline sal_Bool SwFrmOrObj::IsVisibleChildrenOnly() const
170 return !pFrm || pFrm->IsRootFrm() ||
171 !( pFrm->IsTabFrm() || pFrm->IsInTab() ||
172 ( IsBoundAsChar() &&
173 static_cast<const SwFlyFrm*>(pFrm)->GetAnchorFrm()->IsInTab()) );
176 inline SwRect SwFrmOrObj::GetBox() const
178 if( pFrm )
180 if( pFrm->IsPageFrm() &&
181 static_cast< const SwPageFrm * >( pFrm )->IsEmptyPage() )
183 SwRect aBox( pFrm->Frm().Left(), pFrm->Frm().Top()-1, 1, 1 );
184 return aBox;
186 else if ( pFrm->IsTabFrm() )
188 SwRect aBox( pFrm->Frm() );
189 aBox.Intersection( pFrm->GetUpper()->Frm() );
190 return aBox;
192 else
193 return pFrm->Frm();
195 else if( pObj )
196 return SwRect( pObj->GetCurrentBoundRect() );
197 else
198 return SwRect();
201 inline SwRect SwFrmOrObj::GetBounds() const
203 if( pFrm )
205 if( pFrm->IsPageFrm() &&
206 static_cast< const SwPageFrm * >( pFrm )->IsEmptyPage() )
208 SwRect aBox( pFrm->Frm().Left(), pFrm->Frm().Top()-1, 0, 0 );
209 return aBox;
211 else
212 return pFrm->PaintArea();
214 else if( pObj )
215 return SwRect( pObj->GetCurrentBoundRect() );
216 return SwRect();
220 #endif