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
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
38 // We need this to enable namespace support in libgrengine headers.
46 #include <tools/svwin.h>
53 #ifndef _SV_SALGDI_HXX
54 #include <vcl/salgdi.hxx>
57 #ifndef _SV_SALLAYOUT_HXX
58 #include <vcl/sallayout.hxx>
62 #include "vcl/dllapi.h"
65 #include <graphite/GrClient.h>
66 #include <graphite/Font.h>
67 #include <graphite/ITextSource.h>
69 // Module type definitions and forward declarations.
73 class GrFeatureParser
;
75 // Implements the Adaptor pattern to adapt the LayoutArgs and the ServerFont interfaces to the
76 // gr::IGrTextSource interface.
79 class TextSourceAdaptor
: public gr::ITextSource
82 TextSourceAdaptor(ImplLayoutArgs
&layout_args
, const int nContextLen
) throw();
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
);
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
;
111 const grutils::GrFeatureParser
* mpFeatures
;
114 inline TextSourceAdaptor::TextSourceAdaptor(ImplLayoutArgs
&la
, const int nContextLen
) throw()
116 mnEnd(std::min(la
.mnLength
, nContextLen
)),
121 inline TextSourceAdaptor::operator ImplLayoutArgs
& () throw() {
125 inline void TextSourceAdaptor::switchLayoutArgs(ImplLayoutArgs
& aNewArgs
)
127 mnEnd
+= aNewArgs
.mnMinCharPos
- maLayoutArgs
.mnMinCharPos
;
128 maLayoutArgs
= aNewArgs
;