LibreOffice Module sw (master)  1
environmentofanchoredobject.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
21 #include <frame.hxx>
22 #include <pagefrm.hxx>
23 
24 using namespace objectpositioning;
25 
27  const bool _bFollowTextFlow )
28  : mbFollowTextFlow( _bFollowTextFlow )
29 {}
30 
32 {}
33 
36  const SwFrame& _rHoriOrientFrame ) const
37 {
38  const SwFrame* pHoriEnvironmentLayFrame = &_rHoriOrientFrame;
39 
40  if ( !mbFollowTextFlow )
41  {
42  // No exception any more for page alignment.
43  // the page frame determines the horizontal layout environment.
44  pHoriEnvironmentLayFrame = _rHoriOrientFrame.FindPageFrame();
45  }
46  else
47  {
48  while ( !pHoriEnvironmentLayFrame->IsCellFrame() &&
49  !pHoriEnvironmentLayFrame->IsFlyFrame() &&
50  !pHoriEnvironmentLayFrame->IsPageFrame() )
51  {
52  pHoriEnvironmentLayFrame = pHoriEnvironmentLayFrame->GetUpper();
53  OSL_ENSURE( pHoriEnvironmentLayFrame,
54  "SwEnvironmentOfAnchoredObject::GetHoriEnvironmentLayoutFrame(..) - no page|fly|cell frame found" );
55  }
56  }
57 
58  OSL_ENSURE( dynamic_cast< const SwLayoutFrame *>( pHoriEnvironmentLayFrame ) != nullptr,
59  "SwEnvironmentOfAnchoredObject::GetHoriEnvironmentLayoutFrame(..) - found frame isn't a layout frame" );
60 
61  return static_cast<const SwLayoutFrame&>(*pHoriEnvironmentLayFrame);
62 }
63 
66  const SwFrame& _rVertOrientFrame ) const
67 {
68  const SwFrame* pVertEnvironmentLayFrame = &_rVertOrientFrame;
69 
70  if ( !mbFollowTextFlow )
71  {
72  // No exception any more for page alignment.
73  // the page frame determines the vertical layout environment.
74  pVertEnvironmentLayFrame = _rVertOrientFrame.FindPageFrame();
75  }
76  else
77  {
78  while ( !pVertEnvironmentLayFrame->IsCellFrame() &&
79  !pVertEnvironmentLayFrame->IsFlyFrame() &&
80  !pVertEnvironmentLayFrame->IsHeaderFrame() &&
81  !pVertEnvironmentLayFrame->IsFooterFrame() &&
82  !pVertEnvironmentLayFrame->IsFootnoteFrame() &&
83  !pVertEnvironmentLayFrame->IsPageBodyFrame() &&
84  !pVertEnvironmentLayFrame->IsPageFrame() )
85  {
86  pVertEnvironmentLayFrame = pVertEnvironmentLayFrame->GetUpper();
87  OSL_ENSURE( pVertEnvironmentLayFrame,
88  "SwEnvironmentOfAnchoredObject::GetVertEnvironmentLayoutFrame(..) - proposed frame not found" );
89  }
90  }
91 
92  OSL_ENSURE( dynamic_cast< const SwLayoutFrame *>( pVertEnvironmentLayFrame ) != nullptr,
93  "SwEnvironmentOfAnchoredObject::GetVertEnvironmentLayoutFrame(..) - found frame isn't a layout frame" );
94 
95  return static_cast<const SwLayoutFrame&>(*pVertEnvironmentLayFrame);
96 }
97 
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Base class of the Writer layout elements.
Definition: frame.hxx:298
const SwLayoutFrame & GetVertEnvironmentLayoutFrame(const SwFrame &_rVertOrientFrame) const
determine environment layout frame for possible vertical object positions respectively for alignments...
bool IsCellFrame() const
Definition: frame.hxx:1207
bool IsFootnoteFrame() const
Definition: frame.hxx:1183
bool IsFlyFrame() const
Definition: frame.hxx:1191
const SwLayoutFrame & GetHoriEnvironmentLayoutFrame(const SwFrame &_rHoriOrientFrame) const
determine environment layout frame for possible horizontal object positions respectively for alignmen...
bool IsPageBodyFrame() const
Definition: layfrm.hxx:214
SwPageFrame * FindPageFrame()
Definition: frame.hxx:663
SwEnvironmentOfAnchoredObject(const bool _bFollowTextFlow)
constructor
SwLayoutFrame * GetUpper()
Definition: frame.hxx:661
bool IsPageFrame() const
Definition: frame.hxx:1159
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame...
Definition: layfrm.hxx:35
bool IsFooterFrame() const
Definition: frame.hxx:1175
bool IsHeaderFrame() const
Definition: frame.hxx:1171