1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 #ifndef _SV_GRAPHITETEXTSRC_HXX
25 #define _SV_GRAPHITETEXTSRC_HXX
26 // Description: Implements the Graphite interfaces IGrTextSource and
27 // IGrGraphics which provide Graphite with access to the
28 // app's text storage system and the platform's font and
29 // graphics systems.
30
31 // We need this to enable namespace support in libgrengine headers.
32 #define GR_NAMESPACE
33
34 // Standard Library
35 #include <stdexcept>
36 // Platform
37
38 #ifndef _SVWIN_H
39 #include <tools/svwin.h>
40 #endif
41
42 #include <svsys.h>
43 #include <salgdi.hxx>
44 #include <sallayout.hxx>
45
46 // Module
47 #include "vcl/dllapi.h"
48
49 // Libraries
50 #include <preextstl.h>
51 #include <graphite/GrClient.h>
52 #include <graphite/Font.h>
53 #include <graphite/ITextSource.h>
54 #include <postextstl.h>
55
56 // Module type definitions and forward declarations.
57 //
58 namespace grutils
59 {
60 class GrFeatureParser;
61 }
62 // Implements the Adaptor pattern to adapt the LayoutArgs and the ServerFont interfaces to the
63 // gr::IGrTextSource interface.
64 // @author tse
65 //
66 class TextSourceAdaptor : public gr::ITextSource
67 {
68 public:
69 TextSourceAdaptor(ImplLayoutArgs &layout_args, const int nContextLen) throw();
70 ~TextSourceAdaptor();
71 virtual gr::UtfType utfEncodingForm();
72 virtual size_t getLength();
73 virtual size_t fetch(gr::toffset ichMin, size_t cch, gr::utf32 * prgchBuffer);
74 virtual size_t fetch(gr::toffset ichMin, size_t cch, gr::utf16 * prgchwBuffer);
75 virtual size_t fetch(gr::toffset ichMin, size_t cch, gr::utf8 * prgchsBuffer);
76 virtual bool getRightToLeft(gr::toffset ich);
77 virtual unsigned int getDirectionDepth(gr::toffset ich);
78 virtual float getVerticalOffset(gr::toffset ich);
79 virtual gr::isocode getLanguage(gr::toffset ich);
80
81 virtual ext_std::pair<gr::toffset, gr::toffset> propertyRange(gr::toffset ich);
82 virtual size_t getFontFeatures(gr::toffset ich, gr::FeatureSetting * prgfset);
83 virtual bool sameSegment(gr::toffset ich1, gr::toffset ich2);
featureVariations()84 virtual bool featureVariations() { return false; }
85
86 operator ImplLayoutArgs & () throw();
87 void setFeatures(const grutils::GrFeatureParser * pFeatures);
getLayoutArgs() const88 const ImplLayoutArgs & getLayoutArgs() const { return maLayoutArgs; }
getContextLength() const89 size_t getContextLength() const { return mnEnd; };
90 inline void switchLayoutArgs(ImplLayoutArgs & newArgs);
91 private:
92 // Prevent the generation of a default assignment operator.
93 TextSourceAdaptor & operator=(const TextSourceAdaptor &);
94
95 void getCharProperties(const int, int &, int &, size_t &);
96
97 ImplLayoutArgs maLayoutArgs;
98 size_t mnEnd;
99 const grutils::GrFeatureParser * mpFeatures;
100 };
101
TextSourceAdaptor(ImplLayoutArgs & la,const int nContextLen)102 inline TextSourceAdaptor::TextSourceAdaptor(ImplLayoutArgs &la, const int nContextLen) throw()
103 : maLayoutArgs(la),
104 mnEnd(std::min(la.mnLength, nContextLen)),
105 mpFeatures(NULL)
106 {
107 }
108
operator ImplLayoutArgs&()109 inline TextSourceAdaptor::operator ImplLayoutArgs & () throw() {
110 return maLayoutArgs;
111 }
112
switchLayoutArgs(ImplLayoutArgs & aNewArgs)113 inline void TextSourceAdaptor::switchLayoutArgs(ImplLayoutArgs & aNewArgs)
114 {
115 mnEnd += aNewArgs.mnMinCharPos - maLayoutArgs.mnMinCharPos;
116 maLayoutArgs = aNewArgs;
117 }
118
119 #endif
120