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 : #ifndef INCLUDED_SW_SOURCE_CORE_TEXT_WIDORP_HXX
20 : #define INCLUDED_SW_SOURCE_CORE_TEXT_WIDORP_HXX
21 : class SwTxtFrm;
22 :
23 : #include "swtypes.hxx"
24 : #include "itrtxt.hxx"
25 :
26 : class SwTxtFrmBreak
27 : {
28 : private:
29 : SwTwips nRstHeight;
30 : SwTwips nOrigin;
31 : protected:
32 : SwTxtFrm *pFrm;
33 : bool bBreak;
34 : bool bKeep;
35 : public:
36 : SwTxtFrmBreak( SwTxtFrm *pFrm, const SwTwips nRst = 0 );
37 : bool IsBreakNow( SwTxtMargin &rLine );
38 :
39 : bool IsBroken() const { return bBreak; }
40 0 : bool IsKeepAlways() const { return bKeep; }
41 : void Keep() { bKeep = true; }
42 : void Break() { bKeep = false; bBreak = true; }
43 :
44 : inline bool GetKeep() const { return bKeep; }
45 0 : inline void SetKeep( const bool bNew ) { bKeep = bNew; }
46 :
47 : bool IsInside( SwTxtMargin &rLine ) const;
48 :
49 : // In order to be able to handle special cases with Ftn.
50 : // SetRstHeight sets the rest height for SwTxtFrmBreak. This is needed
51 : // to call TruncLines() without IsBreakNow() returning another value.
52 : // We assume that rLine is pointing to the last non-fitting line.
53 :
54 : // OD 2004-02-27 #106629# - no longer inline
55 : void SetRstHeight( const SwTxtMargin &rLine );
56 : SwTwips GetRstHeight() const { return nRstHeight; }
57 : };
58 :
59 : class WidowsAndOrphans : public SwTxtFrmBreak
60 : {
61 : private:
62 : MSHORT nWidLines, nOrphLines;
63 :
64 : public:
65 : WidowsAndOrphans( SwTxtFrm *pFrm, const SwTwips nRst = 0,
66 : bool bCheckKeep = true );
67 : bool FindWidows( SwTxtFrm *pFrm, SwTxtMargin &rLine );
68 0 : MSHORT GetWidowsLines() const
69 0 : { return nWidLines; }
70 0 : MSHORT GetOrphansLines() const
71 0 : { return nOrphLines; }
72 0 : void ClrOrphLines(){ nOrphLines = 0; }
73 :
74 : bool FindBreak( SwTxtFrm *pFrm, SwTxtMargin &rLine, bool bHasToFit );
75 : bool WouldFit( SwTxtMargin &rLine, SwTwips &rMaxHeight, bool bTest );
76 : // OD 2004-02-25 #i16128# - rename method to avoid confusion with base class
77 : // method <SwTxtFrmBreak::IsBreakNow>, which isn't virtual.
78 0 : bool IsBreakNowWidAndOrp( SwTxtMargin &rLine )
79 : {
80 0 : return ( rLine.GetLineNr() > nOrphLines ) && IsBreakNow( rLine );
81 : }
82 : };
83 :
84 : #endif
85 :
86 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|