xref: /trunk/main/sw/source/core/text/itrform2.hxx (revision 914d351e5f5b84e4342a86d6ab8d4aca7308b9bd)
11d2dbeb0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
31d2dbeb0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
41d2dbeb0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
51d2dbeb0SAndrew Rist  * distributed with this work for additional information
61d2dbeb0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
71d2dbeb0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
81d2dbeb0SAndrew Rist  * "License"); you may not use this file except in compliance
91d2dbeb0SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
111d2dbeb0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
131d2dbeb0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
141d2dbeb0SAndrew Rist  * software distributed under the License is distributed on an
151d2dbeb0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
161d2dbeb0SAndrew Rist  * KIND, either express or implied.  See the License for the
171d2dbeb0SAndrew Rist  * specific language governing permissions and limitations
181d2dbeb0SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
201d2dbeb0SAndrew Rist  *************************************************************/
211d2dbeb0SAndrew Rist 
221d2dbeb0SAndrew Rist 
23cdf0e10cSrcweir #ifndef _ITRFORM2_HXX
24cdf0e10cSrcweir #define _ITRFORM2_HXX
25cdf0e10cSrcweir #include "itrpaint.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir class SwFlyCntPortion;
28cdf0e10cSrcweir class SwInterHyphInfo;
29cdf0e10cSrcweir class SwDropPortion;
30cdf0e10cSrcweir class SwFmtDrop;
31cdf0e10cSrcweir class SwTxtAttr;
32cdf0e10cSrcweir class SwNumberPortion;
33cdf0e10cSrcweir class SwErgoSumPortion;
34cdf0e10cSrcweir class SwExpandPortion;
35cdf0e10cSrcweir class SwMultiPortion;
36cdf0e10cSrcweir class SwFtnPortion;
37cdf0e10cSrcweir class SvLongs;
38cdf0e10cSrcweir 
39cdf0e10cSrcweir /*************************************************************************
40cdf0e10cSrcweir  *                      class SwTxtFormatter
41cdf0e10cSrcweir  *************************************************************************/
42cdf0e10cSrcweir 
43cdf0e10cSrcweir class SwTxtFormatter : public SwTxtPainter
44cdf0e10cSrcweir {
45cdf0e10cSrcweir     const SwFmtDrop *pDropFmt;
46cdf0e10cSrcweir     SwMultiPortion* pMulti; // during formatting a multi-portion
47cdf0e10cSrcweir     sal_uInt8 nCntEndHyph;  // zaehlt aufeinanderfolgende Hyphens am Zeilenende
48cdf0e10cSrcweir     sal_uInt8 nCntMidHyph;  // zaehlt aufeinanderfolgende Hyphens vor Flies
49cdf0e10cSrcweir     xub_StrLen nLeftScanIdx; // for increasing performance during
50cdf0e10cSrcweir     xub_StrLen nRightScanIdx;     // scanning for portion ends
51cdf0e10cSrcweir     sal_Bool bOnceMore : 1; // noch 'ne Runde?
52cdf0e10cSrcweir     sal_Bool bFlyInCntBase : 1; // Base-Referenz der zeichengeb. Rahmen setzen
53cdf0e10cSrcweir     sal_Bool bChanges : 1; // Flag, fuer die Berechnung des Repaint-Rechtecks
54cdf0e10cSrcweir     sal_Bool bTruncLines : 1; // Flag, Repaint-Rechtecks ggf. erweitern
55cdf0e10cSrcweir     sal_Bool bUnclipped : 1; // Flag, ob Repaint groesser als feste Zeilenhoehe
56cdf0e10cSrcweir     sal_uInt16 m_nHintEndIndex; // HACK for TryNewNoLengthPortion
57cdf0e10cSrcweir     SwLinePortion *NewPortion( SwTxtFormatInfo &rInf );
58cdf0e10cSrcweir     SwTxtPortion  *NewTxtPortion( SwTxtFormatInfo &rInf );
59cdf0e10cSrcweir     SwLinePortion *NewExtraPortion( SwTxtFormatInfo &rInf );
60cdf0e10cSrcweir     SwTabPortion *NewTabPortion( SwTxtFormatInfo &rInf, bool bAuto ) const;
61cdf0e10cSrcweir     SwNumberPortion *NewNumberPortion( SwTxtFormatInfo &rInf ) const;
62cdf0e10cSrcweir     SwDropPortion *NewDropPortion( SwTxtFormatInfo &rInf );
63cdf0e10cSrcweir     SwNumberPortion *NewFtnNumPortion( SwTxtFormatInfo &rInf ) const;
64cdf0e10cSrcweir     SwErgoSumPortion *NewErgoSumPortion( SwTxtFormatInfo &rInf ) const;
65cdf0e10cSrcweir     SwExpandPortion *NewFldPortion( SwTxtFormatInfo &rInf,
66cdf0e10cSrcweir                                     const SwTxtAttr *pHt ) const;
67cdf0e10cSrcweir     SwFtnPortion *NewFtnPortion( SwTxtFormatInfo &rInf, SwTxtAttr *pHt );
68cdf0e10cSrcweir     SwFlyCntPortion *NewFlyCntPortion( SwTxtFormatInfo &rInf,
69cdf0e10cSrcweir                                        SwTxtAttr *pHt ) const;
70cdf0e10cSrcweir     SwLinePortion *WhichFirstPortion( SwTxtFormatInfo &rInf );
71cdf0e10cSrcweir     SwTxtPortion *WhichTxtPor( SwTxtFormatInfo &rInf ) const;
72cdf0e10cSrcweir     SwExpandPortion * TryNewNoLengthPortion( SwTxtFormatInfo & rInfo );
73cdf0e10cSrcweir 
74cdf0e10cSrcweir     // Das Herzstueck der Formatierung
75cdf0e10cSrcweir     void BuildPortions( SwTxtFormatInfo &rInf );
76cdf0e10cSrcweir     sal_Bool BuildMultiPortion( SwTxtFormatInfo &rInf, SwMultiPortion& rMulti );
77cdf0e10cSrcweir 
78cdf0e10cSrcweir     // Berechnung des emulierten rechten Rands
79cdf0e10cSrcweir     void CalcFlyWidth( SwTxtFormatInfo &rInf );
80cdf0e10cSrcweir 
81cdf0e10cSrcweir     // wird von SwTxtFormatter wegen UpdatePos ueberladen
82cdf0e10cSrcweir     void CalcAdjustLine( SwLineLayout *pCurr );
83cdf0e10cSrcweir 
84*86e1cf34SPedro Giffuni     // considers line spacing attributes
85cdf0e10cSrcweir     void CalcRealHeight( sal_Bool bNewLine = sal_False );
86cdf0e10cSrcweir 
87cdf0e10cSrcweir     // uebertraegt die Daten nach rInf
88cdf0e10cSrcweir     void FeedInf( SwTxtFormatInfo &rInf ) const;
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     // behandelt die Unterlaufsituationen
91cdf0e10cSrcweir     SwLinePortion *UnderFlow( SwTxtFormatInfo &rInf );
92cdf0e10cSrcweir 
93cdf0e10cSrcweir     // errechnet den Ascent und die Hoehe aus der Fontmetric
94cdf0e10cSrcweir     void CalcAscent( SwTxtFormatInfo &rInf, SwLinePortion *pPor );
95cdf0e10cSrcweir 
96cdf0e10cSrcweir     // determines, if a optimized repaint rectange is allowed
97cdf0e10cSrcweir     sal_Bool AllowRepaintOpt() const;
98cdf0e10cSrcweir 
99cdf0e10cSrcweir     // calculates and sets the optimized repaint offset
100cdf0e10cSrcweir     long CalcOptRepaint( xub_StrLen nOldLineEnd, const SvLongs* pFlyStart );
101cdf0e10cSrcweir 
102cdf0e10cSrcweir     // wird von FormatLine gerufen.
103cdf0e10cSrcweir     void FormatReset( SwTxtFormatInfo &rInf );
104cdf0e10cSrcweir 
105cdf0e10cSrcweir     // durch das Adjustment aendert sich die Position der Portions
106cdf0e10cSrcweir     void UpdatePos( SwLineLayout *pCurr, Point aStart, xub_StrLen nStartIdx,
107cdf0e10cSrcweir             sal_Bool bAllWays = sal_False ) const;
108cdf0e10cSrcweir 
109cdf0e10cSrcweir     // Setze alle FlyInCntFrms auf die uebergebene BaseLine
110cdf0e10cSrcweir     void AlignFlyInCntBase( long nBaseLine ) const;
111cdf0e10cSrcweir 
112cdf0e10cSrcweir     // Unterlaufbedingungen bei Flys
113cdf0e10cSrcweir     sal_Bool ChkFlyUnderflow( SwTxtFormatInfo &rInf ) const;
114cdf0e10cSrcweir 
115cdf0e10cSrcweir     // Portion einfuegen.
116cdf0e10cSrcweir     void InsertPortion( SwTxtFormatInfo &rInf, SwLinePortion *pPor ) const;
117cdf0e10cSrcweir 
118cdf0e10cSrcweir     // schaetzt die Hoehe fuer die DropPortion
119cdf0e10cSrcweir     void GuessDropHeight( const MSHORT nLines );
120cdf0e10cSrcweir 
121cdf0e10cSrcweir public:
122cdf0e10cSrcweir     // errechnet die Hoehe fuer die DropPortion
123cdf0e10cSrcweir     void CalcDropHeight( const MSHORT nLines );
124cdf0e10cSrcweir 
125cdf0e10cSrcweir     // errechnet den Bottom des Absatzes, beruecksichtigt an diesem verankerte
126cdf0e10cSrcweir     // Objekte mit Umlauf 1. Absatz.
127cdf0e10cSrcweir     SwTwips CalcBottomLine() const;
128cdf0e10cSrcweir 
129cdf0e10cSrcweir     // Beruecksichtigt zeichengebundene Objekte bei der Repaintrechteck-
130cdf0e10cSrcweir     // berechnung in Zeilen mit fester Zeilenhoehe
131cdf0e10cSrcweir     void CalcUnclipped( SwTwips& rTop, SwTwips& rBottom );
132cdf0e10cSrcweir 
133cdf0e10cSrcweir     // u.a. fuer DropCaps
134cdf0e10cSrcweir     sal_Bool CalcOnceMore();
135cdf0e10cSrcweir 
136cdf0e10cSrcweir     void CtorInitTxtFormatter( SwTxtFrm *pFrm, SwTxtFormatInfo *pInf );
SwTxtFormatter(SwTxtFrm * pTxtFrm,SwTxtFormatInfo * pTxtFmtInf)137cdf0e10cSrcweir     inline SwTxtFormatter( SwTxtFrm *pTxtFrm, SwTxtFormatInfo *pTxtFmtInf ) : SwTxtPainter(pTxtFrm!=NULL?pTxtFrm->GetTxtNode():NULL)
138cdf0e10cSrcweir            { CtorInitTxtFormatter( pTxtFrm, pTxtFmtInf ); }
139cdf0e10cSrcweir     ~SwTxtFormatter();
140cdf0e10cSrcweir 
141cdf0e10cSrcweir     xub_StrLen FormatLine( const xub_StrLen nStart );
142cdf0e10cSrcweir 
143cdf0e10cSrcweir     void RecalcRealHeight();
144cdf0e10cSrcweir 
145cdf0e10cSrcweir     // Wir formatieren eine Zeile fuer die interaktive Trennung
146cdf0e10cSrcweir     sal_Bool Hyphenate( SwInterHyphInfo &rInf );
147cdf0e10cSrcweir 
148cdf0e10cSrcweir     // Spezialmethode fuer QuoVadis-Texte
149cdf0e10cSrcweir     // nErgo ist die Seitennummer der ErgoSum-Ftn
150cdf0e10cSrcweir     // Bei 0 ist es noch unklar.
151cdf0e10cSrcweir     xub_StrLen FormatQuoVadis( const xub_StrLen nStart );
152cdf0e10cSrcweir 
153cdf0e10cSrcweir     // Die Notbremse: Formatierung abbrechen, Zeile verwerfen.
IsStop() const154cdf0e10cSrcweir     inline sal_Bool IsStop() const { return GetInfo().IsStop(); }
155cdf0e10cSrcweir 
156cdf0e10cSrcweir     // Das Gegenstueck: Formatierung unbedingt fortsetzen.
IsNewLine() const157cdf0e10cSrcweir     inline sal_Bool IsNewLine() const { return GetInfo().IsNewLine(); }
158cdf0e10cSrcweir 
159cdf0e10cSrcweir     // FormatQuick(); auffrischen von Formatinformationen
IsQuick() const160cdf0e10cSrcweir     inline sal_Bool IsQuick() const { return GetInfo().IsQuick(); }
161cdf0e10cSrcweir 
162cdf0e10cSrcweir     // erzeugt ggfs. ein SwLineLayout, dass Ftn/Fly--Oszillation unterbindet.
163cdf0e10cSrcweir     void MakeDummyLine();
164cdf0e10cSrcweir 
165cdf0e10cSrcweir     // SwTxtIter-Funktionalitaet
166cdf0e10cSrcweir     void Insert( SwLineLayout *pLine );
167cdf0e10cSrcweir 
168cdf0e10cSrcweir     // die noch verbleibende Hoehe bis zum Seitenrand
169cdf0e10cSrcweir     KSHORT GetFrmRstHeight() const;
170cdf0e10cSrcweir 
171cdf0e10cSrcweir     // Wie breit waerest Du ohne rechte Begrenzungen (Flys etc.)?
172cdf0e10cSrcweir     SwTwips _CalcFitToContent( );
173cdf0e10cSrcweir 
174cdf0e10cSrcweir     SwLinePortion* MakeRestPortion(const SwLineLayout* pLine, xub_StrLen nPos);
175cdf0e10cSrcweir 
GetDropFmt() const176cdf0e10cSrcweir     inline const SwFmtDrop *GetDropFmt() const { return pDropFmt; }
ClearDropFmt()177cdf0e10cSrcweir     inline void ClearDropFmt() { pDropFmt = 0; }
178cdf0e10cSrcweir 
GetMulti() const179cdf0e10cSrcweir     inline SwMultiPortion *GetMulti() const { return pMulti; }
180cdf0e10cSrcweir 
IsOnceMore() const181cdf0e10cSrcweir     inline sal_Bool IsOnceMore() const { return bOnceMore; }
SetOnceMore(sal_Bool bNew)182cdf0e10cSrcweir     inline void       SetOnceMore( sal_Bool bNew ) { bOnceMore = bNew; }
183cdf0e10cSrcweir 
HasChanges() const184cdf0e10cSrcweir     inline sal_Bool HasChanges() const { return bChanges; }
SetChanges()185cdf0e10cSrcweir     inline void       SetChanges()       { bChanges = sal_True; }
186cdf0e10cSrcweir 
HasTruncLines() const187cdf0e10cSrcweir     inline sal_Bool HasTruncLines() const { return bTruncLines; }
SetTruncLines(sal_Bool bNew)188cdf0e10cSrcweir     inline void       SetTruncLines( sal_Bool bNew ) { bTruncLines = bNew; }
189cdf0e10cSrcweir 
IsUnclipped() const190cdf0e10cSrcweir     inline sal_Bool IsUnclipped() const { return bUnclipped; }
SetUnclipped(sal_Bool bNew)191cdf0e10cSrcweir     inline void       SetUnclipped( sal_Bool bNew ) { bUnclipped = bNew; }
192cdf0e10cSrcweir 
IsFlyInCntBase() const193cdf0e10cSrcweir     inline sal_Bool IsFlyInCntBase() const { return bFlyInCntBase; }
SetFlyInCntBase(sal_Bool bNew=sal_True)194cdf0e10cSrcweir     inline void  SetFlyInCntBase( sal_Bool bNew = sal_True ){ bFlyInCntBase = bNew; }
195cdf0e10cSrcweir 
GetInfo()196cdf0e10cSrcweir     inline SwTxtFormatInfo &GetInfo()
197cdf0e10cSrcweir         { return (SwTxtFormatInfo&)SwTxtIter::GetInfo(); }
GetInfo() const198cdf0e10cSrcweir     inline const SwTxtFormatInfo &GetInfo() const
199cdf0e10cSrcweir         { return (const SwTxtFormatInfo&)SwTxtIter::GetInfo(); }
200cdf0e10cSrcweir 
InitCntHyph()201cdf0e10cSrcweir     inline void InitCntHyph() { CntHyphens( nCntEndHyph, nCntMidHyph ); }
CntEndHyph() const202cdf0e10cSrcweir     inline const sal_uInt8 &CntEndHyph() const { return nCntEndHyph; }
CntMidHyph() const203cdf0e10cSrcweir     inline const sal_uInt8 &CntMidHyph() const { return nCntMidHyph; }
CntEndHyph()204cdf0e10cSrcweir     inline sal_uInt8 &CntEndHyph() { return nCntEndHyph; }
CntMidHyph()205cdf0e10cSrcweir     inline sal_uInt8 &CntMidHyph() { return nCntMidHyph; }
206cdf0e10cSrcweir };
207cdf0e10cSrcweir 
208cdf0e10cSrcweir 
209cdf0e10cSrcweir 
210cdf0e10cSrcweir #endif
211