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
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include <hintids.hxx>
29cdf0e10cSrcweir
30cdf0e10cSrcweir #include <com/sun/star/i18n/ScriptType.hdl>
31cdf0e10cSrcweir #include <vcl/graph.hxx>
32cdf0e10cSrcweir #include <editeng/brshitem.hxx>
33cdf0e10cSrcweir #include <vcl/metric.hxx>
34cdf0e10cSrcweir #include <vcl/outdev.hxx>
35cdf0e10cSrcweir #include <viewopt.hxx> // SwViewOptions
36cdf0e10cSrcweir #include <txtcfg.hxx>
37cdf0e10cSrcweir #include <SwPortionHandler.hxx>
38cdf0e10cSrcweir #include <porlay.hxx>
39cdf0e10cSrcweir #include <porfld.hxx>
40cdf0e10cSrcweir #include <inftxt.hxx>
41cdf0e10cSrcweir #include <blink.hxx> // pBlink
42cdf0e10cSrcweir #include <frmtool.hxx> // DrawGraphic
43cdf0e10cSrcweir #include <viewsh.hxx>
44cdf0e10cSrcweir #include <docsh.hxx>
45cdf0e10cSrcweir #include <doc.hxx>
46cdf0e10cSrcweir #include "rootfrm.hxx"
47cdf0e10cSrcweir #include <breakit.hxx>
48cdf0e10cSrcweir #include <porrst.hxx>
49cdf0e10cSrcweir #include <porftn.hxx> // SwFtnPortion
50cdf0e10cSrcweir #include <accessibilityoptions.hxx>
51cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
52cdf0e10cSrcweir
53cdf0e10cSrcweir #include <unicode/ubidi.h>
54cdf0e10cSrcweir
55cdf0e10cSrcweir using namespace ::com::sun::star;
56cdf0e10cSrcweir
57cdf0e10cSrcweir /*************************************************************************
58cdf0e10cSrcweir * class SwFldPortion
59cdf0e10cSrcweir *************************************************************************/
60cdf0e10cSrcweir
Compress()61cdf0e10cSrcweir SwLinePortion *SwFldPortion::Compress()
62cdf0e10cSrcweir { return (GetLen() || aExpand.Len() || SwLinePortion::Compress()) ? this : 0; }
63cdf0e10cSrcweir
Clone(const XubString & rExpand) const64cdf0e10cSrcweir SwFldPortion *SwFldPortion::Clone( const XubString &rExpand ) const
65cdf0e10cSrcweir {
66cdf0e10cSrcweir SwFont *pNewFnt;
67cdf0e10cSrcweir if( 0 != ( pNewFnt = pFnt ) )
68cdf0e10cSrcweir {
69cdf0e10cSrcweir pNewFnt = new SwFont( *pFnt );
70cdf0e10cSrcweir }
71cdf0e10cSrcweir SwFldPortion* pClone = new SwFldPortion( rExpand, pNewFnt, bPlaceHolder );
72cdf0e10cSrcweir pClone->SetNextOffset( nNextOffset );
73cdf0e10cSrcweir pClone->m_bNoLength = this->m_bNoLength;
74cdf0e10cSrcweir return pClone;
75cdf0e10cSrcweir }
76cdf0e10cSrcweir
TakeNextOffset(const SwFldPortion * pFld)77cdf0e10cSrcweir void SwFldPortion::TakeNextOffset( const SwFldPortion* pFld )
78cdf0e10cSrcweir {
79cdf0e10cSrcweir ASSERT( pFld, "TakeNextOffset: Missing Source" );
80cdf0e10cSrcweir nNextOffset = pFld->GetNextOffset();
81cdf0e10cSrcweir aExpand.Erase( 0, nNextOffset );
82cdf0e10cSrcweir bFollow = sal_True;
83cdf0e10cSrcweir }
84cdf0e10cSrcweir
SwFldPortion(const XubString & rExpand,SwFont * pFont,sal_Bool bPlaceHold)85cdf0e10cSrcweir SwFldPortion::SwFldPortion( const XubString &rExpand, SwFont *pFont, sal_Bool bPlaceHold )
86cdf0e10cSrcweir : aExpand(rExpand), pFnt(pFont), nNextOffset(0), nNextScriptChg(STRING_LEN), nViewWidth(0),
87cdf0e10cSrcweir bFollow( sal_False ), bHasFollow( sal_False ), bPlaceHolder( bPlaceHold )
88cdf0e10cSrcweir , m_bNoLength( sal_False )
89cdf0e10cSrcweir {
90cdf0e10cSrcweir SetWhichPor( POR_FLD );
91*ca62e2c2SSteve Yin m_nAttrFldType = 0;
92cdf0e10cSrcweir }
93cdf0e10cSrcweir
SwFldPortion(const SwFldPortion & rFld)94cdf0e10cSrcweir SwFldPortion::SwFldPortion( const SwFldPortion& rFld )
95cdf0e10cSrcweir : SwExpandPortion( rFld ),
96cdf0e10cSrcweir aExpand( rFld.GetExp() ),
97cdf0e10cSrcweir nNextOffset( rFld.GetNextOffset() ),
98cdf0e10cSrcweir nNextScriptChg( rFld.GetNextScriptChg() ),
99cdf0e10cSrcweir bFollow( rFld.IsFollow() ),
100cdf0e10cSrcweir bLeft( rFld.IsLeft() ),
101cdf0e10cSrcweir bHide( rFld.IsHide() ),
102cdf0e10cSrcweir bCenter( rFld.IsCenter() ),
103cdf0e10cSrcweir bHasFollow( rFld.HasFollow() ),
104cdf0e10cSrcweir bPlaceHolder( rFld.bPlaceHolder )
105cdf0e10cSrcweir , m_bNoLength( rFld.m_bNoLength )
106cdf0e10cSrcweir {
107cdf0e10cSrcweir if ( rFld.HasFont() )
108cdf0e10cSrcweir pFnt = new SwFont( *rFld.GetFont() );
109cdf0e10cSrcweir else
110cdf0e10cSrcweir pFnt = 0;
111cdf0e10cSrcweir
112cdf0e10cSrcweir SetWhichPor( POR_FLD );
113cdf0e10cSrcweir }
114cdf0e10cSrcweir
~SwFldPortion()115cdf0e10cSrcweir SwFldPortion::~SwFldPortion()
116cdf0e10cSrcweir {
117cdf0e10cSrcweir delete pFnt;
118cdf0e10cSrcweir if( pBlink )
119cdf0e10cSrcweir pBlink->Delete( this );
120cdf0e10cSrcweir }
121cdf0e10cSrcweir
122cdf0e10cSrcweir /*************************************************************************
123cdf0e10cSrcweir * virtual SwFldPortion::GetViewWidth()
124cdf0e10cSrcweir *************************************************************************/
125cdf0e10cSrcweir
GetViewWidth(const SwTxtSizeInfo & rInf) const126cdf0e10cSrcweir KSHORT SwFldPortion::GetViewWidth( const SwTxtSizeInfo &rInf ) const
127cdf0e10cSrcweir {
128cdf0e10cSrcweir // Wir stehen zwar im const, aber nViewWidth sollte erst im letzten
129cdf0e10cSrcweir // Moment errechnet werden:
130cdf0e10cSrcweir SwFldPortion* pThis = (SwFldPortion*)this;
131cdf0e10cSrcweir if( !Width() && rInf.OnWin() && !rInf.GetOpt().IsPagePreview() &&
132cdf0e10cSrcweir !rInf.GetOpt().IsReadonly() && SwViewOption::IsFieldShadings() )
133cdf0e10cSrcweir {
134cdf0e10cSrcweir if( !nViewWidth )
135cdf0e10cSrcweir pThis->nViewWidth = rInf.GetTxtSize( ' ' ).Width();
136cdf0e10cSrcweir }
137cdf0e10cSrcweir else
138cdf0e10cSrcweir pThis->nViewWidth = 0;
139cdf0e10cSrcweir return nViewWidth;
140cdf0e10cSrcweir }
141cdf0e10cSrcweir
142cdf0e10cSrcweir /*************************************************************************
143cdf0e10cSrcweir * virtual SwFldPortion::Format()
144cdf0e10cSrcweir *************************************************************************/
145cdf0e10cSrcweir
146cdf0e10cSrcweir // 8653: in keinem Fall nur SetLen(0);
147cdf0e10cSrcweir
148cdf0e10cSrcweir /*************************************************************************
149cdf0e10cSrcweir * Hilfsklasse SwFldSlot
150cdf0e10cSrcweir **************************************************************************/
151cdf0e10cSrcweir
152cdf0e10cSrcweir class SwFldSlot
153cdf0e10cSrcweir {
154cdf0e10cSrcweir const XubString *pOldTxt;
155cdf0e10cSrcweir XubString aTxt;
156cdf0e10cSrcweir xub_StrLen nIdx;
157cdf0e10cSrcweir xub_StrLen nLen;
158cdf0e10cSrcweir sal_Bool bOn;
159cdf0e10cSrcweir SwTxtFormatInfo *pInf;
160cdf0e10cSrcweir public:
161cdf0e10cSrcweir SwFldSlot( const SwTxtFormatInfo* pNew, const SwFldPortion *pPor );
162cdf0e10cSrcweir ~SwFldSlot();
163cdf0e10cSrcweir };
164cdf0e10cSrcweir
SwFldSlot(const SwTxtFormatInfo * pNew,const SwFldPortion * pPor)165cdf0e10cSrcweir SwFldSlot::SwFldSlot( const SwTxtFormatInfo* pNew, const SwFldPortion *pPor )
166cdf0e10cSrcweir {
167cdf0e10cSrcweir bOn = pPor->GetExpTxt( *pNew, aTxt );
168cdf0e10cSrcweir
169cdf0e10cSrcweir // Der Text wird ausgetauscht...
170cdf0e10cSrcweir if( bOn )
171cdf0e10cSrcweir {
172cdf0e10cSrcweir pInf = (SwTxtFormatInfo*)pNew;
173cdf0e10cSrcweir nIdx = pInf->GetIdx();
174cdf0e10cSrcweir nLen = pInf->GetLen();
175cdf0e10cSrcweir pOldTxt = &(pInf->GetTxt());
176cdf0e10cSrcweir pInf->SetLen( aTxt.Len() );
177cdf0e10cSrcweir if( pPor->IsFollow() )
178cdf0e10cSrcweir {
179cdf0e10cSrcweir pInf->SetFakeLineStart( nIdx > pInf->GetLineStart() );
180cdf0e10cSrcweir pInf->SetIdx( 0 );
181cdf0e10cSrcweir }
182cdf0e10cSrcweir else
183cdf0e10cSrcweir {
184cdf0e10cSrcweir XubString aTmp( aTxt );
185cdf0e10cSrcweir aTxt = *pOldTxt;
186cdf0e10cSrcweir aTxt.Erase( nIdx, 1 );
187cdf0e10cSrcweir aTxt.Insert( aTmp, nIdx );
188cdf0e10cSrcweir }
189cdf0e10cSrcweir pInf->SetTxt( aTxt );
190cdf0e10cSrcweir }
191cdf0e10cSrcweir }
192cdf0e10cSrcweir
~SwFldSlot()193cdf0e10cSrcweir SwFldSlot::~SwFldSlot()
194cdf0e10cSrcweir {
195cdf0e10cSrcweir if( bOn )
196cdf0e10cSrcweir {
197cdf0e10cSrcweir pInf->SetTxt( *pOldTxt );
198cdf0e10cSrcweir pInf->SetIdx( nIdx );
199cdf0e10cSrcweir pInf->SetLen( nLen );
200cdf0e10cSrcweir pInf->SetFakeLineStart( sal_False );
201cdf0e10cSrcweir }
202cdf0e10cSrcweir }
203cdf0e10cSrcweir
CheckScript(const SwTxtSizeInfo & rInf)204cdf0e10cSrcweir void SwFldPortion::CheckScript( const SwTxtSizeInfo &rInf )
205cdf0e10cSrcweir {
206cdf0e10cSrcweir String aTxt;
207cdf0e10cSrcweir if( GetExpTxt( rInf, aTxt ) && aTxt.Len() && pBreakIt->GetBreakIter().is() )
208cdf0e10cSrcweir {
209cdf0e10cSrcweir sal_uInt8 nActual = pFnt ? pFnt->GetActual() : rInf.GetFont()->GetActual();
210cdf0e10cSrcweir sal_uInt16 nScript;
211cdf0e10cSrcweir {
212cdf0e10cSrcweir nScript = pBreakIt->GetBreakIter()->getScriptType( aTxt, 0 );
213cdf0e10cSrcweir xub_StrLen nChg = 0;
214cdf0e10cSrcweir if( i18n::ScriptType::WEAK == nScript )
215cdf0e10cSrcweir {
216cdf0e10cSrcweir nChg =(xub_StrLen)pBreakIt->GetBreakIter()->endOfScript(aTxt,0,nScript);
217cdf0e10cSrcweir if( nChg < aTxt.Len() )
218cdf0e10cSrcweir nScript = pBreakIt->GetBreakIter()->getScriptType( aTxt, nChg );
219cdf0e10cSrcweir }
220cdf0e10cSrcweir
221cdf0e10cSrcweir //
222cdf0e10cSrcweir // nNextScriptChg will be evaluated during SwFldPortion::Format()
223cdf0e10cSrcweir //
224cdf0e10cSrcweir if ( nChg < aTxt.Len() )
225cdf0e10cSrcweir nNextScriptChg = (xub_StrLen)pBreakIt->GetBreakIter()->endOfScript( aTxt, nChg, nScript );
226cdf0e10cSrcweir else
227cdf0e10cSrcweir nNextScriptChg = aTxt.Len();
228cdf0e10cSrcweir
229cdf0e10cSrcweir }
230cdf0e10cSrcweir sal_uInt8 nTmp;
231cdf0e10cSrcweir switch ( nScript ) {
232cdf0e10cSrcweir case i18n::ScriptType::LATIN : nTmp = SW_LATIN; break;
233cdf0e10cSrcweir case i18n::ScriptType::ASIAN : nTmp = SW_CJK; break;
234cdf0e10cSrcweir case i18n::ScriptType::COMPLEX : nTmp = SW_CTL; break;
235cdf0e10cSrcweir default: nTmp = nActual;
236cdf0e10cSrcweir }
237cdf0e10cSrcweir
238cdf0e10cSrcweir // #i16354# Change script type for RTL text to CTL.
239cdf0e10cSrcweir const SwScriptInfo& rSI = rInf.GetParaPortion()->GetScriptInfo();
240cdf0e10cSrcweir // --> OD 2009-01-29 #i98418#
241cdf0e10cSrcweir // const sal_uInt8 nFldDir = IsNumberPortion() ?
242cdf0e10cSrcweir const sal_uInt8 nFldDir = ( IsNumberPortion() || IsFtnNumPortion() ) ?
243cdf0e10cSrcweir rSI.GetDefaultDir() :
244cdf0e10cSrcweir rSI.DirType( IsFollow() ? rInf.GetIdx() - 1 : rInf.GetIdx() );
245cdf0e10cSrcweir // <--
246cdf0e10cSrcweir if ( UBIDI_RTL == nFldDir )
247cdf0e10cSrcweir {
248cdf0e10cSrcweir UErrorCode nError = U_ZERO_ERROR;
249cdf0e10cSrcweir UBiDi* pBidi = ubidi_openSized( aTxt.Len(), 0, &nError );
250cdf0e10cSrcweir ubidi_setPara( pBidi, reinterpret_cast<const UChar *>(aTxt.GetBuffer()), aTxt.Len(), nFldDir, NULL, &nError );
251cdf0e10cSrcweir int32_t nEnd;
252cdf0e10cSrcweir UBiDiLevel nCurrDir;
253cdf0e10cSrcweir ubidi_getLogicalRun( pBidi, 0, &nEnd, &nCurrDir );
254cdf0e10cSrcweir ubidi_close( pBidi );
255cdf0e10cSrcweir const xub_StrLen nNextDirChg = (xub_StrLen)nEnd;
256cdf0e10cSrcweir nNextScriptChg = Min( nNextScriptChg, nNextDirChg );
257cdf0e10cSrcweir
258cdf0e10cSrcweir // #i89825# change the script type also to CTL
259cdf0e10cSrcweir // if there is no strong LTR char in the LTR run (numbers)
260cdf0e10cSrcweir if ( nCurrDir != UBIDI_RTL )
261cdf0e10cSrcweir {
262cdf0e10cSrcweir nCurrDir = UBIDI_RTL;
263cdf0e10cSrcweir for ( xub_StrLen nCharIdx = 0; nCharIdx < nEnd; ++nCharIdx )
264cdf0e10cSrcweir {
265cdf0e10cSrcweir UCharDirection nCharDir = u_charDirection ( aTxt.GetChar ( nCharIdx ));
266cdf0e10cSrcweir if ( nCharDir == U_LEFT_TO_RIGHT ||
267cdf0e10cSrcweir nCharDir == U_LEFT_TO_RIGHT_EMBEDDING ||
268cdf0e10cSrcweir nCharDir == U_LEFT_TO_RIGHT_OVERRIDE )
269cdf0e10cSrcweir {
270cdf0e10cSrcweir nCurrDir = UBIDI_LTR;
271cdf0e10cSrcweir break;
272cdf0e10cSrcweir }
273cdf0e10cSrcweir }
274cdf0e10cSrcweir }
275cdf0e10cSrcweir
276cdf0e10cSrcweir if ( nCurrDir == UBIDI_RTL )
277cdf0e10cSrcweir nTmp = SW_CTL;
278cdf0e10cSrcweir }
279cdf0e10cSrcweir
280cdf0e10cSrcweir // --> OD 2009-01-29 #i98418#
281cdf0e10cSrcweir // keep determined script type for footnote portions as preferred script type.
282cdf0e10cSrcweir // For footnote portions a font can not be created directly - see footnote
283cdf0e10cSrcweir // portion format method.
284cdf0e10cSrcweir // if( !IsFtnPortion() && nTmp != nActual )
285cdf0e10cSrcweir if ( IsFtnPortion() )
286cdf0e10cSrcweir {
287cdf0e10cSrcweir dynamic_cast<SwFtnPortion*>(this)->SetPreferredScriptType( nTmp );
288cdf0e10cSrcweir }
289cdf0e10cSrcweir else if ( nTmp != nActual )
290cdf0e10cSrcweir {
291cdf0e10cSrcweir if( !pFnt )
292cdf0e10cSrcweir pFnt = new SwFont( *rInf.GetFont() );
293cdf0e10cSrcweir pFnt->SetActual( nTmp );
294cdf0e10cSrcweir }
295cdf0e10cSrcweir // <--
296cdf0e10cSrcweir }
297cdf0e10cSrcweir }
298cdf0e10cSrcweir
Format(SwTxtFormatInfo & rInf)299cdf0e10cSrcweir sal_Bool SwFldPortion::Format( SwTxtFormatInfo &rInf )
300cdf0e10cSrcweir {
301cdf0e10cSrcweir // Scope wegen aDiffTxt::DTOR!
302cdf0e10cSrcweir xub_StrLen nRest;
303cdf0e10cSrcweir sal_Bool bFull;
304cdf0e10cSrcweir sal_Bool bEOL = sal_False;
305cdf0e10cSrcweir long nTxtRest = rInf.GetTxt().Len() - rInf.GetIdx();
306cdf0e10cSrcweir {
307cdf0e10cSrcweir SwFldSlot aDiffTxt( &rInf, this );
308cdf0e10cSrcweir SwLayoutModeModifier aLayoutModeModifier( *rInf.GetOut() );
309cdf0e10cSrcweir aLayoutModeModifier.SetAuto();
310cdf0e10cSrcweir
311cdf0e10cSrcweir // Field portion has to be split in several parts if
312cdf0e10cSrcweir // 1. There are script/direction changes inside the field
313cdf0e10cSrcweir // 2. There are portion breaks (tab, break) inside the field:
314cdf0e10cSrcweir const xub_StrLen nOldFullLen = rInf.GetLen();
315cdf0e10cSrcweir xub_StrLen nFullLen = rInf.ScanPortionEnd( rInf.GetIdx(), rInf.GetIdx() + nOldFullLen ) - rInf.GetIdx();
316cdf0e10cSrcweir if ( nNextScriptChg < nFullLen )
317cdf0e10cSrcweir {
318cdf0e10cSrcweir nFullLen = nNextScriptChg;
319cdf0e10cSrcweir rInf.SetHookChar( 0 );
320cdf0e10cSrcweir }
321cdf0e10cSrcweir rInf.SetLen( nFullLen );
322cdf0e10cSrcweir
323cdf0e10cSrcweir if ( STRING_LEN != rInf.GetUnderScorePos() &&
324cdf0e10cSrcweir rInf.GetUnderScorePos() > rInf.GetIdx() )
325cdf0e10cSrcweir rInf.SetUnderScorePos( rInf.GetIdx() );
326cdf0e10cSrcweir
327cdf0e10cSrcweir if( pFnt )
328cdf0e10cSrcweir pFnt->GoMagic( rInf.GetVsh(), pFnt->GetActual() );
329cdf0e10cSrcweir
330cdf0e10cSrcweir SwFontSave aSave( rInf, pFnt );
331cdf0e10cSrcweir
332cdf0e10cSrcweir // 8674: Laenge muss 0 sein, bei bFull nach Format ist die Laenge
333cdf0e10cSrcweir // gesetzt und wird in nRest uebertragen. Ansonsten bleibt die
334cdf0e10cSrcweir // Laenge erhalten und wuerde auch in nRest einfliessen!
335cdf0e10cSrcweir SetLen(0);
336cdf0e10cSrcweir const MSHORT nFollow = IsFollow() ? 0 : 1;
337cdf0e10cSrcweir
338cdf0e10cSrcweir // So komisch es aussieht, die Abfrage auf GetLen() muss wegen der
339cdf0e10cSrcweir // ExpandPortions _hinter_ aDiffTxt (vgl. SoftHyphs)
340cdf0e10cSrcweir // sal_False returnen wegen SetFull ...
341cdf0e10cSrcweir if( !nFullLen )
342cdf0e10cSrcweir {
343cdf0e10cSrcweir // nicht Init(), weil wir Hoehe und Ascent brauchen
344cdf0e10cSrcweir Width(0);
345cdf0e10cSrcweir bFull = rInf.Width() <= rInf.GetPos().X();
346cdf0e10cSrcweir }
347cdf0e10cSrcweir else
348cdf0e10cSrcweir {
349cdf0e10cSrcweir xub_StrLen nOldLineStart = rInf.GetLineStart();
350cdf0e10cSrcweir if( IsFollow() )
351cdf0e10cSrcweir rInf.SetLineStart( 0 );
352cdf0e10cSrcweir rInf.SetNotEOL( nFullLen == nOldFullLen && nTxtRest > nFollow );
353cdf0e10cSrcweir
354cdf0e10cSrcweir // the height depending on the fields font is set,
355cdf0e10cSrcweir // this is required for SwTxtGuess::Guess
356cdf0e10cSrcweir Height( rInf.GetTxtHeight() );
357cdf0e10cSrcweir // If a kerning portion is inserted after our field portion,
358cdf0e10cSrcweir // the ascent and height must be known
359cdf0e10cSrcweir SetAscent( rInf.GetAscent() );
360cdf0e10cSrcweir bFull = SwTxtPortion::Format( rInf );
361cdf0e10cSrcweir rInf.SetNotEOL( sal_False );
362cdf0e10cSrcweir rInf.SetLineStart( nOldLineStart );
363cdf0e10cSrcweir }
364cdf0e10cSrcweir xub_StrLen nTmpLen = GetLen();
365cdf0e10cSrcweir bEOL = !nTmpLen && nFollow && bFull;
366cdf0e10cSrcweir nRest = nOldFullLen - nTmpLen;
367cdf0e10cSrcweir
368cdf0e10cSrcweir // Das Zeichen wird in der ersten Portion gehalten.
369cdf0e10cSrcweir // Unbedingt nach Format!
370cdf0e10cSrcweir SetLen( (m_bNoLength) ? 0 : nFollow );
371cdf0e10cSrcweir
372cdf0e10cSrcweir if( nRest )
373cdf0e10cSrcweir {
374cdf0e10cSrcweir // aExpand ist noch nicht gekuerzt worden, der neue Ofst
375cdf0e10cSrcweir // ergibt sich durch nRest.
376cdf0e10cSrcweir xub_StrLen nNextOfst = aExpand.Len() - nRest;
377cdf0e10cSrcweir
378cdf0e10cSrcweir if ( IsQuoVadisPortion() )
379cdf0e10cSrcweir nNextOfst = nNextOfst + ((SwQuoVadisPortion*)this)->GetContTxt().Len();
380cdf0e10cSrcweir
381cdf0e10cSrcweir XubString aNew( aExpand, nNextOfst, STRING_LEN );
382cdf0e10cSrcweir aExpand.Erase( nNextOfst, STRING_LEN );
383cdf0e10cSrcweir
384cdf0e10cSrcweir // These characters should not be contained in the follow
385cdf0e10cSrcweir // field portion. They are handled via the HookChar mechanism.
386cdf0e10cSrcweir switch( aNew.GetChar( 0 ))
387cdf0e10cSrcweir {
388cdf0e10cSrcweir case CH_BREAK : bFull = sal_True;
389cdf0e10cSrcweir // kein break;
390cdf0e10cSrcweir case ' ' :
391cdf0e10cSrcweir case CH_TAB :
392cdf0e10cSrcweir case CHAR_HARDHYPHEN: // non-breaking hyphen
393cdf0e10cSrcweir case CHAR_SOFTHYPHEN:
394cdf0e10cSrcweir case CHAR_HARDBLANK:
395cdf0e10cSrcweir case CHAR_ZWSP :
396cdf0e10cSrcweir case CHAR_ZWNBSP :
397cdf0e10cSrcweir case CH_TXTATR_BREAKWORD:
398cdf0e10cSrcweir case CH_TXTATR_INWORD:
399cdf0e10cSrcweir {
400cdf0e10cSrcweir aNew.Erase( 0, 1 );
401cdf0e10cSrcweir ++nNextOfst;
402cdf0e10cSrcweir break;
403cdf0e10cSrcweir }
404cdf0e10cSrcweir default: ;
405cdf0e10cSrcweir }
406cdf0e10cSrcweir
407cdf0e10cSrcweir // Even if there is no more text left for a follow field,
408cdf0e10cSrcweir // we have to build a follow field portion (without font),
409cdf0e10cSrcweir // otherwise the HookChar mechanism would not work.
410cdf0e10cSrcweir SwFldPortion *pFld = Clone( aNew );
411cdf0e10cSrcweir if( aNew.Len() && !pFld->GetFont() )
412cdf0e10cSrcweir {
413cdf0e10cSrcweir SwFont *pNewFnt = new SwFont( *rInf.GetFont() );
414cdf0e10cSrcweir pFld->SetFont( pNewFnt );
415cdf0e10cSrcweir }
416cdf0e10cSrcweir pFld->SetFollow( sal_True );
417cdf0e10cSrcweir SetHasFollow( sal_True );
418cdf0e10cSrcweir // In nNextOffset steht bei einem neuangelegten Feld zunaechst
419cdf0e10cSrcweir // der Offset, an dem es selbst im Originalstring beginnt.
420cdf0e10cSrcweir // Wenn beim Formatieren ein FollowFeld angelegt wird, wird
421cdf0e10cSrcweir // der Offset dieses FollowFelds in nNextOffset festgehalten.
422cdf0e10cSrcweir nNextOffset = nNextOffset + nNextOfst;
423cdf0e10cSrcweir pFld->SetNextOffset( nNextOffset );
424cdf0e10cSrcweir rInf.SetRest( pFld );
425cdf0e10cSrcweir }
426cdf0e10cSrcweir }
427cdf0e10cSrcweir
428cdf0e10cSrcweir if( bEOL && rInf.GetLast() && !rInf.GetUnderFlow() )
429cdf0e10cSrcweir rInf.GetLast()->FormatEOL( rInf );
430cdf0e10cSrcweir return bFull;
431cdf0e10cSrcweir }
432cdf0e10cSrcweir
433cdf0e10cSrcweir /*************************************************************************
434cdf0e10cSrcweir * virtual SwFldPortion::Paint()
435cdf0e10cSrcweir *************************************************************************/
436cdf0e10cSrcweir
Paint(const SwTxtPaintInfo & rInf) const437cdf0e10cSrcweir void SwFldPortion::Paint( const SwTxtPaintInfo &rInf ) const
438cdf0e10cSrcweir {
439cdf0e10cSrcweir SwFontSave aSave( rInf, pFnt );
440cdf0e10cSrcweir
441cdf0e10cSrcweir ASSERT( GetLen() <= 1, "SwFldPortion::Paint: rest-portion polution?" );
442cdf0e10cSrcweir if( Width() && ( !bPlaceHolder || rInf.GetOpt().IsShowPlaceHolderFields() ) )
443cdf0e10cSrcweir {
444cdf0e10cSrcweir // Dies ist eine freizuegige Auslegung der Hintergrundbelegung ...
445cdf0e10cSrcweir rInf.DrawViewOpt( *this, POR_FLD );
446cdf0e10cSrcweir SwExpandPortion::Paint( rInf );
447cdf0e10cSrcweir }
448cdf0e10cSrcweir }
449cdf0e10cSrcweir
450cdf0e10cSrcweir /*************************************************************************
451cdf0e10cSrcweir * virtual SwFldPortion::GetExpTxt()
452cdf0e10cSrcweir *************************************************************************/
453cdf0e10cSrcweir
GetExpTxt(const SwTxtSizeInfo & rInf,XubString & rTxt) const454cdf0e10cSrcweir sal_Bool SwFldPortion::GetExpTxt( const SwTxtSizeInfo &rInf, XubString &rTxt ) const
455cdf0e10cSrcweir {
456cdf0e10cSrcweir rTxt = aExpand;
457cdf0e10cSrcweir if( !rTxt.Len() && rInf.OnWin() &&
458cdf0e10cSrcweir !rInf.GetOpt().IsPagePreview() && !rInf.GetOpt().IsReadonly() &&
459cdf0e10cSrcweir SwViewOption::IsFieldShadings() &&
460cdf0e10cSrcweir !HasFollow() )
461cdf0e10cSrcweir rTxt = ' ';
462cdf0e10cSrcweir return sal_True;
463cdf0e10cSrcweir }
464cdf0e10cSrcweir
465cdf0e10cSrcweir /*************************************************************************
466cdf0e10cSrcweir * virtual SwFldPortion::HandlePortion()
467cdf0e10cSrcweir *************************************************************************/
468cdf0e10cSrcweir
HandlePortion(SwPortionHandler & rPH) const469cdf0e10cSrcweir void SwFldPortion::HandlePortion( SwPortionHandler& rPH ) const
470cdf0e10cSrcweir {
471cdf0e10cSrcweir rPH.Special( GetLen(), aExpand, GetWhichPor() );
472*ca62e2c2SSteve Yin if( GetWhichPor() == POR_FLD )
473*ca62e2c2SSteve Yin {
474*ca62e2c2SSteve Yin rPH.SetAttrFieldType(m_nAttrFldType);
475*ca62e2c2SSteve Yin }
476cdf0e10cSrcweir }
477cdf0e10cSrcweir
478cdf0e10cSrcweir /*************************************************************************
479cdf0e10cSrcweir * virtual SwFldPortion::GetTxtSize()
480cdf0e10cSrcweir *************************************************************************/
481cdf0e10cSrcweir
GetTxtSize(const SwTxtSizeInfo & rInf) const482cdf0e10cSrcweir SwPosSize SwFldPortion::GetTxtSize( const SwTxtSizeInfo &rInf ) const
483cdf0e10cSrcweir {
484cdf0e10cSrcweir SwFontSave aSave( rInf, pFnt );
485cdf0e10cSrcweir SwPosSize aSize( SwExpandPortion::GetTxtSize( rInf ) );
486cdf0e10cSrcweir return aSize;
487cdf0e10cSrcweir }
488cdf0e10cSrcweir
489cdf0e10cSrcweir /*************************************************************************
490cdf0e10cSrcweir * class SwHiddenPortion
491cdf0e10cSrcweir *************************************************************************/
492cdf0e10cSrcweir
Clone(const XubString & rExpand) const493cdf0e10cSrcweir SwFldPortion *SwHiddenPortion::Clone(const XubString &rExpand ) const
494cdf0e10cSrcweir {
495cdf0e10cSrcweir SwFont *pNewFnt;
496cdf0e10cSrcweir if( 0 != ( pNewFnt = pFnt ) )
497cdf0e10cSrcweir pNewFnt = new SwFont( *pFnt );
498cdf0e10cSrcweir return new SwHiddenPortion( rExpand, pNewFnt );
499cdf0e10cSrcweir }
500cdf0e10cSrcweir
501cdf0e10cSrcweir /*************************************************************************
502cdf0e10cSrcweir * virtual SwHiddenPortion::Paint()
503cdf0e10cSrcweir *************************************************************************/
504cdf0e10cSrcweir
Paint(const SwTxtPaintInfo & rInf) const505cdf0e10cSrcweir void SwHiddenPortion::Paint( const SwTxtPaintInfo &rInf ) const
506cdf0e10cSrcweir {
507cdf0e10cSrcweir if( Width() )
508cdf0e10cSrcweir {
509cdf0e10cSrcweir SwFontSave aSave( rInf, pFnt );
510cdf0e10cSrcweir rInf.DrawViewOpt( *this, POR_HIDDEN );
511cdf0e10cSrcweir SwExpandPortion::Paint( rInf );
512cdf0e10cSrcweir }
513cdf0e10cSrcweir }
514cdf0e10cSrcweir
515cdf0e10cSrcweir /*************************************************************************
516cdf0e10cSrcweir * virtual SwHiddenPortion::GetExpTxt()
517cdf0e10cSrcweir *************************************************************************/
518cdf0e10cSrcweir
GetExpTxt(const SwTxtSizeInfo & rInf,XubString & rTxt) const519cdf0e10cSrcweir sal_Bool SwHiddenPortion::GetExpTxt( const SwTxtSizeInfo &rInf, XubString &rTxt ) const
520cdf0e10cSrcweir {
521cdf0e10cSrcweir // Nicht auf IsHidden() abfragen !
522cdf0e10cSrcweir return SwFldPortion::GetExpTxt( rInf, rTxt );
523cdf0e10cSrcweir }
524cdf0e10cSrcweir
525cdf0e10cSrcweir /*************************************************************************
526cdf0e10cSrcweir * class SwNumberPortion
527cdf0e10cSrcweir *************************************************************************/
528cdf0e10cSrcweir
529cdf0e10cSrcweir // --> OD 2008-01-23 #newlistlevelattrs#
SwNumberPortion(const XubString & rExpand,SwFont * pFont,const sal_Bool bLft,const sal_Bool bCntr,const KSHORT nMinDst,const bool bLabelAlignmentPosAndSpaceModeActive)530cdf0e10cSrcweir SwNumberPortion::SwNumberPortion( const XubString &rExpand,
531cdf0e10cSrcweir SwFont *pFont,
532cdf0e10cSrcweir const sal_Bool bLft,
533cdf0e10cSrcweir const sal_Bool bCntr,
534cdf0e10cSrcweir const KSHORT nMinDst,
535cdf0e10cSrcweir const bool bLabelAlignmentPosAndSpaceModeActive )
536cdf0e10cSrcweir : SwFldPortion( rExpand, pFont ),
537cdf0e10cSrcweir nFixWidth(0),
538cdf0e10cSrcweir nMinDist( nMinDst ),
539cdf0e10cSrcweir // --> OD 2008-01-23 #newlistlevelattrs#
540cdf0e10cSrcweir mbLabelAlignmentPosAndSpaceModeActive( bLabelAlignmentPosAndSpaceModeActive )
541cdf0e10cSrcweir // <--
542cdf0e10cSrcweir {
543cdf0e10cSrcweir SetWhichPor( POR_NUMBER );
544cdf0e10cSrcweir SetLeft( bLft );
545cdf0e10cSrcweir SetHide( sal_False );
546cdf0e10cSrcweir SetCenter( bCntr );
547cdf0e10cSrcweir }
548cdf0e10cSrcweir
GetCrsrOfst(const MSHORT) const549cdf0e10cSrcweir xub_StrLen SwNumberPortion::GetCrsrOfst( const MSHORT ) const
550cdf0e10cSrcweir {
551cdf0e10cSrcweir return 0;
552cdf0e10cSrcweir }
553cdf0e10cSrcweir
Clone(const XubString & rExpand) const554cdf0e10cSrcweir SwFldPortion *SwNumberPortion::Clone( const XubString &rExpand ) const
555cdf0e10cSrcweir {
556cdf0e10cSrcweir SwFont *pNewFnt;
557cdf0e10cSrcweir if( 0 != ( pNewFnt = pFnt ) )
558cdf0e10cSrcweir pNewFnt = new SwFont( *pFnt );
559cdf0e10cSrcweir // --> OD 2008-01-23 #newlistlevelattrs#
560cdf0e10cSrcweir return new SwNumberPortion( rExpand, pNewFnt, IsLeft(), IsCenter(),
561cdf0e10cSrcweir nMinDist, mbLabelAlignmentPosAndSpaceModeActive );
562cdf0e10cSrcweir // <--
563cdf0e10cSrcweir }
564cdf0e10cSrcweir
565cdf0e10cSrcweir /*************************************************************************
566cdf0e10cSrcweir * virtual SwNumberPortion::Format()
567cdf0e10cSrcweir *************************************************************************/
568cdf0e10cSrcweir
569cdf0e10cSrcweir // 5010: Wir sind in der Lage, mehrzeilige NumFelder anzulegen!
570cdf0e10cSrcweir // 3689: Fies ist, wenn man in der Dialogbox soviel Davor-Text
571cdf0e10cSrcweir // eingibt, bis die Zeile ueberlaeuft.
572cdf0e10cSrcweir // Man muss die Fly-Ausweichmanoever beachten!
573cdf0e10cSrcweir
Format(SwTxtFormatInfo & rInf)574cdf0e10cSrcweir sal_Bool SwNumberPortion::Format( SwTxtFormatInfo &rInf )
575cdf0e10cSrcweir {
576cdf0e10cSrcweir SetHide( sal_False );
577cdf0e10cSrcweir const sal_Bool bFull = SwFldPortion::Format( rInf );
578cdf0e10cSrcweir SetLen( 0 );
579cdf0e10cSrcweir // a numbering portion can be contained in a rotated portion!!!
580cdf0e10cSrcweir nFixWidth = rInf.IsMulti() ? Height() : Width();
581cdf0e10cSrcweir rInf.SetNumDone( !rInf.GetRest() );
582cdf0e10cSrcweir if( rInf.IsNumDone() )
583cdf0e10cSrcweir {
584cdf0e10cSrcweir // SetAscent( rInf.GetAscent() );
585cdf0e10cSrcweir ASSERT( Height() && nAscent, "NumberPortions without Height | Ascent" );
586cdf0e10cSrcweir
587cdf0e10cSrcweir long nDiff( 0 );
588cdf0e10cSrcweir // --> OD 2008-01-23 #newlistlevelattrs#
589cdf0e10cSrcweir if ( !mbLabelAlignmentPosAndSpaceModeActive )
590cdf0e10cSrcweir {
591cdf0e10cSrcweir if ( !rInf.GetTxtFrm()->GetTxtNode()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::IGNORE_FIRST_LINE_INDENT_IN_NUMBERING) &&
592cdf0e10cSrcweir // --> FME 2004-08-13 #i32902#
593cdf0e10cSrcweir !IsFtnNumPortion() )
594cdf0e10cSrcweir // <--
595cdf0e10cSrcweir {
596cdf0e10cSrcweir nDiff = rInf.Left()
597cdf0e10cSrcweir + rInf.GetTxtFrm()->GetTxtNode()->
598cdf0e10cSrcweir GetSwAttrSet().GetLRSpace().GetTxtFirstLineOfst()
599cdf0e10cSrcweir - rInf.First()
600cdf0e10cSrcweir + rInf.ForcedLeftMargin();
601cdf0e10cSrcweir }
602cdf0e10cSrcweir else
603cdf0e10cSrcweir {
604cdf0e10cSrcweir nDiff = rInf.Left() - rInf.First() + rInf.ForcedLeftMargin();
605cdf0e10cSrcweir }
606cdf0e10cSrcweir }
607cdf0e10cSrcweir // <--
608cdf0e10cSrcweir // Ein Vorschlag von Juergen und Volkmar:
609cdf0e10cSrcweir // Der Textteil hinter der Numerierung sollte immer
610cdf0e10cSrcweir // mindestens beim linken Rand beginnen.
611cdf0e10cSrcweir if( nDiff < 0 )
612cdf0e10cSrcweir nDiff = 0;
613cdf0e10cSrcweir else if ( nDiff > rInf.X() )
614cdf0e10cSrcweir nDiff -= rInf.X();
615cdf0e10cSrcweir else
616cdf0e10cSrcweir nDiff = 0;
617cdf0e10cSrcweir
618cdf0e10cSrcweir if( nDiff < nFixWidth + nMinDist )
619cdf0e10cSrcweir nDiff = nFixWidth + nMinDist;
620cdf0e10cSrcweir // 2739: Numerierung weicht Fly aus, kein nDiff in der zweiten Runde
621cdf0e10cSrcweir // fieser Sonderfall: FlyFrm liegt in dem Bereich,
622cdf0e10cSrcweir // den wir uns gerade unter den Nagel reissen wollen.
623cdf0e10cSrcweir // Die NumberPortion wird als verborgen markiert.
624cdf0e10cSrcweir const sal_Bool bFly = rInf.GetFly() ||
625cdf0e10cSrcweir ( rInf.GetLast() && rInf.GetLast()->IsFlyPortion() );
626cdf0e10cSrcweir if( nDiff > rInf.Width() )
627cdf0e10cSrcweir {
628cdf0e10cSrcweir nDiff = rInf.Width();
629cdf0e10cSrcweir if ( bFly )
630cdf0e10cSrcweir SetHide( sal_True );
631cdf0e10cSrcweir }
632cdf0e10cSrcweir
633cdf0e10cSrcweir // A numbering portion can be inside a SwRotatedPortion. Then the
634cdf0e10cSrcweir // Height has to be changed
635cdf0e10cSrcweir if ( rInf.IsMulti() )
636cdf0e10cSrcweir {
637cdf0e10cSrcweir if ( Height() < nDiff )
638cdf0e10cSrcweir Height( KSHORT( nDiff ) );
639cdf0e10cSrcweir }
640cdf0e10cSrcweir else if( Width() < nDiff )
641cdf0e10cSrcweir Width( KSHORT(nDiff) );
642cdf0e10cSrcweir }
643cdf0e10cSrcweir return bFull;
644cdf0e10cSrcweir }
645cdf0e10cSrcweir
FormatEOL(SwTxtFormatInfo &)646cdf0e10cSrcweir void SwNumberPortion::FormatEOL( SwTxtFormatInfo& )
647cdf0e10cSrcweir {
648cdf0e10cSrcweir /* Ein FormatEOL deutet daraufhin, dass der folgende Text
649cdf0e10cSrcweir * nicht mit auf die Zeile passte. Damit die Numerierung mitwandert,
650cdf0e10cSrcweir * wird diese NumberPortion verborgen.
651cdf0e10cSrcweir */
652cdf0e10cSrcweir
653cdf0e10cSrcweir // This caused trouble with flys anchored as characters.
654cdf0e10cSrcweir // If one of these is numbered but does not fit to the line,
655cdf0e10cSrcweir // it calls this function, causing a loop because both the number
656cdf0e10cSrcweir // portion and the fly portion go to the next line
657cdf0e10cSrcweir // SetHide( sal_True );
658cdf0e10cSrcweir }
659cdf0e10cSrcweir
660cdf0e10cSrcweir /*************************************************************************
661cdf0e10cSrcweir * virtual SwNumberPortion::Paint()
662cdf0e10cSrcweir *************************************************************************/
663cdf0e10cSrcweir
Paint(const SwTxtPaintInfo & rInf) const664cdf0e10cSrcweir void SwNumberPortion::Paint( const SwTxtPaintInfo &rInf ) const
665cdf0e10cSrcweir {
666cdf0e10cSrcweir /* Eine verborgene NumberPortion wird nicht angezeigt, es sei denn, es gibt
667cdf0e10cSrcweir * Textportions in dieser Zeile oder es gibt ueberhaupt nur eine einzige Zeile.
668cdf0e10cSrcweir */
669cdf0e10cSrcweir
670cdf0e10cSrcweir if ( IsHide() && rInf.GetParaPortion() && rInf.GetParaPortion()->GetNext() )
671cdf0e10cSrcweir {
672cdf0e10cSrcweir SwLinePortion *pTmp = GetPortion();
673cdf0e10cSrcweir while ( pTmp && !pTmp->InTxtGrp() )
674cdf0e10cSrcweir pTmp = pTmp->GetPortion();
675cdf0e10cSrcweir if ( !pTmp )
676cdf0e10cSrcweir return;
677cdf0e10cSrcweir }
678cdf0e10cSrcweir
679cdf0e10cSrcweir // calculate the width of the number portion, including follows
680cdf0e10cSrcweir const KSHORT nOldWidth = Width();
681cdf0e10cSrcweir sal_uInt16 nSumWidth = 0;
682cdf0e10cSrcweir sal_uInt16 nOffset = 0;
683cdf0e10cSrcweir
684cdf0e10cSrcweir const SwLinePortion* pTmp = this;
685cdf0e10cSrcweir while ( pTmp && pTmp->InNumberGrp() )
686cdf0e10cSrcweir {
687cdf0e10cSrcweir nSumWidth = nSumWidth + pTmp->Width();
688cdf0e10cSrcweir if ( ((SwNumberPortion*)pTmp)->HasFollow() )
689cdf0e10cSrcweir pTmp = pTmp->GetPortion();
690cdf0e10cSrcweir else
691cdf0e10cSrcweir {
692cdf0e10cSrcweir nOffset = pTmp->Width() - ((SwNumberPortion*)pTmp)->nFixWidth;
693cdf0e10cSrcweir break;
694cdf0e10cSrcweir }
695cdf0e10cSrcweir }
696cdf0e10cSrcweir
697cdf0e10cSrcweir // The master portion takes care for painting the background of the
698cdf0e10cSrcweir // follow field portions
699cdf0e10cSrcweir if ( ! IsFollow() )
700cdf0e10cSrcweir {
701cdf0e10cSrcweir SwLinePortion *pThis = (SwLinePortion*)this;
702cdf0e10cSrcweir pThis->Width( nSumWidth );
703cdf0e10cSrcweir rInf.DrawViewOpt( *this, POR_NUMBER );
704cdf0e10cSrcweir pThis->Width( nOldWidth );
705cdf0e10cSrcweir }
706cdf0e10cSrcweir
707cdf0e10cSrcweir if( aExpand.Len() )
708cdf0e10cSrcweir {
709cdf0e10cSrcweir const SwFont *pTmpFnt = rInf.GetFont();
710cdf0e10cSrcweir sal_Bool bPaintSpace = ( UNDERLINE_NONE != pTmpFnt->GetUnderline() ||
711cdf0e10cSrcweir UNDERLINE_NONE != pTmpFnt->GetOverline() ||
712cdf0e10cSrcweir STRIKEOUT_NONE != pTmpFnt->GetStrikeout() ) &&
713cdf0e10cSrcweir !pTmpFnt->IsWordLineMode();
714cdf0e10cSrcweir if( bPaintSpace && pFnt )
715cdf0e10cSrcweir bPaintSpace = ( UNDERLINE_NONE != pFnt->GetUnderline() ||
716cdf0e10cSrcweir UNDERLINE_NONE != pFnt->GetOverline() ||
717cdf0e10cSrcweir STRIKEOUT_NONE != pFnt->GetStrikeout() ) &&
718cdf0e10cSrcweir !pFnt->IsWordLineMode();
719cdf0e10cSrcweir
720cdf0e10cSrcweir SwFontSave aSave( rInf, pFnt );
721cdf0e10cSrcweir
722cdf0e10cSrcweir if( nFixWidth == Width() && ! HasFollow() )
723cdf0e10cSrcweir SwExpandPortion::Paint( rInf );
724cdf0e10cSrcweir else
725cdf0e10cSrcweir {
726cdf0e10cSrcweir // logisches const: Width wird wieder zurueckgesetzt
727cdf0e10cSrcweir SwLinePortion *pThis = (SwLinePortion*)this;
728cdf0e10cSrcweir bPaintSpace = bPaintSpace && nFixWidth < nOldWidth;
729cdf0e10cSrcweir KSHORT nSpaceOffs = nFixWidth;
730cdf0e10cSrcweir pThis->Width( nFixWidth );
731cdf0e10cSrcweir
732cdf0e10cSrcweir if( ( IsLeft() && ! rInf.GetTxtFrm()->IsRightToLeft() ) ||
733cdf0e10cSrcweir ( ! IsLeft() && ! IsCenter() && rInf.GetTxtFrm()->IsRightToLeft() ) )
734cdf0e10cSrcweir SwExpandPortion::Paint( rInf );
735cdf0e10cSrcweir else
736cdf0e10cSrcweir {
737cdf0e10cSrcweir SwTxtPaintInfo aInf( rInf );
738cdf0e10cSrcweir if( nOffset < nMinDist )
739cdf0e10cSrcweir nOffset = 0;
740cdf0e10cSrcweir else
741cdf0e10cSrcweir {
742cdf0e10cSrcweir if( IsCenter() )
743cdf0e10cSrcweir {
744cdf0e10cSrcweir /* #110778# a / 2 * 2 == a is not a tautology */
745cdf0e10cSrcweir KSHORT nTmpOffset = nOffset;
746cdf0e10cSrcweir nOffset /= 2;
747cdf0e10cSrcweir if( nOffset < nMinDist )
748cdf0e10cSrcweir nOffset = nTmpOffset - nMinDist;
749cdf0e10cSrcweir }
750cdf0e10cSrcweir else
751cdf0e10cSrcweir nOffset = nOffset - nMinDist;
752cdf0e10cSrcweir }
753cdf0e10cSrcweir aInf.X( aInf.X() + nOffset );
754cdf0e10cSrcweir SwExpandPortion::Paint( aInf );
755cdf0e10cSrcweir if( bPaintSpace )
756cdf0e10cSrcweir nSpaceOffs = nSpaceOffs + nOffset;
757cdf0e10cSrcweir }
758cdf0e10cSrcweir if( bPaintSpace && nOldWidth > nSpaceOffs )
759cdf0e10cSrcweir {
760cdf0e10cSrcweir SwTxtPaintInfo aInf( rInf );
761cdf0e10cSrcweir static sal_Char __READONLY_DATA sDoubleSpace[] = " ";
762cdf0e10cSrcweir aInf.X( aInf.X() + nSpaceOffs );
763cdf0e10cSrcweir
764cdf0e10cSrcweir // --> FME 2005-08-12 #i53199# Adjust position of underline:
765cdf0e10cSrcweir if ( rInf.GetUnderFnt() )
766cdf0e10cSrcweir {
767cdf0e10cSrcweir const Point aNewPos( aInf.GetPos().X(), rInf.GetUnderFnt()->GetPos().Y() );
768cdf0e10cSrcweir rInf.GetUnderFnt()->SetPos( aNewPos );
769cdf0e10cSrcweir }
770cdf0e10cSrcweir // <--
771cdf0e10cSrcweir
772cdf0e10cSrcweir pThis->Width( nOldWidth - nSpaceOffs + 12 );
773cdf0e10cSrcweir {
774cdf0e10cSrcweir SwTxtSlot aDiffTxt( &aInf, this, true, false, sDoubleSpace );
775cdf0e10cSrcweir aInf.DrawText( *this, aInf.GetLen(), sal_True );
776cdf0e10cSrcweir }
777cdf0e10cSrcweir }
778cdf0e10cSrcweir pThis->Width( nOldWidth );
779cdf0e10cSrcweir }
780cdf0e10cSrcweir }
781cdf0e10cSrcweir }
782cdf0e10cSrcweir
783cdf0e10cSrcweir
784cdf0e10cSrcweir /*************************************************************************
785cdf0e10cSrcweir * class SwBulletPortion
786cdf0e10cSrcweir *************************************************************************/
787cdf0e10cSrcweir
788cdf0e10cSrcweir // --> OD 2008-01-23 #newlistlevelattrs#
SwBulletPortion(const xub_Unicode cBullet,const XubString & rBulletFollowedBy,SwFont * pFont,const sal_Bool bLft,const sal_Bool bCntr,const KSHORT nMinDst,const bool bLabelAlignmentPosAndSpaceModeActive)789cdf0e10cSrcweir SwBulletPortion::SwBulletPortion( const xub_Unicode cBullet,
790cdf0e10cSrcweir const XubString& rBulletFollowedBy,
791cdf0e10cSrcweir SwFont *pFont,
792cdf0e10cSrcweir const sal_Bool bLft,
793cdf0e10cSrcweir const sal_Bool bCntr,
794cdf0e10cSrcweir const KSHORT nMinDst,
795cdf0e10cSrcweir const bool bLabelAlignmentPosAndSpaceModeActive )
796cdf0e10cSrcweir : SwNumberPortion( XubString( rBulletFollowedBy ).Insert( cBullet, 0 ) ,
797cdf0e10cSrcweir pFont, bLft, bCntr, nMinDst,
798cdf0e10cSrcweir bLabelAlignmentPosAndSpaceModeActive )
799cdf0e10cSrcweir // <--
800cdf0e10cSrcweir {
801cdf0e10cSrcweir SetWhichPor( POR_BULLET );
802cdf0e10cSrcweir }
803cdf0e10cSrcweir
804cdf0e10cSrcweir /*************************************************************************
805cdf0e10cSrcweir * class SwGrfNumPortion
806cdf0e10cSrcweir *************************************************************************/
807cdf0e10cSrcweir
808cdf0e10cSrcweir #define GRFNUM_SECURE 10
809cdf0e10cSrcweir
810cdf0e10cSrcweir // --> OD 2008-01-23 #newlistlevelattrs#
SwGrfNumPortion(SwFrm *,const XubString & rGraphicFollowedBy,const SvxBrushItem * pGrfBrush,const SwFmtVertOrient * pGrfOrient,const Size & rGrfSize,const sal_Bool bLft,const sal_Bool bCntr,const KSHORT nMinDst,const bool bLabelAlignmentPosAndSpaceModeActive)811cdf0e10cSrcweir SwGrfNumPortion::SwGrfNumPortion(
812cdf0e10cSrcweir SwFrm*,
813cdf0e10cSrcweir const XubString& rGraphicFollowedBy,
814cdf0e10cSrcweir const SvxBrushItem* pGrfBrush,
815cdf0e10cSrcweir const SwFmtVertOrient* pGrfOrient, const Size& rGrfSize,
816cdf0e10cSrcweir const sal_Bool bLft, const sal_Bool bCntr, const KSHORT nMinDst,
817cdf0e10cSrcweir const bool bLabelAlignmentPosAndSpaceModeActive ) :
818cdf0e10cSrcweir SwNumberPortion( rGraphicFollowedBy, NULL, bLft, bCntr, nMinDst,
819cdf0e10cSrcweir bLabelAlignmentPosAndSpaceModeActive ),
820cdf0e10cSrcweir // <--
821cdf0e10cSrcweir pBrush( new SvxBrushItem(RES_BACKGROUND) ), nId( 0 )
822cdf0e10cSrcweir {
823cdf0e10cSrcweir SetWhichPor( POR_GRFNUM );
824cdf0e10cSrcweir SetAnimated( sal_False );
825cdf0e10cSrcweir bReplace = sal_False;
826cdf0e10cSrcweir if( pGrfBrush )
827cdf0e10cSrcweir {
828cdf0e10cSrcweir *pBrush = *pGrfBrush;
829cdf0e10cSrcweir const Graphic* pGraph = pGrfBrush->GetGraphic();
830cdf0e10cSrcweir if( pGraph )
831cdf0e10cSrcweir SetAnimated( pGraph->IsAnimated() );
832cdf0e10cSrcweir else
833cdf0e10cSrcweir bReplace = sal_True;
834cdf0e10cSrcweir }
835cdf0e10cSrcweir if( pGrfOrient )
836cdf0e10cSrcweir {
837cdf0e10cSrcweir nYPos = pGrfOrient->GetPos();
838cdf0e10cSrcweir eOrient = pGrfOrient->GetVertOrient();
839cdf0e10cSrcweir }
840cdf0e10cSrcweir else
841cdf0e10cSrcweir {
842cdf0e10cSrcweir nYPos = 0;
843cdf0e10cSrcweir eOrient = text::VertOrientation::TOP;
844cdf0e10cSrcweir }
845cdf0e10cSrcweir Width( static_cast<sal_uInt16>(rGrfSize.Width() + 2 * GRFNUM_SECURE) );
846cdf0e10cSrcweir nFixWidth = Width();
847cdf0e10cSrcweir nGrfHeight = rGrfSize.Height() + 2 * GRFNUM_SECURE;
848cdf0e10cSrcweir Height( KSHORT(nGrfHeight) );
849cdf0e10cSrcweir bNoPaint = sal_False;
850cdf0e10cSrcweir }
851cdf0e10cSrcweir
~SwGrfNumPortion()852cdf0e10cSrcweir SwGrfNumPortion::~SwGrfNumPortion()
853cdf0e10cSrcweir {
854cdf0e10cSrcweir if ( IsAnimated() )
855cdf0e10cSrcweir ( (Graphic*) pBrush->GetGraphic() )->StopAnimation( 0, nId );
856cdf0e10cSrcweir delete pBrush;
857cdf0e10cSrcweir }
858cdf0e10cSrcweir
StopAnimation(OutputDevice * pOut)859cdf0e10cSrcweir void SwGrfNumPortion::StopAnimation( OutputDevice* pOut )
860cdf0e10cSrcweir {
861cdf0e10cSrcweir if ( IsAnimated() )
862cdf0e10cSrcweir ( (Graphic*) pBrush->GetGraphic() )->StopAnimation( pOut, nId );
863cdf0e10cSrcweir }
864cdf0e10cSrcweir
Format(SwTxtFormatInfo & rInf)865cdf0e10cSrcweir sal_Bool SwGrfNumPortion::Format( SwTxtFormatInfo &rInf )
866cdf0e10cSrcweir {
867cdf0e10cSrcweir SetHide( sal_False );
868cdf0e10cSrcweir // --> OD 2008-01-29 #newlistlevelattrs#
869cdf0e10cSrcweir // Width( nFixWidth );
870cdf0e10cSrcweir KSHORT nFollowedByWidth( 0 );
871cdf0e10cSrcweir if ( mbLabelAlignmentPosAndSpaceModeActive )
872cdf0e10cSrcweir {
873cdf0e10cSrcweir SwFldPortion::Format( rInf );
874cdf0e10cSrcweir nFollowedByWidth = Width();
875cdf0e10cSrcweir SetLen( 0 );
876cdf0e10cSrcweir }
877cdf0e10cSrcweir Width( nFixWidth + nFollowedByWidth );
878cdf0e10cSrcweir // <--
879cdf0e10cSrcweir const sal_Bool bFull = rInf.Width() < rInf.X() + Width();
880cdf0e10cSrcweir const sal_Bool bFly = rInf.GetFly() ||
881cdf0e10cSrcweir ( rInf.GetLast() && rInf.GetLast()->IsFlyPortion() );
882cdf0e10cSrcweir SetAscent( static_cast<sal_uInt16>(GetRelPos() > 0 ? GetRelPos() : 0) );
883cdf0e10cSrcweir if( GetAscent() > Height() )
884cdf0e10cSrcweir Height( GetAscent() );
885cdf0e10cSrcweir
886cdf0e10cSrcweir if( bFull )
887cdf0e10cSrcweir {
888cdf0e10cSrcweir Width( rInf.Width() - (KSHORT)rInf.X() );
889cdf0e10cSrcweir if( bFly )
890cdf0e10cSrcweir {
891cdf0e10cSrcweir SetLen( 0 );
892cdf0e10cSrcweir SetNoPaint( sal_True );
893cdf0e10cSrcweir rInf.SetNumDone( sal_False );
894cdf0e10cSrcweir return sal_True;
895cdf0e10cSrcweir }
896cdf0e10cSrcweir }
897cdf0e10cSrcweir rInf.SetNumDone( sal_True );
898cdf0e10cSrcweir // --> OD 2008-01-23 #newlistlevelattrs#
899cdf0e10cSrcweir // long nDiff = rInf.Left() - rInf.First() + rInf.ForcedLeftMargin();
900cdf0e10cSrcweir long nDiff = mbLabelAlignmentPosAndSpaceModeActive
901cdf0e10cSrcweir ? 0
902cdf0e10cSrcweir : rInf.Left() - rInf.First() + rInf.ForcedLeftMargin();
903cdf0e10cSrcweir // <--
904cdf0e10cSrcweir // Ein Vorschlag von Juergen und Volkmar:
905cdf0e10cSrcweir // Der Textteil hinter der Numerierung sollte immer
906cdf0e10cSrcweir // mindestens beim linken Rand beginnen.
907cdf0e10cSrcweir if( nDiff < 0 )
908cdf0e10cSrcweir nDiff = 0;
909cdf0e10cSrcweir else if ( nDiff > rInf.X() )
910cdf0e10cSrcweir nDiff -= rInf.X();
911cdf0e10cSrcweir if( nDiff < nFixWidth + nMinDist )
912cdf0e10cSrcweir nDiff = nFixWidth + nMinDist;
913cdf0e10cSrcweir // 2739: Numerierung weicht Fly aus, kein nDiff in der zweiten Runde
914cdf0e10cSrcweir // fieser Sonderfall: FlyFrm liegt in dem Bereich,
915cdf0e10cSrcweir // den wir uns gerade unter den Nagel reissen wollen.
916cdf0e10cSrcweir // Die NumberPortion wird als verborgen markiert.
917cdf0e10cSrcweir if( nDiff > rInf.Width() )
918cdf0e10cSrcweir {
919cdf0e10cSrcweir nDiff = rInf.Width();
920cdf0e10cSrcweir if( bFly )
921cdf0e10cSrcweir SetHide( sal_True );
922cdf0e10cSrcweir }
923cdf0e10cSrcweir
924cdf0e10cSrcweir if( Width() < nDiff )
925cdf0e10cSrcweir Width( KSHORT(nDiff) );
926cdf0e10cSrcweir return bFull;
927cdf0e10cSrcweir }
928cdf0e10cSrcweir
Paint(const SwTxtPaintInfo & rInf) const929cdf0e10cSrcweir void SwGrfNumPortion::Paint( const SwTxtPaintInfo &rInf ) const
930cdf0e10cSrcweir {
931cdf0e10cSrcweir if( DontPaint() )
932cdf0e10cSrcweir return;
933cdf0e10cSrcweir /* Eine verborgene NumberPortion wird nicht angezeigt, es sei denn, es gibt
934cdf0e10cSrcweir * Textportions in dieser Zeile oder es gibt ueberhaupt nur eine einzige Zeile.
935cdf0e10cSrcweir */
936cdf0e10cSrcweir if ( IsHide() && rInf.GetParaPortion() && rInf.GetParaPortion()->GetNext() )
937cdf0e10cSrcweir {
938cdf0e10cSrcweir SwLinePortion *pTmp = GetPortion();
939cdf0e10cSrcweir while ( pTmp && !pTmp->InTxtGrp() )
940cdf0e10cSrcweir pTmp = pTmp->GetPortion();
941cdf0e10cSrcweir if ( !pTmp )
942cdf0e10cSrcweir return;
943cdf0e10cSrcweir }
944cdf0e10cSrcweir Point aPos( rInf.X() + GRFNUM_SECURE, rInf.Y() - GetRelPos() + GRFNUM_SECURE );
945cdf0e10cSrcweir long nTmpWidth = Max( (long)0, (long)(nFixWidth - 2 * GRFNUM_SECURE) );
946cdf0e10cSrcweir Size aSize( nTmpWidth, GetGrfHeight() - 2 * GRFNUM_SECURE );
947cdf0e10cSrcweir
948cdf0e10cSrcweir // --> OD 2008-02-05 #newlistlevelattrs#
949cdf0e10cSrcweir const sal_Bool bTmpLeft = mbLabelAlignmentPosAndSpaceModeActive ||
950cdf0e10cSrcweir ( IsLeft() && ! rInf.GetTxtFrm()->IsRightToLeft() ) ||
951cdf0e10cSrcweir ( ! IsLeft() && ! IsCenter() && rInf.GetTxtFrm()->IsRightToLeft() );
952cdf0e10cSrcweir // <--
953cdf0e10cSrcweir
954cdf0e10cSrcweir if( nFixWidth < Width() && !bTmpLeft )
955cdf0e10cSrcweir {
956cdf0e10cSrcweir KSHORT nOffset = Width() - nFixWidth;
957cdf0e10cSrcweir if( nOffset < nMinDist )
958cdf0e10cSrcweir nOffset = 0;
959cdf0e10cSrcweir else
960cdf0e10cSrcweir {
961cdf0e10cSrcweir if( IsCenter() )
962cdf0e10cSrcweir {
963cdf0e10cSrcweir nOffset /= 2;
964cdf0e10cSrcweir if( nOffset < nMinDist )
965cdf0e10cSrcweir nOffset = Width() - nFixWidth - nMinDist;
966cdf0e10cSrcweir }
967cdf0e10cSrcweir else
968cdf0e10cSrcweir nOffset = nOffset - nMinDist;
969cdf0e10cSrcweir }
970cdf0e10cSrcweir aPos.X() += nOffset;
971cdf0e10cSrcweir }
972cdf0e10cSrcweir
973cdf0e10cSrcweir if( bReplace )
974cdf0e10cSrcweir {
975cdf0e10cSrcweir KSHORT nTmpH = GetPortion() ? GetPortion()->GetAscent() : 120;
976cdf0e10cSrcweir aSize = Size( nTmpH, nTmpH );
977cdf0e10cSrcweir aPos.Y() = rInf.Y() - nTmpH;
978cdf0e10cSrcweir }
979cdf0e10cSrcweir SwRect aTmp( aPos, aSize );
980cdf0e10cSrcweir
981cdf0e10cSrcweir sal_Bool bDraw = sal_True;
982cdf0e10cSrcweir
983cdf0e10cSrcweir if ( IsAnimated() )
984cdf0e10cSrcweir {
985cdf0e10cSrcweir bDraw = !rInf.GetOpt().IsGraphic();
986cdf0e10cSrcweir if( !nId )
987cdf0e10cSrcweir {
988cdf0e10cSrcweir SetId( long( rInf.GetTxtFrm() ) );
989cdf0e10cSrcweir rInf.GetTxtFrm()->SetAnimation();
990cdf0e10cSrcweir }
991cdf0e10cSrcweir if( aTmp.IsOver( rInf.GetPaintRect() ) && !bDraw )
992cdf0e10cSrcweir {
993cdf0e10cSrcweir rInf.NoteAnimation();
994cdf0e10cSrcweir const ViewShell* pViewShell = rInf.GetVsh();
995cdf0e10cSrcweir
996cdf0e10cSrcweir // virtual device, not pdf export
997cdf0e10cSrcweir if( OUTDEV_VIRDEV == rInf.GetOut()->GetOutDevType() &&
998cdf0e10cSrcweir pViewShell && pViewShell->GetWin() )
999cdf0e10cSrcweir {
1000cdf0e10cSrcweir ( (Graphic*) pBrush->GetGraphic() )->StopAnimation(0,nId);
1001cdf0e10cSrcweir rInf.GetTxtFrm()->getRootFrm()->GetCurrShell()->InvalidateWindows( aTmp );
1002cdf0e10cSrcweir }
1003cdf0e10cSrcweir
1004cdf0e10cSrcweir
1005cdf0e10cSrcweir else if ( pViewShell &&
1006cdf0e10cSrcweir !pViewShell->GetAccessibilityOptions()->IsStopAnimatedGraphics() &&
1007cdf0e10cSrcweir !pViewShell->IsPreView() &&
1008cdf0e10cSrcweir // --> FME 2004-06-21 #i9684# Stop animation during printing/pdf export.
1009cdf0e10cSrcweir pViewShell->GetWin() )
1010cdf0e10cSrcweir // <--
1011cdf0e10cSrcweir {
1012cdf0e10cSrcweir ( (Graphic*) pBrush->GetGraphic() )->StartAnimation(
1013cdf0e10cSrcweir (OutputDevice*)rInf.GetOut(), aPos, aSize, nId );
1014cdf0e10cSrcweir }
1015cdf0e10cSrcweir
1016cdf0e10cSrcweir // pdf export, printing, preview, stop animations...
1017cdf0e10cSrcweir else
1018cdf0e10cSrcweir bDraw = sal_True;
1019cdf0e10cSrcweir }
1020cdf0e10cSrcweir if( bDraw )
1021cdf0e10cSrcweir ( (Graphic*) pBrush->GetGraphic() )->StopAnimation( 0, nId );
1022cdf0e10cSrcweir }
1023cdf0e10cSrcweir
1024cdf0e10cSrcweir SwRect aRepaint( rInf.GetPaintRect() );
1025cdf0e10cSrcweir const SwTxtFrm& rFrm = *rInf.GetTxtFrm();
1026cdf0e10cSrcweir if( rFrm.IsVertical() )
1027cdf0e10cSrcweir {
1028cdf0e10cSrcweir rFrm.SwitchHorizontalToVertical( aTmp );
1029cdf0e10cSrcweir rFrm.SwitchHorizontalToVertical( aRepaint );
1030cdf0e10cSrcweir }
1031cdf0e10cSrcweir
1032cdf0e10cSrcweir if( rFrm.IsRightToLeft() )
1033cdf0e10cSrcweir {
1034cdf0e10cSrcweir rFrm.SwitchLTRtoRTL( aTmp );
1035cdf0e10cSrcweir rFrm.SwitchLTRtoRTL( aRepaint );
1036cdf0e10cSrcweir }
1037cdf0e10cSrcweir
1038cdf0e10cSrcweir if( bDraw && aTmp.HasArea() )
1039cdf0e10cSrcweir DrawGraphic( pBrush, (OutputDevice*)rInf.GetOut(),
1040cdf0e10cSrcweir aTmp, aRepaint, bReplace ? GRFNUM_REPLACE : GRFNUM_YES );
1041cdf0e10cSrcweir }
1042cdf0e10cSrcweir
SetBase(long nLnAscent,long nLnDescent,long nFlyAsc,long nFlyDesc)1043cdf0e10cSrcweir void SwGrfNumPortion::SetBase( long nLnAscent, long nLnDescent,
1044cdf0e10cSrcweir long nFlyAsc, long nFlyDesc )
1045cdf0e10cSrcweir {
1046cdf0e10cSrcweir if ( GetOrient() != text::VertOrientation::NONE )
1047cdf0e10cSrcweir {
1048cdf0e10cSrcweir SetRelPos( 0 );
1049cdf0e10cSrcweir if ( GetOrient() == text::VertOrientation::CENTER )
1050cdf0e10cSrcweir SetRelPos( GetGrfHeight() / 2 );
1051cdf0e10cSrcweir else if ( GetOrient() == text::VertOrientation::TOP )
1052cdf0e10cSrcweir SetRelPos( GetGrfHeight() - GRFNUM_SECURE );
1053cdf0e10cSrcweir else if ( GetOrient() == text::VertOrientation::BOTTOM )
1054cdf0e10cSrcweir ;
1055cdf0e10cSrcweir else if ( GetOrient() == text::VertOrientation::CHAR_CENTER )
1056cdf0e10cSrcweir SetRelPos( ( GetGrfHeight() + nLnAscent - nLnDescent ) / 2 );
1057cdf0e10cSrcweir else if ( GetOrient() == text::VertOrientation::CHAR_TOP )
1058cdf0e10cSrcweir SetRelPos( nLnAscent );
1059cdf0e10cSrcweir else if ( GetOrient() == text::VertOrientation::CHAR_BOTTOM )
1060cdf0e10cSrcweir SetRelPos( GetGrfHeight() - nLnDescent );
1061cdf0e10cSrcweir else
1062cdf0e10cSrcweir {
1063cdf0e10cSrcweir if( GetGrfHeight() >= nFlyAsc + nFlyDesc )
1064cdf0e10cSrcweir {
1065cdf0e10cSrcweir // wenn ich genauso gross bin wie die Zeile, brauche ich mich
1066cdf0e10cSrcweir // nicht an der Zeile nicht weiter ausrichten, ich lasse
1067cdf0e10cSrcweir // dann auch den max. Ascent der Zeile unveraendert
1068cdf0e10cSrcweir
1069cdf0e10cSrcweir SetRelPos( nFlyAsc );
1070cdf0e10cSrcweir }
1071cdf0e10cSrcweir else if ( GetOrient() == text::VertOrientation::LINE_CENTER )
1072cdf0e10cSrcweir SetRelPos( ( GetGrfHeight() + nFlyAsc - nFlyDesc ) / 2 );
1073cdf0e10cSrcweir else if ( GetOrient() == text::VertOrientation::LINE_TOP )
1074cdf0e10cSrcweir SetRelPos( nFlyAsc );
1075cdf0e10cSrcweir else if ( GetOrient() == text::VertOrientation::LINE_BOTTOM )
1076cdf0e10cSrcweir SetRelPos( GetGrfHeight() - nFlyDesc );
1077cdf0e10cSrcweir }
1078cdf0e10cSrcweir }
1079cdf0e10cSrcweir }
1080cdf0e10cSrcweir
StopAnimation(OutputDevice * pOut)1081cdf0e10cSrcweir void SwTxtFrm::StopAnimation( OutputDevice* pOut )
1082cdf0e10cSrcweir {
1083cdf0e10cSrcweir ASSERT( HasAnimation(), "SwTxtFrm::StopAnimation: Which Animation?" );
1084cdf0e10cSrcweir if( HasPara() )
1085cdf0e10cSrcweir {
1086cdf0e10cSrcweir SwLineLayout *pLine = GetPara();
1087cdf0e10cSrcweir while( pLine )
1088cdf0e10cSrcweir {
1089cdf0e10cSrcweir SwLinePortion *pPor = pLine->GetPortion();
1090cdf0e10cSrcweir while( pPor )
1091cdf0e10cSrcweir {
1092cdf0e10cSrcweir if( pPor->IsGrfNumPortion() )
1093cdf0e10cSrcweir ((SwGrfNumPortion*)pPor)->StopAnimation( pOut );
1094cdf0e10cSrcweir // Die Numerierungsportion sitzt immer vor dem ersten Zeichen,
1095cdf0e10cSrcweir // deshalb koennen wir abbrechen, sobald wir eine Portion mit
1096cdf0e10cSrcweir // einer Laenge > 0 erreicht haben.
1097cdf0e10cSrcweir pPor = pPor->GetLen() ? 0 : pPor->GetPortion();
1098cdf0e10cSrcweir }
1099cdf0e10cSrcweir pLine = pLine->GetLen() ? 0 : pLine->GetNext();
1100cdf0e10cSrcweir }
1101cdf0e10cSrcweir }
1102cdf0e10cSrcweir }
1103cdf0e10cSrcweir
1104cdf0e10cSrcweir /*************************************************************************
1105cdf0e10cSrcweir * SwCombinedPortion::SwCombinedPortion(..)
1106cdf0e10cSrcweir * initializes the script array and clears the width array
1107cdf0e10cSrcweir *************************************************************************/
1108cdf0e10cSrcweir
SwCombinedPortion(const XubString & rTxt)1109cdf0e10cSrcweir SwCombinedPortion::SwCombinedPortion( const XubString &rTxt )
1110cdf0e10cSrcweir : SwFldPortion( rTxt )
1111cdf0e10cSrcweir {
1112cdf0e10cSrcweir SetLen(1);
1113cdf0e10cSrcweir SetWhichPor( POR_COMBINED );
1114cdf0e10cSrcweir if( aExpand.Len() > 6 )
1115cdf0e10cSrcweir aExpand.Erase( 6 );
1116cdf0e10cSrcweir // Initialization of the scripttype array,
1117cdf0e10cSrcweir // the arrays of width and position are filled by the format function
1118cdf0e10cSrcweir if( pBreakIt->GetBreakIter().is() )
1119cdf0e10cSrcweir {
1120cdf0e10cSrcweir sal_uInt8 nScr = SW_SCRIPTS;
1121cdf0e10cSrcweir for( sal_uInt16 i = 0; i < rTxt.Len(); ++i )
1122cdf0e10cSrcweir {
1123cdf0e10cSrcweir sal_uInt16 nScript = pBreakIt->GetBreakIter()->getScriptType( rTxt, i );
1124cdf0e10cSrcweir switch ( nScript ) {
1125cdf0e10cSrcweir case i18n::ScriptType::LATIN : nScr = SW_LATIN; break;
1126cdf0e10cSrcweir case i18n::ScriptType::ASIAN : nScr = SW_CJK; break;
1127cdf0e10cSrcweir case i18n::ScriptType::COMPLEX : nScr = SW_CTL; break;
1128cdf0e10cSrcweir }
1129cdf0e10cSrcweir aScrType[i] = nScr;
1130cdf0e10cSrcweir }
1131cdf0e10cSrcweir }
1132cdf0e10cSrcweir else
1133cdf0e10cSrcweir {
1134cdf0e10cSrcweir for( sal_uInt16 i = 0; i < 6; aScrType[i++] = 0 )
1135cdf0e10cSrcweir ; // nothing
1136cdf0e10cSrcweir }
1137cdf0e10cSrcweir memset( &aWidth, 0, sizeof(aWidth) );
1138cdf0e10cSrcweir }
1139cdf0e10cSrcweir
1140cdf0e10cSrcweir /*************************************************************************
1141cdf0e10cSrcweir * SwCombinedPortion::Paint(..)
1142cdf0e10cSrcweir *************************************************************************/
1143cdf0e10cSrcweir
Paint(const SwTxtPaintInfo & rInf) const1144cdf0e10cSrcweir void SwCombinedPortion::Paint( const SwTxtPaintInfo &rInf ) const
1145cdf0e10cSrcweir {
1146cdf0e10cSrcweir ASSERT( GetLen() <= 1, "SwFldPortion::Paint: rest-portion polution?" );
1147cdf0e10cSrcweir if( Width() )
1148cdf0e10cSrcweir {
1149cdf0e10cSrcweir rInf.DrawBackBrush( *this );
1150cdf0e10cSrcweir rInf.DrawViewOpt( *this, POR_FLD );
1151cdf0e10cSrcweir
1152cdf0e10cSrcweir // do we have to repaint a post it portion?
1153cdf0e10cSrcweir if( rInf.OnWin() && pPortion && !pPortion->Width() )
1154cdf0e10cSrcweir pPortion->PrePaint( rInf, this );
1155cdf0e10cSrcweir
1156cdf0e10cSrcweir sal_uInt16 nCount = aExpand.Len();
1157cdf0e10cSrcweir if( !nCount )
1158cdf0e10cSrcweir return;
1159cdf0e10cSrcweir ASSERT( nCount < 7, "Too much combined characters" );
1160cdf0e10cSrcweir
1161cdf0e10cSrcweir // the first character of the second row
1162cdf0e10cSrcweir sal_uInt16 nTop = ( nCount + 1 ) / 2;
1163cdf0e10cSrcweir
1164cdf0e10cSrcweir SwFont aTmpFont( *rInf.GetFont() );
1165cdf0e10cSrcweir aTmpFont.SetProportion( nProportion ); // a smaller font
1166cdf0e10cSrcweir SwFontSave aFontSave( rInf, &aTmpFont );
1167cdf0e10cSrcweir
1168cdf0e10cSrcweir sal_uInt16 i = 0;
1169cdf0e10cSrcweir Point aOldPos = rInf.GetPos();
1170cdf0e10cSrcweir Point aOutPos( aOldPos.X(), aOldPos.Y() - nUpPos );// Y of the first row
1171cdf0e10cSrcweir while( i < nCount )
1172cdf0e10cSrcweir {
1173cdf0e10cSrcweir if( i == nTop ) // change the row
1174cdf0e10cSrcweir aOutPos.Y() = aOldPos.Y() + nLowPos; // Y of the second row
1175cdf0e10cSrcweir aOutPos.X() = aOldPos.X() + aPos[i]; // X position
1176cdf0e10cSrcweir const sal_uInt8 nAct = aScrType[i]; // script type
1177cdf0e10cSrcweir aTmpFont.SetActual( nAct );
1178cdf0e10cSrcweir // if there're more than 4 characters to display, we choose fonts
1179cdf0e10cSrcweir // with 2/3 of the original font width.
1180cdf0e10cSrcweir if( aWidth[ nAct ] )
1181cdf0e10cSrcweir {
1182cdf0e10cSrcweir Size aTmpSz = aTmpFont.GetSize( nAct );
1183cdf0e10cSrcweir if( aTmpSz.Width() != aWidth[ nAct ] )
1184cdf0e10cSrcweir {
1185cdf0e10cSrcweir aTmpSz.Width() = aWidth[ nAct ];
1186cdf0e10cSrcweir aTmpFont.SetSize( aTmpSz, nAct );
1187cdf0e10cSrcweir }
1188cdf0e10cSrcweir }
1189cdf0e10cSrcweir ((SwTxtPaintInfo&)rInf).SetPos( aOutPos );
1190cdf0e10cSrcweir rInf.DrawText( aExpand, *this, i, 1 );
1191cdf0e10cSrcweir ++i;
1192cdf0e10cSrcweir }
1193cdf0e10cSrcweir // rInf is const, so we have to take back our manipulations
1194cdf0e10cSrcweir ((SwTxtPaintInfo&)rInf).SetPos( aOldPos );
1195cdf0e10cSrcweir }
1196cdf0e10cSrcweir }
1197cdf0e10cSrcweir
1198cdf0e10cSrcweir /*************************************************************************
1199cdf0e10cSrcweir * SwCombinedPortion::Format(..)
1200cdf0e10cSrcweir *************************************************************************/
1201cdf0e10cSrcweir
Format(SwTxtFormatInfo & rInf)1202cdf0e10cSrcweir sal_Bool SwCombinedPortion::Format( SwTxtFormatInfo &rInf )
1203cdf0e10cSrcweir {
1204cdf0e10cSrcweir sal_uInt16 nCount = aExpand.Len();
1205cdf0e10cSrcweir if( !nCount )
1206cdf0e10cSrcweir {
1207cdf0e10cSrcweir Width( 0 );
1208cdf0e10cSrcweir return sal_False;
1209cdf0e10cSrcweir }
1210cdf0e10cSrcweir
1211cdf0e10cSrcweir ASSERT( nCount < 7, "Too much combined characters" );
1212cdf0e10cSrcweir // If there are leading "weak"-scripttyped characters in this portion,
1213cdf0e10cSrcweir // they get the actual scripttype.
1214cdf0e10cSrcweir sal_uInt16 i = 0;
1215cdf0e10cSrcweir while( i < nCount && SW_SCRIPTS == aScrType[i] )
1216cdf0e10cSrcweir aScrType[i++] = rInf.GetFont()->GetActual();
1217cdf0e10cSrcweir if( nCount > 4 )
1218cdf0e10cSrcweir {
1219cdf0e10cSrcweir // more than four? Ok, then we need the 2/3 font width
1220cdf0e10cSrcweir i = 0;
1221cdf0e10cSrcweir while( i < aExpand.Len() )
1222cdf0e10cSrcweir {
1223cdf0e10cSrcweir ASSERT( aScrType[i] < SW_SCRIPTS, "Combined: Script fault" );
1224cdf0e10cSrcweir if( !aWidth[ aScrType[i] ] )
1225cdf0e10cSrcweir {
1226cdf0e10cSrcweir rInf.GetOut()->SetFont( rInf.GetFont()->GetFnt( aScrType[i] ) );
1227cdf0e10cSrcweir aWidth[ aScrType[i] ] =
1228cdf0e10cSrcweir static_cast<sal_uInt16>(2 * rInf.GetOut()->GetFontMetric().GetSize().Width() / 3);
1229cdf0e10cSrcweir }
1230cdf0e10cSrcweir ++i;
1231cdf0e10cSrcweir }
1232cdf0e10cSrcweir }
1233cdf0e10cSrcweir
1234cdf0e10cSrcweir sal_uInt16 nTop = ( nCount + 1 ) / 2; // the first character of the second line
1235cdf0e10cSrcweir ViewShell *pSh = rInf.GetTxtFrm()->getRootFrm()->GetCurrShell();
1236cdf0e10cSrcweir SwFont aTmpFont( *rInf.GetFont() );
1237cdf0e10cSrcweir SwFontSave aFontSave( rInf, &aTmpFont );
1238cdf0e10cSrcweir nProportion = 55;
1239cdf0e10cSrcweir // In nMainAscent/Descent we store the ascent and descent
1240cdf0e10cSrcweir // of the original surrounding font
1241cdf0e10cSrcweir sal_uInt16 nMaxDescent, nMaxAscent, nMaxWidth;
1242cdf0e10cSrcweir sal_uInt16 nMainDescent = rInf.GetFont()->GetHeight( pSh, *rInf.GetOut() );
1243cdf0e10cSrcweir const sal_uInt16 nMainAscent = rInf.GetFont()->GetAscent( pSh, *rInf.GetOut() );
1244cdf0e10cSrcweir nMainDescent = nMainDescent - nMainAscent;
1245cdf0e10cSrcweir // we start with a 50% font, but if we notice that the combined portion
1246cdf0e10cSrcweir // becomes bigger than the surrounding font, we check 45% and maybe 40%.
1247cdf0e10cSrcweir do
1248cdf0e10cSrcweir {
1249cdf0e10cSrcweir nProportion -= 5;
1250cdf0e10cSrcweir aTmpFont.SetProportion( nProportion );
1251cdf0e10cSrcweir i = 0;
1252cdf0e10cSrcweir memset( &aPos, 0, sizeof(aPos) );
1253cdf0e10cSrcweir nMaxDescent = 0;
1254cdf0e10cSrcweir nMaxAscent = 0;
1255cdf0e10cSrcweir nMaxWidth = 0;
1256cdf0e10cSrcweir nUpPos = nLowPos = 0;
1257cdf0e10cSrcweir
1258cdf0e10cSrcweir // Now we get the width of all characters.
1259cdf0e10cSrcweir // The ascent and the width of the first line are stored in the
1260cdf0e10cSrcweir // ascent member of the portion, the descent in nLowPos.
1261cdf0e10cSrcweir // The ascent, descent and width of the second line are stored in the
1262cdf0e10cSrcweir // local nMaxAscent, nMaxDescent and nMaxWidth variables.
1263cdf0e10cSrcweir while( i < nCount )
1264cdf0e10cSrcweir {
1265cdf0e10cSrcweir sal_uInt8 nScrp = aScrType[i];
1266cdf0e10cSrcweir aTmpFont.SetActual( nScrp );
1267cdf0e10cSrcweir if( aWidth[ nScrp ] )
1268cdf0e10cSrcweir {
1269cdf0e10cSrcweir Size aFontSize( aTmpFont.GetSize( nScrp ) );
1270cdf0e10cSrcweir aFontSize.Width() = aWidth[ nScrp ];
1271cdf0e10cSrcweir aTmpFont.SetSize( aFontSize, nScrp );
1272cdf0e10cSrcweir }
1273cdf0e10cSrcweir
1274cdf0e10cSrcweir SwDrawTextInfo aDrawInf( pSh, *rInf.GetOut(), 0, aExpand, i, 1 );
1275cdf0e10cSrcweir Size aSize = aTmpFont._GetTxtSize( aDrawInf );
1276cdf0e10cSrcweir sal_uInt16 nAsc = aTmpFont.GetAscent( pSh, *rInf.GetOut() );
1277cdf0e10cSrcweir aPos[ i ] = (sal_uInt16)aSize.Width();
1278cdf0e10cSrcweir if( i == nTop ) // enter the second line
1279cdf0e10cSrcweir {
1280cdf0e10cSrcweir nLowPos = nMaxDescent;
1281cdf0e10cSrcweir Height( nMaxDescent + nMaxAscent );
1282cdf0e10cSrcweir Width( nMaxWidth );
1283cdf0e10cSrcweir SetAscent( nMaxAscent );
1284cdf0e10cSrcweir nMaxAscent = 0;
1285cdf0e10cSrcweir nMaxDescent = 0;
1286cdf0e10cSrcweir nMaxWidth = 0;
1287cdf0e10cSrcweir }
1288cdf0e10cSrcweir nMaxWidth = nMaxWidth + aPos[ i++ ];
1289cdf0e10cSrcweir if( nAsc > nMaxAscent )
1290cdf0e10cSrcweir nMaxAscent = nAsc;
1291cdf0e10cSrcweir if( aSize.Height() - nAsc > nMaxDescent )
1292cdf0e10cSrcweir nMaxDescent = static_cast<sal_uInt16>(aSize.Height() - nAsc);
1293cdf0e10cSrcweir }
1294cdf0e10cSrcweir // for one or two characters we double the width of the portion
1295cdf0e10cSrcweir if( nCount < 3 )
1296cdf0e10cSrcweir {
1297cdf0e10cSrcweir nMaxWidth *= 2;
1298cdf0e10cSrcweir Width( 2*Width() );
1299cdf0e10cSrcweir if( nCount < 2 )
1300cdf0e10cSrcweir {
1301cdf0e10cSrcweir Height( nMaxAscent + nMaxDescent );
1302cdf0e10cSrcweir nLowPos = nMaxDescent;
1303cdf0e10cSrcweir }
1304cdf0e10cSrcweir }
1305cdf0e10cSrcweir Height( Height() + nMaxDescent + nMaxAscent );
1306cdf0e10cSrcweir nUpPos = nMaxAscent;
1307cdf0e10cSrcweir SetAscent( Height() - nMaxDescent - nLowPos );
1308cdf0e10cSrcweir } while( nProportion > 40 && ( GetAscent() > nMainAscent ||
1309cdf0e10cSrcweir Height() - GetAscent() > nMainDescent ) );
1310cdf0e10cSrcweir // if the combined portion is smaller than the surrounding text,
1311cdf0e10cSrcweir // the portion grows. This looks better, if there's a character background.
1312cdf0e10cSrcweir if( GetAscent() < nMainAscent )
1313cdf0e10cSrcweir {
1314cdf0e10cSrcweir Height( Height() + nMainAscent - GetAscent() );
1315cdf0e10cSrcweir SetAscent( nMainAscent );
1316cdf0e10cSrcweir }
1317cdf0e10cSrcweir if( Height() < nMainAscent + nMainDescent )
1318cdf0e10cSrcweir Height( nMainAscent + nMainDescent );
1319cdf0e10cSrcweir
1320cdf0e10cSrcweir // We calculate the x positions of the characters in both lines..
1321cdf0e10cSrcweir sal_uInt16 nTopDiff = 0;
1322cdf0e10cSrcweir sal_uInt16 nBotDiff = 0;
1323cdf0e10cSrcweir if( nMaxWidth > Width() )
1324cdf0e10cSrcweir {
1325cdf0e10cSrcweir nTopDiff = ( nMaxWidth - Width() ) / 2;
1326cdf0e10cSrcweir Width( nMaxWidth );
1327cdf0e10cSrcweir }
1328cdf0e10cSrcweir else
1329cdf0e10cSrcweir nBotDiff = ( Width() - nMaxWidth ) / 2;
1330cdf0e10cSrcweir switch( nTop)
1331cdf0e10cSrcweir {
1332cdf0e10cSrcweir case 3: aPos[1] = aPos[0] + nTopDiff; // no break
1333cdf0e10cSrcweir case 2: aPos[nTop-1] = Width() - aPos[nTop-1];
1334cdf0e10cSrcweir }
1335cdf0e10cSrcweir aPos[0] = 0;
1336cdf0e10cSrcweir switch( nCount )
1337cdf0e10cSrcweir {
1338cdf0e10cSrcweir case 5: aPos[4] = aPos[3] + nBotDiff; // no break
1339cdf0e10cSrcweir case 3: aPos[nTop] = nBotDiff; break;
1340cdf0e10cSrcweir case 6: aPos[4] = aPos[3] + nBotDiff; // no break
1341cdf0e10cSrcweir case 4: aPos[nTop] = 0; // no break
1342cdf0e10cSrcweir case 2: aPos[nCount-1] = Width() - aPos[nCount-1];
1343cdf0e10cSrcweir }
1344cdf0e10cSrcweir
1345cdf0e10cSrcweir // Does the combined portion fit the line?
1346cdf0e10cSrcweir const sal_Bool bFull = rInf.Width() < rInf.X() + Width();
1347cdf0e10cSrcweir if( bFull )
1348cdf0e10cSrcweir {
1349cdf0e10cSrcweir if( rInf.GetLineStart() == rInf.GetIdx() && (!rInf.GetLast()->InFldGrp()
1350cdf0e10cSrcweir || !((SwFldPortion*)rInf.GetLast())->IsFollow() ) )
1351cdf0e10cSrcweir Width( (sal_uInt16)( rInf.Width() - rInf.X() ) );
1352cdf0e10cSrcweir else
1353cdf0e10cSrcweir {
1354cdf0e10cSrcweir Truncate();
1355cdf0e10cSrcweir Width( 0 );
1356cdf0e10cSrcweir SetLen( 0 );
1357cdf0e10cSrcweir if( rInf.GetLast() )
1358cdf0e10cSrcweir rInf.GetLast()->FormatEOL( rInf );
1359cdf0e10cSrcweir }
1360cdf0e10cSrcweir }
1361cdf0e10cSrcweir return bFull;
1362cdf0e10cSrcweir }
1363cdf0e10cSrcweir
1364cdf0e10cSrcweir /*************************************************************************
1365cdf0e10cSrcweir * SwCombinedPortion::GetViewWidth(..)
1366cdf0e10cSrcweir *************************************************************************/
1367cdf0e10cSrcweir
GetViewWidth(const SwTxtSizeInfo & rInf) const1368cdf0e10cSrcweir KSHORT SwCombinedPortion::GetViewWidth( const SwTxtSizeInfo &rInf ) const
1369cdf0e10cSrcweir {
1370cdf0e10cSrcweir if( !GetLen() ) // for the dummy part at the end of the line, where
1371cdf0e10cSrcweir return 0; // the combined portion doesn't fit.
1372cdf0e10cSrcweir return SwFldPortion::GetViewWidth( rInf );
1373cdf0e10cSrcweir }
1374