1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5efeef26fSAndrew Rist * distributed with this work for additional information
6efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist * software distributed under the License is distributed on an
15efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17efeef26fSAndrew Rist * specific language governing permissions and limitations
18efeef26fSAndrew Rist * under the License.
19cdf0e10cSrcweir *
20efeef26fSAndrew Rist *************************************************************/
21efeef26fSAndrew Rist
22efeef26fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir #include <hintids.hxx>
27cdf0e10cSrcweir #include <hints.hxx>
28cdf0e10cSrcweir #include <svl/ctloptions.hxx>
29cdf0e10cSrcweir #include <sfx2/printer.hxx>
30cdf0e10cSrcweir #include <sfx2/sfxuno.hxx>
31cdf0e10cSrcweir #include <editeng/langitem.hxx>
32cdf0e10cSrcweir #include <editeng/lspcitem.hxx>
33cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
34cdf0e10cSrcweir #include <editeng/ulspitem.hxx>
35cdf0e10cSrcweir #include <editeng/brshitem.hxx>
36cdf0e10cSrcweir #include <editeng/pgrditem.hxx>
37cdf0e10cSrcweir #include <swmodule.hxx>
38cdf0e10cSrcweir #include <SwSmartTagMgr.hxx>
39cdf0e10cSrcweir #include <doc.hxx> // GetDoc()
40cdf0e10cSrcweir #include "rootfrm.hxx"
41cdf0e10cSrcweir #include <pagefrm.hxx> // InvalidateSpelling
42cdf0e10cSrcweir #include <rootfrm.hxx>
43cdf0e10cSrcweir #include <viewsh.hxx> // ViewShell
44cdf0e10cSrcweir #include <pam.hxx> // SwPosition
45cdf0e10cSrcweir #include <ndtxt.hxx> // SwTxtNode
46cdf0e10cSrcweir #include <txtatr.hxx>
47cdf0e10cSrcweir #include <paratr.hxx>
48cdf0e10cSrcweir #include <viewopt.hxx>
49cdf0e10cSrcweir #include <dflyobj.hxx>
50cdf0e10cSrcweir #include <flyfrm.hxx>
51cdf0e10cSrcweir #include <tabfrm.hxx>
52cdf0e10cSrcweir #include <frmtool.hxx>
53cdf0e10cSrcweir #include <pagedesc.hxx> // SwPageDesc
54cdf0e10cSrcweir #include <tgrditem.hxx>
55cdf0e10cSrcweir #include <dbg_lay.hxx>
56cdf0e10cSrcweir #include <fmtfld.hxx>
57cdf0e10cSrcweir #include <fmtftn.hxx>
58cdf0e10cSrcweir #include <txtfld.hxx>
59cdf0e10cSrcweir #include <txtftn.hxx>
60cdf0e10cSrcweir #include <charatr.hxx>
61cdf0e10cSrcweir #include <ftninfo.hxx>
62cdf0e10cSrcweir #include <fmtline.hxx>
63cdf0e10cSrcweir #include <txtfrm.hxx> // SwTxtFrm
64cdf0e10cSrcweir #include <sectfrm.hxx> // SwSectFrm
65cdf0e10cSrcweir #include <txtcfg.hxx> // DBG_LOOP
66cdf0e10cSrcweir #include <itrform2.hxx> // Iteratoren
67cdf0e10cSrcweir #include <widorp.hxx> // SwFrmBreak
68cdf0e10cSrcweir #include <txtcache.hxx>
69cdf0e10cSrcweir #include <fntcache.hxx> // GetLineSpace benutzt pLastFont
70cdf0e10cSrcweir #include <SwGrammarMarkUp.hxx>
71cdf0e10cSrcweir #include <lineinfo.hxx>
72cdf0e10cSrcweir #include <SwPortionHandler.hxx>
73cdf0e10cSrcweir #include <dcontact.hxx>
74cdf0e10cSrcweir #include <sortedobjs.hxx>
75cdf0e10cSrcweir #include <txtflcnt.hxx> // SwTxtFlyCnt
76cdf0e10cSrcweir #include <fmtflcnt.hxx> // SwFmtFlyCnt
77cdf0e10cSrcweir #include <fmtcntnt.hxx> // SwFmtCntnt
78cdf0e10cSrcweir #include <numrule.hxx>
79cdf0e10cSrcweir #include <swtable.hxx>
80cdf0e10cSrcweir #include <fldupde.hxx>
81cdf0e10cSrcweir #include <IGrammarContact.hxx>
82cdf0e10cSrcweir #include <switerator.hxx>
83cdf0e10cSrcweir
84cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
85cdf0e10cSrcweir #include <txtpaint.hxx> // DbgRect
86cdf0e10cSrcweir extern const sal_Char *GetPrepName( const enum PrepareHint ePrep );
87cdf0e10cSrcweir #endif
88cdf0e10cSrcweir
89cdf0e10cSrcweir
90cdf0e10cSrcweir TYPEINIT1( SwTxtFrm, SwCntntFrm );
91cdf0e10cSrcweir
92cdf0e10cSrcweir // Switches width and height of the text frame
SwapWidthAndHeight()93cdf0e10cSrcweir void SwTxtFrm::SwapWidthAndHeight()
94cdf0e10cSrcweir {
95cdf0e10cSrcweir if ( ! bIsSwapped )
96cdf0e10cSrcweir {
97cdf0e10cSrcweir const long nPrtOfstX = Prt().Pos().X();
98cdf0e10cSrcweir Prt().Pos().X() = Prt().Pos().Y();
99cdf0e10cSrcweir //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
100cdf0e10cSrcweir if( IsVertLR() )
101cdf0e10cSrcweir Prt().Pos().Y() = nPrtOfstX;
102cdf0e10cSrcweir else
103cdf0e10cSrcweir Prt().Pos().Y() = Frm().Width() - ( nPrtOfstX + Prt().Width() );
104cdf0e10cSrcweir
105cdf0e10cSrcweir }
106cdf0e10cSrcweir else
107cdf0e10cSrcweir {
108cdf0e10cSrcweir const long nPrtOfstY = Prt().Pos().Y();
109cdf0e10cSrcweir Prt().Pos().Y() = Prt().Pos().X();
110cdf0e10cSrcweir //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
111cdf0e10cSrcweir if( IsVertLR() )
112cdf0e10cSrcweir Prt().Pos().X() = nPrtOfstY;
113cdf0e10cSrcweir else
114cdf0e10cSrcweir Prt().Pos().X() = Frm().Height() - ( nPrtOfstY + Prt().Height() );
115cdf0e10cSrcweir }
116cdf0e10cSrcweir
117cdf0e10cSrcweir const long nFrmWidth = Frm().Width();
118cdf0e10cSrcweir Frm().Width( Frm().Height() );
119cdf0e10cSrcweir Frm().Height( nFrmWidth );
120cdf0e10cSrcweir const long nPrtWidth = Prt().Width();
121cdf0e10cSrcweir Prt().Width( Prt().Height() );
122cdf0e10cSrcweir Prt().Height( nPrtWidth );
123cdf0e10cSrcweir
124cdf0e10cSrcweir bIsSwapped = ! bIsSwapped;
125cdf0e10cSrcweir }
126cdf0e10cSrcweir
127cdf0e10cSrcweir // Calculates the coordinates of a rectangle when switching from
128cdf0e10cSrcweir // horizontal to vertical layout.
SwitchHorizontalToVertical(SwRect & rRect) const129cdf0e10cSrcweir void SwTxtFrm::SwitchHorizontalToVertical( SwRect& rRect ) const
130cdf0e10cSrcweir {
131cdf0e10cSrcweir // calc offset inside frame
132cdf0e10cSrcweir //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
133cdf0e10cSrcweir long nOfstX, nOfstY;
134cdf0e10cSrcweir if ( IsVertLR() )
135cdf0e10cSrcweir {
136cdf0e10cSrcweir nOfstX = rRect.Left() - Frm().Left();
137cdf0e10cSrcweir nOfstY = rRect.Top() - Frm().Top();
138cdf0e10cSrcweir }
139cdf0e10cSrcweir else
140cdf0e10cSrcweir {
141cdf0e10cSrcweir nOfstX = rRect.Left() - Frm().Left();
142cdf0e10cSrcweir nOfstY = rRect.Top() + rRect.Height() - Frm().Top();
143cdf0e10cSrcweir }
144cdf0e10cSrcweir
145cdf0e10cSrcweir const long nWidth = rRect.Width();
146cdf0e10cSrcweir const long nHeight = rRect.Height();
147cdf0e10cSrcweir
148cdf0e10cSrcweir //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
149cdf0e10cSrcweir if ( IsVertLR() )
150cdf0e10cSrcweir rRect.Left(Frm().Left() + nOfstY);
151cdf0e10cSrcweir else
152cdf0e10cSrcweir {
153cdf0e10cSrcweir if ( bIsSwapped )
154cdf0e10cSrcweir rRect.Left( Frm().Left() + Frm().Height() - nOfstY );
155cdf0e10cSrcweir else
156cdf0e10cSrcweir // frame is rotated
157cdf0e10cSrcweir rRect.Left( Frm().Left() + Frm().Width() - nOfstY );
158cdf0e10cSrcweir }
159cdf0e10cSrcweir
160cdf0e10cSrcweir rRect.Top( Frm().Top() + nOfstX );
161cdf0e10cSrcweir rRect.Width( nHeight );
162cdf0e10cSrcweir rRect.Height( nWidth );
163cdf0e10cSrcweir }
164cdf0e10cSrcweir
165cdf0e10cSrcweir // Calculates the coordinates of a point when switching from
166cdf0e10cSrcweir // horizontal to vertical layout.
SwitchHorizontalToVertical(Point & rPoint) const167cdf0e10cSrcweir void SwTxtFrm::SwitchHorizontalToVertical( Point& rPoint ) const
168cdf0e10cSrcweir {
169cdf0e10cSrcweir // calc offset inside frame
170cdf0e10cSrcweir const long nOfstX = rPoint.X() - Frm().Left();
171cdf0e10cSrcweir const long nOfstY = rPoint.Y() - Frm().Top();
172cdf0e10cSrcweir //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
173cdf0e10cSrcweir if ( IsVertLR() )
174cdf0e10cSrcweir rPoint.X() = Frm().Left() + nOfstY;
175cdf0e10cSrcweir else
176cdf0e10cSrcweir {
177cdf0e10cSrcweir if ( bIsSwapped )
178cdf0e10cSrcweir rPoint.X() = Frm().Left() + Frm().Height() - nOfstY;
179cdf0e10cSrcweir else
180cdf0e10cSrcweir // calc rotated coords
181cdf0e10cSrcweir rPoint.X() = Frm().Left() + Frm().Width() - nOfstY;
182cdf0e10cSrcweir }
183cdf0e10cSrcweir
184cdf0e10cSrcweir rPoint.Y() = Frm().Top() + nOfstX;
185cdf0e10cSrcweir }
186cdf0e10cSrcweir
187cdf0e10cSrcweir // Calculates the a limit value when switching from
188cdf0e10cSrcweir // horizontal to vertical layout.
SwitchHorizontalToVertical(long nLimit) const189cdf0e10cSrcweir long SwTxtFrm::SwitchHorizontalToVertical( long nLimit ) const
190cdf0e10cSrcweir {
191cdf0e10cSrcweir Point aTmp( 0, nLimit );
192cdf0e10cSrcweir SwitchHorizontalToVertical( aTmp );
193cdf0e10cSrcweir return aTmp.X();
194cdf0e10cSrcweir }
195cdf0e10cSrcweir
196cdf0e10cSrcweir // Calculates the coordinates of a rectangle when switching from
197cdf0e10cSrcweir // vertical to horizontal layout.
SwitchVerticalToHorizontal(SwRect & rRect) const198cdf0e10cSrcweir void SwTxtFrm::SwitchVerticalToHorizontal( SwRect& rRect ) const
199cdf0e10cSrcweir {
200cdf0e10cSrcweir long nOfstX;
201cdf0e10cSrcweir
202cdf0e10cSrcweir // calc offset inside frame
203cdf0e10cSrcweir
204cdf0e10cSrcweir //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
205cdf0e10cSrcweir if ( IsVertLR() )
206cdf0e10cSrcweir nOfstX = rRect.Left() - Frm().Left();
207cdf0e10cSrcweir else
208cdf0e10cSrcweir {
209cdf0e10cSrcweir if ( bIsSwapped )
210cdf0e10cSrcweir nOfstX = Frm().Left() + Frm().Height() - ( rRect.Left() + rRect.Width() );
211cdf0e10cSrcweir else
212cdf0e10cSrcweir nOfstX = Frm().Left() + Frm().Width() - ( rRect.Left() + rRect.Width() );
213cdf0e10cSrcweir }
214cdf0e10cSrcweir
215cdf0e10cSrcweir const long nOfstY = rRect.Top() - Frm().Top();
216cdf0e10cSrcweir const long nWidth = rRect.Height();
217cdf0e10cSrcweir const long nHeight = rRect.Width();
218cdf0e10cSrcweir
219cdf0e10cSrcweir // calc rotated coords
220cdf0e10cSrcweir rRect.Left( Frm().Left() + nOfstY );
221cdf0e10cSrcweir rRect.Top( Frm().Top() + nOfstX );
222cdf0e10cSrcweir rRect.Width( nWidth );
223cdf0e10cSrcweir rRect.Height( nHeight );
224cdf0e10cSrcweir }
225cdf0e10cSrcweir
226cdf0e10cSrcweir // Calculates the coordinates of a point when switching from
227cdf0e10cSrcweir // vertical to horizontal layout.
SwitchVerticalToHorizontal(Point & rPoint) const228cdf0e10cSrcweir void SwTxtFrm::SwitchVerticalToHorizontal( Point& rPoint ) const
229cdf0e10cSrcweir {
230cdf0e10cSrcweir long nOfstX;
231cdf0e10cSrcweir
232cdf0e10cSrcweir // calc offset inside frame
233cdf0e10cSrcweir
234cdf0e10cSrcweir //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
235cdf0e10cSrcweir if ( IsVertLR() )
236cdf0e10cSrcweir nOfstX = rPoint.X() - Frm().Left();
237cdf0e10cSrcweir else
238cdf0e10cSrcweir {
239cdf0e10cSrcweir if ( bIsSwapped )
240cdf0e10cSrcweir nOfstX = Frm().Left() + Frm().Height() - rPoint.X();
241cdf0e10cSrcweir else
242cdf0e10cSrcweir nOfstX = Frm().Left() + Frm().Width() - rPoint.X();
243cdf0e10cSrcweir }
244cdf0e10cSrcweir
245cdf0e10cSrcweir const long nOfstY = rPoint.Y() - Frm().Top();
246cdf0e10cSrcweir
247cdf0e10cSrcweir // calc rotated coords
248cdf0e10cSrcweir rPoint.X() = Frm().Left() + nOfstY;
249cdf0e10cSrcweir rPoint.Y() = Frm().Top() + nOfstX;
250cdf0e10cSrcweir }
251cdf0e10cSrcweir
252cdf0e10cSrcweir // Calculates the a limit value when switching from
253cdf0e10cSrcweir // vertical to horizontal layout.
SwitchVerticalToHorizontal(long nLimit) const254cdf0e10cSrcweir long SwTxtFrm::SwitchVerticalToHorizontal( long nLimit ) const
255cdf0e10cSrcweir {
256cdf0e10cSrcweir Point aTmp( nLimit, 0 );
257cdf0e10cSrcweir SwitchVerticalToHorizontal( aTmp );
258cdf0e10cSrcweir return aTmp.Y();
259cdf0e10cSrcweir }
260cdf0e10cSrcweir
SwFrmSwapper(const SwTxtFrm * pTxtFrm,sal_Bool bSwapIfNotSwapped)261cdf0e10cSrcweir SwFrmSwapper::SwFrmSwapper( const SwTxtFrm* pTxtFrm, sal_Bool bSwapIfNotSwapped )
262cdf0e10cSrcweir : pFrm( pTxtFrm ), bUndo( sal_False )
263cdf0e10cSrcweir {
264cdf0e10cSrcweir if ( pFrm->IsVertical() &&
265cdf0e10cSrcweir ( ( bSwapIfNotSwapped && ! pFrm->IsSwapped() ) ||
266cdf0e10cSrcweir ( ! bSwapIfNotSwapped && pFrm->IsSwapped() ) ) )
267cdf0e10cSrcweir {
268cdf0e10cSrcweir bUndo = sal_True;
269cdf0e10cSrcweir ((SwTxtFrm*)pFrm)->SwapWidthAndHeight();
270cdf0e10cSrcweir }
271cdf0e10cSrcweir }
272cdf0e10cSrcweir
~SwFrmSwapper()273cdf0e10cSrcweir SwFrmSwapper::~SwFrmSwapper()
274cdf0e10cSrcweir {
275cdf0e10cSrcweir if ( bUndo )
276cdf0e10cSrcweir ((SwTxtFrm*)pFrm)->SwapWidthAndHeight();
277cdf0e10cSrcweir }
278cdf0e10cSrcweir
SwitchLTRtoRTL(SwRect & rRect) const279cdf0e10cSrcweir void SwTxtFrm::SwitchLTRtoRTL( SwRect& rRect ) const
280cdf0e10cSrcweir {
281cdf0e10cSrcweir SWAP_IF_NOT_SWAPPED( this )
282cdf0e10cSrcweir
283cdf0e10cSrcweir long nWidth = rRect.Width();
284cdf0e10cSrcweir rRect.Left( 2 * ( Frm().Left() + Prt().Left() ) +
285cdf0e10cSrcweir Prt().Width() - rRect.Right() - 1 );
286cdf0e10cSrcweir
287cdf0e10cSrcweir rRect.Width( nWidth );
288cdf0e10cSrcweir
289cdf0e10cSrcweir UNDO_SWAP( this )
290cdf0e10cSrcweir }
291cdf0e10cSrcweir
SwitchLTRtoRTL(Point & rPoint) const292cdf0e10cSrcweir void SwTxtFrm::SwitchLTRtoRTL( Point& rPoint ) const
293cdf0e10cSrcweir {
294cdf0e10cSrcweir SWAP_IF_NOT_SWAPPED( this )
295cdf0e10cSrcweir
296cdf0e10cSrcweir rPoint.X() = 2 * ( Frm().Left() + Prt().Left() ) + Prt().Width() - rPoint.X() - 1;
297cdf0e10cSrcweir
298cdf0e10cSrcweir UNDO_SWAP( this )
299cdf0e10cSrcweir }
300cdf0e10cSrcweir
SwLayoutModeModifier(const OutputDevice & rOutp)301cdf0e10cSrcweir SwLayoutModeModifier::SwLayoutModeModifier( const OutputDevice& rOutp ) :
302cdf0e10cSrcweir rOut( rOutp ), nOldLayoutMode( rOutp.GetLayoutMode() )
303cdf0e10cSrcweir {
304cdf0e10cSrcweir }
305cdf0e10cSrcweir
~SwLayoutModeModifier()306cdf0e10cSrcweir SwLayoutModeModifier::~SwLayoutModeModifier()
307cdf0e10cSrcweir {
308cdf0e10cSrcweir ((OutputDevice&)rOut).SetLayoutMode( nOldLayoutMode );
309cdf0e10cSrcweir }
310cdf0e10cSrcweir
Modify(sal_Bool bChgToRTL)311cdf0e10cSrcweir void SwLayoutModeModifier::Modify( sal_Bool bChgToRTL )
312cdf0e10cSrcweir {
313cdf0e10cSrcweir ((OutputDevice&)rOut).SetLayoutMode( bChgToRTL ?
314cdf0e10cSrcweir TEXT_LAYOUT_BIDI_STRONG | TEXT_LAYOUT_BIDI_RTL :
315cdf0e10cSrcweir TEXT_LAYOUT_BIDI_STRONG );
316cdf0e10cSrcweir }
317cdf0e10cSrcweir
SetAuto()318cdf0e10cSrcweir void SwLayoutModeModifier::SetAuto()
319cdf0e10cSrcweir {
320cdf0e10cSrcweir const sal_uLong nNewLayoutMode = nOldLayoutMode & ~TEXT_LAYOUT_BIDI_STRONG;
321cdf0e10cSrcweir ((OutputDevice&)rOut).SetLayoutMode( nNewLayoutMode );
322cdf0e10cSrcweir }
323cdf0e10cSrcweir
SwDigitModeModifier(const OutputDevice & rOutp,LanguageType eCurLang)324cdf0e10cSrcweir SwDigitModeModifier::SwDigitModeModifier( const OutputDevice& rOutp, LanguageType eCurLang ) :
325cdf0e10cSrcweir rOut( rOutp ), nOldLanguageType( rOutp.GetDigitLanguage() )
326cdf0e10cSrcweir {
327cdf0e10cSrcweir LanguageType eLang = eCurLang;
328cdf0e10cSrcweir const SvtCTLOptions::TextNumerals nTextNumerals = SW_MOD()->GetCTLOptions().GetCTLTextNumerals();
329cdf0e10cSrcweir
330cdf0e10cSrcweir if ( SvtCTLOptions::NUMERALS_HINDI == nTextNumerals )
331cdf0e10cSrcweir eLang = LANGUAGE_ARABIC_SAUDI_ARABIA;
332cdf0e10cSrcweir else if ( SvtCTLOptions::NUMERALS_ARABIC == nTextNumerals )
333cdf0e10cSrcweir eLang = LANGUAGE_ENGLISH;
334cdf0e10cSrcweir else if ( SvtCTLOptions::NUMERALS_SYSTEM == nTextNumerals )
335cdf0e10cSrcweir eLang = (LanguageType)::GetAppLanguage();
336cdf0e10cSrcweir
337cdf0e10cSrcweir ((OutputDevice&)rOut).SetDigitLanguage( eLang );
338cdf0e10cSrcweir }
339cdf0e10cSrcweir
~SwDigitModeModifier()340cdf0e10cSrcweir SwDigitModeModifier::~SwDigitModeModifier()
341cdf0e10cSrcweir {
342cdf0e10cSrcweir ((OutputDevice&)rOut).SetDigitLanguage( nOldLanguageType );
343cdf0e10cSrcweir }
344cdf0e10cSrcweir
345cdf0e10cSrcweir /*************************************************************************
346cdf0e10cSrcweir * SwTxtFrm::Init()
347cdf0e10cSrcweir *************************************************************************/
348cdf0e10cSrcweir
Init()349cdf0e10cSrcweir void SwTxtFrm::Init()
350cdf0e10cSrcweir {
351cdf0e10cSrcweir ASSERT( !IsLocked(), "+SwTxtFrm::Init: this ist locked." );
352cdf0e10cSrcweir if( !IsLocked() )
353cdf0e10cSrcweir {
354cdf0e10cSrcweir ClearPara();
355cdf0e10cSrcweir ResetBlinkPor();
356cdf0e10cSrcweir //Die Flags direkt setzen um ResetPreps und damit ein unnuetzes GetPara
357cdf0e10cSrcweir //einzusparen.
358cdf0e10cSrcweir // Nicht bOrphan, bLocked oder bWait auf sal_False setzen !
359cdf0e10cSrcweir // bOrphan = bFlag7 = bFlag8 = sal_False;
360cdf0e10cSrcweir }
361cdf0e10cSrcweir }
362cdf0e10cSrcweir
363cdf0e10cSrcweir /*************************************************************************
364cdf0e10cSrcweir |* SwTxtFrm::CTORen/DTOR
365cdf0e10cSrcweir |*************************************************************************/
366cdf0e10cSrcweir
InitCtor()367cdf0e10cSrcweir void SwTxtFrm::InitCtor()
368cdf0e10cSrcweir {
369cdf0e10cSrcweir nCacheIdx = MSHRT_MAX;
370cdf0e10cSrcweir nOfst = 0;
371cdf0e10cSrcweir nAllLines = 0;
372cdf0e10cSrcweir nThisLines = 0;
373cdf0e10cSrcweir mnFlyAnchorOfst = 0;
374cdf0e10cSrcweir mnFlyAnchorOfstNoWrap = 0;
375cdf0e10cSrcweir mnFtnLine = 0;
376cdf0e10cSrcweir // OD 2004-03-17 #i11860#
377cdf0e10cSrcweir mnHeightOfLastLine = 0;
378cdf0e10cSrcweir // --> OD 2008-01-31 #newlistlevelattrs#
379cdf0e10cSrcweir mnAdditionalFirstLineOffset = 0;
380cdf0e10cSrcweir // <--
381cdf0e10cSrcweir
382cdf0e10cSrcweir nType = FRMC_TXT;
383cdf0e10cSrcweir bLocked = bFormatted = bWidow = bUndersized = bJustWidow =
384cdf0e10cSrcweir bEmpty = bInFtnConnect = bFtn = bRepaint = bBlinkPor =
385cdf0e10cSrcweir bFieldFollow = bHasAnimation = bIsSwapped = sal_False;
386cdf0e10cSrcweir // OD 14.03.2003 #i11760#
387cdf0e10cSrcweir mbFollowFormatAllowed = sal_True;
388cdf0e10cSrcweir }
389cdf0e10cSrcweir
390cdf0e10cSrcweir /*************************************************************************
391cdf0e10cSrcweir * SwTxtFrm::SwTxtFrm()
392cdf0e10cSrcweir *************************************************************************/
SwTxtFrm(SwTxtNode * const pNode,SwFrm * pSib)393cdf0e10cSrcweir SwTxtFrm::SwTxtFrm(SwTxtNode * const pNode, SwFrm* pSib )
394cdf0e10cSrcweir : SwCntntFrm( pNode, pSib )
395cdf0e10cSrcweir {
396cdf0e10cSrcweir InitCtor();
397cdf0e10cSrcweir }
398cdf0e10cSrcweir
399cdf0e10cSrcweir /*************************************************************************
400cdf0e10cSrcweir * SwTxtFrm::~SwTxtFrm()
401cdf0e10cSrcweir *************************************************************************/
~SwTxtFrm()402cdf0e10cSrcweir SwTxtFrm::~SwTxtFrm()
403cdf0e10cSrcweir {
404cdf0e10cSrcweir // Remove associated SwParaPortion from pTxtCache
405cdf0e10cSrcweir ClearPara();
406cdf0e10cSrcweir }
407cdf0e10cSrcweir
GetTxt() const408cdf0e10cSrcweir const XubString& SwTxtFrm::GetTxt() const
409cdf0e10cSrcweir {
410cdf0e10cSrcweir return GetTxtNode()->GetTxt();
411cdf0e10cSrcweir }
412cdf0e10cSrcweir
ResetPreps()413cdf0e10cSrcweir void SwTxtFrm::ResetPreps()
414cdf0e10cSrcweir {
415cdf0e10cSrcweir if ( GetCacheIdx() != MSHRT_MAX )
416cdf0e10cSrcweir {
417cdf0e10cSrcweir SwParaPortion *pPara;
418cdf0e10cSrcweir if( 0 != (pPara = GetPara()) )
419cdf0e10cSrcweir pPara->ResetPreps();
420cdf0e10cSrcweir }
421cdf0e10cSrcweir }
422cdf0e10cSrcweir
423cdf0e10cSrcweir /*************************************************************************
424cdf0e10cSrcweir * SwTxtFrm::IsHiddenNow()
425cdf0e10cSrcweir *************************************************************************/
IsHiddenNow() const426cdf0e10cSrcweir sal_Bool SwTxtFrm::IsHiddenNow() const
427cdf0e10cSrcweir {
428cdf0e10cSrcweir SwFrmSwapper aSwapper( this, sal_True );
429cdf0e10cSrcweir
430cdf0e10cSrcweir if( !Frm().Width() && IsValid() && GetUpper()->IsValid() )
431cdf0e10cSrcweir //bei Stackueberlauf (StackHack) invalid!
432cdf0e10cSrcweir {
433cdf0e10cSrcweir // ASSERT( false, "SwTxtFrm::IsHiddenNow: thin frame" );
434cdf0e10cSrcweir return sal_True;
435cdf0e10cSrcweir }
436cdf0e10cSrcweir
437cdf0e10cSrcweir const bool bHiddenCharsHidePara = GetTxtNode()->HasHiddenCharAttribute( true );
438cdf0e10cSrcweir const bool bHiddenParaField = GetTxtNode()->HasHiddenParaField();
439cdf0e10cSrcweir const ViewShell* pVsh = getRootFrm()->GetCurrShell();
440cdf0e10cSrcweir
441cdf0e10cSrcweir if ( pVsh && ( bHiddenCharsHidePara || bHiddenParaField ) )
442cdf0e10cSrcweir {
443cdf0e10cSrcweir if (
444cdf0e10cSrcweir ( bHiddenParaField &&
445cdf0e10cSrcweir ( !pVsh->GetViewOptions()->IsShowHiddenPara() &&
446cdf0e10cSrcweir !pVsh->GetViewOptions()->IsFldName() ) ) ||
447cdf0e10cSrcweir ( bHiddenCharsHidePara &&
448cdf0e10cSrcweir !pVsh->GetViewOptions()->IsShowHiddenChar() ) )
449cdf0e10cSrcweir {
450cdf0e10cSrcweir return sal_True;
451cdf0e10cSrcweir }
452cdf0e10cSrcweir }
453cdf0e10cSrcweir
454cdf0e10cSrcweir return sal_False;
455cdf0e10cSrcweir }
456cdf0e10cSrcweir
457cdf0e10cSrcweir
458cdf0e10cSrcweir /*************************************************************************
459cdf0e10cSrcweir * SwTxtFrm::HideHidden()
460cdf0e10cSrcweir *************************************************************************/
461cdf0e10cSrcweir // Entfernt die Anhaengsel des Textfrms wenn dieser hidden ist
462cdf0e10cSrcweir
HideHidden()463cdf0e10cSrcweir void SwTxtFrm::HideHidden()
464cdf0e10cSrcweir {
465cdf0e10cSrcweir ASSERT( !GetFollow() && IsHiddenNow(),
466cdf0e10cSrcweir "HideHidden on visible frame of hidden frame has follow" );
467cdf0e10cSrcweir
468cdf0e10cSrcweir const xub_StrLen nEnd = STRING_LEN;
469cdf0e10cSrcweir HideFootnotes( GetOfst(), nEnd );
470cdf0e10cSrcweir // OD 2004-01-15 #110582#
471cdf0e10cSrcweir HideAndShowObjects();
472cdf0e10cSrcweir
473cdf0e10cSrcweir //Die Formatinfos sind jetzt obsolete
474cdf0e10cSrcweir ClearPara();
475cdf0e10cSrcweir }
476cdf0e10cSrcweir
477cdf0e10cSrcweir /*************************************************************************
478cdf0e10cSrcweir * SwTxtFrm::HideFootnotes()
479cdf0e10cSrcweir *************************************************************************/
HideFootnotes(xub_StrLen nStart,xub_StrLen nEnd)480cdf0e10cSrcweir void SwTxtFrm::HideFootnotes( xub_StrLen nStart, xub_StrLen nEnd )
481cdf0e10cSrcweir {
482cdf0e10cSrcweir const SwpHints *pHints = GetTxtNode()->GetpSwpHints();
483cdf0e10cSrcweir if( pHints )
484cdf0e10cSrcweir {
485cdf0e10cSrcweir const sal_uInt16 nSize = pHints->Count();
486cdf0e10cSrcweir SwPageFrm *pPage = 0;
487cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < nSize; ++i )
488cdf0e10cSrcweir {
489cdf0e10cSrcweir const SwTxtAttr *pHt = (*pHints)[i];
490cdf0e10cSrcweir if ( pHt->Which() == RES_TXTATR_FTN )
491cdf0e10cSrcweir {
492cdf0e10cSrcweir const xub_StrLen nIdx = *pHt->GetStart();
493cdf0e10cSrcweir if ( nEnd < nIdx )
494cdf0e10cSrcweir break;
495cdf0e10cSrcweir if( nStart <= nIdx )
496cdf0e10cSrcweir {
497cdf0e10cSrcweir if( !pPage )
498cdf0e10cSrcweir pPage = FindPageFrm();
499cdf0e10cSrcweir pPage->RemoveFtn( this, (SwTxtFtn*)pHt );
500cdf0e10cSrcweir }
501cdf0e10cSrcweir }
502cdf0e10cSrcweir }
503cdf0e10cSrcweir }
504cdf0e10cSrcweir }
505cdf0e10cSrcweir
506cdf0e10cSrcweir // --> OD 2005-03-30 #120729# - hotfix: WW8 documents contain at its end hidden,
507cdf0e10cSrcweir // as-character anchored graphics, which are used for a graphic bullet list.
508cdf0e10cSrcweir // As long as these graphic bullet list aren't imported, do not hide a
509cdf0e10cSrcweir // at-character anchored object, if
510cdf0e10cSrcweir // (a) the document is an imported WW8 document -
511cdf0e10cSrcweir // checked by checking certain compatibility options -,
512cdf0e10cSrcweir // (b) the paragraph is the last content in the document and
513cdf0e10cSrcweir // (c) the anchor character is an as-character anchored graphic.
lcl_HideObj(const SwTxtFrm & _rFrm,const RndStdIds _eAnchorType,const xub_StrLen _nObjAnchorPos,SwAnchoredObject * _pAnchoredObj)514cdf0e10cSrcweir bool lcl_HideObj( const SwTxtFrm& _rFrm,
515cdf0e10cSrcweir const RndStdIds _eAnchorType,
516cdf0e10cSrcweir const xub_StrLen _nObjAnchorPos,
517cdf0e10cSrcweir SwAnchoredObject* _pAnchoredObj )
518cdf0e10cSrcweir {
519cdf0e10cSrcweir bool bRet( true );
520cdf0e10cSrcweir
521cdf0e10cSrcweir if (_eAnchorType == FLY_AT_CHAR)
522cdf0e10cSrcweir {
523cdf0e10cSrcweir const IDocumentSettingAccess* pIDSA = _rFrm.GetTxtNode()->getIDocumentSettingAccess();
524cdf0e10cSrcweir if ( !pIDSA->get(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING) &&
525cdf0e10cSrcweir !pIDSA->get(IDocumentSettingAccess::OLD_LINE_SPACING) &&
526cdf0e10cSrcweir !pIDSA->get(IDocumentSettingAccess::USE_FORMER_OBJECT_POS) &&
527cdf0e10cSrcweir pIDSA->get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION) &&
528cdf0e10cSrcweir _rFrm.IsInDocBody() && !_rFrm.FindNextCnt() )
529cdf0e10cSrcweir {
530cdf0e10cSrcweir const xub_Unicode cAnchorChar =
531cdf0e10cSrcweir _rFrm.GetTxtNode()->GetTxt().GetChar( _nObjAnchorPos );
532cdf0e10cSrcweir if ( cAnchorChar == CH_TXTATR_BREAKWORD )
533cdf0e10cSrcweir {
534cdf0e10cSrcweir const SwTxtAttr* const pHint(
535cdf0e10cSrcweir _rFrm.GetTxtNode()->GetTxtAttrForCharAt(_nObjAnchorPos,
536cdf0e10cSrcweir RES_TXTATR_FLYCNT) );
537cdf0e10cSrcweir if ( pHint )
538cdf0e10cSrcweir {
539cdf0e10cSrcweir const SwFrmFmt* pFrmFmt =
540cdf0e10cSrcweir static_cast<const SwTxtFlyCnt*>(pHint)->GetFlyCnt().GetFrmFmt();
541cdf0e10cSrcweir if ( pFrmFmt->Which() == RES_FLYFRMFMT )
542cdf0e10cSrcweir {
543cdf0e10cSrcweir SwNodeIndex nCntntIndex = *(pFrmFmt->GetCntnt().GetCntntIdx());
544cdf0e10cSrcweir nCntntIndex++;
545cdf0e10cSrcweir if ( nCntntIndex.GetNode().IsNoTxtNode() )
546cdf0e10cSrcweir {
547cdf0e10cSrcweir bRet = false;
548cdf0e10cSrcweir // set needed data structure values for object positioning
549cdf0e10cSrcweir SWRECTFN( (&_rFrm) );
550cdf0e10cSrcweir SwRect aLastCharRect( _rFrm.Frm() );
551cdf0e10cSrcweir (aLastCharRect.*fnRect->fnSetWidth)( 1 );
552cdf0e10cSrcweir _pAnchoredObj->maLastCharRect = aLastCharRect;
553cdf0e10cSrcweir _pAnchoredObj->mnLastTopOfLine = (aLastCharRect.*fnRect->fnGetTop)();
554cdf0e10cSrcweir }
555cdf0e10cSrcweir }
556cdf0e10cSrcweir }
557cdf0e10cSrcweir }
558cdf0e10cSrcweir }
559cdf0e10cSrcweir }
560cdf0e10cSrcweir
561cdf0e10cSrcweir return bRet;
562cdf0e10cSrcweir }
563cdf0e10cSrcweir // <--
564cdf0e10cSrcweir /*************************************************************************
565cdf0e10cSrcweir * SwTxtFrm::HideAndShowObjects()
566cdf0e10cSrcweir *************************************************************************/
567cdf0e10cSrcweir /** method to hide/show objects
568cdf0e10cSrcweir
569cdf0e10cSrcweir OD 2004-01-15 #110582#
570cdf0e10cSrcweir method hides respectively shows objects, which are anchored at paragraph,
571cdf0e10cSrcweir at/as a character of the paragraph, corresponding to the paragraph and
572cdf0e10cSrcweir paragraph portion visibility.
573cdf0e10cSrcweir
574cdf0e10cSrcweir - is called from HideHidden() - should hide objects in hidden paragraphs and
575cdf0e10cSrcweir - from _Format() - should hide/show objects in partly visible paragraphs
576cdf0e10cSrcweir
577cdf0e10cSrcweir @author OD
578cdf0e10cSrcweir */
HideAndShowObjects()579cdf0e10cSrcweir void SwTxtFrm::HideAndShowObjects()
580cdf0e10cSrcweir {
581cdf0e10cSrcweir if ( GetDrawObjs() )
582cdf0e10cSrcweir {
583cdf0e10cSrcweir if ( IsHiddenNow() )
584cdf0e10cSrcweir {
585cdf0e10cSrcweir // complete paragraph is hidden. Thus, hide all objects
586cdf0e10cSrcweir for ( sal_uInt32 i = 0; i < GetDrawObjs()->Count(); ++i )
587cdf0e10cSrcweir {
588cdf0e10cSrcweir SdrObject* pObj = (*GetDrawObjs())[i]->DrawObj();
589cdf0e10cSrcweir SwContact* pContact = static_cast<SwContact*>(pObj->GetUserCall());
590cdf0e10cSrcweir // --> OD 2005-03-30 #120729# - hotfix: do not hide object
591cdf0e10cSrcweir // under certain conditions
592cdf0e10cSrcweir const RndStdIds eAnchorType( pContact->GetAnchorId() );
593cdf0e10cSrcweir const xub_StrLen nObjAnchorPos = pContact->GetCntntAnchorIndex().GetIndex();
594cdf0e10cSrcweir if ((eAnchorType != FLY_AT_CHAR) ||
595cdf0e10cSrcweir lcl_HideObj( *this, eAnchorType, nObjAnchorPos,
596cdf0e10cSrcweir (*GetDrawObjs())[i] ))
597cdf0e10cSrcweir {
598cdf0e10cSrcweir pContact->MoveObjToInvisibleLayer( pObj );
599cdf0e10cSrcweir }
600cdf0e10cSrcweir // <--
601cdf0e10cSrcweir }
602cdf0e10cSrcweir }
603cdf0e10cSrcweir else
604cdf0e10cSrcweir {
605cdf0e10cSrcweir // paragraph is visible, but can contain hidden text portion.
606cdf0e10cSrcweir // first we check if objects are allowed to be hidden:
607cdf0e10cSrcweir const SwTxtNode& rNode = *GetTxtNode();
608cdf0e10cSrcweir const ViewShell* pVsh = getRootFrm()->GetCurrShell();
609cdf0e10cSrcweir const bool bShouldBeHidden = !pVsh || !pVsh->GetWin() ||
610cdf0e10cSrcweir !pVsh->GetViewOptions()->IsShowHiddenChar();
611cdf0e10cSrcweir
612cdf0e10cSrcweir // Thus, show all objects, which are anchored at paragraph and
613cdf0e10cSrcweir // hide/show objects, which are anchored at/as character, according
614cdf0e10cSrcweir // to the visibility of the anchor character.
615cdf0e10cSrcweir for ( sal_uInt32 i = 0; i < GetDrawObjs()->Count(); ++i )
616cdf0e10cSrcweir {
617cdf0e10cSrcweir SdrObject* pObj = (*GetDrawObjs())[i]->DrawObj();
618cdf0e10cSrcweir SwContact* pContact = static_cast<SwContact*>(pObj->GetUserCall());
619cdf0e10cSrcweir // --> OD 2005-03-30 #120729# - determine anchor type only once
620cdf0e10cSrcweir const RndStdIds eAnchorType( pContact->GetAnchorId() );
621cdf0e10cSrcweir // <--
622cdf0e10cSrcweir
623cdf0e10cSrcweir if (eAnchorType == FLY_AT_PARA)
624cdf0e10cSrcweir {
625cdf0e10cSrcweir pContact->MoveObjToVisibleLayer( pObj );
626cdf0e10cSrcweir }
627cdf0e10cSrcweir else if ((eAnchorType == FLY_AT_CHAR) ||
628cdf0e10cSrcweir (eAnchorType == FLY_AS_CHAR))
629cdf0e10cSrcweir {
630cdf0e10cSrcweir xub_StrLen nHiddenStart;
631cdf0e10cSrcweir xub_StrLen nHiddenEnd;
632cdf0e10cSrcweir xub_StrLen nObjAnchorPos = pContact->GetCntntAnchorIndex().GetIndex();
633cdf0e10cSrcweir SwScriptInfo::GetBoundsOfHiddenRange( rNode, nObjAnchorPos, nHiddenStart, nHiddenEnd, 0 );
634cdf0e10cSrcweir // --> OD 2005-03-30 #120729# - hotfix: do not hide object
635cdf0e10cSrcweir // under certain conditions
636cdf0e10cSrcweir if ( nHiddenStart != STRING_LEN && bShouldBeHidden &&
637cdf0e10cSrcweir lcl_HideObj( *this, eAnchorType, nObjAnchorPos, (*GetDrawObjs())[i] ) )
638cdf0e10cSrcweir // <--
639cdf0e10cSrcweir pContact->MoveObjToInvisibleLayer( pObj );
640cdf0e10cSrcweir else
641cdf0e10cSrcweir pContact->MoveObjToVisibleLayer( pObj );
642cdf0e10cSrcweir }
643cdf0e10cSrcweir else
644cdf0e10cSrcweir {
645cdf0e10cSrcweir ASSERT( false,
646cdf0e10cSrcweir "<SwTxtFrm::HideAndShowObjects()> - object not anchored at/inside paragraph!?" );
647cdf0e10cSrcweir }
648cdf0e10cSrcweir }
649cdf0e10cSrcweir }
650cdf0e10cSrcweir }
651cdf0e10cSrcweir
652cdf0e10cSrcweir if ( IsFollow() )
653cdf0e10cSrcweir {
654cdf0e10cSrcweir FindMaster()->HideAndShowObjects();
655cdf0e10cSrcweir }
656cdf0e10cSrcweir }
657cdf0e10cSrcweir
658cdf0e10cSrcweir /*************************************************************************
659cdf0e10cSrcweir * SwTxtFrm::FindBrk()
660cdf0e10cSrcweir *
661cdf0e10cSrcweir * Liefert die erste Trennmoeglichkeit in der aktuellen Zeile zurueck.
662cdf0e10cSrcweir * Die Methode wird in SwTxtFrm::Format() benutzt, um festzustellen, ob
663cdf0e10cSrcweir * die Vorgaengerzeile mitformatiert werden muss.
664cdf0e10cSrcweir * nFound ist <= nEndLine.
665cdf0e10cSrcweir *************************************************************************/
666cdf0e10cSrcweir
FindBrk(const XubString & rTxt,const xub_StrLen nStart,const xub_StrLen nEnd) const667cdf0e10cSrcweir xub_StrLen SwTxtFrm::FindBrk( const XubString &rTxt,
668cdf0e10cSrcweir const xub_StrLen nStart,
669cdf0e10cSrcweir const xub_StrLen nEnd ) const
670cdf0e10cSrcweir {
671cdf0e10cSrcweir // --> OD 2009-12-28 #i104291# - applying patch to avoid overflow.
672cdf0e10cSrcweir unsigned long nFound = nStart;
673cdf0e10cSrcweir const xub_StrLen nEndLine = Min( nEnd, rTxt.Len() );
674cdf0e10cSrcweir
675cdf0e10cSrcweir // Wir ueberlesen erst alle Blanks am Anfang der Zeile (vgl. Bug 2235).
676cdf0e10cSrcweir while( nFound <= nEndLine &&
677cdf0e10cSrcweir ' ' == rTxt.GetChar( static_cast<xub_StrLen>(nFound) ) )
678cdf0e10cSrcweir {
679cdf0e10cSrcweir nFound++;
680cdf0e10cSrcweir }
681cdf0e10cSrcweir
682cdf0e10cSrcweir // Eine knifflige Sache mit den TxtAttr-Dummy-Zeichen (hier "$"):
683cdf0e10cSrcweir // "Dr.$Meyer" am Anfang der zweiten Zeile. Dahinter ein Blank eingegeben
684cdf0e10cSrcweir // und das Wort rutscht nicht in die erste Zeile, obwohl es ginge.
685cdf0e10cSrcweir // Aus diesem Grund nehmen wir das Dummy-Zeichen noch mit.
686cdf0e10cSrcweir while( nFound <= nEndLine &&
687cdf0e10cSrcweir ' ' != rTxt.GetChar( static_cast<xub_StrLen>(nFound) ) )
688cdf0e10cSrcweir {
689cdf0e10cSrcweir nFound++;
690cdf0e10cSrcweir }
691cdf0e10cSrcweir
692cdf0e10cSrcweir return nFound <= STRING_LEN
693cdf0e10cSrcweir ? static_cast<xub_StrLen>(nFound)
694cdf0e10cSrcweir : STRING_LEN;
695cdf0e10cSrcweir // <--
696cdf0e10cSrcweir }
697cdf0e10cSrcweir
698cdf0e10cSrcweir /*************************************************************************
699cdf0e10cSrcweir * SwTxtFrm::IsIdxInside()
700cdf0e10cSrcweir *************************************************************************/
701cdf0e10cSrcweir
IsIdxInside(const xub_StrLen nPos,const xub_StrLen nLen) const702cdf0e10cSrcweir sal_Bool SwTxtFrm::IsIdxInside( const xub_StrLen nPos, const xub_StrLen nLen ) const
703cdf0e10cSrcweir {
704cdf0e10cSrcweir if( GetOfst() > nPos + nLen ) // d.h., der Bereich liegt komplett vor uns.
705cdf0e10cSrcweir return sal_False;
706cdf0e10cSrcweir
707cdf0e10cSrcweir if( !GetFollow() ) // der Bereich liegt nicht komplett vor uns,
708cdf0e10cSrcweir return sal_True; // nach uns kommt niemand mehr.
709cdf0e10cSrcweir
710cdf0e10cSrcweir const xub_StrLen nMax = GetFollow()->GetOfst();
711cdf0e10cSrcweir
712cdf0e10cSrcweir // der Bereich liegt nicht komplett hinter uns bzw.
713cdf0e10cSrcweir // unser Text ist geloescht worden.
714cdf0e10cSrcweir if( nMax > nPos || nMax > GetTxt().Len() )
715cdf0e10cSrcweir return sal_True;
716cdf0e10cSrcweir
717cdf0e10cSrcweir // changes made in the first line of a follow can modify the master
718cdf0e10cSrcweir const SwParaPortion* pPara = GetFollow()->GetPara();
719cdf0e10cSrcweir return pPara && ( nPos <= nMax + pPara->GetLen() );
720cdf0e10cSrcweir }
721cdf0e10cSrcweir
722cdf0e10cSrcweir /*************************************************************************
723cdf0e10cSrcweir * SwTxtFrm::InvalidateRange()
724cdf0e10cSrcweir *************************************************************************/
InvalidateRange(const SwCharRange & aRange,const long nD)725cdf0e10cSrcweir inline void SwTxtFrm::InvalidateRange(const SwCharRange &aRange, const long nD)
726cdf0e10cSrcweir {
727cdf0e10cSrcweir if ( IsIdxInside( aRange.Start(), aRange.Len() ) )
728cdf0e10cSrcweir _InvalidateRange( aRange, nD );
729cdf0e10cSrcweir }
730cdf0e10cSrcweir
731cdf0e10cSrcweir /*************************************************************************
732cdf0e10cSrcweir * SwTxtFrm::_InvalidateRange()
733cdf0e10cSrcweir *************************************************************************/
734cdf0e10cSrcweir
_InvalidateRange(const SwCharRange & aRange,const long nD)735cdf0e10cSrcweir void SwTxtFrm::_InvalidateRange( const SwCharRange &aRange, const long nD)
736cdf0e10cSrcweir {
737cdf0e10cSrcweir if ( !HasPara() )
738cdf0e10cSrcweir { InvalidateSize();
739cdf0e10cSrcweir return;
740cdf0e10cSrcweir }
741cdf0e10cSrcweir
742cdf0e10cSrcweir SetWidow( sal_False );
743cdf0e10cSrcweir SwParaPortion *pPara = GetPara();
744cdf0e10cSrcweir
745cdf0e10cSrcweir sal_Bool bInv = sal_False;
746cdf0e10cSrcweir if( 0 != nD )
747cdf0e10cSrcweir {
748cdf0e10cSrcweir //Auf nDelta werden die Differenzen zwischen alter und
749cdf0e10cSrcweir //neuer Zeilenlaenge aufaddiert, deshalb ist es negativ,
750cdf0e10cSrcweir //wenn Zeichen eingefuegt wurden, positiv, wenn Zeichen
751cdf0e10cSrcweir //geloescht wurden.
752cdf0e10cSrcweir *(pPara->GetDelta()) += nD;
753cdf0e10cSrcweir bInv = sal_True;
754cdf0e10cSrcweir }
755cdf0e10cSrcweir SwCharRange &rReformat = *(pPara->GetReformat());
756cdf0e10cSrcweir if(aRange != rReformat) {
757cdf0e10cSrcweir if( STRING_LEN == rReformat.Len() )
758cdf0e10cSrcweir rReformat = aRange;
759cdf0e10cSrcweir else
760cdf0e10cSrcweir rReformat += aRange;
761cdf0e10cSrcweir bInv = sal_True;
762cdf0e10cSrcweir }
763cdf0e10cSrcweir if(bInv)
764cdf0e10cSrcweir {
765cdf0e10cSrcweir // 90365: nD is passed to a follow two times
766cdf0e10cSrcweir // if( GetFollow() )
767cdf0e10cSrcweir // ((SwTxtFrm*)GetFollow())->InvalidateRange( aRange, nD );
768cdf0e10cSrcweir InvalidateSize();
769cdf0e10cSrcweir }
770cdf0e10cSrcweir }
771cdf0e10cSrcweir
772cdf0e10cSrcweir /*************************************************************************
773cdf0e10cSrcweir * SwTxtFrm::CalcLineSpace()
774cdf0e10cSrcweir *************************************************************************/
775cdf0e10cSrcweir
CalcLineSpace()776cdf0e10cSrcweir void SwTxtFrm::CalcLineSpace()
777cdf0e10cSrcweir {
778cdf0e10cSrcweir ASSERT( ! IsVertical() || ! IsSwapped(),
779cdf0e10cSrcweir "SwTxtFrm::CalcLineSpace with swapped frame!" )
780cdf0e10cSrcweir
781cdf0e10cSrcweir if( IsLocked() || !HasPara() )
782cdf0e10cSrcweir return;
783cdf0e10cSrcweir
784cdf0e10cSrcweir SwParaPortion *pPara;
785cdf0e10cSrcweir if( GetDrawObjs() ||
786cdf0e10cSrcweir GetTxtNode()->GetSwAttrSet().GetLRSpace().IsAutoFirst() ||
787cdf0e10cSrcweir ( pPara = GetPara() )->IsFixLineHeight() )
788cdf0e10cSrcweir {
789cdf0e10cSrcweir Init();
790cdf0e10cSrcweir return;
791cdf0e10cSrcweir }
792cdf0e10cSrcweir
793cdf0e10cSrcweir Size aNewSize( Prt().SSize() );
794cdf0e10cSrcweir
795cdf0e10cSrcweir SwTxtFormatInfo aInf( this );
796cdf0e10cSrcweir SwTxtFormatter aLine( this, &aInf );
797cdf0e10cSrcweir if( aLine.GetDropLines() )
798cdf0e10cSrcweir {
799cdf0e10cSrcweir Init();
800cdf0e10cSrcweir return;
801cdf0e10cSrcweir }
802cdf0e10cSrcweir
803cdf0e10cSrcweir aLine.Top();
804cdf0e10cSrcweir aLine.RecalcRealHeight();
805cdf0e10cSrcweir
806cdf0e10cSrcweir aNewSize.Height() = (aLine.Y() - Frm().Top()) + aLine.GetLineHeight();
807cdf0e10cSrcweir
808cdf0e10cSrcweir SwTwips nDelta = aNewSize.Height() - Prt().Height();
809cdf0e10cSrcweir // 4291: Unterlauf bei Flys
810cdf0e10cSrcweir if( aInf.GetTxtFly()->IsOn() )
811cdf0e10cSrcweir {
812cdf0e10cSrcweir SwRect aTmpFrm( Frm() );
813cdf0e10cSrcweir if( nDelta < 0 )
814cdf0e10cSrcweir aTmpFrm.Height( Prt().Height() );
815cdf0e10cSrcweir else
816cdf0e10cSrcweir aTmpFrm.Height( aNewSize.Height() );
817cdf0e10cSrcweir if( aInf.GetTxtFly()->Relax( aTmpFrm ) )
818cdf0e10cSrcweir {
819cdf0e10cSrcweir Init();
820cdf0e10cSrcweir return;
821cdf0e10cSrcweir }
822cdf0e10cSrcweir }
823cdf0e10cSrcweir
824cdf0e10cSrcweir if( nDelta )
825cdf0e10cSrcweir {
826cdf0e10cSrcweir SwTxtFrmBreak aBreak( this );
827cdf0e10cSrcweir if( GetFollow() || aBreak.IsBreakNow( aLine ) )
828cdf0e10cSrcweir {
829cdf0e10cSrcweir // Wenn es einen Follow() gibt, oder wenn wir an dieser
830cdf0e10cSrcweir // Stelle aufbrechen muessen, so wird neu formatiert.
831cdf0e10cSrcweir Init();
832cdf0e10cSrcweir }
833cdf0e10cSrcweir else
834cdf0e10cSrcweir {
835cdf0e10cSrcweir // Alles nimmt seinen gewohnten Gang ...
836cdf0e10cSrcweir pPara->SetPrepAdjust();
837cdf0e10cSrcweir pPara->SetPrep();
838cdf0e10cSrcweir }
839cdf0e10cSrcweir }
840cdf0e10cSrcweir }
841cdf0e10cSrcweir
842cdf0e10cSrcweir //
843cdf0e10cSrcweir // SET_WRONG( nPos, nCnt, bMove )
844cdf0e10cSrcweir //
845cdf0e10cSrcweir #define SET_WRONG( nPos, nCnt, bMove ) \
846cdf0e10cSrcweir { \
847cdf0e10cSrcweir lcl_SetWrong( *this, nPos, nCnt, bMove ); \
848cdf0e10cSrcweir }
849cdf0e10cSrcweir
lcl_SetWrong(SwTxtFrm & rFrm,xub_StrLen nPos,long nCnt,bool bMove)850cdf0e10cSrcweir void lcl_SetWrong( SwTxtFrm& rFrm, xub_StrLen nPos, long nCnt, bool bMove )
851cdf0e10cSrcweir {
852cdf0e10cSrcweir if ( !rFrm.IsFollow() )
853cdf0e10cSrcweir {
854cdf0e10cSrcweir SwTxtNode* pTxtNode = rFrm.GetTxtNode();
855cdf0e10cSrcweir IGrammarContact* pGrammarContact = getGrammarContact( *pTxtNode );
856cdf0e10cSrcweir SwGrammarMarkUp* pWrongGrammar = pGrammarContact ?
857cdf0e10cSrcweir pGrammarContact->getGrammarCheck( *pTxtNode, false ) :
858cdf0e10cSrcweir pTxtNode->GetGrammarCheck();
859cdf0e10cSrcweir bool bGrammarProxy = pWrongGrammar != pTxtNode->GetGrammarCheck();
860cdf0e10cSrcweir if( bMove )
861cdf0e10cSrcweir {
862cdf0e10cSrcweir if( pTxtNode->GetWrong() )
863cdf0e10cSrcweir pTxtNode->GetWrong()->Move( nPos, nCnt );
864cdf0e10cSrcweir if( pWrongGrammar )
865cdf0e10cSrcweir pWrongGrammar->MoveGrammar( nPos, nCnt );
866cdf0e10cSrcweir if( bGrammarProxy && pTxtNode->GetGrammarCheck() )
867cdf0e10cSrcweir pTxtNode->GetGrammarCheck()->MoveGrammar( nPos, nCnt );
868cdf0e10cSrcweir if( pTxtNode->GetSmartTags() )
869cdf0e10cSrcweir pTxtNode->GetSmartTags()->Move( nPos, nCnt );
870cdf0e10cSrcweir }
871cdf0e10cSrcweir else
872cdf0e10cSrcweir {
873cdf0e10cSrcweir xub_StrLen nLen = (xub_StrLen)nCnt;
874cdf0e10cSrcweir if( pTxtNode->GetWrong() )
875cdf0e10cSrcweir pTxtNode->GetWrong()->Invalidate( nPos, nLen );
876cdf0e10cSrcweir if( pWrongGrammar )
877cdf0e10cSrcweir pWrongGrammar->Invalidate( nPos, nLen );
878cdf0e10cSrcweir if( pTxtNode->GetSmartTags() )
879cdf0e10cSrcweir pTxtNode->GetSmartTags()->Invalidate( nPos, nLen );
880cdf0e10cSrcweir }
881cdf0e10cSrcweir if ( !pTxtNode->GetWrong() && !pTxtNode->IsWrongDirty() )
882cdf0e10cSrcweir {
883cdf0e10cSrcweir pTxtNode->SetWrong( new SwWrongList( WRONGLIST_SPELL ) );
884cdf0e10cSrcweir pTxtNode->GetWrong()->SetInvalid( nPos, nPos + (sal_uInt16)( nCnt > 0 ? nCnt : 1 ) );
885cdf0e10cSrcweir }
886cdf0e10cSrcweir if ( !pTxtNode->GetSmartTags() && !pTxtNode->IsSmartTagDirty() )
887cdf0e10cSrcweir {
888cdf0e10cSrcweir // SMARTTAGS
889cdf0e10cSrcweir pTxtNode->SetSmartTags( new SwWrongList( WRONGLIST_SMARTTAG ) );
890cdf0e10cSrcweir pTxtNode->GetSmartTags()->SetInvalid( nPos, nPos + (sal_uInt16)( nCnt > 0 ? nCnt : 1 ) );
891cdf0e10cSrcweir }
892cdf0e10cSrcweir pTxtNode->SetWrongDirty( true );
893cdf0e10cSrcweir pTxtNode->SetGrammarCheckDirty( true );
894cdf0e10cSrcweir pTxtNode->SetWordCountDirty( true );
895cdf0e10cSrcweir pTxtNode->SetAutoCompleteWordDirty( true );
896cdf0e10cSrcweir // SMARTTAGS
897cdf0e10cSrcweir pTxtNode->SetSmartTagDirty( true );
898cdf0e10cSrcweir }
899cdf0e10cSrcweir
900cdf0e10cSrcweir SwRootFrm *pRootFrm = rFrm.getRootFrm();
901cdf0e10cSrcweir if (pRootFrm)
902cdf0e10cSrcweir {
903cdf0e10cSrcweir pRootFrm->SetNeedGrammarCheck( sal_True );
904cdf0e10cSrcweir }
905cdf0e10cSrcweir
906cdf0e10cSrcweir SwPageFrm *pPage = rFrm.FindPageFrm();
907cdf0e10cSrcweir if( pPage )
908cdf0e10cSrcweir {
909cdf0e10cSrcweir pPage->InvalidateSpelling();
910cdf0e10cSrcweir pPage->InvalidateAutoCompleteWords();
911cdf0e10cSrcweir pPage->InvalidateWordCount();
912cdf0e10cSrcweir pPage->InvalidateSmartTags();
913cdf0e10cSrcweir }
914cdf0e10cSrcweir }
915cdf0e10cSrcweir
916cdf0e10cSrcweir //
917cdf0e10cSrcweir // SET_SCRIPT_INVAL( nPos )
918cdf0e10cSrcweir //
919cdf0e10cSrcweir
920cdf0e10cSrcweir #define SET_SCRIPT_INVAL( nPos )\
921cdf0e10cSrcweir lcl_SetScriptInval( *this, nPos );
922cdf0e10cSrcweir
lcl_SetScriptInval(SwTxtFrm & rFrm,xub_StrLen nPos)923cdf0e10cSrcweir void lcl_SetScriptInval( SwTxtFrm& rFrm, xub_StrLen nPos )
924cdf0e10cSrcweir {
925cdf0e10cSrcweir if( rFrm.GetPara() )
926cdf0e10cSrcweir rFrm.GetPara()->GetScriptInfo().SetInvalidity( nPos );
927cdf0e10cSrcweir }
928cdf0e10cSrcweir
lcl_ModifyOfst(SwTxtFrm * pFrm,xub_StrLen nPos,xub_StrLen nLen)929cdf0e10cSrcweir void lcl_ModifyOfst( SwTxtFrm* pFrm, xub_StrLen nPos, xub_StrLen nLen )
930cdf0e10cSrcweir {
931cdf0e10cSrcweir while( pFrm && pFrm->GetOfst() <= nPos )
932cdf0e10cSrcweir pFrm = pFrm->GetFollow();
933cdf0e10cSrcweir while( pFrm )
934cdf0e10cSrcweir {
935cdf0e10cSrcweir pFrm->ManipOfst( pFrm->GetOfst() + nLen );
936cdf0e10cSrcweir pFrm = pFrm->GetFollow();
937cdf0e10cSrcweir }
938cdf0e10cSrcweir }
939cdf0e10cSrcweir
940cdf0e10cSrcweir /*************************************************************************
941cdf0e10cSrcweir * SwTxtFrm::Modify()
942cdf0e10cSrcweir *************************************************************************/
943cdf0e10cSrcweir
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)944cdf0e10cSrcweir void SwTxtFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew )
945cdf0e10cSrcweir {
946cdf0e10cSrcweir const MSHORT nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0;
947cdf0e10cSrcweir
948cdf0e10cSrcweir //Wuensche die FrmAttribute betreffen werden von der Basisklasse
949cdf0e10cSrcweir //verarbeitet.
950cdf0e10cSrcweir if( IsInRange( aFrmFmtSetRange, nWhich ) || RES_FMT_CHG == nWhich )
951cdf0e10cSrcweir {
952cdf0e10cSrcweir SwCntntFrm::Modify( pOld, pNew );
953cdf0e10cSrcweir if( nWhich == RES_FMT_CHG && getRootFrm()->GetCurrShell() )
954cdf0e10cSrcweir {
955cdf0e10cSrcweir // Collection hat sich geaendert
956cdf0e10cSrcweir Prepare( PREP_CLEAR );
957cdf0e10cSrcweir _InvalidatePrt();
958cdf0e10cSrcweir SET_WRONG( 0, STRING_LEN, false );
959cdf0e10cSrcweir SetDerivedR2L( sal_False );
960cdf0e10cSrcweir CheckDirChange();
961cdf0e10cSrcweir // OD 09.12.2002 #105576# - Force complete paint due to existing
962cdf0e10cSrcweir // indents.
963cdf0e10cSrcweir SetCompletePaint();
964cdf0e10cSrcweir InvalidateLineNum();
965cdf0e10cSrcweir }
966cdf0e10cSrcweir return;
967cdf0e10cSrcweir }
968cdf0e10cSrcweir
969cdf0e10cSrcweir // Im gelockten Zustand werden keine Bestellungen angenommen.
970cdf0e10cSrcweir if( IsLocked() )
971cdf0e10cSrcweir return;
972cdf0e10cSrcweir
973cdf0e10cSrcweir // Dies spart Stack, man muss nur aufpassen,
974cdf0e10cSrcweir // dass sie Variablen gesetzt werden.
975cdf0e10cSrcweir xub_StrLen nPos, nLen;
976cdf0e10cSrcweir sal_Bool bSetFldsDirty = sal_False;
977cdf0e10cSrcweir sal_Bool bRecalcFtnFlag = sal_False;
978cdf0e10cSrcweir
979cdf0e10cSrcweir switch( nWhich )
980cdf0e10cSrcweir {
981cdf0e10cSrcweir case RES_LINENUMBER:
982cdf0e10cSrcweir {
983cdf0e10cSrcweir InvalidateLineNum();
984cdf0e10cSrcweir }
985cdf0e10cSrcweir break;
986cdf0e10cSrcweir case RES_INS_TXT:
987cdf0e10cSrcweir {
988cdf0e10cSrcweir nPos = ((SwInsTxt*)pNew)->nPos;
989cdf0e10cSrcweir nLen = ((SwInsTxt*)pNew)->nLen;
990cdf0e10cSrcweir if( IsIdxInside( nPos, nLen ) )
991cdf0e10cSrcweir {
992cdf0e10cSrcweir if( !nLen )
993cdf0e10cSrcweir {
994cdf0e10cSrcweir // 6969: Aktualisierung der NumPortions auch bei leeren Zeilen!
995cdf0e10cSrcweir if( nPos )
996cdf0e10cSrcweir InvalidateSize();
997cdf0e10cSrcweir else
998cdf0e10cSrcweir Prepare( PREP_CLEAR );
999cdf0e10cSrcweir }
1000cdf0e10cSrcweir else
1001cdf0e10cSrcweir _InvalidateRange( SwCharRange( nPos, nLen ), nLen );
1002cdf0e10cSrcweir }
1003cdf0e10cSrcweir SET_WRONG( nPos, nLen, true )
1004cdf0e10cSrcweir SET_SCRIPT_INVAL( nPos )
1005cdf0e10cSrcweir bSetFldsDirty = sal_True;
1006cdf0e10cSrcweir if( HasFollow() )
1007cdf0e10cSrcweir lcl_ModifyOfst( this, nPos, nLen );
1008cdf0e10cSrcweir }
1009cdf0e10cSrcweir break;
1010cdf0e10cSrcweir case RES_DEL_CHR:
1011cdf0e10cSrcweir {
1012cdf0e10cSrcweir nPos = ((SwDelChr*)pNew)->nPos;
1013cdf0e10cSrcweir InvalidateRange( SwCharRange( nPos, 1 ), -1 );
1014cdf0e10cSrcweir SET_WRONG( nPos, -1, true )
1015cdf0e10cSrcweir SET_SCRIPT_INVAL( nPos )
1016cdf0e10cSrcweir bSetFldsDirty = bRecalcFtnFlag = sal_True;
1017cdf0e10cSrcweir if( HasFollow() )
1018cdf0e10cSrcweir lcl_ModifyOfst( this, nPos, STRING_LEN );
1019cdf0e10cSrcweir }
1020cdf0e10cSrcweir break;
1021cdf0e10cSrcweir case RES_DEL_TXT:
1022cdf0e10cSrcweir {
1023cdf0e10cSrcweir nPos = ((SwDelTxt*)pNew)->nStart;
1024cdf0e10cSrcweir nLen = ((SwDelTxt*)pNew)->nLen;
1025cdf0e10cSrcweir long m = nLen;
1026cdf0e10cSrcweir m *= -1;
1027cdf0e10cSrcweir if( IsIdxInside( nPos, nLen ) )
1028cdf0e10cSrcweir {
1029cdf0e10cSrcweir if( !nLen )
1030cdf0e10cSrcweir InvalidateSize();
1031cdf0e10cSrcweir else
1032cdf0e10cSrcweir InvalidateRange( SwCharRange( nPos, 1 ), m );
1033cdf0e10cSrcweir }
1034cdf0e10cSrcweir SET_WRONG( nPos, m, true )
1035cdf0e10cSrcweir SET_SCRIPT_INVAL( nPos )
1036cdf0e10cSrcweir bSetFldsDirty = bRecalcFtnFlag = sal_True;
1037cdf0e10cSrcweir if( HasFollow() )
1038cdf0e10cSrcweir lcl_ModifyOfst( this, nPos, nLen );
1039cdf0e10cSrcweir }
1040cdf0e10cSrcweir break;
1041cdf0e10cSrcweir case RES_UPDATE_ATTR:
1042cdf0e10cSrcweir {
1043cdf0e10cSrcweir nPos = ((SwUpdateAttr*)pNew)->nStart;
1044cdf0e10cSrcweir nLen = ((SwUpdateAttr*)pNew)->nEnd - nPos;
1045cdf0e10cSrcweir if( IsIdxInside( nPos, nLen ) )
1046cdf0e10cSrcweir {
1047cdf0e10cSrcweir // Es muss in jedem Fall neu formatiert werden,
1048cdf0e10cSrcweir // auch wenn der invalidierte Bereich null ist.
1049cdf0e10cSrcweir // Beispiel: leere Zeile, 14Pt einstellen !
1050cdf0e10cSrcweir // if( !nLen ) nLen = 1;
1051cdf0e10cSrcweir
1052cdf0e10cSrcweir // 6680: FtnNummern muessen formatiert werden.
1053cdf0e10cSrcweir if( !nLen )
1054cdf0e10cSrcweir nLen = 1;
1055cdf0e10cSrcweir
1056cdf0e10cSrcweir _InvalidateRange( SwCharRange( nPos, nLen) );
1057cdf0e10cSrcweir MSHORT nTmp = ((SwUpdateAttr*)pNew)->nWhichAttr;
1058cdf0e10cSrcweir
1059cdf0e10cSrcweir if( ! nTmp || RES_TXTATR_CHARFMT == nTmp || RES_TXTATR_AUTOFMT == nTmp ||
1060cdf0e10cSrcweir RES_FMT_CHG == nTmp || RES_ATTRSET_CHG == nTmp )
1061cdf0e10cSrcweir {
1062cdf0e10cSrcweir SET_WRONG( nPos, nPos + nLen, false )
1063cdf0e10cSrcweir SET_SCRIPT_INVAL( nPos )
1064cdf0e10cSrcweir }
1065cdf0e10cSrcweir }
1066cdf0e10cSrcweir
1067cdf0e10cSrcweir // --> OD 2010-02-16 #i104008#
1068cdf0e10cSrcweir ViewShell* pViewSh = getRootFrm() ? getRootFrm()->GetCurrShell() : 0;
1069cdf0e10cSrcweir if ( pViewSh )
1070cdf0e10cSrcweir {
1071cdf0e10cSrcweir pViewSh->InvalidateAccessibleParaAttrs( *this );
1072cdf0e10cSrcweir }
1073cdf0e10cSrcweir // <--
1074cdf0e10cSrcweir }
1075cdf0e10cSrcweir break;
1076cdf0e10cSrcweir case RES_OBJECTDYING:
1077cdf0e10cSrcweir break;
1078cdf0e10cSrcweir
1079cdf0e10cSrcweir case RES_PARATR_LINESPACING:
1080cdf0e10cSrcweir {
1081cdf0e10cSrcweir CalcLineSpace();
1082cdf0e10cSrcweir InvalidateSize();
1083cdf0e10cSrcweir _InvalidatePrt();
1084cdf0e10cSrcweir if( IsInSct() && !GetPrev() )
1085cdf0e10cSrcweir {
1086cdf0e10cSrcweir SwSectionFrm *pSect = FindSctFrm();
1087cdf0e10cSrcweir if( pSect->ContainsAny() == this )
1088cdf0e10cSrcweir pSect->InvalidatePrt();
1089cdf0e10cSrcweir }
1090cdf0e10cSrcweir
1091cdf0e10cSrcweir // OD 09.01.2004 #i11859# - correction:
1092cdf0e10cSrcweir // (1) Also invalidate next frame on next page/column.
1093cdf0e10cSrcweir // (2) Skip empty sections and hidden paragraphs
1094cdf0e10cSrcweir // Thus, use method <InvalidateNextPrtArea()>
1095cdf0e10cSrcweir InvalidateNextPrtArea();
1096cdf0e10cSrcweir
1097cdf0e10cSrcweir SetCompletePaint();
1098cdf0e10cSrcweir }
1099cdf0e10cSrcweir break;
1100*dec99bbdSOliver-Rainer Wittmann
1101cdf0e10cSrcweir case RES_TXTATR_FIELD:
1102*dec99bbdSOliver-Rainer Wittmann case RES_TXTATR_ANNOTATION:
1103cdf0e10cSrcweir {
1104cdf0e10cSrcweir nPos = *((SwFmtFld*)pNew)->GetTxtFld()->GetStart();
1105cdf0e10cSrcweir if( IsIdxInside( nPos, 1 ) )
1106cdf0e10cSrcweir {
1107cdf0e10cSrcweir if( pNew == pOld )
1108cdf0e10cSrcweir {
1109cdf0e10cSrcweir // Nur repainten
1110cdf0e10cSrcweir // opt: invalidate aufs Window ?
1111cdf0e10cSrcweir InvalidatePage();
1112cdf0e10cSrcweir SetCompletePaint();
1113cdf0e10cSrcweir }
1114cdf0e10cSrcweir else
1115cdf0e10cSrcweir _InvalidateRange( SwCharRange( nPos, 1 ) );
1116cdf0e10cSrcweir }
1117cdf0e10cSrcweir bSetFldsDirty = sal_True;
1118cdf0e10cSrcweir // ST2
1119cdf0e10cSrcweir if ( SwSmartTagMgr::Get().IsSmartTagsEnabled() )
1120cdf0e10cSrcweir SET_WRONG( nPos, nPos + 1, false )
1121cdf0e10cSrcweir }
1122cdf0e10cSrcweir break;
1123*dec99bbdSOliver-Rainer Wittmann
1124cdf0e10cSrcweir case RES_TXTATR_FTN :
1125cdf0e10cSrcweir {
1126cdf0e10cSrcweir nPos = *((SwFmtFtn*)pNew)->GetTxtFtn()->GetStart();
1127cdf0e10cSrcweir if( IsInFtn() || IsIdxInside( nPos, 1 ) )
1128cdf0e10cSrcweir Prepare( PREP_FTN, ((SwFmtFtn*)pNew)->GetTxtFtn() );
1129cdf0e10cSrcweir break;
1130cdf0e10cSrcweir }
1131cdf0e10cSrcweir
1132cdf0e10cSrcweir case RES_ATTRSET_CHG:
1133cdf0e10cSrcweir {
1134cdf0e10cSrcweir InvalidateLineNum();
1135cdf0e10cSrcweir
1136cdf0e10cSrcweir SwAttrSet& rNewSet = *((SwAttrSetChg*)pNew)->GetChgSet();
1137*dec99bbdSOliver-Rainer Wittmann const SfxPoolItem* pItem = 0;
1138cdf0e10cSrcweir int nClear = 0;
1139cdf0e10cSrcweir MSHORT nCount = rNewSet.Count();
1140cdf0e10cSrcweir
1141*dec99bbdSOliver-Rainer Wittmann if( SFX_ITEM_SET == rNewSet.GetItemState( RES_TXTATR_FTN, sal_False, &pItem ))
1142cdf0e10cSrcweir {
1143cdf0e10cSrcweir nPos = *((SwFmtFtn*)pItem)->GetTxtFtn()->GetStart();
1144cdf0e10cSrcweir if( IsIdxInside( nPos, 1 ) )
1145cdf0e10cSrcweir Prepare( PREP_FTN, pNew );
1146cdf0e10cSrcweir nClear = 0x01;
1147cdf0e10cSrcweir --nCount;
1148cdf0e10cSrcweir }
1149cdf0e10cSrcweir
1150*dec99bbdSOliver-Rainer Wittmann if( SFX_ITEM_SET == rNewSet.GetItemState( RES_TXTATR_FIELD, sal_False, &pItem ))
1151cdf0e10cSrcweir {
1152cdf0e10cSrcweir nPos = *((SwFmtFld*)pItem)->GetTxtFld()->GetStart();
1153cdf0e10cSrcweir if( IsIdxInside( nPos, 1 ) )
1154cdf0e10cSrcweir {
1155*dec99bbdSOliver-Rainer Wittmann const SfxPoolItem& rOldItem =
1156*dec99bbdSOliver-Rainer Wittmann ((SwAttrSetChg*)pOld)->GetChgSet()->Get( RES_TXTATR_FIELD );
1157cdf0e10cSrcweir if( pItem == &rOldItem )
1158cdf0e10cSrcweir {
1159cdf0e10cSrcweir InvalidatePage();
1160cdf0e10cSrcweir SetCompletePaint();
1161cdf0e10cSrcweir }
1162cdf0e10cSrcweir else
1163cdf0e10cSrcweir _InvalidateRange( SwCharRange( nPos, 1 ) );
1164cdf0e10cSrcweir }
1165cdf0e10cSrcweir nClear |= 0x02;
1166cdf0e10cSrcweir --nCount;
1167cdf0e10cSrcweir }
1168cdf0e10cSrcweir sal_Bool bLineSpace = SFX_ITEM_SET == rNewSet.GetItemState(
1169cdf0e10cSrcweir RES_PARATR_LINESPACING, sal_False ),
1170cdf0e10cSrcweir bRegister = SFX_ITEM_SET == rNewSet.GetItemState(
1171cdf0e10cSrcweir RES_PARATR_REGISTER, sal_False );
1172cdf0e10cSrcweir if ( bLineSpace || bRegister )
1173cdf0e10cSrcweir {
1174cdf0e10cSrcweir Prepare( bRegister ? PREP_REGISTER : PREP_ADJUST_FRM );
1175cdf0e10cSrcweir CalcLineSpace();
1176cdf0e10cSrcweir InvalidateSize();
1177cdf0e10cSrcweir _InvalidatePrt();
1178cdf0e10cSrcweir
1179cdf0e10cSrcweir // OD 09.01.2004 #i11859# - correction:
1180cdf0e10cSrcweir // (1) Also invalidate next frame on next page/column.
1181cdf0e10cSrcweir // (2) Skip empty sections and hidden paragraphs
1182cdf0e10cSrcweir // Thus, use method <InvalidateNextPrtArea()>
1183cdf0e10cSrcweir InvalidateNextPrtArea();
1184cdf0e10cSrcweir
1185cdf0e10cSrcweir SetCompletePaint();
1186cdf0e10cSrcweir nClear |= 0x04;
1187cdf0e10cSrcweir if ( bLineSpace )
1188cdf0e10cSrcweir {
1189cdf0e10cSrcweir --nCount;
1190cdf0e10cSrcweir if( IsInSct() && !GetPrev() )
1191cdf0e10cSrcweir {
1192cdf0e10cSrcweir SwSectionFrm *pSect = FindSctFrm();
1193cdf0e10cSrcweir if( pSect->ContainsAny() == this )
1194cdf0e10cSrcweir pSect->InvalidatePrt();
1195cdf0e10cSrcweir }
1196cdf0e10cSrcweir }
1197cdf0e10cSrcweir if ( bRegister )
1198cdf0e10cSrcweir --nCount;
1199cdf0e10cSrcweir }
1200cdf0e10cSrcweir if ( SFX_ITEM_SET == rNewSet.GetItemState( RES_PARATR_SPLIT,
1201cdf0e10cSrcweir sal_False ))
1202cdf0e10cSrcweir {
1203cdf0e10cSrcweir if ( GetPrev() )
1204cdf0e10cSrcweir CheckKeep();
1205cdf0e10cSrcweir Prepare( PREP_CLEAR );
1206cdf0e10cSrcweir InvalidateSize();
1207cdf0e10cSrcweir nClear |= 0x08;
1208cdf0e10cSrcweir --nCount;
1209cdf0e10cSrcweir }
1210cdf0e10cSrcweir
1211cdf0e10cSrcweir if( SFX_ITEM_SET == rNewSet.GetItemState( RES_BACKGROUND, sal_False)
1212cdf0e10cSrcweir && !IsFollow() && GetDrawObjs() )
1213cdf0e10cSrcweir {
1214cdf0e10cSrcweir SwSortedObjs *pObjs = GetDrawObjs();
1215cdf0e10cSrcweir for ( int i = 0; GetDrawObjs() && i < int(pObjs->Count()); ++i )
1216cdf0e10cSrcweir {
1217cdf0e10cSrcweir SwAnchoredObject* pAnchoredObj = (*pObjs)[MSHORT(i)];
1218cdf0e10cSrcweir if ( pAnchoredObj->ISA(SwFlyFrm) )
1219cdf0e10cSrcweir {
1220cdf0e10cSrcweir SwFlyFrm *pFly = static_cast<SwFlyFrm*>(pAnchoredObj);
1221cdf0e10cSrcweir if( !pFly->IsFlyInCntFrm() )
1222cdf0e10cSrcweir {
1223cdf0e10cSrcweir const SvxBrushItem &rBack =
1224cdf0e10cSrcweir pFly->GetAttrSet()->GetBackground();
1225cdf0e10cSrcweir // OD 20.08.2002 #99657# #GetTransChg#
1226cdf0e10cSrcweir // following condition determines, if the fly frame
1227cdf0e10cSrcweir // "inherites" the background color of text frame.
1228cdf0e10cSrcweir // This is the case, if fly frame background
1229cdf0e10cSrcweir // color is "no fill"/"auto fill" and if the fly frame
1230cdf0e10cSrcweir // has no background graphic.
1231cdf0e10cSrcweir // Thus, check complete fly frame background
1232cdf0e10cSrcweir // color and *not* only its transparency value
1233cdf0e10cSrcweir if ( (rBack.GetColor() == COL_TRANSPARENT) &&
1234cdf0e10cSrcweir //if( rBack.GetColor().GetTransparency() &&
1235cdf0e10cSrcweir rBack.GetGraphicPos() == GPOS_NONE )
1236cdf0e10cSrcweir {
1237cdf0e10cSrcweir pFly->SetCompletePaint();
1238cdf0e10cSrcweir pFly->InvalidatePage();
1239cdf0e10cSrcweir }
1240cdf0e10cSrcweir }
1241cdf0e10cSrcweir }
1242cdf0e10cSrcweir }
1243cdf0e10cSrcweir }
1244cdf0e10cSrcweir
1245cdf0e10cSrcweir if ( SFX_ITEM_SET ==
1246cdf0e10cSrcweir rNewSet.GetItemState( RES_TXTATR_CHARFMT, sal_False ) )
1247cdf0e10cSrcweir {
1248cdf0e10cSrcweir SET_WRONG( 0, STRING_LEN, false )
1249cdf0e10cSrcweir SET_SCRIPT_INVAL( 0 )
1250cdf0e10cSrcweir }
1251cdf0e10cSrcweir else if ( SFX_ITEM_SET ==
1252cdf0e10cSrcweir rNewSet.GetItemState( RES_CHRATR_LANGUAGE, sal_False ) ||
1253cdf0e10cSrcweir SFX_ITEM_SET ==
1254cdf0e10cSrcweir rNewSet.GetItemState( RES_CHRATR_CJK_LANGUAGE, sal_False ) ||
1255cdf0e10cSrcweir SFX_ITEM_SET ==
1256cdf0e10cSrcweir rNewSet.GetItemState( RES_CHRATR_CTL_LANGUAGE, sal_False ) )
1257cdf0e10cSrcweir SET_WRONG( 0, STRING_LEN, false )
1258cdf0e10cSrcweir else if ( SFX_ITEM_SET ==
1259cdf0e10cSrcweir rNewSet.GetItemState( RES_CHRATR_FONT, sal_False ) ||
1260cdf0e10cSrcweir SFX_ITEM_SET ==
1261cdf0e10cSrcweir rNewSet.GetItemState( RES_CHRATR_CJK_FONT, sal_False ) ||
1262cdf0e10cSrcweir SFX_ITEM_SET ==
1263cdf0e10cSrcweir rNewSet.GetItemState( RES_CHRATR_CTL_FONT, sal_False ) )
1264cdf0e10cSrcweir SET_SCRIPT_INVAL( 0 )
1265cdf0e10cSrcweir else if ( SFX_ITEM_SET ==
1266cdf0e10cSrcweir rNewSet.GetItemState( RES_FRAMEDIR, sal_False ) )
1267cdf0e10cSrcweir {
1268cdf0e10cSrcweir SetDerivedR2L( sal_False );
1269cdf0e10cSrcweir CheckDirChange();
1270cdf0e10cSrcweir // OD 09.12.2002 #105576# - Force complete paint due to existing
1271cdf0e10cSrcweir // indents.
1272cdf0e10cSrcweir SetCompletePaint();
1273cdf0e10cSrcweir }
1274cdf0e10cSrcweir
1275cdf0e10cSrcweir
1276cdf0e10cSrcweir if( nCount )
1277cdf0e10cSrcweir {
1278cdf0e10cSrcweir if( getRootFrm()->GetCurrShell() )
1279cdf0e10cSrcweir {
1280cdf0e10cSrcweir Prepare( PREP_CLEAR );
1281cdf0e10cSrcweir _InvalidatePrt();
1282cdf0e10cSrcweir }
1283cdf0e10cSrcweir
1284cdf0e10cSrcweir if( nClear )
1285cdf0e10cSrcweir {
1286cdf0e10cSrcweir SwAttrSetChg aOldSet( *(SwAttrSetChg*)pOld );
1287cdf0e10cSrcweir SwAttrSetChg aNewSet( *(SwAttrSetChg*)pNew );
1288cdf0e10cSrcweir
1289cdf0e10cSrcweir if( 0x01 & nClear )
1290cdf0e10cSrcweir {
1291cdf0e10cSrcweir aOldSet.ClearItem( RES_TXTATR_FTN );
1292cdf0e10cSrcweir aNewSet.ClearItem( RES_TXTATR_FTN );
1293cdf0e10cSrcweir }
1294cdf0e10cSrcweir if( 0x02 & nClear )
1295cdf0e10cSrcweir {
1296cdf0e10cSrcweir aOldSet.ClearItem( RES_TXTATR_FIELD );
1297cdf0e10cSrcweir aNewSet.ClearItem( RES_TXTATR_FIELD );
1298cdf0e10cSrcweir }
1299cdf0e10cSrcweir if ( 0x04 & nClear )
1300cdf0e10cSrcweir {
1301cdf0e10cSrcweir if ( bLineSpace )
1302cdf0e10cSrcweir {
1303cdf0e10cSrcweir aOldSet.ClearItem( RES_PARATR_LINESPACING );
1304cdf0e10cSrcweir aNewSet.ClearItem( RES_PARATR_LINESPACING );
1305cdf0e10cSrcweir }
1306cdf0e10cSrcweir if ( bRegister )
1307cdf0e10cSrcweir {
1308cdf0e10cSrcweir aOldSet.ClearItem( RES_PARATR_REGISTER );
1309cdf0e10cSrcweir aNewSet.ClearItem( RES_PARATR_REGISTER );
1310cdf0e10cSrcweir }
1311cdf0e10cSrcweir }
1312cdf0e10cSrcweir if ( 0x08 & nClear )
1313cdf0e10cSrcweir {
1314cdf0e10cSrcweir aOldSet.ClearItem( RES_PARATR_SPLIT );
1315cdf0e10cSrcweir aNewSet.ClearItem( RES_PARATR_SPLIT );
1316cdf0e10cSrcweir }
1317cdf0e10cSrcweir SwCntntFrm::Modify( &aOldSet, &aNewSet );
1318cdf0e10cSrcweir }
1319cdf0e10cSrcweir else
1320cdf0e10cSrcweir SwCntntFrm::Modify( pOld, pNew );
1321cdf0e10cSrcweir }
1322cdf0e10cSrcweir
1323cdf0e10cSrcweir // --> OD 2009-01-06 #i88069#
1324cdf0e10cSrcweir ViewShell* pViewSh = getRootFrm() ? getRootFrm()->GetCurrShell() : 0;
1325cdf0e10cSrcweir if ( pViewSh )
1326cdf0e10cSrcweir {
1327cdf0e10cSrcweir pViewSh->InvalidateAccessibleParaAttrs( *this );
1328cdf0e10cSrcweir }
1329cdf0e10cSrcweir // <--
1330cdf0e10cSrcweir }
1331cdf0e10cSrcweir break;
1332cdf0e10cSrcweir
1333cdf0e10cSrcweir // 6870: SwDocPosUpdate auswerten.
1334cdf0e10cSrcweir case RES_DOCPOS_UPDATE:
1335cdf0e10cSrcweir {
1336cdf0e10cSrcweir if( pOld && pNew )
1337cdf0e10cSrcweir {
1338cdf0e10cSrcweir const SwDocPosUpdate *pDocPos = (const SwDocPosUpdate*)pOld;
1339cdf0e10cSrcweir if( pDocPos->nDocPos <= aFrm.Top() )
1340cdf0e10cSrcweir {
1341cdf0e10cSrcweir const SwFmtFld *pFld = (const SwFmtFld *)pNew;
1342cdf0e10cSrcweir InvalidateRange(
1343cdf0e10cSrcweir SwCharRange( *pFld->GetTxtFld()->GetStart(), 1 ) );
1344cdf0e10cSrcweir }
1345cdf0e10cSrcweir }
1346cdf0e10cSrcweir break;
1347cdf0e10cSrcweir }
1348cdf0e10cSrcweir case RES_PARATR_SPLIT:
1349cdf0e10cSrcweir if ( GetPrev() )
1350cdf0e10cSrcweir CheckKeep();
1351cdf0e10cSrcweir Prepare( PREP_CLEAR );
1352cdf0e10cSrcweir bSetFldsDirty = sal_True;
1353cdf0e10cSrcweir break;
1354cdf0e10cSrcweir case RES_FRAMEDIR :
1355cdf0e10cSrcweir SetDerivedR2L( sal_False );
1356cdf0e10cSrcweir CheckDirChange();
1357cdf0e10cSrcweir break;
1358cdf0e10cSrcweir default:
1359cdf0e10cSrcweir {
1360cdf0e10cSrcweir Prepare( PREP_CLEAR );
1361cdf0e10cSrcweir _InvalidatePrt();
1362cdf0e10cSrcweir if ( !nWhich )
1363cdf0e10cSrcweir {
1364cdf0e10cSrcweir //Wird z.B. bei HiddenPara mit 0 gerufen.
1365cdf0e10cSrcweir SwFrm *pNxt;
1366cdf0e10cSrcweir if ( 0 != (pNxt = FindNext()) )
1367cdf0e10cSrcweir pNxt->InvalidatePrt();
1368cdf0e10cSrcweir }
1369cdf0e10cSrcweir }
1370cdf0e10cSrcweir } // switch
1371cdf0e10cSrcweir
1372cdf0e10cSrcweir if( bSetFldsDirty )
1373cdf0e10cSrcweir GetNode()->getIDocumentFieldsAccess()->SetFieldsDirty( sal_True, GetNode(), 1 );
1374cdf0e10cSrcweir
1375cdf0e10cSrcweir if ( bRecalcFtnFlag )
1376cdf0e10cSrcweir CalcFtnFlag();
1377cdf0e10cSrcweir }
1378cdf0e10cSrcweir
GetInfo(SfxPoolItem & rHnt) const1379cdf0e10cSrcweir sal_Bool SwTxtFrm::GetInfo( SfxPoolItem &rHnt ) const
1380cdf0e10cSrcweir {
1381cdf0e10cSrcweir if ( RES_VIRTPAGENUM_INFO == rHnt.Which() && IsInDocBody() && ! IsFollow() )
1382cdf0e10cSrcweir {
1383cdf0e10cSrcweir SwVirtPageNumInfo &rInfo = (SwVirtPageNumInfo&)rHnt;
1384cdf0e10cSrcweir const SwPageFrm *pPage = FindPageFrm();
1385cdf0e10cSrcweir if ( pPage )
1386cdf0e10cSrcweir {
1387cdf0e10cSrcweir if ( pPage == rInfo.GetOrigPage() && !GetPrev() )
1388cdf0e10cSrcweir {
1389cdf0e10cSrcweir //Das sollte er sein (kann allenfalls temporaer anders sein,
1390cdf0e10cSrcweir // sollte uns das beunruhigen?)
1391cdf0e10cSrcweir rInfo.SetInfo( pPage, this );
1392cdf0e10cSrcweir return sal_False;
1393cdf0e10cSrcweir }
1394cdf0e10cSrcweir if ( pPage->GetPhyPageNum() < rInfo.GetOrigPage()->GetPhyPageNum() &&
1395cdf0e10cSrcweir (!rInfo.GetPage() || pPage->GetPhyPageNum() > rInfo.GetPage()->GetPhyPageNum()))
1396cdf0e10cSrcweir {
1397cdf0e10cSrcweir //Das koennte er sein.
1398cdf0e10cSrcweir rInfo.SetInfo( pPage, this );
1399cdf0e10cSrcweir }
1400cdf0e10cSrcweir }
1401cdf0e10cSrcweir }
1402cdf0e10cSrcweir return sal_True;
1403cdf0e10cSrcweir }
1404cdf0e10cSrcweir
1405cdf0e10cSrcweir /*************************************************************************
1406cdf0e10cSrcweir * SwTxtFrm::PrepWidows()
1407cdf0e10cSrcweir *************************************************************************/
1408cdf0e10cSrcweir
PrepWidows(const MSHORT nNeed,sal_Bool bNotify)1409cdf0e10cSrcweir void SwTxtFrm::PrepWidows( const MSHORT nNeed, sal_Bool bNotify )
1410cdf0e10cSrcweir {
1411cdf0e10cSrcweir ASSERT(GetFollow() && nNeed, "+SwTxtFrm::Prepare: lost all friends");
1412cdf0e10cSrcweir
1413cdf0e10cSrcweir SwParaPortion *pPara = GetPara();
1414cdf0e10cSrcweir if ( !pPara )
1415cdf0e10cSrcweir return;
1416cdf0e10cSrcweir pPara->SetPrepWidows( sal_True );
1417cdf0e10cSrcweir
1418cdf0e10cSrcweir // These two lines of code have been deleted for #102340#.
1419cdf0e10cSrcweir // Obviously the widow control does not work if we have a
1420cdf0e10cSrcweir // pMaster->pFollow->pFollow situation:
1421cdf0e10cSrcweir
1422cdf0e10cSrcweir // returnen oder nicht ist hier die Frage.
1423cdf0e10cSrcweir // Ohne IsLocked() ist 5156 gefaehrlich,
1424cdf0e10cSrcweir // ohne IsFollow() werden die Orphans unterdrueckt: 6968.
1425cdf0e10cSrcweir // Abfrage auf IsLocked erst hier, weil das Flag gesetzt werden soll.
1426cdf0e10cSrcweir // if( IsLocked() && IsFollow() )
1427cdf0e10cSrcweir // return;
1428cdf0e10cSrcweir
1429cdf0e10cSrcweir MSHORT nHave = nNeed;
1430cdf0e10cSrcweir
1431cdf0e10cSrcweir // Wir geben ein paar Zeilen ab und schrumpfen im CalcPreps()
1432cdf0e10cSrcweir SWAP_IF_NOT_SWAPPED( this )
1433cdf0e10cSrcweir
1434cdf0e10cSrcweir SwTxtSizeInfo aInf( this );
1435cdf0e10cSrcweir SwTxtMargin aLine( this, &aInf );
1436cdf0e10cSrcweir aLine.Bottom();
1437cdf0e10cSrcweir xub_StrLen nTmpLen = aLine.GetCurr()->GetLen();
1438cdf0e10cSrcweir while( nHave && aLine.PrevLine() )
1439cdf0e10cSrcweir {
1440cdf0e10cSrcweir if( nTmpLen )
1441cdf0e10cSrcweir --nHave;
1442cdf0e10cSrcweir nTmpLen = aLine.GetCurr()->GetLen();
1443cdf0e10cSrcweir }
1444cdf0e10cSrcweir // In dieser Ecke tummelten sich einige Bugs: 7513, 7606.
1445cdf0e10cSrcweir // Wenn feststeht, dass Zeilen abgegeben werden koennen,
1446cdf0e10cSrcweir // muss der Master darueber hinaus die Widow-Regel ueberpruefen.
1447cdf0e10cSrcweir if( !nHave )
1448cdf0e10cSrcweir {
1449cdf0e10cSrcweir sal_Bool bSplit;
1450cdf0e10cSrcweir if( !IsFollow() ) //Nur ein Master entscheidet ueber Orphans
1451cdf0e10cSrcweir {
1452cdf0e10cSrcweir const WidowsAndOrphans aWidOrp( this );
1453cdf0e10cSrcweir bSplit = ( aLine.GetLineNr() >= aWidOrp.GetOrphansLines() &&
1454cdf0e10cSrcweir aLine.GetLineNr() >= aLine.GetDropLines() );
1455cdf0e10cSrcweir }
1456cdf0e10cSrcweir else
1457cdf0e10cSrcweir bSplit = sal_True;
1458cdf0e10cSrcweir
1459cdf0e10cSrcweir if( bSplit )
1460cdf0e10cSrcweir {
1461cdf0e10cSrcweir GetFollow()->SetOfst( aLine.GetEnd() );
1462cdf0e10cSrcweir aLine.TruncLines( sal_True );
1463cdf0e10cSrcweir if( pPara->IsFollowField() )
1464cdf0e10cSrcweir GetFollow()->SetFieldFollow( sal_True );
1465cdf0e10cSrcweir }
1466cdf0e10cSrcweir }
1467cdf0e10cSrcweir if ( bNotify )
1468cdf0e10cSrcweir {
1469cdf0e10cSrcweir _InvalidateSize();
1470cdf0e10cSrcweir InvalidatePage();
1471cdf0e10cSrcweir }
1472cdf0e10cSrcweir
1473cdf0e10cSrcweir UNDO_SWAP( this )
1474cdf0e10cSrcweir }
1475cdf0e10cSrcweir
1476cdf0e10cSrcweir /*************************************************************************
1477cdf0e10cSrcweir * SwTxtFrm::Prepare
1478cdf0e10cSrcweir *************************************************************************/
1479cdf0e10cSrcweir
lcl_ErgoVadis(SwTxtFrm * pFrm,xub_StrLen & rPos,const PrepareHint ePrep)1480cdf0e10cSrcweir sal_Bool lcl_ErgoVadis( SwTxtFrm* pFrm, xub_StrLen &rPos, const PrepareHint ePrep )
1481cdf0e10cSrcweir {
1482cdf0e10cSrcweir const SwFtnInfo &rFtnInfo = pFrm->GetNode()->GetDoc()->GetFtnInfo();
1483cdf0e10cSrcweir if( ePrep == PREP_ERGOSUM )
1484cdf0e10cSrcweir {
1485cdf0e10cSrcweir if( !rFtnInfo.aErgoSum.Len() )
1486cdf0e10cSrcweir return sal_False;;
1487cdf0e10cSrcweir rPos = pFrm->GetOfst();
1488cdf0e10cSrcweir }
1489cdf0e10cSrcweir else
1490cdf0e10cSrcweir {
1491cdf0e10cSrcweir if( !rFtnInfo.aQuoVadis.Len() )
1492cdf0e10cSrcweir return sal_False;
1493cdf0e10cSrcweir if( pFrm->HasFollow() )
1494cdf0e10cSrcweir rPos = pFrm->GetFollow()->GetOfst();
1495cdf0e10cSrcweir else
1496cdf0e10cSrcweir rPos = pFrm->GetTxt().Len();
1497cdf0e10cSrcweir if( rPos )
1498cdf0e10cSrcweir --rPos; // unser letztes Zeichen
1499cdf0e10cSrcweir }
1500cdf0e10cSrcweir return sal_True;
1501cdf0e10cSrcweir }
1502cdf0e10cSrcweir
Prepare(const PrepareHint ePrep,const void * pVoid,sal_Bool bNotify)1503cdf0e10cSrcweir void SwTxtFrm::Prepare( const PrepareHint ePrep, const void* pVoid,
1504cdf0e10cSrcweir sal_Bool bNotify )
1505cdf0e10cSrcweir {
1506cdf0e10cSrcweir SwFrmSwapper aSwapper( this, sal_False );
1507cdf0e10cSrcweir
1508cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1509cdf0e10cSrcweir const SwTwips nDbgY = Frm().Top();
1510cdf0e10cSrcweir (void)nDbgY;
1511cdf0e10cSrcweir #endif
1512cdf0e10cSrcweir
1513cdf0e10cSrcweir if ( IsEmpty() )
1514cdf0e10cSrcweir {
1515cdf0e10cSrcweir switch ( ePrep )
1516cdf0e10cSrcweir {
1517cdf0e10cSrcweir case PREP_BOSS_CHGD:
1518cdf0e10cSrcweir SetInvalidVert( sal_True ); // Test
1519cdf0e10cSrcweir case PREP_WIDOWS_ORPHANS:
1520cdf0e10cSrcweir case PREP_WIDOWS:
1521cdf0e10cSrcweir case PREP_FTN_GONE : return;
1522cdf0e10cSrcweir
1523cdf0e10cSrcweir case PREP_POS_CHGD :
1524cdf0e10cSrcweir {
1525cdf0e10cSrcweir // Auch in (spaltigen) Bereichen ist ein InvalidateSize notwendig,
1526cdf0e10cSrcweir // damit formatiert wird und ggf. das bUndersized gesetzt wird.
1527cdf0e10cSrcweir if( IsInFly() || IsInSct() )
1528cdf0e10cSrcweir {
1529cdf0e10cSrcweir SwTwips nTmpBottom = GetUpper()->Frm().Top() +
1530cdf0e10cSrcweir GetUpper()->Prt().Bottom();
1531cdf0e10cSrcweir if( nTmpBottom < Frm().Bottom() )
1532cdf0e10cSrcweir break;
1533cdf0e10cSrcweir }
1534cdf0e10cSrcweir // Gibt es ueberhaupt Flys auf der Seite ?
1535cdf0e10cSrcweir SwTxtFly aTxtFly( this );
1536cdf0e10cSrcweir if( aTxtFly.IsOn() )
1537cdf0e10cSrcweir {
1538cdf0e10cSrcweir // Ueberlappt irgendein Fly ?
1539cdf0e10cSrcweir aTxtFly.Relax();
1540cdf0e10cSrcweir if ( aTxtFly.IsOn() || IsUndersized() )
1541cdf0e10cSrcweir break;
1542cdf0e10cSrcweir }
1543cdf0e10cSrcweir if( GetTxtNode()->GetSwAttrSet().GetRegister().GetValue())
1544cdf0e10cSrcweir break;
1545cdf0e10cSrcweir
1546cdf0e10cSrcweir GETGRID( FindPageFrm() )
1547cdf0e10cSrcweir if ( pGrid && GetTxtNode()->GetSwAttrSet().GetParaGrid().GetValue() )
1548cdf0e10cSrcweir break;
1549cdf0e10cSrcweir
1550cdf0e10cSrcweir // --> OD 2004-07-16 #i28701# - consider anchored objects
1551cdf0e10cSrcweir if ( GetDrawObjs() )
1552cdf0e10cSrcweir break;
1553cdf0e10cSrcweir // <--
1554cdf0e10cSrcweir
1555cdf0e10cSrcweir return;
1556cdf0e10cSrcweir }
1557cdf0e10cSrcweir default:
1558cdf0e10cSrcweir break;
1559cdf0e10cSrcweir }
1560cdf0e10cSrcweir }
1561cdf0e10cSrcweir
1562cdf0e10cSrcweir if( !HasPara() && PREP_MUST_FIT != ePrep )
1563cdf0e10cSrcweir {
1564cdf0e10cSrcweir SetInvalidVert( sal_True ); // Test
1565cdf0e10cSrcweir ASSERT( !IsLocked(), "SwTxtFrm::Prepare: three of a perfect pair" );
1566cdf0e10cSrcweir if ( bNotify )
1567cdf0e10cSrcweir InvalidateSize();
1568cdf0e10cSrcweir else
1569cdf0e10cSrcweir _InvalidateSize();
1570cdf0e10cSrcweir return;
1571cdf0e10cSrcweir }
1572cdf0e10cSrcweir
1573cdf0e10cSrcweir //Objekt mit Locking aus dem Cache holen.
1574cdf0e10cSrcweir SwTxtLineAccess aAccess( this );
1575cdf0e10cSrcweir SwParaPortion *pPara = aAccess.GetPara();
1576cdf0e10cSrcweir
1577cdf0e10cSrcweir switch( ePrep )
1578cdf0e10cSrcweir {
1579cdf0e10cSrcweir case PREP_MOVEFTN : Frm().Height(0);
1580cdf0e10cSrcweir Prt().Height(0);
1581cdf0e10cSrcweir _InvalidatePrt();
1582cdf0e10cSrcweir _InvalidateSize();
1583cdf0e10cSrcweir // KEIN break
1584cdf0e10cSrcweir case PREP_ADJUST_FRM : pPara->SetPrepAdjust( sal_True );
1585cdf0e10cSrcweir if( IsFtnNumFrm() != pPara->IsFtnNum() ||
1586cdf0e10cSrcweir IsUndersized() )
1587cdf0e10cSrcweir {
1588cdf0e10cSrcweir InvalidateRange( SwCharRange( 0, 1 ), 1);
1589cdf0e10cSrcweir if( GetOfst() && !IsFollow() )
1590cdf0e10cSrcweir _SetOfst( 0 );
1591cdf0e10cSrcweir }
1592cdf0e10cSrcweir break;
1593cdf0e10cSrcweir case PREP_MUST_FIT : pPara->SetPrepMustFit( sal_True );
1594cdf0e10cSrcweir /* no break here */
1595cdf0e10cSrcweir case PREP_WIDOWS_ORPHANS : pPara->SetPrepAdjust( sal_True );
1596cdf0e10cSrcweir break;
1597cdf0e10cSrcweir
1598cdf0e10cSrcweir case PREP_WIDOWS :
1599cdf0e10cSrcweir // MustFit ist staerker als alles anderes
1600cdf0e10cSrcweir if( pPara->IsPrepMustFit() )
1601cdf0e10cSrcweir return;
1602cdf0e10cSrcweir // Siehe Kommentar in WidowsAndOrphans::FindOrphans und CalcPreps()
1603cdf0e10cSrcweir PrepWidows( *(const MSHORT *)pVoid, bNotify );
1604cdf0e10cSrcweir break;
1605cdf0e10cSrcweir
1606cdf0e10cSrcweir case PREP_FTN :
1607cdf0e10cSrcweir {
1608cdf0e10cSrcweir SwTxtFtn *pFtn = (SwTxtFtn *)pVoid;
1609cdf0e10cSrcweir if( IsInFtn() )
1610cdf0e10cSrcweir {
1611cdf0e10cSrcweir // Bin ich der erste TxtFrm einer Fussnote ?
1612cdf0e10cSrcweir if( !GetPrev() )
1613cdf0e10cSrcweir // Wir sind also ein TxtFrm der Fussnote, die
1614cdf0e10cSrcweir // die Fussnotenzahl zur Anzeige bringen muss.
1615cdf0e10cSrcweir // Oder den ErgoSum-Text...
1616cdf0e10cSrcweir InvalidateRange( SwCharRange( 0, 1 ), 1);
1617cdf0e10cSrcweir
1618cdf0e10cSrcweir if( !GetNext() )
1619cdf0e10cSrcweir {
1620cdf0e10cSrcweir // Wir sind der letzte Ftn, jetzt muessten die
1621cdf0e10cSrcweir // QuoVadis-Texte geupdated werden.
1622cdf0e10cSrcweir const SwFtnInfo &rFtnInfo = GetNode()->GetDoc()->GetFtnInfo();
1623cdf0e10cSrcweir if( !pPara->UpdateQuoVadis( rFtnInfo.aQuoVadis ) )
1624cdf0e10cSrcweir {
1625cdf0e10cSrcweir xub_StrLen nPos = pPara->GetParLen();
1626cdf0e10cSrcweir if( nPos )
1627cdf0e10cSrcweir --nPos;
1628cdf0e10cSrcweir InvalidateRange( SwCharRange( nPos, 1 ), 1);
1629cdf0e10cSrcweir }
1630cdf0e10cSrcweir }
1631cdf0e10cSrcweir }
1632cdf0e10cSrcweir else
1633cdf0e10cSrcweir {
1634cdf0e10cSrcweir // Wir sind also der TxtFrm _mit_ der Fussnote
1635cdf0e10cSrcweir const xub_StrLen nPos = *pFtn->GetStart();
1636cdf0e10cSrcweir InvalidateRange( SwCharRange( nPos, 1 ), 1);
1637cdf0e10cSrcweir }
1638cdf0e10cSrcweir break;
1639cdf0e10cSrcweir }
1640cdf0e10cSrcweir case PREP_BOSS_CHGD :
1641cdf0e10cSrcweir {
1642cdf0e10cSrcweir // Test
1643cdf0e10cSrcweir {
1644cdf0e10cSrcweir SetInvalidVert( sal_False );
1645cdf0e10cSrcweir sal_Bool bOld = IsVertical();
1646cdf0e10cSrcweir SetInvalidVert( sal_True );
1647cdf0e10cSrcweir if( bOld != IsVertical() )
1648cdf0e10cSrcweir InvalidateRange( SwCharRange( GetOfst(), STRING_LEN ) );
1649cdf0e10cSrcweir }
1650cdf0e10cSrcweir
1651cdf0e10cSrcweir if( HasFollow() )
1652cdf0e10cSrcweir {
1653cdf0e10cSrcweir xub_StrLen nNxtOfst = GetFollow()->GetOfst();
1654cdf0e10cSrcweir if( nNxtOfst )
1655cdf0e10cSrcweir --nNxtOfst;
1656cdf0e10cSrcweir InvalidateRange( SwCharRange( nNxtOfst, 1 ), 1);
1657cdf0e10cSrcweir }
1658cdf0e10cSrcweir if( IsInFtn() )
1659cdf0e10cSrcweir {
1660cdf0e10cSrcweir xub_StrLen nPos;
1661cdf0e10cSrcweir if( lcl_ErgoVadis( this, nPos, PREP_QUOVADIS ) )
1662cdf0e10cSrcweir InvalidateRange( SwCharRange( nPos, 1 ), 0 );
1663cdf0e10cSrcweir if( lcl_ErgoVadis( this, nPos, PREP_ERGOSUM ) )
1664cdf0e10cSrcweir InvalidateRange( SwCharRange( nPos, 1 ), 0 );
1665cdf0e10cSrcweir }
1666cdf0e10cSrcweir // 4739: Wenn wir ein Seitennummernfeld besitzen, muessen wir
1667cdf0e10cSrcweir // die Stellen invalidieren.
1668cdf0e10cSrcweir SwpHints *pHints = GetTxtNode()->GetpSwpHints();
1669cdf0e10cSrcweir if( pHints )
1670cdf0e10cSrcweir {
1671cdf0e10cSrcweir const sal_uInt16 nSize = pHints->Count();
1672cdf0e10cSrcweir const xub_StrLen nEnd = GetFollow() ?
1673cdf0e10cSrcweir GetFollow()->GetOfst() : STRING_LEN;
1674cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < nSize; ++i )
1675cdf0e10cSrcweir {
1676cdf0e10cSrcweir const SwTxtAttr *pHt = (*pHints)[i];
1677cdf0e10cSrcweir const xub_StrLen nStart = *pHt->GetStart();
1678cdf0e10cSrcweir if( nStart >= GetOfst() )
1679cdf0e10cSrcweir {
1680cdf0e10cSrcweir if( nStart >= nEnd )
1681cdf0e10cSrcweir i = nSize; // fuehrt das Ende herbei
1682cdf0e10cSrcweir else
1683cdf0e10cSrcweir {
1684cdf0e10cSrcweir // 4029: wenn wir zurueckfliessen und eine Ftn besitzen, so
1685cdf0e10cSrcweir // fliesst die Ftn in jedem Fall auch mit. Damit sie nicht im
1686cdf0e10cSrcweir // Weg steht, schicken wir uns ein ADJUST_FRM.
1687cdf0e10cSrcweir // pVoid != 0 bedeutet MoveBwd()
1688cdf0e10cSrcweir const MSHORT nWhich = pHt->Which();
1689cdf0e10cSrcweir if( RES_TXTATR_FIELD == nWhich ||
1690cdf0e10cSrcweir (HasFtn() && pVoid && RES_TXTATR_FTN == nWhich))
1691cdf0e10cSrcweir InvalidateRange( SwCharRange( nStart, 1 ), 1 );
1692cdf0e10cSrcweir }
1693cdf0e10cSrcweir }
1694cdf0e10cSrcweir }
1695cdf0e10cSrcweir }
1696cdf0e10cSrcweir // A new boss, a new chance for growing
1697cdf0e10cSrcweir if( IsUndersized() )
1698cdf0e10cSrcweir {
1699cdf0e10cSrcweir _InvalidateSize();
1700cdf0e10cSrcweir InvalidateRange( SwCharRange( GetOfst(), 1 ), 1);
1701cdf0e10cSrcweir }
1702cdf0e10cSrcweir break;
1703cdf0e10cSrcweir }
1704cdf0e10cSrcweir
1705cdf0e10cSrcweir case PREP_POS_CHGD :
1706cdf0e10cSrcweir {
1707cdf0e10cSrcweir if ( GetValidPrtAreaFlag() )
1708cdf0e10cSrcweir {
1709cdf0e10cSrcweir GETGRID( FindPageFrm() )
1710cdf0e10cSrcweir if ( pGrid && GetTxtNode()->GetSwAttrSet().GetParaGrid().GetValue() )
1711cdf0e10cSrcweir InvalidatePrt();
1712cdf0e10cSrcweir }
1713cdf0e10cSrcweir
1714cdf0e10cSrcweir // Falls wir mit niemandem ueberlappen:
1715cdf0e10cSrcweir // Ueberlappte irgendein Fly _vor_ der Positionsaenderung ?
1716cdf0e10cSrcweir sal_Bool bFormat = pPara->HasFly();
1717cdf0e10cSrcweir if( !bFormat )
1718cdf0e10cSrcweir {
1719cdf0e10cSrcweir if( IsInFly() )
1720cdf0e10cSrcweir {
1721cdf0e10cSrcweir SwTwips nTmpBottom = GetUpper()->Frm().Top() +
1722cdf0e10cSrcweir GetUpper()->Prt().Bottom();
1723cdf0e10cSrcweir if( nTmpBottom < Frm().Bottom() )
1724cdf0e10cSrcweir bFormat = sal_True;
1725cdf0e10cSrcweir }
1726cdf0e10cSrcweir if( !bFormat )
1727cdf0e10cSrcweir {
1728cdf0e10cSrcweir if ( GetDrawObjs() )
1729cdf0e10cSrcweir {
1730cdf0e10cSrcweir const sal_uInt32 nCnt = GetDrawObjs()->Count();
1731cdf0e10cSrcweir for ( MSHORT i = 0; i < nCnt; ++i )
1732cdf0e10cSrcweir {
1733cdf0e10cSrcweir SwAnchoredObject* pAnchoredObj = (*GetDrawObjs())[i];
1734cdf0e10cSrcweir // --> OD 2004-07-16 #i28701# - consider all
1735cdf0e10cSrcweir // to-character anchored objects
1736cdf0e10cSrcweir if ( pAnchoredObj->GetFrmFmt().GetAnchor().GetAnchorId()
1737cdf0e10cSrcweir == FLY_AT_CHAR )
1738cdf0e10cSrcweir {
1739cdf0e10cSrcweir bFormat = sal_True;
1740cdf0e10cSrcweir break;
1741cdf0e10cSrcweir }
1742cdf0e10cSrcweir }
1743cdf0e10cSrcweir }
1744cdf0e10cSrcweir if( !bFormat )
1745cdf0e10cSrcweir {
1746cdf0e10cSrcweir // Gibt es ueberhaupt Flys auf der Seite ?
1747cdf0e10cSrcweir SwTxtFly aTxtFly( this );
1748cdf0e10cSrcweir if( aTxtFly.IsOn() )
1749cdf0e10cSrcweir {
1750cdf0e10cSrcweir // Ueberlappt irgendein Fly ?
1751cdf0e10cSrcweir aTxtFly.Relax();
1752cdf0e10cSrcweir bFormat = aTxtFly.IsOn() || IsUndersized();
1753cdf0e10cSrcweir }
1754cdf0e10cSrcweir }
1755cdf0e10cSrcweir }
1756cdf0e10cSrcweir }
1757cdf0e10cSrcweir
1758cdf0e10cSrcweir if( bFormat )
1759cdf0e10cSrcweir {
1760cdf0e10cSrcweir if( !IsLocked() )
1761cdf0e10cSrcweir {
1762cdf0e10cSrcweir if( pPara->GetRepaint()->HasArea() )
1763cdf0e10cSrcweir SetCompletePaint();
1764cdf0e10cSrcweir Init();
1765cdf0e10cSrcweir pPara = 0;
1766cdf0e10cSrcweir _InvalidateSize();
1767cdf0e10cSrcweir }
1768cdf0e10cSrcweir }
1769cdf0e10cSrcweir else
1770cdf0e10cSrcweir {
1771cdf0e10cSrcweir if( GetTxtNode()->GetSwAttrSet().GetRegister().GetValue() )
1772cdf0e10cSrcweir Prepare( PREP_REGISTER, 0, bNotify );
1773cdf0e10cSrcweir // Durch Positionsverschiebungen mit Ftns muessen die
1774cdf0e10cSrcweir // Frames neu adjustiert werden.
1775cdf0e10cSrcweir else if( HasFtn() )
1776cdf0e10cSrcweir {
1777cdf0e10cSrcweir Prepare( PREP_ADJUST_FRM, 0, bNotify );
1778cdf0e10cSrcweir _InvalidateSize();
1779cdf0e10cSrcweir }
1780cdf0e10cSrcweir else
1781cdf0e10cSrcweir return; // damit kein SetPrep() erfolgt.
1782cdf0e10cSrcweir }
1783cdf0e10cSrcweir break;
1784cdf0e10cSrcweir }
1785cdf0e10cSrcweir case PREP_REGISTER:
1786cdf0e10cSrcweir if( GetTxtNode()->GetSwAttrSet().GetRegister().GetValue() )
1787cdf0e10cSrcweir {
1788cdf0e10cSrcweir pPara->SetPrepAdjust( sal_True );
1789cdf0e10cSrcweir CalcLineSpace();
1790cdf0e10cSrcweir InvalidateSize();
1791cdf0e10cSrcweir _InvalidatePrt();
1792cdf0e10cSrcweir SwFrm* pNxt;
1793cdf0e10cSrcweir if ( 0 != ( pNxt = GetIndNext() ) )
1794cdf0e10cSrcweir {
1795cdf0e10cSrcweir pNxt->_InvalidatePrt();
1796cdf0e10cSrcweir if ( pNxt->IsLayoutFrm() )
1797cdf0e10cSrcweir pNxt->InvalidatePage();
1798cdf0e10cSrcweir }
1799cdf0e10cSrcweir SetCompletePaint();
1800cdf0e10cSrcweir }
1801cdf0e10cSrcweir break;
1802cdf0e10cSrcweir case PREP_FTN_GONE :
1803cdf0e10cSrcweir {
1804cdf0e10cSrcweir // Wenn ein Follow uns ruft, weil eine Fussnote geloescht wird, muss unsere
1805cdf0e10cSrcweir // letzte Zeile formatiert werden, damit ggf. die erste Zeile des Follows
1806cdf0e10cSrcweir // hochrutschen kann, die extra auf die naechste Seite gerutscht war, um mit
1807cdf0e10cSrcweir // der Fussnote zusammen zu sein, insbesondere bei spaltigen Bereichen.
1808cdf0e10cSrcweir ASSERT( GetFollow(), "PREP_FTN_GONE darf nur vom Follow gerufen werden" );
1809cdf0e10cSrcweir xub_StrLen nPos = GetFollow()->GetOfst();
1810cdf0e10cSrcweir if( IsFollow() && GetOfst() == nPos ) // falls wir gar keine Textmasse besitzen,
1811cdf0e10cSrcweir FindMaster()->Prepare( PREP_FTN_GONE ); // rufen wir das Prepare unseres Masters
1812cdf0e10cSrcweir if( nPos )
1813cdf0e10cSrcweir --nPos; // das Zeichen vor unserem Follow
1814cdf0e10cSrcweir InvalidateRange( SwCharRange( nPos, 1 ), 0 );
1815cdf0e10cSrcweir return;
1816cdf0e10cSrcweir }
1817cdf0e10cSrcweir case PREP_ERGOSUM:
1818cdf0e10cSrcweir case PREP_QUOVADIS:
1819cdf0e10cSrcweir {
1820cdf0e10cSrcweir xub_StrLen nPos;
1821cdf0e10cSrcweir if( lcl_ErgoVadis( this, nPos, ePrep ) )
1822cdf0e10cSrcweir InvalidateRange( SwCharRange( nPos, 1 ), 0 );
1823cdf0e10cSrcweir }
1824cdf0e10cSrcweir break;
1825cdf0e10cSrcweir case PREP_FLY_ATTR_CHG:
1826cdf0e10cSrcweir {
1827cdf0e10cSrcweir if( pVoid )
1828cdf0e10cSrcweir {
1829cdf0e10cSrcweir xub_StrLen nWhere = CalcFlyPos( (SwFrmFmt*)pVoid );
1830cdf0e10cSrcweir ASSERT( STRING_LEN != nWhere, "Prepare: Why me?" );
1831cdf0e10cSrcweir InvalidateRange( SwCharRange( nWhere, 1 ) );
1832cdf0e10cSrcweir return;
1833cdf0e10cSrcweir }
1834cdf0e10cSrcweir // else ... Laufe in den Default-Switch
1835cdf0e10cSrcweir }
1836cdf0e10cSrcweir case PREP_CLEAR:
1837cdf0e10cSrcweir default:
1838cdf0e10cSrcweir {
1839cdf0e10cSrcweir if( IsLocked() )
1840cdf0e10cSrcweir {
1841cdf0e10cSrcweir if( PREP_FLY_ARRIVE == ePrep || PREP_FLY_LEAVE == ePrep )
1842cdf0e10cSrcweir {
1843cdf0e10cSrcweir xub_StrLen nLen = ( GetFollow() ? GetFollow()->GetOfst() :
1844cdf0e10cSrcweir STRING_LEN ) - GetOfst();
1845cdf0e10cSrcweir InvalidateRange( SwCharRange( GetOfst(), nLen ), 0 );
1846cdf0e10cSrcweir }
1847cdf0e10cSrcweir }
1848cdf0e10cSrcweir else
1849cdf0e10cSrcweir {
1850cdf0e10cSrcweir if( pPara->GetRepaint()->HasArea() )
1851cdf0e10cSrcweir SetCompletePaint();
1852cdf0e10cSrcweir Init();
1853cdf0e10cSrcweir pPara = 0;
1854cdf0e10cSrcweir if( GetOfst() && !IsFollow() )
1855cdf0e10cSrcweir _SetOfst( 0 );
1856cdf0e10cSrcweir if ( bNotify )
1857cdf0e10cSrcweir InvalidateSize();
1858cdf0e10cSrcweir else
1859cdf0e10cSrcweir _InvalidateSize();
1860cdf0e10cSrcweir }
1861cdf0e10cSrcweir return; // damit kein SetPrep() erfolgt.
1862cdf0e10cSrcweir }
1863cdf0e10cSrcweir }
1864cdf0e10cSrcweir if( pPara )
1865cdf0e10cSrcweir pPara->SetPrep( sal_True );
1866cdf0e10cSrcweir }
1867cdf0e10cSrcweir
1868cdf0e10cSrcweir /* -----------------11.02.99 17:56-------------------
1869cdf0e10cSrcweir * Kleine Hilfsklasse mit folgender Funktion:
1870cdf0e10cSrcweir * Sie soll eine Probeformatierung vorbereiten.
1871cdf0e10cSrcweir * Der Frame wird in Groesse und Position angepasst, sein SwParaPortion zur Seite
1872cdf0e10cSrcweir * gestellt und eine neue erzeugt, dazu wird formatiert mit gesetztem bTestFormat.
1873cdf0e10cSrcweir * Im Dtor wird der TxtFrm wieder in seinen alten Zustand zurueckversetzt.
1874cdf0e10cSrcweir *
1875cdf0e10cSrcweir * --------------------------------------------------*/
1876cdf0e10cSrcweir
1877cdf0e10cSrcweir class SwTestFormat
1878cdf0e10cSrcweir {
1879cdf0e10cSrcweir SwTxtFrm *pFrm;
1880cdf0e10cSrcweir SwParaPortion *pOldPara;
1881cdf0e10cSrcweir SwRect aOldFrm, aOldPrt;
1882cdf0e10cSrcweir public:
1883cdf0e10cSrcweir SwTestFormat( SwTxtFrm* pTxtFrm, const SwFrm* pPrv, SwTwips nMaxHeight );
1884cdf0e10cSrcweir ~SwTestFormat();
1885cdf0e10cSrcweir };
1886cdf0e10cSrcweir
SwTestFormat(SwTxtFrm * pTxtFrm,const SwFrm * pPre,SwTwips nMaxHeight)1887cdf0e10cSrcweir SwTestFormat::SwTestFormat( SwTxtFrm* pTxtFrm, const SwFrm* pPre, SwTwips nMaxHeight )
1888cdf0e10cSrcweir : pFrm( pTxtFrm )
1889cdf0e10cSrcweir {
1890cdf0e10cSrcweir aOldFrm = pFrm->Frm();
1891cdf0e10cSrcweir aOldPrt = pFrm->Prt();
1892cdf0e10cSrcweir
1893cdf0e10cSrcweir SWRECTFN( pFrm )
1894cdf0e10cSrcweir SwTwips nLower = (pFrm->*fnRect->fnGetBottomMargin)();
1895cdf0e10cSrcweir
1896cdf0e10cSrcweir pFrm->Frm() = pFrm->GetUpper()->Prt();
1897cdf0e10cSrcweir pFrm->Frm() += pFrm->GetUpper()->Frm().Pos();
1898cdf0e10cSrcweir
1899cdf0e10cSrcweir (pFrm->Frm().*fnRect->fnSetHeight)( nMaxHeight );
1900cdf0e10cSrcweir if( pFrm->GetPrev() )
1901cdf0e10cSrcweir (pFrm->Frm().*fnRect->fnSetPosY)(
1902cdf0e10cSrcweir (pFrm->GetPrev()->Frm().*fnRect->fnGetBottom)() -
1903cdf0e10cSrcweir ( bVert ? nMaxHeight + 1 : 0 ) );
1904cdf0e10cSrcweir
1905cdf0e10cSrcweir SwBorderAttrAccess aAccess( SwFrm::GetCache(), pFrm );
1906cdf0e10cSrcweir const SwBorderAttrs &rAttrs = *aAccess.Get();
1907cdf0e10cSrcweir (pFrm->Prt().*fnRect->fnSetPosX)( rAttrs.CalcLeft( pFrm ) );
1908cdf0e10cSrcweir
1909cdf0e10cSrcweir if( pPre )
1910cdf0e10cSrcweir {
1911cdf0e10cSrcweir SwTwips nUpper = pFrm->CalcUpperSpace( &rAttrs, pPre );
1912cdf0e10cSrcweir (pFrm->Prt().*fnRect->fnSetPosY)( nUpper );
1913cdf0e10cSrcweir }
1914cdf0e10cSrcweir (pFrm->Prt().*fnRect->fnSetHeight)(
1915cdf0e10cSrcweir Max( 0L , (pFrm->Frm().*fnRect->fnGetHeight)() -
1916cdf0e10cSrcweir (pFrm->Prt().*fnRect->fnGetTop)() - nLower ) );
1917cdf0e10cSrcweir (pFrm->Prt().*fnRect->fnSetWidth)(
1918cdf0e10cSrcweir (pFrm->Frm().*fnRect->fnGetWidth)() -
1919cdf0e10cSrcweir // OD 23.01.2003 #106895# - add 1st param to <SwBorderAttrs::CalcRight(..)>
1920cdf0e10cSrcweir ( rAttrs.CalcLeft( pFrm ) + rAttrs.CalcRight( pFrm ) ) );
1921cdf0e10cSrcweir pOldPara = pFrm->HasPara() ? pFrm->GetPara() : NULL;
1922cdf0e10cSrcweir pFrm->SetPara( new SwParaPortion(), sal_False );
1923cdf0e10cSrcweir
1924cdf0e10cSrcweir ASSERT( ! pFrm->IsSwapped(), "A frame is swapped before _Format" );
1925cdf0e10cSrcweir
1926cdf0e10cSrcweir if ( pFrm->IsVertical() )
1927cdf0e10cSrcweir pFrm->SwapWidthAndHeight();
1928cdf0e10cSrcweir
1929cdf0e10cSrcweir SwTxtFormatInfo aInf( pFrm, sal_False, sal_True, sal_True );
1930cdf0e10cSrcweir SwTxtFormatter aLine( pFrm, &aInf );
1931cdf0e10cSrcweir
1932cdf0e10cSrcweir pFrm->_Format( aLine, aInf );
1933cdf0e10cSrcweir
1934cdf0e10cSrcweir if ( pFrm->IsVertical() )
1935cdf0e10cSrcweir pFrm->SwapWidthAndHeight();
1936cdf0e10cSrcweir
1937cdf0e10cSrcweir ASSERT( ! pFrm->IsSwapped(), "A frame is swapped after _Format" );
1938cdf0e10cSrcweir }
1939cdf0e10cSrcweir
~SwTestFormat()1940cdf0e10cSrcweir SwTestFormat::~SwTestFormat()
1941cdf0e10cSrcweir {
1942cdf0e10cSrcweir pFrm->Frm() = aOldFrm;
1943cdf0e10cSrcweir pFrm->Prt() = aOldPrt;
1944cdf0e10cSrcweir pFrm->SetPara( pOldPara );
1945cdf0e10cSrcweir }
1946cdf0e10cSrcweir
TestFormat(const SwFrm * pPrv,SwTwips & rMaxHeight,sal_Bool & bSplit)1947cdf0e10cSrcweir sal_Bool SwTxtFrm::TestFormat( const SwFrm* pPrv, SwTwips &rMaxHeight, sal_Bool &bSplit )
1948cdf0e10cSrcweir {
1949cdf0e10cSrcweir PROTOCOL_ENTER( this, PROT_TESTFORMAT, 0, 0 )
1950cdf0e10cSrcweir
1951cdf0e10cSrcweir if( IsLocked() && GetUpper()->Prt().Width() <= 0 )
1952cdf0e10cSrcweir return sal_False;
1953cdf0e10cSrcweir
1954cdf0e10cSrcweir SwTestFormat aSave( this, pPrv, rMaxHeight );
1955cdf0e10cSrcweir
1956cdf0e10cSrcweir return SwTxtFrm::WouldFit( rMaxHeight, bSplit, sal_True );
1957cdf0e10cSrcweir }
1958cdf0e10cSrcweir
1959cdf0e10cSrcweir
1960cdf0e10cSrcweir /*************************************************************************
1961cdf0e10cSrcweir * SwTxtFrm::WouldFit()
1962cdf0e10cSrcweir *************************************************************************/
1963cdf0e10cSrcweir
1964cdf0e10cSrcweir /* SwTxtFrm::WouldFit()
1965cdf0e10cSrcweir * sal_True: wenn ich aufspalten kann.
1966cdf0e10cSrcweir * Es soll und braucht nicht neu formatiert werden.
1967cdf0e10cSrcweir * Wir gehen davon aus, dass bereits formatiert wurde und dass
1968cdf0e10cSrcweir * die Formatierungsdaten noch aktuell sind.
1969cdf0e10cSrcweir * Wir gehen davon aus, dass die Framebreiten des evtl. Masters und
1970cdf0e10cSrcweir * Follows gleich sind. Deswegen wird kein FindBreak() mit FindOrphans()
1971cdf0e10cSrcweir * gerufen.
1972cdf0e10cSrcweir * Die benoetigte Hoehe wird von nMaxHeight abgezogen!
1973cdf0e10cSrcweir */
1974cdf0e10cSrcweir
WouldFit(SwTwips & rMaxHeight,sal_Bool & bSplit,sal_Bool bTst)1975cdf0e10cSrcweir sal_Bool SwTxtFrm::WouldFit( SwTwips &rMaxHeight, sal_Bool &bSplit, sal_Bool bTst )
1976cdf0e10cSrcweir {
1977cdf0e10cSrcweir ASSERT( ! IsVertical() || ! IsSwapped(),
1978cdf0e10cSrcweir "SwTxtFrm::WouldFit with swapped frame" );
1979cdf0e10cSrcweir SWRECTFN( this );
1980cdf0e10cSrcweir
1981cdf0e10cSrcweir if( IsLocked() )
1982cdf0e10cSrcweir return sal_False;
1983cdf0e10cSrcweir
1984cdf0e10cSrcweir //Kann gut sein, dass mir der IdleCollector mir die gecachten
1985cdf0e10cSrcweir //Informationen entzogen hat.
1986cdf0e10cSrcweir if( !IsEmpty() )
1987cdf0e10cSrcweir GetFormatted();
1988cdf0e10cSrcweir
1989cdf0e10cSrcweir // OD 2004-05-24 #i27801# - correction: 'short cut' for empty paragraph
1990cdf0e10cSrcweir // can *not* be applied, if test format is in progress. The test format doesn't
1991cdf0e10cSrcweir // adjust the frame and the printing area - see method <SwTxtFrm::_Format(..)>,
1992cdf0e10cSrcweir // which is called in <SwTxtFrm::TestFormat(..)>
1993cdf0e10cSrcweir if ( IsEmpty() && !bTst )
1994cdf0e10cSrcweir {
1995cdf0e10cSrcweir bSplit = sal_False;
1996cdf0e10cSrcweir SwTwips nHeight = bVert ? Prt().SSize().Width() : Prt().SSize().Height();
1997cdf0e10cSrcweir if( rMaxHeight < nHeight )
1998cdf0e10cSrcweir return sal_False;
1999cdf0e10cSrcweir else
2000cdf0e10cSrcweir {
2001cdf0e10cSrcweir rMaxHeight -= nHeight;
2002cdf0e10cSrcweir return sal_True;
2003cdf0e10cSrcweir }
2004cdf0e10cSrcweir }
2005cdf0e10cSrcweir
2006cdf0e10cSrcweir // In sehr unguenstigen Faellen kann GetPara immer noch 0 sein.
2007cdf0e10cSrcweir // Dann returnen wir sal_True, um auf der neuen Seite noch einmal
2008cdf0e10cSrcweir // anformatiert zu werden.
2009cdf0e10cSrcweir ASSERT( HasPara() || IsHiddenNow(), "WouldFit: GetFormatted() and then !HasPara()" );
2010cdf0e10cSrcweir if( !HasPara() || ( !(Frm().*fnRect->fnGetHeight)() && IsHiddenNow() ) )
2011cdf0e10cSrcweir return sal_True;
2012cdf0e10cSrcweir
2013cdf0e10cSrcweir // Da das Orphan-Flag nur sehr fluechtig existiert, wird als zweite
2014cdf0e10cSrcweir // Bedingung ueberprueft, ob die Rahmengroesse durch CalcPreps
2015cdf0e10cSrcweir // auf riesengross gesetzt wird, um ein MoveFwd zu erzwingen.
2016cdf0e10cSrcweir if( IsWidow() || ( bVert ?
2017cdf0e10cSrcweir ( 0 == Frm().Left() ) :
2018cdf0e10cSrcweir ( LONG_MAX - 20000 < Frm().Bottom() ) ) )
2019cdf0e10cSrcweir {
2020cdf0e10cSrcweir SetWidow(sal_False);
2021cdf0e10cSrcweir if ( GetFollow() )
2022cdf0e10cSrcweir {
2023cdf0e10cSrcweir // Wenn wir hier durch eine Widow-Anforderung unseres Follows gelandet
2024cdf0e10cSrcweir // sind, wird ueberprueft, ob es ueberhaupt einen Follow mit einer
2025cdf0e10cSrcweir // echten Hoehe gibt, andernfalls (z.B. in neu angelegten SctFrms)
2026cdf0e10cSrcweir // ignorieren wir das IsWidow() und pruefen doch noch, ob wir
2027cdf0e10cSrcweir // genung Platz finden.
2028cdf0e10cSrcweir if( ( ( ! bVert && LONG_MAX - 20000 >= Frm().Bottom() ) ||
2029cdf0e10cSrcweir ( bVert && 0 < Frm().Left() ) ) &&
2030cdf0e10cSrcweir ( GetFollow()->IsVertical() ?
2031cdf0e10cSrcweir !GetFollow()->Frm().Width() :
2032cdf0e10cSrcweir !GetFollow()->Frm().Height() ) )
2033cdf0e10cSrcweir {
2034cdf0e10cSrcweir SwTxtFrm* pFoll = GetFollow()->GetFollow();
2035cdf0e10cSrcweir while( pFoll &&
2036cdf0e10cSrcweir ( pFoll->IsVertical() ?
2037cdf0e10cSrcweir !pFoll->Frm().Width() :
2038cdf0e10cSrcweir !pFoll->Frm().Height() ) )
2039cdf0e10cSrcweir pFoll = pFoll->GetFollow();
2040cdf0e10cSrcweir if( pFoll )
2041cdf0e10cSrcweir return sal_False;
2042cdf0e10cSrcweir }
2043cdf0e10cSrcweir else
2044cdf0e10cSrcweir return sal_False;
2045cdf0e10cSrcweir }
2046cdf0e10cSrcweir }
2047cdf0e10cSrcweir
2048cdf0e10cSrcweir SWAP_IF_NOT_SWAPPED( this );
2049cdf0e10cSrcweir
2050cdf0e10cSrcweir SwTxtSizeInfo aInf( this );
2051cdf0e10cSrcweir SwTxtMargin aLine( this, &aInf );
2052cdf0e10cSrcweir
2053cdf0e10cSrcweir WidowsAndOrphans aFrmBreak( this, rMaxHeight, bSplit );
2054cdf0e10cSrcweir
2055cdf0e10cSrcweir sal_Bool bRet = sal_True;
2056cdf0e10cSrcweir
2057cdf0e10cSrcweir aLine.Bottom();
2058cdf0e10cSrcweir // Ist Aufspalten ueberhaupt notwendig?
2059cdf0e10cSrcweir if ( 0 != ( bSplit = !aFrmBreak.IsInside( aLine ) ) )
2060cdf0e10cSrcweir bRet = !aFrmBreak.IsKeepAlways() && aFrmBreak.WouldFit( aLine, rMaxHeight, bTst );
2061cdf0e10cSrcweir else
2062cdf0e10cSrcweir {
2063cdf0e10cSrcweir //Wir brauchen die Gesamthoehe inklusive der aktuellen Zeile
2064cdf0e10cSrcweir aLine.Top();
2065cdf0e10cSrcweir do
2066cdf0e10cSrcweir {
2067cdf0e10cSrcweir rMaxHeight -= aLine.GetLineHeight();
2068cdf0e10cSrcweir } while ( aLine.Next() );
2069cdf0e10cSrcweir }
2070cdf0e10cSrcweir
2071cdf0e10cSrcweir UNDO_SWAP( this )
2072cdf0e10cSrcweir
2073cdf0e10cSrcweir return bRet;
2074cdf0e10cSrcweir }
2075cdf0e10cSrcweir
2076cdf0e10cSrcweir
2077cdf0e10cSrcweir /*************************************************************************
2078cdf0e10cSrcweir * SwTxtFrm::GetParHeight()
2079cdf0e10cSrcweir *************************************************************************/
2080cdf0e10cSrcweir
GetParHeight() const2081cdf0e10cSrcweir KSHORT SwTxtFrm::GetParHeight() const
2082cdf0e10cSrcweir {
2083cdf0e10cSrcweir ASSERT( ! IsVertical() || ! IsSwapped(),
2084cdf0e10cSrcweir "SwTxtFrm::GetParHeight with swapped frame" )
2085cdf0e10cSrcweir
2086cdf0e10cSrcweir if( !HasPara() )
2087cdf0e10cSrcweir { // Fuer nichtleere Absaetze ist dies ein Sonderfall, da koennen wir
2088cdf0e10cSrcweir // bei UnderSized ruhig nur 1 Twip mehr anfordern.
2089cdf0e10cSrcweir KSHORT nRet = (KSHORT)Prt().SSize().Height();
2090cdf0e10cSrcweir if( IsUndersized() )
2091cdf0e10cSrcweir {
2092cdf0e10cSrcweir if( IsEmpty() )
2093cdf0e10cSrcweir nRet = (KSHORT)EmptyHeight();
2094cdf0e10cSrcweir else
2095cdf0e10cSrcweir ++nRet;
2096cdf0e10cSrcweir }
2097cdf0e10cSrcweir return nRet;
2098cdf0e10cSrcweir }
2099cdf0e10cSrcweir
2100cdf0e10cSrcweir // FME, OD 08.01.2004 #i11859# - refactoring and improve code
2101cdf0e10cSrcweir const SwLineLayout* pLineLayout = GetPara();
2102cdf0e10cSrcweir KSHORT nHeight = pLineLayout->GetRealHeight();
2103cdf0e10cSrcweir if( GetOfst() && !IsFollow() ) // Ist dieser Absatz gescrollt? Dann ist unsere
2104cdf0e10cSrcweir nHeight *= 2; // bisherige Hoehe mind. eine Zeilenhoehe zu gering
2105cdf0e10cSrcweir // OD 2004-03-04 #115793#
2106cdf0e10cSrcweir while ( pLineLayout && pLineLayout->GetNext() )
2107cdf0e10cSrcweir {
2108cdf0e10cSrcweir pLineLayout = pLineLayout->GetNext();
2109cdf0e10cSrcweir nHeight = nHeight + pLineLayout->GetRealHeight();
2110cdf0e10cSrcweir }
2111cdf0e10cSrcweir
2112cdf0e10cSrcweir return nHeight;
2113cdf0e10cSrcweir }
2114cdf0e10cSrcweir
2115cdf0e10cSrcweir
2116cdf0e10cSrcweir /*************************************************************************
2117cdf0e10cSrcweir * SwTxtFrm::GetFormatted()
2118cdf0e10cSrcweir *************************************************************************/
2119cdf0e10cSrcweir
2120cdf0e10cSrcweir // returnt this _immer_ im formatierten Zustand!
GetFormatted(bool bForceQuickFormat)2121cdf0e10cSrcweir SwTxtFrm* SwTxtFrm::GetFormatted( bool bForceQuickFormat )
2122cdf0e10cSrcweir {
2123cdf0e10cSrcweir SWAP_IF_SWAPPED( this )
2124cdf0e10cSrcweir
2125cdf0e10cSrcweir //Kann gut sein, dass mir der IdleCollector mir die gecachten
2126cdf0e10cSrcweir //Informationen entzogen hat. Calc() ruft unser Format.
2127cdf0e10cSrcweir //Nicht bei leeren Absaetzen!
2128cdf0e10cSrcweir if( !HasPara() && !(IsValid() && IsEmpty()) )
2129cdf0e10cSrcweir {
2130cdf0e10cSrcweir // Calc() muss gerufen werden, weil unsere Frameposition
2131cdf0e10cSrcweir // nicht stimmen muss.
2132cdf0e10cSrcweir const sal_Bool bFormat = GetValidSizeFlag();
2133cdf0e10cSrcweir Calc();
2134cdf0e10cSrcweir // Es kann durchaus sein, dass Calc() das Format()
2135cdf0e10cSrcweir // nicht anstiess (weil wir einst vom Idle-Zerstoerer
2136cdf0e10cSrcweir // aufgefordert wurden unsere Formatinformationen wegzuschmeissen).
2137cdf0e10cSrcweir // 6995: Optimierung mit FormatQuick()
2138cdf0e10cSrcweir if( bFormat && !FormatQuick( bForceQuickFormat ) )
2139cdf0e10cSrcweir Format();
2140cdf0e10cSrcweir }
2141cdf0e10cSrcweir
2142cdf0e10cSrcweir UNDO_SWAP( this )
2143cdf0e10cSrcweir
2144cdf0e10cSrcweir return this;
2145cdf0e10cSrcweir }
2146cdf0e10cSrcweir
2147cdf0e10cSrcweir /*************************************************************************
2148cdf0e10cSrcweir * SwTxtFrm::CalcFitToContent()
2149cdf0e10cSrcweir *************************************************************************/
2150cdf0e10cSrcweir
CalcFitToContent()2151cdf0e10cSrcweir SwTwips SwTxtFrm::CalcFitToContent()
2152cdf0e10cSrcweir {
2153cdf0e10cSrcweir // --> FME 2004-07-16 #i31490#
2154cdf0e10cSrcweir // If we are currently locked, we better return with a
2155cdf0e10cSrcweir // fairly reasonable value:
2156cdf0e10cSrcweir if ( IsLocked() )
2157cdf0e10cSrcweir return Prt().Width();
2158cdf0e10cSrcweir // <--
2159cdf0e10cSrcweir
2160cdf0e10cSrcweir SwParaPortion* pOldPara = GetPara();
2161cdf0e10cSrcweir SwParaPortion *pDummy = new SwParaPortion();
2162cdf0e10cSrcweir SetPara( pDummy, false );
2163cdf0e10cSrcweir const SwPageFrm* pPage = FindPageFrm();
2164cdf0e10cSrcweir
2165cdf0e10cSrcweir const Point aOldFrmPos = Frm().Pos();
2166cdf0e10cSrcweir const SwTwips nOldFrmWidth = Frm().Width();
2167cdf0e10cSrcweir const SwTwips nOldPrtWidth = Prt().Width();
2168cdf0e10cSrcweir const SwTwips nPageWidth = GetUpper()->IsVertical() ?
2169cdf0e10cSrcweir pPage->Prt().Height() :
2170cdf0e10cSrcweir pPage->Prt().Width();
2171cdf0e10cSrcweir
2172cdf0e10cSrcweir Frm().Width( nPageWidth );
2173cdf0e10cSrcweir Prt().Width( nPageWidth );
2174cdf0e10cSrcweir
2175cdf0e10cSrcweir // --> FME 2004-07-19 #i25422# objects anchored as character in RTL
2176cdf0e10cSrcweir if ( IsRightToLeft() )
2177cdf0e10cSrcweir Frm().Pos().X() += nOldFrmWidth - nPageWidth;
2178cdf0e10cSrcweir
2179cdf0e10cSrcweir // --> FME 2004-07-16 #i31490#
2180cdf0e10cSrcweir SwTxtFrmLocker aLock( this );
2181cdf0e10cSrcweir // <--
2182cdf0e10cSrcweir
2183cdf0e10cSrcweir SwTxtFormatInfo aInf( this, sal_False, sal_True, sal_True );
2184cdf0e10cSrcweir aInf.SetIgnoreFly( sal_True );
2185cdf0e10cSrcweir SwTxtFormatter aLine( this, &aInf );
2186cdf0e10cSrcweir SwHookOut aHook( aInf );
2187cdf0e10cSrcweir
2188cdf0e10cSrcweir // --> OD 2005-09-06 #i54031# - assure mininum of MINLAY twips.
2189cdf0e10cSrcweir const SwTwips nMax = Max( (SwTwips)MINLAY,
2190cdf0e10cSrcweir aLine._CalcFitToContent() + 1 );
2191cdf0e10cSrcweir // <--
2192cdf0e10cSrcweir
2193cdf0e10cSrcweir Frm().Width( nOldFrmWidth );
2194cdf0e10cSrcweir Prt().Width( nOldPrtWidth );
2195cdf0e10cSrcweir
2196cdf0e10cSrcweir // --> FME 2004-07-19 #i25422# objects anchored as character in RTL
2197cdf0e10cSrcweir if ( IsRightToLeft() )
2198cdf0e10cSrcweir Frm().Pos() = aOldFrmPos;
2199cdf0e10cSrcweir
2200cdf0e10cSrcweir
2201cdf0e10cSrcweir SetPara( pOldPara );
2202cdf0e10cSrcweir
2203cdf0e10cSrcweir return nMax;
2204cdf0e10cSrcweir }
2205cdf0e10cSrcweir
2206cdf0e10cSrcweir /** simulate format for a list item paragraph, whose list level attributes
2207cdf0e10cSrcweir are in LABEL_ALIGNMENT mode, in order to determine additional first
2208cdf0e10cSrcweir line offset for the real text formatting due to the value of label
2209cdf0e10cSrcweir adjustment attribute of the list level.
2210cdf0e10cSrcweir
2211cdf0e10cSrcweir OD 2008-01-31 #newlistlevelattrs#
2212cdf0e10cSrcweir
2213cdf0e10cSrcweir @author OD
2214cdf0e10cSrcweir */
CalcAdditionalFirstLineOffset()2215cdf0e10cSrcweir void SwTxtFrm::CalcAdditionalFirstLineOffset()
2216cdf0e10cSrcweir {
2217cdf0e10cSrcweir if ( IsLocked() )
2218cdf0e10cSrcweir return;
2219cdf0e10cSrcweir
2220cdf0e10cSrcweir // reset additional first line offset
2221cdf0e10cSrcweir mnAdditionalFirstLineOffset = 0;
2222cdf0e10cSrcweir
2223cdf0e10cSrcweir const SwTxtNode* pTxtNode( GetTxtNode() );
2224cdf0e10cSrcweir if ( pTxtNode && pTxtNode->IsNumbered() && pTxtNode->IsCountedInList() &&
2225cdf0e10cSrcweir pTxtNode->GetNumRule() )
2226cdf0e10cSrcweir {
2227cdf0e10cSrcweir const SwNumFmt& rNumFmt =
2228cdf0e10cSrcweir pTxtNode->GetNumRule()->Get( static_cast<sal_uInt16>(pTxtNode->GetActualListLevel()) );
2229cdf0e10cSrcweir if ( rNumFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
2230cdf0e10cSrcweir {
2231cdf0e10cSrcweir // keep current paragraph portion and apply dummy paragraph portion
2232cdf0e10cSrcweir SwParaPortion* pOldPara = GetPara();
2233cdf0e10cSrcweir SwParaPortion *pDummy = new SwParaPortion();
2234cdf0e10cSrcweir SetPara( pDummy, false );
2235cdf0e10cSrcweir
2236cdf0e10cSrcweir // lock paragraph
2237cdf0e10cSrcweir SwTxtFrmLocker aLock( this );
2238cdf0e10cSrcweir
2239cdf0e10cSrcweir // simulate text formatting
2240cdf0e10cSrcweir SwTxtFormatInfo aInf( this, sal_False, sal_True, sal_True );
2241cdf0e10cSrcweir aInf.SetIgnoreFly( sal_True );
2242cdf0e10cSrcweir SwTxtFormatter aLine( this, &aInf );
2243cdf0e10cSrcweir SwHookOut aHook( aInf );
2244cdf0e10cSrcweir aLine._CalcFitToContent();
2245cdf0e10cSrcweir
2246cdf0e10cSrcweir // determine additional first line offset
2247cdf0e10cSrcweir const SwLinePortion* pFirstPortion = aLine.GetCurr()->GetFirstPortion();
2248cdf0e10cSrcweir if ( pFirstPortion->InNumberGrp() && !pFirstPortion->IsFtnNumPortion() )
2249cdf0e10cSrcweir {
2250cdf0e10cSrcweir SwTwips nNumberPortionWidth( pFirstPortion->Width() );
2251cdf0e10cSrcweir
2252cdf0e10cSrcweir const SwLinePortion* pPortion = pFirstPortion->GetPortion();
2253cdf0e10cSrcweir while ( pPortion &&
2254cdf0e10cSrcweir pPortion->InNumberGrp() && !pPortion->IsFtnNumPortion())
2255cdf0e10cSrcweir {
2256cdf0e10cSrcweir nNumberPortionWidth += pPortion->Width();
2257cdf0e10cSrcweir pPortion = pPortion->GetPortion();
2258cdf0e10cSrcweir }
2259cdf0e10cSrcweir
2260cdf0e10cSrcweir if ( ( IsRightToLeft() &&
2261cdf0e10cSrcweir rNumFmt.GetNumAdjust() == SVX_ADJUST_LEFT ) ||
2262cdf0e10cSrcweir ( !IsRightToLeft() &&
2263cdf0e10cSrcweir rNumFmt.GetNumAdjust() == SVX_ADJUST_RIGHT ) )
2264cdf0e10cSrcweir {
2265cdf0e10cSrcweir mnAdditionalFirstLineOffset = -nNumberPortionWidth;
2266cdf0e10cSrcweir }
2267cdf0e10cSrcweir else if ( rNumFmt.GetNumAdjust() == SVX_ADJUST_CENTER )
2268cdf0e10cSrcweir {
2269cdf0e10cSrcweir mnAdditionalFirstLineOffset = -(nNumberPortionWidth/2);
2270cdf0e10cSrcweir }
2271cdf0e10cSrcweir }
2272cdf0e10cSrcweir
2273cdf0e10cSrcweir // restore paragraph portion
2274cdf0e10cSrcweir SetPara( pOldPara );
2275cdf0e10cSrcweir }
2276cdf0e10cSrcweir }
2277cdf0e10cSrcweir }
2278cdf0e10cSrcweir
2279cdf0e10cSrcweir /** determine height of last line for the calculation of the proportional line
2280cdf0e10cSrcweir spacing
2281cdf0e10cSrcweir
2282cdf0e10cSrcweir OD 08.01.2004 #i11859#
2283cdf0e10cSrcweir OD 2004-03-17 #i11860# - method <GetHeightOfLastLineForPropLineSpacing()>
2284cdf0e10cSrcweir replace by method <_CalcHeightOfLastLine()>. Height of last line will be
2285cdf0e10cSrcweir stored in new member <mnHeightOfLastLine> and can be accessed via method
2286cdf0e10cSrcweir <GetHeightOfLastLine()>
2287cdf0e10cSrcweir OD 2005-05-20 #i47162# - introduce new optional parameter <_bUseFont>
2288cdf0e10cSrcweir in order to force the usage of the former algorithm to determine the
2289cdf0e10cSrcweir height of the last line, which uses the font.
2290cdf0e10cSrcweir
2291cdf0e10cSrcweir @author OD
2292cdf0e10cSrcweir */
_CalcHeightOfLastLine(const bool _bUseFont)2293cdf0e10cSrcweir void SwTxtFrm::_CalcHeightOfLastLine( const bool _bUseFont )
2294cdf0e10cSrcweir {
2295cdf0e10cSrcweir // --> OD 2006-11-13 #i71281#
2296cdf0e10cSrcweir // invalidate printing area, if height of last line changes
2297cdf0e10cSrcweir const SwTwips mnOldHeightOfLastLine( mnHeightOfLastLine );
2298cdf0e10cSrcweir // <--
2299cdf0e10cSrcweir // determine output device
2300cdf0e10cSrcweir ViewShell* pVsh = getRootFrm()->GetCurrShell();
2301cdf0e10cSrcweir ASSERT( pVsh, "<SwTxtFrm::_GetHeightOfLastLineForPropLineSpacing()> - no ViewShell" );
2302cdf0e10cSrcweir // --> OD 2007-07-02 #i78921# - make code robust, according to provided patch
2303cdf0e10cSrcweir // There could be no <ViewShell> instance in the case of loading a binary
2304cdf0e10cSrcweir // StarOffice file format containing an embedded Writer document.
2305cdf0e10cSrcweir if ( !pVsh )
2306cdf0e10cSrcweir {
2307cdf0e10cSrcweir return;
2308cdf0e10cSrcweir }
2309cdf0e10cSrcweir OutputDevice* pOut = pVsh->GetOut();
2310cdf0e10cSrcweir const IDocumentSettingAccess* pIDSA = GetTxtNode()->getIDocumentSettingAccess();
2311cdf0e10cSrcweir if ( !pVsh->GetViewOptions()->getBrowseMode() ||
2312cdf0e10cSrcweir pVsh->GetViewOptions()->IsPrtFormat() )
2313cdf0e10cSrcweir {
2314cdf0e10cSrcweir pOut = GetTxtNode()->getIDocumentDeviceAccess()->getReferenceDevice( true );
2315cdf0e10cSrcweir }
2316cdf0e10cSrcweir ASSERT( pOut, "<SwTxtFrm::_GetHeightOfLastLineForPropLineSpacing()> - no OutputDevice" );
2317cdf0e10cSrcweir // --> OD 2007-07-02 #i78921# - make code robust, according to provided patch
2318cdf0e10cSrcweir if ( !pOut )
2319cdf0e10cSrcweir {
2320cdf0e10cSrcweir return;
2321cdf0e10cSrcweir }
2322cdf0e10cSrcweir // <--
2323cdf0e10cSrcweir
2324cdf0e10cSrcweir // determine height of last line
2325cdf0e10cSrcweir
2326cdf0e10cSrcweir if ( _bUseFont || pIDSA->get(IDocumentSettingAccess::OLD_LINE_SPACING ) )
2327cdf0e10cSrcweir {
2328cdf0e10cSrcweir // former determination of last line height for proprotional line
2329cdf0e10cSrcweir // spacing - take height of font set at the paragraph
2330cdf0e10cSrcweir SwFont aFont( GetAttrSet(), pIDSA );
2331cdf0e10cSrcweir
2332cdf0e10cSrcweir // Wir muessen dafuer sorgen, dass am OutputDevice der Font
2333cdf0e10cSrcweir // korrekt restauriert wird, sonst droht ein Last!=Owner.
2334cdf0e10cSrcweir if ( pLastFont )
2335cdf0e10cSrcweir {
2336cdf0e10cSrcweir SwFntObj *pOldFont = pLastFont;
2337cdf0e10cSrcweir pLastFont = NULL;
2338cdf0e10cSrcweir aFont.SetFntChg( sal_True );
2339cdf0e10cSrcweir aFont.ChgPhysFnt( pVsh, *pOut );
2340cdf0e10cSrcweir mnHeightOfLastLine = aFont.GetHeight( pVsh, *pOut );
2341cdf0e10cSrcweir pLastFont->Unlock();
2342cdf0e10cSrcweir pLastFont = pOldFont;
2343cdf0e10cSrcweir pLastFont->SetDevFont( pVsh, *pOut );
2344cdf0e10cSrcweir }
2345cdf0e10cSrcweir else
2346cdf0e10cSrcweir {
2347cdf0e10cSrcweir Font aOldFont = pOut->GetFont();
2348cdf0e10cSrcweir aFont.SetFntChg( sal_True );
2349cdf0e10cSrcweir aFont.ChgPhysFnt( pVsh, *pOut );
2350cdf0e10cSrcweir mnHeightOfLastLine = aFont.GetHeight( pVsh, *pOut );
2351cdf0e10cSrcweir pLastFont->Unlock();
2352cdf0e10cSrcweir pLastFont = NULL;
2353cdf0e10cSrcweir pOut->SetFont( aOldFont );
2354cdf0e10cSrcweir }
2355cdf0e10cSrcweir }
2356cdf0e10cSrcweir else
2357cdf0e10cSrcweir {
2358cdf0e10cSrcweir // new determination of last line height - take actually height of last line
2359cdf0e10cSrcweir // --> OD 2008-05-06 #i89000#
2360cdf0e10cSrcweir // assure same results, if paragraph is undersized
2361cdf0e10cSrcweir if ( IsUndersized() )
2362cdf0e10cSrcweir {
2363cdf0e10cSrcweir mnHeightOfLastLine = 0;
2364cdf0e10cSrcweir }
2365cdf0e10cSrcweir else
2366cdf0e10cSrcweir {
2367cdf0e10cSrcweir bool bCalcHeightOfLastLine = true;
2368cdf0e10cSrcweir if ( !HasPara() )
2369cdf0e10cSrcweir {
2370cdf0e10cSrcweir if ( IsEmpty() )
2371cdf0e10cSrcweir {
2372cdf0e10cSrcweir mnHeightOfLastLine = EmptyHeight();
2373cdf0e10cSrcweir bCalcHeightOfLastLine = false;
2374cdf0e10cSrcweir }
2375cdf0e10cSrcweir }
2376cdf0e10cSrcweir
2377cdf0e10cSrcweir if ( bCalcHeightOfLastLine )
2378cdf0e10cSrcweir {
2379cdf0e10cSrcweir ASSERT( HasPara(),
2380cdf0e10cSrcweir "<SwTxtFrm::_CalcHeightOfLastLine()> - missing paragraph portions." );
2381cdf0e10cSrcweir const SwLineLayout* pLineLayout = GetPara();
2382cdf0e10cSrcweir while ( pLineLayout && pLineLayout->GetNext() )
2383cdf0e10cSrcweir {
2384cdf0e10cSrcweir // iteration to last line
2385cdf0e10cSrcweir pLineLayout = pLineLayout->GetNext();
2386cdf0e10cSrcweir }
2387cdf0e10cSrcweir if ( pLineLayout )
2388cdf0e10cSrcweir {
2389cdf0e10cSrcweir SwTwips nAscent, nDescent, nDummy1, nDummy2;
2390cdf0e10cSrcweir // --> OD 2005-05-20 #i47162# - suppress consideration of
2391cdf0e10cSrcweir // fly content portions and the line portion.
2392cdf0e10cSrcweir pLineLayout->MaxAscentDescent( nAscent, nDescent,
2393cdf0e10cSrcweir nDummy1, nDummy2,
2394cdf0e10cSrcweir 0, true );
2395cdf0e10cSrcweir // <--
2396cdf0e10cSrcweir // --> OD 2006-11-22 #i71281#
2397cdf0e10cSrcweir // Suppress wrong invalidation of printing area, if method is
2398cdf0e10cSrcweir // called recursive.
2399cdf0e10cSrcweir // Thus, member <mnHeightOfLastLine> is only set directly, if
2400cdf0e10cSrcweir // no recursive call is needed.
2401cdf0e10cSrcweir // mnHeightOfLastLine = nAscent + nDescent;
2402cdf0e10cSrcweir const SwTwips nNewHeightOfLastLine = nAscent + nDescent;
2403cdf0e10cSrcweir // --> OD 2005-05-20 #i47162# - if last line only contains
2404cdf0e10cSrcweir // fly content portions, <mnHeightOfLastLine> is zero.
2405cdf0e10cSrcweir // In this case determine height of last line by the font
2406cdf0e10cSrcweir if ( nNewHeightOfLastLine == 0 )
2407cdf0e10cSrcweir {
2408cdf0e10cSrcweir _CalcHeightOfLastLine( true );
2409cdf0e10cSrcweir }
2410cdf0e10cSrcweir else
2411cdf0e10cSrcweir {
2412cdf0e10cSrcweir mnHeightOfLastLine = nNewHeightOfLastLine;
2413cdf0e10cSrcweir }
2414cdf0e10cSrcweir // <--
2415cdf0e10cSrcweir // <--
2416cdf0e10cSrcweir }
2417cdf0e10cSrcweir }
2418cdf0e10cSrcweir }
2419cdf0e10cSrcweir // <--
2420cdf0e10cSrcweir }
2421cdf0e10cSrcweir // --> OD 2006-11-13 #i71281#
2422cdf0e10cSrcweir // invalidate printing area, if height of last line changes
2423cdf0e10cSrcweir if ( mnHeightOfLastLine != mnOldHeightOfLastLine )
2424cdf0e10cSrcweir {
2425cdf0e10cSrcweir InvalidatePrt();
2426cdf0e10cSrcweir }
2427cdf0e10cSrcweir // <--
2428cdf0e10cSrcweir }
2429cdf0e10cSrcweir
2430cdf0e10cSrcweir /*************************************************************************
2431cdf0e10cSrcweir * SwTxtFrm::GetLineSpace()
2432cdf0e10cSrcweir *************************************************************************/
2433cdf0e10cSrcweir // OD 07.01.2004 #i11859# - change return data type
2434cdf0e10cSrcweir // add default parameter <_bNoPropLineSpacing> to control, if the
2435cdf0e10cSrcweir // value of a proportional line spacing is returned or not
2436cdf0e10cSrcweir // OD 07.01.2004 - trying to describe purpose of method:
2437cdf0e10cSrcweir // Method returns the value of the inter line spacing for a text frame.
2438cdf0e10cSrcweir // Such a value exists for proportional line spacings ("1,5 Lines",
2439cdf0e10cSrcweir // "Double", "Proportional" and for leading line spacing ("Leading").
2440cdf0e10cSrcweir // By parameter <_bNoPropLineSpace> (default value false) it can be
2441cdf0e10cSrcweir // controlled, if the value of a proportional line spacing is returned.
GetLineSpace(const bool _bNoPropLineSpace) const2442cdf0e10cSrcweir long SwTxtFrm::GetLineSpace( const bool _bNoPropLineSpace ) const
2443cdf0e10cSrcweir {
2444cdf0e10cSrcweir long nRet = 0;
2445cdf0e10cSrcweir
2446cdf0e10cSrcweir const SwAttrSet* pSet = GetAttrSet();
2447cdf0e10cSrcweir const SvxLineSpacingItem &rSpace = pSet->GetLineSpacing();
2448cdf0e10cSrcweir
2449cdf0e10cSrcweir switch( rSpace.GetInterLineSpaceRule() )
2450cdf0e10cSrcweir {
2451cdf0e10cSrcweir case SVX_INTER_LINE_SPACE_PROP:
2452cdf0e10cSrcweir {
2453cdf0e10cSrcweir // OD 07.01.2004 #i11859#
2454cdf0e10cSrcweir if ( _bNoPropLineSpace )
2455cdf0e10cSrcweir {
2456cdf0e10cSrcweir break;
2457cdf0e10cSrcweir }
2458cdf0e10cSrcweir
2459cdf0e10cSrcweir // OD 2004-03-17 #i11860# - use method <GetHeightOfLastLine()>
2460cdf0e10cSrcweir nRet = GetHeightOfLastLine();
2461cdf0e10cSrcweir
2462cdf0e10cSrcweir long nTmp = nRet;
2463cdf0e10cSrcweir nTmp *= rSpace.GetPropLineSpace();
2464cdf0e10cSrcweir nTmp /= 100;
2465cdf0e10cSrcweir nTmp -= nRet;
2466cdf0e10cSrcweir if ( nTmp > 0 )
2467cdf0e10cSrcweir nRet = nTmp;
2468cdf0e10cSrcweir else
2469cdf0e10cSrcweir nRet = 0;
2470cdf0e10cSrcweir }
2471cdf0e10cSrcweir break;
2472cdf0e10cSrcweir case SVX_INTER_LINE_SPACE_FIX:
2473cdf0e10cSrcweir {
2474cdf0e10cSrcweir if ( rSpace.GetInterLineSpace() > 0 )
2475cdf0e10cSrcweir nRet = rSpace.GetInterLineSpace();
2476cdf0e10cSrcweir }
2477cdf0e10cSrcweir break;
2478cdf0e10cSrcweir default:
2479cdf0e10cSrcweir break;
2480cdf0e10cSrcweir }
2481cdf0e10cSrcweir return nRet;
2482cdf0e10cSrcweir }
2483cdf0e10cSrcweir
2484cdf0e10cSrcweir /*************************************************************************
2485cdf0e10cSrcweir * SwTxtFrm::FirstLineHeight()
2486cdf0e10cSrcweir *************************************************************************/
2487cdf0e10cSrcweir
FirstLineHeight() const2488cdf0e10cSrcweir KSHORT SwTxtFrm::FirstLineHeight() const
2489cdf0e10cSrcweir {
2490cdf0e10cSrcweir if ( !HasPara() )
2491cdf0e10cSrcweir {
2492cdf0e10cSrcweir if( IsEmpty() && IsValid() )
2493cdf0e10cSrcweir return IsVertical() ? (KSHORT)Prt().Width() : (KSHORT)Prt().Height();
2494cdf0e10cSrcweir return KSHRT_MAX;
2495cdf0e10cSrcweir }
2496cdf0e10cSrcweir const SwParaPortion *pPara = GetPara();
2497cdf0e10cSrcweir if ( !pPara )
2498cdf0e10cSrcweir return KSHRT_MAX;
2499cdf0e10cSrcweir
2500cdf0e10cSrcweir return pPara->Height();
2501cdf0e10cSrcweir }
2502cdf0e10cSrcweir
GetLineCount(xub_StrLen nPos)2503cdf0e10cSrcweir MSHORT SwTxtFrm::GetLineCount( xub_StrLen nPos )
2504cdf0e10cSrcweir {
2505cdf0e10cSrcweir MSHORT nRet = 0;
2506cdf0e10cSrcweir SwTxtFrm *pFrm = this;
2507cdf0e10cSrcweir do
2508cdf0e10cSrcweir {
2509cdf0e10cSrcweir pFrm->GetFormatted();
2510cdf0e10cSrcweir if( !pFrm->HasPara() )
2511cdf0e10cSrcweir break;
2512cdf0e10cSrcweir SwTxtSizeInfo aInf( pFrm );
2513cdf0e10cSrcweir SwTxtMargin aLine( pFrm, &aInf );
2514cdf0e10cSrcweir if( STRING_LEN == nPos )
2515cdf0e10cSrcweir aLine.Bottom();
2516cdf0e10cSrcweir else
2517cdf0e10cSrcweir aLine.CharToLine( nPos );
2518cdf0e10cSrcweir nRet = nRet + aLine.GetLineNr();
2519cdf0e10cSrcweir pFrm = pFrm->GetFollow();
2520cdf0e10cSrcweir } while ( pFrm && pFrm->GetOfst() <= nPos );
2521cdf0e10cSrcweir return nRet;
2522cdf0e10cSrcweir }
2523cdf0e10cSrcweir
ChgThisLines()2524cdf0e10cSrcweir void SwTxtFrm::ChgThisLines()
2525cdf0e10cSrcweir {
2526cdf0e10cSrcweir //not necassary to format here (GerFormatted etc.), because we have to come from there!
2527cdf0e10cSrcweir
2528cdf0e10cSrcweir sal_uLong nNew = 0;
2529cdf0e10cSrcweir const SwLineNumberInfo &rInf = GetNode()->getIDocumentLineNumberAccess()->GetLineNumberInfo();
2530cdf0e10cSrcweir if ( GetTxt().Len() && HasPara() )
2531cdf0e10cSrcweir {
2532cdf0e10cSrcweir SwTxtSizeInfo aInf( this );
2533cdf0e10cSrcweir SwTxtMargin aLine( this, &aInf );
2534cdf0e10cSrcweir if ( rInf.IsCountBlankLines() )
2535cdf0e10cSrcweir {
2536cdf0e10cSrcweir aLine.Bottom();
2537cdf0e10cSrcweir nNew = (sal_uLong)aLine.GetLineNr();
2538cdf0e10cSrcweir }
2539cdf0e10cSrcweir else
2540cdf0e10cSrcweir {
2541cdf0e10cSrcweir do
2542cdf0e10cSrcweir {
2543cdf0e10cSrcweir if( aLine.GetCurr()->HasCntnt() )
2544cdf0e10cSrcweir ++nNew;
2545cdf0e10cSrcweir } while ( aLine.NextLine() );
2546cdf0e10cSrcweir }
2547cdf0e10cSrcweir }
2548cdf0e10cSrcweir else if ( rInf.IsCountBlankLines() )
2549cdf0e10cSrcweir nNew = 1;
2550cdf0e10cSrcweir
2551cdf0e10cSrcweir if ( nNew != nThisLines )
2552cdf0e10cSrcweir {
2553cdf0e10cSrcweir if ( !IsInTab() && GetAttrSet()->GetLineNumber().IsCount() )
2554cdf0e10cSrcweir {
2555cdf0e10cSrcweir nAllLines -= nThisLines;
2556cdf0e10cSrcweir nThisLines = nNew;
2557cdf0e10cSrcweir nAllLines += nThisLines;
2558cdf0e10cSrcweir SwFrm *pNxt = GetNextCntntFrm();
2559cdf0e10cSrcweir while( pNxt && pNxt->IsInTab() )
2560cdf0e10cSrcweir {
2561cdf0e10cSrcweir if( 0 != (pNxt = pNxt->FindTabFrm()) )
2562cdf0e10cSrcweir pNxt = pNxt->FindNextCnt();
2563cdf0e10cSrcweir }
2564cdf0e10cSrcweir if( pNxt )
2565cdf0e10cSrcweir pNxt->InvalidateLineNum();
2566cdf0e10cSrcweir
2567cdf0e10cSrcweir //Extend repaint to the bottom.
2568cdf0e10cSrcweir if ( HasPara() )
2569cdf0e10cSrcweir {
2570cdf0e10cSrcweir SwRepaint *pRepaint = GetPara()->GetRepaint();
2571cdf0e10cSrcweir pRepaint->Bottom( Max( pRepaint->Bottom(),
2572cdf0e10cSrcweir Frm().Top()+Prt().Bottom()));
2573cdf0e10cSrcweir }
2574cdf0e10cSrcweir }
2575cdf0e10cSrcweir else //Paragraphs which are not counted should not manipulate the AllLines.
2576cdf0e10cSrcweir nThisLines = nNew;
2577cdf0e10cSrcweir }
2578cdf0e10cSrcweir
2579cdf0e10cSrcweir //mba: invalidating is not necessary; if mongolian script has a problem, it should be fixed at the ritgh place
2580cdf0e10cSrcweir //with invalidating we probably get too much flickering
2581cdf0e10cSrcweir //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
2582cdf0e10cSrcweir //Ugly. How can we hack if better?
2583cdf0e10cSrcweir //InvalidatePage();
2584cdf0e10cSrcweir }
2585cdf0e10cSrcweir
2586cdf0e10cSrcweir
RecalcAllLines()2587cdf0e10cSrcweir void SwTxtFrm::RecalcAllLines()
2588cdf0e10cSrcweir {
2589cdf0e10cSrcweir ValidateLineNum();
2590cdf0e10cSrcweir
2591cdf0e10cSrcweir const SwAttrSet *pAttrSet = GetAttrSet();
2592cdf0e10cSrcweir
2593cdf0e10cSrcweir if ( !IsInTab() )
2594cdf0e10cSrcweir {
2595cdf0e10cSrcweir const sal_uLong nOld = GetAllLines();
2596cdf0e10cSrcweir const SwFmtLineNumber &rLineNum = pAttrSet->GetLineNumber();
2597cdf0e10cSrcweir sal_uLong nNewNum;
2598cdf0e10cSrcweir const bool bRestart = GetTxtNode()->getIDocumentLineNumberAccess()->GetLineNumberInfo().IsRestartEachPage();
2599cdf0e10cSrcweir
2600cdf0e10cSrcweir if ( !IsFollow() && rLineNum.GetStartValue() && rLineNum.IsCount() )
2601cdf0e10cSrcweir nNewNum = rLineNum.GetStartValue() - 1;
2602cdf0e10cSrcweir //If it is a follow or not has not be considered if it is a restart at each page; the
2603cdf0e10cSrcweir //restart should also take affekt at follows.
2604cdf0e10cSrcweir else if ( bRestart && FindPageFrm()->FindFirstBodyCntnt() == this )
2605cdf0e10cSrcweir {
2606cdf0e10cSrcweir nNewNum = 0;
2607cdf0e10cSrcweir }
2608cdf0e10cSrcweir else
2609cdf0e10cSrcweir {
2610cdf0e10cSrcweir SwCntntFrm *pPrv = GetPrevCntntFrm();
2611cdf0e10cSrcweir while ( pPrv &&
2612cdf0e10cSrcweir (pPrv->IsInTab() || pPrv->IsInDocBody() != IsInDocBody()) )
2613cdf0e10cSrcweir pPrv = pPrv->GetPrevCntntFrm();
2614cdf0e10cSrcweir
2615cdf0e10cSrcweir // --> FME 2007-06-22 #i78254# Restart line numbering at page change:
2616cdf0e10cSrcweir // First body content may be in table!
2617cdf0e10cSrcweir if ( bRestart && pPrv && pPrv->FindPageFrm() != FindPageFrm() )
2618cdf0e10cSrcweir pPrv = 0;
2619cdf0e10cSrcweir // <--
2620cdf0e10cSrcweir
2621cdf0e10cSrcweir nNewNum = pPrv ? ((SwTxtFrm*)pPrv)->GetAllLines() : 0;
2622cdf0e10cSrcweir }
2623cdf0e10cSrcweir if ( rLineNum.IsCount() )
2624cdf0e10cSrcweir nNewNum += GetThisLines();
2625cdf0e10cSrcweir
2626cdf0e10cSrcweir if ( nOld != nNewNum )
2627cdf0e10cSrcweir {
2628cdf0e10cSrcweir nAllLines = nNewNum;
2629cdf0e10cSrcweir SwCntntFrm *pNxt = GetNextCntntFrm();
2630cdf0e10cSrcweir while ( pNxt &&
2631cdf0e10cSrcweir (pNxt->IsInTab() || pNxt->IsInDocBody() != IsInDocBody()) )
2632cdf0e10cSrcweir pNxt = pNxt->GetNextCntntFrm();
2633cdf0e10cSrcweir if ( pNxt )
2634cdf0e10cSrcweir {
2635cdf0e10cSrcweir if ( pNxt->GetUpper() != GetUpper() )
2636cdf0e10cSrcweir pNxt->InvalidateLineNum();
2637cdf0e10cSrcweir else
2638cdf0e10cSrcweir pNxt->_InvalidateLineNum();
2639cdf0e10cSrcweir }
2640cdf0e10cSrcweir }
2641cdf0e10cSrcweir }
2642cdf0e10cSrcweir }
2643cdf0e10cSrcweir
VisitPortions(SwPortionHandler & rPH) const2644cdf0e10cSrcweir void SwTxtFrm::VisitPortions( SwPortionHandler& rPH ) const
2645cdf0e10cSrcweir {
2646cdf0e10cSrcweir const SwParaPortion* pPara = GetPara();
2647cdf0e10cSrcweir
2648cdf0e10cSrcweir if( pPara )
2649cdf0e10cSrcweir {
2650cdf0e10cSrcweir if ( IsFollow() )
2651cdf0e10cSrcweir rPH.Skip( GetOfst() );
2652cdf0e10cSrcweir
2653cdf0e10cSrcweir const SwLineLayout* pLine = pPara;
2654cdf0e10cSrcweir while ( pLine )
2655cdf0e10cSrcweir {
2656cdf0e10cSrcweir const SwLinePortion* pPor = pLine->GetFirstPortion();
2657cdf0e10cSrcweir while ( pPor )
2658cdf0e10cSrcweir {
2659cdf0e10cSrcweir pPor->HandlePortion( rPH );
2660cdf0e10cSrcweir pPor = pPor->GetPortion();
2661cdf0e10cSrcweir }
2662cdf0e10cSrcweir
2663cdf0e10cSrcweir rPH.LineBreak();
2664cdf0e10cSrcweir pLine = pLine->GetNext();
2665cdf0e10cSrcweir }
2666cdf0e10cSrcweir }
2667cdf0e10cSrcweir
2668cdf0e10cSrcweir rPH.Finish();
2669cdf0e10cSrcweir }
2670cdf0e10cSrcweir
2671cdf0e10cSrcweir
2672cdf0e10cSrcweir /*************************************************************************
2673cdf0e10cSrcweir * SwTxtFrm::GetScriptInfo()
2674cdf0e10cSrcweir *************************************************************************/
2675cdf0e10cSrcweir
GetScriptInfo() const2676cdf0e10cSrcweir const SwScriptInfo* SwTxtFrm::GetScriptInfo() const
2677cdf0e10cSrcweir {
2678cdf0e10cSrcweir const SwParaPortion* pPara = GetPara();
2679cdf0e10cSrcweir return pPara ? &pPara->GetScriptInfo() : 0;
2680cdf0e10cSrcweir }
2681cdf0e10cSrcweir
2682cdf0e10cSrcweir /*************************************************************************
2683cdf0e10cSrcweir * lcl_CalcFlyBasePos()
2684cdf0e10cSrcweir * Helper function for SwTxtFrm::CalcBasePosForFly()
2685cdf0e10cSrcweir *************************************************************************/
2686cdf0e10cSrcweir
lcl_CalcFlyBasePos(const SwTxtFrm & rFrm,SwRect aFlyRect,SwTxtFly & rTxtFly)2687cdf0e10cSrcweir SwTwips lcl_CalcFlyBasePos( const SwTxtFrm& rFrm, SwRect aFlyRect,
2688cdf0e10cSrcweir SwTxtFly& rTxtFly )
2689cdf0e10cSrcweir {
2690cdf0e10cSrcweir SWRECTFN( (&rFrm) )
2691cdf0e10cSrcweir SwTwips nRet = rFrm.IsRightToLeft() ?
2692cdf0e10cSrcweir (rFrm.Frm().*fnRect->fnGetRight)() :
2693cdf0e10cSrcweir (rFrm.Frm().*fnRect->fnGetLeft)();
2694cdf0e10cSrcweir
2695cdf0e10cSrcweir do
2696cdf0e10cSrcweir {
2697cdf0e10cSrcweir SwRect aRect = rTxtFly.GetFrm( aFlyRect );
2698cdf0e10cSrcweir if ( 0 != (aRect.*fnRect->fnGetWidth)() )
2699cdf0e10cSrcweir {
2700cdf0e10cSrcweir if ( rFrm.IsRightToLeft() )
2701cdf0e10cSrcweir {
2702cdf0e10cSrcweir if ( (aRect.*fnRect->fnGetRight)() -
2703cdf0e10cSrcweir (aFlyRect.*fnRect->fnGetRight)() >= 0 )
2704cdf0e10cSrcweir {
2705cdf0e10cSrcweir (aFlyRect.*fnRect->fnSetRight)(
2706cdf0e10cSrcweir (aRect.*fnRect->fnGetLeft)() );
2707cdf0e10cSrcweir nRet = (aRect.*fnRect->fnGetLeft)();
2708cdf0e10cSrcweir }
2709cdf0e10cSrcweir else
2710cdf0e10cSrcweir break;
2711cdf0e10cSrcweir }
2712cdf0e10cSrcweir else
2713cdf0e10cSrcweir {
2714cdf0e10cSrcweir if ( (aFlyRect.*fnRect->fnGetLeft)() -
2715cdf0e10cSrcweir (aRect.*fnRect->fnGetLeft)() >= 0 )
2716cdf0e10cSrcweir {
2717cdf0e10cSrcweir (aFlyRect.*fnRect->fnSetLeft)(
2718cdf0e10cSrcweir (aRect.*fnRect->fnGetRight)() + 1 );
2719cdf0e10cSrcweir nRet = (aRect.*fnRect->fnGetRight)();
2720cdf0e10cSrcweir }
2721cdf0e10cSrcweir else
2722cdf0e10cSrcweir break;
2723cdf0e10cSrcweir }
2724cdf0e10cSrcweir }
2725cdf0e10cSrcweir else
2726cdf0e10cSrcweir break;
2727cdf0e10cSrcweir }
2728cdf0e10cSrcweir while ( (aFlyRect.*fnRect->fnGetWidth)() > 0 );
2729cdf0e10cSrcweir
2730cdf0e10cSrcweir return nRet;
2731cdf0e10cSrcweir }
2732cdf0e10cSrcweir
2733cdf0e10cSrcweir /*************************************************************************
2734cdf0e10cSrcweir * SwTxtFrm::CalcBasePosForFly()
2735cdf0e10cSrcweir *************************************************************************/
2736cdf0e10cSrcweir
CalcBaseOfstForFly()2737cdf0e10cSrcweir void SwTxtFrm::CalcBaseOfstForFly()
2738cdf0e10cSrcweir {
2739cdf0e10cSrcweir ASSERT( !IsVertical() || !IsSwapped(),
2740cdf0e10cSrcweir "SwTxtFrm::CalcBasePosForFly with swapped frame!" )
2741cdf0e10cSrcweir
2742cdf0e10cSrcweir const SwNode* pNode = GetTxtNode();
2743cdf0e10cSrcweir if ( !pNode->getIDocumentSettingAccess()->get(IDocumentSettingAccess::ADD_FLY_OFFSETS) )
2744cdf0e10cSrcweir return;
2745cdf0e10cSrcweir
2746cdf0e10cSrcweir SWRECTFN( this )
2747cdf0e10cSrcweir
2748cdf0e10cSrcweir SwRect aFlyRect( Frm().Pos() + Prt().Pos(), Prt().SSize() );
2749cdf0e10cSrcweir
2750cdf0e10cSrcweir // Get first 'real' line and adjust position and height of line rectangle
2751cdf0e10cSrcweir // OD 08.09.2003 #110978#, #108749#, #110354# - correct behaviour,
2752cdf0e10cSrcweir // if no 'real' line exists (empty paragraph with and without a dummy portion)
2753cdf0e10cSrcweir {
2754cdf0e10cSrcweir SwTwips nTop = (aFlyRect.*fnRect->fnGetTop)();
2755cdf0e10cSrcweir const SwLineLayout* pLay = GetPara();
2756cdf0e10cSrcweir SwTwips nLineHeight = 200;
2757cdf0e10cSrcweir while( pLay && pLay->IsDummy() && pLay->GetNext() )
2758cdf0e10cSrcweir {
2759cdf0e10cSrcweir nTop += pLay->Height();
2760cdf0e10cSrcweir pLay = pLay->GetNext();
2761cdf0e10cSrcweir }
2762cdf0e10cSrcweir if ( pLay )
2763cdf0e10cSrcweir {
2764cdf0e10cSrcweir nLineHeight = pLay->Height();
2765cdf0e10cSrcweir }
2766cdf0e10cSrcweir (aFlyRect.*fnRect->fnSetTopAndHeight)( nTop, nLineHeight );
2767cdf0e10cSrcweir }
2768cdf0e10cSrcweir
2769cdf0e10cSrcweir SwTxtFly aTxtFly( this );
2770cdf0e10cSrcweir aTxtFly.SetIgnoreCurrentFrame( sal_True );
2771cdf0e10cSrcweir aTxtFly.SetIgnoreContour( sal_True );
2772cdf0e10cSrcweir // --> OD 2004-12-17 #118809# - ignore objects in page header|footer for
2773cdf0e10cSrcweir // text frames not in page header|footer
2774cdf0e10cSrcweir aTxtFly.SetIgnoreObjsInHeaderFooter( sal_True );
2775cdf0e10cSrcweir // <--
2776cdf0e10cSrcweir SwTwips nRet1 = lcl_CalcFlyBasePos( *this, aFlyRect, aTxtFly );
2777cdf0e10cSrcweir aTxtFly.SetIgnoreCurrentFrame( sal_False );
2778cdf0e10cSrcweir SwTwips nRet2 = lcl_CalcFlyBasePos( *this, aFlyRect, aTxtFly );
2779cdf0e10cSrcweir
2780cdf0e10cSrcweir // make values relative to frame start position
2781cdf0e10cSrcweir SwTwips nLeft = IsRightToLeft() ?
2782cdf0e10cSrcweir (Frm().*fnRect->fnGetRight)() :
2783cdf0e10cSrcweir (Frm().*fnRect->fnGetLeft)();
2784cdf0e10cSrcweir
2785cdf0e10cSrcweir mnFlyAnchorOfst = nRet1 - nLeft;
2786cdf0e10cSrcweir mnFlyAnchorOfstNoWrap = nRet2 - nLeft;
2787cdf0e10cSrcweir }
2788cdf0e10cSrcweir
2789cdf0e10cSrcweir /* repaint all text frames of the given text node */
repaintTextFrames(const SwTxtNode & rNode)2790cdf0e10cSrcweir void SwTxtFrm::repaintTextFrames( const SwTxtNode& rNode )
2791cdf0e10cSrcweir {
2792cdf0e10cSrcweir SwIterator<SwTxtFrm,SwTxtNode> aIter( rNode );
2793cdf0e10cSrcweir for( const SwTxtFrm *pFrm = aIter.First(); pFrm; pFrm = aIter.Next() )
2794cdf0e10cSrcweir {
2795cdf0e10cSrcweir SwRect aRec( pFrm->PaintArea() );
2796cdf0e10cSrcweir const SwRootFrm *pRootFrm = pFrm->getRootFrm();
2797cdf0e10cSrcweir ViewShell *pCurShell = pRootFrm ? pRootFrm->GetCurrShell() : NULL;
2798cdf0e10cSrcweir if( pCurShell )
2799cdf0e10cSrcweir pCurShell->InvalidateWindows( aRec );
2800cdf0e10cSrcweir }
2801cdf0e10cSrcweir }
2802cdf0e10cSrcweir
2803