nss: upgrade to release 3.73
[LibreOffice.git] / sw / source / core / inc / drawfont.hxx
blob64739ef6d114acdd0b43a798c3ac0c3ccfe1188d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SW_SOURCE_CORE_INC_DRAWFONT_HXX
21 #define INCLUDED_SW_SOURCE_CORE_INC_DRAWFONT_HXX
23 #include <osl/diagnose.h>
24 #include <vcl/vclptr.hxx>
25 #include <vcl/outdev.hxx>
26 #include "TextFrameIndex.hxx"
27 #include <swdllapi.h>
29 class SwTextFrame;
30 class SwViewShell;
31 class SwScriptInfo;
32 namespace sw { class WrongListIterator; }
33 class SwFont;
34 namespace vcl {
35 class Font;
36 class TextLayoutCache;
37 typedef OutputDevice RenderContext;
39 class SwUnderlineFont;
41 // encapsulates information for drawing text
42 class SW_DLLPUBLIC SwDrawTextInfo
44 const SwTextFrame* m_pFrame;
45 VclPtr<OutputDevice> m_pOut;
46 SwViewShell const * m_pSh;
47 const SwScriptInfo* m_pScriptInfo;
48 Point m_aPos;
49 vcl::TextLayoutCache const* m_pCachedVclData;
50 OUString m_aText;
51 sw::WrongListIterator* m_pWrong;
52 sw::WrongListIterator* m_pGrammarCheck;
53 sw::WrongListIterator* m_pSmartTags;
54 Size m_aSize;
55 SwFont *m_pFnt;
56 SwUnderlineFont* m_pUnderFnt;
57 TextFrameIndex* m_pHyphPos;
58 tools::Long m_nKanaDiff;
59 TextFrameIndex m_nIdx;
60 TextFrameIndex m_nLen;
61 /// this is not a string index
62 sal_Int32 m_nOfst;
63 sal_uInt16 m_nWidth;
64 sal_uInt16 m_nAscent;
65 sal_uInt16 m_nCompress;
66 tools::Long m_nSperren;
67 tools::Long m_nSpace;
68 tools::Long m_nKern;
69 TextFrameIndex m_nNumberOfBlanks;
70 sal_uInt8 m_nCursorBidiLevel;
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 // GetModelPositionForViewPoint 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;
85 public:
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
106 /// constructor for simple strings
107 SwDrawTextInfo( SwViewShell const *pSh, OutputDevice &rOut,
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)
112 /// constructor for text frame contents
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)
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;
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;
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
165 const SwTextFrame* GetFrame() const
167 return m_pFrame;
170 void SetFrame( const SwTextFrame* pNewFrame )
172 m_pFrame = pNewFrame;
175 SwViewShell const *GetShell() const
177 return m_pSh;
180 vcl::RenderContext& GetOut() const
182 return *m_pOut;
185 vcl::RenderContext *GetpOut() const
187 return m_pOut;
190 const SwScriptInfo* GetScriptInfo() const
192 return m_pScriptInfo;
195 const Point &GetPos() const
197 #ifdef DBG_UTIL
198 OSL_ENSURE( m_bPos, "DrawTextInfo: Undefined Position" );
199 #endif
200 return m_aPos;
203 TextFrameIndex *GetHyphPos() const
205 #ifdef DBG_UTIL
206 OSL_ENSURE( m_bHyph, "DrawTextInfo: Undefined Hyph Position" );
207 #endif
208 return m_pHyphPos;
211 vcl::TextLayoutCache const* GetVclCache() const
213 return m_pCachedVclData;
216 const OUString &GetText() const
218 return m_aText;
221 sw::WrongListIterator* GetWrong() const
223 #ifdef DBG_UTIL
224 OSL_ENSURE( m_bWrong, "DrawTextInfo: Undefined WrongList" );
225 #endif
226 return m_pWrong;
229 sw::WrongListIterator* GetGrammarCheck() const
231 #ifdef DBG_UTIL
232 OSL_ENSURE( m_bGrammarCheck, "DrawTextInfo: Undefined GrammarCheck List" );
233 #endif
234 return m_pGrammarCheck;
237 sw::WrongListIterator* GetSmartTags() const
239 return m_pSmartTags;
242 const Size &GetSize() const
244 #ifdef DBG_UTIL
245 OSL_ENSURE( m_bSize, "DrawTextInfo: Undefined Size" );
246 #endif
247 return m_aSize;
250 SwFont* GetFont() const
252 #ifdef DBG_UTIL
253 OSL_ENSURE( m_bFnt, "DrawTextInfo: Undefined Font" );
254 #endif
255 return m_pFnt;
258 SwUnderlineFont* GetUnderFnt() const
260 return m_pUnderFnt;
263 TextFrameIndex GetIdx() const
265 return m_nIdx;
268 TextFrameIndex GetLen() const
270 return m_nLen;
273 sal_Int32 GetOffset() const
275 #ifdef DBG_UTIL
276 OSL_ENSURE( m_bOfst, "DrawTextInfo: Undefined Offset" );
277 #endif
278 return m_nOfst;
281 TextFrameIndex GetEnd() const
283 return m_nIdx + m_nLen;
286 tools::Long GetKanaDiff() const
288 #ifdef DBG_UTIL
289 OSL_ENSURE( m_bKana, "DrawTextInfo: Undefined kana difference" );
290 #endif
291 return m_nKanaDiff;
294 sal_uInt16 GetWidth() const
296 return m_nWidth;
299 sal_uInt16 GetAscent() const
301 #ifdef DBG_UTIL
302 OSL_ENSURE( m_bAscent, "DrawTextInfo: Undefined Ascent" );
303 #endif
304 return m_nAscent;
307 sal_uInt16 GetKanaComp() const
309 return m_nCompress;
312 tools::Long GetSperren() const
314 #ifdef DBG_UTIL
315 OSL_ENSURE( m_bSperr, "DrawTextInfo: Undefined >Sperren<" );
316 #endif
317 return m_nSperren;
320 tools::Long GetKern() const
322 return m_nKern;
325 tools::Long GetSpace() const
327 #ifdef DBG_UTIL
328 OSL_ENSURE( m_bSpace, "DrawTextInfo: Undefined Spacing" );
329 #endif
330 return m_nSpace;
333 TextFrameIndex GetNumberOfBlanks() const
335 #ifdef DBG_UTIL
336 OSL_ENSURE( m_bNumberOfBlanks, "DrawTextInfo::Undefined NumberOfBlanks" );
337 #endif
338 return m_nNumberOfBlanks;
341 sal_uInt8 GetCursorBidiLevel() const
343 return m_nCursorBidiLevel;
346 bool GetBullet() const
348 return m_bBullet;
351 bool GetUpper() const
353 #ifdef DBG_UTIL
354 OSL_ENSURE( m_bUppr, "DrawTextInfo: Undefined Upperflag" );
355 #endif
356 return m_bUpper;
359 bool GetDrawSpace() const
361 #ifdef DBG_UTIL
362 OSL_ENSURE( m_bDrawSp, "DrawTextInfo: Undefined DrawSpaceflag" );
363 #endif
364 return m_bDrawSpace;
367 bool GetGreyWave() const
369 return m_bGreyWave;
372 bool IsSpaceStop() const
374 return m_bSpaceStop;
377 bool SnapToGrid() const
379 return m_bSnapToGrid;
382 bool IsIgnoreFrameRTL() const
384 return m_bIgnoreFrameRTL;
387 bool IsPosMatchesBounds() const
389 return m_bPosMatchesBounds;
392 void SetOut( OutputDevice &rNew )
394 m_pOut = &rNew;
397 void SetPos( const Point &rNew )
399 m_aPos = rNew;
400 #ifdef DBG_UTIL
401 m_bPos = true;
402 #endif
405 void SetHyphPos(TextFrameIndex *const pNew)
407 m_pHyphPos = pNew;
408 #ifdef DBG_UTIL
409 m_bHyph = true;
410 #endif
413 void SetText( const OUString &rNew )
415 m_aText = rNew;
416 m_pCachedVclData = nullptr; // would any case benefit from save/restore?
419 void SetWrong(sw::WrongListIterator *const pNew)
421 m_pWrong = pNew;
422 #ifdef DBG_UTIL
423 m_bWrong = true;
424 #endif
427 void SetGrammarCheck(sw::WrongListIterator *const pNew)
429 m_pGrammarCheck = pNew;
430 #ifdef DBG_UTIL
431 m_bGrammarCheck = true;
432 #endif
435 void SetSmartTags(sw::WrongListIterator *const pNew)
437 m_pSmartTags = pNew;
440 void SetSize( const Size &rNew )
442 m_aSize = rNew;
443 #ifdef DBG_UTIL
444 m_bSize = true;
445 #endif
448 void SetFont( SwFont* pNew )
450 m_pFnt = pNew;
451 #ifdef DBG_UTIL
452 m_bFnt = true;
453 #endif
456 void SetIdx(TextFrameIndex const nNew)
458 m_nIdx = nNew;
461 void SetLen(TextFrameIndex const nNew)
463 m_nLen = nNew;
466 void SetOffset( sal_Int32 nNew )
468 m_nOfst = nNew;
469 #ifdef DBG_UTIL
470 m_bOfst = true;
471 #endif
474 void SetKanaDiff( tools::Long nNew )
476 m_nKanaDiff = nNew;
477 #ifdef DBG_UTIL
478 m_bKana = true;
479 #endif
482 void SetWidth( sal_uInt16 nNew )
484 m_nWidth = nNew;
487 void SetAscent( sal_uInt16 nNew )
489 m_nAscent = nNew;
490 #ifdef DBG_UTIL
491 m_bAscent = true;
492 #endif
495 void SetKern( tools::Long nNew )
497 m_nKern = nNew;
500 void SetSpace( tools::Long nNew )
502 if( nNew < 0 )
504 m_nSperren = -nNew;
505 m_nSpace = 0;
507 else
509 m_nSpace = nNew;
510 m_nSperren = 0;
512 #ifdef DBG_UTIL
513 m_bSpace = true;
514 m_bSperr = true;
515 #endif
518 void SetNumberOfBlanks( TextFrameIndex const nNew )
520 #ifdef DBG_UTIL
521 m_bNumberOfBlanks = true;
522 #endif
523 m_nNumberOfBlanks = nNew;
526 void SetCursorBidiLevel( sal_uInt8 nNew )
528 m_nCursorBidiLevel = nNew;
531 void SetKanaComp( short nNew )
533 m_nCompress = nNew;
536 void SetBullet( bool bNew )
538 m_bBullet = bNew;
541 void SetUnderFnt( SwUnderlineFont* pULFnt )
543 m_pUnderFnt = pULFnt;
546 void SetUpper( bool bNew )
548 m_bUpper = bNew;
549 #ifdef DBG_UTIL
550 m_bUppr = true;
551 #endif
554 void SetDrawSpace( bool bNew )
556 m_bDrawSpace = bNew;
557 #ifdef DBG_UTIL
558 m_bDrawSp = true;
559 #endif
562 void SetGreyWave( bool bNew )
564 m_bGreyWave = bNew;
567 void SetSpaceStop( bool bNew )
569 m_bSpaceStop = bNew;
572 void SetSnapToGrid( bool bNew )
574 m_bSnapToGrid = bNew;
577 void SetIgnoreFrameRTL( bool bNew )
579 m_bIgnoreFrameRTL = bNew;
582 void SetPosMatchesBounds( bool bNew )
584 m_bPosMatchesBounds = bNew;
587 void Shift( Degree10 nDir );
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 );
595 #endif
597 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */