summaryrefslogtreecommitdiff
path: root/sw/source/core/inc/swfont.hxx
blob: e5608e5d65c7f5ce1039c3dc58e7cd0123dd9798 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */
#ifndef INCLUDED_SW_SOURCE_CORE_INC_SWFONT_HXX
#define INCLUDED_SW_SOURCE_CORE_INC_SWFONT_HXX

#include <i18nlangtag/lang.h>
#include <tools/color.hxx>
#include <tools/gen.hxx>
#include <editeng/svxfont.hxx>
#include <swtypes.hxx>
#include <drawfont.hxx>
#include <editeng/borderline.hxx>
#include <boost/optional.hpp>

class SfxItemSet;
class SwAttrSet;
class SwDoCapitals;     // DoCapitals
class SwDrawTextInfo;   // _DrawText
class SwScriptInfo;     // _GetTextSize
class SwViewShell;
class IDocumentSettingAccess;
typedef struct _xmlTextWriter *xmlTextWriterPtr;
enum class SvxShadowItemSide;

const sal_Unicode CH_BLANK = ' ';   // ' ' blank spaces
const sal_Unicode CH_BREAK = 0x0A;
const sal_Unicode CH_TAB   = '\t';  // \t
const sal_Unicode CH_PAR    = 0xB6;     // paragraph
const sal_Unicode CH_BULLET = 0xB7;     // centered dot

sal_uInt16 UnMapDirection( sal_uInt16 nDir, const bool bVertFormat );

class SwSubFont : public SvxFont
{
    friend class SwFont;
    const void *m_pMagic;         // "MagicNumber" within the font cache
    Size        m_aSize;          // foreigners only see this size
    sal_uInt16      m_nFontIndex;      // index in the font cache
    sal_uInt16      m_nOrgHeight;     // height including escapement/proportion
    sal_uInt16      m_nOrgAscent;     // ascent including escapement/proportion
    sal_uInt16      m_nProportionalWidth;     // proportional width
    bool m_bSmallCapsPercentage66;
    inline SwSubFont() : m_aSize(0,0)
    { m_pMagic = nullptr; m_nFontIndex = m_nOrgHeight = m_nOrgAscent = 0; m_nProportionalWidth =100; m_bSmallCapsPercentage66 = false; }

    sal_uInt16 CalcEscAscent( const sal_uInt16 nOldAscent ) const;
    sal_uInt16 CalcEscHeight( const sal_uInt16 nOldHeight,
                          const sal_uInt16 nOldAscent ) const;
    void CalcEsc( SwDrawTextInfo& rInf, Point& rPos );

    SwSubFont& operator=( const SwSubFont &rFont );

    short _CheckKerning( );

    bool ChgFnt( SwViewShell const *pSh, OutputDevice& rOut );
    bool IsSymbol( SwViewShell *pSh );
    sal_uInt16 GetAscent( SwViewShell *pSh, const OutputDevice& rOut );
    sal_uInt16 GetHeight( SwViewShell *pSh, const OutputDevice& rOut );
    Size _GetTextSize( SwDrawTextInfo& rInf );
    Size GetCapitalSize( SwDrawTextInfo& rInf );
    void _DrawText( SwDrawTextInfo &rInf, const bool bGrey );
    void DrawCapital( SwDrawTextInfo &rInf );
    void DrawStretchCapital( SwDrawTextInfo &rInf );
    void DoOnCapitals( SwDoCapitals &rDo );
    void _DrawStretchText( SwDrawTextInfo &rInf );
    sal_Int32 _GetCursorOfst( SwDrawTextInfo& rInf );
    sal_Int32 GetCapitalCursorOfst( SwDrawTextInfo& rInf );

    inline void SetColor( const Color& rColor );
    inline void SetFillColor( const Color& rColor );
    inline void SetCharSet( const rtl_TextEncoding eCharSet );
    inline void SetPitch( const FontPitch ePitch );
    inline void SetAlign( const FontAlign eAlign );
    inline void SetUnderline( const FontLineStyle eUnderline );
    inline void SetOverline( const FontLineStyle eOverline );
    inline void SetStrikeout( const FontStrikeout eStrikeout );
    inline void SetItalic( const FontItalic eItalic );
    inline void SetOutline( const bool bOutline );
    inline void SetVertical( const sal_uInt16 nDir, const bool bVertFormat );
    inline void SetShadow( const bool bShadow );
    inline void SetAutoKern( FontKerning nAutoKern );
    inline void SetWordLineMode( const bool bWordLineMode );
    inline void SetEmphasisMark( const FontEmphasisMark eValue );
    inline void SetRelief( const FontRelief eNew );

    // methods for sub-/superscript
    inline void SetEscapement( const short nNewEsc );
    inline void SetProportion( const sal_uInt8 nNewPropr );

    inline void SetFamily( const FontFamily eFamily );
    inline void SetName( const OUString& rName );
    inline void SetStyleName( const OUString& rStyleName );
    inline void SetSize( const Size& rSize );
    inline void SetWeight( const FontWeight eWeight );
    inline void SetLanguage( LanguageType eNewLang );
    inline short CheckKerning()
    {   return GetFixKerning() >= 0 ? GetFixKerning() : _CheckKerning( ); }
    inline void SetPropWidth( const sal_uInt16 nNew )
        { m_pMagic = nullptr; m_nProportionalWidth = nNew; }
public:
    sal_uInt16 GetPropWidth() const { return m_nProportionalWidth; }
};

#define SW_LATIN 0
#define SW_CJK 1
#define SW_CTL 2
#define SW_SCRIPTS 3

class SW_DLLPUBLIC SwFont
{
    // CJK == Chinese, Japanese, Korean
    // CTL == Complex text layout ( Hebrew, Arabic )
    SwSubFont   m_aSub[SW_SCRIPTS]; // Latin-, CJK- and CTL-font

    Color*      m_pBackColor;     // background color (i.e. at character styles)
    Color       m_aHighlightColor;   // highlight color
    Color       m_aUnderColor;    // color of the underlining
    Color       m_aOverColor;     // color of the overlining

    // character borders
    boost::optional<editeng::SvxBorderLine>     m_aTopBorder;
    boost::optional<editeng::SvxBorderLine>     m_aBottomBorder;
    boost::optional<editeng::SvxBorderLine>     m_aRightBorder;
    boost::optional<editeng::SvxBorderLine>     m_aLeftBorder;

    // border distance
    sal_uInt16 m_nTopBorderDist;
    sal_uInt16 m_nBottomBorderDist;
    sal_uInt16 m_nRightBorderDist;
    sal_uInt16 m_nLeftBorderDist;

    Color               m_aShadowColor;
    sal_uInt16          m_nShadowWidth;
    SvxShadowLocation   m_aShadowLocation;

    sal_uInt8   m_nToxCount;        // counts the nesting depth of the Tox
    sal_uInt8   m_nRefCount;        // counts the nesting depth of the Refs
    sal_uInt8   m_nMetaCount;   // count META/METAFIELD
    sal_uInt8   m_nInputFieldCount; // count INPUTFIELD

    sal_uInt8   m_nActual;        // actual font (Latin, CJK or CTL)

    // switch for the font-extensions
    bool m_bNoHyph        :1;  // SwTextNoHyphenHere: no separator
    bool m_bBlink         :1;  // blinking font
    bool m_bPaintBlank    :1;  // blanks not with DrawRect
    bool m_bFontChg        :1;
    bool m_bOrgChg        :1;  // nOrgHeight/Ascent are invalid
    bool m_bURL           :1;
    bool m_bPaintWrong    :1;  // flag for spelling mistakes
    bool m_bGreyWave      :1;  // for the extended TextInput: gray waveline
    bool m_bNoColorReplace  :1;  // Replacement without colormanipulation

public:
    SwFont( const SwAttrSet* pSet, const IDocumentSettingAccess* pIDocumentSettingAccess );
    SwFont( const SwFont& rFont );

    inline void ChgFnt( SwViewShell const *pSh, OutputDevice& rOut )
        { m_bPaintBlank = m_aSub[m_nActual].ChgFnt( pSh, rOut ); }

    ~SwFont();

    SwFont& operator=( const SwFont &rFont );

    inline sal_uInt8 GetActual() const {    return m_nActual; }
    inline void SetActual( sal_uInt8 nNew );
    inline const SvxFont& GetActualFont() const { return m_aSub[m_nActual]; }

    // gets a MagicNumber via SwFntAccess
    void GoMagic( SwViewShell *pSh, sal_uInt8 nWhich );
    // set background color
    void SetBackColor( Color* pNewColor );
    inline const Color* GetBackColor() const{ return m_pBackColor; }
    void SetHighlightColor( const Color& aNewColor );
    const Color& GetHighlightColor() const { return m_aHighlightColor; }

    inline void ChkMagic( SwViewShell *pSh, sal_uInt8 nWhich )
        { if( !m_aSub[ nWhich ].m_pMagic ) GoMagic( pSh, nWhich ); }
    inline void GetMagic( const void* &rMagic, sal_uInt16 &rIdx, sal_uInt8 nWhich )
        { rMagic = m_aSub[nWhich].m_pMagic; rIdx = m_aSub[nWhich].m_nFontIndex; }
    inline void SetMagic( const void* pNew, const sal_uInt16 nIdx, sal_uInt8 nWhich )
        { m_aSub[nWhich].m_pMagic = pNew; m_aSub[nWhich].m_nFontIndex = nIdx; }
    inline bool DifferentMagic( const SwFont* pFnt, sal_uInt8 nWhich )
        { return m_aSub[nWhich].m_pMagic != pFnt->m_aSub[nWhich].m_pMagic ||
          !m_aSub[nWhich].m_pMagic || !pFnt->m_aSub[nWhich].m_pMagic; }

    inline const Size &GetSize( sal_uInt8 nWhich ) const
        { return m_aSub[nWhich].m_aSize; }
    inline bool IsFntChg() const { return m_bFontChg; }
    inline void SetFntChg( const bool bNew ) { m_bFontChg = bNew; }

    // the encapsulated SV-Font-methods (set bFntChg to true)
    inline void SetColor( const Color& rColor );
    inline void SetFillColor( const Color& rColor );
    inline void SetAlign( const FontAlign eAlign );
    inline void SetUnderline( const FontLineStyle eUnderline );
    inline void SetUnderColor( const Color &rColor ) { m_aUnderColor = rColor; }
    inline void SetOverline( const FontLineStyle eOverline );
    inline void SetOverColor( const Color &rColor ) { m_aOverColor = rColor; }
    inline void SetStrikeout( const FontStrikeout eStrikeout );
    inline void SetOutline( const bool bOutline );
           void SetVertical( sal_uInt16 nDir, const bool bVertLayout = false );
    inline void SetShadow( const bool bShadow );
    inline void SetAutoKern( FontKerning nAutoKern );
    inline void SetTransparent( const bool bTrans );
    inline void SetWordLineMode( const bool bWordLineMode );
    inline void SetFixKerning( const short nNewKern );
    inline void SetCaseMap( const SvxCaseMap eNew );
    inline void SetEmphasisMark( const FontEmphasisMark eValue );

    // methods for sub-/superscript
    inline void SetEscapement( const short nNewEsc );
    inline void SetProportion( const sal_uInt8 nNewPropr );

    inline void SetPropWidth( const sal_uInt16 nNew );

    inline void SetFamily( const FontFamily eFamily, const sal_uInt8 nWhich );
    inline void SetName( const OUString& rName, const sal_uInt8 nWhich );
    inline void SetStyleName( const OUString& rStyleName, const sal_uInt8 nWhich );
    inline void SetSize( const Size& rSize, const sal_uInt8 nWhich );
    inline void SetWeight( const FontWeight eWeight, const sal_uInt8 nWhich );
    inline void SetItalic( const FontItalic eItalic, const sal_uInt8 nWhich );
    inline void SetLanguage( LanguageType eNewLang, const sal_uInt8 nWhich );
    inline void SetCharSet( const rtl_TextEncoding eCharSet, const sal_uInt8 nWhich );
    inline void SetPitch( const FontPitch ePitch, const sal_uInt8 nWhich );
    inline void SetRelief( const FontRelief eNew );

    // Get/Set-methods for the current setting
    inline void SetNoHyph( const bool bNew );
    inline void SetBlink( const bool bBlink );
    inline bool IsBlink() const { return m_bBlink; }
    inline sal_uInt8 &GetTox() { return m_nToxCount; }
    inline bool IsTox() const { return ( 0 != m_nToxCount ); }
    inline sal_uInt8 &GetRef() { return m_nRefCount; }
    inline bool IsRef() const { return ( 0 != m_nRefCount ); }
    inline sal_uInt8 &GetMeta() { return m_nMetaCount; }
    inline bool IsMeta() const { return (0 != m_nMetaCount); }
    inline sal_uInt8 &GetInputField() { return m_nInputFieldCount; }
    inline bool IsInputField() const { return (0 != m_nInputFieldCount); }
    inline bool IsURL() const { return m_bURL; }
    inline void SetGreyWave( const bool bNew );
    inline bool IsGreyWave() const { return m_bGreyWave; }
    inline void SetNoCol( const bool bNew );
    inline bool IsPaintBlank() const { return m_bPaintBlank; }

    // setting of the base class font for SwTextCharFormat
    void SetDiffFnt( const SfxItemSet* pSet,
                     const IDocumentSettingAccess* pIDocumentSettingAccess );

    inline const SvxFont &GetFnt( const sal_uInt8 nWhich ) const
        { return m_aSub[nWhich]; };

    bool IsSymbol( SwViewShell *pSh )
        { return m_aSub[m_nActual].IsSymbol( pSh ); }
    FontLineStyle GetUnderline() const { return m_aSub[m_nActual].GetUnderline(); }
    const Color& GetUnderColor() const { return m_aUnderColor; }
    FontLineStyle GetOverline() const { return m_aSub[m_nActual].GetOverline(); }
    const Color& GetOverColor() const { return m_aOverColor; }
    FontStrikeout GetStrikeout() const { return m_aSub[m_nActual].GetStrikeout(); }
    const Color& GetColor() const { return m_aSub[m_nActual].GetColor(); }
    bool IsWordLineMode() const { return m_aSub[m_nActual].IsWordLineMode(); }
    short GetEscapement() const { return m_aSub[m_nActual].GetEscapement(); }
    SvxCaseMap GetCaseMap() const { return m_aSub[m_nActual].GetCaseMap(); }
    sal_uInt8 GetPropr() const { return m_aSub[m_nActual].GetPropr(); }
    FontItalic GetItalic() const { return m_aSub[m_nActual].GetItalic(); }
    LanguageType GetLanguage() const { return m_aSub[m_nActual].GetLanguage(); }
    long GetHeight() const { return m_aSub[m_nActual].GetFontSize().Height(); }
    FontWeight GetWeight() const { return m_aSub[m_nActual].GetWeight(); }
    FontEmphasisMark GetEmphasisMark() const
        { return m_aSub[m_nActual].GetEmphasisMark(); }
    sal_uInt16 GetOrientation( const bool bVertLayout = false ) const;

    inline const OUString& GetName( const sal_uInt8 nWhich ) const
        { return m_aSub[nWhich].GetFamilyName(); }
    inline LanguageType GetLanguage( const sal_uInt8 nWhich ) const
        { return m_aSub[nWhich].GetLanguage(); }
    inline rtl_TextEncoding GetCharSet( const sal_uInt8 nWhich ) const
        { return m_aSub[nWhich].GetCharSet(); }
    inline long GetHeight( const sal_uInt8 nWhich ) const
        { return m_aSub[nWhich].GetFontSize().Height(); }

    // makes the logical font be effective in the OutputDevice
    void ChgPhysFnt( SwViewShell *pSh, OutputDevice& rOut );

    sal_Int32 GetCapitalBreak( SwViewShell const* pSh,  const OutputDevice* pOut,
        const SwScriptInfo* pScript, const OUString& rText,
        long nTextWidth, const sal_Int32 nIdx,
        const sal_Int32 nLen );

    void DoOnCapitals( SwDoCapitals &rDo )
        { m_aSub[m_nActual].DoOnCapitals( rDo ); }

    Size _GetTextSize( SwDrawTextInfo& rInf )
        { rInf.SetFont( this ); return m_aSub[m_nActual]._GetTextSize( rInf ); }

    sal_Int32 GetTextBreak( SwDrawTextInfo& rInf, long nTextWidth );

    sal_Int32 _GetCursorOfst( SwDrawTextInfo& rInf )
        { return m_aSub[m_nActual]._GetCursorOfst( rInf ); }

    inline void _DrawText( SwDrawTextInfo &rInf )
        { m_aSub[m_nActual]._DrawText( rInf, IsGreyWave() ); }

    inline void _DrawStretchText( SwDrawTextInfo &rInf )
        { m_aSub[m_nActual]._DrawStretchText( rInf ); }

    inline short CheckKerning()
        { return m_aSub[m_nActual].CheckKerning(); }

    inline sal_uInt16 GetAscent( SwViewShell *pSh, const OutputDevice& rOut )
        { return m_aSub[m_nActual].GetAscent( pSh, rOut ); }
    inline sal_uInt16 GetHeight( SwViewShell *pSh, const OutputDevice& rOut )
        { return m_aSub[m_nActual].GetHeight( pSh, rOut ); }

    inline void Invalidate()
        { m_bFontChg = m_bOrgChg = true; }

    void SetTopBorder( const editeng::SvxBorderLine* pTopBorder );
    void SetBottomBorder( const editeng::SvxBorderLine* pBottomBorder );
    void SetRightBorder( const editeng::SvxBorderLine* pRightBorder );
    void SetLeftBorder( const editeng::SvxBorderLine* pLeftBorder );

    const boost::optional<editeng::SvxBorderLine>& GetTopBorder() const { return m_aTopBorder; }
    const boost::optional<editeng::SvxBorderLine>& GetBottomBorder() const { return m_aBottomBorder; }
    const boost::optional<editeng::SvxBorderLine>& GetRightBorder() const { return m_aRightBorder; }
    const boost::optional<editeng::SvxBorderLine>& GetLeftBorder() const { return m_aLeftBorder; }

    // Get absolute border correspond to the layout verticality and orientation.
    const boost::optional<editeng::SvxBorderLine>& GetAbsTopBorder( const bool bVertLayout ) const;
    const boost::optional<editeng::SvxBorderLine>& GetAbsBottomBorder( const bool bVertLayout ) const;
    const boost::optional<editeng::SvxBorderLine>& GetAbsRightBorder( const bool bVertLayout ) const;
    const boost::optional<editeng::SvxBorderLine>& GetAbsLeftBorder( const bool bVertLayout ) const;

    void SetTopBorderDist( const sal_uInt16 nTopDist );
    void SetBottomBorderDist( const sal_uInt16 nBottomDist );
    void SetRightBorderDist( const sal_uInt16 nRightDist );
    void SetLeftBorderDist( const sal_uInt16 nLeftDist );

    sal_uInt16 GetTopBorderDist() const { return m_nTopBorderDist; }
    sal_uInt16 GetBottomBorderDist() const { return m_nBottomBorderDist; }
    sal_uInt16 GetRightBorderDist() const { return m_nRightBorderDist; }
    sal_uInt16 GetLeftBorderDist() const { return m_nLeftBorderDist; }

    // Return with the whole space which border holed (border width, spacing and shadow width)
    sal_uInt16 GetTopBorderSpace() const;
    sal_uInt16 GetBottomBorderSpace() const;
    sal_uInt16 GetRightBorderSpace() const;
    sal_uInt16 GetLeftBorderSpace() const;

    /// Check whether font has any border on any side
    bool HasBorder() const;

    void SetShadowColor( const Color& rColor );
    void SetShadowWidth( const sal_uInt16 nWidth );
    void SetShadowLocation( const SvxShadowLocation aLocation );

    const Color&        GetShadowColor() const { return m_aShadowColor; }
    sal_uInt16          GetShadowWidth() const { return m_nShadowWidth; }
    SvxShadowLocation   GetShadowLocation() const { return m_aShadowLocation; }

    /**
     * Get the absolute shadow location dependent from orientation.
     *
     * @param[in]   bVertLayout true, if the container layout is vertical
     *                          false, otherwise
     * @return      absolute location
    **/
    SvxShadowLocation GetAbsShadowLocation( const bool bVertLayout ) const;

    /**
     * Calculate the shadow space on the specified side dependent from
     * the orientation and connection with neighbours.
     * @see shaditem.hxx for integer constants of sides
     *
     * @param[in]   nShadow     specify the side
     * @param[in]   bVertLayout true, if the container layout is vertical
     *                          false, otherwise
     * @param[in]   bSkipLeft   relative left shadow space is skipped
     * @param[in]   bSkipRight  relative right shadow space is skipped
     * @return      the shadow space
    **/
    sal_uInt16 CalcShadowSpace(
        const SvxShadowItemSide nShadow, const bool bVertLayout,
        const bool bSkipLeft, const bool bSkipRight ) const;

    void dumpAsXml( xmlTextWriterPtr writer = nullptr ) const;
};

inline void SwFont::SetColor( const Color& rColor )
{
    m_bFontChg = true;
    m_aSub[0].SetColor( rColor );
    m_aSub[1].SetColor( rColor );
    m_aSub[2].SetColor( rColor );
}

// encapsulated SV-Font-method
inline void SwSubFont::SetColor( const Color& rColor )
{
    m_pMagic = nullptr;
    Font::SetColor( rColor );
}

// encapsulated SV-Font-method
inline void SwSubFont::SetFillColor( const Color& rColor )
{
    m_pMagic = nullptr;
    Font::SetFillColor( rColor );
}

inline void SwFont::SetFillColor( const Color& rColor )
{
    m_bFontChg = true;
    m_aSub[0].SetFillColor( rColor );
    m_aSub[1].SetFillColor( rColor );
    m_aSub[2].SetFillColor( rColor );
}

// encapsulated SV-Font-method
inline void SwSubFont::SetFamily( const FontFamily eFamily )
{
    m_pMagic = nullptr;
    Font::SetFamily( eFamily );
}

inline void SwFont::SetFamily( const FontFamily eFamily, const sal_uInt8 nWhich )
{
    m_bFontChg = true;
    m_aSub[nWhich].SetFamily( eFamily );
}

// encapsulated SV-Font-method
inline void SwSubFont::SetName( const OUString& rName )
{
    m_pMagic = nullptr;
    Font::SetFamilyName( rName );
}

inline void SwFont::SetName( const OUString& rName, const sal_uInt8 nWhich )
{
    m_bFontChg = true;
    m_aSub[nWhich].SetName( rName );
}

// encapsulated SV-Font-method
inline void SwSubFont::SetStyleName( const OUString& rStyleName )
{
    m_pMagic = nullptr;
    Font::SetStyleName( rStyleName );
}

inline void SwFont::SetStyleName( const OUString& rStyle, const sal_uInt8 nWhich )
{
    m_bFontChg = true;
    m_aSub[nWhich].SetStyleName( rStyle );
}

// encapsulated SV-Font-method
inline void SwSubFont::SetCharSet( const rtl_TextEncoding eCharSet )
{
    m_pMagic = nullptr;
    Font::SetCharSet( eCharSet );
}

inline void SwFont::SetCharSet( const rtl_TextEncoding eCharSet, const sal_uInt8 nWhich )
{
    m_bFontChg = true;
    m_aSub[nWhich].SetCharSet( eCharSet );
}

// encapsulated SV-Font-method
inline void SwSubFont::SetPitch( const FontPitch ePitch )
{
    m_pMagic = nullptr;
    Font::SetPitch( ePitch );
}

// encapsulated SV-Font-method
inline void SwFont::SetPitch( const FontPitch ePitch, const sal_uInt8 nWhich )
{
    m_bFontChg = true;
    m_aSub[nWhich].SetPitch( ePitch );
}

// encapsulated SV-Font-method
inline void SwSubFont::SetAlign( const FontAlign eAlign )
{
    m_pMagic = nullptr;
    Font::SetAlignment( eAlign );
}

inline void SwFont::SetAlign( const FontAlign eAlign )
{
    m_bFontChg = true;
    m_aSub[0].SetAlign( eAlign );
    m_aSub[1].SetAlign( eAlign );
    m_aSub[2].SetAlign( eAlign );
}

// encapsulated SV-Font-method
inline void SwSubFont::SetWeight( const FontWeight eWeight )
{
    m_pMagic = nullptr;
    Font::SetWeight( eWeight );
}

inline void SwFont::SetWeight( const FontWeight eWeight, const sal_uInt8 nWhich )
{
    m_bFontChg = true;
    m_aSub[nWhich].SetWeight( eWeight );
}

// encapsulated SV-Font-method
inline void SwSubFont::SetUnderline( const FontLineStyle eUnderline )
{
    m_pMagic = nullptr;
    Font::SetUnderline( eUnderline );
}

inline void SwFont::SetUnderline( const FontLineStyle eUnderline )
{
    m_bFontChg = true;
    m_aSub[0].SetUnderline( eUnderline );
    m_aSub[1].SetUnderline( eUnderline );
    m_aSub[2].SetUnderline( eUnderline );
}

// encapsulated SV-Font-method
inline void SwSubFont::SetOverline( const FontLineStyle eOverline )
{
    m_pMagic = nullptr;
    Font::SetOverline( eOverline );
}

inline void SwFont::SetOverline( const FontLineStyle eOverline )
{
    m_bFontChg = true;
    m_aSub[0].SetOverline( eOverline );
    m_aSub[1].SetOverline( eOverline );
    m_aSub[2].SetOverline( eOverline );
}

// encapsulated SV-Font-method
inline void SwSubFont::SetStrikeout( const FontStrikeout eStrikeout )
{
    m_pMagic = nullptr;
    Font::SetStrikeout( eStrikeout );
}

inline void SwFont::SetStrikeout( const FontStrikeout eStrikeout )
{
    m_bFontChg = true;
    m_aSub[0].SetStrikeout( eStrikeout );
    m_aSub[1].SetStrikeout( eStrikeout );
    m_aSub[2].SetStrikeout( eStrikeout );
}

// encapsulated SV-Font-method
inline void SwSubFont::SetItalic( const FontItalic eItalic )
{
    m_pMagic = nullptr;
    Font::SetItalic( eItalic );
}

inline void SwFont::SetItalic( const FontItalic eItalic, const sal_uInt8 nWhich )
{
    m_bFontChg = true;
    m_aSub[nWhich].SetItalic( eItalic );
}

// encapsulated SV-Font-method
inline void SwSubFont::SetOutline( const bool bOutline )
{
    m_pMagic = nullptr;
    Font::SetOutline( bOutline );
}

inline void SwFont::SetOutline( const bool bOutline )
{
    m_bFontChg = true;
    m_aSub[0].SetOutline( bOutline );
    m_aSub[1].SetOutline( bOutline );
    m_aSub[2].SetOutline( bOutline );
}

// encapsulated SV-Font-method
inline void SwSubFont::SetShadow( const bool bShadow )
{
    m_pMagic = nullptr;
    Font::SetShadow( bShadow );
}

inline void SwFont::SetShadow( const bool bShadow )
{
    m_bFontChg = true;
    m_aSub[0].SetShadow( bShadow );
    m_aSub[1].SetShadow( bShadow );
    m_aSub[2].SetShadow( bShadow );
}

// encapsulated SV-Font-method
inline void SwSubFont::SetAutoKern( FontKerning nAutoKern )
{
    m_pMagic = nullptr;
    Font::SetKerning( nAutoKern );
}

inline void SwFont::SetAutoKern( FontKerning nAutoKern )
{
    m_bFontChg = true;
    m_aSub[1].SetAutoKern( nAutoKern );
    if( nAutoKern != FontKerning::NONE )
        nAutoKern = FontKerning::FontSpecific;
    m_aSub[0].SetAutoKern( nAutoKern );
    m_aSub[2].SetAutoKern( nAutoKern );
}

inline void SwFont::SetTransparent( const bool bTrans )
{
    m_aSub[0].SetTransparent( bTrans );
    m_aSub[1].SetTransparent( bTrans );
    m_aSub[2].SetTransparent( bTrans );
}

inline void SwFont::SetFixKerning( const short nNewKern )
{
    m_aSub[SW_LATIN].SetFixKerning( nNewKern );
    m_aSub[SW_CJK].SetFixKerning( nNewKern );
    m_aSub[SW_CTL].SetFixKerning( nNewKern );
}

inline void SwFont::SetCaseMap( const SvxCaseMap eNew )
{
    m_aSub[SW_LATIN].SetCaseMap( eNew );
    m_aSub[SW_CJK].SetCaseMap( eNew );
    m_aSub[SW_CTL].SetCaseMap( eNew );
}

// encapsulated SV-Font-method
inline void SwSubFont::SetWordLineMode( const bool bWordLineMode )
{
    m_pMagic = nullptr;
    Font::SetWordLineMode( bWordLineMode );
}

inline void SwFont::SetWordLineMode( const bool bWordLineMode )
{
    m_bFontChg = true;
    m_aSub[0].SetWordLineMode( bWordLineMode );
    m_aSub[1].SetWordLineMode( bWordLineMode );
    m_aSub[2].SetWordLineMode( bWordLineMode );
}
// encapsulated SV-Font-method
inline void SwSubFont::SetEmphasisMark( const FontEmphasisMark eValue )
{
    m_pMagic = nullptr;
    Font::SetEmphasisMark( eValue );
}

inline void SwFont::SetEmphasisMark( const FontEmphasisMark eValue )
{
    m_bFontChg = true;
    m_aSub[0].SetEmphasisMark( eValue );
    m_aSub[1].SetEmphasisMark( eValue );
    m_aSub[2].SetEmphasisMark( eValue );
}

inline void SwFont::SetPropWidth( const sal_uInt16 nNew )
{
    if( nNew != m_aSub[0].GetPropWidth() )
    {
        m_bFontChg = true;
        m_aSub[0].SetPropWidth( nNew );
        m_aSub[1].SetPropWidth( nNew );
        m_aSub[2].SetPropWidth( nNew );
    }
}

// encapsulated SV-Font-method
inline void SwSubFont::SetRelief( const FontRelief eNew )
{
    m_pMagic = nullptr;
    Font::SetRelief( eNew );
}

inline void SwFont::SetRelief( const FontRelief eNew )
{
    if( eNew != m_aSub[0].GetRelief() )
    {
        m_bFontChg = true;
        m_aSub[0].SetRelief( eNew );
        m_aSub[1].SetRelief( eNew );
        m_aSub[2].SetRelief( eNew );
    }
}

// overloaded font-method
inline void SwSubFont::SetSize( const Size& rSize )
{
    m_aSize = rSize;
    if ( GetPropr() == 100 )
        Font::SetFontSize( m_aSize );
    else
    {
        Font::SetFontSize( Size(
            (long) m_aSize.Width() * GetPropr() / 100L,
            (long) m_aSize.Height() * GetPropr() / 100L ) );
    }
    m_pMagic = nullptr;
}

inline void SwFont::SetSize( const Size& rSize, const sal_uInt8 nWhich )
{
    if( m_aSub[nWhich].m_aSize != rSize )
    {
        m_aSub[nWhich].SetSize( rSize );
        m_bFontChg = true;
        m_bOrgChg = true;
    }
}

inline void SwFont::SetActual( sal_uInt8 nNew )
{
     if ( m_nActual != nNew )
     {
        m_bFontChg = true;
        m_bOrgChg = true;
        m_nActual = nNew;
     }
}

inline void SwSubFont::SetProportion( const sal_uInt8 nNewPropr )
{
    m_pMagic = nullptr;
    Font::SetFontSize( Size( (long) m_aSize.Width() * nNewPropr / 100L,
                         (long) m_aSize.Height() * nNewPropr / 100L ) );
    SvxFont::SetPropr( nNewPropr );
}

inline void SwFont::SetProportion( const sal_uInt8 nNewPropr )
{
    if( nNewPropr != m_aSub[0].GetPropr() )
    {
        m_bFontChg = true;
        m_bOrgChg = true;

        m_aSub[0].SetProportion( nNewPropr );
        m_aSub[1].SetProportion( nNewPropr );
        m_aSub[2].SetProportion( nNewPropr );
    }
}

inline void SwSubFont::SetEscapement( const short nNewEsc )
{
    m_pMagic = nullptr;
    SvxFont::SetEscapement( nNewEsc );
}

inline void SwFont::SetEscapement( const short nNewEsc )
{
    if( nNewEsc != m_aSub[0].GetEscapement() )
    {
        // these have to be set, otherwise nOrgHeight and nOrgAscent will not
        // be calculated
        m_bFontChg = true;
        m_bOrgChg = true;

        m_aSub[0].SetEscapement( nNewEsc );
        m_aSub[1].SetEscapement( nNewEsc );
        m_aSub[2].SetEscapement( nNewEsc );
    }
}

inline void SwSubFont::SetLanguage( LanguageType eNewLang )
{
    m_pMagic = nullptr;
    if( eNewLang == LANGUAGE_SYSTEM )
        eNewLang = (LanguageType)GetAppLanguage();
    SvxFont::SetLanguage( eNewLang );
}

inline void SwFont::SetLanguage( const LanguageType eNewLang, const sal_uInt8 nWhich )
{
    m_aSub[nWhich].SetLanguage( eNewLang );
    if( SW_CJK == nWhich )
    {
        m_aSub[SW_LATIN].SetCJKContextLanguage( eNewLang );
        m_aSub[SW_CJK].SetCJKContextLanguage( eNewLang );
        m_aSub[SW_CTL].SetCJKContextLanguage( eNewLang );
    }
}

inline void SwFont::SetNoHyph( const bool bNew )
{
    m_bNoHyph = bNew;
}

inline void SwFont::SetBlink( const bool bNew )
{
    m_bBlink = bNew;
}

inline void SwFont::SetGreyWave( const bool bNew )
{
    m_bGreyWave = bNew;
}

inline void SwFont::SetNoCol( const bool bNew )
{
    m_bNoColorReplace = bNew;
}

inline void SwSubFont::SetVertical( const sal_uInt16 nDir, const bool bVertFormat )
{
    m_pMagic = nullptr;
    Font::SetVertical( bVertFormat );
    Font::SetOrientation( nDir );
}

inline void SwFont::SetTopBorderDist( const sal_uInt16 nTopDist )
{
    m_nTopBorderDist = nTopDist;
    m_bFontChg = true;
    m_aSub[SW_LATIN].m_pMagic = m_aSub[SW_CJK].m_pMagic = m_aSub[SW_CTL].m_pMagic = nullptr;
}

inline void SwFont::SetBottomBorderDist( const sal_uInt16 nBottomDist )
{
    m_nBottomBorderDist = nBottomDist;
    m_bFontChg = true;
    m_aSub[SW_LATIN].m_pMagic = m_aSub[SW_CJK].m_pMagic = m_aSub[SW_CTL].m_pMagic = nullptr;
}

inline void SwFont::SetRightBorderDist( const sal_uInt16 nRightDist )
{
    m_nRightBorderDist = nRightDist;
    m_bFontChg = true;
    m_aSub[SW_LATIN].m_pMagic = m_aSub[SW_CJK].m_pMagic = m_aSub[SW_CTL].m_pMagic = nullptr;
}

inline void SwFont::SetLeftBorderDist( const sal_uInt16 nLeftDist )
{
    m_nLeftBorderDist = nLeftDist;
    m_bFontChg = true;
    m_aSub[SW_LATIN].m_pMagic = m_aSub[SW_CJK].m_pMagic = m_aSub[SW_CTL].m_pMagic = nullptr;
}

inline sal_uInt16 SwFont::GetTopBorderSpace() const
{
    sal_uInt16 nRet = 0;
    if( m_aTopBorder )
    {
        nRet += m_aTopBorder.get().GetScaledWidth() + m_nTopBorderDist;
    }
    if( m_aShadowLocation == SVX_SHADOW_TOPLEFT ||
        m_aShadowLocation == SVX_SHADOW_TOPRIGHT )
    {
        nRet += m_nShadowWidth;
    }
    return nRet;
}

inline sal_uInt16 SwFont::GetBottomBorderSpace() const
{
    sal_uInt16 nRet = 0;
    if( m_aBottomBorder )
    {
        nRet += m_aBottomBorder.get().GetScaledWidth() + m_nBottomBorderDist;
    }
    if( m_aShadowLocation == SVX_SHADOW_BOTTOMLEFT ||
        m_aShadowLocation == SVX_SHADOW_BOTTOMRIGHT )
    {
        nRet += m_nShadowWidth;
    }
    return nRet;
}

inline sal_uInt16 SwFont::GetRightBorderSpace() const
{
    sal_uInt16 nRet = 0;
    if( m_aRightBorder )
    {
        nRet += m_aRightBorder.get().GetScaledWidth() + m_nRightBorderDist;
    }
    if( m_aShadowLocation == SVX_SHADOW_TOPRIGHT ||
        m_aShadowLocation == SVX_SHADOW_BOTTOMRIGHT )
    {
        nRet += m_nShadowWidth;
    }
    return nRet;
}

inline sal_uInt16 SwFont::GetLeftBorderSpace() const
{
    sal_uInt16 nRet = 0;
    if( m_aLeftBorder )
    {
        nRet += m_aLeftBorder.get().GetScaledWidth() + m_nLeftBorderDist;
    }
    if( m_aShadowLocation == SVX_SHADOW_TOPLEFT ||
        m_aShadowLocation == SVX_SHADOW_BOTTOMLEFT )
    {
        nRet += m_nShadowWidth;
    }
    return nRet;
}

inline bool SwFont::HasBorder() const
{
    return m_aTopBorder || m_aBottomBorder || m_aLeftBorder || m_aRightBorder;
}

inline void SwFont::SetShadowColor( const Color& rColor )
{
    m_aShadowColor = rColor;
    m_bFontChg = true;
    m_aSub[SW_LATIN].m_pMagic = m_aSub[SW_CJK].m_pMagic = m_aSub[SW_CTL].m_pMagic = nullptr;
}

inline void SwFont::SetShadowWidth( const sal_uInt16 nWidth )
{
    m_nShadowWidth = nWidth;
    m_bFontChg = true;
    m_aSub[SW_LATIN].m_pMagic = m_aSub[SW_CJK].m_pMagic = m_aSub[SW_CTL].m_pMagic = nullptr;
}

inline void SwFont::SetShadowLocation( const SvxShadowLocation aLocation )
{
    m_aShadowLocation = aLocation;
    m_bFontChg = true;
    m_aSub[SW_LATIN].m_pMagic = m_aSub[SW_CJK].m_pMagic = m_aSub[SW_CTL].m_pMagic = nullptr;
}

inline void SwFont::SetHighlightColor( const Color& aNewColor )
{
    m_aHighlightColor = aNewColor;
    m_bFontChg = true;
    m_aSub[SW_LATIN].m_pMagic = m_aSub[SW_CJK].m_pMagic = m_aSub[SW_CTL].m_pMagic = nullptr;
}

// Used for the "continuous underline" feature.
class SwUnderlineFont
{
    Point m_aPos;
    SwFont* m_pFont;

public:
    // sets the font which should paint the common baseline
    // and the starting point of the common baseline
    SwUnderlineFont( SwFont& rFnt, const Point& rPoint );
    ~SwUnderlineFont();

    SwFont& GetFont()
    {
        OSL_ENSURE( m_pFont, "No underline font" );
        return *m_pFont;
    }
    const Point& GetPos() const { return m_aPos; }
    // the x coordinate of the starting point has to be set for each portion
    void SetPos( const Point& rPoint ) { m_aPos = rPoint;  }
};

#ifdef DBG_UTIL

class SvStatistics
{
public:
    sal_uInt16 nGetTextSize;
    sal_uInt16 nDrawText;
    sal_uInt16 nGetStretchTextSize;
    sal_uInt16 nDrawStretchText;
    sal_uInt16 nChangeFont;
    sal_uInt16 nGetFontMetric;

    inline void Reset()
    {
        nGetTextSize = nDrawText = nGetStretchTextSize =
        nDrawStretchText = nChangeFont = nGetFontMetric = 0;
    }

    inline SvStatistics() { Reset(); }
};

// global variable, implemented in swfont.cxx
extern SvStatistics g_SvStat;

#define SV_STAT(nWhich) ++(g_SvStat.nWhich);


#else
#define SV_STAT(nWhich)
#endif  /* DBG_UTIL */

#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */