1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <swtypes.hxx>
26 class SwTextFrameBreak
32 SwTextFrame
*m_pFrame
;
36 SwTextFrameBreak( SwTextFrame
*pFrame
, const SwTwips nRst
= 0 );
37 bool IsBreakNow( SwTextMargin
&rLine
);
38 bool IsKeepAlways() const { return m_bKeep
; }
40 void SetKeep( const bool bNew
) { m_bKeep
= bNew
; }
42 bool IsInside( SwTextMargin
const &rLine
) const;
43 bool IsInside(SwTextMargin
const& rLine
, SwResizeLimitReason
&) const;
45 // In order to be able to handle special cases with Footnote.
46 // SetRstHeight sets the rest height for SwTextFrameBreak. This is needed
47 // to call TruncLines() without IsBreakNow() returning another value.
48 // We assume that rLine is pointing to the last non-fitting line.
50 void SetRstHeight( const SwTextMargin
&rLine
);
53 class WidowsAndOrphans
: public SwTextFrameBreak
56 sal_uInt16 m_nWidLines
, m_nOrphLines
;
59 WidowsAndOrphans( SwTextFrame
*pFrame
, const SwTwips nRst
= 0,
60 bool bCheckKeep
= true );
61 bool FindWidows( SwTextFrame
*pFrame
, SwTextMargin
&rLine
);
62 sal_uInt16
GetOrphansLines() const
63 { return m_nOrphLines
; }
64 void ClrOrphLines(){ m_nOrphLines
= 0; }
66 bool FindBreak( SwTextFrame
*pFrame
, SwTextMargin
&rLine
, bool bHasToFit
);
67 bool WouldFit( SwTextMargin
&rLine
, SwTwips
&rMaxHeight
, bool bTest
, bool bMoveBwd
);
68 // i#16128 - This method is named this way to avoid confusion with
69 // base class method <SwTextFrameBreak::IsBreakNow>, which isn't virtual.
70 bool IsBreakNowWidAndOrp( SwTextMargin
&rLine
)
72 bool isOnFirstLine
= (rLine
.GetLineNr() == 1 && !rLine
.GetPrev());
73 if ( isOnFirstLine
&& rLine
.GetCurr()->IsDummy()) {
74 return IsBreakNow( rLine
);
76 if ( rLine
.GetLineNr() > m_nOrphLines
) {
77 return IsBreakNow( rLine
);
83 inline bool SwTextFrameBreak::IsInside(SwTextMargin
const& rLine
) const
85 return IsInside(rLine
, o3tl::temporary(SwResizeLimitReason()));
90 auto FindNonFlyPortion(SwLineLayout
const& rLine
) -> bool;
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */