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 <osl/diagnose.h>
24 
25 namespace objectpositioning
26 {
27 
29  const bool _bFollowTextFlow )
30  : mbFollowTextFlow( _bFollowTextFlow )
31 {}
32 
35  const SwFrame& _rHoriOrientFrame ) const
36 {
37  const SwFrame* pHoriEnvironmentLayFrame = &_rHoriOrientFrame;
38 
39  if ( !mbFollowTextFlow )
40  {
41  // No exception any more for page alignment.
42  // the page frame determines the horizontal layout environment.
43  pHoriEnvironmentLayFrame = _rHoriOrientFrame.FindPageFrame();
44  }
45  else
46  {
47  while ( !pHoriEnvironmentLayFrame->IsCellFrame() &&
48  !pHoriEnvironmentLayFrame->IsFlyFrame() &&
49  !pHoriEnvironmentLayFrame->IsPageFrame() )
50  {
51  pHoriEnvironmentLayFrame = pHoriEnvironmentLayFrame->GetUpper();
52  OSL_ENSURE( pHoriEnvironmentLayFrame,
53  "SwEnvironmentOfAnchoredObject::GetHoriEnvironmentLayoutFrame(..) - no page|fly|cell frame found" );
54  }
55  }
56 
57  assert( dynamic_cast< const SwLayoutFrame *>( pHoriEnvironmentLayFrame ) &&
58  "SwEnvironmentOfAnchoredObject::GetHoriEnvironmentLayoutFrame(..) - found frame isn't a layout frame" );
59 
60  return static_cast<const SwLayoutFrame&>(*pHoriEnvironmentLayFrame);
61 }
62 
65  const SwFrame& _rVertOrientFrame ) const
66 {
67  const SwFrame* pVertEnvironmentLayFrame = &_rVertOrientFrame;
68 
69  if ( !mbFollowTextFlow )
70  {
71  // No exception any more for page alignment.
72  // the page frame determines the vertical layout environment.
73  pVertEnvironmentLayFrame = _rVertOrientFrame.FindPageFrame();
74  }
75  else
76  {
77  while ( !pVertEnvironmentLayFrame->IsCellFrame() &&
78  !pVertEnvironmentLayFrame->IsFlyFrame() &&
79  !pVertEnvironmentLayFrame->IsHeaderFrame() &&
80  !pVertEnvironmentLayFrame->IsFooterFrame() &&
81  !pVertEnvironmentLayFrame->IsFootnoteFrame() &&
82  !pVertEnvironmentLayFrame->IsPageBodyFrame() &&
83  !pVertEnvironmentLayFrame->IsPageFrame() )
84  {
85  pVertEnvironmentLayFrame = pVertEnvironmentLayFrame->GetUpper();
86  OSL_ENSURE( pVertEnvironmentLayFrame,
87  "SwEnvironmentOfAnchoredObject::GetVertEnvironmentLayoutFrame(..) - proposed frame not found" );
88  }
89  }
90 
91  assert( dynamic_cast< const SwLayoutFrame *>( pVertEnvironmentLayFrame ) &&
92  "SwEnvironmentOfAnchoredObject::GetVertEnvironmentLayoutFrame(..) - found frame isn't a layout frame" );
93 
94  return static_cast<const SwLayoutFrame&>(*pVertEnvironmentLayFrame);
95 }
96 
97 }
98 
99 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Base class of the Writer layout elements.
Definition: frame.hxx:314
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:1226
bool IsFootnoteFrame() const
Definition: frame.hxx:1202
bool IsFlyFrame() const
Definition: frame.hxx:1210
bool IsPageBodyFrame() const
Definition: layfrm.hxx:215
SwPageFrame * FindPageFrame()
Definition: frame.hxx:680
SwLayoutFrame * GetUpper()
Definition: frame.hxx:678
SwEnvironmentOfAnchoredObject(const bool _bFollowTextFlow)
constructor
bool IsPageFrame() const
Definition: frame.hxx:1178
const SwLayoutFrame & GetHoriEnvironmentLayoutFrame(const SwFrame &_rHoriOrientFrame) const
determine environment layout frame for possible horizontal object positions respectively for alignmen...
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:1194
bool IsHeaderFrame() const
Definition: frame.hxx:1190