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 #include <flyfrm.hxx>
24 
25 using namespace objectpositioning;
26 
28  const bool _bFollowTextFlow )
29  : mbFollowTextFlow( _bFollowTextFlow )
30 {}
31 
33 {}
34 
37  const SwFrame& _rHoriOrientFrame ) const
38 {
39  const SwFrame* pHoriEnvironmentLayFrame = &_rHoriOrientFrame;
40 
41  if ( !mbFollowTextFlow )
42  {
43  // No exception any more for page alignment.
44  // the page frame determines the horizontal layout environment.
45  pHoriEnvironmentLayFrame = _rHoriOrientFrame.FindPageFrame();
46  }
47  else
48  {
49  while ( !pHoriEnvironmentLayFrame->IsCellFrame() &&
50  !pHoriEnvironmentLayFrame->IsFlyFrame() &&
51  !pHoriEnvironmentLayFrame->IsPageFrame() )
52  {
53  pHoriEnvironmentLayFrame = pHoriEnvironmentLayFrame->GetUpper();
54  OSL_ENSURE( pHoriEnvironmentLayFrame,
55  "SwEnvironmentOfAnchoredObject::GetHoriEnvironmentLayoutFrame(..) - no page|fly|cell frame found" );
56  }
57  }
58 
59  OSL_ENSURE( dynamic_cast< const SwLayoutFrame *>( pHoriEnvironmentLayFrame ) != nullptr,
60  "SwEnvironmentOfAnchoredObject::GetHoriEnvironmentLayoutFrame(..) - found frame isn't a layout frame" );
61 
62  return static_cast<const SwLayoutFrame&>(*pHoriEnvironmentLayFrame);
63 }
64 
67  const SwFrame& _rVertOrientFrame ) const
68 {
69  const SwFrame* pVertEnvironmentLayFrame = &_rVertOrientFrame;
70 
71  if ( !mbFollowTextFlow )
72  {
73  // No exception any more for page alignment.
74  // the page frame determines the vertical layout environment.
75  pVertEnvironmentLayFrame = _rVertOrientFrame.FindPageFrame();
76  }
77  else
78  {
79  while ( !pVertEnvironmentLayFrame->IsCellFrame() &&
80  !pVertEnvironmentLayFrame->IsFlyFrame() &&
81  !pVertEnvironmentLayFrame->IsHeaderFrame() &&
82  !pVertEnvironmentLayFrame->IsFooterFrame() &&
83  !pVertEnvironmentLayFrame->IsFootnoteFrame() &&
84  !pVertEnvironmentLayFrame->IsPageBodyFrame() &&
85  !pVertEnvironmentLayFrame->IsPageFrame() )
86  {
87  pVertEnvironmentLayFrame = pVertEnvironmentLayFrame->GetUpper();
88  OSL_ENSURE( pVertEnvironmentLayFrame,
89  "SwEnvironmentOfAnchoredObject::GetVertEnvironmentLayoutFrame(..) - proposed frame not found" );
90  }
91  }
92 
93  OSL_ENSURE( dynamic_cast< const SwLayoutFrame *>( pVertEnvironmentLayFrame ) != nullptr,
94  "SwEnvironmentOfAnchoredObject::GetVertEnvironmentLayoutFrame(..) - found frame isn't a layout frame" );
95 
96  return static_cast<const SwLayoutFrame&>(*pVertEnvironmentLayFrame);
97 }
98 
99 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Base class of the Writer layout elements.
Definition: frame.hxx:295
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:1202
bool IsFootnoteFrame() const
Definition: frame.hxx:1178
bool IsFlyFrame() const
Definition: frame.hxx:1186
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:658
SwEnvironmentOfAnchoredObject(const bool _bFollowTextFlow)
constructor
SwLayoutFrame * GetUpper()
Definition: frame.hxx:656
bool IsPageFrame() const
Definition: frame.hxx:1154
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:1170
bool IsHeaderFrame() const
Definition: frame.hxx:1166