Go to the documentation of this file.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 fl_BlockLayout* getBlock(void) const { return m_pBlock; }
00088 virtual UT_sint32 getHeight(void) const;
00089
00090 virtual UT_sint32 getX(void) const;
00091 virtual UT_sint32 getY(void) const;
00092
00093 UT_sint32 getMaxWidth(void) const ;
00094 UT_sint32 getAscent(void) const;
00095 UT_sint32 getDescent(void) const;
00096 UT_sint32 getNumRunsInLine(void) const {return m_vecRuns.getItemCount();}
00097 UT_sint32 getColumnGap(void) const;
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) const;
00108 fp_Page * getPage(void) const;
00109
00110 virtual void setWidth(UT_sint32 ){}
00111 virtual void setHeight(UT_sint32 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) const;
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_Option<UT_Rect> getScreenRect() const;
00155 virtual void markDirtyOverlappingRuns(const 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(const fp_Run* pRun, UT_sint32& xoff, UT_sint32& yoff) const;
00162 void getScreenOffsets(const fp_Run* pRun, UT_sint32& xoff, UT_sint32& yoff) const;
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_sint32 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 setAlongTopBorder(bool bAlongTopBorder)
00216 { m_bIsAlongTopBorder = bAlongTopBorder;}
00217 void setAlongBotBorder(bool bAlongBotBorder)
00218 { m_bIsAlongBotBorder = bAlongBotBorder;}
00219 bool isAlongTopBorder(void) const
00220 { return m_bIsAlongTopBorder;}
00221 bool isAlongBotBorder(void) const
00222 { return m_bIsAlongBotBorder;}
00223 void genOverlapRects(UT_Rect & recLeft, UT_Rect & recRight);
00224
00225 bool canContainPoint() const;
00226 UT_sint32 calcLeftBorderThick(void);
00227 UT_sint32 calcRightBorderThick(void);
00228 UT_sint32 calcTopBorderThick(void);
00229 UT_sint32 calcBotBorderThick(void);
00230 void calcBorderThickness(void);
00231 UT_sint32 getLeftThick(void) const;
00232 UT_sint32 getRightThick(void) const;
00233 UT_sint32 getTopThick(void) const;
00234 UT_sint32 getBotThick(void) const;
00235 UT_sint32 getAvailableWidth(void) const;
00236 const fp_Line * getFirstInContainer(void) const;
00237 const fp_Line * getLastInContainer(void) const;
00238 bool canDrawTopBorder(void) const;
00239 bool canDrawBotBorder(void) const;
00240 void drawBorders(GR_Graphics * pG);
00241 UT_sint32 getLeftEdge(void) const;
00242 UT_sint32 getRightEdge(void) const;
00243 bool getAbsLeftRight(UT_sint32& left ,UT_sint32& right);
00244 bool hasBordersOrShading(void) const;
00245 #ifdef FMT_TEST
00246 void __dump(FILE * fp) const;
00247 #endif
00248
00249 protected:
00250 void _calculateWidthOfRun(UT_sint32 &iX,
00251 fp_Run * pRun,
00252 UT_uint32 iIndx,
00253 UT_uint32 iCountRuns,
00254 FL_WORKING_DIRECTION eWorkingDirection,
00255 FL_WHICH_TABSTOP eUseTabStop,
00256 UT_BidiCharType iDomDirection
00257 );
00258
00259 private:
00260 void _splitRunsAtSpaces(void);
00261 void _doClearScreenFromRunToEnd(UT_sint32 runIndex);
00262
00263
00264 void setAscent(UT_sint32 i) { m_iAscent = i; }
00265 void setDescent(UT_sint32 i) { m_iDescent = i; }
00266 void setScreenHeight(UT_sint32 i) {m_iScreenHeight =i;}
00267
00268
00269 fl_BlockLayout* m_pBlock;
00270 fp_Container* m_pContainer;
00271
00272 UT_sint32 m_iWidth;
00273 UT_sint32 m_iMaxWidth;
00274 UT_sint32 m_iClearToPos;
00275 UT_sint32 m_iClearLeftOffset;
00276 UT_sint32 m_iHeight;
00279 UT_sint32 m_iScreenHeight;
00280 UT_sint32 m_iAscent;
00281 UT_sint32 m_iDescent;
00282
00283 UT_sint32 m_iX;
00284 UT_sint32 m_iY;
00285 UT_GenericVector<fp_Run *> m_vecRuns;
00286
00287 bool m_bNeedsRedraw;
00288
00289 static UT_sint32 * s_pOldXs;
00290 static UT_uint32 s_iOldXsSize;
00291 static UT_uint32 s_iClassInstanceCounter;
00292
00293 UT_uint32 _getRunVisIndx(UT_sint32 indx);
00294 UT_uint32 _getRunLogIndx(UT_sint32 indx);
00295 UT_sint32 _createMapOfRuns();
00296 #ifdef USE_STATIC_MAP
00297 static UT_Byte * s_pEmbeddingLevels;
00298 static UT_uint32 * s_pMapOfRunsL2V;
00299 static UT_uint32 * s_pMapOfRunsV2L;
00300 static UT_UCS4Char * s_pPseudoString;
00301
00302
00303 static UT_sint32 s_iMapOfRunsSize;
00304 static fp_Line * s_pMapOwner;
00305 bool m_bMapDirty;
00306 #else
00307 UT_sint32 * m_pMapOfDirs;
00308 UT_sint32 * m_pMapOfRunsL2V;
00309 UT_sint32 * m_pMapOfRunsV2L;
00310
00311 UT_sint32 m_iMapOfRunsSize;
00312 #endif
00313 UT_uint32 m_iRunsRTLcount;
00314 UT_uint32 m_iRunsLTRcount;
00315 UT_sint32 m_iMaxDirLevel;
00316 bool m_bIsCleared;
00317 bool m_bContainsFootnoteRef;
00318 void _updateContainsFootnoteRef(void);
00319 UT_sint32 m_iBreakTick;
00320 bool m_bIsWrapped;
00321 bool m_bIsSameYAsPrevious;
00322 bool m_bIsAlongTopBorder;
00323 bool m_bIsAlongBotBorder;
00324 UT_sint32 m_iAdditionalMarginAfter;
00325 UT_sint32 m_iLeftThick;
00326 UT_sint32 m_iRightThick;
00327 UT_sint32 m_iTopThick;
00328 UT_sint32 m_iBotThick;
00329 };
00330
00331 #endif
00332
00333