Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _DRAWFONT_HXX
30 : : #define _DRAWFONT_HXX
31 : :
32 : : #include <tools/solar.h>
33 : : #include <tools/string.hxx>
34 : :
35 : : class SwTxtFrm;
36 : : class OutputDevice;
37 : : class ViewShell;
38 : : class SwScriptInfo;
39 : : class Point;
40 : : class SwWrongList;
41 : : class Size;
42 : : class SwFont;
43 : : class Font;
44 : : class SwUnderlineFont;
45 : :
46 : : // encapsulates information for drawing text
47 : : class SwDrawTextInfo
48 : : {
49 : : const SwTxtFrm* pFrm;
50 : : OutputDevice* pOut;
51 : : ViewShell* pSh;
52 : : const SwScriptInfo* pScriptInfo;
53 : : const Point* pPos;
54 : : const XubString* pText;
55 : : const SwWrongList* pWrong;
56 : : const SwWrongList* pGrammarCheck;
57 : : const SwWrongList* pSmartTags;
58 : : const Size* pSize;
59 : : SwFont *pFnt;
60 : : SwUnderlineFont* pUnderFnt;
61 : : xub_StrLen* pHyphPos;
62 : : long nLeft;
63 : : long nRight;
64 : : long nKanaDiff;
65 : : xub_StrLen nIdx;
66 : : xub_StrLen nLen;
67 : : xub_StrLen nOfst;
68 : : sal_uInt16 nWidth;
69 : : sal_uInt16 nAscent;
70 : : sal_uInt16 nCompress;
71 : : long nSperren;
72 : : long nSpace;
73 : : long nKern;
74 : : xub_StrLen nNumberOfBlanks;
75 : : sal_uInt8 nCursorBidiLevel;
76 : : sal_Bool bBullet : 1;
77 : : sal_Bool bUpper : 1; // for small caps: upper case flag
78 : : sal_Bool bDrawSpace : 1; // for small caps: underline/ line through
79 : : sal_Bool bGreyWave : 1; // grey wave line for extended text input
80 : : // For underlining we need to know, if a section is right in front of a
81 : : // whole block or a fix margin section.
82 : : sal_Bool bSpaceStop : 1;
83 : : sal_Bool bSnapToGrid : 1; // Does paragraph snap to grid?
84 : : // Paint text as if text has LTR direction, used for line numbering
85 : : sal_Bool bIgnoreFrmRTL : 1;
86 : : // GetCrsrOfst should not return the next position if screen position is
87 : : // inside second half of bound rect, used for Accessibility
88 : : sal_Bool bPosMatchesBounds :1;
89 : :
90 : : SwDrawTextInfo(); // prohibited
91 : : public:
92 : :
93 : : #ifdef DBG_UTIL
94 : : // These flags should control that the appropriate Set-function has been
95 : : // called before calling the Get-function of a member
96 : : bool m_bPos : 1;
97 : : bool m_bWrong : 1;
98 : : bool m_bGrammarCheck : 1;
99 : : bool m_bSize : 1;
100 : : bool m_bFnt : 1;
101 : : bool m_bHyph : 1;
102 : : bool m_bLeft : 1;
103 : : bool m_bRight : 1;
104 : : bool m_bKana : 1;
105 : : bool m_bOfst : 1;
106 : : bool m_bAscent: 1;
107 : : bool m_bSperr : 1;
108 : : bool m_bSpace : 1;
109 : : bool m_bNumberOfBlanks : 1;
110 : : bool m_bUppr : 1;
111 : : bool m_bDrawSp: 1;
112 : : #endif
113 : :
114 : 123392 : SwDrawTextInfo( ViewShell *pS, OutputDevice &rO, const SwScriptInfo* pSI,
115 : : const XubString &rSt, xub_StrLen nI, xub_StrLen nL,
116 : : sal_uInt16 nW = 0, sal_Bool bB = sal_False )
117 : : {
118 : 123392 : pFrm = NULL;
119 : 123392 : pSh = pS;
120 : 123392 : pOut = &rO;
121 : 123392 : pScriptInfo = pSI;
122 : 123392 : pText = &rSt;
123 : 123392 : nIdx = nI;
124 : 123392 : nLen = nL;
125 : 123392 : nKern = 0;
126 : 123392 : nCompress = 0;
127 : 123392 : nWidth = nW;
128 : 123392 : nNumberOfBlanks = 0;
129 : 123392 : nCursorBidiLevel = 0;
130 : 123392 : bBullet = bB;
131 : 123392 : pUnderFnt = 0;
132 : 123392 : bGreyWave = sal_False;
133 : 123392 : bSpaceStop = sal_False;
134 : 123392 : bSnapToGrid = sal_False;
135 : 123392 : bIgnoreFrmRTL = sal_False;
136 : 123392 : bPosMatchesBounds = sal_False;
137 : :
138 : : // These values are initialized but have to be set explicitly via their
139 : : // Set-function before they may be accessed by their Get-function:
140 : 123392 : pPos = 0;
141 : 123392 : pWrong = 0;
142 : 123392 : pGrammarCheck = 0;
143 : 123392 : pSmartTags = 0;
144 : 123392 : pSize = 0;
145 : 123392 : pFnt = 0;
146 : 123392 : pHyphPos = 0;
147 : 123392 : nLeft = 0;
148 : 123392 : nRight = 0;
149 : 123392 : nKanaDiff = 0;
150 : 123392 : nOfst = 0;
151 : 123392 : nAscent = 0;
152 : 123392 : nSperren = 0;
153 : 123392 : nSpace = 0;
154 : 123392 : bUpper = sal_False;
155 : 123392 : bDrawSpace = sal_False;
156 : :
157 : : #ifdef DBG_UTIL
158 : : // these flags control whether the matching member variables have been
159 : : // set by using the Set-function before they may be accessed by their
160 : : // Get-function:
161 : : m_bPos = m_bWrong = m_bGrammarCheck = m_bSize = m_bFnt = m_bAscent =
162 : : m_bSpace = m_bNumberOfBlanks = m_bUppr =
163 : : m_bDrawSp = m_bLeft = m_bRight = m_bKana = m_bOfst = m_bHyph =
164 : : m_bSperr = false;
165 : : #endif
166 : 123392 : }
167 : :
168 : 406304 : const SwTxtFrm* GetFrm() const
169 : : {
170 : 406304 : return pFrm;
171 : : }
172 : :
173 : 123383 : void SetFrm( const SwTxtFrm* pNewFrm )
174 : : {
175 : 123383 : pFrm = pNewFrm;
176 : 123383 : }
177 : :
178 : 440815 : ViewShell *GetShell() const
179 : : {
180 : 440815 : return pSh;
181 : : }
182 : :
183 : 854481 : OutputDevice& GetOut() const
184 : : {
185 : 854481 : return *pOut;
186 : : }
187 : :
188 : 162673 : OutputDevice *GetpOut() const
189 : : {
190 : 162673 : return pOut;
191 : : }
192 : :
193 : 26422 : const SwScriptInfo* GetScriptInfo() const
194 : : {
195 : 26422 : return pScriptInfo;
196 : : }
197 : :
198 : 90801 : const Point &GetPos() const
199 : : {
200 : : #ifdef DBG_UTIL
201 : : OSL_ENSURE( m_bPos, "DrawTextInfo: Undefined Position" );
202 : : #endif
203 : 90801 : return *pPos;
204 : : }
205 : :
206 : 42491 : xub_StrLen *GetHyphPos() const
207 : : {
208 : : #ifdef DBG_UTIL
209 : : OSL_ENSURE( m_bHyph, "DrawTextInfo: Undefined Hyph Position" );
210 : : #endif
211 : 42491 : return pHyphPos;
212 : : }
213 : :
214 : 1733746 : const XubString &GetText() const
215 : : {
216 : 1733746 : return *pText;
217 : : }
218 : :
219 : 51285 : const SwWrongList* GetWrong() const
220 : : {
221 : : #ifdef DBG_UTIL
222 : : OSL_ENSURE( m_bWrong, "DrawTextInfo: Undefined WrongList" );
223 : : #endif
224 : 51285 : return pWrong;
225 : : }
226 : :
227 : 34129 : const SwWrongList* GetGrammarCheck() const
228 : : {
229 : : #ifdef DBG_UTIL
230 : : OSL_ENSURE( m_bGrammarCheck, "DrawTextInfo: Undefined GrammarCheck List" );
231 : : #endif
232 : 34129 : return pGrammarCheck;
233 : : }
234 : :
235 : 32043 : const SwWrongList* GetSmartTags() const
236 : : {
237 : 32043 : return pSmartTags;
238 : : }
239 : :
240 : 241 : const Size &GetSize() const
241 : : {
242 : : #ifdef DBG_UTIL
243 : : OSL_ENSURE( m_bSize, "DrawTextInfo: Undefined Size" );
244 : : #endif
245 : 241 : return *pSize;
246 : : }
247 : :
248 : 652888 : SwFont* GetFont() const
249 : : {
250 : : #ifdef DBG_UTIL
251 : : OSL_ENSURE( m_bFnt, "DrawTextInfo: Undefined Font" );
252 : : #endif
253 : 652888 : return pFnt;
254 : : }
255 : :
256 : 26687 : SwUnderlineFont* GetUnderFnt() const
257 : : {
258 : 26687 : return pUnderFnt;
259 : : }
260 : :
261 : 1723790 : xub_StrLen GetIdx() const
262 : : {
263 : 1723790 : return nIdx;
264 : : }
265 : :
266 : 769716 : xub_StrLen GetLen() const
267 : : {
268 : 769716 : return nLen;
269 : : }
270 : :
271 : 0 : xub_StrLen GetOfst() const
272 : : {
273 : : #ifdef DBG_UTIL
274 : : OSL_ENSURE( m_bOfst, "DrawTextInfo: Undefined Offset" );
275 : : #endif
276 : 0 : return nOfst;
277 : : }
278 : :
279 : 0 : xub_StrLen GetEnd() const
280 : : {
281 : 0 : return nIdx + nLen;
282 : : }
283 : :
284 : : long GetLeft() const
285 : : {
286 : : #ifdef DBG_UTIL
287 : : OSL_ENSURE( m_bLeft, "DrawTextInfo: Undefined left range" );
288 : : #endif
289 : : return nLeft;
290 : : }
291 : :
292 : : long GetRight() const
293 : : {
294 : : #ifdef DBG_UTIL
295 : : OSL_ENSURE( m_bRight, "DrawTextInfo: Undefined right range" );
296 : : #endif
297 : : return nRight;
298 : : }
299 : :
300 : 51563 : long GetKanaDiff() const
301 : : {
302 : : #ifdef DBG_UTIL
303 : : OSL_ENSURE( m_bKana, "DrawTextInfo: Undefined kana difference" );
304 : : #endif
305 : 51563 : return nKanaDiff;
306 : : }
307 : :
308 : 146 : sal_uInt16 GetWidth() const
309 : : {
310 : 146 : return nWidth;
311 : : }
312 : :
313 : 206 : sal_uInt16 GetAscent() const
314 : : {
315 : : #ifdef DBG_UTIL
316 : : OSL_ENSURE( m_bAscent, "DrawTextInfo: Undefined Ascent" );
317 : : #endif
318 : 206 : return nAscent;
319 : : }
320 : :
321 : 97102 : sal_uInt16 GetKanaComp() const
322 : : {
323 : 97102 : return nCompress;
324 : : }
325 : :
326 : 26568 : long GetSperren() const
327 : : {
328 : : #ifdef DBG_UTIL
329 : : OSL_ENSURE( m_bSperr, "DrawTextInfo: Undefined >Sperren<" );
330 : : #endif
331 : 26568 : return nSperren;
332 : : }
333 : :
334 : 1534415 : long GetKern() const
335 : : {
336 : 1534415 : return nKern;
337 : : }
338 : :
339 : 33347 : long GetSpace() const
340 : : {
341 : : #ifdef DBG_UTIL
342 : : OSL_ENSURE( m_bSpace, "DrawTextInfo: Undefined Spacing" );
343 : : #endif
344 : 33347 : return nSpace;
345 : : }
346 : :
347 : 0 : xub_StrLen GetNumberOfBlanks() const
348 : : {
349 : : #ifdef DBG_UTIL
350 : : OSL_ENSURE( m_bNumberOfBlanks, "DrawTextInfo::Undefined NumberOfBlanks" );
351 : : #endif
352 : 0 : return nNumberOfBlanks;
353 : : }
354 : :
355 : 0 : sal_uInt8 GetCursorBidiLevel() const
356 : : {
357 : 0 : return nCursorBidiLevel;
358 : : }
359 : :
360 : 26445 : sal_Bool GetBullet() const
361 : : {
362 : 26445 : return bBullet;
363 : : }
364 : :
365 : 21 : sal_Bool GetUpper() const
366 : : {
367 : : #ifdef DBG_UTIL
368 : : OSL_ENSURE( m_bUppr, "DrawTextInfo: Undefined Upperflag" );
369 : : #endif
370 : 21 : return bUpper;
371 : : }
372 : :
373 : 7 : sal_Bool GetDrawSpace() const
374 : : {
375 : : #ifdef DBG_UTIL
376 : : OSL_ENSURE( m_bDrawSp, "DrawTextInfo: Undefined DrawSpaceflag" );
377 : : #endif
378 : 7 : return bDrawSpace;
379 : : }
380 : :
381 : 26445 : sal_Bool GetGreyWave() const
382 : : {
383 : 26445 : return bGreyWave;
384 : : }
385 : :
386 : 0 : sal_Bool IsSpaceStop() const
387 : : {
388 : 0 : return bSpaceStop;
389 : : }
390 : :
391 : 247030 : sal_Bool SnapToGrid() const
392 : : {
393 : 247030 : return bSnapToGrid;
394 : : }
395 : :
396 : 0 : sal_Bool IsIgnoreFrmRTL() const
397 : : {
398 : 0 : return bIgnoreFrmRTL;
399 : : }
400 : :
401 : 0 : sal_Bool IsPosMatchesBounds() const
402 : : {
403 : 0 : return bPosMatchesBounds;
404 : : }
405 : :
406 : 42 : void SetOut( OutputDevice &rNew )
407 : : {
408 : 42 : pOut = &rNew;
409 : 42 : }
410 : :
411 : 80126 : void SetPos( const Point &rNew )
412 : : {
413 : 80126 : pPos = &rNew;
414 : : #ifdef DBG_UTIL
415 : : m_bPos = true;
416 : : #endif
417 : 80126 : }
418 : :
419 : 42491 : void SetHyphPos( xub_StrLen *pNew )
420 : : {
421 : 42491 : pHyphPos = pNew;
422 : : #ifdef DBG_UTIL
423 : : m_bHyph = true;
424 : : #endif
425 : 42491 : }
426 : :
427 : 55817 : void SetText( const XubString &rNew )
428 : : {
429 : 55817 : pText = &rNew;
430 : 55817 : }
431 : :
432 : 26448 : void SetWrong( const SwWrongList* pNew )
433 : : {
434 : 26448 : pWrong = pNew;
435 : : #ifdef DBG_UTIL
436 : : m_bWrong = true;
437 : : #endif
438 : 26448 : }
439 : :
440 : 26448 : void SetGrammarCheck( const SwWrongList* pNew )
441 : : {
442 : 26448 : pGrammarCheck = pNew;
443 : : #ifdef DBG_UTIL
444 : : m_bGrammarCheck = true;
445 : : #endif
446 : 26448 : }
447 : :
448 : 26448 : void SetSmartTags( const SwWrongList* pNew )
449 : : {
450 : 26448 : pSmartTags = pNew;
451 : 26448 : }
452 : :
453 : 213 : void SetSize( const Size &rNew )
454 : : {
455 : 213 : pSize = &rNew;
456 : : #ifdef DBG_UTIL
457 : : m_bSize = true;
458 : : #endif
459 : 213 : }
460 : :
461 : 177838 : void SetFont( SwFont* pNew )
462 : : {
463 : 177838 : pFnt = pNew;
464 : : #ifdef DBG_UTIL
465 : : m_bFnt = sal_True;
466 : : #endif
467 : 177838 : }
468 : :
469 : 259 : void SetIdx( xub_StrLen nNew )
470 : : {
471 : 259 : nIdx = nNew;
472 : 259 : }
473 : :
474 : 54854 : void SetLen( xub_StrLen nNew )
475 : : {
476 : 54854 : nLen = nNew;
477 : 54854 : }
478 : :
479 : 0 : void SetOfst( xub_StrLen nNew )
480 : : {
481 : 0 : nOfst = nNew;
482 : : #ifdef DBG_UTIL
483 : : m_bOfst = true;
484 : : #endif
485 : 0 : }
486 : :
487 : 26452 : void SetLeft( long nNew )
488 : : {
489 : 26452 : nLeft = nNew;
490 : : #ifdef DBG_UTIL
491 : : m_bLeft = true;
492 : : #endif
493 : 26452 : }
494 : :
495 : 26452 : void SetRight( long nNew )
496 : : {
497 : 26452 : nRight = nNew;
498 : : #ifdef DBG_UTIL
499 : : m_bRight = true;
500 : : #endif
501 : 26452 : }
502 : :
503 : 54595 : void SetKanaDiff( long nNew )
504 : : {
505 : 54595 : nKanaDiff = nNew;
506 : : #ifdef DBG_UTIL
507 : : m_bKana = true;
508 : : #endif
509 : 54595 : }
510 : :
511 : 119 : void SetWidth( sal_uInt16 nNew )
512 : : {
513 : 119 : nWidth = nNew;
514 : 119 : }
515 : :
516 : 206 : void SetAscent( sal_uInt16 nNew )
517 : : {
518 : 206 : nAscent = nNew;
519 : : #ifdef DBG_UTIL
520 : : m_bAscent = true;
521 : : #endif
522 : 206 : }
523 : :
524 : 135922 : void SetKern( long nNew )
525 : : {
526 : 135922 : nKern = nNew;
527 : 135922 : }
528 : :
529 : 26459 : void SetSpace( long nNew )
530 : : {
531 [ - + ]: 26459 : if( nNew < 0 )
532 : : {
533 : 0 : nSperren = -nNew;
534 : 0 : nSpace = 0;
535 : : }
536 : : else
537 : : {
538 : 26459 : nSpace = nNew;
539 : 26459 : nSperren = 0;
540 : : }
541 : : #ifdef DBG_UTIL
542 : : m_bSpace = true;
543 : : m_bSperr = true;
544 : : #endif
545 : 26459 : }
546 : :
547 : 0 : void SetNumberOfBlanks( xub_StrLen nNew )
548 : : {
549 : : #ifdef DBG_UTIL
550 : : m_bNumberOfBlanks = true;
551 : : #endif
552 : 0 : nNumberOfBlanks = nNew;
553 : 0 : }
554 : :
555 : 0 : void SetCursorBidiLevel( sal_uInt8 nNew )
556 : : {
557 : 0 : nCursorBidiLevel = nNew;
558 : 0 : }
559 : :
560 : 123377 : void SetKanaComp( short nNew )
561 : : {
562 : 123377 : nCompress = nNew;
563 : 123377 : }
564 : :
565 : 0 : void SetBullet( sal_Bool bNew )
566 : : {
567 : 0 : bBullet = bNew;
568 : 0 : }
569 : :
570 : 26661 : void SetUnderFnt( SwUnderlineFont* pULFnt )
571 : : {
572 : 26661 : pUnderFnt = pULFnt;
573 : 26661 : }
574 : :
575 : 21 : void SetUpper( sal_Bool bNew )
576 : : {
577 : 21 : bUpper = bNew;
578 : : #ifdef DBG_UTIL
579 : : m_bUppr = true;
580 : : #endif
581 : 21 : }
582 : :
583 : 7 : void SetDrawSpace( sal_Bool bNew )
584 : : {
585 : 7 : bDrawSpace = bNew;
586 : : #ifdef DBG_UTIL
587 : : m_bDrawSp = true;
588 : : #endif
589 : 7 : }
590 : :
591 : 26445 : void SetGreyWave( sal_Bool bNew )
592 : : {
593 : 26445 : bGreyWave = bNew;
594 : 26445 : }
595 : :
596 : 26423 : void SetSpaceStop( sal_Bool bNew )
597 : : {
598 : 26423 : bSpaceStop = bNew;
599 : 26423 : }
600 : :
601 : 123383 : void SetSnapToGrid( sal_Bool bNew )
602 : : {
603 : 123383 : bSnapToGrid = bNew;
604 : 123383 : }
605 : :
606 : 6 : void SetIgnoreFrmRTL( sal_Bool bNew )
607 : : {
608 : 6 : bIgnoreFrmRTL = bNew;
609 : 6 : }
610 : :
611 : 0 : void SetPosMatchesBounds( sal_Bool bNew )
612 : : {
613 : 0 : bPosMatchesBounds = bNew;
614 : 0 : }
615 : :
616 : : void Shift( sal_uInt16 nDir );
617 : :
618 : : // sets a new color at the output device if necessary if a font is passed
619 : : // as argument, the change if made to the font otherwise the font at the
620 : : // output device is changed returns if the font has been changed
621 : : sal_Bool ApplyAutoColor( Font* pFnt = 0 );
622 : : };
623 : :
624 : : #endif
625 : :
626 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|