00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef GR_RENDERINFO_H
00022 #define GR_RENDERINFO_H
00023
00024 #include "ut_types.h"
00025 #include "ut_vector.h"
00026 #include "gr_Graphics.h"
00027
00028 class UT_TextIterator;
00029
00039 enum GR_ScriptType
00040 {
00041 GRScriptType_Undefined = 0,
00042 GRScriptType_Void = 0xffffffff
00043 };
00044
00047 enum GRRI_Type
00048 {
00049 GRRI_XP = 0,
00050 GRRI_WIN32,
00051 GRRI_UNIX,
00052 GRRI_COCOA,
00053 GRRI_WIN32_UNISCRIBE,
00054 GRRI_CAIRO_PANGO,
00055
00056 GRRI_BUILT_IN_LAST = 0x0000ffff,
00057
00058 GRRI_UNKNOWN = 0xffffffff
00059 };
00060
00061
00070 class ABI_EXPORT GR_Item
00071 {
00072 public:
00073 virtual ~GR_Item(){};
00074 virtual GR_ScriptType getType() const = 0;
00075 virtual GR_Item * makeCopy() const = 0;
00076 virtual GRRI_Type getClassId() const = 0;
00077
00078 protected:
00079 GR_Item(){};
00080 };
00081
00082
00083 class ABI_EXPORT GR_XPItem : public GR_Item
00084 {
00085 friend class GR_Graphics;
00086
00087 public:
00088 virtual ~GR_XPItem(){};
00089
00090 virtual GR_ScriptType getType() const {return m_eType;}
00091 virtual GR_Item * makeCopy() const {return new GR_XPItem(m_eType);}
00092 virtual GRRI_Type getClassId() const {return GRRI_XP;}
00093
00094 protected:
00095 GR_XPItem():
00096 m_eType(GRScriptType_Undefined){};
00097 GR_XPItem(GR_ScriptType t):
00098 m_eType(t){};
00099
00100 GR_ScriptType m_eType;
00101 };
00102
00103
00120 class ABI_EXPORT GR_Itemization
00121 {
00122 public:
00123 GR_Itemization():
00124 m_iEmbedingLevel(0),
00125 m_iDirOverride(0),
00126 m_bShowControlChars(false),
00127 m_pLang(NULL),
00128 m_pFont(NULL)
00129 {};
00130
00131 virtual ~GR_Itemization() {clear();}
00132
00133
00134
00135 UT_sint32 getItemCount() const {return m_vOffsets.getItemCount();}
00136 UT_sint32 getNthOffset(UT_sint32 i) const {return m_vOffsets.getNthItem(i);}
00137 GR_ScriptType getNthType(UT_sint32 i) const
00138 {return m_vItems.getNthItem(i)->getType();}
00139
00140 UT_uint32 getNthLength(UT_sint32 i)
00141 {
00142 UT_return_val_if_fail(i < m_vOffsets.getItemCount()-1, 0);
00143 return m_vOffsets.getNthItem(i+1) - m_vOffsets.getNthItem(i);
00144 }
00145
00146 GR_Item * getNthItem(UT_sint32 i) const {return m_vItems.getNthItem(i);}
00147
00148 void addItem(UT_sint32 offset, GR_Item *item)
00149 { m_vOffsets.addItem(offset); m_vItems.addItem(item);}
00150
00151 void insertItem(UT_sint32 indx, UT_sint32 offset, GR_Item *item)
00152 { m_vOffsets.insertItemAt(offset, indx); m_vItems.insertItemAt(item,indx);}
00153
00154 void clear();
00155
00156 void setEmbedingLevel(UT_uint32 l) {m_iEmbedingLevel = l;}
00157 UT_uint32 getEmbedingLevel() const {return m_iEmbedingLevel;}
00158
00159 void setDirOverride(UT_BidiCharType o) {m_iDirOverride = o;}
00160 UT_BidiCharType getDirOverride() const {return m_iDirOverride;}
00161
00162 void setShowControlChars(bool s) {m_bShowControlChars = s;}
00163 bool getShowControlChars() const {return m_bShowControlChars;}
00164
00165 void setLang(const char * l) {m_pLang = l;}
00166 const char * getLang()const {return m_pLang;}
00167
00168 void setFont(const GR_Font * pFont) {m_pFont = pFont;}
00169 const GR_Font * getFont()const {return m_pFont;}
00170
00171 private:
00172 UT_NumberVector m_vOffsets;
00173 UT_GenericVector<GR_Item*> m_vItems;
00174
00175 UT_uint32 m_iEmbedingLevel;
00176 UT_BidiCharType m_iDirOverride;
00177 bool m_bShowControlChars;
00178 const char * m_pLang;
00179 const GR_Font * m_pFont;
00180 };
00181
00207 class ABI_EXPORT GR_RenderInfo
00208 {
00209 public:
00210 GR_RenderInfo(GR_ScriptType type)
00211 : m_iOffset(0), m_iLength(0), m_eShapingResult(GRSR_Unknown),
00212 m_eState(GRSR_Unknown), m_eScriptType(type),
00213 m_pText(NULL), m_iVisDir(UT_BIDI_LTR),
00214 m_xoff(0), m_yoff(),
00215 m_pGraphics(NULL), m_pFont(NULL),
00216 m_iJustificationPoints(0),
00217 m_iJustificationAmount(0),
00218 m_bLastOnLine(false),
00219 m_pItem(NULL),
00220 m_bInvalidateFontCache(false){};
00221
00222
00223 virtual ~GR_RenderInfo(){};
00224
00225 virtual GRRI_Type getType() const = 0;
00226
00227 virtual bool append(GR_RenderInfo &ri, bool bReverse = false) = 0;
00228 virtual bool split (GR_RenderInfo *&pri, bool bReverse = false) = 0;
00229 virtual bool cut(UT_uint32 offset, UT_uint32 len, bool bReverse = false) = 0;
00230
00231 virtual bool canAppend(GR_RenderInfo &ri) const
00232 {return (m_eScriptType == ri.m_eScriptType);}
00233
00234 virtual bool isJustified() const = 0;
00235
00236
00237 UT_sint32 m_iOffset;
00238 UT_sint32 m_iLength;
00239 GRShapingResult m_eShapingResult;
00240 GRShapingResult m_eState;
00241 GR_ScriptType m_eScriptType;
00242 UT_TextIterator * m_pText;
00243 UT_BidiCharType m_iVisDir;
00244 UT_sint32 m_xoff;
00245 UT_sint32 m_yoff;
00246
00247 const GR_Graphics * m_pGraphics;
00248 const GR_Font * m_pFont;
00249
00250 UT_sint32 m_iJustificationPoints;
00251 UT_sint32 m_iJustificationAmount;
00252 bool m_bLastOnLine;
00253 const GR_Item * m_pItem;
00254 bool m_bInvalidateFontCache;
00255
00256 private:
00259 GR_RenderInfo() {};
00260 };
00261
00266 class ABI_EXPORT GR_XPRenderInfo : public GR_RenderInfo
00267 {
00268 public:
00269 GR_XPRenderInfo(GR_ScriptType type);
00270
00271 virtual ~GR_XPRenderInfo();
00272
00273 virtual GRRI_Type getType() const {return GRRI_XP;}
00274
00275 virtual bool append(GR_RenderInfo &ri, bool bReverse = false);
00276 virtual bool split (GR_RenderInfo *&pri, bool bReverse = false);
00277 virtual bool cut(UT_uint32 offset, UT_uint32 len, bool bReverse = false);
00278
00279 virtual bool isJustified() const {return (m_iJustificationPoints != 0);}
00280
00281 void prepareToRenderChars();
00282
00283
00284 UT_UCS4Char * m_pChars;
00285 UT_sint32 * m_pWidths;
00286 UT_sint32 m_iBufferSize;
00287 UT_sint32 * m_pSegmentOffset;
00288 UT_sint32 m_iSegmentCount;
00289 UT_sint32 m_iSpaceWidthBeforeJustification;
00290 UT_uint32 m_iTotalLength;
00291
00292
00293 static UT_sint32 s_iClassInstanceCount;
00294 static UT_UCS4Char * s_pCharBuff;
00295 static UT_sint32 * s_pWidthBuff;
00296 static UT_sint32 s_iBuffSize;
00297 static UT_sint32 * s_pAdvances;
00298 static GR_RenderInfo * s_pOwner;
00299 private:
00300 void _constructorCommonCode();
00301 inline void _stripLigaturePlaceHolders();
00302 inline void _calculateCharAdvances();
00303 inline bool _checkAndFixStaticBuffers();
00304
00305 };
00306
00307
00311 class ABI_EXPORT GR_ShapingInfo
00312 {
00313 public:
00314 enum TextTransform {
00315 NONE = 0,
00316 CAPITALIZE,
00317 UPPERCASE,
00318 LOWERCASE
00319 };
00320
00321 GR_ShapingInfo(UT_TextIterator & text, UT_uint32 iLen,
00322 const char * pLang,
00323 UT_BidiCharType iVisDir,
00324 GRShapingResult eShapingRequired,
00325 const GR_Font * pFont,
00326 const GR_Item * pItem,
00327 TextTransform textTransform = NONE,
00328 bool previousWasSpace = false)
00329 :m_Text(text), m_iLength(iLen), m_pLang(pLang), m_iVisDir(iVisDir),
00330 m_eShapingRequired(eShapingRequired),
00331 m_pFont(pFont),
00332 m_iJustifyBy(0),
00333 m_pItem(pItem),
00334 m_TextTransform(textTransform),
00335 m_previousWasSpace(previousWasSpace)
00336 {
00337 }
00338
00339 virtual ~GR_ShapingInfo() {};
00340
00341 UT_TextIterator & m_Text;
00342 UT_sint32 m_iLength;
00343 const char * m_pLang;
00344 UT_BidiCharType m_iVisDir;
00345 GRShapingResult m_eShapingRequired;
00346
00347 const GR_Font * m_pFont;
00348
00349 UT_uint32 m_iJustifyBy;
00350
00351 const GR_Item * m_pItem;
00352
00353 TextTransform m_TextTransform;
00354 bool m_previousWasSpace;
00355 };
00356
00357
00358 #endif