1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef _WIDORP_HXX 28 #define _WIDORP_HXX 29 class SwTxtFrm; 30 31 #include "swtypes.hxx" 32 #include "itrtxt.hxx" 33 34 class SwTxtFrmBreak 35 { 36 private: 37 SwTwips nRstHeight; 38 SwTwips nOrigin; 39 protected: 40 SwTxtFrm *pFrm; 41 sal_Bool bBreak; 42 sal_Bool bKeep; 43 public: 44 SwTxtFrmBreak( SwTxtFrm *pFrm, const SwTwips nRst = 0 ); 45 sal_Bool IsBreakNow( SwTxtMargin &rLine ); 46 47 sal_Bool IsBroken() const { return bBreak; } 48 sal_Bool IsKeepAlways() const { return bKeep; } 49 void Keep() { bKeep = sal_True; } 50 void Break() { bKeep = sal_False; bBreak = sal_True; } 51 52 inline sal_Bool GetKeep() const { return bKeep; } 53 inline void SetKeep( const sal_Bool bNew ) { bKeep = bNew; } 54 55 sal_Bool IsInside( SwTxtMargin &rLine ) const; 56 57 // Um Sonderfaelle mit Ftn behandeln zu koennen. 58 // Mit SetRstHeight wird dem SwTxtFrmBreak die Resthoehe eingestellt, 59 // Um TruncLines() rufen zu koennen, ohne dass IsBreakNow() einen 60 // anderen Wert zurueckliefert. 61 // Es wird dabei davon ausgegangen, dass rLine auf der letzten Zeile 62 // steht, die nicht mehr passt. 63 64 // OD 2004-02-27 #106629# - no longer inline 65 void SetRstHeight( const SwTxtMargin &rLine ); 66 SwTwips GetRstHeight() const { return nRstHeight; } 67 }; 68 69 class WidowsAndOrphans : public SwTxtFrmBreak 70 { 71 private: 72 MSHORT nWidLines, nOrphLines; 73 74 public: 75 WidowsAndOrphans( SwTxtFrm *pFrm, const SwTwips nRst = 0, 76 sal_Bool bCheckKeep = sal_True ); 77 sal_Bool FindWidows( SwTxtFrm *pFrm, SwTxtMargin &rLine ); 78 MSHORT GetWidowsLines() const 79 { return nWidLines; } 80 MSHORT GetOrphansLines() const 81 { return nOrphLines; } 82 void ClrOrphLines(){ nOrphLines = 0; } 83 84 sal_Bool FindBreak( SwTxtFrm *pFrm, SwTxtMargin &rLine, sal_Bool bHasToFit ); 85 sal_Bool WouldFit( SwTxtMargin &rLine, SwTwips &rMaxHeight, sal_Bool bTest ); 86 // OD 2004-02-25 #i16128# - rename method to avoid confusion with base class 87 // method <SwTxtFrmBreak::IsBreakNow>, which isn't virtual. 88 sal_Bool IsBreakNowWidAndOrp( SwTxtMargin &rLine ) 89 { 90 return ( rLine.GetLineNr() > nOrphLines ) && IsBreakNow( rLine ); 91 } 92 }; 93 94 95 #endif 96