xref: /AOO41X/main/sw/source/core/objectpositioning/environmentofanchoredobject.cxx (revision efeef26f81c84063fb0a91bde3856d4a51172d90)
1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*efeef26fSAndrew Rist  * distributed with this work for additional information
6*efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*efeef26fSAndrew Rist  * specific language governing permissions and limitations
18*efeef26fSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*efeef26fSAndrew Rist  *************************************************************/
21*efeef26fSAndrew Rist 
22*efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir #ifndef _ENVIRONMENTOFANCHOREDOBJECT
27cdf0e10cSrcweir #include <environmentofanchoredobject.hxx>
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir #include <frame.hxx>
30cdf0e10cSrcweir #include <pagefrm.hxx>
31cdf0e10cSrcweir #include <flyfrm.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir using namespace objectpositioning;
34cdf0e10cSrcweir 
SwEnvironmentOfAnchoredObject(const bool _bFollowTextFlow)35cdf0e10cSrcweir SwEnvironmentOfAnchoredObject::SwEnvironmentOfAnchoredObject(
36cdf0e10cSrcweir                                                 const bool   _bFollowTextFlow )
37cdf0e10cSrcweir     : mbFollowTextFlow( _bFollowTextFlow )
38cdf0e10cSrcweir {}
39cdf0e10cSrcweir 
~SwEnvironmentOfAnchoredObject()40cdf0e10cSrcweir SwEnvironmentOfAnchoredObject::~SwEnvironmentOfAnchoredObject()
41cdf0e10cSrcweir {}
42cdf0e10cSrcweir 
43cdf0e10cSrcweir /** determine environment layout frame for possible horizontal object positions
44cdf0e10cSrcweir 
45cdf0e10cSrcweir     OD 05.11.2003
46cdf0e10cSrcweir 
47cdf0e10cSrcweir     @author OD
48cdf0e10cSrcweir */
GetHoriEnvironmentLayoutFrm(const SwFrm & _rHoriOrientFrm) const49cdf0e10cSrcweir const SwLayoutFrm& SwEnvironmentOfAnchoredObject::GetHoriEnvironmentLayoutFrm(
50cdf0e10cSrcweir                                             const SwFrm& _rHoriOrientFrm ) const
51cdf0e10cSrcweir {
52cdf0e10cSrcweir     const SwFrm* pHoriEnvironmentLayFrm = &_rHoriOrientFrm;
53cdf0e10cSrcweir 
54cdf0e10cSrcweir     if ( !mbFollowTextFlow )
55cdf0e10cSrcweir     {
56cdf0e10cSrcweir         // --> OD 2005-01-20 #118546# - no exception any more for page alignment.
57cdf0e10cSrcweir         // the page frame determines the horizontal layout environment.
58cdf0e10cSrcweir         pHoriEnvironmentLayFrm = _rHoriOrientFrm.FindPageFrm();
59cdf0e10cSrcweir         // <--
60cdf0e10cSrcweir     }
61cdf0e10cSrcweir     else
62cdf0e10cSrcweir     {
63cdf0e10cSrcweir         while ( !pHoriEnvironmentLayFrm->IsCellFrm() &&
64cdf0e10cSrcweir                 !pHoriEnvironmentLayFrm->IsFlyFrm() &&
65cdf0e10cSrcweir                 !pHoriEnvironmentLayFrm->IsPageFrm() )
66cdf0e10cSrcweir         {
67cdf0e10cSrcweir             pHoriEnvironmentLayFrm = pHoriEnvironmentLayFrm->GetUpper();
68cdf0e10cSrcweir             ASSERT( pHoriEnvironmentLayFrm,
69cdf0e10cSrcweir                     "SwEnvironmentOfAnchoredObject::GetHoriEnvironmentLayoutFrm(..) - no page|fly|cell frame found" );
70cdf0e10cSrcweir         }
71cdf0e10cSrcweir     }
72cdf0e10cSrcweir 
73cdf0e10cSrcweir     ASSERT( pHoriEnvironmentLayFrm->ISA(SwLayoutFrm),
74cdf0e10cSrcweir                 "SwEnvironmentOfAnchoredObject::GetHoriEnvironmentLayoutFrm(..) - found frame isn't a layout frame" );
75cdf0e10cSrcweir 
76cdf0e10cSrcweir     return static_cast<const SwLayoutFrm&>(*pHoriEnvironmentLayFrm);
77cdf0e10cSrcweir }
78cdf0e10cSrcweir 
79cdf0e10cSrcweir /** determine environment layout frame for possible vertical object positions
80cdf0e10cSrcweir 
81cdf0e10cSrcweir     OD 05.11.2003
82cdf0e10cSrcweir 
83cdf0e10cSrcweir     @author OD
84cdf0e10cSrcweir */
GetVertEnvironmentLayoutFrm(const SwFrm & _rVertOrientFrm) const85cdf0e10cSrcweir const SwLayoutFrm& SwEnvironmentOfAnchoredObject::GetVertEnvironmentLayoutFrm(
86cdf0e10cSrcweir                                             const SwFrm& _rVertOrientFrm ) const
87cdf0e10cSrcweir {
88cdf0e10cSrcweir     const SwFrm* pVertEnvironmentLayFrm = &_rVertOrientFrm;
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     if ( !mbFollowTextFlow )
91cdf0e10cSrcweir     {
92cdf0e10cSrcweir         // --> OD 2005-01-20 #118546# - no exception any more for page alignment.
93cdf0e10cSrcweir         // the page frame determines the vertical layout environment.
94cdf0e10cSrcweir         pVertEnvironmentLayFrm = _rVertOrientFrm.FindPageFrm();
95cdf0e10cSrcweir         // <--
96cdf0e10cSrcweir     }
97cdf0e10cSrcweir     else
98cdf0e10cSrcweir     {
99cdf0e10cSrcweir         while ( !pVertEnvironmentLayFrm->IsCellFrm() &&
100cdf0e10cSrcweir                 !pVertEnvironmentLayFrm->IsFlyFrm() &&
101cdf0e10cSrcweir                 !pVertEnvironmentLayFrm->IsHeaderFrm() &&
102cdf0e10cSrcweir                 !pVertEnvironmentLayFrm->IsFooterFrm() &&
103cdf0e10cSrcweir                 !pVertEnvironmentLayFrm->IsFtnFrm() &&
104cdf0e10cSrcweir                 !pVertEnvironmentLayFrm->IsPageBodyFrm() &&
105cdf0e10cSrcweir                 !pVertEnvironmentLayFrm->IsPageFrm() )
106cdf0e10cSrcweir         {
107cdf0e10cSrcweir             pVertEnvironmentLayFrm = pVertEnvironmentLayFrm->GetUpper();
108cdf0e10cSrcweir             ASSERT( pVertEnvironmentLayFrm,
109cdf0e10cSrcweir                     "SwEnvironmentOfAnchoredObject::GetVertEnvironmentLayoutFrm(..) - proposed frame not found" );
110cdf0e10cSrcweir         }
111cdf0e10cSrcweir     }
112cdf0e10cSrcweir 
113cdf0e10cSrcweir     ASSERT( pVertEnvironmentLayFrm->ISA(SwLayoutFrm),
114cdf0e10cSrcweir                 "SwEnvironmentOfAnchoredObject::GetVertEnvironmentLayoutFrm(..) - found frame isn't a layout frame" );
115cdf0e10cSrcweir 
116cdf0e10cSrcweir     return static_cast<const SwLayoutFrm&>(*pVertEnvironmentLayFrm);
117cdf0e10cSrcweir }
118