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  const bool _bLayoutInCell )
30  : mbFollowTextFlow( _bFollowTextFlow )
31  , mbLayoutInCell( _bLayoutInCell )
32 {}
33 
35 {}
36 
39  const SwFrame& _rHoriOrientFrame ) const
40 {
41  const SwFrame* pHoriEnvironmentLayFrame = &_rHoriOrientFrame;
42 
43  if ( !mbFollowTextFlow )
44  {
45  // No exception any more for page alignment.
46  // the page frame determines the horizontal layout environment.
47  pHoriEnvironmentLayFrame = _rHoriOrientFrame.FindPageFrame();
48  }
49  else
50  {
51  while ( !pHoriEnvironmentLayFrame->IsCellFrame() &&
52  !pHoriEnvironmentLayFrame->IsFlyFrame() &&
53  !pHoriEnvironmentLayFrame->IsPageFrame() )
54  {
55  pHoriEnvironmentLayFrame = pHoriEnvironmentLayFrame->GetUpper();
56  OSL_ENSURE( pHoriEnvironmentLayFrame,
57  "SwEnvironmentOfAnchoredObject::GetHoriEnvironmentLayoutFrame(..) - no page|fly|cell frame found" );
58  }
59  }
60 
61  OSL_ENSURE( dynamic_cast< const SwLayoutFrame *>( pHoriEnvironmentLayFrame ) != nullptr,
62  "SwEnvironmentOfAnchoredObject::GetHoriEnvironmentLayoutFrame(..) - found frame isn't a layout frame" );
63 
64  return static_cast<const SwLayoutFrame&>(*pHoriEnvironmentLayFrame);
65 }
66 
69  const SwFrame& _rVertOrientFrame ) const
70 {
71  const SwFrame* pVertEnvironmentLayFrame = &_rVertOrientFrame;
72 
74  {
75  // No exception any more for page alignment.
76  // the page frame determines the vertical layout environment.
77  pVertEnvironmentLayFrame = _rVertOrientFrame.FindPageFrame();
78  }
79  else
80  {
81  while ( !pVertEnvironmentLayFrame->IsCellFrame() &&
82  !pVertEnvironmentLayFrame->IsFlyFrame() &&
83  !pVertEnvironmentLayFrame->IsHeaderFrame() &&
84  !pVertEnvironmentLayFrame->IsFooterFrame() &&
85  !pVertEnvironmentLayFrame->IsFootnoteFrame() &&
86  !pVertEnvironmentLayFrame->IsPageBodyFrame() &&
87  !pVertEnvironmentLayFrame->IsPageFrame() )
88  {
89  pVertEnvironmentLayFrame = pVertEnvironmentLayFrame->GetUpper();
90  OSL_ENSURE( pVertEnvironmentLayFrame,
91  "SwEnvironmentOfAnchoredObject::GetVertEnvironmentLayoutFrame(..) - proposed frame not found" );
92  }
93  }
94 
95  OSL_ENSURE( dynamic_cast< const SwLayoutFrame *>( pVertEnvironmentLayFrame ) != nullptr,
96  "SwEnvironmentOfAnchoredObject::GetVertEnvironmentLayoutFrame(..) - found frame isn't a layout frame" );
97 
98  return static_cast<const SwLayoutFrame&>(*pVertEnvironmentLayFrame);
99 }
100 
101 /* 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:213
SwPageFrame * FindPageFrame()
Definition: frame.hxx:658
SwLayoutFrame * GetUpper()
Definition: frame.hxx:656
SwEnvironmentOfAnchoredObject(const bool _bFollowTextFlow, const bool _bLayoutInCell=false)
constructor
bool IsPageFrame() const
Definition: frame.hxx:1154
bool IsFooterFrame() const
Definition: frame.hxx:1170
bool IsHeaderFrame() const
Definition: frame.hxx:1166