00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef FP_LINE_H
00022 #define FP_LINE_H
00023
00024 #ifdef FMT_TEST
00025 #include <stdio.h>
00026 #endif
00027
00028 #include "ut_misc.h"
00029 #include "ut_types.h"
00030 #include "ut_vector.h"
00031 #include "pt_Types.h"
00032 #include "fl_BlockLayout.h"
00033 #include "fp_Column.h"
00034 #include "fp_ContainerObject.h"
00035
00036
00037 class fp_Run;
00038 class GR_Graphics;
00039 class fp_Container;
00040 class fp_VerticalContainer;
00041
00042 struct dg_DrawArgs;
00043
00044
00045
00046
00047
00048
00049
00050 #define TEMP_LINE_BUFFER_SIZE 512
00051
00052
00053
00054
00055
00056
00057 #define RUNS_MAP_SIZE 100
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070 #define USE_STATIC_MAP
00071
00072 enum FL_WORKING_DIRECTION {WORK_FORWARD = 1,WORK_BACKWARD = -1,WORK_CENTER = 0};
00073 enum FL_WHICH_TABSTOP {USE_PREV_TABSTOP,USE_NEXT_TABSTOP,USE_FIXED_TABWIDTH};
00074
00075
00076
00077 class ABI_EXPORT fp_Line : public fp_Container
00078 {
00079 friend class fp_Run;
00080
00081
00082 public:
00083 fp_Line(fl_SectionLayout * pSectionLayout);
00084 ~fp_Line();
00085
00086 inline fl_BlockLayout* getBlock(void) const { return m_pBlock; }
00088 virtual inline UT_sint32 getHeight(void) const { return m_iHeight; }
00089 virtual inline UT_sint32 getX(void) const { return m_iX; }
00090 virtual inline UT_sint32 getY(void) const { return m_iY; }
00091
00092 inline UT_sint32 getMaxWidth(void) const { return m_iMaxWidth; }
00093
00094 inline UT_sint32 getAscent(void) const { return m_iAscent; }
00095 inline UT_sint32 getDescent(void) const { return m_iDescent; }
00096 UT_sint32 getNumRunsInLine(void) const {return m_vecRuns.getItemCount();}
00097 UT_sint32 getColumnGap(void);
00098 void setAssignedScreenHeight(UT_sint32);
00099 bool assertLineListIntegrity(void);
00100 void setMaxWidth(UT_sint32);
00101 virtual void setX(UT_sint32 i, bool bDontClearIfNeeded = false);
00102 virtual void setY(UT_sint32);
00103
00104 virtual void setContainer(fp_Container*);
00105 void setBlock(fl_BlockLayout * pBlock);
00106
00107 fp_Container * getColumn(void);
00108 fp_Page * getPage(void);
00109
00110 virtual void setWidth(UT_sint32 ){}
00111 virtual void setHeight(UT_sint32 i) {m_iHeight =i; }
00112 virtual UT_sint32 getWidth(void) const { return m_iWidth;}
00113 virtual UT_sint32 getDrawingWidth(void) const;
00114 UT_sint32 getWidthToRun(fp_Run * pLastRun);
00115 UT_sint32 getFilledWidth(void);
00116 virtual bool isVBreakable(void) { return false;}
00117 virtual bool isHBreakable(void) {return true;}
00118 virtual UT_sint32 wantVBreakAt(UT_sint32) { return 0;}
00119 virtual UT_sint32 wantHBreakAt(UT_sint32) { return 0;}
00120 virtual fp_ContainerObject * VBreakAt(UT_sint32) { return NULL;}
00121 virtual fp_ContainerObject * HBreakAt(UT_sint32) {return NULL;}
00122 virtual UT_uint32 distanceFromPoint(UT_sint32, UT_sint32) {return 0;}
00123 virtual fp_Container* getNextContainerInSection(void) const;
00124 virtual fp_Container* getPrevContainerInSection(void) const;
00125 fp_Run * getRunFromIndex( UT_uint32 runIndex);
00126 bool containsForcedColumnBreak(void) const;
00127 bool containsForcedPageBreak(void) const;
00128 bool containsFootnoteReference(void);
00129 bool getFootnoteContainers(UT_GenericVector<fp_FootnoteContainer *>* pvecFoots);
00130 bool containsAnnotations(void);
00131 bool getAnnotationContainers(UT_GenericVector<fp_AnnotationContainer *>* pvecAnnotations);
00132 void addRun(fp_Run*);
00133 void insertRunAfter(fp_Run* pRun1, fp_Run* pRun2);
00134 void insertRunBefore(fp_Run* pNewRun, fp_Run* pBefore);
00135 void insertRun(fp_Run*);
00136 bool removeRun(fp_Run*, bool bTellTheRunAboutIt=true);
00137
00138 inline bool isEmpty(void) const { return ((m_vecRuns.getItemCount()) == 0); }
00139 inline int countRuns(void) const { return m_vecRuns.getItemCount(); }
00140 inline fp_Run* getFirstRun(void) const { if(countRuns() > 0) return ((fp_Run*) m_vecRuns.getFirstItem()); else return NULL; }
00141 fp_Run* getLastRun(void) const ;
00142 fp_Run* getLastTextRun(void) const ;
00143
00144 fp_Run* calculateWidthOfRun(UT_sint32 &iX,
00145 UT_uint32 iIndxVisual,
00146 FL_WORKING_DIRECTION eWorkingDirection,
00147 FL_WHICH_TABSTOP eUseTabStop);
00148
00149 void getWorkingDirectionAndTabstops(FL_WORKING_DIRECTION &eWorkingDirection, FL_WHICH_TABSTOP &eUseTabStop) const;
00150
00151 inline bool isFirstLineInBlock(void) const;
00152 bool isLastLineInBlock(void) const;
00153
00154 virtual UT_Rect * getScreenRect();
00155 virtual void markDirtyOverlappingRuns(UT_Rect & recScreen);
00156
00157 void remove(void);
00158 UT_sint32 getMarginBefore(void) const;
00159 UT_sint32 getMarginAfter(void) const;
00160 virtual void mapXYToPosition(UT_sint32 xPos, UT_sint32 yPos, PT_DocPosition& pos, bool& bBOL, bool& bEOL, bool& isTOC);
00161 void getOffsets(fp_Run* pRun, UT_sint32& xoff, UT_sint32& yoff);
00162 void getScreenOffsets(fp_Run* pRun, UT_sint32& xoff, UT_sint32& yoff);
00163 virtual void clearScreen(void);
00164 void clearScreenFromRunToEnd(UT_uint32 runIndex);
00165 void clearScreenFromRunToEnd(fp_Run * pRun);
00166 bool containsOffset(PT_DocPosition blockOffset);
00167 void setScreenCleared(bool bisCleared)
00168 { m_bIsCleared = bisCleared;}
00169 bool isScreenCleared(void) const { return m_bIsCleared;}
00170 void setAdditionalMargin(UT_sint32 iAccum)
00171 { m_iAdditionalMarginAfter = iAccum;}
00172 virtual void draw(dg_DrawArgs*);
00173 virtual void draw(GR_Graphics*);
00174 void align(void);
00175 void layout(void);
00176 bool recalculateFields(UT_uint32 iUpdateCount);
00177 void recalcHeight(fp_Run * pLast = NULL);
00178 void recalcMaxWidth(bool bDontClearIfNeeded = false);
00179 void setReformat(void);
00180 void coalesceRuns(void);
00181
00182 UT_sint32 calculateWidthOfLine(void);
00183 UT_sint32 calculateWidthOfTrailingSpaces(void);
00184 void resetJustification(bool bPermanent);
00185 void justify(UT_sint32 iAmount);
00186 UT_uint32 countJustificationPoints(void);
00187
00188 bool isLastCharacter(UT_UCSChar Character) const;
00189
00190 bool findNextTabStop(UT_sint32 iStartX, UT_sint32& iPosition, eTabType& iType, eTabLeader& iLeader );
00191 bool findPrevTabStop(UT_sint32 iStartX, UT_sint32& iPosition, eTabType& iType, eTabLeader& iLeader );
00192 void setNeedsRedraw(void);
00193
00194 bool needsRedraw(void) { return m_bNeedsRedraw; }
00195 bool redrawUpdate(void);
00196 fp_Run * getLastVisRun();
00197 fp_Run * getFirstVisRun();
00198 UT_uint32 getVisIndx(fp_Run* pRun);
00199 fp_Run * getRunAtVisPos(UT_uint32 i);
00200 void setMapOfRunsDirty(){m_bMapDirty = true;};
00201 void addDirectionUsed(UT_BidiCharType dir, bool bRefreshMap = true);
00202 void removeDirectionUsed(UT_BidiCharType dir, bool bRefreshMap = true);
00203 void changeDirectionUsed(UT_BidiCharType oldDir, UT_BidiCharType newDir, bool bRefreshMap = true);
00204 UT_sint32 getBreakTick(void) const
00205 { return m_iBreakTick;}
00206 void setBreakTick(UT_sint32 iTick)
00207 { m_iBreakTick = iTick;}
00208 void setWrapped(bool bWrapped)
00209 { m_bIsWrapped = bWrapped;}
00210 bool isWrapped(void) const
00211 { return m_bIsWrapped;}
00212 void setSameYAsPrevious(bool bSameAsPrevious);
00213 bool isSameYAsPrevious(void) const
00214 { return m_bIsSameYAsPrevious;}
00215 void genOverlapRects(UT_Rect & recLeft, UT_Rect & recRight);
00216
00217 bool canContainPoint() const;
00218 #ifdef FMT_TEST
00219 void __dump(FILE * fp) const;
00220 #endif
00221
00222 protected:
00223 void _calculateWidthOfRun(UT_sint32 &iX,
00224 fp_Run * pRun,
00225 UT_uint32 iIndx,
00226 UT_uint32 iCountRuns,
00227 FL_WORKING_DIRECTION eWorkingDirection,
00228 FL_WHICH_TABSTOP eUseTabStop,
00229 UT_BidiCharType iDomDirection
00230 );
00231
00232 private:
00233 void _splitRunsAtSpaces(void);
00234 void _doClearScreenFromRunToEnd(UT_sint32 runIndex);
00235
00236
00237 void setAscent(UT_sint32 i) { m_iAscent = i; }
00238 void setDescent(UT_sint32 i) { m_iDescent = i; }
00239 void setScreenHeight(UT_sint32 i) {m_iScreenHeight =i;}
00240
00241
00242 fl_BlockLayout* m_pBlock;
00243 fp_Container* m_pContainer;
00244
00245 UT_sint32 m_iWidth;
00246 UT_sint32 m_iMaxWidth;
00247 UT_sint32 m_iClearToPos;
00248 UT_sint32 m_iClearLeftOffset;
00249 UT_sint32 m_iHeight;
00252 UT_sint32 m_iScreenHeight;
00253 UT_sint32 m_iAscent;
00254 UT_sint32 m_iDescent;
00255
00256 UT_sint32 m_iX;
00257 UT_sint32 m_iY;
00258 UT_GenericVector<fp_Run *> m_vecRuns;
00259
00260 bool m_bNeedsRedraw;
00261
00262 static UT_sint32 * s_pOldXs;
00263 static UT_uint32 s_iOldXsSize;
00264 static UT_uint32 s_iClassInstanceCounter;
00265
00266 UT_uint32 _getRunVisIndx(UT_uint32 indx);
00267 UT_uint32 _getRunLogIndx(UT_uint32 indx);
00268 UT_sint32 _createMapOfRuns();
00269 #ifdef USE_STATIC_MAP
00270 static UT_Byte * s_pEmbeddingLevels;
00271 static UT_uint32 * s_pMapOfRunsL2V;
00272 static UT_uint32 * s_pMapOfRunsV2L;
00273 static UT_UCS4Char * s_pPseudoString;
00274
00275
00276 static UT_uint32 s_iMapOfRunsSize;
00277 static fp_Line * s_pMapOwner;
00278 bool m_bMapDirty;
00279 #else
00280 UT_sint32 * m_pMapOfDirs;
00281 UT_sint32 * m_pMapOfRunsL2V;
00282 UT_sint32 * m_pMapOfRunsV2L;
00283
00284 UT_uint32 m_iMapOfRunsSize;
00285 #endif
00286 UT_uint32 m_iRunsRTLcount;
00287 UT_uint32 m_iRunsLTRcount;
00288 UT_sint32 m_iMaxDirLevel;
00289 bool m_bIsCleared;
00290 bool m_bContainsFootnoteRef;
00291 void _updateContainsFootnoteRef(void);
00292 UT_sint32 m_iBreakTick;
00293 bool m_bIsWrapped;
00294 bool m_bIsSameYAsPrevious;
00295 UT_sint32 m_iAdditionalMarginAfter;
00296 };
00297
00298 #endif
00299
00300