Line data Source code
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 :
20 : // Description:
21 : // Parse a string of features specified as ; separated pairs.
22 : // e.g.
23 : // 1001=1&2002=2&fav1=0
24 :
25 : #ifndef INCLUDED_VCL_INC_GRAPHITE_FEATURES_HXX
26 : #define INCLUDED_VCL_INC_GRAPHITE_FEATURES_HXX
27 :
28 : #include <sal/types.h>
29 : #include <rtl/ustring.hxx>
30 : #include <graphite_static.hxx>
31 : #include <graphite2/Font.h>
32 :
33 : namespace grutils
34 : {
35 : union FeatId
36 : {
37 : gr_uint32 num;
38 : unsigned char label[5];
39 : };
40 :
41 : class GrFeatureParser
42 : {
43 : public:
44 : enum { MAX_FEATURES = 64 };
45 : static const char FEAT_PREFIX;
46 : static const char FEAT_SEPARATOR;
47 : static const char FEAT_ID_VALUE_SEPARATOR;
48 : GrFeatureParser(const gr_face * face, const OString& features, const OString& lang);
49 : GrFeatureParser(const gr_face * face, const OString& lang);
50 : ~GrFeatureParser();
51 : //size_t getFontFeatures(gr::FeatureSetting settings[MAX_FEATURES]) const;
52 : bool parseErrors() { return mbErrors; };
53 : //static bool isValid(gr::Font & font, gr::FeatureSetting & setting);
54 : gr_uint32 getLanguage() const { return maLang.num; };
55 : bool hasLanguage() const { return (maLang.label[0] != '\0'); }
56 : sal_Int32 hashCode() const { return mnHash; }
57 : size_t numFeatures() const { return mnNumSettings; }
58 0 : gr_feature_val * values() const { return mpSettings; };
59 : private:
60 : GrFeatureParser(const GrFeatureParser & copy) SAL_DELETED_FUNCTION;
61 : void setLang(const gr_face * face, const OString & lang);
62 : static bool isCharId(const OString & id, size_t offset, size_t length);
63 : static gr_uint32 getCharId(const OString & id, size_t offset, size_t length);
64 : short getIntValue(const OString & id, size_t offset, size_t length);
65 : size_t mnNumSettings;
66 : FeatId maLang;
67 : bool mbErrors;
68 : sal_uInt32 mnHash;
69 : gr_feature_val * mpSettings;
70 : };
71 :
72 : }
73 :
74 : #endif // INCLUDED_VCL_INC_GRAPHITE_FEATURES_HXX
75 :
76 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|