LibreOffice Module vcl (master)  1
Feature.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 
10 #ifndef INCLUDED_VCL_FONT_FEATURE_HXX
11 #define INCLUDED_VCL_FONT_FEATURE_HXX
12 
13 #include <vcl/dllapi.h>
14 #include <rtl/ustring.hxx>
15 #include <vector>
16 
17 namespace vcl
18 {
19 namespace font
20 {
21 constexpr uint32_t featureCode(const char sFeature[4])
22 {
23  return static_cast<uint32_t>(sFeature[0]) << 24U | static_cast<uint32_t>(sFeature[1]) << 16U
24  | static_cast<uint32_t>(sFeature[2]) << 8U | static_cast<uint32_t>(sFeature[3]);
25 }
26 
27 VCL_DLLPUBLIC OUString featureCodeAsString(uint32_t nFeature);
28 
30 {
31  BOOL,
32  ENUM
33 };
34 
35 enum class FeatureType
36 {
37  OpenType,
38  Graphite
39 };
40 
42 {
43 private:
44  uint32_t m_nCode;
45  OUString m_sDescription;
46  const char* m_pDescriptionID;
47 
48 public:
49  FeatureParameter(uint32_t nCode, OUString aDescription);
50  FeatureParameter(uint32_t nCode, const char* pDescriptionID);
51 
52  uint32_t getCode() const;
53  OUString getDescription() const;
54 };
55 
57 {
58 private:
59  OUString m_sDescription;
60  const char* m_pDescriptionID;
61  OUString m_sNumericPart;
62  uint32_t m_nCode;
63  uint32_t m_nDefault;
65  // the index of the parameter defines the enum value, string is the description
66  std::vector<FeatureParameter> m_aEnumParameters;
67 
68 public:
70  FeatureDefinition(uint32_t nCode, OUString const& rDescription,
72  std::vector<FeatureParameter> const& rEnumParameters
73  = std::vector<FeatureParameter>{},
74  uint32_t nDefault = 0);
75  FeatureDefinition(uint32_t nCode, const char* pDescriptionID,
76  OUString const& rNumericPart = OUString());
77  FeatureDefinition(uint32_t nCode, const char* pDescriptionID,
78  std::vector<FeatureParameter> aEnumParameters);
79 
80  const std::vector<FeatureParameter>& getEnumParameters() const;
81  uint32_t getCode() const;
82  OUString getDescription() const;
84  uint32_t getDefault() const;
85 
86  operator bool() const;
87 };
88 
90 {
91  uint32_t m_aFeatureCode;
92  uint32_t m_aScriptCode;
93  uint32_t m_aLanguageCode;
94 };
95 
97 {
98  Feature();
99  Feature(FeatureID const& rID, FeatureType eType);
100 
104 };
105 
106 // This is basically duplicates hb_feature_t to avoid including HarfBuzz
107 // headers here, so the member types should remain compatible.
109 {
110  FeatureSetting(OString feature);
111 
112  uint32_t m_nTag;
113  uint32_t m_nValue;
114  unsigned int m_nStart;
115  unsigned int m_nEnd;
116 };
117 
118 } // end font namespace
119 
120 } // end vcl namespace
121 
122 #endif // INCLUDED_VCL_FONT_FEATURE_HXX
123 
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool getType(BSTR name, Type &type)
OUString featureCodeAsString(uint32_t nFeature)
Definition: Feature.cxx:21
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
constexpr uint32_t featureCode(const char sFeature[4])
Definition: Feature.hxx:21
FeatureID m_aID
Definition: Feature.hxx:101
const char * m_pDescriptionID
Definition: Feature.hxx:60
const char * m_pDescriptionID
Definition: Feature.hxx:46
FeatureType const m_eType
Definition: Feature.hxx:102
uint32_t m_aFeatureCode
Definition: Feature.hxx:91
uint32_t m_aScriptCode
Definition: Feature.hxx:92
DocumentType const eType
uint32_t m_aLanguageCode
Definition: Feature.hxx:93
FeatureParameterType m_eType
Definition: Feature.hxx:64
std::vector< FeatureParameter > m_aEnumParameters
Definition: Feature.hxx:66
FeatureDefinition m_aDefinition
Definition: Feature.hxx:103
FeatureParameterType
Definition: Feature.hxx:29