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