xref: /AOO41X/main/sw/source/core/text/porrst.cxx (revision efeef26f81c84063fb0a91bde3856d4a51172d90)
1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*efeef26fSAndrew Rist  * distributed with this work for additional information
6*efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*efeef26fSAndrew Rist  * specific language governing permissions and limitations
18*efeef26fSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*efeef26fSAndrew Rist  *************************************************************/
21*efeef26fSAndrew Rist 
22*efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir #include <hintids.hxx>
27cdf0e10cSrcweir #include <sfx2/printer.hxx>
28cdf0e10cSrcweir #include <editeng/lspcitem.hxx>
29cdf0e10cSrcweir #include <editeng/adjitem.hxx>
30cdf0e10cSrcweir #include <editeng/escpitem.hxx>
31cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
32cdf0e10cSrcweir #include <editeng/pgrditem.hxx>
33cdf0e10cSrcweir #include <vcl/window.hxx>
34cdf0e10cSrcweir #include <vcl/svapp.hxx>
35cdf0e10cSrcweir #include <viewsh.hxx>	// ViewShell
36cdf0e10cSrcweir #include <viewopt.hxx>
37cdf0e10cSrcweir #include <ndtxt.hxx>	// SwTxtNode
38cdf0e10cSrcweir #include <pagefrm.hxx>  // SwPageFrm
39cdf0e10cSrcweir #include <paratr.hxx>
40cdf0e10cSrcweir #include <SwPortionHandler.hxx>
41cdf0e10cSrcweir #include <txtcfg.hxx>
42cdf0e10cSrcweir #include <porrst.hxx>
43cdf0e10cSrcweir #include <inftxt.hxx>
44cdf0e10cSrcweir #include <txtpaint.hxx>	// ClipVout
45cdf0e10cSrcweir #include <swfntcch.hxx>	// SwFontAccess
46cdf0e10cSrcweir #include <tgrditem.hxx>
47cdf0e10cSrcweir #include <pagedesc.hxx> // SwPageDesc
48cdf0e10cSrcweir #include <frmatr.hxx>
49cdf0e10cSrcweir #include <redlnitr.hxx>	// SwRedlineItr
50cdf0e10cSrcweir #include <porfly.hxx> 	// SwFlyPortion
51cdf0e10cSrcweir #include <atrhndl.hxx>
52cdf0e10cSrcweir #include "rootfrm.hxx"
53cdf0e10cSrcweir 
54cdf0e10cSrcweir #include <IDocumentRedlineAccess.hxx>
55cdf0e10cSrcweir #include <IDocumentSettingAccess.hxx>
56cdf0e10cSrcweir #include <IDocumentDeviceAccess.hxx>
57cdf0e10cSrcweir 
58cdf0e10cSrcweir /*************************************************************************
59cdf0e10cSrcweir  *                      class SwTmpEndPortion
60cdf0e10cSrcweir  *************************************************************************/
61cdf0e10cSrcweir 
SwTmpEndPortion(const SwLinePortion & rPortion)62cdf0e10cSrcweir SwTmpEndPortion::SwTmpEndPortion( const SwLinePortion &rPortion )
63cdf0e10cSrcweir {
64cdf0e10cSrcweir 	Height( rPortion.Height() );
65cdf0e10cSrcweir 	SetAscent( rPortion.GetAscent() );
66cdf0e10cSrcweir 	SetWhichPor( POR_TMPEND );
67cdf0e10cSrcweir }
68cdf0e10cSrcweir 
69cdf0e10cSrcweir /*************************************************************************
70cdf0e10cSrcweir  *				   virtual SwTmpEndPortion::Paint()
71cdf0e10cSrcweir  *************************************************************************/
72cdf0e10cSrcweir 
Paint(const SwTxtPaintInfo & rInf) const73cdf0e10cSrcweir void SwTmpEndPortion::Paint( const SwTxtPaintInfo &rInf ) const
74cdf0e10cSrcweir {
75cdf0e10cSrcweir 	if( rInf.OnWin() && rInf.GetOpt().IsParagraph() )
76cdf0e10cSrcweir 	{
77cdf0e10cSrcweir 		SwDefFontSave aSave( rInf );
78cdf0e10cSrcweir 		const XubString aTmp( CH_PAR );
79cdf0e10cSrcweir 		rInf.DrawText( aTmp, *this );
80cdf0e10cSrcweir 	}
81cdf0e10cSrcweir }
82cdf0e10cSrcweir 
83cdf0e10cSrcweir /*************************************************************************
84cdf0e10cSrcweir  *						class SwBreakPortion
85cdf0e10cSrcweir  *************************************************************************/
SwBreakPortion(const SwLinePortion & rPortion)86cdf0e10cSrcweir SwBreakPortion::SwBreakPortion( const SwLinePortion &rPortion )
87cdf0e10cSrcweir     : SwLinePortion( rPortion )
88cdf0e10cSrcweir {
89cdf0e10cSrcweir 	nLineLength = 1;
90cdf0e10cSrcweir 	SetWhichPor( POR_BRK );
91cdf0e10cSrcweir }
92cdf0e10cSrcweir 
GetCrsrOfst(const KSHORT) const93cdf0e10cSrcweir xub_StrLen SwBreakPortion::GetCrsrOfst( const KSHORT ) const
94cdf0e10cSrcweir { return 0; }
95cdf0e10cSrcweir 
GetViewWidth(const SwTxtSizeInfo &) const96cdf0e10cSrcweir KSHORT SwBreakPortion::GetViewWidth( const SwTxtSizeInfo & ) const
97cdf0e10cSrcweir { return 0; }
98cdf0e10cSrcweir 
Compress()99cdf0e10cSrcweir SwLinePortion *SwBreakPortion::Compress()
100cdf0e10cSrcweir { return (GetPortion() && GetPortion()->InTxtGrp() ? 0 : this); }
101cdf0e10cSrcweir 
Paint(const SwTxtPaintInfo & rInf) const102cdf0e10cSrcweir void SwBreakPortion::Paint( const SwTxtPaintInfo &rInf ) const
103cdf0e10cSrcweir {
104cdf0e10cSrcweir     if( rInf.OnWin() && rInf.GetOpt().IsLineBreak() )
105cdf0e10cSrcweir         rInf.DrawLineBreak( *this );
106cdf0e10cSrcweir }
107cdf0e10cSrcweir 
108cdf0e10cSrcweir /*************************************************************************
109cdf0e10cSrcweir  *				   virtual SwBreakPortion::Format()
110cdf0e10cSrcweir  *************************************************************************/
111cdf0e10cSrcweir 
Format(SwTxtFormatInfo & rInf)112cdf0e10cSrcweir sal_Bool SwBreakPortion::Format( SwTxtFormatInfo &rInf )
113cdf0e10cSrcweir {
114cdf0e10cSrcweir     const SwLinePortion *pRoot = rInf.GetRoot();
115cdf0e10cSrcweir 	Width( 0 );
116cdf0e10cSrcweir 	Height( pRoot->Height() );
117cdf0e10cSrcweir 	SetAscent( pRoot->GetAscent() );
118cdf0e10cSrcweir 	if ( rInf.GetIdx()+1 == rInf.GetTxt().Len() )
119cdf0e10cSrcweir 		rInf.SetNewLine( sal_True );
120cdf0e10cSrcweir 	return sal_True;
121cdf0e10cSrcweir }
122cdf0e10cSrcweir 
123cdf0e10cSrcweir /*************************************************************************
124cdf0e10cSrcweir  *              virtual SwBreakPortion::HandlePortion()
125cdf0e10cSrcweir  *************************************************************************/
126cdf0e10cSrcweir 
HandlePortion(SwPortionHandler & rPH) const127cdf0e10cSrcweir void SwBreakPortion::HandlePortion( SwPortionHandler& rPH ) const
128cdf0e10cSrcweir {
129cdf0e10cSrcweir     rPH.Text( GetLen(), GetWhichPor() );
130cdf0e10cSrcweir }
131cdf0e10cSrcweir 
132cdf0e10cSrcweir 
SwKernPortion(SwLinePortion & rPortion,short nKrn,sal_Bool bBG,sal_Bool bGK)133cdf0e10cSrcweir SwKernPortion::SwKernPortion( SwLinePortion &rPortion, short nKrn,
134cdf0e10cSrcweir                               sal_Bool bBG, sal_Bool bGK ) :
135cdf0e10cSrcweir     nKern( nKrn ), bBackground( bBG ), bGridKern( bGK )
136cdf0e10cSrcweir {
137cdf0e10cSrcweir 	Height( rPortion.Height() );
138cdf0e10cSrcweir 	SetAscent( rPortion.GetAscent() );
139cdf0e10cSrcweir 	nLineLength = 0;
140cdf0e10cSrcweir 	SetWhichPor( POR_KERN );
141cdf0e10cSrcweir 	if( nKern > 0 )
142cdf0e10cSrcweir 		Width( nKern );
143cdf0e10cSrcweir  	rPortion.Insert( this );
144cdf0e10cSrcweir }
145cdf0e10cSrcweir 
SwKernPortion(const SwLinePortion & rPortion)146cdf0e10cSrcweir SwKernPortion::SwKernPortion( const SwLinePortion& rPortion ) :
147cdf0e10cSrcweir     nKern( 0 ), bBackground( sal_False ), bGridKern( sal_True )
148cdf0e10cSrcweir {
149cdf0e10cSrcweir 	Height( rPortion.Height() );
150cdf0e10cSrcweir 	SetAscent( rPortion.GetAscent() );
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 	nLineLength = 0;
153cdf0e10cSrcweir 	SetWhichPor( POR_KERN );
154cdf0e10cSrcweir }
155cdf0e10cSrcweir 
Paint(const SwTxtPaintInfo & rInf) const156cdf0e10cSrcweir void SwKernPortion::Paint( const SwTxtPaintInfo &rInf ) const
157cdf0e10cSrcweir {
158cdf0e10cSrcweir 	if( Width() )
159cdf0e10cSrcweir 	{
160cdf0e10cSrcweir         // bBackground is set for Kerning Portions between two fields
161cdf0e10cSrcweir         if ( bBackground )
162cdf0e10cSrcweir             rInf.DrawViewOpt( *this, POR_FLD );
163cdf0e10cSrcweir 
164cdf0e10cSrcweir 		rInf.DrawBackBrush( *this );
165cdf0e10cSrcweir 
166cdf0e10cSrcweir         // do we have to repaint a post it portion?
167cdf0e10cSrcweir         if( rInf.OnWin() && pPortion && !pPortion->Width() )
168cdf0e10cSrcweir             pPortion->PrePaint( rInf, this );
169cdf0e10cSrcweir 
170cdf0e10cSrcweir         if( rInf.GetFont()->IsPaintBlank() )
171cdf0e10cSrcweir 		{
172cdf0e10cSrcweir             static sal_Char __READONLY_DATA sDoubleSpace[] = "  ";
173cdf0e10cSrcweir 			XubString aTxtDouble( sDoubleSpace, RTL_TEXTENCODING_MS_1252 );
174cdf0e10cSrcweir             // --> FME 2006-07-12 #b6439097#
175cdf0e10cSrcweir             SwRect aClipRect;
176cdf0e10cSrcweir             rInf.CalcRect( *this, &aClipRect, 0 );
177cdf0e10cSrcweir             SwSaveClip aClip( (OutputDevice*)rInf.GetOut() );
178cdf0e10cSrcweir             aClip.ChgClip( aClipRect, 0 );
179cdf0e10cSrcweir             // <--
180cdf0e10cSrcweir             rInf.DrawText( aTxtDouble, *this, 0, 2, sal_True );
181cdf0e10cSrcweir 		}
182cdf0e10cSrcweir 	}
183cdf0e10cSrcweir }
184cdf0e10cSrcweir 
FormatEOL(SwTxtFormatInfo & rInf)185cdf0e10cSrcweir void SwKernPortion::FormatEOL( SwTxtFormatInfo &rInf )
186cdf0e10cSrcweir {
187cdf0e10cSrcweir     if ( bGridKern )
188cdf0e10cSrcweir         return;
189cdf0e10cSrcweir 
190cdf0e10cSrcweir     if( rInf.GetLast() == this )
191cdf0e10cSrcweir 		rInf.SetLast( FindPrevPortion( rInf.GetRoot() ) );
192cdf0e10cSrcweir 	if( nKern < 0 )
193cdf0e10cSrcweir 		Width( -nKern );
194cdf0e10cSrcweir 	else
195cdf0e10cSrcweir 		Width( 0 );
196cdf0e10cSrcweir 	rInf.GetLast()->FormatEOL( rInf );
197cdf0e10cSrcweir }
198cdf0e10cSrcweir 
SwArrowPortion(const SwLinePortion & rPortion)199cdf0e10cSrcweir SwArrowPortion::SwArrowPortion( const SwLinePortion &rPortion ) :
200cdf0e10cSrcweir 	bLeft( sal_True )
201cdf0e10cSrcweir {
202cdf0e10cSrcweir 	Height( rPortion.Height() );
203cdf0e10cSrcweir 	SetAscent( rPortion.GetAscent() );
204cdf0e10cSrcweir 	nLineLength = 0;
205cdf0e10cSrcweir 	SetWhichPor( POR_ARROW );
206cdf0e10cSrcweir }
207cdf0e10cSrcweir 
SwArrowPortion(const SwTxtPaintInfo & rInf)208cdf0e10cSrcweir SwArrowPortion::SwArrowPortion( const SwTxtPaintInfo &rInf )
209cdf0e10cSrcweir 	: bLeft( sal_False )
210cdf0e10cSrcweir {
211cdf0e10cSrcweir     Height( (sal_uInt16)(rInf.GetTxtFrm()->Prt().Height()) );
212cdf0e10cSrcweir 	aPos.X() = rInf.GetTxtFrm()->Frm().Left() +
213cdf0e10cSrcweir 			   rInf.GetTxtFrm()->Prt().Right();
214cdf0e10cSrcweir 	aPos.Y() = rInf.GetTxtFrm()->Frm().Top() +
215cdf0e10cSrcweir 			   rInf.GetTxtFrm()->Prt().Bottom();
216cdf0e10cSrcweir     SetWhichPor( POR_ARROW );
217cdf0e10cSrcweir }
218cdf0e10cSrcweir 
Paint(const SwTxtPaintInfo & rInf) const219cdf0e10cSrcweir void SwArrowPortion::Paint( const SwTxtPaintInfo &rInf ) const
220cdf0e10cSrcweir {
221cdf0e10cSrcweir 	((SwArrowPortion*)this)->aPos = rInf.GetPos();
222cdf0e10cSrcweir }
223cdf0e10cSrcweir 
Compress()224cdf0e10cSrcweir SwLinePortion *SwArrowPortion::Compress() { return this; }
225cdf0e10cSrcweir 
EmptyHeight() const226cdf0e10cSrcweir SwTwips SwTxtFrm::EmptyHeight() const
227cdf0e10cSrcweir {
228cdf0e10cSrcweir     ASSERT( ! IsVertical() || ! IsSwapped(),"SwTxtFrm::EmptyHeight with swapped frame" );
229cdf0e10cSrcweir 
230cdf0e10cSrcweir     SwFont *pFnt;
231cdf0e10cSrcweir 	const SwTxtNode& rTxtNode = *GetTxtNode();
232cdf0e10cSrcweir     const IDocumentSettingAccess* pIDSA = rTxtNode.getIDocumentSettingAccess();
233cdf0e10cSrcweir 	ViewShell *pSh = getRootFrm()->GetCurrShell();
234cdf0e10cSrcweir 	if ( rTxtNode.HasSwAttrSet() )
235cdf0e10cSrcweir 	{
236cdf0e10cSrcweir 		const SwAttrSet *pAttrSet = &( rTxtNode.GetSwAttrSet() );
237cdf0e10cSrcweir         pFnt = new SwFont( pAttrSet, pIDSA );
238cdf0e10cSrcweir 	}
239cdf0e10cSrcweir 	else
240cdf0e10cSrcweir 	{
241cdf0e10cSrcweir 		SwFontAccess aFontAccess( &rTxtNode.GetAnyFmtColl(), pSh);
242cdf0e10cSrcweir         pFnt = new SwFont( *aFontAccess.Get()->GetFont() );
243cdf0e10cSrcweir 		pFnt->ChkMagic( pSh, pFnt->GetActual() );
244cdf0e10cSrcweir 	}
245cdf0e10cSrcweir 
246cdf0e10cSrcweir     if ( IsVertical() )
247cdf0e10cSrcweir         pFnt->SetVertical( 2700 );
248cdf0e10cSrcweir 
249cdf0e10cSrcweir     OutputDevice* pOut = pSh ? pSh->GetOut() : 0;
250cdf0e10cSrcweir     if ( !pOut || !pSh->GetViewOptions()->getBrowseMode() ||
251cdf0e10cSrcweir 		 pSh->GetViewOptions()->IsPrtFormat() )
252cdf0e10cSrcweir 	{
253cdf0e10cSrcweir         pOut = rTxtNode.getIDocumentDeviceAccess()->getReferenceDevice(true);
254cdf0e10cSrcweir 	}
255cdf0e10cSrcweir 
256cdf0e10cSrcweir     const IDocumentRedlineAccess* pIDRA = rTxtNode.getIDocumentRedlineAccess();
257cdf0e10cSrcweir     if( IDocumentRedlineAccess::IsShowChanges( pIDRA->GetRedlineMode() ) )
258cdf0e10cSrcweir 	{
259cdf0e10cSrcweir         MSHORT nRedlPos = pIDRA->GetRedlinePos( rTxtNode, USHRT_MAX );
260cdf0e10cSrcweir         if( MSHRT_MAX != nRedlPos )
261cdf0e10cSrcweir         {
262cdf0e10cSrcweir             SwAttrHandler aAttrHandler;
263cdf0e10cSrcweir             aAttrHandler.Init(  GetTxtNode()->GetSwAttrSet(),
264cdf0e10cSrcweir                                *GetTxtNode()->getIDocumentSettingAccess(), NULL );
265cdf0e10cSrcweir             SwRedlineItr aRedln( rTxtNode, *pFnt, aAttrHandler,
266cdf0e10cSrcweir                                  nRedlPos, sal_True );
267cdf0e10cSrcweir         }
268cdf0e10cSrcweir     }
269cdf0e10cSrcweir 
270cdf0e10cSrcweir 	SwTwips nRet;
271cdf0e10cSrcweir 	if( !pOut )
272cdf0e10cSrcweir         nRet = IsVertical() ?
273cdf0e10cSrcweir                Prt().SSize().Width() + 1 :
274cdf0e10cSrcweir                Prt().SSize().Height() + 1;
275cdf0e10cSrcweir 	else
276cdf0e10cSrcweir 	{
277cdf0e10cSrcweir 		pFnt->SetFntChg( sal_True );
278cdf0e10cSrcweir         pFnt->ChgPhysFnt( pSh, *pOut );
279cdf0e10cSrcweir         nRet = pFnt->GetHeight( pSh, *pOut );
280cdf0e10cSrcweir 	}
281cdf0e10cSrcweir 	delete pFnt;
282cdf0e10cSrcweir 	return nRet;
283cdf0e10cSrcweir }
284cdf0e10cSrcweir 
285cdf0e10cSrcweir /*************************************************************************
286cdf0e10cSrcweir  *						SwTxtFrm::FormatEmpty()
287cdf0e10cSrcweir  *************************************************************************/
288cdf0e10cSrcweir 
FormatEmpty()289cdf0e10cSrcweir sal_Bool SwTxtFrm::FormatEmpty()
290cdf0e10cSrcweir {
291cdf0e10cSrcweir     ASSERT( ! IsVertical() || ! IsSwapped(),"SwTxtFrm::FormatEmpty with swapped frame" );
292cdf0e10cSrcweir 
293cdf0e10cSrcweir 	if ( HasFollow() || GetTxtNode()->GetpSwpHints() ||
294cdf0e10cSrcweir 		0 != GetTxtNode()->GetNumRule() ||
295cdf0e10cSrcweir         GetTxtNode()->HasHiddenCharAttribute( true ) ||
296cdf0e10cSrcweir 		 IsInFtn() || ( HasPara() && GetPara()->IsPrepMustFit() ) )
297cdf0e10cSrcweir 		return sal_False;
298cdf0e10cSrcweir 	const SwAttrSet& aSet = GetTxtNode()->GetSwAttrSet();
299cdf0e10cSrcweir     const SvxAdjust nAdjust = aSet.GetAdjust().GetAdjust();
300cdf0e10cSrcweir     if( ( ( ! IsRightToLeft() && ( SVX_ADJUST_LEFT != nAdjust ) ) ||
301cdf0e10cSrcweir           (   IsRightToLeft() && ( SVX_ADJUST_RIGHT != nAdjust ) ) ) ||
302cdf0e10cSrcweir           aSet.GetRegister().GetValue() )
303cdf0e10cSrcweir         return sal_False;
304cdf0e10cSrcweir 	const SvxLineSpacingItem &rSpacing = aSet.GetLineSpacing();
305cdf0e10cSrcweir 	if( SVX_LINE_SPACE_MIN == rSpacing.GetLineSpaceRule() ||
306cdf0e10cSrcweir 		SVX_LINE_SPACE_FIX == rSpacing.GetLineSpaceRule() ||
307cdf0e10cSrcweir 		aSet.GetLRSpace().IsAutoFirst() )
308cdf0e10cSrcweir 		return sal_False;
309cdf0e10cSrcweir 	else
310cdf0e10cSrcweir 	{
311cdf0e10cSrcweir         SwTxtFly aTxtFly( this );
312cdf0e10cSrcweir 		SwRect aRect;
313cdf0e10cSrcweir 		sal_Bool bFirstFlyCheck = 0 != Prt().Height();
314cdf0e10cSrcweir 		if ( bFirstFlyCheck &&
315cdf0e10cSrcweir 			 aTxtFly.IsOn() && aTxtFly.IsAnyObj( aRect ) )
316cdf0e10cSrcweir 			return sal_False;
317cdf0e10cSrcweir 		else
318cdf0e10cSrcweir 		{
319cdf0e10cSrcweir             SwTwips nHeight = EmptyHeight();
320cdf0e10cSrcweir 
321cdf0e10cSrcweir             if ( GetTxtNode()->GetSwAttrSet().GetParaGrid().GetValue() &&
322cdf0e10cSrcweir                  IsInDocBody() )
323cdf0e10cSrcweir             {
324cdf0e10cSrcweir                 GETGRID( FindPageFrm() )
325cdf0e10cSrcweir                 if ( pGrid )
326cdf0e10cSrcweir                     nHeight = pGrid->GetBaseHeight() + pGrid->GetRubyHeight();
327cdf0e10cSrcweir             }
328cdf0e10cSrcweir 
329cdf0e10cSrcweir             SWRECTFN( this )
330cdf0e10cSrcweir             const SwTwips nChg = nHeight - (Prt().*fnRect->fnGetHeight)();
331cdf0e10cSrcweir 
332cdf0e10cSrcweir             if( !nChg )
333cdf0e10cSrcweir 				SetUndersized( sal_False );
334cdf0e10cSrcweir 			AdjustFrm( nChg );
335cdf0e10cSrcweir 
336cdf0e10cSrcweir 			if( HasBlinkPor() )
337cdf0e10cSrcweir 			{
338cdf0e10cSrcweir 				ClearPara();
339cdf0e10cSrcweir 				ResetBlinkPor();
340cdf0e10cSrcweir 			}
341cdf0e10cSrcweir 			SetCacheIdx( MSHRT_MAX );
342cdf0e10cSrcweir 			if( !IsEmpty() )
343cdf0e10cSrcweir 			{
344cdf0e10cSrcweir 				SetEmpty( sal_True );
345cdf0e10cSrcweir 				SetCompletePaint();
346cdf0e10cSrcweir 			}
347cdf0e10cSrcweir 			if( !bFirstFlyCheck &&
348cdf0e10cSrcweir 				 aTxtFly.IsOn() && aTxtFly.IsAnyObj( aRect ) )
349cdf0e10cSrcweir 				 return sal_False;
350cdf0e10cSrcweir 
351cdf0e10cSrcweir             // --> OD 2004-11-17 #i35635# - call method <HideAndShowObjects()>
352cdf0e10cSrcweir             // to assure that objects anchored at the empty paragraph are
353cdf0e10cSrcweir             // correctly visible resp. invisible.
354cdf0e10cSrcweir             HideAndShowObjects();
355cdf0e10cSrcweir             // <--
356cdf0e10cSrcweir 			return sal_True;
357cdf0e10cSrcweir 		}
358cdf0e10cSrcweir 	}
359cdf0e10cSrcweir }
360cdf0e10cSrcweir 
FillRegister(SwTwips & rRegStart,KSHORT & rRegDiff)361cdf0e10cSrcweir sal_Bool SwTxtFrm::FillRegister( SwTwips& rRegStart, KSHORT& rRegDiff )
362cdf0e10cSrcweir {
363cdf0e10cSrcweir 	const SwFrm *pFrm = this;
364cdf0e10cSrcweir 	rRegDiff = 0;
365cdf0e10cSrcweir 	while( !( ( FRM_BODY | FRM_FLY )
366cdf0e10cSrcweir 		   & pFrm->GetType() ) && pFrm->GetUpper() )
367cdf0e10cSrcweir 		pFrm = pFrm->GetUpper();
368cdf0e10cSrcweir 	if( ( FRM_BODY| FRM_FLY ) & pFrm->GetType() )
369cdf0e10cSrcweir 	{
370cdf0e10cSrcweir         SWRECTFN( pFrm )
371cdf0e10cSrcweir         rRegStart = (pFrm->*fnRect->fnGetPrtTop)();
372cdf0e10cSrcweir 		pFrm = pFrm->FindPageFrm();
373cdf0e10cSrcweir 		if( pFrm->IsPageFrm() )
374cdf0e10cSrcweir 		{
375cdf0e10cSrcweir 			SwPageDesc* pDesc = ((SwPageFrm*)pFrm)->FindPageDesc();
376cdf0e10cSrcweir 			if( pDesc )
377cdf0e10cSrcweir 			{
378cdf0e10cSrcweir 				rRegDiff = pDesc->GetRegHeight();
379cdf0e10cSrcweir 				if( !rRegDiff )
380cdf0e10cSrcweir 				{
381cdf0e10cSrcweir 					const SwTxtFmtColl *pFmt = pDesc->GetRegisterFmtColl();
382cdf0e10cSrcweir 					if( pFmt )
383cdf0e10cSrcweir 					{
384cdf0e10cSrcweir 						const SvxLineSpacingItem &rSpace = pFmt->GetLineSpacing();
385cdf0e10cSrcweir 						if( SVX_LINE_SPACE_FIX == rSpace.GetLineSpaceRule() )
386cdf0e10cSrcweir 						{
387cdf0e10cSrcweir 							rRegDiff = rSpace.GetLineHeight();
388cdf0e10cSrcweir 							pDesc->SetRegHeight( rRegDiff );
389cdf0e10cSrcweir 							pDesc->SetRegAscent( ( 4 * rRegDiff ) / 5 );
390cdf0e10cSrcweir 						}
391cdf0e10cSrcweir 						else
392cdf0e10cSrcweir 						{
393cdf0e10cSrcweir 							ViewShell *pSh = getRootFrm()->GetCurrShell();
394cdf0e10cSrcweir 							SwFontAccess aFontAccess( pFmt, pSh );
395cdf0e10cSrcweir 							SwFont aFnt( *aFontAccess.Get()->GetFont() );
396cdf0e10cSrcweir 
397cdf0e10cSrcweir 							OutputDevice *pOut = 0;
398cdf0e10cSrcweir                             if( !pSh || !pSh->GetViewOptions()->getBrowseMode() ||
399cdf0e10cSrcweir 								pSh->GetViewOptions()->IsPrtFormat() )
400cdf0e10cSrcweir                                 pOut = GetTxtNode()->getIDocumentDeviceAccess()->getReferenceDevice( true );
401cdf0e10cSrcweir 
402cdf0e10cSrcweir                             if( pSh && !pOut )
403cdf0e10cSrcweir 								pOut = pSh->GetWin();
404cdf0e10cSrcweir 
405cdf0e10cSrcweir 							if( !pOut )
406cdf0e10cSrcweir 								pOut = GetpApp()->GetDefaultDevice();
407cdf0e10cSrcweir 
408cdf0e10cSrcweir 							MapMode aOldMap( pOut->GetMapMode() );
409cdf0e10cSrcweir 							pOut->SetMapMode( MapMode( MAP_TWIP ) );
410cdf0e10cSrcweir 
411cdf0e10cSrcweir                             aFnt.ChgFnt( pSh, *pOut );
412cdf0e10cSrcweir                             rRegDiff = aFnt.GetHeight( pSh, *pOut );
413cdf0e10cSrcweir 							KSHORT nNettoHeight = rRegDiff;
414cdf0e10cSrcweir 
415cdf0e10cSrcweir 							switch( rSpace.GetLineSpaceRule() )
416cdf0e10cSrcweir 							{
417cdf0e10cSrcweir 								case SVX_LINE_SPACE_AUTO:
418cdf0e10cSrcweir 								break;
419cdf0e10cSrcweir 								case SVX_LINE_SPACE_MIN:
420cdf0e10cSrcweir 								{
421cdf0e10cSrcweir 									if( rRegDiff < KSHORT( rSpace.GetLineHeight() ) )
422cdf0e10cSrcweir 										rRegDiff = rSpace.GetLineHeight();
423cdf0e10cSrcweir 									break;
424cdf0e10cSrcweir 								}
425cdf0e10cSrcweir 								default: ASSERT(
426cdf0e10cSrcweir 								sal_False, ": unknown LineSpaceRule" );
427cdf0e10cSrcweir 							}
428cdf0e10cSrcweir 							switch( rSpace.GetInterLineSpaceRule() )
429cdf0e10cSrcweir 							{
430cdf0e10cSrcweir 								case SVX_INTER_LINE_SPACE_OFF:
431cdf0e10cSrcweir 								break;
432cdf0e10cSrcweir 								case SVX_INTER_LINE_SPACE_PROP:
433cdf0e10cSrcweir 								{
434cdf0e10cSrcweir 									long nTmp = rSpace.GetPropLineSpace();
435cdf0e10cSrcweir 									if( nTmp < 50 )
436cdf0e10cSrcweir 										nTmp = nTmp ? 50 : 100;
437cdf0e10cSrcweir 									nTmp *= rRegDiff;
438cdf0e10cSrcweir 									nTmp /= 100;
439cdf0e10cSrcweir 									if( !nTmp )
440cdf0e10cSrcweir 										++nTmp;
441cdf0e10cSrcweir 									rRegDiff = (KSHORT)nTmp;
442cdf0e10cSrcweir 									nNettoHeight = rRegDiff;
443cdf0e10cSrcweir 									break;
444cdf0e10cSrcweir 								}
445cdf0e10cSrcweir 								case SVX_INTER_LINE_SPACE_FIX:
446cdf0e10cSrcweir 								{
447cdf0e10cSrcweir 									rRegDiff = rRegDiff + rSpace.GetInterLineSpace();
448cdf0e10cSrcweir 									nNettoHeight = rRegDiff;
449cdf0e10cSrcweir 									break;
450cdf0e10cSrcweir 								}
451cdf0e10cSrcweir 								default: ASSERT( sal_False, ": unknown InterLineSpaceRule" );
452cdf0e10cSrcweir 							}
453cdf0e10cSrcweir 							pDesc->SetRegHeight( rRegDiff );
454cdf0e10cSrcweir 							pDesc->SetRegAscent( rRegDiff - nNettoHeight +
455cdf0e10cSrcweir                                                  aFnt.GetAscent( pSh, *pOut ) );
456cdf0e10cSrcweir 							pOut->SetMapMode( aOldMap );
457cdf0e10cSrcweir 						}
458cdf0e10cSrcweir 					}
459cdf0e10cSrcweir 				}
460cdf0e10cSrcweir                 const long nTmpDiff = pDesc->GetRegAscent() - rRegDiff;
461cdf0e10cSrcweir                 if ( bVert )
462cdf0e10cSrcweir                     rRegStart -= nTmpDiff;
463cdf0e10cSrcweir                 else
464cdf0e10cSrcweir                     rRegStart += nTmpDiff;
465cdf0e10cSrcweir 			}
466cdf0e10cSrcweir 		}
467cdf0e10cSrcweir 	}
468cdf0e10cSrcweir 	return ( 0 != rRegDiff );
469cdf0e10cSrcweir }
470cdf0e10cSrcweir 
471cdf0e10cSrcweir /*************************************************************************
472cdf0e10cSrcweir  *              virtual SwHiddenTextPortion::Paint()
473cdf0e10cSrcweir  *************************************************************************/
474cdf0e10cSrcweir 
Paint(const SwTxtPaintInfo & rInf) const475cdf0e10cSrcweir void SwHiddenTextPortion::Paint( const SwTxtPaintInfo & rInf) const
476cdf0e10cSrcweir {
477cdf0e10cSrcweir     (void)rInf;
478cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
479cdf0e10cSrcweir     OutputDevice* pOut = (OutputDevice*)rInf.GetOut();
480cdf0e10cSrcweir     Color aCol( SwViewOption::GetFieldShadingsColor() );
481cdf0e10cSrcweir     Color aOldColor( pOut->GetFillColor() );
482cdf0e10cSrcweir     pOut->SetFillColor( aCol );
483cdf0e10cSrcweir     Point aPos( rInf.GetPos() );
484cdf0e10cSrcweir     aPos.Y() -= 150;
485cdf0e10cSrcweir     aPos.X() -= 25;
486cdf0e10cSrcweir     SwRect aRect( aPos, Size( 100, 200 ) );
487cdf0e10cSrcweir     ((OutputDevice*)pOut)->DrawRect( aRect.SVRect() );
488cdf0e10cSrcweir     pOut->SetFillColor( aOldColor );
489cdf0e10cSrcweir #endif
490cdf0e10cSrcweir }
491cdf0e10cSrcweir 
492cdf0e10cSrcweir /*************************************************************************
493cdf0e10cSrcweir  *              virtual SwHiddenTextPortion::Format()
494cdf0e10cSrcweir  *************************************************************************/
495cdf0e10cSrcweir 
Format(SwTxtFormatInfo & rInf)496cdf0e10cSrcweir sal_Bool SwHiddenTextPortion::Format( SwTxtFormatInfo &rInf )
497cdf0e10cSrcweir {
498cdf0e10cSrcweir     Width( 0 );
499cdf0e10cSrcweir     rInf.GetTxtFrm()->HideFootnotes( rInf.GetIdx(), rInf.GetIdx() + GetLen() );
500cdf0e10cSrcweir 
501cdf0e10cSrcweir     return sal_False;
502cdf0e10cSrcweir };
503cdf0e10cSrcweir 
504cdf0e10cSrcweir /*************************************************************************
505cdf0e10cSrcweir  *              virtual SwControlCharPortion::Paint()
506cdf0e10cSrcweir  *************************************************************************/
507cdf0e10cSrcweir 
Paint(const SwTxtPaintInfo & rInf) const508cdf0e10cSrcweir void SwControlCharPortion::Paint( const SwTxtPaintInfo &rInf ) const
509cdf0e10cSrcweir {
510cdf0e10cSrcweir     if ( Width() )  // is only set during prepaint mode
511cdf0e10cSrcweir     {
512cdf0e10cSrcweir         rInf.DrawViewOpt( *this, POR_CONTROLCHAR );
513cdf0e10cSrcweir 
514cdf0e10cSrcweir         if ( !rInf.GetOpt().IsPagePreview() &&
515cdf0e10cSrcweir              !rInf.GetOpt().IsReadonly() &&
516cdf0e10cSrcweir               SwViewOption::IsFieldShadings() &&
517cdf0e10cSrcweir               CHAR_ZWNBSP != mcChar )
518cdf0e10cSrcweir         {
519cdf0e10cSrcweir             SwFont aTmpFont( *rInf.GetFont() );
520cdf0e10cSrcweir             aTmpFont.SetEscapement( CHAR_ZWSP == mcChar ? DFLT_ESC_AUTO_SUB : -25 );
521cdf0e10cSrcweir             const sal_uInt16 nProp = 40;
522cdf0e10cSrcweir             aTmpFont.SetProportion( nProp );  // a smaller font
523cdf0e10cSrcweir             SwFontSave aFontSave( rInf, &aTmpFont );
524cdf0e10cSrcweir 
525cdf0e10cSrcweir             String aOutString;
526cdf0e10cSrcweir 
527cdf0e10cSrcweir             switch ( mcChar )
528cdf0e10cSrcweir             {
529cdf0e10cSrcweir                 case CHAR_ZWSP :
530cdf0e10cSrcweir                     aOutString = '/'; break;
531cdf0e10cSrcweir //                case CHAR_LRM :
532cdf0e10cSrcweir //                    rTxt = sal_Unicode(0x2514); break;
533cdf0e10cSrcweir //                case CHAR_RLM :
534cdf0e10cSrcweir //                    rTxt = sal_Unicode(0x2518); break;
535cdf0e10cSrcweir             }
536cdf0e10cSrcweir 
537cdf0e10cSrcweir             if ( !mnHalfCharWidth )
538cdf0e10cSrcweir                 mnHalfCharWidth = rInf.GetTxtSize( aOutString ).Width() / 2;
539cdf0e10cSrcweir 
540cdf0e10cSrcweir             Point aOldPos = rInf.GetPos();
541cdf0e10cSrcweir             Point aNewPos( aOldPos );
542cdf0e10cSrcweir             aNewPos.X() = aNewPos.X() + ( Width() / 2 ) - mnHalfCharWidth;
543cdf0e10cSrcweir             const_cast< SwTxtPaintInfo& >( rInf ).SetPos( aNewPos );
544cdf0e10cSrcweir 
545cdf0e10cSrcweir             rInf.DrawText( aOutString, *this );
546cdf0e10cSrcweir 
547cdf0e10cSrcweir             const_cast< SwTxtPaintInfo& >( rInf ).SetPos( aOldPos );
548cdf0e10cSrcweir         }
549cdf0e10cSrcweir     }
550cdf0e10cSrcweir }
551cdf0e10cSrcweir 
552cdf0e10cSrcweir /*************************************************************************
553cdf0e10cSrcweir  *              virtual SwControlCharPortion::Format()
554cdf0e10cSrcweir  *************************************************************************/
555cdf0e10cSrcweir 
Format(SwTxtFormatInfo & rInf)556cdf0e10cSrcweir sal_Bool SwControlCharPortion::Format( SwTxtFormatInfo &rInf )
557cdf0e10cSrcweir {
558cdf0e10cSrcweir     const SwLinePortion* pRoot = rInf.GetRoot();
559cdf0e10cSrcweir     Width( 0 );
560cdf0e10cSrcweir     Height( pRoot->Height() );
561cdf0e10cSrcweir     SetAscent( pRoot->GetAscent() );
562cdf0e10cSrcweir 
563cdf0e10cSrcweir     return sal_False;
564cdf0e10cSrcweir }
565cdf0e10cSrcweir 
566cdf0e10cSrcweir /*************************************************************************
567cdf0e10cSrcweir  *              virtual SwControlCharPortion::GetViewWidth()
568cdf0e10cSrcweir  *************************************************************************/
569cdf0e10cSrcweir 
GetViewWidth(const SwTxtSizeInfo & rInf) const570cdf0e10cSrcweir KSHORT SwControlCharPortion::GetViewWidth( const SwTxtSizeInfo& rInf ) const
571cdf0e10cSrcweir {
572cdf0e10cSrcweir     if( !mnViewWidth )
573cdf0e10cSrcweir         mnViewWidth = rInf.GetTxtSize( ' ' ).Width();
574cdf0e10cSrcweir 
575cdf0e10cSrcweir     return mnViewWidth;
576cdf0e10cSrcweir }
577