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