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