1 # ifndef DOC_DRAW_H 2 # define DOC_DRAW_H 3 4 # include <docBuf.h> 5 # include <docStripFrame.h> 6 # include <docBlockOrnaments.h> 7 # include "docLayoutDocumentTree.h" 8 # include <docBlockFrame.h> 9 # include <utilIndexMapping.h> 10 # include <docLayoutPosition.h> 11 # include "docParticuleData.h" 12 # include "layoutContext.h" 13 # include "docSelectionGeometry.h" 14 15 struct DrawingContext; 16 17 /************************************************************************/ 18 19 typedef struct ParagraphDrawingStrip 20 { 21 int pdsLineFrom; 22 int pdsLineUpto; 23 24 int pdsAtParaTop; 25 int pdsAtParaBottom; 26 27 LayoutPosition pdsShadeTop; 28 LayoutPosition pdsShadeBelow; 29 } ParagraphDrawingStrip; 30 31 typedef struct DrawTextLine 32 { 33 void * dtlThrough; 34 struct DrawingContext * dtlDrawingContext; 35 36 LayoutPosition dtlShiftedTop; 37 DocumentRectangle dtlLineRectangle; 38 LayoutPosition dtlBaselinePosition; 39 LayoutPosition dtlShiftedBaselinePosition; 40 int dtlXShift; 41 int dtlYShift; 42 int dtlPartUpto; 43 const ParticuleData * dtlParticuleData; 44 const struct TextLine * dtlTextLine; 45 const struct BufferItem * dtlParaNode; 46 const ParagraphFrame * dtlParagraphFrame; 47 int dtlDrawParticulesSeparately; 48 } DrawTextLine; 49 50 /************************************************************************/ 51 /* */ 52 /* The different resources needed for drawing. */ 53 /* */ 54 /************************************************************************/ 55 56 typedef int (*DRAW_TEXT_LINE)( struct BufferItem * paraBi, 57 int line, 58 const struct ParagraphFrame * pf, 59 const DocumentRectangle * drLinePixels, 60 void * through, 61 struct DrawingContext * dc, 62 const BlockOrigin * bo ); 63 64 typedef int (*DRAW_ORNAMENTS)( const BlockOrnaments * ornaments, 65 int page, 66 const DocumentRectangle * drOutside, 67 const DocumentRectangle * drInside, 68 void * through, 69 struct DrawingContext * dc ); 70 71 typedef int (*FINISH_PAGE)( void * through, 72 struct DrawingContext * dc, 73 struct BufferItem * bodySectNode, 74 int page, 75 int asLast ); 76 77 typedef int (*START_PAGE)( void * through, 78 const DocumentGeometry * dg, 79 struct DrawingContext * dc, 80 int page ); 81 82 typedef int (*SET_COLOR_RGB)( struct DrawingContext * dc, 83 void * through, 84 const RGB8Color * rgb8 ); 85 86 typedef int (*SET_FONT)( struct DrawingContext * dc, 87 void * through, 88 int textAttrNr, 89 const TextAttribute * ta ); 90 91 typedef int (*DRAW_SHAPE)( const DocumentRectangle * drTwips, 92 int page, 93 struct DrawingShape * ds, 94 struct DrawingContext * dc, 95 void * through ); 96 97 typedef int (*DRAW_OBJECT)( const DrawTextLine * dtl, 98 int part, 99 InsertedObject * io, 100 int x0Twips, 101 int x1Twips, 102 const LayoutPosition * baseLine ); 103 104 typedef int (*DRAW_TAB)( const DrawTextLine * dtl, 105 int part, 106 int textAttrNr, 107 const TextAttribute * ta, 108 int leader, 109 int x0Twips, 110 int x1Twips, 111 const LayoutPosition * baseLine ); 112 113 typedef int (*DRAW_FTNSEP)( const DrawTextLine * dtl, 114 int part, 115 int textAttrNr, 116 const TextAttribute * ta, 117 int x0Twips, 118 int x1Twips, 119 const LayoutPosition * baseLine ); 120 121 typedef int (*DRAW_UNDERLINE)( const DrawTextLine * dtl, 122 int part, 123 int upto, 124 int textAttrNr, 125 const TextAttribute * ta, 126 int x0Twips, 127 int x1Twips, 128 const LayoutPosition * baseLine ); 129 130 typedef int (*DRAW_STRIKETHROUGH)( 131 const DrawTextLine * dtl, 132 int part, 133 int upto, 134 int textAttrNr, 135 const TextAttribute * ta, 136 int x0Twips, 137 int x1Twips, 138 const LayoutPosition * baseLine ); 139 140 typedef int (*START_FIELD)( const DrawTextLine * dtl, 141 int part, 142 const DocumentField * df ); 143 144 typedef int (*FINISH_FIELD)( const DrawTextLine * dtl, 145 int part, 146 const DocumentField * df ); 147 148 typedef int (*DRAW_SPAN)( const DrawTextLine * dtl, 149 int part, 150 int count, 151 const LayoutPosition * baseLine, 152 int textAttrNr, 153 const TextAttribute * ta, 154 const char * printString, 155 int nbLen ); 156 157 typedef struct DrawingContext 158 { 159 int dcCurrentTextAttributeSet; 160 TextAttribute dcCurrentTextAttribute; 161 int dcCurrentColorSet; 162 RGB8Color dcCurrentColor; 163 164 LayoutContext dcLayoutContext; 165 const DocumentRectangle * dcClipRect; 166 const DocumentSelection * dcSelection; 167 const SelectionGeometry * dcSelectionGeometry; 168 int dcFirstPage; 169 int dcLastPage; 170 int dcDrawExternalItems; 171 int dcPostponeHeadersFooters; 172 int dcDocHasPageHeaders; 173 int dcDocHasPageFooters; 174 175 int dcDrawTableGrid; 176 177 SET_COLOR_RGB dcSetColorRgb; 178 SET_FONT dcSetFont; 179 DRAW_SHAPE dcDrawShape; 180 DRAW_OBJECT dcDrawObject; 181 START_FIELD dcStartField; 182 FINISH_FIELD dcFinishField; 183 DRAW_TAB dcDrawTab; 184 DRAW_FTNSEP dcDrawFtnsep; 185 DRAW_UNDERLINE dcDrawUnderline; 186 DRAW_STRIKETHROUGH dcDrawStrikethrough; 187 DRAW_SPAN dcDrawSpan; 188 189 DRAW_TEXT_LINE dcDrawTextLine; /* foreground */ 190 DRAW_ORNAMENTS dcDrawOrnaments; /* background */ 191 192 FINISH_PAGE dcFinishPage; 193 START_PAGE dcStartPage; 194 INIT_LAYOUT_EXTERNAL dcInitLayoutExternal; 195 } DrawingContext; 196 197 /************************************************************************/ 198 /* */ 199 /* Routine declarations. */ 200 /* */ 201 /************************************************************************/ 202 203 extern void docInitDrawTextLine( DrawTextLine * dtl ); 204 extern void docInitDrawingContext( DrawingContext * dc ); 205 206 extern int docDrawNode( LayoutPosition * lpBelow, 207 struct BufferItem * node, 208 void * through, 209 DrawingContext * dc ); 210 211 extern int docDrawPageRange( DrawingContext * dc, 212 void * through ); 213 214 extern int docDrawPageHeader( struct BufferItem * sectNode, 215 void * through, 216 DrawingContext * dc, 217 int page ); 218 219 extern int docDrawPageFooter( struct BufferItem * sectNode, 220 void * through, 221 DrawingContext * dc, 222 int page ); 223 224 extern int docDrawShapesForPage( void * through, 225 DrawingContext * dc, 226 int belowText, 227 int page ); 228 229 extern int docDrawFootnotesForColumn( 230 int page, 231 int column, 232 void * through, 233 DrawingContext * dc ); 234 235 extern int docDrawEndnotesForSection( LayoutPosition * lpBelow, 236 int sect, 237 void * through, 238 DrawingContext * dc ); 239 240 extern int docDrawEndnotesForDocument( LayoutPosition * lpBelow, 241 void * through, 242 DrawingContext * dc ); 243 244 extern int docDrawToColumnOfNode( struct BufferItem * prevBodyBi, 245 struct BufferItem * thisBodyBi, 246 struct BufferItem * thisBi, 247 void * through, 248 LayoutPosition * lpHere, 249 DrawingContext * dc, 250 const BlockOrigin * bo ); 251 252 extern void docDrawSetColorRgb( DrawingContext * dc, 253 void * through, 254 const RGB8Color * rgb8 ); 255 256 extern void docDrawSetColorNumber( DrawingContext * dc, 257 void * through, 258 int colorNumber ); 259 260 extern void docDrawSetFont( DrawingContext * dc, 261 void * through, 262 int textAttrNr, 263 const TextAttribute * ta ); 264 265 extern int docDrawShapeGetFill( int * pFill, 266 RGB8Color * rgb8Fill, 267 const struct DrawingShape * ds, 268 DrawingContext * dc, 269 void * through ); 270 271 extern int docDrawShapeGetLine( int * pLine, 272 RGB8Color * rgb8Stroke, 273 const struct DrawingShape * ds, 274 DrawingContext * dc, 275 void * through ); 276 277 extern int docDrawShape( DrawingContext * dc, 278 void * through, 279 const struct BufferItem * bodySectNode, 280 const InsertedObject * io ); 281 282 extern int docDrawRowNode( struct BufferItem * rowBi, 283 void * through, 284 DrawingContext * dc, 285 const BlockOrigin * bo ); 286 287 extern int docDrawTableHeader( int * pHigh, 288 const struct BufferItem * rowBi, 289 const BlockFrame * bfRef, 290 void * through, 291 DrawingContext * dc, 292 const LayoutPosition * lpHeader ); 293 294 extern int docDrawParagraphStrip( void * through, 295 ParagraphDrawingStrip * pds, 296 struct BufferItem * paraBi, 297 int countAfter, 298 const LayoutPosition * lpShadeTop, 299 int lineFrom, 300 const ParagraphFrame * pf, 301 DrawingContext * dc, 302 const LayoutPosition * lpThisFrame, 303 const BlockOrigin * bo ); 304 305 extern int docDrawTextLines( void * through, 306 const ParagraphDrawingStrip * pds, 307 struct BufferItem * paraBi, 308 const ParagraphFrame * pf, 309 DrawingContext * dc, 310 const BlockOrigin * bo ); 311 312 extern int docDrawToNextColumn( struct BufferItem * thisBodyBi, 313 struct BufferItem * nextBodyBi, 314 void * through, 315 LayoutPosition * lpHere, 316 BlockFrame * bf, 317 DrawingContext * dc ); 318 319 extern int docDrawParaNode( LayoutPosition * lpBelow, 320 struct BufferItem * paraBi, 321 void * through, 322 DrawingContext * dc, 323 const BlockOrigin * bo ); 324 325 extern void docSetDrawTextLine( DrawTextLine * dtl, 326 void * through, 327 DrawingContext * dc, 328 const struct TextLine * tl, 329 const struct BufferItem * paraBi, 330 const BlockOrigin * bo, 331 const ParagraphFrame * pf, 332 const DocumentRectangle * drLine ); 333 334 extern int docDrawLineParticules( 335 const DrawTextLine * dtl, 336 int * pXTwips, 337 int part ); 338 339 extern int docDrawShapeText( const DocumentRectangle * drHere, 340 const struct BufferItem * bodySectNode, 341 int page, 342 int column, 343 struct DrawingShape * ds, 344 DrawingContext * dc, 345 void * through ); 346 347 # endif 348