Update ooo320-m1
[ooovba.git] / vcl / source / glyphs / graphite_textsrc.hxx
blob5e03bbfb09b45c5b2f8e8e9488726d1aeb94287e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: $
10 * $Revision: $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SV_GRAPHITETEXTSRC_HXX
32 #define _SV_GRAPHITETEXTSRC_HXX
33 // Description: Implements the Graphite interfaces IGrTextSource and
34 // IGrGraphics which provide Graphite with access to the
35 // app's text storage system and the platform's font and
36 // graphics systems.
38 // We need this to enable namespace support in libgrengine headers.
39 #define GR_NAMESPACE
41 // Standard Library
42 #include <stdexcept>
43 // Platform
45 #ifndef _SVWIN_H
46 #include <tools/svwin.h>
47 #endif
49 #ifndef _SV_SVSYS_HXX
50 #include <svsys.h>
51 #endif
53 #ifndef _SV_SALGDI_HXX
54 #include <vcl/salgdi.hxx>
55 #endif
57 #ifndef _SV_SALLAYOUT_HXX
58 #include <vcl/sallayout.hxx>
59 #endif
61 // Module
62 #include "vcl/dllapi.h"
64 // Libraries
65 #include <graphite/GrClient.h>
66 #include <graphite/Font.h>
67 #include <graphite/ITextSource.h>
69 // Module type definitions and forward declarations.
71 namespace grutils
73 class GrFeatureParser;
75 // Implements the Adaptor pattern to adapt the LayoutArgs and the ServerFont interfaces to the
76 // gr::IGrTextSource interface.
77 // @author tse
79 class TextSourceAdaptor : public gr::ITextSource
81 public:
82 TextSourceAdaptor(ImplLayoutArgs &layout_args, const int nContextLen) throw();
83 ~TextSourceAdaptor();
84 virtual gr::UtfType utfEncodingForm();
85 virtual size_t getLength();
86 virtual size_t fetch(gr::toffset ichMin, size_t cch, gr::utf32 * prgchBuffer);
87 virtual size_t fetch(gr::toffset ichMin, size_t cch, gr::utf16 * prgchwBuffer);
88 virtual size_t fetch(gr::toffset ichMin, size_t cch, gr::utf8 * prgchsBuffer);
89 virtual bool getRightToLeft(gr::toffset ich);
90 virtual unsigned int getDirectionDepth(gr::toffset ich);
91 virtual float getVerticalOffset(gr::toffset ich);
92 virtual gr::isocode getLanguage(gr::toffset ich);
94 virtual std::pair<gr::toffset, gr::toffset> propertyRange(gr::toffset ich);
95 virtual size_t getFontFeatures(gr::toffset ich, gr::FeatureSetting * prgfset);
96 virtual bool sameSegment(gr::toffset ich1, gr::toffset ich2);
98 operator ImplLayoutArgs & () throw();
99 void setFeatures(const grutils::GrFeatureParser * pFeatures);
100 const ImplLayoutArgs & getLayoutArgs() const { return maLayoutArgs; }
101 size_t getContextLength() const { return mnEnd; };
102 inline void switchLayoutArgs(ImplLayoutArgs & newArgs);
103 private:
104 // Prevent the generation of a default assignment operator.
105 TextSourceAdaptor & operator=(const TextSourceAdaptor &);
107 void getCharProperties(const int, int &, int &, size_t &);
109 ImplLayoutArgs maLayoutArgs;
110 size_t mnEnd;
111 const grutils::GrFeatureParser * mpFeatures;
114 inline TextSourceAdaptor::TextSourceAdaptor(ImplLayoutArgs &la, const int nContextLen) throw()
115 : maLayoutArgs(la),
116 mnEnd(std::min(la.mnLength, nContextLen)),
117 mpFeatures(NULL)
121 inline TextSourceAdaptor::operator ImplLayoutArgs & () throw() {
122 return maLayoutArgs;
125 inline void TextSourceAdaptor::switchLayoutArgs(ImplLayoutArgs & aNewArgs)
127 mnEnd += aNewArgs.mnMinCharPos - maLayoutArgs.mnMinCharPos;
128 maLayoutArgs = aNewArgs;
131 #endif