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