LibreOffice Module editeng (master) 1
svxfont.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#ifndef INCLUDED_EDITENG_SVXFONT_HXX
20#define INCLUDED_EDITENG_SVXFONT_HXX
21
22#include <editeng/svxenum.hxx>
23#include <o3tl/span.hxx>
24#include <tools/long.hxx>
25#include <vcl/font.hxx>
27#include <tools/poly.hxx>
28
29// Percentage of height of lower case small capital letters compared to upper case letters
30// See i#1526# for full explanation
31#define SMALL_CAPS_PERCENTAGE 80
32
33class KernArray;
34class SvxDoCapitals;
35class OutputDevice;
36class Printer;
37class Point;
38namespace tools { class Rectangle; }
39class Size;
41{
42 SvxCaseMap eCaseMap; // Text Markup
43 short nEsc; // Degree of Superscript/Subscript
44 sal_uInt8 nPropr; // Degree of reduction of the font height
45
46public:
47 SvxFont();
48 SvxFont( const vcl::Font &rFont );
49 SvxFont( const SvxFont &rFont );
50
51 // Methods for Superscript/Subscript
52 short GetEscapement() const { return nEsc; }
53 void SetEscapement( const short nNewEsc ) { nEsc = nNewEsc; }
54 // set specific values instead of automatic, and ensure valid value. Depends on nPropr being set already.
55 void SetNonAutoEscapement(short nNewEsc, const OutputDevice* pOutDev = nullptr);
56
57 sal_uInt8 GetPropr() const { return nPropr; }
58 void SetPropr( const sal_uInt8 nNewPropr ) { nPropr = nNewPropr; }
59 void SetProprRel( const sal_uInt8 nNewPropr )
60 { SetPropr( static_cast<sal_uInt8>( static_cast<tools::Long>(nNewPropr) * static_cast<tools::Long>(nPropr) / 100 ) ); }
61
62 SvxCaseMap GetCaseMap() const { return eCaseMap; }
63 void SetCaseMap( const SvxCaseMap eNew ) { eCaseMap = eNew; }
64
65 // Is-Methods:
66 bool IsCaseMap() const { return SvxCaseMap::NotMapped != eCaseMap; }
67 bool IsCapital() const { return SvxCaseMap::SmallCaps == eCaseMap; }
68 bool IsEsc() const { return 0 != nEsc; }
69
70 // Consider Upper case, Lower case letters etc.
71 OUString CalcCaseMap(const OUString &rTxt) const;
72
73 // Handle upper case letters
74 void DoOnCapitals(SvxDoCapitals &rDo) const;
75
76 void SetPhysFont(OutputDevice& rOut) const;
77 vcl::Font ChgPhysFont(OutputDevice& rOut) const;
78
79 Size GetCapitalSize( const OutputDevice *pOut, const OUString &rTxt,
80 const sal_Int32 nIdx, const sal_Int32 nLen) const;
81 void DrawCapital( OutputDevice *pOut, const Point &rPos, const OUString &rTxt,
82 const sal_Int32 nIdx, const sal_Int32 nLen ) const;
83
84 Size GetPhysTxtSize( const OutputDevice *pOut, const OUString &rTxt,
85 const sal_Int32 nIdx, const sal_Int32 nLen ) const;
86
87 Size GetPhysTxtSize( const OutputDevice *pOut );
88
89 Size GetTextSize(const OutputDevice& rOut, const OUString &rTxt,
90 const sal_Int32 nIdx = 0, const sal_Int32 nLen = SAL_MAX_INT32) const;
91
92 void QuickDrawText( OutputDevice *pOut, const Point &rPos, const OUString &rTxt,
93 const sal_Int32 nIdx = 0, const sal_Int32 nLen = SAL_MAX_INT32,
94 o3tl::span<const sal_Int32> pDXArray = {},
95 o3tl::span<const sal_Bool> pKashidaArray = {} ) const;
96
97 Size QuickGetTextSize( const OutputDevice *pOut, const OUString &rTxt,
98 const sal_Int32 nIdx, const sal_Int32 nLen,
99 KernArray* pDXArray = nullptr ) const;
100
101 void DrawPrev( OutputDevice* pOut, Printer* pPrinter,
102 const Point &rPos, const OUString &rTxt,
103 const sal_Int32 nIdx = 0, const sal_Int32 nLen = SAL_MAX_INT32 ) const;
104
105 static tools::Polygon DrawArrow( OutputDevice &rOut, const tools::Rectangle& rRect,
106 const Size& rSize, const Color& rCol, bool bLeftOrTop,
107 bool bVertical );
108
109 SvxFont& operator=( const SvxFont& rFont );
110 SvxFont& operator=( const Font& rFont );
111};
112
113#endif // INCLUDED_EDITENG_SVXFONT_HXX
114
115/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsEsc() const
Definition: svxfont.hxx:68
sal_uInt8 GetPropr() const
Definition: svxfont.hxx:57
void SetPropr(const sal_uInt8 nNewPropr)
Definition: svxfont.hxx:58
SvxCaseMap GetCaseMap() const
Definition: svxfont.hxx:62
SvxFont & operator=(const Font &rFont)
bool IsCaseMap() const
Definition: svxfont.hxx:66
SvxCaseMap eCaseMap
Definition: svxfont.hxx:42
short nEsc
Definition: svxfont.hxx:43
bool IsCapital() const
Definition: svxfont.hxx:67
void SetEscapement(const short nNewEsc)
Definition: svxfont.hxx:53
void SetProprRel(const sal_uInt8 nNewPropr)
Definition: svxfont.hxx:59
sal_uInt8 nPropr
Definition: svxfont.hxx:44
short GetEscapement() const
Definition: svxfont.hxx:52
void SetCaseMap(const SvxCaseMap eNew)
Definition: svxfont.hxx:63
Font & operator=(const Font &)
#define EDITENG_DLLPUBLIC
Definition: editengdllapi.h:28
float GetTextSize(std::u16string_view sValue)
long Long
SvxCaseMap
Definition: svxenum.hxx:25
unsigned char sal_uInt8