merge the formfield patch from ooo-build
[ooovba.git] / sw / source / core / inc / drawfont.hxx
blob9fc27ae2d0810a6b3414f7c877d8079d4acb2e2e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: drawfont.hxx,v $
10 * $Revision: 1.40 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _DRAWFONT_HXX
31 #define _DRAWFONT_HXX
33 #include <tools/solar.h>
34 #include <tools/string.hxx>
35 #include <errhdl.hxx>
37 class SwTxtFrm;
38 class OutputDevice;
39 class ViewShell;
40 class SwScriptInfo;
41 class Point;
42 class SwWrongList;
43 class Size;
44 class SwFont;
45 class Font;
46 class SwUnderlineFont;
48 /*************************************************************************
49 * class SwDrawTextInfo
51 * encapsulates information for drawing text
52 *************************************************************************/
54 class SwDrawTextInfo
56 const SwTxtFrm* pFrm;
57 OutputDevice* pOut;
58 ViewShell* pSh;
59 const SwScriptInfo* pScriptInfo;
60 const Point* pPos;
61 const XubString* pText;
62 const SwWrongList* pWrong;
63 const SwWrongList* pGrammarCheck;
64 const SwWrongList* pSmartTags; // SMARTTAGS
65 const Size* pSize;
66 SwFont *pFnt;
67 SwUnderlineFont* pUnderFnt;
68 xub_StrLen* pHyphPos;
69 long nLeft;
70 long nRight;
71 long nKanaDiff;
72 xub_StrLen nIdx;
73 xub_StrLen nLen;
74 xub_StrLen nOfst;
75 USHORT nWidth;
76 USHORT nAscent;
77 USHORT nCompress;
78 long nSperren;
79 long nSpace;
80 long nKern;
81 xub_StrLen nNumberOfBlanks;
82 BYTE nCursorBidiLevel;
83 BOOL bBullet : 1;
84 BOOL bUpper : 1; // Fuer Kapitaelchen: Grossbuchstaben-Flag
85 BOOL bDrawSpace : 1; // Fuer Kapitaelchen: Unter/Durchstreichung
86 BOOL bGreyWave : 1; // Graue Wellenlinie beim extended TextInput
87 BOOL bSpaceStop : 1; // For underlining we need to know, if a portion
88 // is right in front of a hole portion or a
89 // fix margin portion.
90 BOOL bSnapToGrid : 1; // Does paragraph snap to grid?
91 BOOL bIgnoreFrmRTL : 1; // Paint text as if text has LTR direction, used for
92 // line numbering
93 BOOL bPosMatchesBounds :1; // GetCrsrOfst should not return the next
94 // position if screen position is inside second
95 // half of bound rect, used for Accessibility
97 SwDrawTextInfo(); // nicht zulaessig
98 public:
100 #ifndef PRODUCT
101 BOOL bPos : 1; // These flags should control, that the appropriate
102 BOOL bWrong : 1; // Set-function has been called before calling
103 BOOL bGrammarCheck : 1; // the Get-function of a member
104 BOOL bSize : 1;
105 BOOL bFnt : 1;
106 BOOL bHyph : 1;
107 BOOL bLeft : 1;
108 BOOL bRight : 1;
109 BOOL bKana : 1;
110 BOOL bOfst : 1;
111 BOOL bAscent: 1;
112 BOOL bSperr : 1;
113 BOOL bSpace : 1;
114 BOOL bNumberOfBlanks : 1;
115 BOOL bUppr : 1;
116 BOOL bDrawSp: 1;
117 #endif
119 SwDrawTextInfo( ViewShell *pS, OutputDevice &rO, const SwScriptInfo* pSI,
120 const XubString &rSt, xub_StrLen nI, xub_StrLen nL,
121 USHORT nW = 0, BOOL bB = FALSE )
123 pFrm = NULL;
124 pSh = pS;
125 pOut = &rO;
126 pScriptInfo = pSI;
127 pText = &rSt;
128 nIdx = nI;
129 nLen = nL;
130 nKern = 0;
131 nCompress = 0;
132 nWidth = nW;
133 nNumberOfBlanks = 0;
134 nCursorBidiLevel = 0;
135 bBullet = bB;
136 pUnderFnt = 0;
137 bGreyWave = FALSE;
138 bSpaceStop = FALSE;
139 bSnapToGrid = FALSE;
140 bIgnoreFrmRTL = FALSE;
141 bPosMatchesBounds = FALSE;
143 // These values are initialized but, they have to be
144 // set explicitly via their Set-function before they may
145 // be accessed by their Get-function:
146 pPos = 0;
147 pWrong = 0;
148 pGrammarCheck = 0;
149 pSmartTags = 0;
150 pSize = 0;
151 pFnt = 0;
152 pHyphPos = 0;
153 nLeft = 0;
154 nRight = 0;
155 nKanaDiff = 0;
156 nOfst = 0;
157 nAscent = 0;
158 nSperren = 0;
159 nSpace = 0;
160 bUpper = FALSE;
161 bDrawSpace = FALSE;
163 #ifndef PRODUCT
164 // these flags control, whether the matching member variables have
165 // been set by using the Set-function before they may be accessed
166 // by their Get-function:
167 bPos = bWrong = bGrammarCheck = bSize = bFnt = bAscent = bSpace = bNumberOfBlanks = bUppr =
168 bDrawSp = bLeft = bRight = bKana = bOfst = bHyph = bSperr = FALSE;
169 #endif
172 const SwTxtFrm* GetFrm() const
174 return pFrm;
177 void SetFrm( const SwTxtFrm* pNewFrm )
179 pFrm = pNewFrm;
182 ViewShell *GetShell() const
184 return pSh;
187 OutputDevice& GetOut() const
189 return *pOut;
192 OutputDevice *GetpOut() const
194 return pOut;
197 const SwScriptInfo* GetScriptInfo() const
199 return pScriptInfo;
202 const Point &GetPos() const
204 ASSERT( bPos, "DrawTextInfo: Undefined Position" );
205 return *pPos;
208 xub_StrLen *GetHyphPos() const
210 ASSERT( bHyph, "DrawTextInfo: Undefined Hyph Position" );
211 return pHyphPos;
214 const XubString &GetText() const
216 return *pText;
219 const SwWrongList* GetWrong() const
221 ASSERT( bWrong, "DrawTextInfo: Undefined WrongList" );
222 return pWrong;
225 const SwWrongList* GetGrammarCheck() const
227 ASSERT( bGrammarCheck, "DrawTextInfo: Undefined GrammarCheck List" );
228 return pGrammarCheck;
231 const SwWrongList* GetSmartTags() const
233 return pSmartTags;
236 const Size &GetSize() const
238 ASSERT( bSize, "DrawTextInfo: Undefined Size" );
239 return *pSize;
242 SwFont* GetFont() const
244 ASSERT( bFnt, "DrawTextInfo: Undefined Font" );
245 return pFnt;
248 SwUnderlineFont* GetUnderFnt() const
250 return pUnderFnt;
253 xub_StrLen GetIdx() const
255 return nIdx;
258 xub_StrLen GetLen() const
260 return nLen;
263 xub_StrLen GetOfst() const
265 ASSERT( bOfst, "DrawTextInfo: Undefined Offset" );
266 return nOfst;
269 xub_StrLen GetEnd() const
271 return nIdx + nLen;
274 long GetLeft() const
276 ASSERT( bLeft, "DrawTextInfo: Undefined left range" );
277 return nLeft;
280 long GetRight() const
282 ASSERT( bRight, "DrawTextInfo: Undefined right range" );
283 return nRight;
286 long GetKanaDiff() const
288 ASSERT( bKana, "DrawTextInfo: Undefined kana difference" );
289 return nKanaDiff;
292 USHORT GetWidth() const
294 return nWidth;
297 USHORT GetAscent() const
299 ASSERT( bAscent, "DrawTextInfo: Undefined Ascent" );
300 return nAscent;
303 USHORT GetKanaComp() const
305 return nCompress;
308 long GetSperren() const
310 ASSERT( bSperr, "DrawTextInfo: Undefined >Sperren<" );
311 return nSperren;
314 long GetKern() const
316 return nKern;
319 long GetSpace() const
321 ASSERT( bSpace, "DrawTextInfo: Undefined Spacing" );
322 return nSpace;
325 xub_StrLen GetNumberOfBlanks() const
327 ASSERT( bNumberOfBlanks, "DrawTextInfo::Undefined NumberOfBlanks" );
328 return nNumberOfBlanks;
331 BYTE GetCursorBidiLevel() const
333 return nCursorBidiLevel;
336 BOOL GetBullet() const
338 return bBullet;
341 BOOL GetUpper() const
343 ASSERT( bUppr, "DrawTextInfo: Undefined Upperflag" );
344 return bUpper;
347 BOOL GetDrawSpace() const
349 ASSERT( bDrawSp, "DrawTextInfo: Undefined DrawSpaceflag" );
350 return bDrawSpace;
353 BOOL GetGreyWave() const
355 return bGreyWave;
358 BOOL IsSpaceStop() const
360 return bSpaceStop;
363 BOOL SnapToGrid() const
365 return bSnapToGrid;
368 BOOL IsIgnoreFrmRTL() const
370 return bIgnoreFrmRTL;
373 BOOL IsPosMatchesBounds() const
375 return bPosMatchesBounds;
378 void SetOut( OutputDevice &rNew )
380 pOut = &rNew;
383 void SetPos( const Point &rNew )
385 pPos = &rNew;
386 #ifndef PRODUCT
387 bPos = TRUE;
388 #endif
391 void SetHyphPos( xub_StrLen *pNew )
393 pHyphPos = pNew;
394 #ifndef PRODUCT
395 bHyph = TRUE;
396 #endif
399 void SetText( const XubString &rNew )
401 pText = &rNew;
404 void SetWrong( const SwWrongList* pNew )
406 pWrong = pNew;
407 #ifndef PRODUCT
408 bWrong = TRUE;
409 #endif
412 void SetGrammarCheck( const SwWrongList* pNew )
414 pGrammarCheck = pNew;
415 #ifndef PRODUCT
416 bGrammarCheck = TRUE;
417 #endif
420 void SetSmartTags( const SwWrongList* pNew )
422 pSmartTags = pNew;
425 void SetSize( const Size &rNew )
427 pSize = &rNew;
428 #ifndef PRODUCT
429 bSize = TRUE;
430 #endif
433 void SetFont( SwFont* pNew )
435 pFnt = pNew;
436 #ifndef PRODUCT
437 bFnt = TRUE;
438 #endif
441 void SetIdx( xub_StrLen nNew )
443 nIdx = nNew;
446 void SetLen( xub_StrLen nNew )
448 nLen = nNew;
451 void SetOfst( xub_StrLen nNew )
453 nOfst = nNew;
454 #ifndef PRODUCT
455 bOfst = TRUE;
456 #endif
459 void SetLeft( long nNew )
461 nLeft = nNew;
462 #ifndef PRODUCT
463 bLeft = TRUE;
464 #endif
467 void SetRight( long nNew )
469 nRight = nNew;
470 #ifndef PRODUCT
471 bRight = TRUE;
472 #endif
475 void SetKanaDiff( long nNew )
477 nKanaDiff = nNew;
478 #ifndef PRODUCT
479 bKana = TRUE;
480 #endif
483 void SetWidth( USHORT nNew )
485 nWidth = nNew;
488 void SetAscent( USHORT nNew )
490 nAscent = nNew;
491 #ifndef PRODUCT
492 bAscent = TRUE;
493 #endif
496 void SetKern( long nNew )
498 nKern = nNew;
501 void SetSpace( long nNew )
503 if( nNew < 0 )
505 nSperren = -nNew;
506 nSpace = 0;
508 else
510 nSpace = nNew;
511 nSperren = 0;
513 #ifndef PRODUCT
514 bSpace = TRUE;
515 bSperr = TRUE;
516 #endif
519 void SetNumberOfBlanks( xub_StrLen nNew )
521 #ifndef PRODUCT
522 bNumberOfBlanks = TRUE;
523 #endif
524 nNumberOfBlanks = nNew;
527 void SetCursorBidiLevel( BYTE nNew )
529 nCursorBidiLevel = nNew;
532 void SetKanaComp( short nNew )
534 nCompress = nNew;
537 void SetBullet( BOOL bNew )
539 bBullet = bNew;
542 void SetUnderFnt( SwUnderlineFont* pULFnt )
544 pUnderFnt = pULFnt;
547 void SetUpper( BOOL bNew )
549 bUpper = bNew;
550 #ifndef PRODUCT
551 bUppr = TRUE;
552 #endif
555 void SetDrawSpace( BOOL bNew )
557 bDrawSpace = bNew;
558 #ifndef PRODUCT
559 bDrawSp = TRUE;
560 #endif
563 void SetGreyWave( BOOL bNew )
565 bGreyWave = bNew;
568 void SetSpaceStop( BOOL bNew )
570 bSpaceStop = bNew;
573 void SetSnapToGrid( BOOL bNew )
575 bSnapToGrid = bNew;
578 void SetIgnoreFrmRTL( BOOL bNew )
580 bIgnoreFrmRTL = bNew;
583 void SetPosMatchesBounds( BOOL bNew )
585 bPosMatchesBounds = bNew;
588 void Shift( USHORT nDir );
590 // sets a new color at the output device if necessary
591 // if a font is passed as argument, the change if made to the font
592 // otherwise the font at the output device is changed
593 // returns if the font has been changed
594 sal_Bool ApplyAutoColor( Font* pFnt = 0 );
597 #endif