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