Line data Source code
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 :
20 : #include <environmentofanchoredobject.hxx>
21 : #include <frame.hxx>
22 : #include <pagefrm.hxx>
23 : #include <flyfrm.hxx>
24 :
25 : using namespace objectpositioning;
26 :
27 0 : SwEnvironmentOfAnchoredObject::SwEnvironmentOfAnchoredObject(
28 : const bool _bFollowTextFlow )
29 0 : : mbFollowTextFlow( _bFollowTextFlow )
30 0 : {}
31 :
32 0 : SwEnvironmentOfAnchoredObject::~SwEnvironmentOfAnchoredObject()
33 0 : {}
34 :
35 : /** determine environment layout frame for possible horizontal object positions */
36 0 : const SwLayoutFrm& SwEnvironmentOfAnchoredObject::GetHoriEnvironmentLayoutFrm(
37 : const SwFrm& _rHoriOrientFrm ) const
38 : {
39 0 : const SwFrm* pHoriEnvironmentLayFrm = &_rHoriOrientFrm;
40 :
41 0 : if ( !mbFollowTextFlow )
42 : {
43 : // No exception any more for page alignment.
44 : // the page frame determines the horizontal layout environment.
45 0 : pHoriEnvironmentLayFrm = _rHoriOrientFrm.FindPageFrm();
46 : }
47 : else
48 : {
49 0 : while ( !pHoriEnvironmentLayFrm->IsCellFrm() &&
50 0 : !pHoriEnvironmentLayFrm->IsFlyFrm() &&
51 0 : !pHoriEnvironmentLayFrm->IsPageFrm() )
52 : {
53 0 : pHoriEnvironmentLayFrm = pHoriEnvironmentLayFrm->GetUpper();
54 : OSL_ENSURE( pHoriEnvironmentLayFrm,
55 : "SwEnvironmentOfAnchoredObject::GetHoriEnvironmentLayoutFrm(..) - no page|fly|cell frame found" );
56 : }
57 : }
58 :
59 : OSL_ENSURE( pHoriEnvironmentLayFrm->ISA(SwLayoutFrm),
60 : "SwEnvironmentOfAnchoredObject::GetHoriEnvironmentLayoutFrm(..) - found frame isn't a layout frame" );
61 :
62 0 : return static_cast<const SwLayoutFrm&>(*pHoriEnvironmentLayFrm);
63 : }
64 :
65 : /** determine environment layout frame for possible vertical object positions */
66 0 : const SwLayoutFrm& SwEnvironmentOfAnchoredObject::GetVertEnvironmentLayoutFrm(
67 : const SwFrm& _rVertOrientFrm ) const
68 : {
69 0 : const SwFrm* pVertEnvironmentLayFrm = &_rVertOrientFrm;
70 :
71 0 : if ( !mbFollowTextFlow )
72 : {
73 : // No exception any more for page alignment.
74 : // the page frame determines the vertical layout environment.
75 0 : pVertEnvironmentLayFrm = _rVertOrientFrm.FindPageFrm();
76 : }
77 : else
78 : {
79 0 : while ( !pVertEnvironmentLayFrm->IsCellFrm() &&
80 0 : !pVertEnvironmentLayFrm->IsFlyFrm() &&
81 0 : !pVertEnvironmentLayFrm->IsHeaderFrm() &&
82 0 : !pVertEnvironmentLayFrm->IsFooterFrm() &&
83 0 : !pVertEnvironmentLayFrm->IsFtnFrm() &&
84 0 : !pVertEnvironmentLayFrm->IsPageBodyFrm() &&
85 0 : !pVertEnvironmentLayFrm->IsPageFrm() )
86 : {
87 0 : pVertEnvironmentLayFrm = pVertEnvironmentLayFrm->GetUpper();
88 : OSL_ENSURE( pVertEnvironmentLayFrm,
89 : "SwEnvironmentOfAnchoredObject::GetVertEnvironmentLayoutFrm(..) - proposed frame not found" );
90 : }
91 : }
92 :
93 : OSL_ENSURE( pVertEnvironmentLayFrm->ISA(SwLayoutFrm),
94 : "SwEnvironmentOfAnchoredObject::GetVertEnvironmentLayoutFrm(..) - found frame isn't a layout frame" );
95 :
96 0 : return static_cast<const SwLayoutFrm&>(*pVertEnvironmentLayFrm);
97 : }
98 :
99 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|