xref: /aoo41x/main/vcl/inc/graphite_features.hxx (revision 161f4cd1)
1*161f4cd1SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*161f4cd1SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*161f4cd1SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*161f4cd1SAndrew Rist  * distributed with this work for additional information
6*161f4cd1SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*161f4cd1SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*161f4cd1SAndrew Rist  * "License"); you may not use this file except in compliance
9*161f4cd1SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*161f4cd1SAndrew Rist  *
11*161f4cd1SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*161f4cd1SAndrew Rist  *
13*161f4cd1SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*161f4cd1SAndrew Rist  * software distributed under the License is distributed on an
15*161f4cd1SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*161f4cd1SAndrew Rist  * KIND, either express or implied.  See the License for the
17*161f4cd1SAndrew Rist  * specific language governing permissions and limitations
18*161f4cd1SAndrew Rist  * under the License.
19*161f4cd1SAndrew Rist  *
20*161f4cd1SAndrew Rist  *************************************************************/
21*161f4cd1SAndrew Rist 
22*161f4cd1SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // Description:
25cdf0e10cSrcweir // Parse a string of features specified as ; separated pairs.
26cdf0e10cSrcweir // e.g.
27cdf0e10cSrcweir // 1001=1&2002=2&fav1=0
28cdf0e10cSrcweir #include <preextstl.h>
29cdf0e10cSrcweir #include <graphite/GrClient.h>
30cdf0e10cSrcweir #include <graphite/Font.h>
31cdf0e10cSrcweir #include <graphite/GrFeature.h>
32cdf0e10cSrcweir #include <postextstl.h>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir namespace grutils
35cdf0e10cSrcweir {
36cdf0e10cSrcweir 
37cdf0e10cSrcweir     class GrFeatureParser
38cdf0e10cSrcweir     {
39cdf0e10cSrcweir     public:
40cdf0e10cSrcweir         enum { MAX_FEATURES = 64 };
41cdf0e10cSrcweir         static const char FEAT_PREFIX;
42cdf0e10cSrcweir         static const char FEAT_SEPARATOR;
43cdf0e10cSrcweir         static const char FEAT_ID_VALUE_SEPARATOR;
44cdf0e10cSrcweir         static const std::string ISO_LANG;
45cdf0e10cSrcweir         GrFeatureParser(gr::Font & font, const std::string features, const std::string lang);
46cdf0e10cSrcweir         GrFeatureParser(gr::Font & font, const std::string lang);
47cdf0e10cSrcweir         GrFeatureParser(const GrFeatureParser & copy);
48cdf0e10cSrcweir         ~GrFeatureParser();
49cdf0e10cSrcweir         size_t getFontFeatures(gr::FeatureSetting settings[MAX_FEATURES]) const;
parseErrors()50cdf0e10cSrcweir         bool parseErrors() { return mbErrors; };
51cdf0e10cSrcweir         static bool isValid(gr::Font & font, gr::FeatureSetting & setting);
getLanguage() const52cdf0e10cSrcweir         gr::isocode getLanguage() const { return maLang; };
hasLanguage() const53cdf0e10cSrcweir         bool hasLanguage() const { return (maLang.rgch[0] != '\0'); }
54cdf0e10cSrcweir         sal_Int32 hashCode() const;
55cdf0e10cSrcweir     private:
56cdf0e10cSrcweir         void setLang(gr::Font & font, const std::string & lang);
57cdf0e10cSrcweir         bool isCharId(const std::string & id, size_t offset, size_t length);
58cdf0e10cSrcweir         int getCharId(const std::string & id, size_t offset, size_t length);
59cdf0e10cSrcweir         int getIntValue(const std::string & id, size_t offset, size_t length);
60cdf0e10cSrcweir         size_t mnNumSettings;
61cdf0e10cSrcweir         gr::isocode maLang;
62cdf0e10cSrcweir         bool mbErrors;
63cdf0e10cSrcweir         gr::FeatureSetting maSettings[64];
64cdf0e10cSrcweir     };
65cdf0e10cSrcweir 
66cdf0e10cSrcweir     union FeatId
67cdf0e10cSrcweir     {
68cdf0e10cSrcweir         gr::featid num;
69cdf0e10cSrcweir         unsigned char label[5];
70cdf0e10cSrcweir     };
71cdf0e10cSrcweir }
72