merge the formfield patch from ooo-build
[ooovba.git] / sw / source / core / objectpositioning / environmentofanchoredobject.cxx
blob01119a9ba383e105760ce6886f60961061befd53
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: environmentofanchoredobject.cxx,v $
10 * $Revision: 1.7 $
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 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 #ifndef _ENVIRONMENTOFANCHOREDOBJECT
34 #include <environmentofanchoredobject.hxx>
35 #endif
36 #include <frame.hxx>
37 #include <pagefrm.hxx>
38 #include <flyfrm.hxx>
40 using namespace objectpositioning;
42 SwEnvironmentOfAnchoredObject::SwEnvironmentOfAnchoredObject(
43 const bool _bFollowTextFlow )
44 : mbFollowTextFlow( _bFollowTextFlow )
47 SwEnvironmentOfAnchoredObject::~SwEnvironmentOfAnchoredObject()
50 /** determine environment layout frame for possible horizontal object positions
52 OD 05.11.2003
54 @author OD
56 const SwLayoutFrm& SwEnvironmentOfAnchoredObject::GetHoriEnvironmentLayoutFrm(
57 const SwFrm& _rHoriOrientFrm ) const
59 const SwFrm* pHoriEnvironmentLayFrm = &_rHoriOrientFrm;
61 if ( !mbFollowTextFlow )
63 // --> OD 2005-01-20 #118546# - no exception any more for page alignment.
64 // the page frame determines the horizontal layout environment.
65 pHoriEnvironmentLayFrm = _rHoriOrientFrm.FindPageFrm();
66 // <--
68 else
70 while ( !pHoriEnvironmentLayFrm->IsCellFrm() &&
71 !pHoriEnvironmentLayFrm->IsFlyFrm() &&
72 !pHoriEnvironmentLayFrm->IsPageFrm() )
74 pHoriEnvironmentLayFrm = pHoriEnvironmentLayFrm->GetUpper();
75 ASSERT( pHoriEnvironmentLayFrm,
76 "SwEnvironmentOfAnchoredObject::GetHoriEnvironmentLayoutFrm(..) - no page|fly|cell frame found" );
80 ASSERT( pHoriEnvironmentLayFrm->ISA(SwLayoutFrm),
81 "SwEnvironmentOfAnchoredObject::GetHoriEnvironmentLayoutFrm(..) - found frame isn't a layout frame" );
83 return static_cast<const SwLayoutFrm&>(*pHoriEnvironmentLayFrm);
86 /** determine environment layout frame for possible vertical object positions
88 OD 05.11.2003
90 @author OD
92 const SwLayoutFrm& SwEnvironmentOfAnchoredObject::GetVertEnvironmentLayoutFrm(
93 const SwFrm& _rVertOrientFrm ) const
95 const SwFrm* pVertEnvironmentLayFrm = &_rVertOrientFrm;
97 if ( !mbFollowTextFlow )
99 // --> OD 2005-01-20 #118546# - no exception any more for page alignment.
100 // the page frame determines the vertical layout environment.
101 pVertEnvironmentLayFrm = _rVertOrientFrm.FindPageFrm();
102 // <--
104 else
106 while ( !pVertEnvironmentLayFrm->IsCellFrm() &&
107 !pVertEnvironmentLayFrm->IsFlyFrm() &&
108 !pVertEnvironmentLayFrm->IsHeaderFrm() &&
109 !pVertEnvironmentLayFrm->IsFooterFrm() &&
110 !pVertEnvironmentLayFrm->IsFtnFrm() &&
111 !pVertEnvironmentLayFrm->IsPageBodyFrm() &&
112 !pVertEnvironmentLayFrm->IsPageFrm() )
114 pVertEnvironmentLayFrm = pVertEnvironmentLayFrm->GetUpper();
115 ASSERT( pVertEnvironmentLayFrm,
116 "SwEnvironmentOfAnchoredObject::GetVertEnvironmentLayoutFrm(..) - proposed frame not found" );
120 ASSERT( pVertEnvironmentLayFrm->ISA(SwLayoutFrm),
121 "SwEnvironmentOfAnchoredObject::GetVertEnvironmentLayoutFrm(..) - found frame isn't a layout frame" );
123 return static_cast<const SwLayoutFrm&>(*pVertEnvironmentLayFrm);