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 8248 : SwEnvironmentOfAnchoredObject::SwEnvironmentOfAnchoredObject(
28 : const bool _bFollowTextFlow )
29 8248 : : mbFollowTextFlow( _bFollowTextFlow )
30 8248 : {}
31 :
32 8248 : SwEnvironmentOfAnchoredObject::~SwEnvironmentOfAnchoredObject()
33 8248 : {}
34 :
35 : /** determine environment layout frame for possible horizontal object positions */
36 16496 : const SwLayoutFrm& SwEnvironmentOfAnchoredObject::GetHoriEnvironmentLayoutFrm(
37 : const SwFrm& _rHoriOrientFrm ) const
38 : {
39 16496 : const SwFrm* pHoriEnvironmentLayFrm = &_rHoriOrientFrm;
40 :
41 16496 : if ( !mbFollowTextFlow )
42 : {
43 : // No exception any more for page alignment.
44 : // the page frame determines the horizontal layout environment.
45 16260 : pHoriEnvironmentLayFrm = _rHoriOrientFrm.FindPageFrm();
46 : }
47 : else
48 : {
49 2312 : while ( !pHoriEnvironmentLayFrm->IsCellFrm() &&
50 1380 : !pHoriEnvironmentLayFrm->IsFlyFrm() &&
51 684 : !pHoriEnvironmentLayFrm->IsPageFrm() )
52 : {
53 460 : 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 16496 : return static_cast<const SwLayoutFrm&>(*pHoriEnvironmentLayFrm);
63 : }
64 :
65 : /** determine environment layout frame for possible vertical object positions */
66 16496 : const SwLayoutFrm& SwEnvironmentOfAnchoredObject::GetVertEnvironmentLayoutFrm(
67 : const SwFrm& _rVertOrientFrm ) const
68 : {
69 16496 : const SwFrm* pVertEnvironmentLayFrm = &_rVertOrientFrm;
70 :
71 16496 : if ( !mbFollowTextFlow )
72 : {
73 : // No exception any more for page alignment.
74 : // the page frame determines the vertical layout environment.
75 16260 : pVertEnvironmentLayFrm = _rVertOrientFrm.FindPageFrm();
76 : }
77 : else
78 : {
79 1286 : while ( !pVertEnvironmentLayFrm->IsCellFrm() &&
80 684 : !pVertEnvironmentLayFrm->IsFlyFrm() &&
81 600 : !pVertEnvironmentLayFrm->IsHeaderFrm() &&
82 516 : !pVertEnvironmentLayFrm->IsFooterFrm() &&
83 516 : !pVertEnvironmentLayFrm->IsFtnFrm() &&
84 730 : !pVertEnvironmentLayFrm->IsPageBodyFrm() &&
85 118 : !pVertEnvironmentLayFrm->IsPageFrm() )
86 : {
87 118 : 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 16496 : return static_cast<const SwLayoutFrm&>(*pVertEnvironmentLayFrm);
97 270 : }
98 :
99 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|