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