xref: /trunk/main/sw/source/core/text/inftxt.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
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 <com/sun/star/uno/Sequence.h>
29cdf0e10cSrcweir #include <unotools/linguprops.hxx>
30cdf0e10cSrcweir #include <unotools/lingucfg.hxx>
31cdf0e10cSrcweir #include <hintids.hxx>
32cdf0e10cSrcweir #include <sfx2/printer.hxx>
33cdf0e10cSrcweir #include <editeng/hyznitem.hxx>
34cdf0e10cSrcweir #include <editeng/escpitem.hxx>
35cdf0e10cSrcweir #include <editeng/hngpnctitem.hxx>
36cdf0e10cSrcweir #include <editeng/scriptspaceitem.hxx>
37cdf0e10cSrcweir #include <editeng/brshitem.hxx>
38cdf0e10cSrcweir #include <editeng/splwrap.hxx>
39cdf0e10cSrcweir #include <editeng/pgrditem.hxx>
40cdf0e10cSrcweir #include <editeng/tstpitem.hxx>
41cdf0e10cSrcweir 
42cdf0e10cSrcweir #include <SwSmartTagMgr.hxx>
43cdf0e10cSrcweir #include <linguistic/lngprops.hxx>
44cdf0e10cSrcweir #include <editeng/unolingu.hxx>
45cdf0e10cSrcweir #include <breakit.hxx>
46cdf0e10cSrcweir #include <editeng/forbiddenruleitem.hxx>
47cdf0e10cSrcweir #include <txatbase.hxx>
48cdf0e10cSrcweir #include <fmtinfmt.hxx>
49cdf0e10cSrcweir #include <swmodule.hxx>
50cdf0e10cSrcweir #include <vcl/svapp.hxx>
51cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
52cdf0e10cSrcweir #include <viewsh.hxx>   // ViewShell
53cdf0e10cSrcweir #include <viewopt.hxx>  // SwViewOptions
54cdf0e10cSrcweir #include <frmtool.hxx>  // DrawGraphic
55cdf0e10cSrcweir #include <IDocumentSettingAccess.hxx>
56cdf0e10cSrcweir #include <IDocumentDeviceAccess.hxx>
57cdf0e10cSrcweir #include <paratr.hxx>   // SwFmtDrop
58cdf0e10cSrcweir #include <rootfrm.hxx>  // SwRootFrm
59cdf0e10cSrcweir #include <inftxt.hxx>   // SwTxtInfo
60cdf0e10cSrcweir #include <blink.hxx>    // SwBlink
61cdf0e10cSrcweir #include <noteurl.hxx>  // SwNoteURL
62cdf0e10cSrcweir #include <porftn.hxx>   // SwFtnPortion
63cdf0e10cSrcweir #include <porrst.hxx>       // SwHangingPortion
64cdf0e10cSrcweir #include <itratr.hxx>
65cdf0e10cSrcweir #include <accessibilityoptions.hxx>
66cdf0e10cSrcweir #include <wrong.hxx>
67cdf0e10cSrcweir #include <doc.hxx>
68cdf0e10cSrcweir #include <pam.hxx>
69cdf0e10cSrcweir #include <SwGrammarMarkUp.hxx>
70cdf0e10cSrcweir #include <cstdio>
71cdf0e10cSrcweir #include <EnhancedPDFExportHelper.hxx>
72cdf0e10cSrcweir 
7364b14621SArmin Le Grand //UUUU
7464b14621SArmin Le Grand #include <frmfmt.hxx>
7564b14621SArmin Le Grand 
76cdf0e10cSrcweir #include <unomid.h>
77cdf0e10cSrcweir 
78cdf0e10cSrcweir using namespace ::com::sun::star;
79cdf0e10cSrcweir using namespace ::com::sun::star::linguistic2;
80cdf0e10cSrcweir using namespace ::com::sun::star::uno;
81cdf0e10cSrcweir using namespace ::com::sun::star::beans;
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 
84cdf0e10cSrcweir #define CHAR_UNDERSCORE ((sal_Unicode)0x005F)
85cdf0e10cSrcweir #define CHAR_LEFT_ARROW ((sal_Unicode)0x25C0)
86cdf0e10cSrcweir #define CHAR_RIGHT_ARROW ((sal_Unicode)0x25B6)
87cdf0e10cSrcweir #define CHAR_TAB ((sal_Unicode)0x2192)
88cdf0e10cSrcweir #define CHAR_TAB_RTL ((sal_Unicode)0x2190)
89cdf0e10cSrcweir #define CHAR_LINEBREAK ((sal_Unicode)0x21B5)
90cdf0e10cSrcweir #define CHAR_LINEBREAK_RTL ((sal_Unicode)0x21B3)
91cdf0e10cSrcweir 
92cdf0e10cSrcweir #define DRAW_SPECIAL_OPTIONS_CENTER 1
93cdf0e10cSrcweir #define DRAW_SPECIAL_OPTIONS_ROTATE 2
94cdf0e10cSrcweir 
95cdf0e10cSrcweir // --> OD 2006-06-27 #b6440955#
96cdf0e10cSrcweir // variable moved to class <numfunc:GetDefBulletConfig>
97cdf0e10cSrcweir //extern const sal_Char __FAR_DATA sBulletFntName[];
98cdf0e10cSrcweir namespace numfunc
99cdf0e10cSrcweir {
100cdf0e10cSrcweir     extern const String& GetDefBulletFontname();
101cdf0e10cSrcweir     extern bool IsDefBulletFontUserDefined();
102cdf0e10cSrcweir }
103cdf0e10cSrcweir // <--
104cdf0e10cSrcweir 
105cdf0e10cSrcweir #ifdef DBG_UTIL
106cdf0e10cSrcweir // Test2: WYSIWYG++
107cdf0e10cSrcweir // Test4: WYSIWYG debug
108cdf0e10cSrcweir static sal_Bool bDbgLow = sal_False;
109cdf0e10cSrcweir #endif
110cdf0e10cSrcweir 
111cdf0e10cSrcweir #ifdef DBG_UTIL
112cdf0e10cSrcweir 
IsOptCalm() const113cdf0e10cSrcweir sal_Bool SwTxtSizeInfo::IsOptCalm() const { return !GetOpt().IsTest3(); }
114cdf0e10cSrcweir 
IsOptLow() const115cdf0e10cSrcweir sal_Bool SwTxtSizeInfo::IsOptLow() const { return bDbgLow; }
116cdf0e10cSrcweir 
IsOptDbg() const117cdf0e10cSrcweir sal_Bool SwTxtSizeInfo::IsOptDbg() const { return GetOpt().IsTest4(); }
118cdf0e10cSrcweir 
IsOptTest1() const119cdf0e10cSrcweir sal_Bool SwTxtSizeInfo::IsOptTest1() const { return GetOpt().IsTest1(); }
120cdf0e10cSrcweir 
IsOptTest2() const121cdf0e10cSrcweir sal_Bool SwTxtSizeInfo::IsOptTest2() const { return GetOpt().IsTest2(); }
122cdf0e10cSrcweir 
IsOptTest3() const123cdf0e10cSrcweir sal_Bool SwTxtSizeInfo::IsOptTest3() const { return GetOpt().IsTest3(); }
124cdf0e10cSrcweir 
IsOptTest4() const125cdf0e10cSrcweir sal_Bool SwTxtSizeInfo::IsOptTest4() const { return GetOpt().IsTest4(); }
126cdf0e10cSrcweir 
IsOptTest5() const127cdf0e10cSrcweir sal_Bool SwTxtSizeInfo::IsOptTest5() const { return GetOpt().IsTest5(); }
128cdf0e10cSrcweir 
IsOptTest6() const129cdf0e10cSrcweir sal_Bool SwTxtSizeInfo::IsOptTest6() const { return GetOpt().IsTest6(); }
130cdf0e10cSrcweir 
IsOptTest7() const131cdf0e10cSrcweir sal_Bool SwTxtSizeInfo::IsOptTest7() const { return GetOpt().IsTest7(); }
132cdf0e10cSrcweir 
IsOptTest8() const133cdf0e10cSrcweir sal_Bool SwTxtSizeInfo::IsOptTest8() const { return GetOpt().IsTest8(); }
134cdf0e10cSrcweir 
135cdf0e10cSrcweir #endif
136cdf0e10cSrcweir 
137cdf0e10cSrcweir /*************************************************************************
138cdf0e10cSrcweir  *                      SwLineInfo::SwLineInfo()
139cdf0e10cSrcweir  *************************************************************************/
140cdf0e10cSrcweir 
141cdf0e10cSrcweir // --> OD 2008-01-17 #newlistlevelattrs#
SwLineInfo()142cdf0e10cSrcweir SwLineInfo::SwLineInfo()
143cdf0e10cSrcweir     : pRuler( 0 ),
144cdf0e10cSrcweir       pSpace( 0 ),
145cdf0e10cSrcweir       nVertAlign( 0 ),
146cdf0e10cSrcweir       nDefTabStop( 0 ),
147cdf0e10cSrcweir       bListTabStopIncluded( false ),
148cdf0e10cSrcweir       nListTabStopPosition( 0 )
149cdf0e10cSrcweir {
150cdf0e10cSrcweir }
151cdf0e10cSrcweir 
~SwLineInfo()152cdf0e10cSrcweir SwLineInfo::~SwLineInfo()
153cdf0e10cSrcweir {
154cdf0e10cSrcweir     delete pRuler;
155cdf0e10cSrcweir }
CtorInitLineInfo(const SwAttrSet & rAttrSet,const SwTxtNode & rTxtNode)156cdf0e10cSrcweir void SwLineInfo::CtorInitLineInfo( const SwAttrSet& rAttrSet,
157cdf0e10cSrcweir                                    const SwTxtNode& rTxtNode )
158cdf0e10cSrcweir // <--
159cdf0e10cSrcweir {
160cdf0e10cSrcweir     // --> OD 2008-01-17 #newlistlevelattrs#
161cdf0e10cSrcweir //    pRuler = &rAttrSet.GetTabStops();
162cdf0e10cSrcweir     delete pRuler;
163cdf0e10cSrcweir     pRuler = new SvxTabStopItem( rAttrSet.GetTabStops() );
164cdf0e10cSrcweir     if ( rTxtNode.GetListTabStopPosition( nListTabStopPosition ) )
165cdf0e10cSrcweir     {
166cdf0e10cSrcweir         bListTabStopIncluded = true;
167cdf0e10cSrcweir 
168cdf0e10cSrcweir         // insert the list tab stop into SvxTabItem instance <pRuler>
169cdf0e10cSrcweir         const SvxTabStop aListTabStop( nListTabStopPosition,
170cdf0e10cSrcweir                                        SVX_TAB_ADJUST_LEFT );
171cdf0e10cSrcweir         pRuler->Insert( aListTabStop );
172cdf0e10cSrcweir 
173cdf0e10cSrcweir         // remove default tab stops, which are before the inserted list tab stop
174cdf0e10cSrcweir         for ( sal_uInt16 i = 0; i < pRuler->Count(); i++ )
175cdf0e10cSrcweir         {
176cdf0e10cSrcweir             if ( (*pRuler)[i].GetTabPos() < nListTabStopPosition &&
177cdf0e10cSrcweir                  (*pRuler)[i].GetAdjustment() == SVX_TAB_ADJUST_DEFAULT )
178cdf0e10cSrcweir             {
179cdf0e10cSrcweir                 pRuler->Remove(i);
180cdf0e10cSrcweir                 continue;
181cdf0e10cSrcweir             }
182cdf0e10cSrcweir         }
183cdf0e10cSrcweir     }
184cdf0e10cSrcweir     // <--
185cdf0e10cSrcweir     // --> OD 2008-02-15 #newlistlevelattrs#
186cdf0e10cSrcweir     if ( !rTxtNode.getIDocumentSettingAccess()->get(IDocumentSettingAccess::TABS_RELATIVE_TO_INDENT) )
187cdf0e10cSrcweir     {
188cdf0e10cSrcweir         // remove default tab stop at position 0
189cdf0e10cSrcweir         for ( sal_uInt16 i = 0; i < pRuler->Count(); i++ )
190cdf0e10cSrcweir         {
191cdf0e10cSrcweir             if ( (*pRuler)[i].GetTabPos() == 0 &&
192cdf0e10cSrcweir                  (*pRuler)[i].GetAdjustment() == SVX_TAB_ADJUST_DEFAULT )
193cdf0e10cSrcweir             {
194cdf0e10cSrcweir                 pRuler->Remove(i);
195cdf0e10cSrcweir                 break;
196cdf0e10cSrcweir             }
197cdf0e10cSrcweir         }
198cdf0e10cSrcweir     }
199cdf0e10cSrcweir     // <--
200cdf0e10cSrcweir     pSpace = &rAttrSet.GetLineSpacing();
201cdf0e10cSrcweir     nVertAlign = rAttrSet.GetParaVertAlign().GetValue();
202cdf0e10cSrcweir     nDefTabStop = MSHRT_MAX;
203cdf0e10cSrcweir }
204cdf0e10cSrcweir 
205cdf0e10cSrcweir /*************************************************************************
206cdf0e10cSrcweir  *                      SwTxtInfo::CtorInitTxtInfo()
207cdf0e10cSrcweir  *************************************************************************/
208cdf0e10cSrcweir 
CtorInitTxtInfo(SwTxtFrm * pFrm)209cdf0e10cSrcweir void SwTxtInfo::CtorInitTxtInfo( SwTxtFrm *pFrm )
210cdf0e10cSrcweir {
211cdf0e10cSrcweir     pPara = pFrm->GetPara();
212cdf0e10cSrcweir     nTxtStart = pFrm->GetOfst();
213cdf0e10cSrcweir     if( !pPara )
214cdf0e10cSrcweir     {
215cdf0e10cSrcweir         ASSERT( pPara, "+SwTxtInfo::CTOR: missing paragraph information" );
216cdf0e10cSrcweir         pFrm->Format();
217cdf0e10cSrcweir         pPara = pFrm->GetPara();
218cdf0e10cSrcweir     }
219cdf0e10cSrcweir }
220cdf0e10cSrcweir 
SwTxtInfo(const SwTxtInfo & rInf)221cdf0e10cSrcweir SwTxtInfo::SwTxtInfo( const SwTxtInfo &rInf )
222cdf0e10cSrcweir     : pPara( ((SwTxtInfo&)rInf).GetParaPortion() ),
223cdf0e10cSrcweir       nTxtStart( rInf.GetTxtStart() )
224cdf0e10cSrcweir { }
225cdf0e10cSrcweir 
226cdf0e10cSrcweir 
227cdf0e10cSrcweir #ifdef DBG_UTIL
228cdf0e10cSrcweir /*************************************************************************
229cdf0e10cSrcweir  *                      ChkOutDev()
230cdf0e10cSrcweir  *************************************************************************/
231cdf0e10cSrcweir 
ChkOutDev(const SwTxtSizeInfo & rInf)232cdf0e10cSrcweir void ChkOutDev( const SwTxtSizeInfo &rInf )
233cdf0e10cSrcweir {
234cdf0e10cSrcweir     if ( !rInf.GetVsh() )
235cdf0e10cSrcweir         return;
236cdf0e10cSrcweir 
237cdf0e10cSrcweir     const OutputDevice* pOut = rInf.GetOut();
238cdf0e10cSrcweir     const OutputDevice* pRef = rInf.GetRefDev();
239cdf0e10cSrcweir     ASSERT( pOut && pRef, "ChkOutDev: invalid output devices" )
240cdf0e10cSrcweir }
241cdf0e10cSrcweir #endif  // PRODUCT
242cdf0e10cSrcweir 
243cdf0e10cSrcweir 
GetMinLen(const SwTxtSizeInfo & rInf)244cdf0e10cSrcweir inline xub_StrLen GetMinLen( const SwTxtSizeInfo &rInf )
245cdf0e10cSrcweir {
246cdf0e10cSrcweir     const xub_StrLen nInfLen = rInf.GetIdx() + rInf.GetLen();
247cdf0e10cSrcweir     return Min( rInf.GetTxt().Len(), nInfLen );
248cdf0e10cSrcweir }
249cdf0e10cSrcweir 
250cdf0e10cSrcweir 
SwTxtSizeInfo(const SwTxtSizeInfo & rNew)251cdf0e10cSrcweir SwTxtSizeInfo::SwTxtSizeInfo( const SwTxtSizeInfo &rNew )
252cdf0e10cSrcweir     : SwTxtInfo( rNew ),
253cdf0e10cSrcweir       pKanaComp(((SwTxtSizeInfo&)rNew).GetpKanaComp()),
254cdf0e10cSrcweir       pVsh(((SwTxtSizeInfo&)rNew).GetVsh()),
255cdf0e10cSrcweir       pOut(((SwTxtSizeInfo&)rNew).GetOut()),
256cdf0e10cSrcweir       pRef(((SwTxtSizeInfo&)rNew).GetRefDev()),
257cdf0e10cSrcweir       pFnt(((SwTxtSizeInfo&)rNew).GetFont()),
258cdf0e10cSrcweir       pUnderFnt(((SwTxtSizeInfo&)rNew).GetUnderFnt()),
259cdf0e10cSrcweir       pFrm(rNew.pFrm),
260cdf0e10cSrcweir       pOpt(&rNew.GetOpt()),
261cdf0e10cSrcweir       pTxt(&rNew.GetTxt()),
262cdf0e10cSrcweir       nIdx(rNew.GetIdx()),
263cdf0e10cSrcweir       nLen(rNew.GetLen()),
264cdf0e10cSrcweir       nKanaIdx( rNew.GetKanaIdx() ),
265cdf0e10cSrcweir       bOnWin( rNew.OnWin() ),
266cdf0e10cSrcweir       bNotEOL( rNew.NotEOL() ),
267cdf0e10cSrcweir       bURLNotify( rNew.URLNotify() ),
268cdf0e10cSrcweir       bStopUnderFlow( rNew.StopUnderFlow() ),
269cdf0e10cSrcweir       bFtnInside( rNew.IsFtnInside() ),
270cdf0e10cSrcweir       bOtherThanFtnInside( rNew.IsOtherThanFtnInside() ),
271cdf0e10cSrcweir       bMulti( rNew.IsMulti() ),
272cdf0e10cSrcweir       bFirstMulti( rNew.IsFirstMulti() ),
273cdf0e10cSrcweir       bRuby( rNew.IsRuby() ),
274cdf0e10cSrcweir       bHanging( rNew.IsHanging() ),
275cdf0e10cSrcweir       bScriptSpace( rNew.HasScriptSpace() ),
276cdf0e10cSrcweir       bForbiddenChars( rNew.HasForbiddenChars() ),
277cdf0e10cSrcweir       bSnapToGrid( rNew.SnapToGrid() ),
278cdf0e10cSrcweir       nDirection( rNew.GetDirection() )
279cdf0e10cSrcweir {
280cdf0e10cSrcweir #ifdef DBG_UTIL
281cdf0e10cSrcweir     ChkOutDev( *this );
282cdf0e10cSrcweir #endif
283cdf0e10cSrcweir }
284cdf0e10cSrcweir 
CtorInitTxtSizeInfo(SwTxtFrm * pFrame,SwFont * pNewFnt,const xub_StrLen nNewIdx,const xub_StrLen nNewLen)285cdf0e10cSrcweir void SwTxtSizeInfo::CtorInitTxtSizeInfo( SwTxtFrm *pFrame, SwFont *pNewFnt,
286cdf0e10cSrcweir                    const xub_StrLen nNewIdx, const xub_StrLen nNewLen )
287cdf0e10cSrcweir {
288cdf0e10cSrcweir     pKanaComp = NULL;
289cdf0e10cSrcweir     nKanaIdx = 0;
290cdf0e10cSrcweir     pFrm = pFrame;
291cdf0e10cSrcweir     CtorInitTxtInfo( pFrm );
292cdf0e10cSrcweir     const SwTxtNode *pNd = pFrm->GetTxtNode();
293cdf0e10cSrcweir     pVsh = pFrm->getRootFrm()->GetCurrShell();
294cdf0e10cSrcweir 
295cdf0e10cSrcweir     // Get the output and reference device
296cdf0e10cSrcweir     if ( pVsh )
297cdf0e10cSrcweir     {
298cdf0e10cSrcweir         pOut = pVsh->GetOut();
299cdf0e10cSrcweir         pRef = &pVsh->GetRefDev();
300cdf0e10cSrcweir         bOnWin = pVsh->GetWin() || OUTDEV_WINDOW == pOut->GetOutDevType();
301cdf0e10cSrcweir     }
302cdf0e10cSrcweir     else
303cdf0e10cSrcweir     {
304cdf0e10cSrcweir         //Zugriff ueber StarONE, es muss keine Shell existieren oder aktiv sein.
305cdf0e10cSrcweir         if ( pNd->getIDocumentSettingAccess()->get(IDocumentSettingAccess::HTML_MODE) )
306cdf0e10cSrcweir         {
307cdf0e10cSrcweir             //in Ermangelung eines Besseren kann hier ja wohl nur noch das
308cdf0e10cSrcweir             //AppWin genommen werden?
309cdf0e10cSrcweir             pOut = GetpApp()->GetDefaultDevice();
310cdf0e10cSrcweir         }
311cdf0e10cSrcweir         else
312cdf0e10cSrcweir             pOut = pNd->getIDocumentDeviceAccess()->getPrinter( false );
313cdf0e10cSrcweir 
314cdf0e10cSrcweir         pRef = pOut;
315cdf0e10cSrcweir     }
316cdf0e10cSrcweir 
317cdf0e10cSrcweir #ifdef DBG_UTIL
318cdf0e10cSrcweir     ChkOutDev( *this );
319cdf0e10cSrcweir #endif
320cdf0e10cSrcweir 
321cdf0e10cSrcweir     // Set default layout mode ( LTR or RTL ).
322cdf0e10cSrcweir     if ( pFrm->IsRightToLeft() )
323cdf0e10cSrcweir     {
324cdf0e10cSrcweir         pOut->SetLayoutMode( TEXT_LAYOUT_BIDI_STRONG | TEXT_LAYOUT_BIDI_RTL );
325cdf0e10cSrcweir         pRef->SetLayoutMode( TEXT_LAYOUT_BIDI_STRONG | TEXT_LAYOUT_BIDI_RTL );
326cdf0e10cSrcweir         nDirection = DIR_RIGHT2LEFT;
327cdf0e10cSrcweir     }
328cdf0e10cSrcweir     else
329cdf0e10cSrcweir     {
330cdf0e10cSrcweir         pOut->SetLayoutMode( TEXT_LAYOUT_BIDI_STRONG );
331cdf0e10cSrcweir         pRef->SetLayoutMode( TEXT_LAYOUT_BIDI_STRONG );
332cdf0e10cSrcweir         nDirection = DIR_LEFT2RIGHT;
333cdf0e10cSrcweir     }
334cdf0e10cSrcweir 
335cdf0e10cSrcweir /*    LanguageType eLang;
336cdf0e10cSrcweir     const SvtCTLOptions& rCTLOptions = SW_MOD()->GetCTLOptions();
337cdf0e10cSrcweir     if ( SvtCTLOptions::NUMERALS_HINDI == rCTLOptions.GetCTLTextNumerals() )
338cdf0e10cSrcweir         eLang = LANGUAGE_ARABIC_SAUDI_ARABIA;
339cdf0e10cSrcweir     else if ( SvtCTLOptions::NUMERALS_ARABIC == rCTLOptions.GetCTLTextNumerals() )
340cdf0e10cSrcweir         eLang = LANGUAGE_ENGLISH;
341cdf0e10cSrcweir     else
342cdf0e10cSrcweir         eLang = (LanguageType)::GetAppLanguage();
343cdf0e10cSrcweir 
344cdf0e10cSrcweir     pOut->SetDigitLanguage( eLang );
345cdf0e10cSrcweir     pRef->SetDigitLanguage( eLang );*/
346cdf0e10cSrcweir 
347cdf0e10cSrcweir     //
348cdf0e10cSrcweir     // The Options
349cdf0e10cSrcweir     //
350cdf0e10cSrcweir     pOpt = pVsh ?
351cdf0e10cSrcweir            pVsh->GetViewOptions() :
352cdf0e10cSrcweir            SW_MOD()->GetViewOption( pNd->getIDocumentSettingAccess()->get(IDocumentSettingAccess::HTML_MODE) ); //Options vom Module wg. StarONE
353cdf0e10cSrcweir 
354cdf0e10cSrcweir     // bURLNotify wird gesetzt, wenn MakeGraphic dies vorbereitet
355cdf0e10cSrcweir     // TODO: Aufdr?seln
356cdf0e10cSrcweir     bURLNotify = pNoteURL && !bOnWin;
357cdf0e10cSrcweir 
358cdf0e10cSrcweir     SetSnapToGrid( pNd->GetSwAttrSet().GetParaGrid().GetValue() &&
359cdf0e10cSrcweir                    pFrm->IsInDocBody() );
360cdf0e10cSrcweir 
361cdf0e10cSrcweir     pFnt = pNewFnt;
362cdf0e10cSrcweir     pUnderFnt = 0;
363cdf0e10cSrcweir     pTxt = &pNd->GetTxt();
364cdf0e10cSrcweir 
365cdf0e10cSrcweir     nIdx = nNewIdx;
366cdf0e10cSrcweir     nLen = nNewLen;
367cdf0e10cSrcweir     bNotEOL = sal_False;
368cdf0e10cSrcweir     bStopUnderFlow = bFtnInside = bOtherThanFtnInside = sal_False;
369cdf0e10cSrcweir     bMulti = bFirstMulti = bRuby = bHanging = bScriptSpace =
370cdf0e10cSrcweir         bForbiddenChars = sal_False;
371cdf0e10cSrcweir 
372cdf0e10cSrcweir     SetLen( GetMinLen( *this ) );
373cdf0e10cSrcweir }
374cdf0e10cSrcweir 
SwTxtSizeInfo(const SwTxtSizeInfo & rNew,const XubString & rTxt,const xub_StrLen nIndex,const xub_StrLen nLength)375cdf0e10cSrcweir SwTxtSizeInfo::SwTxtSizeInfo( const SwTxtSizeInfo &rNew, const XubString &rTxt,
376cdf0e10cSrcweir                               const xub_StrLen nIndex, const xub_StrLen nLength )
377cdf0e10cSrcweir     : SwTxtInfo( rNew ),
378cdf0e10cSrcweir       pKanaComp(((SwTxtSizeInfo&)rNew).GetpKanaComp()),
379cdf0e10cSrcweir       pVsh(((SwTxtSizeInfo&)rNew).GetVsh()),
380cdf0e10cSrcweir       pOut(((SwTxtSizeInfo&)rNew).GetOut()),
381cdf0e10cSrcweir       pRef(((SwTxtSizeInfo&)rNew).GetRefDev()),
382cdf0e10cSrcweir       pFnt(((SwTxtSizeInfo&)rNew).GetFont()),
383cdf0e10cSrcweir       pUnderFnt(((SwTxtSizeInfo&)rNew).GetUnderFnt()),
384cdf0e10cSrcweir       pFrm( rNew.pFrm ),
385cdf0e10cSrcweir       pOpt(&rNew.GetOpt()),
386cdf0e10cSrcweir       pTxt(&rTxt),
387cdf0e10cSrcweir       nIdx(nIndex),
388cdf0e10cSrcweir       nLen(nLength),
389cdf0e10cSrcweir       nKanaIdx( rNew.GetKanaIdx() ),
390cdf0e10cSrcweir       bOnWin( rNew.OnWin() ),
391cdf0e10cSrcweir       bNotEOL( rNew.NotEOL() ),
392cdf0e10cSrcweir       bURLNotify( rNew.URLNotify() ),
393cdf0e10cSrcweir       bStopUnderFlow( rNew.StopUnderFlow() ),
394cdf0e10cSrcweir       bFtnInside( rNew.IsFtnInside() ),
395cdf0e10cSrcweir       bOtherThanFtnInside( rNew.IsOtherThanFtnInside() ),
396cdf0e10cSrcweir       bMulti( rNew.IsMulti() ),
397cdf0e10cSrcweir       bFirstMulti( rNew.IsFirstMulti() ),
398cdf0e10cSrcweir       bRuby( rNew.IsRuby() ),
399cdf0e10cSrcweir       bHanging( rNew.IsHanging() ),
400cdf0e10cSrcweir       bScriptSpace( rNew.HasScriptSpace() ),
401cdf0e10cSrcweir       bForbiddenChars( rNew.HasForbiddenChars() ),
402cdf0e10cSrcweir       bSnapToGrid( rNew.SnapToGrid() ),
403cdf0e10cSrcweir       nDirection( rNew.GetDirection() )
404cdf0e10cSrcweir {
405cdf0e10cSrcweir #ifdef DBG_UTIL
406cdf0e10cSrcweir     ChkOutDev( *this );
407cdf0e10cSrcweir #endif
408cdf0e10cSrcweir     SetLen( GetMinLen( *this ) );
409cdf0e10cSrcweir }
410cdf0e10cSrcweir 
411cdf0e10cSrcweir /*************************************************************************
412cdf0e10cSrcweir  *                      SwTxtSizeInfo::SelectFont()
413cdf0e10cSrcweir  *************************************************************************/
414cdf0e10cSrcweir 
SelectFont()415cdf0e10cSrcweir void SwTxtSizeInfo::SelectFont()
416cdf0e10cSrcweir {
417cdf0e10cSrcweir     // 8731: Der Weg muss ueber ChgPhysFnt gehen, sonst geraet
418cdf0e10cSrcweir     // der FontMetricCache durcheinander. In diesem Fall steht pLastMet
419cdf0e10cSrcweir     // auf dem alten Wert.
420cdf0e10cSrcweir     // Falsch: GetOut()->SetFont( GetFont()->GetFnt() );
421cdf0e10cSrcweir     GetFont()->Invalidate();
422cdf0e10cSrcweir     GetFont()->ChgPhysFnt( pVsh, *GetOut() );
423cdf0e10cSrcweir }
424cdf0e10cSrcweir 
425cdf0e10cSrcweir /*************************************************************************
426cdf0e10cSrcweir  *                      SwTxtSizeInfo::NoteAnimation()
427cdf0e10cSrcweir  *************************************************************************/
428cdf0e10cSrcweir 
NoteAnimation() const429cdf0e10cSrcweir void SwTxtSizeInfo::NoteAnimation() const
430cdf0e10cSrcweir {
431cdf0e10cSrcweir     if( OnWin() )
432cdf0e10cSrcweir         SwRootFrm::FlushVout();
433cdf0e10cSrcweir 
434cdf0e10cSrcweir     ASSERT( pOut == pVsh->GetOut(),
435cdf0e10cSrcweir             "SwTxtSizeInfo::NoteAnimation() changed pOut" )
436cdf0e10cSrcweir }
437cdf0e10cSrcweir 
438cdf0e10cSrcweir /*************************************************************************
439cdf0e10cSrcweir  *                      SwTxtSizeInfo::GetTxtSize()
440cdf0e10cSrcweir  *************************************************************************/
441cdf0e10cSrcweir 
GetTxtSize(OutputDevice * pOutDev,const SwScriptInfo * pSI,const XubString & rTxt,const xub_StrLen nIndex,const xub_StrLen nLength,const sal_uInt16 nComp) const442cdf0e10cSrcweir SwPosSize SwTxtSizeInfo::GetTxtSize( OutputDevice* pOutDev,
443cdf0e10cSrcweir                                      const SwScriptInfo* pSI,
444cdf0e10cSrcweir                                      const XubString& rTxt,
445cdf0e10cSrcweir                                      const xub_StrLen nIndex,
446cdf0e10cSrcweir                                      const xub_StrLen nLength,
447cdf0e10cSrcweir                                      const sal_uInt16 nComp ) const
448cdf0e10cSrcweir {
449cdf0e10cSrcweir     SwDrawTextInfo aDrawInf( pVsh, *pOutDev, pSI, rTxt, nIndex, nLength );
450cdf0e10cSrcweir     aDrawInf.SetFrm( pFrm );
451cdf0e10cSrcweir     aDrawInf.SetFont( pFnt );
452cdf0e10cSrcweir     aDrawInf.SetSnapToGrid( SnapToGrid() );
453cdf0e10cSrcweir     aDrawInf.SetKanaComp( nComp );
454cdf0e10cSrcweir     SwPosSize aSize = pFnt->_GetTxtSize( aDrawInf );
455cdf0e10cSrcweir     return aSize;
456cdf0e10cSrcweir }
457cdf0e10cSrcweir 
458cdf0e10cSrcweir /*************************************************************************
459cdf0e10cSrcweir  *                      SwTxtSizeInfo::GetTxtSize()
460cdf0e10cSrcweir  *************************************************************************/
461cdf0e10cSrcweir 
GetTxtSize() const462cdf0e10cSrcweir SwPosSize SwTxtSizeInfo::GetTxtSize() const
463cdf0e10cSrcweir {
464cdf0e10cSrcweir     const SwScriptInfo& rSI =
465cdf0e10cSrcweir                      ( (SwParaPortion*)GetParaPortion() )->GetScriptInfo();
466cdf0e10cSrcweir 
46786e1cf34SPedro Giffuni     // in some cases, compression is not allowed or suppressed for
468cdf0e10cSrcweir     // performance reasons
469cdf0e10cSrcweir     sal_uInt16 nComp =( SW_CJK == GetFont()->GetActual() &&
470cdf0e10cSrcweir                     rSI.CountCompChg() &&
471cdf0e10cSrcweir                     ! IsMulti() ) ?
472cdf0e10cSrcweir                     GetKanaComp() :
473cdf0e10cSrcweir                                 0 ;
474cdf0e10cSrcweir 
475cdf0e10cSrcweir     SwDrawTextInfo aDrawInf( pVsh, *pOut, &rSI, *pTxt, nIdx, nLen );
476cdf0e10cSrcweir     aDrawInf.SetFrm( pFrm );
477cdf0e10cSrcweir     aDrawInf.SetFont( pFnt );
478cdf0e10cSrcweir     aDrawInf.SetSnapToGrid( SnapToGrid() );
479cdf0e10cSrcweir     aDrawInf.SetKanaComp( nComp );
480cdf0e10cSrcweir     return pFnt->_GetTxtSize( aDrawInf );
481cdf0e10cSrcweir }
482cdf0e10cSrcweir 
483cdf0e10cSrcweir /*************************************************************************
484cdf0e10cSrcweir  *                      SwTxtSizeInfo::GetTxtSize()
485cdf0e10cSrcweir  *************************************************************************/
486cdf0e10cSrcweir 
GetTxtSize(const SwScriptInfo * pSI,const xub_StrLen nIndex,const xub_StrLen nLength,const sal_uInt16 nComp,sal_uInt16 & nMinSize,sal_uInt16 & nMaxSizeDiff) const487cdf0e10cSrcweir void SwTxtSizeInfo::GetTxtSize( const SwScriptInfo* pSI, const xub_StrLen nIndex,
488cdf0e10cSrcweir                                 const xub_StrLen nLength, const sal_uInt16 nComp,
489cdf0e10cSrcweir                                 sal_uInt16& nMinSize, sal_uInt16& nMaxSizeDiff ) const
490cdf0e10cSrcweir {
491cdf0e10cSrcweir     SwDrawTextInfo aDrawInf( pVsh, *pOut, pSI, *pTxt, nIndex, nLength );
492cdf0e10cSrcweir     aDrawInf.SetFrm( pFrm );
493cdf0e10cSrcweir     aDrawInf.SetFont( pFnt );
494cdf0e10cSrcweir     aDrawInf.SetSnapToGrid( SnapToGrid() );
495cdf0e10cSrcweir     aDrawInf.SetKanaComp( nComp );
496cdf0e10cSrcweir     SwPosSize aSize = pFnt->_GetTxtSize( aDrawInf );
497cdf0e10cSrcweir     nMaxSizeDiff = (sal_uInt16)aDrawInf.GetKanaDiff();
498cdf0e10cSrcweir     nMinSize = aSize.Width();
499cdf0e10cSrcweir }
500cdf0e10cSrcweir 
501cdf0e10cSrcweir /*************************************************************************
502cdf0e10cSrcweir  *                      SwTxtSizeInfo::GetTxtBreak()
503cdf0e10cSrcweir  *************************************************************************/
504cdf0e10cSrcweir 
GetTxtBreak(const long nLineWidth,const xub_StrLen nMaxLen,const sal_uInt16 nComp) const505cdf0e10cSrcweir xub_StrLen SwTxtSizeInfo::GetTxtBreak( const long nLineWidth,
506cdf0e10cSrcweir                                        const xub_StrLen nMaxLen,
507cdf0e10cSrcweir                                        const sal_uInt16 nComp ) const
508cdf0e10cSrcweir {
509cdf0e10cSrcweir     const SwScriptInfo& rScriptInfo =
510cdf0e10cSrcweir                      ( (SwParaPortion*)GetParaPortion() )->GetScriptInfo();
511cdf0e10cSrcweir 
512cdf0e10cSrcweir     ASSERT( pRef == pOut, "GetTxtBreak is supposed to use the RefDev" )
513cdf0e10cSrcweir     SwDrawTextInfo aDrawInf( pVsh, *pOut, &rScriptInfo,
514cdf0e10cSrcweir                              *pTxt, GetIdx(), nMaxLen );
515cdf0e10cSrcweir     aDrawInf.SetFrm( pFrm );
516cdf0e10cSrcweir     aDrawInf.SetFont( pFnt );
517cdf0e10cSrcweir     aDrawInf.SetSnapToGrid( SnapToGrid() );
518cdf0e10cSrcweir     aDrawInf.SetKanaComp( nComp );
519cdf0e10cSrcweir     aDrawInf.SetHyphPos( 0 );
520cdf0e10cSrcweir 
521cdf0e10cSrcweir     return pFnt->GetTxtBreak( aDrawInf, nLineWidth );
522cdf0e10cSrcweir }
523cdf0e10cSrcweir 
524cdf0e10cSrcweir /*************************************************************************
525cdf0e10cSrcweir  *                      SwTxtSizeInfo::GetTxtBreak()
526cdf0e10cSrcweir  *************************************************************************/
527cdf0e10cSrcweir 
GetTxtBreak(const long nLineWidth,const xub_StrLen nMaxLen,const sal_uInt16 nComp,xub_StrLen & rExtraCharPos) const528cdf0e10cSrcweir xub_StrLen SwTxtSizeInfo::GetTxtBreak( const long nLineWidth,
529cdf0e10cSrcweir                                        const xub_StrLen nMaxLen,
530cdf0e10cSrcweir                                        const sal_uInt16 nComp,
531cdf0e10cSrcweir                                        xub_StrLen& rExtraCharPos ) const
532cdf0e10cSrcweir {
533cdf0e10cSrcweir     const SwScriptInfo& rScriptInfo =
534cdf0e10cSrcweir                      ( (SwParaPortion*)GetParaPortion() )->GetScriptInfo();
535cdf0e10cSrcweir 
536cdf0e10cSrcweir     ASSERT( pRef == pOut, "GetTxtBreak is supposed to use the RefDev" )
537cdf0e10cSrcweir     SwDrawTextInfo aDrawInf( pVsh, *pOut, &rScriptInfo,
538cdf0e10cSrcweir                              *pTxt, GetIdx(), nMaxLen );
539cdf0e10cSrcweir     aDrawInf.SetFrm( pFrm );
540cdf0e10cSrcweir     aDrawInf.SetFont( pFnt );
541cdf0e10cSrcweir     aDrawInf.SetSnapToGrid( SnapToGrid() );
542cdf0e10cSrcweir     aDrawInf.SetKanaComp( nComp );
543cdf0e10cSrcweir     aDrawInf.SetHyphPos( &rExtraCharPos );
544cdf0e10cSrcweir 
545cdf0e10cSrcweir     return pFnt->GetTxtBreak( aDrawInf, nLineWidth );
546cdf0e10cSrcweir }
547cdf0e10cSrcweir 
548cdf0e10cSrcweir /*************************************************************************
549cdf0e10cSrcweir  *                     SwTxtPaintInfo::CtorInitTxtPaintInfo()
550cdf0e10cSrcweir  *************************************************************************/
551cdf0e10cSrcweir 
CtorInitTxtPaintInfo(SwTxtFrm * pFrame,const SwRect & rPaint)552cdf0e10cSrcweir void SwTxtPaintInfo::CtorInitTxtPaintInfo( SwTxtFrm *pFrame, const SwRect &rPaint )
553cdf0e10cSrcweir {
554cdf0e10cSrcweir     CtorInitTxtSizeInfo( pFrame );
555cdf0e10cSrcweir     aTxtFly.CtorInitTxtFly( pFrame ),
556cdf0e10cSrcweir     aPaintRect = rPaint;
557cdf0e10cSrcweir     nSpaceIdx = 0;
558cdf0e10cSrcweir     pSpaceAdd = NULL;
559cdf0e10cSrcweir     pWrongList = NULL;
560cdf0e10cSrcweir     pGrammarCheckList = NULL;
561cdf0e10cSrcweir     pSmartTags = NULL;  // SMARTTAGS
562cdf0e10cSrcweir 
563cdf0e10cSrcweir #ifndef DBG_UTIL
564cdf0e10cSrcweir     pBrushItem = 0;
565cdf0e10cSrcweir #else
566cdf0e10cSrcweir     pBrushItem = ((SvxBrushItem*)-1);
567cdf0e10cSrcweir #endif
568cdf0e10cSrcweir }
569cdf0e10cSrcweir 
SwTxtPaintInfo(const SwTxtPaintInfo & rInf,const XubString & rTxt)570cdf0e10cSrcweir SwTxtPaintInfo::SwTxtPaintInfo( const SwTxtPaintInfo &rInf, const XubString &rTxt )
571cdf0e10cSrcweir     : SwTxtSizeInfo( rInf, rTxt ),
572cdf0e10cSrcweir       pWrongList( rInf.GetpWrongList() ),
573cdf0e10cSrcweir       pGrammarCheckList( rInf.GetGrammarCheckList() ),
574cdf0e10cSrcweir       pSmartTags( rInf.GetSmartTags() ),    // SMARTTAGS
575cdf0e10cSrcweir       pSpaceAdd( rInf.GetpSpaceAdd() ),
576cdf0e10cSrcweir       pBrushItem( rInf.GetBrushItem() ),
577cdf0e10cSrcweir       aTxtFly( *rInf.GetTxtFly() ),
578cdf0e10cSrcweir       aPos( rInf.GetPos() ),
579cdf0e10cSrcweir       aPaintRect( rInf.GetPaintRect() ),
580cdf0e10cSrcweir       nSpaceIdx( rInf.GetSpaceIdx() )
581cdf0e10cSrcweir { }
582cdf0e10cSrcweir 
SwTxtPaintInfo(const SwTxtPaintInfo & rInf)583cdf0e10cSrcweir SwTxtPaintInfo::SwTxtPaintInfo( const SwTxtPaintInfo &rInf )
584cdf0e10cSrcweir     : SwTxtSizeInfo( rInf ),
585cdf0e10cSrcweir       pWrongList( rInf.GetpWrongList() ),
586cdf0e10cSrcweir       pGrammarCheckList( rInf.GetGrammarCheckList() ),
587cdf0e10cSrcweir       pSmartTags( rInf.GetSmartTags() ),    // SMARTTAGS
588cdf0e10cSrcweir       pSpaceAdd( rInf.GetpSpaceAdd() ),
589cdf0e10cSrcweir       pBrushItem( rInf.GetBrushItem() ),
590cdf0e10cSrcweir       aTxtFly( *rInf.GetTxtFly() ),
591cdf0e10cSrcweir       aPos( rInf.GetPos() ),
592cdf0e10cSrcweir       aPaintRect( rInf.GetPaintRect() ),
593cdf0e10cSrcweir       nSpaceIdx( rInf.GetSpaceIdx() )
594cdf0e10cSrcweir { }
595cdf0e10cSrcweir 
596cdf0e10cSrcweir extern Color aGlobalRetoucheColor;
597cdf0e10cSrcweir 
598cdf0e10cSrcweir /*************************************************************************
599cdf0e10cSrcweir  *                          lcl_IsDarkBackground
600cdf0e10cSrcweir  *
601cdf0e10cSrcweir  * Returns if the current background color is dark.
602cdf0e10cSrcweir  *************************************************************************/
603cdf0e10cSrcweir 
lcl_IsDarkBackground(const SwTxtPaintInfo & rInf)604cdf0e10cSrcweir sal_Bool lcl_IsDarkBackground( const SwTxtPaintInfo& rInf )
605cdf0e10cSrcweir {
606cdf0e10cSrcweir     const Color* pCol = rInf.GetFont()->GetBackColor();
607cdf0e10cSrcweir     if( ! pCol || COL_TRANSPARENT == pCol->GetColor() )
608cdf0e10cSrcweir     {
609cdf0e10cSrcweir         const SvxBrushItem* pItem;
610cdf0e10cSrcweir         SwRect aOrigBackRect;
611cdf0e10cSrcweir 
61264b14621SArmin Le Grand         //UUUU
61356b35d86SArmin Le Grand         drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFillAttributes;
61464b14621SArmin Le Grand 
615cdf0e10cSrcweir         /// OD 21.08.2002
616cdf0e10cSrcweir         ///     consider, that [GetBackgroundBrush(...)] can set <pCol>
617cdf0e10cSrcweir         ///     - see implementation in /core/layout/paintfrm.cxx
618cdf0e10cSrcweir         /// OD 21.08.2002 #99657#
619cdf0e10cSrcweir         ///     There is a background color, if there is a background brush and
620cdf0e10cSrcweir         ///     its color is *not* "no fill"/"auto fill".
62164b14621SArmin Le Grand         if( rInf.GetTxtFrm()->GetBackgroundBrush( aFillAttributes, pItem, pCol, aOrigBackRect, sal_False ) )
622cdf0e10cSrcweir         {
623cdf0e10cSrcweir             if ( !pCol )
624cdf0e10cSrcweir                 pCol = &pItem->GetColor();
625cdf0e10cSrcweir 
626cdf0e10cSrcweir             /// OD 30.08.2002 #99657#
627cdf0e10cSrcweir             /// determined color <pCol> can be <COL_TRANSPARENT>. Thus, check it.
628cdf0e10cSrcweir             if ( pCol->GetColor() == COL_TRANSPARENT)
629cdf0e10cSrcweir                 pCol = NULL;
630cdf0e10cSrcweir         }
631cdf0e10cSrcweir         else
632cdf0e10cSrcweir             pCol = NULL;
633cdf0e10cSrcweir     }
634cdf0e10cSrcweir 
635cdf0e10cSrcweir 
636cdf0e10cSrcweir     if( !pCol )
637cdf0e10cSrcweir         pCol = &aGlobalRetoucheColor;
638cdf0e10cSrcweir 
639cdf0e10cSrcweir     return pCol->IsDark();
640cdf0e10cSrcweir }
641cdf0e10cSrcweir 
642cdf0e10cSrcweir /*************************************************************************
643cdf0e10cSrcweir  *                     SwTxtPaintInfo::_DrawText()
644cdf0e10cSrcweir  *************************************************************************/
645cdf0e10cSrcweir 
_DrawText(const XubString & rText,const SwLinePortion & rPor,const xub_StrLen nStart,const xub_StrLen nLength,const sal_Bool bKern,const sal_Bool bWrong,const sal_Bool bSmartTag,const sal_Bool bGrammarCheck)646cdf0e10cSrcweir void SwTxtPaintInfo::_DrawText( const XubString &rText, const SwLinePortion &rPor,
647cdf0e10cSrcweir                                 const xub_StrLen nStart, const xub_StrLen nLength,
648cdf0e10cSrcweir                                 const sal_Bool bKern, const sal_Bool bWrong,
649cdf0e10cSrcweir                                 const sal_Bool bSmartTag,
650cdf0e10cSrcweir                                 const sal_Bool bGrammarCheck )  // SMARTTAGS
651cdf0e10cSrcweir {
652cdf0e10cSrcweir     if( !nLength )
653cdf0e10cSrcweir         return;
654cdf0e10cSrcweir 
655cdf0e10cSrcweir     if( GetFont()->IsBlink() && OnWin() && rPor.Width() )
656cdf0e10cSrcweir     {
657cdf0e10cSrcweir         // check if accessibility options allow blinking portions:
658cdf0e10cSrcweir         const ViewShell* pSh = GetTxtFrm()->getRootFrm()->GetCurrShell();
659cdf0e10cSrcweir         if ( pSh && ! pSh->GetAccessibilityOptions()->IsStopAnimatedText() &&
660cdf0e10cSrcweir              ! pSh->IsPreView() )
661cdf0e10cSrcweir         {
662cdf0e10cSrcweir             if( !pBlink )
663cdf0e10cSrcweir                 pBlink = new SwBlink();
664cdf0e10cSrcweir 
665cdf0e10cSrcweir             Point aPoint( aPos );
666cdf0e10cSrcweir 
667cdf0e10cSrcweir             if ( GetTxtFrm()->IsRightToLeft() )
668cdf0e10cSrcweir                 GetTxtFrm()->SwitchLTRtoRTL( aPoint );
669cdf0e10cSrcweir 
670cdf0e10cSrcweir             if ( TEXT_LAYOUT_BIDI_STRONG != GetOut()->GetLayoutMode() )
671cdf0e10cSrcweir                 aPoint.X() -= rPor.Width();
672cdf0e10cSrcweir 
673cdf0e10cSrcweir             if ( GetTxtFrm()->IsVertical() )
674cdf0e10cSrcweir                 GetTxtFrm()->SwitchHorizontalToVertical( aPoint );
675cdf0e10cSrcweir 
676cdf0e10cSrcweir             pBlink->Insert( aPoint, &rPor, GetTxtFrm(), pFnt->GetOrientation() );
677cdf0e10cSrcweir 
678cdf0e10cSrcweir             if( !pBlink->IsVisible() )
679cdf0e10cSrcweir                 return;
680cdf0e10cSrcweir         }
681cdf0e10cSrcweir         else
682cdf0e10cSrcweir         {
683cdf0e10cSrcweir             delete pBlink;
684cdf0e10cSrcweir             pBlink = NULL;
685cdf0e10cSrcweir         }
686cdf0e10cSrcweir     }
687cdf0e10cSrcweir 
688cdf0e10cSrcweir     // The SwScriptInfo is useless if we are inside a field portion
689cdf0e10cSrcweir     SwScriptInfo* pSI = 0;
690cdf0e10cSrcweir     if ( ! rPor.InFldGrp() )
691cdf0e10cSrcweir         pSI = &GetParaPortion()->GetScriptInfo();
692cdf0e10cSrcweir 
69386e1cf34SPedro Giffuni     // in some cases, kana compression is not allowed or suppressed for
694cdf0e10cSrcweir     // performance reasons
695cdf0e10cSrcweir     sal_uInt16 nComp = 0;
696cdf0e10cSrcweir     if ( ! IsMulti() )
697cdf0e10cSrcweir         nComp = GetKanaComp();
698cdf0e10cSrcweir 
699cdf0e10cSrcweir     sal_Bool bCfgIsAutoGrammar = sal_False;
700cdf0e10cSrcweir     SvtLinguConfig().GetProperty( C2U( UPN_IS_GRAMMAR_AUTO ) ) >>= bCfgIsAutoGrammar;
701cdf0e10cSrcweir     const sal_Bool bBullet = OnWin() && GetOpt().IsBlank() && IsNoSymbol();
702cdf0e10cSrcweir     const sal_Bool bTmpWrong = bWrong && OnWin() && GetOpt().IsOnlineSpell();
703cdf0e10cSrcweir     const sal_Bool bTmpGrammarCheck = bGrammarCheck && OnWin() && bCfgIsAutoGrammar && GetOpt().IsOnlineSpell();
704cdf0e10cSrcweir     const sal_Bool bTmpSmart = bSmartTag && OnWin() && !GetOpt().IsPagePreview() && SwSmartTagMgr::Get().IsSmartTagsEnabled(); // SMARTTAGS
705cdf0e10cSrcweir 
706cdf0e10cSrcweir     ASSERT( GetParaPortion(), "No paragraph!");
707cdf0e10cSrcweir     SwDrawTextInfo aDrawInf( pFrm->getRootFrm()->GetCurrShell(), *pOut, pSI, rText, nStart, nLength,
708cdf0e10cSrcweir                              rPor.Width(), bBullet );
709cdf0e10cSrcweir 
710cdf0e10cSrcweir     aDrawInf.SetLeft( GetPaintRect().Left() );
711cdf0e10cSrcweir     aDrawInf.SetRight( GetPaintRect().Right() );
712cdf0e10cSrcweir     aDrawInf.SetUnderFnt( pUnderFnt );
713cdf0e10cSrcweir 
714cdf0e10cSrcweir     const long nSpaceAdd = ( rPor.IsBlankPortion() || rPor.IsDropPortion() ||
715cdf0e10cSrcweir                              rPor.InNumberGrp() ) ? 0 : GetSpaceAdd();
716cdf0e10cSrcweir     if ( nSpaceAdd )
717cdf0e10cSrcweir     {
718cdf0e10cSrcweir         xub_StrLen nCharCnt;
719cdf0e10cSrcweir         // --> FME 2005-04-04 #i41860# Thai justified alignemt needs some
720cdf0e10cSrcweir         // additional information:
721cdf0e10cSrcweir         aDrawInf.SetNumberOfBlanks( rPor.InTxtGrp() ?
722cdf0e10cSrcweir                                     static_cast<const SwTxtPortion&>(rPor).GetSpaceCnt( *this, nCharCnt ) :
723cdf0e10cSrcweir                                     0 );
724cdf0e10cSrcweir         // <--
725cdf0e10cSrcweir     }
726cdf0e10cSrcweir 
727cdf0e10cSrcweir     aDrawInf.SetSpace( nSpaceAdd );
728cdf0e10cSrcweir     aDrawInf.SetKanaComp( nComp );
729cdf0e10cSrcweir 
730cdf0e10cSrcweir     // the font is used to identify the current script via nActual
731cdf0e10cSrcweir     aDrawInf.SetFont( pFnt );
732cdf0e10cSrcweir     // the frame is used to identify the orientation
733cdf0e10cSrcweir     aDrawInf.SetFrm( GetTxtFrm() );
734cdf0e10cSrcweir     // we have to know if the paragraph should snap to grid
735cdf0e10cSrcweir     aDrawInf.SetSnapToGrid( SnapToGrid() );
736cdf0e10cSrcweir     // for underlining we must know when not to add extra space behind
737cdf0e10cSrcweir     // a character in justified mode
738cdf0e10cSrcweir     aDrawInf.SetSpaceStop( ! rPor.GetPortion() ||
739cdf0e10cSrcweir                              rPor.GetPortion()->InFixMargGrp() ||
740cdf0e10cSrcweir                              rPor.GetPortion()->IsHolePortion() );
741cdf0e10cSrcweir 
742cdf0e10cSrcweir     if( GetTxtFly()->IsOn() )
743cdf0e10cSrcweir     {
744cdf0e10cSrcweir         // aPos muss als TopLeft vorliegen, weil die ClipRects sonst
745cdf0e10cSrcweir         // nicht berechnet werden koennen.
746cdf0e10cSrcweir         const Point aPoint( aPos.X(), aPos.Y() - rPor.GetAscent() );
747cdf0e10cSrcweir         const Size aSize( rPor.Width(), rPor.Height() );
748cdf0e10cSrcweir         aDrawInf.SetPos( aPoint );
749cdf0e10cSrcweir         aDrawInf.SetSize( aSize );
750cdf0e10cSrcweir         aDrawInf.SetAscent( rPor.GetAscent() );
751cdf0e10cSrcweir         aDrawInf.SetKern( bKern ? rPor.Width() : 0 );
752cdf0e10cSrcweir         aDrawInf.SetWrong( bTmpWrong ? pWrongList : NULL );
753cdf0e10cSrcweir         aDrawInf.SetGrammarCheck( bTmpGrammarCheck ? pGrammarCheckList : NULL );
754cdf0e10cSrcweir         aDrawInf.SetSmartTags( bTmpSmart ? pSmartTags : NULL );     // SMARTTAGS
755cdf0e10cSrcweir         GetTxtFly()->DrawTextOpaque( aDrawInf );
756cdf0e10cSrcweir     }
757cdf0e10cSrcweir     else
758cdf0e10cSrcweir     {
759cdf0e10cSrcweir         aDrawInf.SetPos( aPos );
760cdf0e10cSrcweir         if( bKern )
761cdf0e10cSrcweir             pFnt->_DrawStretchText( aDrawInf );
762cdf0e10cSrcweir         else
763cdf0e10cSrcweir         {
764cdf0e10cSrcweir             aDrawInf.SetWrong( bTmpWrong ? pWrongList : NULL );
765cdf0e10cSrcweir             aDrawInf.SetGrammarCheck( bTmpGrammarCheck ? pGrammarCheckList : NULL );
766cdf0e10cSrcweir             aDrawInf.SetSmartTags( bTmpSmart ? pSmartTags : NULL );  // SMARTTAGS
767cdf0e10cSrcweir             pFnt->_DrawText( aDrawInf );
768cdf0e10cSrcweir         }
769cdf0e10cSrcweir     }
770cdf0e10cSrcweir }
771cdf0e10cSrcweir 
772cdf0e10cSrcweir /*************************************************************************
773cdf0e10cSrcweir  *                          SwTxtPaintInfo::CalcRect()
774cdf0e10cSrcweir  *************************************************************************/
775cdf0e10cSrcweir 
CalcRect(const SwLinePortion & rPor,SwRect * pRect,SwRect * pIntersect) const776cdf0e10cSrcweir void SwTxtPaintInfo::CalcRect( const SwLinePortion& rPor,
777cdf0e10cSrcweir                                SwRect* pRect, SwRect* pIntersect ) const
778cdf0e10cSrcweir {
779cdf0e10cSrcweir     Size aSize( rPor.Width(), rPor.Height() );
780cdf0e10cSrcweir     if( rPor.IsHangingPortion() )
781cdf0e10cSrcweir         aSize.Width() = ((SwHangingPortion&)rPor).GetInnerWidth();
782cdf0e10cSrcweir     if( rPor.InSpaceGrp() && GetSpaceAdd() )
783cdf0e10cSrcweir     {
784cdf0e10cSrcweir         SwTwips nAdd = rPor.CalcSpacing( GetSpaceAdd(), *this );
785cdf0e10cSrcweir         if( rPor.InFldGrp() && GetSpaceAdd() < 0 && nAdd )
786cdf0e10cSrcweir             nAdd += GetSpaceAdd() / SPACING_PRECISION_FACTOR;
787cdf0e10cSrcweir         aSize.Width() += nAdd;
788cdf0e10cSrcweir     }
789cdf0e10cSrcweir 
790cdf0e10cSrcweir     Point aPoint;
791cdf0e10cSrcweir 
792cdf0e10cSrcweir     if( IsRotated() )
793cdf0e10cSrcweir     {
794cdf0e10cSrcweir         long nTmp = aSize.Width();
795cdf0e10cSrcweir         aSize.Width() = aSize.Height();
796cdf0e10cSrcweir         aSize.Height() = nTmp;
797cdf0e10cSrcweir         if ( 1 == GetDirection() )
798cdf0e10cSrcweir         {
799cdf0e10cSrcweir             aPoint.A() = X() - rPor.GetAscent();
800cdf0e10cSrcweir             aPoint.B() = Y() - aSize.Height();
801cdf0e10cSrcweir         }
802cdf0e10cSrcweir         else
803cdf0e10cSrcweir         {
804cdf0e10cSrcweir             aPoint.A() = X() - rPor.Height() + rPor.GetAscent();
805cdf0e10cSrcweir             aPoint.B() = Y();
806cdf0e10cSrcweir         }
807cdf0e10cSrcweir     }
808cdf0e10cSrcweir     else
809cdf0e10cSrcweir     {
810cdf0e10cSrcweir         aPoint.A() = X();
811cdf0e10cSrcweir         //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
812cdf0e10cSrcweir         if ( GetTxtFrm()->IsVertLR() )
813cdf0e10cSrcweir             aPoint.B() = Y() - rPor.Height() + rPor.GetAscent();
814cdf0e10cSrcweir         else
815cdf0e10cSrcweir             aPoint.B() = Y() - rPor.GetAscent();
816cdf0e10cSrcweir     }
817cdf0e10cSrcweir 
818cdf0e10cSrcweir     // Adjust x coordinate if we are inside a bidi portion
819cdf0e10cSrcweir     const sal_Bool bFrmDir = GetTxtFrm()->IsRightToLeft();
820cdf0e10cSrcweir     sal_Bool bCounterDir = ( ! bFrmDir && DIR_RIGHT2LEFT == GetDirection() ) ||
821cdf0e10cSrcweir                        (   bFrmDir && DIR_LEFT2RIGHT == GetDirection() );
822cdf0e10cSrcweir 
823cdf0e10cSrcweir     if ( bCounterDir )
824cdf0e10cSrcweir         aPoint.A() -= aSize.Width();
825cdf0e10cSrcweir 
826cdf0e10cSrcweir     SwRect aRect( aPoint, aSize );
827cdf0e10cSrcweir 
828cdf0e10cSrcweir     if ( GetTxtFrm()->IsRightToLeft() )
829cdf0e10cSrcweir         GetTxtFrm()->SwitchLTRtoRTL( aRect );
830cdf0e10cSrcweir 
831cdf0e10cSrcweir     if ( GetTxtFrm()->IsVertical() )
832cdf0e10cSrcweir         GetTxtFrm()->SwitchHorizontalToVertical( aRect );
833cdf0e10cSrcweir 
834cdf0e10cSrcweir     if ( pRect )
835cdf0e10cSrcweir         *pRect = aRect;
836cdf0e10cSrcweir 
837cdf0e10cSrcweir     if( aRect.HasArea() && pIntersect )
838cdf0e10cSrcweir     {
839cdf0e10cSrcweir         ::SwAlignRect( aRect, (ViewShell*)GetVsh() );
840cdf0e10cSrcweir 
841cdf0e10cSrcweir         if ( GetOut()->IsClipRegion() )
842cdf0e10cSrcweir         {
843cdf0e10cSrcweir             SwRect aClip( GetOut()->GetClipRegion().GetBoundRect() );
844cdf0e10cSrcweir             aRect.Intersection( aClip );
845cdf0e10cSrcweir         }
846cdf0e10cSrcweir 
847cdf0e10cSrcweir         *pIntersect = aRect;
848cdf0e10cSrcweir     }
849cdf0e10cSrcweir }
850cdf0e10cSrcweir 
851cdf0e10cSrcweir /*************************************************************************
852cdf0e10cSrcweir  *                          lcl_DrawSpecial
853cdf0e10cSrcweir  *
854cdf0e10cSrcweir  * Draws a special portion, e.g., line break portion, tab portion.
855cdf0e10cSrcweir  * rPor - The portion
856cdf0e10cSrcweir  * rRect - The rectangle surrounding the character
857cdf0e10cSrcweir  * pCol     - Specify a color for the character
858cdf0e10cSrcweir  * bCenter  - Draw the character centered, otherwise left aligned
859cdf0e10cSrcweir  * bRotate  - Rotate the character if character rotation is set
860cdf0e10cSrcweir  *************************************************************************/
861cdf0e10cSrcweir 
lcl_DrawSpecial(const SwTxtPaintInfo & rInf,const SwLinePortion & rPor,SwRect & rRect,const Color * pCol,sal_Unicode cChar,sal_uInt8 nOptions)862cdf0e10cSrcweir static void lcl_DrawSpecial( const SwTxtPaintInfo& rInf, const SwLinePortion& rPor,
863cdf0e10cSrcweir                       SwRect& rRect, const Color* pCol, sal_Unicode cChar,
864cdf0e10cSrcweir                       sal_uInt8 nOptions )
865cdf0e10cSrcweir {
866cdf0e10cSrcweir     sal_Bool bCenter = 0 != ( nOptions & DRAW_SPECIAL_OPTIONS_CENTER );
867cdf0e10cSrcweir     sal_Bool bRotate = 0 != ( nOptions & DRAW_SPECIAL_OPTIONS_ROTATE );
868cdf0e10cSrcweir 
869cdf0e10cSrcweir     // rRect is given in absolute coordinates
870cdf0e10cSrcweir     if ( rInf.GetTxtFrm()->IsRightToLeft() )
871cdf0e10cSrcweir         rInf.GetTxtFrm()->SwitchRTLtoLTR( rRect );
872cdf0e10cSrcweir     if ( rInf.GetTxtFrm()->IsVertical() )
873cdf0e10cSrcweir         rInf.GetTxtFrm()->SwitchVerticalToHorizontal( rRect );
874cdf0e10cSrcweir 
875cdf0e10cSrcweir     const SwFont* pOldFnt = rInf.GetFont();
876cdf0e10cSrcweir 
877cdf0e10cSrcweir     // Font is generated only once:
878cdf0e10cSrcweir     static SwFont* pFnt = 0;
879cdf0e10cSrcweir     if ( ! pFnt )
880cdf0e10cSrcweir     {
881cdf0e10cSrcweir         pFnt = new SwFont( *pOldFnt );
882cdf0e10cSrcweir         pFnt->SetFamily( FAMILY_DONTKNOW, pFnt->GetActual() );
883cdf0e10cSrcweir         pFnt->SetName( numfunc::GetDefBulletFontname(), pFnt->GetActual() );
884cdf0e10cSrcweir         pFnt->SetStyleName( aEmptyStr, pFnt->GetActual() );
885cdf0e10cSrcweir         pFnt->SetCharSet( RTL_TEXTENCODING_SYMBOL, pFnt->GetActual() );
886cdf0e10cSrcweir     }
887cdf0e10cSrcweir 
888cdf0e10cSrcweir     // Some of the current values are set at the font:
889cdf0e10cSrcweir     if ( ! bRotate )
890cdf0e10cSrcweir         pFnt->SetVertical( 0, rInf.GetTxtFrm()->IsVertical() );
891cdf0e10cSrcweir     else
892cdf0e10cSrcweir         pFnt->SetVertical( pOldFnt->GetOrientation() );
893cdf0e10cSrcweir 
894cdf0e10cSrcweir     if ( pCol )
895cdf0e10cSrcweir         pFnt->SetColor( *pCol );
896cdf0e10cSrcweir     else
897cdf0e10cSrcweir         pFnt->SetColor( pOldFnt->GetColor() );
898cdf0e10cSrcweir 
899cdf0e10cSrcweir     Size aFontSize( 0, SPECIAL_FONT_HEIGHT );
900cdf0e10cSrcweir     pFnt->SetSize( aFontSize, pFnt->GetActual() );
901cdf0e10cSrcweir 
902cdf0e10cSrcweir     ((SwTxtPaintInfo&)rInf).SetFont( pFnt );
903cdf0e10cSrcweir 
904cdf0e10cSrcweir     // The maximum width depends on the current orientation
905cdf0e10cSrcweir     const sal_uInt16 nDir = pFnt->GetOrientation( rInf.GetTxtFrm()->IsVertical() );
906cdf0e10cSrcweir     SwTwips nMaxWidth = 0;
907cdf0e10cSrcweir     switch ( nDir )
908cdf0e10cSrcweir     {
909cdf0e10cSrcweir     case 0 :
910cdf0e10cSrcweir         nMaxWidth = rRect.Width();
911cdf0e10cSrcweir         break;
912cdf0e10cSrcweir     case 900 :
913cdf0e10cSrcweir     case 2700 :
914cdf0e10cSrcweir         nMaxWidth = rRect.Height();
915cdf0e10cSrcweir         break;
916cdf0e10cSrcweir     default:
917cdf0e10cSrcweir         ASSERT( sal_False, "Unknown direction set at font" )
918cdf0e10cSrcweir         break;
919cdf0e10cSrcweir     }
920cdf0e10cSrcweir 
921cdf0e10cSrcweir     // check if char fits into rectangle
922cdf0e10cSrcweir     const XubString aTmp( cChar );
923cdf0e10cSrcweir     aFontSize = rInf.GetTxtSize( aTmp ).SvLSize();
924cdf0e10cSrcweir     while ( aFontSize.Width() > nMaxWidth )
925cdf0e10cSrcweir     {
926cdf0e10cSrcweir         SwTwips nFactor = ( 100 * aFontSize.Width() ) / nMaxWidth;
927cdf0e10cSrcweir         const SwTwips nOldWidth = aFontSize.Width();
928cdf0e10cSrcweir 
929cdf0e10cSrcweir         // new height for font
930cdf0e10cSrcweir         const sal_uInt8 nAct = pFnt->GetActual();
931cdf0e10cSrcweir         aFontSize.Height() = ( 100 * pFnt->GetSize( nAct ).Height() ) / nFactor;
932cdf0e10cSrcweir         aFontSize.Width() = ( 100 * pFnt->GetSize( nAct).Width() ) / nFactor;
933cdf0e10cSrcweir 
934cdf0e10cSrcweir         if ( !aFontSize.Width() && !aFontSize.Height() )
935cdf0e10cSrcweir             break;
936cdf0e10cSrcweir 
937cdf0e10cSrcweir         pFnt->SetSize( aFontSize, nAct );
938cdf0e10cSrcweir 
939cdf0e10cSrcweir         aFontSize = rInf.GetTxtSize( aTmp ).SvLSize();
940cdf0e10cSrcweir 
941cdf0e10cSrcweir         if ( aFontSize.Width() >= nOldWidth )
942cdf0e10cSrcweir             break;
943cdf0e10cSrcweir     }
944cdf0e10cSrcweir 
945cdf0e10cSrcweir     const Point aOldPos( rInf.GetPos() );
946cdf0e10cSrcweir 
947cdf0e10cSrcweir     // adjust values so that tab is vertically and horizontally centered
948cdf0e10cSrcweir     SwTwips nX = rRect.Left();
949cdf0e10cSrcweir     SwTwips nY = rRect.Top();
950cdf0e10cSrcweir     switch ( nDir )
951cdf0e10cSrcweir     {
952cdf0e10cSrcweir     case 0 :
953cdf0e10cSrcweir         if ( bCenter )
954cdf0e10cSrcweir             nX += ( rRect.Width() - aFontSize.Width() ) / 2;
955cdf0e10cSrcweir         nY += ( rRect.Height() - aFontSize.Height() ) / 2 + rInf.GetAscent();
956cdf0e10cSrcweir         break;
957cdf0e10cSrcweir     case 900 :
958cdf0e10cSrcweir         if ( bCenter )
959cdf0e10cSrcweir             nX += ( rRect.Width() - aFontSize.Height() ) / 2 + rInf.GetAscent();
960cdf0e10cSrcweir         nY += ( rRect.Height() + aFontSize.Width() ) / 2;
961cdf0e10cSrcweir         break;
962cdf0e10cSrcweir     case 2700 :
963cdf0e10cSrcweir         if ( bCenter )
964cdf0e10cSrcweir             nX += ( rRect.Width() + aFontSize.Height() ) / 2 - rInf.GetAscent();
965cdf0e10cSrcweir         nY += ( rRect.Height() - aFontSize.Width() ) / 2;
966cdf0e10cSrcweir         break;
967cdf0e10cSrcweir     }
968cdf0e10cSrcweir 
969cdf0e10cSrcweir     Point aTmpPos( nX, nY );
970cdf0e10cSrcweir     ((SwTxtPaintInfo&)rInf).SetPos( aTmpPos );
971cdf0e10cSrcweir     sal_uInt16 nOldWidth = rPor.Width();
972cdf0e10cSrcweir     ((SwLinePortion&)rPor).Width( (sal_uInt16)aFontSize.Width() );
973cdf0e10cSrcweir     rInf.DrawText( aTmp, rPor );
974cdf0e10cSrcweir     ((SwLinePortion&)rPor).Width( nOldWidth );
975cdf0e10cSrcweir     ((SwTxtPaintInfo&)rInf).SetFont( (SwFont*)pOldFnt );
976cdf0e10cSrcweir     ((SwTxtPaintInfo&)rInf).SetPos( aOldPos );
977cdf0e10cSrcweir }
978cdf0e10cSrcweir 
979cdf0e10cSrcweir /*************************************************************************
980cdf0e10cSrcweir  *                     SwTxtPaintInfo::DrawRect()
981cdf0e10cSrcweir  *************************************************************************/
982cdf0e10cSrcweir 
DrawRect(const SwRect & rRect,sal_Bool bNoGraphic,sal_Bool bRetouche) const983cdf0e10cSrcweir void SwTxtPaintInfo::DrawRect( const SwRect &rRect, sal_Bool bNoGraphic,
984cdf0e10cSrcweir                                sal_Bool bRetouche ) const
985cdf0e10cSrcweir {
986cdf0e10cSrcweir     if ( OnWin() || !bRetouche )
987cdf0e10cSrcweir     {
988cdf0e10cSrcweir         if( aTxtFly.IsOn() )
989cdf0e10cSrcweir             ((SwTxtPaintInfo*)this)->GetTxtFly()->
990cdf0e10cSrcweir                 DrawFlyRect( pOut, rRect, *this, bNoGraphic );
991cdf0e10cSrcweir         else if ( bNoGraphic )
992cdf0e10cSrcweir             pOut->DrawRect( rRect.SVRect() );
993cdf0e10cSrcweir         else
994cdf0e10cSrcweir         {
99564b14621SArmin Le Grand             if(pBrushItem != ((SvxBrushItem*)-1))
99664b14621SArmin Le Grand             {
997cdf0e10cSrcweir                 ::DrawGraphic( pBrushItem, pOut, aItemRect, rRect );
998cdf0e10cSrcweir             }
99964b14621SArmin Le Grand             else
100064b14621SArmin Le Grand             {
100164b14621SArmin Le Grand                 OSL_ENSURE(false, "DrawRect: Uninitialized BrushItem!" );
100264b14621SArmin Le Grand             }
100364b14621SArmin Le Grand         }
1004cdf0e10cSrcweir     }
1005cdf0e10cSrcweir }
1006cdf0e10cSrcweir 
1007cdf0e10cSrcweir /*************************************************************************
1008cdf0e10cSrcweir  *                     SwTxtPaintInfo::DrawTab()
1009cdf0e10cSrcweir  *************************************************************************/
1010cdf0e10cSrcweir 
DrawTab(const SwLinePortion & rPor) const1011cdf0e10cSrcweir void SwTxtPaintInfo::DrawTab( const SwLinePortion &rPor ) const
1012cdf0e10cSrcweir {
1013cdf0e10cSrcweir     if( OnWin() )
1014cdf0e10cSrcweir     {
1015cdf0e10cSrcweir         SwRect aRect;
1016cdf0e10cSrcweir         CalcRect( rPor, &aRect );
1017cdf0e10cSrcweir 
1018cdf0e10cSrcweir         if ( ! aRect.HasArea() )
1019cdf0e10cSrcweir             return;
1020cdf0e10cSrcweir 
1021cdf0e10cSrcweir         const sal_Unicode cChar = GetTxtFrm()->IsRightToLeft() ?
1022cdf0e10cSrcweir                                   CHAR_TAB_RTL : CHAR_TAB;
1023cdf0e10cSrcweir         const sal_uInt8 nOptions = DRAW_SPECIAL_OPTIONS_CENTER |
1024cdf0e10cSrcweir                               DRAW_SPECIAL_OPTIONS_ROTATE;
1025cdf0e10cSrcweir         lcl_DrawSpecial( *this, rPor, aRect, 0, cChar, nOptions );
1026cdf0e10cSrcweir     }
1027cdf0e10cSrcweir }
1028cdf0e10cSrcweir 
1029cdf0e10cSrcweir /*************************************************************************
1030cdf0e10cSrcweir  *                     SwTxtPaintInfo::DrawLineBreak()
1031cdf0e10cSrcweir  *************************************************************************/
1032cdf0e10cSrcweir 
DrawLineBreak(const SwLinePortion & rPor) const1033cdf0e10cSrcweir void SwTxtPaintInfo::DrawLineBreak( const SwLinePortion &rPor ) const
1034cdf0e10cSrcweir {
1035cdf0e10cSrcweir     if( OnWin() )
1036cdf0e10cSrcweir     {
1037cdf0e10cSrcweir         KSHORT nOldWidth = rPor.Width();
1038cdf0e10cSrcweir         ((SwLinePortion&)rPor).Width( LINE_BREAK_WIDTH );
1039cdf0e10cSrcweir 
1040cdf0e10cSrcweir         SwRect aRect;
1041cdf0e10cSrcweir         CalcRect( rPor, &aRect );
1042cdf0e10cSrcweir 
1043cdf0e10cSrcweir         if( aRect.HasArea() )
1044cdf0e10cSrcweir         {
1045cdf0e10cSrcweir             const sal_Unicode cChar = GetTxtFrm()->IsRightToLeft() ?
1046cdf0e10cSrcweir                                       CHAR_LINEBREAK_RTL : CHAR_LINEBREAK;
1047cdf0e10cSrcweir             const sal_uInt8 nOptions = 0;
1048cdf0e10cSrcweir             lcl_DrawSpecial( *this, rPor, aRect, 0, cChar, nOptions );
1049cdf0e10cSrcweir         }
1050cdf0e10cSrcweir 
1051cdf0e10cSrcweir         ((SwLinePortion&)rPor).Width( nOldWidth );
1052cdf0e10cSrcweir     }
1053cdf0e10cSrcweir }
1054cdf0e10cSrcweir 
1055cdf0e10cSrcweir 
1056cdf0e10cSrcweir /*************************************************************************
1057cdf0e10cSrcweir  *                     SwTxtPaintInfo::DrawRedArrow()
1058cdf0e10cSrcweir  *************************************************************************/
1059cdf0e10cSrcweir 
DrawRedArrow(const SwLinePortion & rPor) const1060cdf0e10cSrcweir void SwTxtPaintInfo::DrawRedArrow( const SwLinePortion &rPor ) const
1061cdf0e10cSrcweir {
1062cdf0e10cSrcweir     Size aSize( SPECIAL_FONT_HEIGHT, SPECIAL_FONT_HEIGHT );
1063cdf0e10cSrcweir     SwRect aRect( ((SwArrowPortion&)rPor).GetPos(), aSize );
1064cdf0e10cSrcweir     sal_Unicode cChar;
1065cdf0e10cSrcweir     if( ((SwArrowPortion&)rPor).IsLeft() )
1066cdf0e10cSrcweir     {
1067cdf0e10cSrcweir         aRect.Pos().Y() += 20 - GetAscent();
1068cdf0e10cSrcweir         aRect.Pos().X() += 20;
1069cdf0e10cSrcweir         if( aSize.Height() > rPor.Height() )
1070cdf0e10cSrcweir             aRect.Height( rPor.Height() );
1071cdf0e10cSrcweir         cChar = CHAR_LEFT_ARROW;
1072cdf0e10cSrcweir     }
1073cdf0e10cSrcweir     else
1074cdf0e10cSrcweir     {
1075cdf0e10cSrcweir         if( aSize.Height() > rPor.Height() )
1076cdf0e10cSrcweir             aRect.Height( rPor.Height() );
1077cdf0e10cSrcweir         aRect.Pos().Y() -= aRect.Height() + 20;
1078cdf0e10cSrcweir         aRect.Pos().X() -= aRect.Width() + 20;
1079cdf0e10cSrcweir         cChar = CHAR_RIGHT_ARROW;
1080cdf0e10cSrcweir     }
1081cdf0e10cSrcweir 
1082cdf0e10cSrcweir     if ( GetTxtFrm()->IsVertical() )
1083cdf0e10cSrcweir         GetTxtFrm()->SwitchHorizontalToVertical( aRect );
1084cdf0e10cSrcweir 
1085cdf0e10cSrcweir     Color aCol( COL_LIGHTRED );
1086cdf0e10cSrcweir 
1087cdf0e10cSrcweir     if( aRect.HasArea() )
1088cdf0e10cSrcweir     {
1089cdf0e10cSrcweir         const sal_uInt8 nOptions = 0;
1090cdf0e10cSrcweir         lcl_DrawSpecial( *this, rPor, aRect, &aCol, cChar, nOptions );
1091cdf0e10cSrcweir     }
1092cdf0e10cSrcweir }
1093cdf0e10cSrcweir 
1094cdf0e10cSrcweir 
1095cdf0e10cSrcweir /*************************************************************************
1096cdf0e10cSrcweir  *                     SwTxtPaintInfo::DrawPostIts()
1097cdf0e10cSrcweir  *************************************************************************/
1098cdf0e10cSrcweir 
DrawPostIts(const SwLinePortion &,sal_Bool bScript) const1099cdf0e10cSrcweir void SwTxtPaintInfo::DrawPostIts( const SwLinePortion&, sal_Bool bScript ) const
1100cdf0e10cSrcweir {
1101cdf0e10cSrcweir     if( OnWin() && pOpt->IsPostIts() )
1102cdf0e10cSrcweir     {
1103cdf0e10cSrcweir         Size aSize;
1104cdf0e10cSrcweir         Point aTmp;
1105cdf0e10cSrcweir 
1106cdf0e10cSrcweir         const sal_uInt16 nPostItsWidth = pOpt->GetPostItsWidth( GetOut() );
1107cdf0e10cSrcweir         const sal_uInt16 nFontHeight = pFnt->GetHeight( pVsh, *GetOut() );
1108cdf0e10cSrcweir         const sal_uInt16 nFontAscent = pFnt->GetAscent( pVsh, *GetOut() );
1109cdf0e10cSrcweir 
1110cdf0e10cSrcweir         switch ( pFnt->GetOrientation( GetTxtFrm()->IsVertical() ) )
1111cdf0e10cSrcweir         {
1112cdf0e10cSrcweir         case 0 :
1113cdf0e10cSrcweir             aSize.Width() = nPostItsWidth;
1114cdf0e10cSrcweir             aSize.Height() = nFontHeight;
1115cdf0e10cSrcweir             aTmp.X() = aPos.X();
1116cdf0e10cSrcweir             aTmp.Y() = aPos.Y() - nFontAscent;
1117cdf0e10cSrcweir             break;
1118cdf0e10cSrcweir         case 900 :
1119cdf0e10cSrcweir             aSize.Height() = nPostItsWidth;
1120cdf0e10cSrcweir             aSize.Width() = nFontHeight;
1121cdf0e10cSrcweir             aTmp.X() = aPos.X() - nFontAscent;
1122cdf0e10cSrcweir             aTmp.Y() = aPos.Y();
1123cdf0e10cSrcweir             break;
1124cdf0e10cSrcweir         case 2700 :
1125cdf0e10cSrcweir             aSize.Height() = nPostItsWidth;
1126cdf0e10cSrcweir             aSize.Width() = nFontHeight;
1127cdf0e10cSrcweir             aTmp.X() = aPos.X() - nFontHeight +
1128cdf0e10cSrcweir                                   nFontAscent;
1129cdf0e10cSrcweir             aTmp.Y() = aPos.Y();
1130cdf0e10cSrcweir             break;
1131cdf0e10cSrcweir         }
1132cdf0e10cSrcweir 
1133cdf0e10cSrcweir         SwRect aTmpRect( aTmp, aSize );
1134cdf0e10cSrcweir 
1135cdf0e10cSrcweir         if ( GetTxtFrm()->IsRightToLeft() )
1136cdf0e10cSrcweir             GetTxtFrm()->SwitchLTRtoRTL( aTmpRect );
1137cdf0e10cSrcweir 
1138cdf0e10cSrcweir         if ( GetTxtFrm()->IsVertical() )
1139cdf0e10cSrcweir             GetTxtFrm()->SwitchHorizontalToVertical( aTmpRect );
1140cdf0e10cSrcweir 
1141cdf0e10cSrcweir         const Rectangle aRect( aTmpRect.SVRect() );
1142cdf0e10cSrcweir         pOpt->PaintPostIts( (OutputDevice*)GetOut(), aRect, bScript );
1143cdf0e10cSrcweir     }
1144cdf0e10cSrcweir }
1145cdf0e10cSrcweir 
DrawCheckBox(const SwFieldFormPortion & rPor,bool checked) const1146cdf0e10cSrcweir void SwTxtPaintInfo::DrawCheckBox( const SwFieldFormPortion &rPor, bool checked) const
1147cdf0e10cSrcweir {
1148cdf0e10cSrcweir     SwRect aIntersect;
1149cdf0e10cSrcweir     CalcRect( rPor, &aIntersect, 0 );
1150cdf0e10cSrcweir     if ( aIntersect.HasArea() )
1151cdf0e10cSrcweir     {
1152cdf0e10cSrcweir         if (OnWin() && SwViewOption::IsFieldShadings() &&
1153cdf0e10cSrcweir                 !GetOpt().IsPagePreview())
1154cdf0e10cSrcweir         {
1155cdf0e10cSrcweir             OutputDevice* pOut_ = (OutputDevice*)GetOut();
1156cdf0e10cSrcweir             pOut_->Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
1157cdf0e10cSrcweir             pOut_->SetFillColor( SwViewOption::GetFieldShadingsColor() );
1158cdf0e10cSrcweir             pOut_->SetLineColor();
1159cdf0e10cSrcweir             pOut_->DrawRect( aIntersect.SVRect() );
1160cdf0e10cSrcweir             pOut_->Pop();
1161cdf0e10cSrcweir         }
1162cdf0e10cSrcweir         const int delta=10;
1163cdf0e10cSrcweir         Rectangle r(aIntersect.Left()+delta, aIntersect.Top()+delta, aIntersect.Right()-delta, aIntersect.Bottom()-delta);
1164cdf0e10cSrcweir         pOut->Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
1165cdf0e10cSrcweir         pOut->SetLineColor( Color(0, 0, 0));
1166cdf0e10cSrcweir         pOut->SetFillColor();
1167cdf0e10cSrcweir         pOut->DrawRect( r );
1168cdf0e10cSrcweir         if (checked) {
1169cdf0e10cSrcweir             pOut->DrawLine(r.TopLeft(), r.BottomRight());
1170cdf0e10cSrcweir             pOut->DrawLine(r.TopRight(), r.BottomLeft());
1171cdf0e10cSrcweir         }
1172cdf0e10cSrcweir         pOut->Pop();
1173cdf0e10cSrcweir     }
1174cdf0e10cSrcweir }
1175cdf0e10cSrcweir /*************************************************************************
1176cdf0e10cSrcweir  *                     SwTxtPaintInfo::DrawBackGround()
1177cdf0e10cSrcweir  *************************************************************************/
DrawBackground(const SwLinePortion & rPor) const1178cdf0e10cSrcweir void SwTxtPaintInfo::DrawBackground( const SwLinePortion &rPor ) const
1179cdf0e10cSrcweir {
118086e1cf34SPedro Giffuni     ASSERT( OnWin(), "SwTxtPaintInfo::DrawBackground: printer pollution ?" );
1181cdf0e10cSrcweir 
1182cdf0e10cSrcweir     SwRect aIntersect;
1183cdf0e10cSrcweir     CalcRect( rPor, 0, &aIntersect );
1184cdf0e10cSrcweir 
1185cdf0e10cSrcweir     if ( aIntersect.HasArea() )
1186cdf0e10cSrcweir     {
1187cdf0e10cSrcweir         OutputDevice* pTmpOut = (OutputDevice*)GetOut();
1188cdf0e10cSrcweir         pTmpOut->Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
1189cdf0e10cSrcweir 
1190cdf0e10cSrcweir         // For dark background we do not want to have a filled rectangle
1191cdf0e10cSrcweir         if ( GetVsh() && GetVsh()->GetWin() && lcl_IsDarkBackground( *this ) )
1192cdf0e10cSrcweir         {
1193cdf0e10cSrcweir             pTmpOut->SetLineColor( SwViewOption::GetFontColor().GetColor() );
1194cdf0e10cSrcweir         }
1195cdf0e10cSrcweir         else
1196cdf0e10cSrcweir         {
1197cdf0e10cSrcweir             pTmpOut->SetFillColor( SwViewOption::GetFieldShadingsColor() );
1198cdf0e10cSrcweir             pTmpOut->SetLineColor();
1199cdf0e10cSrcweir         }
1200cdf0e10cSrcweir 
1201cdf0e10cSrcweir         DrawRect( aIntersect, sal_True );
1202cdf0e10cSrcweir         pTmpOut->Pop();
1203cdf0e10cSrcweir     }
1204cdf0e10cSrcweir }
1205cdf0e10cSrcweir 
_DrawBackBrush(const SwLinePortion & rPor) const1206cdf0e10cSrcweir void SwTxtPaintInfo::_DrawBackBrush( const SwLinePortion &rPor ) const
1207cdf0e10cSrcweir {
1208cdf0e10cSrcweir     {
1209cdf0e10cSrcweir         SwRect aIntersect;
1210cdf0e10cSrcweir         CalcRect( rPor, &aIntersect, 0 );
1211cdf0e10cSrcweir         if(aIntersect.HasArea())
1212cdf0e10cSrcweir         {
1213cdf0e10cSrcweir             SwTxtNode *pNd = pFrm->GetTxtNode();
1214dec99bbdSOliver-Rainer Wittmann             const ::sw::mark::IMark* pFieldmark = NULL;
1215cdf0e10cSrcweir             if(pNd)
1216cdf0e10cSrcweir             {
1217cdf0e10cSrcweir                 const SwDoc *doc=pNd->GetDoc();
1218cdf0e10cSrcweir                 if(doc)
1219cdf0e10cSrcweir                 {
1220cdf0e10cSrcweir                     SwIndex aIndex(pNd, GetIdx());
1221cdf0e10cSrcweir                     SwPosition aPosition(*pNd, aIndex);
1222cdf0e10cSrcweir                     pFieldmark=doc->getIDocumentMarkAccess()->getFieldmarkFor(aPosition);
1223cdf0e10cSrcweir                 }
1224cdf0e10cSrcweir             }
1225cdf0e10cSrcweir             bool bIsStartMark=(1==GetLen() && CH_TXT_ATR_FIELDSTART==GetTxt().GetChar(GetIdx()));
1226cdf0e10cSrcweir             if(pFieldmark) {
1227cdf0e10cSrcweir                 OSL_TRACE("Found Fieldmark");
1228cdf0e10cSrcweir #if DEBUG
1229cdf0e10cSrcweir                 rtl::OUString str = pFieldmark->ToString( );
1230cdf0e10cSrcweir                 fprintf( stderr, "%s\n", rtl::OUStringToOString( str, RTL_TEXTENCODING_UTF8 ).getStr( ) );
1231cdf0e10cSrcweir #endif
1232cdf0e10cSrcweir             }
1233cdf0e10cSrcweir             if(bIsStartMark) OSL_TRACE("Found StartMark");
1234cdf0e10cSrcweir             if (OnWin() && (pFieldmark!=NULL || bIsStartMark) &&
1235cdf0e10cSrcweir                     SwViewOption::IsFieldShadings() &&
1236cdf0e10cSrcweir                     !GetOpt().IsPagePreview())
1237cdf0e10cSrcweir             {
1238cdf0e10cSrcweir                 OutputDevice* pOutDev = (OutputDevice*)GetOut();
1239cdf0e10cSrcweir                 pOutDev->Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
1240cdf0e10cSrcweir                 pOutDev->SetFillColor( SwViewOption::GetFieldShadingsColor() );
1241cdf0e10cSrcweir                 pOutDev->SetLineColor( );
1242cdf0e10cSrcweir                 pOutDev->DrawRect( aIntersect.SVRect() );
1243cdf0e10cSrcweir                 pOutDev->Pop();
1244cdf0e10cSrcweir             }
1245cdf0e10cSrcweir         }
1246cdf0e10cSrcweir     }
1247cdf0e10cSrcweir     if( !pFnt->GetBackColor() ) return;
1248cdf0e10cSrcweir 
1249cdf0e10cSrcweir     ASSERT( pFnt->GetBackColor(), "DrawBackBrush: Lost Color" );
1250cdf0e10cSrcweir 
1251cdf0e10cSrcweir     SwRect aIntersect;
1252cdf0e10cSrcweir     CalcRect( rPor, 0, &aIntersect );
1253cdf0e10cSrcweir 
1254cdf0e10cSrcweir     if ( aIntersect.HasArea() )
1255cdf0e10cSrcweir     {
1256cdf0e10cSrcweir         OutputDevice* pTmpOut = (OutputDevice*)GetOut();
1257cdf0e10cSrcweir 
1258cdf0e10cSrcweir         // --> FME 2004-06-24 #i16816# tagged pdf support
1259cdf0e10cSrcweir         SwTaggedPDFHelper aTaggedPDFHelper( 0, 0, 0, *pTmpOut );
1260cdf0e10cSrcweir         // <--
1261cdf0e10cSrcweir 
1262cdf0e10cSrcweir         pTmpOut->Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
1263cdf0e10cSrcweir 
1264cdf0e10cSrcweir         pTmpOut->SetFillColor( *pFnt->GetBackColor() );
1265cdf0e10cSrcweir         pTmpOut->SetLineColor();
1266cdf0e10cSrcweir 
1267cdf0e10cSrcweir         DrawRect( aIntersect, sal_True, sal_False );
1268cdf0e10cSrcweir 
1269cdf0e10cSrcweir         pTmpOut->Pop();
1270cdf0e10cSrcweir     }
1271cdf0e10cSrcweir }
1272cdf0e10cSrcweir 
1273cdf0e10cSrcweir /*************************************************************************
1274cdf0e10cSrcweir  *                     SwTxtPaintInfo::DrawViewOpt()
1275cdf0e10cSrcweir  *************************************************************************/
1276cdf0e10cSrcweir 
DrawViewOpt(const SwLinePortion & rPor,const MSHORT nWhich) const1277cdf0e10cSrcweir void SwTxtPaintInfo::DrawViewOpt( const SwLinePortion &rPor,
1278cdf0e10cSrcweir                                   const MSHORT nWhich ) const
1279cdf0e10cSrcweir {
1280cdf0e10cSrcweir     if( OnWin() && !IsMulti() )
1281cdf0e10cSrcweir     {
1282cdf0e10cSrcweir         sal_Bool bDraw = sal_False;
1283cdf0e10cSrcweir         switch( nWhich )
1284cdf0e10cSrcweir         {
1285cdf0e10cSrcweir         case POR_FTN:
1286cdf0e10cSrcweir         case POR_QUOVADIS:
1287cdf0e10cSrcweir         case POR_NUMBER:
1288cdf0e10cSrcweir         case POR_FLD:
1289cdf0e10cSrcweir         case POR_URL:
1290cdf0e10cSrcweir         case POR_HIDDEN:
1291cdf0e10cSrcweir         case POR_TOX:
1292cdf0e10cSrcweir         case POR_REF:
1293cdf0e10cSrcweir         case POR_META:
1294cdf0e10cSrcweir         case POR_CONTROLCHAR:
129569a74367SOliver-Rainer Wittmann             if ( !GetOpt().IsPagePreview()
129669a74367SOliver-Rainer Wittmann                  && !GetOpt().IsReadonly()
129769a74367SOliver-Rainer Wittmann                  && SwViewOption::IsFieldShadings()
129869a74367SOliver-Rainer Wittmann                  && ( POR_NUMBER != nWhich
129969a74367SOliver-Rainer Wittmann                       || pFrm->GetTxtNode()->HasMarkedLabel())) // #i27615#
130069a74367SOliver-Rainer Wittmann             {
1301cdf0e10cSrcweir                 bDraw = sal_True;
130269a74367SOliver-Rainer Wittmann             }
130369a74367SOliver-Rainer Wittmann             break;
130469a74367SOliver-Rainer Wittmann         case POR_INPUTFLD:
130569a74367SOliver-Rainer Wittmann             // input field shading also in read-only mode
130669a74367SOliver-Rainer Wittmann             if ( !GetOpt().IsPagePreview()
130769a74367SOliver-Rainer Wittmann                  && SwViewOption::IsFieldShadings() )
130869a74367SOliver-Rainer Wittmann             {
130969a74367SOliver-Rainer Wittmann                 bDraw = sal_True;
131069a74367SOliver-Rainer Wittmann             }
1311cdf0e10cSrcweir             break;
1312cdf0e10cSrcweir         case POR_TAB:       if ( GetOpt().IsTab() )     bDraw = sal_True; break;
1313cdf0e10cSrcweir         case POR_SOFTHYPH:  if ( GetOpt().IsSoftHyph() )bDraw = sal_True; break;
1314cdf0e10cSrcweir         case POR_BLANK:     if ( GetOpt().IsHardBlank())bDraw = sal_True; break;
1315cdf0e10cSrcweir         default:
1316cdf0e10cSrcweir             {
1317870262e3SDon Lewis                 ASSERT( sal_False, "SwTxtPaintInfo::DrawViewOpt: don't know how to draw this" );
1318cdf0e10cSrcweir                 break;
1319cdf0e10cSrcweir             }
1320cdf0e10cSrcweir         }
1321cdf0e10cSrcweir         if ( bDraw )
1322cdf0e10cSrcweir             DrawBackground( rPor );
1323cdf0e10cSrcweir     }
1324cdf0e10cSrcweir }
1325cdf0e10cSrcweir 
1326cdf0e10cSrcweir /*************************************************************************
1327cdf0e10cSrcweir  *                     SwTxtPaintInfo::_NotifyURL()
1328cdf0e10cSrcweir  *************************************************************************/
1329cdf0e10cSrcweir 
_NotifyURL(const SwLinePortion & rPor) const1330cdf0e10cSrcweir void SwTxtPaintInfo::_NotifyURL( const SwLinePortion &rPor ) const
1331cdf0e10cSrcweir {
1332cdf0e10cSrcweir     ASSERT( pNoteURL, "NotifyURL: pNoteURL gone with the wind!" );
1333cdf0e10cSrcweir 
1334cdf0e10cSrcweir     SwRect aIntersect;
1335cdf0e10cSrcweir     CalcRect( rPor, 0, &aIntersect );
1336cdf0e10cSrcweir 
1337cdf0e10cSrcweir     if( aIntersect.HasArea() )
1338cdf0e10cSrcweir     {
1339cdf0e10cSrcweir         SwTxtNode *pNd = (SwTxtNode*)GetTxtFrm()->GetTxtNode();
1340cdf0e10cSrcweir         SwTxtAttr *const pAttr =
1341cdf0e10cSrcweir             pNd->GetTxtAttrAt(GetIdx(), RES_TXTATR_INETFMT);
1342cdf0e10cSrcweir         if( pAttr )
1343cdf0e10cSrcweir         {
1344cdf0e10cSrcweir             const SwFmtINetFmt& rFmt = pAttr->GetINetFmt();
1345cdf0e10cSrcweir             pNoteURL->InsertURLNote( rFmt.GetValue(), rFmt.GetTargetFrame(),
1346cdf0e10cSrcweir                 aIntersect );
1347cdf0e10cSrcweir         }
1348cdf0e10cSrcweir     }
1349cdf0e10cSrcweir }
1350cdf0e10cSrcweir 
1351cdf0e10cSrcweir /*************************************************************************
1352cdf0e10cSrcweir  *                  lcl_InitHyphValues()
1353cdf0e10cSrcweir  *************************************************************************/
1354cdf0e10cSrcweir 
lcl_InitHyphValues(PropertyValues & rVals,sal_Int16 nMinLeading,sal_Int16 nMinTrailing)1355cdf0e10cSrcweir static void lcl_InitHyphValues( PropertyValues &rVals,
1356cdf0e10cSrcweir             sal_Int16 nMinLeading, sal_Int16 nMinTrailing )
1357cdf0e10cSrcweir {
1358cdf0e10cSrcweir     sal_Int32 nLen = rVals.getLength();
1359cdf0e10cSrcweir 
1360cdf0e10cSrcweir     if (0 == nLen)  // yet to be initialized?
1361cdf0e10cSrcweir     {
1362cdf0e10cSrcweir         rVals.realloc( 2 );
1363cdf0e10cSrcweir         PropertyValue *pVal = rVals.getArray();
1364cdf0e10cSrcweir 
1365cdf0e10cSrcweir         pVal[0].Name    = C2U( UPN_HYPH_MIN_LEADING );
1366cdf0e10cSrcweir         pVal[0].Handle  = UPH_HYPH_MIN_LEADING;
1367cdf0e10cSrcweir         pVal[0].Value   <<= nMinLeading;
1368cdf0e10cSrcweir 
1369cdf0e10cSrcweir         pVal[1].Name    = C2U( UPN_HYPH_MIN_TRAILING );
1370cdf0e10cSrcweir         pVal[1].Handle  = UPH_HYPH_MIN_TRAILING;
1371cdf0e10cSrcweir         pVal[1].Value   <<= nMinTrailing;
1372cdf0e10cSrcweir     }
1373cdf0e10cSrcweir     else if (2 == nLen) // already initialized once?
1374cdf0e10cSrcweir     {
1375cdf0e10cSrcweir         PropertyValue *pVal = rVals.getArray();
1376cdf0e10cSrcweir         pVal[0].Value <<= nMinLeading;
1377cdf0e10cSrcweir         pVal[1].Value <<= nMinTrailing;
1378cdf0e10cSrcweir     }
1379cdf0e10cSrcweir     else {
1380*0193600aSJohn Bampton         DBG_ERROR( "unexpected size of sequence" );
1381cdf0e10cSrcweir     }
1382cdf0e10cSrcweir }
1383cdf0e10cSrcweir 
1384cdf0e10cSrcweir /*************************************************************************
1385cdf0e10cSrcweir  *                  SwTxtFormatInfo::GetHyphValues()
1386cdf0e10cSrcweir  *************************************************************************/
1387cdf0e10cSrcweir 
GetHyphValues() const1388cdf0e10cSrcweir const PropertyValues & SwTxtFormatInfo::GetHyphValues() const
1389cdf0e10cSrcweir {
1390cdf0e10cSrcweir     DBG_ASSERT( 2 == aHyphVals.getLength(),
1391cdf0e10cSrcweir             "hyphenation values not yet initialized" );
1392cdf0e10cSrcweir     return aHyphVals;
1393cdf0e10cSrcweir }
1394cdf0e10cSrcweir 
1395cdf0e10cSrcweir /*************************************************************************
1396cdf0e10cSrcweir  *                  SwTxtFormatInfo::InitHyph()
1397cdf0e10cSrcweir  *************************************************************************/
1398cdf0e10cSrcweir 
InitHyph(const sal_Bool bAutoHyphen)1399cdf0e10cSrcweir sal_Bool SwTxtFormatInfo::InitHyph( const sal_Bool bAutoHyphen )
1400cdf0e10cSrcweir {
1401cdf0e10cSrcweir     const SwAttrSet& rAttrSet = GetTxtFrm()->GetTxtNode()->GetSwAttrSet();
1402cdf0e10cSrcweir     SetHanging( rAttrSet.GetHangingPunctuation().GetValue() );
1403cdf0e10cSrcweir     SetScriptSpace( rAttrSet.GetScriptSpace().GetValue() );
1404cdf0e10cSrcweir     SetForbiddenChars( rAttrSet.GetForbiddenRule().GetValue() );
1405cdf0e10cSrcweir     const SvxHyphenZoneItem &rAttr = rAttrSet.GetHyphenZone();
1406cdf0e10cSrcweir     MaxHyph() = rAttr.GetMaxHyphens();
1407cdf0e10cSrcweir     sal_Bool bAuto = bAutoHyphen || rAttr.IsHyphen();
1408cdf0e10cSrcweir     if( bAuto || bInterHyph )
1409cdf0e10cSrcweir     {
1410cdf0e10cSrcweir         nHyphStart = nHyphWrdStart = STRING_LEN;
1411cdf0e10cSrcweir         nHyphWrdLen = 0;
1412cdf0e10cSrcweir 
1413cdf0e10cSrcweir         const sal_Int16 nMinimalLeading  = Max(rAttr.GetMinLead(), sal_uInt8(2));
1414cdf0e10cSrcweir         const sal_Int16 nMinimalTrailing = rAttr.GetMinTrail();
1415cdf0e10cSrcweir         lcl_InitHyphValues( aHyphVals, nMinimalLeading, nMinimalTrailing);
1416cdf0e10cSrcweir     }
1417cdf0e10cSrcweir     return bAuto;
1418cdf0e10cSrcweir }
1419cdf0e10cSrcweir 
1420cdf0e10cSrcweir /*************************************************************************
1421cdf0e10cSrcweir  *                  SwTxtFormatInfo::CtorInitTxtFormatInfo()
1422cdf0e10cSrcweir  *************************************************************************/
1423cdf0e10cSrcweir 
CtorInitTxtFormatInfo(SwTxtFrm * pNewFrm,const sal_Bool bNewInterHyph,const sal_Bool bNewQuick,const sal_Bool bTst)1424cdf0e10cSrcweir void SwTxtFormatInfo::CtorInitTxtFormatInfo( SwTxtFrm *pNewFrm, const sal_Bool bNewInterHyph,
1425cdf0e10cSrcweir                                 const sal_Bool bNewQuick, const sal_Bool bTst )
1426cdf0e10cSrcweir {
1427cdf0e10cSrcweir     CtorInitTxtPaintInfo( pNewFrm, SwRect() );
1428cdf0e10cSrcweir 
1429cdf0e10cSrcweir     bQuick = bNewQuick;
1430cdf0e10cSrcweir     bInterHyph = bNewInterHyph;
1431cdf0e10cSrcweir 
1432cdf0e10cSrcweir     //! needs to be done in this order
1433cdf0e10cSrcweir     nMinLeading     = 2;
1434cdf0e10cSrcweir     nMinTrailing    = 2;
1435cdf0e10cSrcweir     nMinWordLength  = 0;
1436cdf0e10cSrcweir     bAutoHyph = InitHyph();
1437cdf0e10cSrcweir 
1438cdf0e10cSrcweir     bIgnoreFly = sal_False;
1439cdf0e10cSrcweir     bFakeLineStart = sal_False;
1440cdf0e10cSrcweir     bShift = sal_False;
1441cdf0e10cSrcweir     bDropInit = sal_False;
1442cdf0e10cSrcweir     bTestFormat = bTst;
1443cdf0e10cSrcweir     nLeft = 0;
1444cdf0e10cSrcweir     nRight = 0;
1445cdf0e10cSrcweir     nFirst = 0;
1446cdf0e10cSrcweir     nRealWidth = 0;
1447cdf0e10cSrcweir     nForcedLeftMargin = 0;
1448cdf0e10cSrcweir     pRest = 0;
1449cdf0e10cSrcweir     nLineHeight = 0;
1450cdf0e10cSrcweir     nLineNettoHeight = 0;
1451cdf0e10cSrcweir     SetLineStart(0);
1452cdf0e10cSrcweir     Init();
1453cdf0e10cSrcweir }
1454cdf0e10cSrcweir 
1455cdf0e10cSrcweir /*************************************************************************
1456cdf0e10cSrcweir  *                  SwTxtFormatInfo::IsHyphenate()
1457cdf0e10cSrcweir  *************************************************************************/
1458cdf0e10cSrcweir // Trennen oder nicht trennen, das ist hier die Frage:
1459cdf0e10cSrcweir // - in keinem Fall trennen, wenn der Hyphenator ERROR zurueckliefert,
1460cdf0e10cSrcweir //   oder wenn als Sprache NOLANGUAGE eingestellt ist.
1461cdf0e10cSrcweir // - ansonsten immer trennen, wenn interaktive Trennung vorliegt
1462cdf0e10cSrcweir // - wenn keine interakt. Trennung, dann nur trennen, wenn im ParaFmt
1463cdf0e10cSrcweir //   automatische Trennung eingestellt ist.
1464cdf0e10cSrcweir 
IsHyphenate() const1465cdf0e10cSrcweir sal_Bool SwTxtFormatInfo::IsHyphenate() const
1466cdf0e10cSrcweir {
1467cdf0e10cSrcweir     if( !bInterHyph && !bAutoHyph )
1468cdf0e10cSrcweir         return sal_False;
1469cdf0e10cSrcweir 
1470cdf0e10cSrcweir     LanguageType eTmp = GetFont()->GetLanguage();
1471cdf0e10cSrcweir     if( LANGUAGE_DONTKNOW == eTmp || LANGUAGE_NONE == eTmp )
1472cdf0e10cSrcweir         return sal_False;
1473cdf0e10cSrcweir 
1474cdf0e10cSrcweir     uno::Reference< XHyphenator > xHyph = ::GetHyphenator();
1475cdf0e10cSrcweir     if (bInterHyph && xHyph.is())
1476cdf0e10cSrcweir         SvxSpellWrapper::CheckHyphLang( xHyph, eTmp );
1477cdf0e10cSrcweir 
1478cdf0e10cSrcweir     if( !xHyph.is() || !xHyph->hasLocale( pBreakIt->GetLocale(eTmp) ) )
1479cdf0e10cSrcweir         return sal_False;
1480cdf0e10cSrcweir     return sal_True;
1481cdf0e10cSrcweir }
1482cdf0e10cSrcweir 
1483cdf0e10cSrcweir /*************************************************************************
1484cdf0e10cSrcweir  *                  SwTxtFormatInfo::GetDropFmt()
1485cdf0e10cSrcweir  *************************************************************************/
1486cdf0e10cSrcweir 
1487cdf0e10cSrcweir // Dropcaps vom SwTxtFormatter::CTOR gerufen.
GetDropFmt() const1488cdf0e10cSrcweir const SwFmtDrop *SwTxtFormatInfo::GetDropFmt() const
1489cdf0e10cSrcweir {
1490cdf0e10cSrcweir     const SwFmtDrop *pDrop = &GetTxtFrm()->GetTxtNode()->GetSwAttrSet().GetDrop();
1491cdf0e10cSrcweir     if( 1 >= pDrop->GetLines() ||
1492cdf0e10cSrcweir         ( !pDrop->GetChars() && !pDrop->GetWholeWord() ) )
1493cdf0e10cSrcweir         pDrop = 0;
1494cdf0e10cSrcweir     return pDrop;
1495cdf0e10cSrcweir }
1496cdf0e10cSrcweir 
1497cdf0e10cSrcweir /*************************************************************************
1498cdf0e10cSrcweir  *                      SwTxtFormatInfo::Init()
1499cdf0e10cSrcweir  *************************************************************************/
1500cdf0e10cSrcweir 
Init()1501cdf0e10cSrcweir void SwTxtFormatInfo::Init()
1502cdf0e10cSrcweir {
1503cdf0e10cSrcweir     // Nicht initialisieren: pRest, nLeft, nRight, nFirst, nRealWidth
1504cdf0e10cSrcweir     X(0);
1505cdf0e10cSrcweir     bArrowDone = bFull = bFtnDone = bErgoDone = bNumDone = bNoEndHyph =
1506cdf0e10cSrcweir         bNoMidHyph = bStop = bNewLine = bUnderFlow = sal_False;
1507cdf0e10cSrcweir 
1508cdf0e10cSrcweir     // generally we do not allow number portions in follows, except...
1509cdf0e10cSrcweir     if ( GetTxtFrm()->IsFollow() )
1510cdf0e10cSrcweir     {
1511cdf0e10cSrcweir         const SwTxtFrm* pMaster = GetTxtFrm()->FindMaster();
1512cdf0e10cSrcweir         const SwLinePortion* pTmpPara = pMaster->GetPara();
1513cdf0e10cSrcweir 
1514cdf0e10cSrcweir         // there is a master for this follow and the master does not have
1515cdf0e10cSrcweir         // any contents (especially it does not have a number portion)
1516cdf0e10cSrcweir         bNumDone = ! pTmpPara ||
1517cdf0e10cSrcweir                    ! ((SwParaPortion*)pTmpPara)->GetFirstPortion()->IsFlyPortion();
1518cdf0e10cSrcweir     }
1519cdf0e10cSrcweir 
1520cdf0e10cSrcweir     pRoot = 0;
1521cdf0e10cSrcweir     pLast = 0;
1522cdf0e10cSrcweir     pFly = 0;
1523cdf0e10cSrcweir     pLastFld = 0;
1524cdf0e10cSrcweir     pLastTab = 0;
1525cdf0e10cSrcweir     pUnderFlow = 0;
1526cdf0e10cSrcweir     cTabDecimal = 0;
1527cdf0e10cSrcweir     nWidth = nRealWidth;
1528cdf0e10cSrcweir     nForcedLeftMargin = 0;
1529cdf0e10cSrcweir     nSoftHyphPos = 0;
1530cdf0e10cSrcweir     nUnderScorePos = STRING_LEN;
1531cdf0e10cSrcweir     cHookChar = 0;
1532cdf0e10cSrcweir     SetIdx(0);
1533cdf0e10cSrcweir     SetLen( GetTxt().Len() );
1534cdf0e10cSrcweir     SetPaintOfst(0);
1535cdf0e10cSrcweir }
1536cdf0e10cSrcweir 
1537cdf0e10cSrcweir /*-----------------16.10.00 11:39-------------------
1538cdf0e10cSrcweir  * There are a few differences between a copy constructor
1539cdf0e10cSrcweir  * and the following constructor for multi-line formatting.
1540cdf0e10cSrcweir  * The root is the first line inside the multi-portion,
1541cdf0e10cSrcweir  * the line start is the actual position in the text,
1542cdf0e10cSrcweir  * the line width is the rest width from the surrounding line
1543cdf0e10cSrcweir  * and the bMulti and bFirstMulti-flag has to be set correctly.
1544cdf0e10cSrcweir  * --------------------------------------------------*/
1545cdf0e10cSrcweir 
SwTxtFormatInfo(const SwTxtFormatInfo & rInf,SwLineLayout & rLay,SwTwips nActWidth)1546cdf0e10cSrcweir SwTxtFormatInfo::SwTxtFormatInfo( const SwTxtFormatInfo& rInf,
1547cdf0e10cSrcweir     SwLineLayout& rLay, SwTwips nActWidth ) : SwTxtPaintInfo( rInf )
1548cdf0e10cSrcweir {
1549cdf0e10cSrcweir     pRoot = &rLay;
1550cdf0e10cSrcweir     pLast = &rLay;
1551cdf0e10cSrcweir     pFly = NULL;
1552cdf0e10cSrcweir     pLastFld = NULL;
1553cdf0e10cSrcweir     pUnderFlow = NULL;
1554cdf0e10cSrcweir     pRest = NULL;
1555cdf0e10cSrcweir     pLastTab = NULL;
1556cdf0e10cSrcweir 
1557cdf0e10cSrcweir     nSoftHyphPos = 0;
1558cdf0e10cSrcweir     nUnderScorePos = STRING_LEN;
1559cdf0e10cSrcweir     nHyphStart = 0;
1560cdf0e10cSrcweir     nHyphWrdStart = 0;
1561cdf0e10cSrcweir     nHyphWrdLen = 0;
1562cdf0e10cSrcweir     nLineStart = rInf.GetIdx();
1563cdf0e10cSrcweir     nLeft = rInf.nLeft;
1564cdf0e10cSrcweir     nRight = rInf.nRight;
1565cdf0e10cSrcweir     nFirst = rInf.nLeft;
1566cdf0e10cSrcweir     nRealWidth = KSHORT(nActWidth);
1567cdf0e10cSrcweir     nWidth = nRealWidth;
1568cdf0e10cSrcweir     nLineHeight = 0;
1569cdf0e10cSrcweir     nLineNettoHeight = 0;
1570cdf0e10cSrcweir     nForcedLeftMargin = 0;
1571cdf0e10cSrcweir 
1572cdf0e10cSrcweir     nMinLeading = 0;
1573cdf0e10cSrcweir     nMinTrailing = 0;
1574cdf0e10cSrcweir     nMinWordLength = 0;
1575cdf0e10cSrcweir     bFull = sal_False;
1576cdf0e10cSrcweir     bFtnDone = sal_True;
1577cdf0e10cSrcweir     bErgoDone = sal_True;
1578cdf0e10cSrcweir     bNumDone = sal_True;
1579cdf0e10cSrcweir     bArrowDone = sal_True;
1580cdf0e10cSrcweir     bStop = sal_False;
1581cdf0e10cSrcweir     bNewLine = sal_True;
1582cdf0e10cSrcweir     bShift  = sal_False;
1583cdf0e10cSrcweir     bUnderFlow = sal_False;
1584cdf0e10cSrcweir     bInterHyph = sal_False;
1585cdf0e10cSrcweir     bAutoHyph = sal_False;
1586cdf0e10cSrcweir     bDropInit = sal_False;
1587cdf0e10cSrcweir     bQuick  = rInf.bQuick;
1588cdf0e10cSrcweir     bNoEndHyph  = sal_False;
1589cdf0e10cSrcweir     bNoMidHyph  = sal_False;
1590cdf0e10cSrcweir     bIgnoreFly = sal_False;
1591cdf0e10cSrcweir     bFakeLineStart = sal_False;
1592cdf0e10cSrcweir 
1593cdf0e10cSrcweir     cTabDecimal = 0;
1594cdf0e10cSrcweir     cHookChar = 0;
1595cdf0e10cSrcweir     nMaxHyph = 0;
1596cdf0e10cSrcweir     bTestFormat = rInf.bTestFormat;
1597cdf0e10cSrcweir     SetMulti( sal_True );
1598cdf0e10cSrcweir     SetFirstMulti( rInf.IsFirstMulti() );
1599cdf0e10cSrcweir }
1600cdf0e10cSrcweir 
1601cdf0e10cSrcweir /*************************************************************************
1602cdf0e10cSrcweir  *                 SwTxtFormatInfo::_CheckFtnPortion()
1603cdf0e10cSrcweir  *************************************************************************/
1604cdf0e10cSrcweir 
_CheckFtnPortion(SwLineLayout * pCurr)1605cdf0e10cSrcweir sal_Bool SwTxtFormatInfo::_CheckFtnPortion( SwLineLayout* pCurr )
1606cdf0e10cSrcweir {
1607cdf0e10cSrcweir     KSHORT nHeight = pCurr->GetRealHeight();
1608cdf0e10cSrcweir     SwLinePortion *pPor = pCurr->GetPortion();
1609cdf0e10cSrcweir     sal_Bool bRet = sal_False;
1610cdf0e10cSrcweir     while( pPor )
1611cdf0e10cSrcweir     {
1612cdf0e10cSrcweir         if( pPor->IsFtnPortion() && nHeight > ((SwFtnPortion*)pPor)->Orig() )
1613cdf0e10cSrcweir         {
1614cdf0e10cSrcweir             bRet = sal_True;
1615cdf0e10cSrcweir             SetLineHeight( nHeight );
1616cdf0e10cSrcweir             SetLineNettoHeight( pCurr->Height() );
1617cdf0e10cSrcweir             break;
1618cdf0e10cSrcweir         }
1619cdf0e10cSrcweir         pPor = pPor->GetPortion();
1620cdf0e10cSrcweir     }
1621cdf0e10cSrcweir     return bRet;
1622cdf0e10cSrcweir }
1623cdf0e10cSrcweir 
1624cdf0e10cSrcweir 
1625cdf0e10cSrcweir 
1626cdf0e10cSrcweir 
1627cdf0e10cSrcweir /*************************************************************************
1628cdf0e10cSrcweir  *                 SwTxtFormatInfo::ScanPortionEnd()
1629cdf0e10cSrcweir  *************************************************************************/
ScanPortionEnd(const xub_StrLen nStart,const xub_StrLen nEnd)1630cdf0e10cSrcweir xub_StrLen SwTxtFormatInfo::ScanPortionEnd( const xub_StrLen nStart,
1631cdf0e10cSrcweir                                             const xub_StrLen nEnd )
1632cdf0e10cSrcweir {
1633cdf0e10cSrcweir     cHookChar = 0;
1634cdf0e10cSrcweir     xub_StrLen i = nStart;
1635cdf0e10cSrcweir 
1636cdf0e10cSrcweir     //
1637cdf0e10cSrcweir     // Used for decimal tab handling:
1638cdf0e10cSrcweir     //
1639cdf0e10cSrcweir     const xub_Unicode cTabDec = GetLastTab() ? (sal_Unicode)GetTabDecimal() : 0;
1640cdf0e10cSrcweir     const xub_Unicode cThousandSep  = ',' == cTabDec ? '.' : ',';
1641cdf0e10cSrcweir     // --> FME 2006-01-23 #i45951# German (Switzerland) uses ' as thousand separator:
1642cdf0e10cSrcweir     const xub_Unicode cThousandSep2 = ',' == cTabDec ? '.' : '\'';
1643cdf0e10cSrcweir     // <--
1644cdf0e10cSrcweir 
1645cdf0e10cSrcweir     bool bNumFound = false;
1646cdf0e10cSrcweir     const bool bTabCompat = GetTxtFrm()->GetTxtNode()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::TAB_COMPAT);
1647cdf0e10cSrcweir 
1648cdf0e10cSrcweir     // Removed for i7288. bSkip used to be passed from SwFldPortion::Format
1649cdf0e10cSrcweir     // as IsFollow(). Therefore more than one special character was not
1650cdf0e10cSrcweir     // handled correctly at the beginning of follow fields.
1651cdf0e10cSrcweir //    if ( bSkip && i < nEnd )
1652cdf0e10cSrcweir //       ++i;
1653cdf0e10cSrcweir 
1654cdf0e10cSrcweir     for( ; i < nEnd; ++i )
1655cdf0e10cSrcweir     {
1656cdf0e10cSrcweir         const xub_Unicode cPos = GetChar( i );
1657cdf0e10cSrcweir         switch( cPos )
1658cdf0e10cSrcweir         {
1659cdf0e10cSrcweir         case CH_TXTATR_BREAKWORD:
1660cdf0e10cSrcweir         case CH_TXTATR_INWORD:
1661cdf0e10cSrcweir             if( !HasHint( i ))
1662cdf0e10cSrcweir                 break;
1663cdf0e10cSrcweir             // no break;
1664cdf0e10cSrcweir 
1665cdf0e10cSrcweir         case CHAR_SOFTHYPHEN:
1666cdf0e10cSrcweir         case CHAR_HARDHYPHEN:
1667cdf0e10cSrcweir         case CHAR_HARDBLANK:
1668cdf0e10cSrcweir         case CH_TAB:
1669cdf0e10cSrcweir         case CH_BREAK:
1670cdf0e10cSrcweir         case CHAR_ZWSP :
1671cdf0e10cSrcweir         case CHAR_ZWNBSP :
1672cdf0e10cSrcweir //        case CHAR_RLM :
1673cdf0e10cSrcweir //        case CHAR_LRM :
1674cdf0e10cSrcweir             cHookChar = cPos;
1675cdf0e10cSrcweir             return i;
1676cdf0e10cSrcweir 
1677cdf0e10cSrcweir         case CHAR_UNDERSCORE:
1678cdf0e10cSrcweir             if ( STRING_LEN == nUnderScorePos )
1679cdf0e10cSrcweir                 nUnderScorePos = i;
1680cdf0e10cSrcweir             break;
1681cdf0e10cSrcweir 
1682cdf0e10cSrcweir         default:
1683cdf0e10cSrcweir             if ( cTabDec )
1684cdf0e10cSrcweir             {
1685cdf0e10cSrcweir                 if( cTabDec == cPos )
1686cdf0e10cSrcweir                 {
1687cdf0e10cSrcweir                     ASSERT( cPos, "Unexpected end of string" );
1688cdf0e10cSrcweir                     if( cPos ) // robust
1689cdf0e10cSrcweir                     {
1690cdf0e10cSrcweir                         cHookChar = cPos;
1691cdf0e10cSrcweir                         return i;
1692cdf0e10cSrcweir                     }
1693cdf0e10cSrcweir                 }
1694cdf0e10cSrcweir 
1695cdf0e10cSrcweir                 //
1696cdf0e10cSrcweir                 // Compatibility: First non-digit character behind a
1697cdf0e10cSrcweir                 // a digit character becomes the hook character
1698cdf0e10cSrcweir                 //
1699cdf0e10cSrcweir                 if ( bTabCompat )
1700cdf0e10cSrcweir                 {
1701cdf0e10cSrcweir                     if ( ( 0x2F < cPos && cPos < 0x3A ) ||
1702cdf0e10cSrcweir                          ( bNumFound && ( cPos == cThousandSep || cPos == cThousandSep2 ) ) )
1703cdf0e10cSrcweir                     {
1704cdf0e10cSrcweir                         bNumFound = true;
1705cdf0e10cSrcweir                     }
1706cdf0e10cSrcweir                     else
1707cdf0e10cSrcweir                     {
1708cdf0e10cSrcweir                         if ( bNumFound )
1709cdf0e10cSrcweir                         {
1710cdf0e10cSrcweir                             cHookChar = cPos;
1711cdf0e10cSrcweir                             SetTabDecimal( cPos );
1712cdf0e10cSrcweir                             return i;
1713cdf0e10cSrcweir                         }
1714cdf0e10cSrcweir                     }
1715cdf0e10cSrcweir                 }
1716cdf0e10cSrcweir             }
1717cdf0e10cSrcweir         }
1718cdf0e10cSrcweir     }
1719cdf0e10cSrcweir 
1720cdf0e10cSrcweir     // --> FME 2006-01-13 #130210# Check if character *behind* the portion has
1721cdf0e10cSrcweir     // to become the hook:
1722cdf0e10cSrcweir     if ( i == nEnd && i < GetTxt().Len() && bNumFound )
1723cdf0e10cSrcweir     {
1724cdf0e10cSrcweir         const xub_Unicode cPos = GetChar( i );
1725cdf0e10cSrcweir         if ( cPos != cTabDec && cPos != cThousandSep && cPos !=cThousandSep2 && ( 0x2F >= cPos || cPos >= 0x3A ) )
1726cdf0e10cSrcweir         {
1727cdf0e10cSrcweir             cHookChar = GetChar( i );
1728cdf0e10cSrcweir             SetTabDecimal( cHookChar );
1729cdf0e10cSrcweir         }
1730cdf0e10cSrcweir     }
1731cdf0e10cSrcweir 
1732cdf0e10cSrcweir     return i;
1733cdf0e10cSrcweir }
1734cdf0e10cSrcweir 
LastKernPortion()1735cdf0e10cSrcweir sal_Bool SwTxtFormatInfo::LastKernPortion()
1736cdf0e10cSrcweir {
1737cdf0e10cSrcweir     if( GetLast() )
1738cdf0e10cSrcweir     {
1739cdf0e10cSrcweir         if( GetLast()->IsKernPortion() )
1740cdf0e10cSrcweir             return sal_True;
1741cdf0e10cSrcweir         if( GetLast()->Width() || ( GetLast()->GetLen() &&
1742cdf0e10cSrcweir             !GetLast()->IsHolePortion() ) )
1743cdf0e10cSrcweir             return sal_False;
1744cdf0e10cSrcweir     }
1745cdf0e10cSrcweir     SwLinePortion* pPor = GetRoot();
1746cdf0e10cSrcweir     SwLinePortion *pKern = NULL;
1747cdf0e10cSrcweir     while( pPor )
1748cdf0e10cSrcweir     {
1749cdf0e10cSrcweir         if( pPor->IsKernPortion() )
1750cdf0e10cSrcweir             pKern = pPor;
1751cdf0e10cSrcweir         else if( pPor->Width() || ( pPor->GetLen() && !pPor->IsHolePortion() ) )
1752cdf0e10cSrcweir             pKern = NULL;
1753cdf0e10cSrcweir         pPor = pPor->GetPortion();
1754cdf0e10cSrcweir     }
1755cdf0e10cSrcweir     if( pKern )
1756cdf0e10cSrcweir     {
1757cdf0e10cSrcweir         SetLast( pKern );
1758cdf0e10cSrcweir         return sal_True;
1759cdf0e10cSrcweir     }
1760cdf0e10cSrcweir     return sal_False;
1761cdf0e10cSrcweir }
1762cdf0e10cSrcweir 
1763cdf0e10cSrcweir /*************************************************************************
1764cdf0e10cSrcweir  *                      class SwTxtSlot
1765cdf0e10cSrcweir  *************************************************************************/
1766cdf0e10cSrcweir 
SwTxtSlot(const SwTxtSizeInfo * pNew,const SwLinePortion * pPor,bool bTxtLen,bool bExgLists,const sal_Char * pCh)176769a74367SOliver-Rainer Wittmann SwTxtSlot::SwTxtSlot(
176869a74367SOliver-Rainer Wittmann     const SwTxtSizeInfo *pNew,
176969a74367SOliver-Rainer Wittmann     const SwLinePortion *pPor,
177069a74367SOliver-Rainer Wittmann     bool bTxtLen,
177169a74367SOliver-Rainer Wittmann     bool bExgLists,
177269a74367SOliver-Rainer Wittmann     const sal_Char *pCh )
1773cdf0e10cSrcweir     : pOldTxt( 0 ),
1774cdf0e10cSrcweir       pOldSmartTagList( 0 ),
1775cdf0e10cSrcweir       pOldGrammarCheckList( 0 ),
1776cdf0e10cSrcweir       pTempList( 0 )
1777cdf0e10cSrcweir {
1778cdf0e10cSrcweir     if( pCh )
1779cdf0e10cSrcweir     {
1780cdf0e10cSrcweir         aTxt = XubString( pCh, RTL_TEXTENCODING_MS_1252 );
1781cdf0e10cSrcweir         bOn = sal_True;
1782cdf0e10cSrcweir     }
1783cdf0e10cSrcweir     else
1784cdf0e10cSrcweir         bOn = pPor->GetExpTxt( *pNew, aTxt );
1785cdf0e10cSrcweir 
1786cdf0e10cSrcweir     // Der Text wird ausgetauscht...
1787cdf0e10cSrcweir     if( bOn )
1788cdf0e10cSrcweir     {
1789cdf0e10cSrcweir         pInf = (SwTxtSizeInfo*)pNew;
1790cdf0e10cSrcweir         nIdx = pInf->GetIdx();
1791cdf0e10cSrcweir         nLen = pInf->GetLen();
1792cdf0e10cSrcweir         pOldTxt = &(pInf->GetTxt());
1793cdf0e10cSrcweir         pInf->SetTxt( aTxt );
1794cdf0e10cSrcweir         pInf->SetIdx( 0 );
1795cdf0e10cSrcweir         pInf->SetLen( bTxtLen ? pInf->GetTxt().Len() : pPor->GetLen() );
1796cdf0e10cSrcweir 
1797cdf0e10cSrcweir         // ST2
1798cdf0e10cSrcweir         if ( bExgLists )
1799cdf0e10cSrcweir         {
1800cdf0e10cSrcweir             pOldSmartTagList = static_cast<SwTxtPaintInfo*>(pInf)->GetSmartTags();
1801cdf0e10cSrcweir             if ( pOldSmartTagList )
1802cdf0e10cSrcweir             {
1803cdf0e10cSrcweir                 const sal_uInt16 nPos = pOldSmartTagList->GetWrongPos(nIdx);
1804cdf0e10cSrcweir                 const xub_StrLen nListPos = pOldSmartTagList->Pos(nPos);
1805cdf0e10cSrcweir                 if( nListPos == nIdx )
1806cdf0e10cSrcweir                     ((SwTxtPaintInfo*)pInf)->SetSmartTags( pOldSmartTagList->SubList( nPos ) );
1807cdf0e10cSrcweir                 else if( !pTempList && nPos < pOldSmartTagList->Count() && nListPos < nIdx && aTxt.Len() )
1808cdf0e10cSrcweir                 {
1809cdf0e10cSrcweir                     pTempList = new SwWrongList( WRONGLIST_SMARTTAG );
1810cdf0e10cSrcweir                     pTempList->Insert( rtl::OUString(), 0, 0, aTxt.Len(), 0 );
1811cdf0e10cSrcweir                     ((SwTxtPaintInfo*)pInf)->SetSmartTags( pTempList );
1812cdf0e10cSrcweir                 }
1813cdf0e10cSrcweir                 else
1814cdf0e10cSrcweir                     ((SwTxtPaintInfo*)pInf)->SetSmartTags( 0);
1815cdf0e10cSrcweir             }
1816cdf0e10cSrcweir             pOldGrammarCheckList = static_cast<SwTxtPaintInfo*>(pInf)->GetGrammarCheckList();
1817cdf0e10cSrcweir             if ( pOldGrammarCheckList )
1818cdf0e10cSrcweir             {
1819cdf0e10cSrcweir                 const sal_uInt16 nPos = pOldGrammarCheckList->GetWrongPos(nIdx);
1820cdf0e10cSrcweir                 const xub_StrLen nListPos = pOldGrammarCheckList->Pos(nPos);
1821cdf0e10cSrcweir                 if( nListPos == nIdx )
1822cdf0e10cSrcweir                     ((SwTxtPaintInfo*)pInf)->SetGrammarCheckList( pOldGrammarCheckList->SubList( nPos ) );
1823cdf0e10cSrcweir                 else if( !pTempList && nPos < pOldGrammarCheckList->Count() && nListPos < nIdx && aTxt.Len() )
1824cdf0e10cSrcweir                 {
1825cdf0e10cSrcweir                     pTempList = new SwWrongList( WRONGLIST_GRAMMAR );
1826cdf0e10cSrcweir                     pTempList->Insert( rtl::OUString(), 0, 0, aTxt.Len(), 0 );
1827cdf0e10cSrcweir                     ((SwTxtPaintInfo*)pInf)->SetGrammarCheckList( pTempList );
1828cdf0e10cSrcweir                 }
1829cdf0e10cSrcweir                 else
1830cdf0e10cSrcweir                     ((SwTxtPaintInfo*)pInf)->SetGrammarCheckList( 0);
1831cdf0e10cSrcweir             }
1832cdf0e10cSrcweir         }
1833cdf0e10cSrcweir     }
1834cdf0e10cSrcweir }
1835cdf0e10cSrcweir 
1836cdf0e10cSrcweir /*************************************************************************
1837cdf0e10cSrcweir  *                       SwTxtSlot::~SwTxtSlot()
1838cdf0e10cSrcweir  *************************************************************************/
1839cdf0e10cSrcweir 
~SwTxtSlot()1840cdf0e10cSrcweir SwTxtSlot::~SwTxtSlot()
1841cdf0e10cSrcweir {
1842cdf0e10cSrcweir     if( bOn )
1843cdf0e10cSrcweir     {
1844cdf0e10cSrcweir         pInf->SetTxt( *pOldTxt );
1845cdf0e10cSrcweir         pInf->SetIdx( nIdx );
1846cdf0e10cSrcweir         pInf->SetLen( nLen );
1847cdf0e10cSrcweir 
1848cdf0e10cSrcweir         // ST2
1849cdf0e10cSrcweir         // Restore old smart tag list
1850cdf0e10cSrcweir         if ( pOldSmartTagList )
1851cdf0e10cSrcweir             ((SwTxtPaintInfo*)pInf)->SetSmartTags( pOldSmartTagList );
1852cdf0e10cSrcweir         if ( pOldGrammarCheckList )
1853cdf0e10cSrcweir             ((SwTxtPaintInfo*)pInf)->SetGrammarCheckList( pOldGrammarCheckList );
1854cdf0e10cSrcweir         delete pTempList;
1855cdf0e10cSrcweir     }
1856cdf0e10cSrcweir }
1857cdf0e10cSrcweir 
1858cdf0e10cSrcweir /*************************************************************************
1859cdf0e10cSrcweir  *                     SwFontSave::SwFontSave()
1860cdf0e10cSrcweir  *************************************************************************/
1861cdf0e10cSrcweir 
SwFontSave(const SwTxtSizeInfo & rInf,SwFont * pNew,SwAttrIter * pItr)1862cdf0e10cSrcweir SwFontSave::SwFontSave( const SwTxtSizeInfo &rInf, SwFont *pNew,
1863cdf0e10cSrcweir         SwAttrIter* pItr )
1864cdf0e10cSrcweir         : pFnt( pNew ? ((SwTxtSizeInfo&)rInf).GetFont() : 0 )
1865cdf0e10cSrcweir {
1866cdf0e10cSrcweir     if( pFnt )
1867cdf0e10cSrcweir     {
1868cdf0e10cSrcweir         pInf = &((SwTxtSizeInfo&)rInf);
1869cdf0e10cSrcweir         // In these cases we temporarily switch to the new font:
1870cdf0e10cSrcweir         // 1. the fonts have a different magic number
1871cdf0e10cSrcweir         // 2. they have different script types
1872cdf0e10cSrcweir         // 3. their background colors differ (this is not covered by 1.)
1873cdf0e10cSrcweir         if( pFnt->DifferentMagic( pNew, pFnt->GetActual() ) ||
1874cdf0e10cSrcweir             pNew->GetActual() != pFnt->GetActual() ||
1875cdf0e10cSrcweir             ( ! pNew->GetBackColor() && pFnt->GetBackColor() ) ||
1876cdf0e10cSrcweir             ( pNew->GetBackColor() && ! pFnt->GetBackColor() ) ||
1877cdf0e10cSrcweir             ( pNew->GetBackColor() && pFnt->GetBackColor() &&
1878cdf0e10cSrcweir               ( *pNew->GetBackColor() != *pFnt->GetBackColor() ) ) )
1879cdf0e10cSrcweir         {
1880cdf0e10cSrcweir             pNew->SetTransparent( sal_True );
1881cdf0e10cSrcweir             pNew->SetAlign( ALIGN_BASELINE );
1882cdf0e10cSrcweir             pInf->SetFont( pNew );
1883cdf0e10cSrcweir         }
1884cdf0e10cSrcweir         else
1885cdf0e10cSrcweir             pFnt = 0;
1886cdf0e10cSrcweir         pNew->Invalidate();
1887cdf0e10cSrcweir         pNew->ChgPhysFnt( pInf->GetVsh(), *pInf->GetOut() );
1888cdf0e10cSrcweir         if( pItr && pItr->GetFnt() == pFnt )
1889cdf0e10cSrcweir         {
1890cdf0e10cSrcweir             pIter = pItr;
1891cdf0e10cSrcweir             pIter->SetFnt( pNew );
1892cdf0e10cSrcweir         }
1893cdf0e10cSrcweir         else
1894cdf0e10cSrcweir             pIter = NULL;
1895cdf0e10cSrcweir     }
1896cdf0e10cSrcweir }
1897cdf0e10cSrcweir 
1898cdf0e10cSrcweir /*************************************************************************
1899cdf0e10cSrcweir  *                     SwFontSave::~SwFontSave()
1900cdf0e10cSrcweir  *************************************************************************/
1901cdf0e10cSrcweir 
~SwFontSave()1902cdf0e10cSrcweir SwFontSave::~SwFontSave()
1903cdf0e10cSrcweir {
1904cdf0e10cSrcweir     if( pFnt )
1905cdf0e10cSrcweir     {
1906cdf0e10cSrcweir         // SwFont zurueckstellen
1907cdf0e10cSrcweir         pFnt->Invalidate();
1908cdf0e10cSrcweir         pInf->SetFont( pFnt );
1909cdf0e10cSrcweir         if( pIter )
1910cdf0e10cSrcweir         {
1911cdf0e10cSrcweir             pIter->SetFnt( pFnt );
1912cdf0e10cSrcweir             pIter->nPos = STRING_LEN;
1913cdf0e10cSrcweir         }
1914cdf0e10cSrcweir     }
1915cdf0e10cSrcweir }
1916cdf0e10cSrcweir 
1917cdf0e10cSrcweir /*************************************************************************
1918cdf0e10cSrcweir  *                     SwDefFontSave::SwDefFontSave()
1919cdf0e10cSrcweir  *************************************************************************/
1920cdf0e10cSrcweir 
SwDefFontSave(const SwTxtSizeInfo & rInf)1921cdf0e10cSrcweir SwDefFontSave::SwDefFontSave( const SwTxtSizeInfo &rInf )
1922cdf0e10cSrcweir         : pFnt( ((SwTxtSizeInfo&)rInf).GetFont()  )
1923cdf0e10cSrcweir {
1924cdf0e10cSrcweir     const sal_Bool bTmpAlter = pFnt->GetFixKerning() ||
1925cdf0e10cSrcweir          ( RTL_TEXTENCODING_SYMBOL == pFnt->GetCharSet(pFnt->GetActual()) )
1926cdf0e10cSrcweir         ;
1927cdf0e10cSrcweir 
1928cdf0e10cSrcweir     const sal_Bool bFamily = bTmpAlter &&
1929cdf0e10cSrcweir           pFnt->GetName( pFnt->GetActual() ) != numfunc::GetDefBulletFontname();
1930cdf0e10cSrcweir     const sal_Bool bRotation = (sal_Bool)pFnt->GetOrientation() &&
1931cdf0e10cSrcweir                                 ! rInf.GetTxtFrm()->IsVertical();
1932cdf0e10cSrcweir 
1933cdf0e10cSrcweir     if( bFamily || bRotation )
1934cdf0e10cSrcweir     {
1935cdf0e10cSrcweir         pNewFnt = new SwFont( *pFnt );
1936cdf0e10cSrcweir 
1937cdf0e10cSrcweir         if ( bFamily )
1938cdf0e10cSrcweir         {
1939cdf0e10cSrcweir             pNewFnt->SetFamily( FAMILY_DONTKNOW, pFnt->GetActual() );
1940cdf0e10cSrcweir             pNewFnt->SetName( numfunc::GetDefBulletFontname(), pFnt->GetActual() );
1941cdf0e10cSrcweir             pNewFnt->SetStyleName( aEmptyStr, pFnt->GetActual() );
1942cdf0e10cSrcweir             pNewFnt->SetCharSet( RTL_TEXTENCODING_SYMBOL, pFnt->GetActual() );
1943cdf0e10cSrcweir             pNewFnt->SetFixKerning( 0 );
1944cdf0e10cSrcweir         }
1945cdf0e10cSrcweir 
1946cdf0e10cSrcweir         if ( bRotation )
1947cdf0e10cSrcweir             pNewFnt->SetVertical( 0, rInf.GetTxtFrm()->IsVertical() );
1948cdf0e10cSrcweir 
1949cdf0e10cSrcweir         pInf = &((SwTxtSizeInfo&)rInf);
1950cdf0e10cSrcweir         pNewFnt->Invalidate();
1951cdf0e10cSrcweir         pInf->SetFont( pNewFnt );
1952cdf0e10cSrcweir     }
1953cdf0e10cSrcweir     else
1954cdf0e10cSrcweir     {
1955cdf0e10cSrcweir         pFnt = 0;
1956cdf0e10cSrcweir         pNewFnt = 0;
1957cdf0e10cSrcweir     }
1958cdf0e10cSrcweir }
1959cdf0e10cSrcweir 
1960cdf0e10cSrcweir /*************************************************************************
1961cdf0e10cSrcweir  *                     SwDefFontSave::~SwDefFontSave()
1962cdf0e10cSrcweir  *************************************************************************/
1963cdf0e10cSrcweir 
~SwDefFontSave()1964cdf0e10cSrcweir SwDefFontSave::~SwDefFontSave()
1965cdf0e10cSrcweir {
1966cdf0e10cSrcweir     if( pFnt )
1967cdf0e10cSrcweir     {
1968cdf0e10cSrcweir         delete pNewFnt;
1969cdf0e10cSrcweir         // SwFont zurueckstellen
1970cdf0e10cSrcweir         pFnt->Invalidate();
1971cdf0e10cSrcweir         pInf->SetFont( pFnt );
1972cdf0e10cSrcweir     }
1973cdf0e10cSrcweir }
1974cdf0e10cSrcweir 
1975cdf0e10cSrcweir /*************************************************************************
1976cdf0e10cSrcweir  *                  SwTxtFormatInfo::ChgHyph()
1977cdf0e10cSrcweir  *************************************************************************/
1978cdf0e10cSrcweir 
ChgHyph(const sal_Bool bNew)1979cdf0e10cSrcweir sal_Bool SwTxtFormatInfo::ChgHyph( const sal_Bool bNew )
1980cdf0e10cSrcweir {
1981cdf0e10cSrcweir     const sal_Bool bOld = bAutoHyph;
1982cdf0e10cSrcweir     if( bAutoHyph != bNew )
1983cdf0e10cSrcweir     {
1984cdf0e10cSrcweir         bAutoHyph = bNew;
1985cdf0e10cSrcweir         InitHyph( bNew );
1986cdf0e10cSrcweir         // 5744: Sprache am Hyphenator einstellen.
1987cdf0e10cSrcweir         if( pFnt )
1988cdf0e10cSrcweir             pFnt->ChgPhysFnt( pVsh, *pOut );
1989cdf0e10cSrcweir     }
1990cdf0e10cSrcweir     return bOld;
1991cdf0e10cSrcweir }
1992