• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

fp_TextRun.h

Go to the documentation of this file.
00001 /* AbiWord
00002  * Copyright (C) 1998,1999 AbiSource, Inc.
00003  * Copyright (c) 2001,2002 Tomas Frydrych
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00018  * 02110-1301 USA.
00019  */
00020 
00021 
00022 #ifndef FP_TEXTRUN_H
00023 #define FP_TEXTRUN_H
00024 
00025 #include "fp_Run.h"
00026 
00027 #include "ut_types.h"
00028 #include "ut_misc.h"
00029 #include "pt_Types.h"
00030 #include "gr_RenderInfo.h"
00031 
00032 #ifdef ENABLE_SPELL
00033 #include "fl_Squiggles.h"
00034 #endif
00035 /*
00036     fp_TextRun represents a run of contiguous text sharing the same
00037     properties.
00038 */
00039 #define MAX_SPAN_LEN 250   //initial size for m_pSpanBuff, realocated if needed
00040 #include "ut_timer.h"
00041 
00042 class ABI_EXPORT fp_TextRun : public fp_Run
00043 {
00044 public:
00045     fp_TextRun(fl_BlockLayout* pBL, UT_uint32 iOffsetFirst, UT_uint32 iLen, bool bLookupProperties=true);
00046     virtual ~fp_TextRun();
00047 
00048     virtual void            mapXYToPosition(UT_sint32 xPos, UT_sint32 yPos, PT_DocPosition& pos, bool& bBOL, bool& bEOL, bool &isTOC);
00049     virtual void            findPointCoords(UT_uint32 iOffset, UT_sint32& x, UT_sint32& y, UT_sint32& x2, UT_sint32& y2, UT_sint32& height, bool& bDirection);
00050     virtual bool            canBreakAfter(void) const;
00051     virtual bool            canBreakBefore(void) const;
00052     virtual bool            alwaysFits(void) const;
00053     virtual bool            findMaxLeftFitSplitPoint(UT_sint32 iMaxLeftWidth, fp_RunSplitInfo& si, bool bForce=false);
00054     virtual UT_sint32       findTrailingSpaceDistance(void) const;
00055 #ifdef ENABLE_SPELL
00056     void                drawSquiggle(UT_uint32, UT_uint32,FL_SQUIGGLE_TYPE iSquiggle);
00057 #endif
00058     bool                split(UT_uint32 iSplitOffset,UT_sint32 iLenSkip=0);
00059 #if DEBUG
00060     virtual void            printText(void);
00061 #endif
00062     void                    appendTextToBuf(UT_GrowBuf & buf) const;
00063     virtual bool            hasLayoutProperties(void) const;
00064     //virtual void          fetchCharWidths(fl_CharWidths * pgbCharWidths);
00065     bool                    canMergeWithNext(void);
00066     void                    mergeWithNext(void);
00067     bool                    findFirstNonBlankSplitPoint(fp_RunSplitInfo & splitInfo);
00068     bool                    isOneItem(fp_Run * pNext);
00069     enum
00070     {
00071         Calculate_full_width = -1
00072     };
00073     UT_sint32               simpleRecalcWidth(UT_sint32 iLength = Calculate_full_width);
00074 
00075     void                    resetJustification(bool bPermanent);
00076     void                    justify(UT_sint32 iAmount, UT_uint32 iSpacesInRun);
00077     UT_sint32               countJustificationPoints(bool bLast) const;
00078 
00079     bool                    getCharacter(UT_uint32 run_offset, UT_UCSChar &Character) const;
00080     UT_sint32               findCharacter(UT_uint32 startPosition, UT_UCSChar Character) const;
00081     bool                    isFirstCharacter(UT_UCSChar Character) const;
00082     bool                    isLastCharacter(UT_UCSChar Character) const;
00083     virtual bool            doesContainNonBlankData(void) const;
00084     inline virtual bool isSuperscript(void) const;
00085     inline virtual bool isSubscript(void) const;
00086     const GR_Font*              getFont(void) const
00087         { return _getFont(); }
00088     const gchar *           getLanguage() const;
00089 
00090 
00091     UT_sint32               getStr(UT_UCSChar * str, UT_uint32 &iMax);
00092 
00093     // applies provided values of direction and override to the run
00094     void                    setDirection(UT_BidiCharType dir, UT_BidiCharType override);
00095 
00096     // the usability of the following function is *very* limited, see the note in cpp file
00097     void                    setDirOverride(UT_BidiCharType dir);
00098     virtual UT_BidiCharType getDirection() const;
00099 
00100     UT_BidiCharType         getDirOverride() const { return m_iDirOverride; }
00101 
00102     void                breakNeighborsAtDirBoundaries();
00103     void                breakMeAtDirBoundaries(UT_BidiCharType iNewOverride);
00104     void                setShapingRequired(GRShapingResult eR)
00105                              {m_pRenderInfo->m_eShapingResult = eR;}
00106     void                orShapingRequired(GRShapingResult eR)
00107                           {
00108                             m_pRenderInfo->m_eShapingResult =
00109                                 (GRShapingResult)((UT_uint32)m_pRenderInfo->m_eShapingResult
00110                                                   | (UT_uint32)eR);
00111                           }
00112 
00113     void                itemize(void);
00114     void                setItem(GR_Item * i);
00115     const GR_Item *           getItem() const {return m_pItem;}
00116 
00117 
00118     virtual void        updateOnDelete(UT_uint32 offset, UT_uint32 iLen);
00119 
00120     virtual UT_uint32   adjustCaretPosition(UT_uint32 iDocumentPosition, bool bForward);
00121     virtual void        adjustDeletePosition(UT_uint32 &pos1, UT_uint32 &count);
00122 
00123     static UT_uint32    s_iClassInstanceCount;
00124     UT_BidiCharType     m_iDirOverride;
00125     static bool         s_bBidiOS;
00126 
00127     void                measureCharWidths();
00128 
00129     GR_ShapingInfo::TextTransform getTextTransform() const { return m_TextTransform;}
00130     void setTextTransform(GR_ShapingInfo::TextTransform transform) { m_TextTransform = transform; }
00131 
00132 private:
00133     GR_ShapingInfo::TextTransform m_TextTransform;
00134 
00135     bool                _refreshDrawBuffer();
00136     bool                _addupCharWidths(void);
00137     virtual void        _lookupProperties(const PP_AttrProp * pSpanAP,
00138                                            const PP_AttrProp * pBlockAP,
00139                                            const PP_AttrProp * pSectionAP,
00140                                           GR_Graphics * pG);
00141 
00142 #ifdef FMT_TEST
00143 public:
00144     virtual void            __dump(FILE * fp) const;
00145 #endif
00146 
00147 protected:
00148     virtual bool            _recalcWidth(void);
00149     virtual bool            _canContainPoint(void) const;
00150     virtual void            _draw(dg_DrawArgs*);
00151     virtual void            _clearScreen(bool bFullLineHeightRect = true);
00152 
00153     void                    _drawInvisibleSpaces(UT_sint32, UT_sint32);
00154     void                    _drawInvisibles(UT_sint32, UT_sint32);
00155 #ifdef ENABLE_SPELL
00156     void                    _drawSquiggle(UT_sint32 top, UT_sint32 left, UT_sint32 right,FL_SQUIGGLE_TYPE iSquiggle);
00157 #endif
00158     void                    _getPartRect(UT_Rect* pRect,
00159                                          UT_sint32 xoff,
00160                                          UT_sint32 yoff,
00161                                          UT_uint32 iStart,
00162                                          UT_uint32 iLen);
00163 
00164     void                    _drawLastChar(bool bSelection);
00165 
00166     void                    _drawFirstChar(bool bSelection);
00167 
00168     void                    _fillRect(UT_RGBColor& clr,
00169                                       UT_sint32 xoff,
00170                                       UT_sint32 yoff,
00171                                       UT_uint32 iStart,
00172                                       UT_uint32 iLen,
00173                                       UT_Rect & rect,
00174                                       GR_Graphics * pG);
00175 
00176 private:
00177     enum
00178     {
00179         TEXT_POSITION_NORMAL,
00180         TEXT_POSITION_SUPERSCRIPT,
00181         TEXT_POSITION_SUBSCRIPT
00182     };
00183     UT_Byte             m_fPosition;
00184 
00185     /*
00186       This makes the assumption that all characters in a given run
00187       can be obtained from the same font.  This may not be true.
00188       For example, suppose that a run includes a mixture of latin
00189       and non-latin characters.  The resulting glyphs will probably need to be
00190       retrieved from multiple fonts.
00191       TODO fix this issue
00192     */
00193     bool                    m_bSpellSquiggled;
00194     bool                    m_bGrammarSquiggled;
00195 
00196     // !!! the m_pLanguage member cannot be set to an arbitrary string pointer
00197     // but only a pointer in the static table of the UT_Language class !!!
00198     const gchar *       m_pLanguage;
00199     bool                    m_bIsOverhanging;
00200 
00201     bool                    m_bKeepWidths;
00202 
00203     const GR_Item *               m_pItem;
00204     GR_RenderInfo   *       m_pRenderInfo;
00205 };
00206 
00207 #endif /* FP_TEXTRUN_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1