1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: drawfont.hxx,v $
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 ************************************************************************/
33 #include <tools/solar.h>
34 #include <tools/string.hxx>
46 class SwUnderlineFont
;
48 /*************************************************************************
49 * class SwDrawTextInfo
51 * encapsulates information for drawing text
52 *************************************************************************/
59 const SwScriptInfo
* pScriptInfo
;
61 const XubString
* pText
;
62 const SwWrongList
* pWrong
;
63 const SwWrongList
* pGrammarCheck
;
64 const SwWrongList
* pSmartTags
; // SMARTTAGS
67 SwUnderlineFont
* pUnderFnt
;
81 xub_StrLen nNumberOfBlanks
;
82 BYTE nCursorBidiLevel
;
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
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
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
114 BOOL bNumberOfBlanks
: 1;
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
)
134 nCursorBidiLevel
= 0;
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:
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
;
172 const SwTxtFrm
* GetFrm() const
177 void SetFrm( const SwTxtFrm
* pNewFrm
)
182 ViewShell
*GetShell() const
187 OutputDevice
& GetOut() const
192 OutputDevice
*GetpOut() const
197 const SwScriptInfo
* GetScriptInfo() const
202 const Point
&GetPos() const
204 ASSERT( bPos
, "DrawTextInfo: Undefined Position" );
208 xub_StrLen
*GetHyphPos() const
210 ASSERT( bHyph
, "DrawTextInfo: Undefined Hyph Position" );
214 const XubString
&GetText() const
219 const SwWrongList
* GetWrong() const
221 ASSERT( bWrong
, "DrawTextInfo: Undefined WrongList" );
225 const SwWrongList
* GetGrammarCheck() const
227 ASSERT( bGrammarCheck
, "DrawTextInfo: Undefined GrammarCheck List" );
228 return pGrammarCheck
;
231 const SwWrongList
* GetSmartTags() const
236 const Size
&GetSize() const
238 ASSERT( bSize
, "DrawTextInfo: Undefined Size" );
242 SwFont
* GetFont() const
244 ASSERT( bFnt
, "DrawTextInfo: Undefined Font" );
248 SwUnderlineFont
* GetUnderFnt() const
253 xub_StrLen
GetIdx() const
258 xub_StrLen
GetLen() const
263 xub_StrLen
GetOfst() const
265 ASSERT( bOfst
, "DrawTextInfo: Undefined Offset" );
269 xub_StrLen
GetEnd() const
276 ASSERT( bLeft
, "DrawTextInfo: Undefined left range" );
280 long GetRight() const
282 ASSERT( bRight
, "DrawTextInfo: Undefined right range" );
286 long GetKanaDiff() const
288 ASSERT( bKana
, "DrawTextInfo: Undefined kana difference" );
292 USHORT
GetWidth() const
297 USHORT
GetAscent() const
299 ASSERT( bAscent
, "DrawTextInfo: Undefined Ascent" );
303 USHORT
GetKanaComp() const
308 long GetSperren() const
310 ASSERT( bSperr
, "DrawTextInfo: Undefined >Sperren<" );
319 long GetSpace() const
321 ASSERT( bSpace
, "DrawTextInfo: Undefined Spacing" );
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
341 BOOL
GetUpper() const
343 ASSERT( bUppr
, "DrawTextInfo: Undefined Upperflag" );
347 BOOL
GetDrawSpace() const
349 ASSERT( bDrawSp
, "DrawTextInfo: Undefined DrawSpaceflag" );
353 BOOL
GetGreyWave() const
358 BOOL
IsSpaceStop() const
363 BOOL
SnapToGrid() const
368 BOOL
IsIgnoreFrmRTL() const
370 return bIgnoreFrmRTL
;
373 BOOL
IsPosMatchesBounds() const
375 return bPosMatchesBounds
;
378 void SetOut( OutputDevice
&rNew
)
383 void SetPos( const Point
&rNew
)
391 void SetHyphPos( xub_StrLen
*pNew
)
399 void SetText( const XubString
&rNew
)
404 void SetWrong( const SwWrongList
* pNew
)
412 void SetGrammarCheck( const SwWrongList
* pNew
)
414 pGrammarCheck
= pNew
;
416 bGrammarCheck
= TRUE
;
420 void SetSmartTags( const SwWrongList
* pNew
)
425 void SetSize( const Size
&rNew
)
433 void SetFont( SwFont
* pNew
)
441 void SetIdx( xub_StrLen nNew
)
446 void SetLen( xub_StrLen nNew
)
451 void SetOfst( xub_StrLen nNew
)
459 void SetLeft( long nNew
)
467 void SetRight( long nNew
)
475 void SetKanaDiff( long nNew
)
483 void SetWidth( USHORT nNew
)
488 void SetAscent( USHORT nNew
)
496 void SetKern( long nNew
)
501 void SetSpace( long nNew
)
519 void SetNumberOfBlanks( xub_StrLen nNew
)
522 bNumberOfBlanks
= TRUE
;
524 nNumberOfBlanks
= nNew
;
527 void SetCursorBidiLevel( BYTE nNew
)
529 nCursorBidiLevel
= nNew
;
532 void SetKanaComp( short nNew
)
537 void SetBullet( BOOL bNew
)
542 void SetUnderFnt( SwUnderlineFont
* pULFnt
)
547 void SetUpper( BOOL bNew
)
555 void SetDrawSpace( BOOL bNew
)
563 void SetGreyWave( BOOL bNew
)
568 void SetSpaceStop( BOOL bNew
)
573 void SetSnapToGrid( BOOL 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 );