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