1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: environmentofanchoredobject.cxx,v $
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>
37 #include <pagefrm.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
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();
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
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();
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
);