LibreOffice Module sw (master)  1
drawfont.hxx
Go to the documentation of this file.
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 INCLUDED_SW_SOURCE_CORE_INC_DRAWFONT_HXX
21 #define INCLUDED_SW_SOURCE_CORE_INC_DRAWFONT_HXX
22 
23 #include <osl/diagnose.h>
24 #include <vcl/vclptr.hxx>
25 #include <vcl/outdev.hxx>
26 #include "TextFrameIndex.hxx"
27 #include <swdllapi.h>
28 
29 class SwTextFrame;
30 class SwViewShell;
31 class SwScriptInfo;
32 namespace sw { class WrongListIterator; }
33 class SwFont;
34 namespace vcl {
35  class Font;
38 }
39 class SwUnderlineFont;
40 
41 // encapsulates information for drawing text
43 {
46  SwViewShell const * m_pSh;
50  OUString m_aText;
62  sal_Int32 m_nOfst;
63  sal_uInt16 m_nWidth;
64  sal_uInt16 m_nAscent;
65  sal_uInt16 m_nCompress;
66  long m_nSperren;
67  long m_nSpace;
68  long m_nKern;
71  bool m_bBullet : 1;
72  bool m_bUpper : 1; // for small caps: upper case flag
73  bool m_bDrawSpace : 1; // for small caps: underline/ line through
74  bool m_bGreyWave : 1; // grey wave line for extended text input
75  // For underlining we need to know, if a section is right in front of a
76  // whole block or a fix margin section.
77  bool m_bSpaceStop : 1;
78  bool m_bSnapToGrid : 1; // Does paragraph snap to grid?
79  // Paint text as if text has LTR direction, used for line numbering
80  bool m_bIgnoreFrameRTL : 1;
81  // GetCursorOfst should not return the next position if screen position is
82  // inside second half of bound rect, used for Accessibility
83  bool m_bPosMatchesBounds :1;
84 
85 public:
86 
87 #ifdef DBG_UTIL
88  // These flags should control that the appropriate Set-function has been
89  // called before calling the Get-function of a member
90  bool m_bPos : 1;
91  bool m_bWrong : 1;
92  bool m_bGrammarCheck : 1;
93  bool m_bSize : 1;
94  bool m_bFnt : 1;
95  bool m_bHyph : 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 
108  const OUString &rText, sal_Int32 const nIdx, sal_Int32 const nLen,
109  sal_uInt16 nWidth = 0, bool bBullet = false)
110  : SwDrawTextInfo(pSh, rOut, nullptr, rText, TextFrameIndex(nIdx), TextFrameIndex(nLen), nWidth, bBullet)
111  {}
113  SwDrawTextInfo( SwViewShell const *pSh, OutputDevice &rOut, const SwScriptInfo* pSI,
114  const OUString &rText, TextFrameIndex const nIdx, TextFrameIndex const nLen,
115  sal_uInt16 nWidth = 0, bool bBullet = false,
116  vcl::TextLayoutCache const*const pCachedVclData = nullptr)
117  : m_pCachedVclData(pCachedVclData)
118  {
119  m_pFrame = nullptr;
120  m_pSh = pSh;
121  m_pOut = &rOut;
122  m_pScriptInfo = pSI;
123  m_aText = rText;
124  m_nIdx = nIdx;
125  m_nLen = nLen;
126  m_nKern = 0;
127  m_nCompress = 0;
128  m_nWidth = nWidth;
129  m_nNumberOfBlanks = TextFrameIndex(0);
130  m_nCursorBidiLevel = 0;
131  m_bBullet = bBullet;
132  m_pUnderFnt = nullptr;
133  m_bGreyWave = false;
134  m_bSpaceStop = false;
135  m_bSnapToGrid = false;
136  m_bIgnoreFrameRTL = false;
137  m_bPosMatchesBounds = false;
138 
139  // These values are initialized but have to be set explicitly via their
140  // Set-function before they may be accessed by their Get-function:
141  m_pWrong = nullptr;
142  m_pGrammarCheck = nullptr;
143  m_pSmartTags = nullptr;
144  m_pFnt = nullptr;
145  m_pHyphPos = nullptr;
146  m_nKanaDiff = 0;
147  m_nOfst = 0;
148  m_nAscent = 0;
149  m_nSperren = 0;
150  m_nSpace = 0;
151  m_bUpper = false;
152  m_bDrawSpace = false;
153 
154 #ifdef DBG_UTIL
155  // these flags control whether the matching member variables have been
156  // set by using the Set-function before they may be accessed by their
157  // Get-function:
158  m_bPos = m_bWrong = m_bGrammarCheck = m_bSize = m_bFnt = m_bAscent =
159  m_bSpace = m_bNumberOfBlanks = m_bUppr =
160  m_bDrawSp = m_bKana = m_bOfst = m_bHyph =
161  m_bSperr = false;
162 #endif
163  }
164 
165  const SwTextFrame* GetFrame() const
166  {
167  return m_pFrame;
168  }
169 
170  void SetFrame( const SwTextFrame* pNewFrame )
171  {
172  m_pFrame = pNewFrame;
173  }
174 
175  SwViewShell const *GetShell() const
176  {
177  return m_pSh;
178  }
179 
181  {
182  return *m_pOut;
183  }
184 
186  {
187  return m_pOut;
188  }
189 
191  {
192  return m_pScriptInfo;
193  }
194 
195  const Point &GetPos() const
196  {
197 #ifdef DBG_UTIL
198  OSL_ENSURE( m_bPos, "DrawTextInfo: Undefined Position" );
199 #endif
200  return m_aPos;
201  }
202 
204  {
205 #ifdef DBG_UTIL
206  OSL_ENSURE( m_bHyph, "DrawTextInfo: Undefined Hyph Position" );
207 #endif
208  return m_pHyphPos;
209  }
210 
212  {
213  return m_pCachedVclData;
214  }
215 
216  const OUString &GetText() const
217  {
218  return m_aText;
219  }
220 
222  {
223 #ifdef DBG_UTIL
224  OSL_ENSURE( m_bWrong, "DrawTextInfo: Undefined WrongList" );
225 #endif
226  return m_pWrong;
227  }
228 
230  {
231 #ifdef DBG_UTIL
232  OSL_ENSURE( m_bGrammarCheck, "DrawTextInfo: Undefined GrammarCheck List" );
233 #endif
234  return m_pGrammarCheck;
235  }
236 
238  {
239  return m_pSmartTags;
240  }
241 
242  const Size &GetSize() const
243  {
244 #ifdef DBG_UTIL
245  OSL_ENSURE( m_bSize, "DrawTextInfo: Undefined Size" );
246 #endif
247  return m_aSize;
248  }
249 
250  SwFont* GetFont() const
251  {
252 #ifdef DBG_UTIL
253  OSL_ENSURE( m_bFnt, "DrawTextInfo: Undefined Font" );
254 #endif
255  return m_pFnt;
256  }
257 
259  {
260  return m_pUnderFnt;
261  }
262 
264  {
265  return m_nIdx;
266  }
267 
269  {
270  return m_nLen;
271  }
272 
273  sal_Int32 GetOfst() const
274  {
275 #ifdef DBG_UTIL
276  OSL_ENSURE( m_bOfst, "DrawTextInfo: Undefined Offset" );
277 #endif
278  return m_nOfst;
279  }
280 
282  {
283  return m_nIdx + m_nLen;
284  }
285 
286  long GetKanaDiff() const
287  {
288 #ifdef DBG_UTIL
289  OSL_ENSURE( m_bKana, "DrawTextInfo: Undefined kana difference" );
290 #endif
291  return m_nKanaDiff;
292  }
293 
294  sal_uInt16 GetWidth() const
295  {
296  return m_nWidth;
297  }
298 
299  sal_uInt16 GetAscent() const
300  {
301 #ifdef DBG_UTIL
302  OSL_ENSURE( m_bAscent, "DrawTextInfo: Undefined Ascent" );
303 #endif
304  return m_nAscent;
305  }
306 
307  sal_uInt16 GetKanaComp() const
308  {
309  return m_nCompress;
310  }
311 
312  long GetSperren() const
313  {
314 #ifdef DBG_UTIL
315  OSL_ENSURE( m_bSperr, "DrawTextInfo: Undefined >Sperren<" );
316 #endif
317  return m_nSperren;
318  }
319 
320  long GetKern() const
321  {
322  return m_nKern;
323  }
324 
325  long GetSpace() const
326  {
327 #ifdef DBG_UTIL
328  OSL_ENSURE( m_bSpace, "DrawTextInfo: Undefined Spacing" );
329 #endif
330  return m_nSpace;
331  }
332 
334  {
335 #ifdef DBG_UTIL
336  OSL_ENSURE( m_bNumberOfBlanks, "DrawTextInfo::Undefined NumberOfBlanks" );
337 #endif
338  return m_nNumberOfBlanks;
339  }
340 
342  {
343  return m_nCursorBidiLevel;
344  }
345 
346  bool GetBullet() const
347  {
348  return m_bBullet;
349  }
350 
351  bool GetUpper() const
352  {
353 #ifdef DBG_UTIL
354  OSL_ENSURE( m_bUppr, "DrawTextInfo: Undefined Upperflag" );
355 #endif
356  return m_bUpper;
357  }
358 
359  bool GetDrawSpace() const
360  {
361 #ifdef DBG_UTIL
362  OSL_ENSURE( m_bDrawSp, "DrawTextInfo: Undefined DrawSpaceflag" );
363 #endif
364  return m_bDrawSpace;
365  }
366 
367  bool GetGreyWave() const
368  {
369  return m_bGreyWave;
370  }
371 
372  bool IsSpaceStop() const
373  {
374  return m_bSpaceStop;
375  }
376 
377  bool SnapToGrid() const
378  {
379  return m_bSnapToGrid;
380  }
381 
382  bool IsIgnoreFrameRTL() const
383  {
384  return m_bIgnoreFrameRTL;
385  }
386 
387  bool IsPosMatchesBounds() const
388  {
389  return m_bPosMatchesBounds;
390  }
391 
392  void SetOut( OutputDevice &rNew )
393  {
394  m_pOut = &rNew;
395  }
396 
397  void SetPos( const Point &rNew )
398  {
399  m_aPos = rNew;
400 #ifdef DBG_UTIL
401  m_bPos = true;
402 #endif
403  }
404 
405  void SetHyphPos(TextFrameIndex *const pNew)
406  {
407  m_pHyphPos = pNew;
408 #ifdef DBG_UTIL
409  m_bHyph = true;
410 #endif
411  }
412 
413  void SetText( const OUString &rNew )
414  {
415  m_aText = rNew;
416  m_pCachedVclData = nullptr; // would any case benefit from save/restore?
417  }
418 
419  void SetWrong(sw::WrongListIterator *const pNew)
420  {
421  m_pWrong = pNew;
422 #ifdef DBG_UTIL
423  m_bWrong = true;
424 #endif
425  }
426 
428  {
429  m_pGrammarCheck = pNew;
430 #ifdef DBG_UTIL
431  m_bGrammarCheck = true;
432 #endif
433  }
434 
436  {
437  m_pSmartTags = pNew;
438  }
439 
440  void SetSize( const Size &rNew )
441  {
442  m_aSize = rNew;
443 #ifdef DBG_UTIL
444  m_bSize = true;
445 #endif
446  }
447 
448  void SetFont( SwFont* pNew )
449  {
450  m_pFnt = pNew;
451 #ifdef DBG_UTIL
452  m_bFnt = true;
453 #endif
454  }
455 
456  void SetIdx(TextFrameIndex const nNew)
457  {
458  m_nIdx = nNew;
459  }
460 
461  void SetLen(TextFrameIndex const nNew)
462  {
463  m_nLen = nNew;
464  }
465 
466  void SetOfst( sal_Int32 nNew )
467  {
468  m_nOfst = nNew;
469 #ifdef DBG_UTIL
470  m_bOfst = true;
471 #endif
472  }
473 
474  void SetKanaDiff( long nNew )
475  {
476  m_nKanaDiff = nNew;
477 #ifdef DBG_UTIL
478  m_bKana = true;
479 #endif
480  }
481 
482  void SetWidth( sal_uInt16 nNew )
483  {
484  m_nWidth = nNew;
485  }
486 
487  void SetAscent( sal_uInt16 nNew )
488  {
489  m_nAscent = nNew;
490 #ifdef DBG_UTIL
491  m_bAscent = true;
492 #endif
493  }
494 
495  void SetKern( long nNew )
496  {
497  m_nKern = nNew;
498  }
499 
500  void SetSpace( long nNew )
501  {
502  if( nNew < 0 )
503  {
504  m_nSperren = -nNew;
505  m_nSpace = 0;
506  }
507  else
508  {
509  m_nSpace = nNew;
510  m_nSperren = 0;
511  }
512 #ifdef DBG_UTIL
513  m_bSpace = true;
514  m_bSperr = true;
515 #endif
516  }
517 
519  {
520 #ifdef DBG_UTIL
521  m_bNumberOfBlanks = true;
522 #endif
523  m_nNumberOfBlanks = nNew;
524  }
525 
527  {
528  m_nCursorBidiLevel = nNew;
529  }
530 
531  void SetKanaComp( short nNew )
532  {
533  m_nCompress = nNew;
534  }
535 
536  void SetBullet( bool bNew )
537  {
538  m_bBullet = bNew;
539  }
540 
541  void SetUnderFnt( SwUnderlineFont* pULFnt )
542  {
543  m_pUnderFnt = pULFnt;
544  }
545 
546  void SetUpper( bool bNew )
547  {
548  m_bUpper = bNew;
549 #ifdef DBG_UTIL
550  m_bUppr = true;
551 #endif
552  }
553 
554  void SetDrawSpace( bool bNew )
555  {
556  m_bDrawSpace = bNew;
557 #ifdef DBG_UTIL
558  m_bDrawSp = true;
559 #endif
560  }
561 
562  void SetGreyWave( bool bNew )
563  {
564  m_bGreyWave = bNew;
565  }
566 
567  void SetSpaceStop( bool bNew )
568  {
569  m_bSpaceStop = bNew;
570  }
571 
572  void SetSnapToGrid( bool bNew )
573  {
574  m_bSnapToGrid = bNew;
575  }
576 
577  void SetIgnoreFrameRTL( bool bNew )
578  {
579  m_bIgnoreFrameRTL = bNew;
580  }
581 
582  void SetPosMatchesBounds( bool bNew )
583  {
584  m_bPosMatchesBounds = bNew;
585  }
586 
587  void Shift( sal_uInt16 nDir );
588 
589  // sets a new color at the output device if necessary if a font is passed
590  // as argument, the change if made to the font otherwise the font at the
591  // output device is changed returns if the font has been changed
592  bool ApplyAutoColor( vcl::Font* pFnt = nullptr );
593 };
594 
595 #endif
596 
597 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetSmartTags(sw::WrongListIterator *const pNew)
Definition: drawfont.hxx:435
SwViewShell const * GetShell() const
Definition: drawfont.hxx:175
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:149
long GetSpace() const
Definition: drawfont.hxx:325
sw::WrongListIterator * GetGrammarCheck() const
Definition: drawfont.hxx:229
VclPtr< OutputDevice > m_pOut
Definition: drawfont.hxx:45
sal_uInt16 m_nWidth
Definition: drawfont.hxx:63
vcl::RenderContext * GetpOut() const
Definition: drawfont.hxx:185
SwFont * GetFont() const
Definition: drawfont.hxx:250
bool GetDrawSpace() const
Definition: drawfont.hxx:359
sw::WrongListIterator * GetWrong() const
Definition: drawfont.hxx:221
TextFrameIndex GetEnd() const
Definition: drawfont.hxx:281
TextFrameIndex * GetHyphPos() const
Definition: drawfont.hxx:203
void SetSize(const Size &rNew)
Definition: drawfont.hxx:440
bool GetBullet() const
Definition: drawfont.hxx:346
void SetKern(long nNew)
Definition: drawfont.hxx:495
void SetIdx(TextFrameIndex const nNew)
Definition: drawfont.hxx:456
void SetGreyWave(bool bNew)
Definition: drawfont.hxx:562
void SetKanaComp(short nNew)
Definition: drawfont.hxx:531
void SetPos(const Point &rNew)
Definition: drawfont.hxx:397
bool IsPosMatchesBounds() const
Definition: drawfont.hxx:387
sal_uInt16 GetWidth() const
Definition: drawfont.hxx:294
void SetWidth(sal_uInt16 nNew)
Definition: drawfont.hxx:482
sal_uInt16 GetAscent() const
Definition: drawfont.hxx:299
Dialog to specify the properties of date form field.
Definition: accfrmobj.cxx:38
SwFont * m_pFnt
Definition: drawfont.hxx:55
void SetFrame(const SwTextFrame *pNewFrame)
Definition: drawfont.hxx:170
TextFrameIndex * m_pHyphPos
Definition: drawfont.hxx:57
void SetKanaDiff(long nNew)
Definition: drawfont.hxx:474
sal_Int32 GetOfst() const
Definition: drawfont.hxx:273
sw::WrongListIterator * m_pSmartTags
Definition: drawfont.hxx:53
const SwScriptInfo * GetScriptInfo() const
Definition: drawfont.hxx:190
void SetCursorBidiLevel(sal_uInt8 nNew)
Definition: drawfont.hxx:526
void SetSpaceStop(bool bNew)
Definition: drawfont.hxx:567
const SwTextFrame * GetFrame() const
Definition: drawfont.hxx:165
sal_Int32 m_nOfst
this is not a string index
Definition: drawfont.hxx:62
SwDrawTextInfo(SwViewShell const *pSh, OutputDevice &rOut, const OUString &rText, sal_Int32 const nIdx, sal_Int32 const nLen, sal_uInt16 nWidth=0, bool bBullet=false)
constructor for simple strings
Definition: drawfont.hxx:107
void SetUnderFnt(SwUnderlineFont *pULFnt)
Definition: drawfont.hxx:541
void SetOut(OutputDevice &rNew)
Definition: drawfont.hxx:392
SwUnderlineFont * m_pUnderFnt
Definition: drawfont.hxx:56
long GetKern() const
Definition: drawfont.hxx:320
sal_uInt8 m_nCursorBidiLevel
Definition: drawfont.hxx:70
SwUnderlineFont * GetUnderFnt() const
Definition: drawfont.hxx:258
vcl::TextLayoutCache const * GetVclCache() const
Definition: drawfont.hxx:211
void SetHyphPos(TextFrameIndex *const pNew)
Definition: drawfont.hxx:405
sal_uInt16 GetKanaComp() const
Definition: drawfont.hxx:307
void SetWrong(sw::WrongListIterator *const pNew)
Definition: drawfont.hxx:419
void SetLen(TextFrameIndex const nNew)
Definition: drawfont.hxx:461
SwDrawTextInfo(SwViewShell const *pSh, OutputDevice &rOut, const SwScriptInfo *pSI, const OUString &rText, TextFrameIndex const nIdx, TextFrameIndex const nLen, sal_uInt16 nWidth=0, bool bBullet=false, vcl::TextLayoutCache const *const pCachedVclData=nullptr)
constructor for text frame contents
Definition: drawfont.hxx:113
const OUString & GetText() const
Definition: drawfont.hxx:216
sw::WrongListIterator * GetSmartTags() const
Definition: drawfont.hxx:237
void SetNumberOfBlanks(TextFrameIndex const nNew)
Definition: drawfont.hxx:518
void SetAscent(sal_uInt16 nNew)
Definition: drawfont.hxx:487
void SetPosMatchesBounds(bool bNew)
Definition: drawfont.hxx:582
bool SnapToGrid() const
Definition: drawfont.hxx:377
bool IsIgnoreFrameRTL() const
Definition: drawfont.hxx:382
void SetOfst(sal_Int32 nNew)
Definition: drawfont.hxx:466
const SwTextFrame * m_pFrame
Definition: drawfont.hxx:44
void SetUpper(bool bNew)
Definition: drawfont.hxx:546
void SetBullet(bool bNew)
Definition: drawfont.hxx:536
void SetGrammarCheck(sw::WrongListIterator *const pNew)
Definition: drawfont.hxx:427
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
bool GetGreyWave() const
Definition: drawfont.hxx:367
TextFrameIndex m_nNumberOfBlanks
Definition: drawfont.hxx:69
void SetDrawSpace(bool bNew)
Definition: drawfont.hxx:554
OUString m_aText
Definition: drawfont.hxx:50
sal_uInt8 GetCursorBidiLevel() const
Definition: drawfont.hxx:341
sal_uInt16 m_nCompress
Definition: drawfont.hxx:65
bool GetUpper() const
Definition: drawfont.hxx:351
sw::WrongListIterator * m_pWrong
Definition: drawfont.hxx:51
long GetSperren() const
Definition: drawfont.hxx:312
long GetKanaDiff() const
Definition: drawfont.hxx:286
TextFrameIndex m_nIdx
Definition: drawfont.hxx:59
sal_uInt16 m_nAscent
Definition: drawfont.hxx:64
unsigned char sal_uInt8
OutputDevice RenderContext
Definition: paintfrm.hxx:29
TextFrameIndex GetNumberOfBlanks() const
Definition: drawfont.hxx:333
const Point & GetPos() const
Definition: drawfont.hxx:195
TextFrameIndex GetLen() const
Definition: drawfont.hxx:268
const Size & GetSize() const
Definition: drawfont.hxx:242
void SetSnapToGrid(bool bNew)
Definition: drawfont.hxx:572
SwViewShell const * m_pSh
Definition: drawfont.hxx:46
long m_nKanaDiff
Definition: drawfont.hxx:58
vcl::RenderContext & GetOut() const
Definition: drawfont.hxx:180
void SetText(const OUString &rNew)
Definition: drawfont.hxx:413
TextFrameIndex GetIdx() const
Definition: drawfont.hxx:263
void SetFont(SwFont *pNew)
Definition: drawfont.hxx:448
bool IsSpaceStop() const
Definition: drawfont.hxx:372
void SetSpace(long nNew)
Definition: drawfont.hxx:500
vcl::TextLayoutCache const * m_pCachedVclData
Definition: drawfont.hxx:49
o3tl::strong_int< sal_Int32, struct Tag_TextFrameIndex > TextFrameIndex
Denotes a character index in a text frame at a layout level, after extent mapping from a text node at...
TextFrameIndex m_nLen
Definition: drawfont.hxx:60
const SwScriptInfo * m_pScriptInfo
Definition: drawfont.hxx:47
void SetIgnoreFrameRTL(bool bNew)
Definition: drawfont.hxx:577
sw::WrongListIterator * m_pGrammarCheck
Definition: drawfont.hxx:52