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