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