xref: /aoo4110/main/sw/source/core/text/widorp.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _WIDORP_HXX
24 #define _WIDORP_HXX
25 class SwTxtFrm;
26 
27 #include "swtypes.hxx"
28 #include "itrtxt.hxx"
29 
30 class SwTxtFrmBreak
31 {
32 private:
33     SwTwips  nRstHeight;
34     SwTwips  nOrigin;
35 protected:
36 	SwTxtFrm *pFrm;
37 	sal_Bool	 bBreak;
38 	sal_Bool	 bKeep;
39 public:
40 	SwTxtFrmBreak( SwTxtFrm *pFrm, const SwTwips nRst = 0  );
41 	sal_Bool IsBreakNow( SwTxtMargin &rLine );
42 
IsBroken() const43 	sal_Bool IsBroken() const 	{ return bBreak; }
IsKeepAlways() const44 	sal_Bool IsKeepAlways() const { return bKeep; }
Keep()45 	void Keep()				{ bKeep = sal_True; }
Break()46 	void Break()				{ bKeep = sal_False; bBreak = sal_True; }
47 
GetKeep() const48 	inline sal_Bool GetKeep() const { return bKeep; }
SetKeep(const sal_Bool bNew)49 	inline void SetKeep( const sal_Bool bNew ) { bKeep = bNew; }
50 
51 	sal_Bool IsInside( SwTxtMargin &rLine ) const;
52 
53 	// Um Sonderfaelle mit Ftn behandeln zu koennen.
54 	// Mit SetRstHeight wird dem SwTxtFrmBreak die Resthoehe eingestellt,
55 	// Um TruncLines() rufen zu koennen, ohne dass IsBreakNow() einen
56 	// anderen Wert zurueckliefert.
57 	// Es wird dabei davon ausgegangen, dass rLine auf der letzten Zeile
58 	// steht, die nicht mehr passt.
59 
60     // OD 2004-02-27 #106629# - no longer inline
61     void SetRstHeight( const SwTxtMargin &rLine );
GetRstHeight() const62 	SwTwips GetRstHeight() const { return nRstHeight; }
63 };
64 
65 class WidowsAndOrphans : public SwTxtFrmBreak
66 {
67 private:
68 	MSHORT	 nWidLines, nOrphLines;
69 
70 public:
71 	WidowsAndOrphans( SwTxtFrm *pFrm, const SwTwips nRst = 0,
72 		sal_Bool bCheckKeep = sal_True );
73 	sal_Bool FindWidows( SwTxtFrm *pFrm, SwTxtMargin &rLine );
GetWidowsLines() const74 	MSHORT GetWidowsLines() const
75 	{ return nWidLines; }
GetOrphansLines() const76 	MSHORT GetOrphansLines() const
77 	{ return nOrphLines; }
ClrOrphLines()78 	void ClrOrphLines(){ nOrphLines = 0; }
79 
80 	sal_Bool FindBreak( SwTxtFrm *pFrm, SwTxtMargin &rLine, sal_Bool bHasToFit );
81     sal_Bool WouldFit( SwTxtMargin &rLine, SwTwips &rMaxHeight, sal_Bool bTest );
82     // OD 2004-02-25 #i16128# - rename method to avoid confusion with base class
83     // method <SwTxtFrmBreak::IsBreakNow>, which isn't virtual.
IsBreakNowWidAndOrp(SwTxtMargin & rLine)84     sal_Bool IsBreakNowWidAndOrp( SwTxtMargin &rLine )
85     {
86         return ( rLine.GetLineNr() > nOrphLines ) && IsBreakNow( rLine );
87     }
88 };
89 
90 
91 #endif
92