%% options copyright owner = Dirk Krause copyright year = 2017-xxxx SPDX-License-Identifier: BSD-3-Clause %% header /** @file dk4pppt.h PGF/PDF+TeX/(E)PS+TeX output. */ #ifndef DK4CONF_H_INCLUDED #if DK4_BUILDING_DKTOOLS4 #include "dk4conf.h" #else #include #endif #endif #ifndef DK4FONT_H_INCLUDED #if DK4_BUILDING_DKTOOLS4 #include "dk4font.h" #else #include #endif #endif #ifndef DK4ALIGN_H_INCLUDED #if DK4_BUILDING_DKTOOLS4 #include "dk4align.h" #else #include #endif #endif #ifndef DK4ERROR_H_INCLUDED #if DK4_BUILDING_DKTOOLS4 #include "dk4error.h" #else #include #endif #endif #ifndef DK4MEMBF_H_INCLUDED #if DK4_BUILDING_DKTOOLS4 #include "dk4membuf.h" #else #include #endif #endif #ifndef DK4MBSTRM_H_INCLUDED #if DK4_BUILDING_DKTOOLS4 #include "dk4mbstrm.h" #else #include #endif #endif #ifndef DK4GRA_H_INCLUDED #if DK4_BUILDING_DKTOOLS4 #include "dk4gra.h" #else #include #endif #endif #ifndef DK4ENC_H_INCLUDED #if DK4_BUILDING_DKTOOLS4 #include "dk4enc.h" #else #include #endif #endif #ifndef DK4REC25_H_INCLUDED #if DK4_BUILDING_DKTOOLS4 #include "dk4rec25.h" #else #include #endif #endif /** Output drivers. */ typedef enum { DK4_PPPT_DR_PDF_TEX = 0, /**< Produce PDF+TeX file pair. */ DK4_PPPT_DR_EPS_TEX , /**< Produce EPS+TeX file pair. */ DK4_PPPT_DR_PGF /**< Produce PGF file. */ } dk4_pppt_driver_t; /** Output structure for combined PDF+TeX/EPS+TeX output. */ typedef struct { dkChar *tfn; /**< TeX file name. */ dk4_gra_t *gra; /**< Graphics structure. */ dk4_font_collector_t *fc; /**< Font collector. */ dk4_membuf_t *tmb; /**< TeX memory buffer. */ dk4_stream_t *tms; /**< TeX memory stream. */ dk4_sto_t *s_f; /**< Storage for font setup lines. */ dk4_sto_it_t *i_f; /**< Iterator for font setup lines. */ dk4_sto_t *s_p; /**< Storage for package setup lines. */ dk4_sto_it_t *i_p; /**< Iterator for package setup lines. */ dk4_sto_t *s_o; /**< Storage for other preamble lines. */ dk4_sto_it_t *i_o; /**< Iterator for other preamble lines. */ double dfs; /**< Document font size. */ size_t n_f; /**< Number of font setup lines. */ size_t n_p; /**< Number of package setup lines. */ size_t n_o; /**< Number of other setup lines. */ } dk4_pppt_pdf_ps_t; /** Details structure. */ typedef union { dk4_gra_t *pgf; /**< PGF output structure. */ dk4_pppt_pdf_ps_t ppt; /**< Output structure PDF+TeX/EPS+TeX. */ } dk4_pppt_out_t; /** Output structure. */ typedef struct { dk4_pppt_out_t out; /**< Output union. */ dk4_pppt_driver_t dr; /**< Driver, dk4_pppt_driver_t value. */ int isdoc; /**< Flag: Produce entire document. */ int flags; /**< Document and page flags. */ } dk4_pppt_t; #ifdef __cplusplus extern "C" { #endif /** Open an output structure. @param texname Name of TeX output file. The name ends on ".tex". The name of the included *.eps or *.pdf file is derived from this name. @param dr Output driver. @param isdoc Flag: Produce LaTeX document, not just image. @param flags Additional flags for graphics. @param width Image width in bp (PS point). @param height Image height in bp. @param erp Error report, may be NULL. @return Valid pointer to new output structure on success, NULL on error. */ dk4_pppt_t * dk4pppt_open( const dkChar *texname, dk4_pppt_driver_t dr, int isdoc, int flags, size_t width, size_t height, dk4_er_t *erp ); /** Write output file(s) and close output structure. @param pppt Output structure to write and close. @param erp Error report, may be NULL. @return 1 on success, 0 on error. */ int dk4pppt_write_and_close( dk4_pppt_t *pppt, dk4_er_t *erp ); /** Close output structure without writing. This function can be used after errors to close the structure without any attempt to overwrite existing files. @param pppt Output structure to close. */ void dk4pppt_close( dk4_pppt_t *pppt ); /** Set flag for simplified gsave/grestore handling. Set this flag, if you use gsave and grestore only to save and restore the clip path for pattern filling. @param pppt Output structure. @param val Flag: Simplified gsave and grestore handling. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL. */ void dk4pppt_set_gs_for_pattern_only( dk4_pppt_t *pppt, int val, dk4_er_t *erp ); /** Save current graphics state (especially clip path). @param pppt Output structure. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation, - DK4_E_MATH_OVERFLOW
on numeric overflow in memory size calculation, - DK4_E_MEMORY_ALLOCATION_FAILED
if there is not enough memory available, - DK4_E_WRITE_FAILED
if writing one ore multiple bytes to the stream failed, - DK4_E_FLUSH_FAILED
if flushing data downwards failed. */ void dk4pppt_gsave( dk4_pppt_t *pppt, int *backptr, dk4_er_t *erp ); /** Restore graphics state (especially clip path). @param pppt Output structure. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation, - DK4_E_MATH_OVERFLOW
on numeric overflow in memory size calculation, - DK4_E_MEMORY_ALLOCATION_FAILED
if there is not enough memory available, - DK4_E_WRITE_FAILED
if writing one ore multiple bytes to the stream failed, - DK4_E_FLUSH_FAILED
if flushing data downwards failed. */ void dk4pppt_grestore( dk4_pppt_t *pppt, int *backptr, dk4_er_t *erp ); /** Set line width. @param pppt Output structure. @param lw Line width in bp. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation. */ void dk4pppt_set_line_width( dk4_pppt_t *pppt, double lw, int *backptr, dk4_er_t *erp ); /** Set line style. @param pppt Output structure. @param ls Line style. @param sv Style value (dash length in bp). @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation. */ void dk4pppt_set_line_style( dk4_pppt_t *pppt, dk4_gra_ls_t ls, double sv, int *backptr, dk4_er_t *erp ); /** Set line cap. @param pppt Output structure. @param lc Line cap type. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation. */ void dk4pppt_set_line_cap( dk4_pppt_t *pppt, dk4_gra_lc_t lc, int *backptr, dk4_er_t *erp ); /** Set line join. @param pppt Output structure. @param lj Line join type. @param ml Miter limit, only used if lj is DK4_GRA_LJ_MITERED. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation. */ void dk4pppt_set_line_join( dk4_pppt_t *pppt, dk4_gra_lj_t lj, double ml, int *backptr, dk4_er_t *erp ); /** Set fill color to gray. @param pppt Output structure. @param g Gray value in interval 0 to 1. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation. */ void dk4pppt_set_fill_gray( dk4_pppt_t *pppt, double g, int *backptr, dk4_er_t *erp ); /** Set fill color to RGB. @param pppt Output structure. @param r Red value in interval 0 to 1. @param g Green value in interval 0 to 1. @param b Blue value in interval 0 to 1. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation. */ void dk4pppt_set_fill_rgb( dk4_pppt_t *pppt, double r, double g, double b, int *backptr, dk4_er_t *erp ); /** Set fill color to CMYK. @param pppt Output structure. @param c Cyan value in interval 0 to 1. @param m Magenta value in interval 0 to 1. @param y Yellow value in interval 0 to 1. @param k Black value in interval 0 to 1. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation. */ void dk4pppt_set_fill_cmyk( dk4_pppt_t *pppt, double c, double m, double y, double k, int *backptr, dk4_er_t *erp ); /** Set stroke color to gray. @param pppt Output structure. @param g Gray value in interval 0 to 1. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation. */ void dk4pppt_set_stroke_gray( dk4_pppt_t *pppt, double g, int *backptr, dk4_er_t *erp ); /** Set stroke color to RGB. @param pppt Output structure. @param r Red value in interval 0 to 1. @param g Green value in interval 0 to 1. @param b Blue value in interval 0 to 1. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation. */ void dk4pppt_set_stroke_rgb( dk4_pppt_t *pppt, double r, double g, double b, int *backptr, dk4_er_t *erp ); /** Set stroke color to CMYK. @param pppt Output structure. @param c Cyan value in interval 0 to 1. @param m Magenta value in interval 0 to 1. @param y Yellow value in interval 0 to 1. @param k Black value in interval 0 to 1. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation. */ void dk4pppt_set_stroke_cmyk( dk4_pppt_t *pppt, double c, double m, double y, double k, int *backptr, dk4_er_t *erp ); /** Prepare output structure for a fill operation. Use this function before you start to construct a path you plan to fill. @param pppt Output structure. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation, - DK4_E_MATH_OVERFLOW
on numeric overflow in memory size calculation, - DK4_E_MEMORY_ALLOCATION_FAILED
if there is not enough memory available, - DK4_E_WRITE_FAILED
if writing one ore multiple bytes to the stream failed, - DK4_E_FLUSH_FAILED
if flushing data downwards failed. */ void dk4pppt_prepare_fill( dk4_pppt_t *pppt, int *backptr, dk4_er_t *erp ); /** Prepare output structure for a stroke operation. Use this function before you start to construct a path you plan to stroke. @param pppt Output structure. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation, - DK4_E_MATH_OVERFLOW
on numeric overflow in memory size calculation, - DK4_E_MEMORY_ALLOCATION_FAILED
if there is not enough memory available, - DK4_E_WRITE_FAILED
if writing one ore multiple bytes to the stream failed, - DK4_E_FLUSH_FAILED
if flushing data downwards failed. */ void dk4pppt_prepare_stroke( dk4_pppt_t *pppt, int *backptr, dk4_er_t *erp ); /** Prepare output structure for a combined fill and stroke operation. Use this function before you start to construct a path you plan to fill and stroke. @param pppt Output structure. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation, - DK4_E_MATH_OVERFLOW
on numeric overflow in memory size calculation, - DK4_E_MEMORY_ALLOCATION_FAILED
if there is not enough memory available, - DK4_E_WRITE_FAILED
if writing one ore multiple bytes to the stream failed, - DK4_E_FLUSH_FAILED
if flushing data downwards failed. */ void dk4pppt_prepare_fill_and_stroke( dk4_pppt_t *pppt, int *backptr, dk4_er_t *erp ); /** Check whether a combined fill and close operation is available for an output structure. @param pppt Output structure to test. @return 1 if a fill-and-close operation is available, 0 otherwise. */ int dk4pppt_can_fill_and_stroke( const dk4_pppt_t *pppt ); /** Fill current path. Note: Use dk4gra_prepare_fill() before you start to construct a path you plan to fill. @param pppt Output structure. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation, - DK4_E_MATH_OVERFLOW
on numeric overflow in memory size calculation, - DK4_E_MEMORY_ALLOCATION_FAILED
if there is not enough memory available, - DK4_E_WRITE_FAILED
if writing one ore multiple bytes to the stream failed, - DK4_E_FLUSH_FAILED
if flushing data downwards failed. */ void dk4pppt_fill( dk4_pppt_t *pppt, int *backptr, dk4_er_t *erp ); /** Stroke current path. Note: Use dk4gra_prepare_stroke() before you start to construct a path you plan to stroke. @param pppt Output structure. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation, - DK4_E_MATH_OVERFLOW
on numeric overflow in memory size calculation, - DK4_E_MEMORY_ALLOCATION_FAILED
if there is not enough memory available, - DK4_E_WRITE_FAILED
if writing one ore multiple bytes to the stream failed, - DK4_E_FLUSH_FAILED
if flushing data downwards failed. */ void dk4pppt_stroke( dk4_pppt_t *pppt, int *backptr, dk4_er_t *erp ); /** Fill and stroke current path. Note: Use dk4gra_prepare_fill_and_stroke() before you start to construct a path you plan to fill and stroke. @param pppt Output structure. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation, - DK4_E_MATH_OVERFLOW
on numeric overflow in memory size calculation, - DK4_E_MEMORY_ALLOCATION_FAILED
if there is not enough memory available, - DK4_E_WRITE_FAILED
if writing one ore multiple bytes to the stream failed, - DK4_E_FLUSH_FAILED
if flushing data downwards failed. */ void dk4pppt_fill_and_stroke( dk4_pppt_t *pppt, int *backptr, dk4_er_t *erp ); /** Use current path for clipping. @param pppt Output structure. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation, - DK4_E_MATH_OVERFLOW
on numeric overflow in memory size calculation, - DK4_E_MEMORY_ALLOCATION_FAILED
if there is not enough memory available, - DK4_E_WRITE_FAILED
if writing one ore multiple bytes to the stream failed, - DK4_E_FLUSH_FAILED
if flushing data downwards failed. */ void dk4pppt_clip( dk4_pppt_t *pppt, int *backptr, dk4_er_t *erp ); /** Set line width to draw fill patterns. The pattern line width should be in range 0 to 2bp, default is 0.9bp. @param pppt Output structure. @param plw New pattern line width in bp. */ void dk4pppt_set_pattern_line_width( dk4_pppt_t *pppt, double plw ); /** Pattern a region (clipping should be set to the path). @param pppt Output structure. @param xl Left y coordinate. @param xr Right x coordinate. @param yb Bottom y coordinate. @param yt Top y coordinate. @param pn Pattern number. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation, - DK4_E_MATH_OVERFLOW
on numeric overflow in memory size calculation, - DK4_E_MEMORY_ALLOCATION_FAILED
if there is not enough memory available, - DK4_E_WRITE_FAILED
if writing one ore multiple bytes to the stream failed, - DK4_E_FLUSH_FAILED
if flushing data downwards failed. */ void dk4pppt_pattern( dk4_pppt_t *pppt, double xl, double xr, double yb, double yt, dk4_gra_pattern_t pn, int *backptr, dk4_er_t *erp ); /** Start a new path and move to first point. @param pppt Output structure. @param x X coordinate of start point. @param y Y coordinate of start point. @param bbptr Bounding box, may be NULL. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation, - DK4_E_MATH_OVERFLOW
on numeric overflow in memory size calculation, - DK4_E_MEMORY_ALLOCATION_FAILED
if there is not enough memory available, - DK4_E_WRITE_FAILED
if writing one ore multiple bytes to the stream failed, - DK4_E_FLUSH_FAILED
if flushing data downwards failed. */ void dk4pppt_newpath_moveto( dk4_pppt_t *pppt, double x, double y, dk4_bb_t *bbptr, int *backptr, dk4_er_t *erp ); /** Add line from current point to new point to path. @param pppt Output structure. @param x X coordinate of new point. @param y Y coordinate of new point. @param bbptr Bounding box, may be NULL. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation, - DK4_E_MATH_OVERFLOW
on numeric overflow in memory size calculation, - DK4_E_MEMORY_ALLOCATION_FAILED
if there is not enough memory available, - DK4_E_WRITE_FAILED
if writing one ore multiple bytes to the stream failed, - DK4_E_FLUSH_FAILED
if flushing data downwards failed. */ void dk4pppt_lineto( dk4_pppt_t *pppt, double x, double y, dk4_bb_t *bbptr, int *backptr, dk4_er_t *erp ); /** Add Bezier curve segment from current point to new point in path. @param pppt Output structure. @param xc1 X coordinate of first control point. @param yc1 Y coordinate of first control point. @param xc2 X coordinate of second control point. @param yc2 Y coordinate of second control point. @param x X coordinate of new point. @param y Y coordinate of new point. @param bbptr Bounding box, may be NULL. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation, - DK4_E_MATH_OVERFLOW
on numeric overflow in memory size calculation, - DK4_E_MEMORY_ALLOCATION_FAILED
if there is not enough memory available, - DK4_E_WRITE_FAILED
if writing one ore multiple bytes to the stream failed, - DK4_E_FLUSH_FAILED
if flushing data downwards failed. */ void dk4pppt_curveto( dk4_pppt_t *pppt, double xc1, double yc1, double xc2, double yc2, double x, double y, dk4_bb_t *bbptr, int *backptr, dk4_er_t *erp ); /** Close current path. @param pppt Output structure. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation, - DK4_E_MATH_OVERFLOW
on numeric overflow in memory size calculation, - DK4_E_MEMORY_ALLOCATION_FAILED
if there is not enough memory available, - DK4_E_WRITE_FAILED
if writing one ore multiple bytes to the stream failed, - DK4_E_FLUSH_FAILED
if flushing data downwards failed. */ void dk4pppt_closepath( dk4_pppt_t *pppt, int *backptr, dk4_er_t *erp ); /** Add bitmap image XFig style. @param pppt Output structure. @param xl Left x coordinate. @param xr Right x coordinate. @param yb Bottom y coordinate. @param yt Top y coordinate. @param bif Bitmap image file. @param fn Image file name. @param fno Frame number (0 for first frame). @param pos Image positioning: - 0 not rotated, not flipped, - 1 rotated 90 degree counterclockwise, not flipped, - 2 rotated 180 degree counterclockwise, not flipped, - 3 rotated 270 degree counterclockwise, not flipped, - 4 not rotated, flipped, - 5 rotated 90 degree counterclockwise, flipped, - 6 rotated 180 degree counterclockwise, flipped, - 7 rotated 270 degree counterclockwise, flipped. @param ifl Image flags. @param bbptr Bounding box, may be NULL. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL or bif is NULL or a frame number other than 0 was specified for PGF output, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation, - DK4_E_MATH_OVERFLOW
on numeric overflow in memory size calculation, - DK4_E_MEMORY_ALLOCATION_FAILED
if there is not enough memory available, - DK4_E_WRITE_FAILED
if writing one ore multiple bytes to the stream failed, - DK4_E_FLUSH_FAILED
if flushing data downwards failed. */ void dk4pppt_bif_fig_image( dk4_pppt_t *pppt, double xl, double xr, double yb, double yt, dk4_bif_t *bif, const dkChar *fn, size_t fno, int pos, int ifl, dk4_bb_t *bbptr, int *backptr, dk4_er_t *erp ); /** Add bitmap image. @param pppt Output structure. @param xl Left x coordinate. @param xr Right x coordinate. @param yb Bottom y coordinate. @param yt Top y coordinate. @param bif Bitmap image file data. @param fn Image file name. @param fno Frame number (0 for first frame). @param ifl Image flags. @param bbptr Bounding box, may be NULL. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL or bif is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation, - DK4_E_MATH_OVERFLOW
on numeric overflow in memory size calculation, - DK4_E_MEMORY_ALLOCATION_FAILED
if there is not enough memory available, - DK4_E_WRITE_FAILED
if writing one ore multiple bytes to the stream failed, - DK4_E_FLUSH_FAILED
if flushing data downwards failed. */ void dk4pppt_bif_image( dk4_pppt_t *pppt, double xl, double xr, double yb, double yt, dk4_bif_t *bif, const dkChar *fn, size_t fno, int ifl, dk4_bb_t *bbptr, int *backptr, dk4_er_t *erp ); /** Add bitmap image. @param pppt Output structure. @param xl Left x coordinate. @param xr Right x coordinate. @param yb Bottom y coordinate. @param yt Top y coordinate. @param fn Image file name. @param fno Frame number (0 for first frame). @param ctx Bitmap image conversion context, may be NULL. @param ifl Image flags. @param bbptr Bounding box, may be NULL. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL or bif is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation, - DK4_E_MATH_OVERFLOW
on numeric overflow in memory size calculation, - DK4_E_MEMORY_ALLOCATION_FAILED
if there is not enough memory available, - DK4_E_WRITE_FAILED
if writing one ore multiple bytes to the stream failed, - DK4_E_FLUSH_FAILED
if flushing data downwards failed. */ void dk4pppt_image( dk4_pppt_t *pppt, double xl, double xr, double yb, double yt, const dkChar *fn, size_t fno, dk4_cs_conv_ctx_t *ctx, int ifl, dk4_bb_t *bbptr, int *backptr, dk4_er_t *erp ); /** Add bitmap image XFig style. @param pppt Output structure. @param xl Left x coordinate. @param xr Right x coordinate. @param yb Bottom y coordinate. @param yt Top y coordinate. @param fn Image file name. @param fno Frame number (0 for first frame). @param ctx Bitmap image conversion context, may be NULL. @param pos Image positioning: - 0 not rotated, not flipped, - 1 rotated 90 degree counterclockwise, not flipped, - 2 rotated 180 degree counterclockwise, not flipped, - 3 rotated 270 degree counterclockwise, not flipped, - 4 not rotated, flipped, - 5 rotated 90 degree counterclockwise, flipped, - 6 rotated 180 degree counterclockwise, flipped, - 7 rotated 270 degree counterclockwise, flipped. @param ifl Image flags. @param bbptr Bounding box, may be NULL. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL or bif is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation, - DK4_E_MATH_OVERFLOW
on numeric overflow in memory size calculation, - DK4_E_MEMORY_ALLOCATION_FAILED
if there is not enough memory available, - DK4_E_WRITE_FAILED
if writing one ore multiple bytes to the stream failed, - DK4_E_FLUSH_FAILED
if flushing data downwards failed. */ void dk4pppt_fig_image( dk4_pppt_t *pppt, double xl, double xr, double yb, double yt, const dkChar *fn, size_t fno, dk4_cs_conv_ctx_t *ctx, int pos, int ifl, dk4_bb_t *bbptr, int *backptr, dk4_er_t *erp ); /** Create path for a circle. @param pppt Output structure. @param xc Center point x coordinate. @param yc Center point y coordinate. @param r Radius. @param bbptr Bounding box, may be NULL. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation, - DK4_E_MATH_OVERFLOW
on numeric overflow in memory size calculation, - DK4_E_MEMORY_ALLOCATION_FAILED
if there is not enough memory available, - DK4_E_WRITE_FAILED
if writing one ore multiple bytes to the stream failed, - DK4_E_FLUSH_FAILED
if flushing data downwards failed. */ void dk4pppt_circle( dk4_pppt_t *pppt, double xc, double yc, double r, dk4_bb_t *bbptr, int *backptr, dk4_er_t *erp ); /** Create path for rectangle parallel to axes, optionally with rounded corners. @param pppt Output structure. @param xl Left x coordinate. @param xr Right x coordinate. @param yb Bottom y coordinate. @param yt Top y coordinate. @param r Corner radius, maximum is a half of the smaller side length. Use negative values to avoid rounded corners. @param bbptr Bounding box, may be NULL. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation, - DK4_E_MATH_OVERFLOW
on numeric overflow in memory size calculation, - DK4_E_MEMORY_ALLOCATION_FAILED
if there is not enough memory available, - DK4_E_WRITE_FAILED
if writing one ore multiple bytes to the stream failed, - DK4_E_FLUSH_FAILED
if flushing data downwards failed. */ void dk4pppt_rectangle( dk4_pppt_t *pppt, double xl, double xr, double yb, double yt, double r, dk4_bb_t *bbptr, int *backptr, dk4_er_t *erp ); /** Add path for an arc. @param pppt Output structure. @param xc Center point x coordinate. @param yc Center point y coordinate. @param ra Radius. @param start Start angle in degree. @param end End angle in degree. @param cl Flag: Draw closed arc (piece of cake) instead of simple arc. @param bbptr Bounding box, may be NULL. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation, - DK4_E_MATH_OVERFLOW
on numeric overflow in memory size calculation, - DK4_E_MEMORY_ALLOCATION_FAILED
if there is not enough memory available, - DK4_E_WRITE_FAILED
if writing one ore multiple bytes to the stream failed, - DK4_E_FLUSH_FAILED
if flushing data downwards failed. */ void dk4pppt_arc( dk4_pppt_t *pppt, double xc, double yc, double ra, double start, double end, int cl, dk4_bb_t *bbptr, int *backptr, dk4_er_t *erp ); /** Create path for an ellipse. @param pppt Output structure. @param xc Center point x coordinate. @param yc Center point y coordinate. @param rx Radius in x direction. @param ry Radius in y direction. @param rot Rotation counterclockwise in degree. @param bbptr Bounding box, may be NULL. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation, - DK4_E_MATH_OVERFLOW
on numeric overflow in memory size calculation, - DK4_E_MEMORY_ALLOCATION_FAILED
if there is not enough memory available, - DK4_E_WRITE_FAILED
if writing one ore multiple bytes to the stream failed, - DK4_E_FLUSH_FAILED
if flushing data downwards failed. */ void dk4pppt_ellipse( dk4_pppt_t *pppt, double xc, double yc, double rx, double ry, double rot, dk4_bb_t *bbptr, int *backptr, dk4_er_t *erp ); /** Add simple (non-special) text to PGF graphics. The text is shown in the current fill color (non-stroking color) unless colspec is used to specify a color. @param pppt Output structure, must be initialized for PGF. @param x X coordinate. @param y Y coordinate. @param rot Rotation counterclockwise in degree. @param txt Text to show. @param colspec Color specification, may be NULL to use fill color. @param ie Text encoding, only used for char text. @param ha Horizontal alignment. @param va Vertical alignment. @param fno Font number. @param fsz Font size in pt. @param fex Flag: Use exact font (1) or similar font (0). @param uc2l UC to LaTeX conversion structure. @param flags Text flags DK4_GRA_TEXT_FLAG_xxx, can be or-combined. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation, - DK4_E_MATH_OVERFLOW
on numeric overflow in memory size calculation, - DK4_E_MEMORY_ALLOCATION_FAILED
if there is not enough memory available, - DK4_E_WRITE_FAILED
if writing one ore multiple bytes to the stream failed, - DK4_E_FLUSH_FAILED
if flushing data downwards failed. */ void dk4pppt_simple_text( dk4_pppt_t *pppt, double x, double y, double rot, const dkChar *txt, const char *colspec, int ie, dk4_text_align_h_t ha, dk4_text_align_v_t va, int fno, double fsz, dk4_gra_tf_t fex, dk4_uc2l_t *uc2l, int flags, int *backptr, dk4_er_t *erp ); /** Add simple (non-special) text to PGF graphics. The text is shown in the current fill color (non-stroking color) unless colspec is used to specify a color. @param pppt Output structure, must be initialized for PGF. @param x X coordinate. @param y Y coordinate. @param rot Rotation counterclockwise in degree. @param txt Text to show. @param colspec Color specification, may be NULL to use fill color. @param ha Horizontal alignment. @param va Vertical alignment. @param fno Font number. @param fsz Font size in pt. @param fex Flag: Use exact font (1) or similar font (0). @param uc2l UC to LaTeX conversion structure. @param flags Text flags DK4_GRA_TEXT_FLAG_xxx, can be or-combined. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation, - DK4_E_MATH_OVERFLOW
on numeric overflow in memory size calculation, - DK4_E_MEMORY_ALLOCATION_FAILED
if there is not enough memory available, - DK4_E_WRITE_FAILED
if writing one ore multiple bytes to the stream failed, - DK4_E_FLUSH_FAILED
if flushing data downwards failed. */ void dk4pppt_simple_utf8_text( dk4_pppt_t *pppt, double x, double y, double rot, const char *txt, const char *colspec, dk4_text_align_h_t ha, dk4_text_align_v_t va, int fno, double fsz, dk4_gra_tf_t fex, dk4_uc2l_t *uc2l, int flags, int *backptr, dk4_er_t *erp ); /** Add special text to PGF graphics. The text is shown in the current fill color (non-stroking color) unless colspec is used to specify a color. @param pppt Output structure, must be initialized for PGF. @param x X coordinate. @param y Y coordinate. @param rot Rotation counterclockwise in degree. @param txt Text to show. @param colspec Color specification, may be NULL to use fill color. @param ha Horizontal alignment. @param va Vertical alignment. @param fno Font number. @param fsz Font size in pt. @param fex Flag: Use exact font. @param flags Text flags DK4_GRA_TEXT_FLAG_xxx, can be or-combined. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. Error codes: - DK4_E_INVALID_ARGUMENTS
if gra is NULL, - DK4_E_INVALID_ARGUMENTS
if gra is not in a state allowing this operation, - DK4_E_MATH_OVERFLOW
on numeric overflow in memory size calculation, - DK4_E_MEMORY_ALLOCATION_FAILED
if there is not enough memory available, - DK4_E_WRITE_FAILED
if writing one ore multiple bytes to the stream failed, - DK4_E_FLUSH_FAILED
if flushing data downwards failed. */ void dk4pppt_special_text( dk4_pppt_t *pppt, double x, double y, double rot, const char *txt, const char *colspec, dk4_text_align_h_t ha, dk4_text_align_v_t va, int fno, double fsz, dk4_gra_tf_t fex, int flags, int *backptr, dk4_er_t *erp ); /** Set flag for even-odd-rule. If this flag is on, the even-odd-rule is used for filling and clipping. Otherwise the nonzero-winding rule is used. By default this flag is turned on when creating a dk4_gra_t structure. @param pppt Output structure. @param val New flag value. */ void dk4pppt_set_eorule( dk4_pppt_t *pppt, int val ); /** Set document font size. @param pppt Output structure. @param fs New font size. @param backptr Address of success variable to reset on error. @param erp Error report, may be NULL. */ void dk4pppt_doc_font_size( dk4_pppt_t *pppt, double fs, int *backptr, dk4_er_t *erp ); /** Add one preamble line. @param pppt Output structure. @param line Line to add without trailing newline. @param tp Preamble line type. @param backptr Address of success variable to reset on error. @param erp Error report, may be NULL. */ void dk4pppt_doc_preamble_line( dk4_pppt_t *pppt, const char *line, int tp, int *backptr, dk4_er_t *erp ); #ifdef __cplusplus } #endif /* vim: set ai sw=4 ts=4 : */ %% module #include "dk4conf.h" #ifdef DK4_HAVE_MATH_H #ifndef MATH_H_INCLUDED #define _USE_MATH_DEFINES 1 #include #define MATH_H_INCLUDED 1 #endif #endif #ifndef DK4PPPT_H_INCLUDED #include "dk4pppt.h" #endif #ifndef GRA_H_INCLUDED #include "gra.h" #endif #ifndef DK4MEM_H_INCLUDED #include "dk4mem.h" #endif #ifndef DK4ENC_H_INCLUDED #include "dk4enc.h" #endif #ifndef DK4FOPD_H_INCLUDED #include "dk4fopd.h" #endif #ifndef DK4STR8_H_INCLUDED #include "dk4str8.h" #endif #ifndef DK4STRD_H_INCLUDED #include "dk4strd.h" #endif #ifndef DK4STRMF_H_INCLUDED #include "dk4strmf.h" #endif #ifndef DK4PATHD_H_INCLUDED #include "dk4pathd.h" #endif #ifndef DK4MPL_H_INCLUDED #include "dk4mpl.h" #endif #ifndef DK4ISADM_H_INCLUDED #include "dk4isadm.h" #endif #if DK4_HAVE_ASSERT_H #ifndef ASSERT_H_INCLUDED #include #define ASSERT_H_INCLUDED 1 #endif #endif $!trace-include /** Constant text fragments. */ static const dkChar * const dk4pppt_dk_kw[] = { $!string-table macro=dkT # # 0-3 File name suffixes for graphics files. # -i.pdf .pdf .ps .eps $!end }; /** Constant text fragments */ static const char * const dk4pppt_c8_kw[] = { $!string-table # # 0-3 Put instruction for text # \\put( , ){ }%\n # # 4-12 makebox instructions with alignments # \\makebox(0,0)[lb]{ \\makebox(0,0)[b]{ \\makebox(0,0)[rb]{ \\makebox(0,0)[l]{ \\makebox(0,0){ \\makebox(0,0)[r]{ \\makebox(0,0)[lt]{ \\makebox(0,0)[t]{ \\makebox(0,0)[rt]{ # # 13 Closing the makebox # } # # 14 Smash # \\smash{ # # 15 Start group # { # # 16 Font command # \\PPPTfo # # 17-18 begin/end picture # \\begin{picture}(0,0)\n \\end{picture}%\n\\setlength{\\unitlength}{1bp}%\n # # 19-20 Included image # \\includegraphics{ }\n # # 21 End picture # \\end{picture}%\n # # 22-23 # \\begin{picture}( )\n # # 24 Mark text as command # {} # # 25 Open white box # \\colorbox{white}{ # # 26 Open oval box # \\ovalbox{ # # 27 Rotatebox # \\rotatebox{ # # 28 Separate degrees from text # }{ $!end }; /** Reset a success variable. @param backptr Address of success variable to reset. */ static void dk4pppt_reset(int *backptr) { if (NULL != backptr) { *backptr = 0; } } /** Check whether a value is within a specified range. @param min Minimum value (inclusive). @param max Maximum value (inclusive). @param val Value to check. @return 1 on success, 0 on error. */ static int dk4pppt_in_range(double min, double max, double val) { int back = 0; if ((min <= val) && (max >= val)) { back = 1; } return back; } /** Release preamble lines. @param ps Preamble lines storage. @param pi Preamble lines iterator. */ static void dk4pppt_release_preamble_lines( dk4_sto_t *ps, dk4_sto_it_t *pi ) { dk4_gra_preamble_line_t *pl; if (NULL != ps) { if (NULL != pi) { dk4sto_it_reset(pi); do { pl = (dk4_gra_preamble_line_t *)dk4sto_it_next(pi); if (NULL != pl) { dk4gratool_preamble_delete(pl); } } while (NULL != pl); dk4sto_it_close(pi); } dk4sto_close(ps); } } void dk4pppt_close( dk4_pppt_t *pppt ) { $? "+ dk4pppt_close" #if DK4_USE_ASSERT assert(NULL != pppt); #endif if (NULL != pppt) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { if (NULL != pppt->out.pgf) { dk4gra_close(pppt->out.pgf); pppt->out.pgf = NULL; } } break; default : { /* PDF+TeX or EPS+TeX */ dk4pppt_release_preamble_lines( pppt->out.ppt.s_f, pppt->out.ppt.i_f ); dk4pppt_release_preamble_lines( pppt->out.ppt.s_p, pppt->out.ppt.i_p ); dk4pppt_release_preamble_lines( pppt->out.ppt.s_o, pppt->out.ppt.i_o ); pppt->out.ppt.s_f = pppt->out.ppt.s_p = pppt->out.ppt.s_o = NULL; pppt->out.ppt.i_f = pppt->out.ppt.i_p = pppt->out.ppt.i_o = NULL; if (NULL != pppt->out.ppt.tms) { dk4stream_close(pppt->out.ppt.tms, NULL); pppt->out.ppt.tms = NULL; } if (NULL != pppt->out.ppt.tmb) { dk4membuf_close(pppt->out.ppt.tmb); pppt->out.ppt.tmb = NULL; } if (NULL != pppt->out.ppt.fc) { dk4fontc_close(pppt->out.ppt.fc); pppt->out.ppt.fc = NULL; } if (NULL != pppt->out.ppt.gra) { dk4gra_close(pppt->out.ppt.gra); pppt->out.ppt.gra = NULL; } if (NULL != pppt->out.ppt.tfn) { dk4mem_free(pppt->out.ppt.tfn); pppt->out.ppt.tfn = NULL; } } break; } dk4mem_free(pppt); } $? "- dk4pppt_close" } /** Open a PGF output structure. @param texname Name of TeX output file. The name ends on ".tex". The name of the included *.eps or *.pdf file is derived from this name. @param dr Output driver. @param isdoc Flag: Produce LaTeX document, not just image. @param flags Additional flags for graphics. @param width Image width in bp (PS point). @param height Image height in bp. @param erp Error report, may be NULL. @return Valid pointer to new output structure on success, NULL on error. */ static dk4_pppt_t * dk4pppt_pgf_open( const dkChar *texname, int isdoc, int flags, size_t width, size_t height, dk4_er_t *erp ) { dk4_pppt_t *back = NULL; $? "+ dk4pppt_pgf_open" #if DK4_USE_ASSERT assert(NULL != texname); assert(0 < width); assert(0 < height); #endif back = dk4mem_new(dk4_pppt_t,1,erp); if (NULL != back) { DK4_MEMRES(back,sizeof(dk4_pppt_t)); back->flags = flags; back->isdoc = isdoc; back->dr = DK4_PPPT_DR_PGF; back->out.pgf = dk4gra_open_pgf(texname,width,height,flags,isdoc,erp); if (NULL == back->out.pgf) { dk4mem_free(back); back = NULL; } } $? "- dk4pppt_pgf_open %d", TR_IPTR(back) return back; } /** Construct output file name based on TeX file name. @param obuf Output buffer. @param szobuf Output buffer size (number of dkChar). @param texname TeX file name. @param dr Driver to produce name for. @param flags Document flags. @param isdoc Flag: Produce entire document. @param erp Error report, may be NULL. @return 1 on success, 0 on error (buffer too short). */ static int dk4pppt_construct_output_file_name( dkChar *obuf, size_t szobuf, const dkChar *texname, dk4_pppt_driver_t dr, int flags, int isdoc, dk4_er_t *erp ) { dkChar *psuffix = NULL; /* File name existing suffix */ size_t kwi = 0; /* Keyword index for suffix to append */ int back = 0; $? "+ dk4pppt_construct_output_file_name" #if DK4_USE_ASSERT assert(NULL != obuf); assert(0 < szobuf); assert(NULL != texname); #endif if (0 != dk4str_cpy_s(obuf, szobuf, texname, erp)) { psuffix = dk4path_get_suffix(obuf, NULL); if (NULL != psuffix) { *psuffix = dkT('\0'); } kwi = 1; if (DK4_PPPT_DR_PDF_TEX == dr) { if (0 != isdoc) { kwi = 0; } } else { kwi = 2; if (0 != (DK4_GRA_DOC_FLAG_EPS & flags)) { kwi = 3; } } back = dk4str_cat_s(obuf, szobuf, dk4pppt_dk_kw[kwi], erp); } if (0 == back) { obuf[0] = dkT('\0'); } $? "- dk4pppt_construct_output_file_name %d \"%!ds\"", back, obuf return back; } /** Open a non-PGF output structure. @param texname Name of TeX output file. The name ends on ".tex". The name of the included *.eps or *.pdf file is derived from this name. @param dr Output driver. @param isdoc Flag: Produce LaTeX document, not just image. @param flags Additional flags for graphics. @param width Image width in bp (PS point). @param height Image height in bp. @param erp Error report, may be NULL. @return Valid pointer to new output structure on success, NULL on error. */ static dk4_pppt_t * dk4pppt_ppt_open( const dkChar *texname, dk4_pppt_driver_t dr, int isdoc, int flags, size_t width, size_t height, dk4_er_t *erp ) { dkChar ofnbuf[DK4_MAX_PATH]; /* Buffer to construct name */ #if DK4_CHAR_SIZE > 1 char tb[DK4_MAX_PATH]; /* ANSI file name */ #endif dk4_pppt_t *back = NULL; /* Function result */ int res = 0; /* Operation result */ int ok = 0; /* Flag: Everything ok */ $? "+ dk4pppt_ppt_open" #if DK4_USE_ASSERT assert(NULL != texname); #endif res = dk4pppt_construct_output_file_name( ofnbuf, DK4_SIZEOF(ofnbuf,dkChar), texname, dr, flags, isdoc, erp ); if (0 != res) { back = dk4mem_new(dk4_pppt_t,1,erp); if (NULL != back) { DK4_MEMRES(back,sizeof(dk4_pppt_t)); back->flags = flags; back->isdoc = isdoc; back->dr = dr; back->out.ppt.tfn = NULL; back->out.ppt.gra = NULL; back->out.ppt.fc = NULL; back->out.ppt.tmb = NULL; back->out.ppt.tms = NULL; back->out.ppt.s_f = NULL; back->out.ppt.i_f = NULL; back->out.ppt.s_p = NULL; back->out.ppt.i_p = NULL; back->out.ppt.s_o = NULL; back->out.ppt.i_o = NULL; back->out.ppt.dfs = -1.0; back->out.ppt.n_f = 0UL; back->out.ppt.n_p = 0UL; back->out.ppt.n_o = 0UL; back->out.ppt.tfn = dk4str_dup(texname, erp); if (NULL != back->out.ppt.tfn) { if (DK4_PPPT_DR_EPS_TEX == dr) { back->out.ppt.gra = dk4gra_open_ps( ofnbuf, width, height, flags, erp ); } else { back->out.ppt.gra = dk4gra_open_pdf( ofnbuf, width, height, flags, erp ); } if (NULL != back->out.ppt.gra) { back->out.ppt.fc = dk4fontc_open(erp); if (NULL != back->out.ppt.fc) { back->out.ppt.tmb = dk4membuf_open(erp); if (NULL != back->out.ppt.tmb) { back->out.ppt.tms = dk4stream_open_membuf_writer( back->out.ppt.tmb, erp ); if (NULL != back->out.ppt.tms) { #if DK4_CHAR_SIZE > 1 #if DK4_CHAR_SIZE > 2 ok = dk4recode_dk_to_any( tb, sizeof(tb), DK4_FILE_ENCODING_WIN1252, ofnbuf, DK4_ENCODING_32, erp ); #else ok = dk4recode_dk_to_any( tb, sizeof(tb), DK4_FILE_ENCODING_WIN1252, ofnbuf, DK4_ENCODING_UTF16, erp ); #endif #else ok = 1; #endif } } } } } if (0 == ok) { dk4pppt_close(back); back = NULL; } } } $? "- dk4pppt_ppt_open" return back; } dk4_pppt_t * dk4pppt_open( const dkChar *texname, dk4_pppt_driver_t dr, int isdoc, int flags, size_t width, size_t height, dk4_er_t *erp ) { dk4_pppt_t *back = NULL; int ok = 1; $? "+ dk4pppt_open" #if DK4_USE_ASSERT assert(NULL != texname); assert(0 < width); assert(0 < height); #endif if ((NULL != texname) && (0 < width) && (0 < height)) { switch (dr) { case DK4_PPPT_DR_PGF : { $? ". PGF" back = dk4pppt_pgf_open( texname, isdoc, flags, width, height, erp ); } break; case DK4_PPPT_DR_EPS_TEX : { /* Cannot create document for PS output, check here */ $? ". not PGF (EPS/TeX)" if (0 == isdoc) { back = dk4pppt_ppt_open( texname, dr, isdoc, flags, width, height, erp ); } else { dk4error_set_simple_error_code(erp,DK4_E_INVALID_ARGUMENTS); } } break; default : { /* DK4_PPPT_DR_PDF_TEX */ $? ". not PGF" back = dk4pppt_ppt_open( texname, dr, isdoc, flags, width, height, erp ); } break; } if (NULL != back) { switch (dr) { case DK4_PPPT_DR_PGF : { dk4gra_page_with_flags( back->out.pgf, flags, &ok, erp ); } break; default : { dk4gra_page_with_flags( back->out.ppt.gra, flags, &ok, erp ); } break; } if (0 == ok) { dk4pppt_close(back); back = NULL; } } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); } $? "- dk4pppt_open %d", TR_IPTR(back) return back; } /** Check whether pppt object state grants graphics and text operations. @param pppt Structure to check. @return 1 on success, 0 on error. */ static int dk4pppt_is_state_ok( const dk4_pppt_t *pppt ) { int back = 0; /* Check for valid pointer */ if (NULL == pppt) { goto finished; } /* Remaining checks depend on driver */ switch (pppt->dr) { case DK4_PPPT_DR_PGF : { if (NULL != pppt->out.pgf) { back = 1; } } break; default : { if (NULL != pppt->out.ppt.gra) { if (NULL != pppt->out.ppt.fc) { if (NULL != pppt->out.ppt.tmb) { if (NULL != pppt->out.ppt.tms) { if (NULL != pppt->out.ppt.tfn) { back = 1; } } } } } } break; } finished: return back; } /** Convert backslashes to forward slashes for use of file name in LaTeX. @param fn String to correct. */ static void dk4pppt_to_slash(char *fn) { while ('\0' != *fn) { if ('\\' == *fn) { *fn = '/'; } fn++; } } /** Write file name to includegraphics instruction. @param ostrm Destination output stream. @param fn File name to print. @param backptr Address of success variable to reset on error. @param erp Error report, may be NULL. */ static void dk4pppt_file_name_to_stream( dk4_stream_t *ostrm, const dkChar *fn, int *backptr, dk4_er_t *erp ) { char buf[DK4_MAX_PATH]; char *p1 = NULL; char *p2 = NULL; int res = 0; #if DK4_USE_ASSERT assert(NULL != ostrm); assert(NULL != fn); #endif #if DK4_CHAR_SIZE > 1 #if DK4_CHAR_SIZE > 2 res = dk4recode_dk_to_any( buf, sizeof(buf), DK4_FILE_ENCODING_WIN1252, fn, DK4_ENCODING_32, erp ); #else res = dk4recode_dk_to_any( buf, sizeof(buf), DK4_FILE_ENCODING_WIN1252, fn, DK4_ENCODING_UTF16, erp ); #endif #else res = dk4str8_cpy_s(buf, sizeof(buf), fn, erp); #endif if (0 != res) { dk4pppt_to_slash(buf); if (0 != dk4path_is_absolute(fn)) { res = dk4stream_write_char_string(ostrm, buf, erp); if (0 == res) { if (NULL != backptr) { *backptr = 0; } } } else { p2 = buf; while ('\0' != *p2) { if ('/' == *p2) { p1 = p2; } p2++; } if (NULL != p1) { p1++; } else { p1 = buf; } res = dk4stream_write_char_string(ostrm, p1, erp); if (0 == res) { if (NULL != backptr) { *backptr = 0; } } } } else { if (NULL != backptr) { *backptr = 0; } } } /** Write output data. @param pppt Output structure. @param erp Error report, may be NULL. @return 1 on success, 0 on error. */ static int dk4pppt_write( dk4_pppt_t *pppt, dk4_er_t *erp ) { FILE *fout = NULL; dk4_stream_t *ostrm = NULL; int tests = DK4_FOPEN_SC_USER; int res = 0; int back = 0; $? "+ dk4pppt_write" #if DK4_USE_ASSERT assert(NULL != pppt); #endif switch (pppt->dr) { case DK4_PPPT_DR_PGF : { back = 1; dk4gra_write_and_close(pppt->out.pgf, &back, erp); pppt->out.pgf = NULL; } break; default : { /* Write *.tex file first, as name of graphics file is in gra */ if (0 != dk4isadmin()) { tests = DK4_FOPEN_SC_PRIVILEGED; } fout = dk4fopen(pppt->out.ppt.tfn, dkT("wb"), tests, erp); if (NULL != fout) { ostrm = dk4stream_open_for_file( fout, DK4_STREAM_WRITE, 0, 0, erp ); if (NULL != ostrm) { back = 1; if (0 != pppt->isdoc) { dk4gratool_start_standalone_document( ostrm, pppt->out.ppt.gra, 0, pppt->out.ppt.dfs, pppt->out.ppt.s_f, pppt->out.ppt.i_f, pppt->out.ppt.s_p, pppt->out.ppt.i_p, pppt->out.ppt.s_o, pppt->out.ppt.i_o, &back, erp ); } dk4gratool_stream_string( ostrm, dk4pppt_c8_kw[17], &back, erp ); dk4gratool_stream_string( ostrm, dk4pppt_c8_kw[19], &back, erp ); dk4pppt_file_name_to_stream( ostrm, pppt->out.ppt.gra->fn, &back, erp ); dk4gratool_stream_string( ostrm, dk4pppt_c8_kw[20], &back, erp ); dk4gratool_stream_string( ostrm, dk4pppt_c8_kw[18], &back, erp ); dk4gratool_font_definitions( ostrm, pppt->out.ppt.fc, &back, erp ); dk4gratool_stream_string( ostrm, dk4pppt_c8_kw[22], &back, erp ); dk4gratool_stream_uint( ostrm, pppt->out.ppt.gra->w, 0, &back, erp ); dk4gratool_stream_string( ostrm, dk4pppt_c8_kw[1], &back, erp ); dk4gratool_stream_uint( ostrm, pppt->out.ppt.gra->h, 0, &back, erp ); dk4gratool_stream_string( ostrm, dk4pppt_c8_kw[23], &back, erp ); if (NULL != pppt->out.ppt.tms) { if (0 == dk4stream_close(pppt->out.ppt.tms, erp)) { back = 0; } pppt->out.ppt.tms = NULL; } if (NULL != pppt->out.ppt.tmb) { res = dk4membuf_to_stream(ostrm,pppt->out.ppt.tmb,erp); if (0 == res) { back = 0; } } dk4gratool_stream_string( ostrm, dk4pppt_c8_kw[21], &back, erp ); if (0 != pppt->isdoc) { dk4gratool_end_standalone_document(ostrm, &back, erp); } if (0 == dk4stream_close(ostrm, erp)) { back = 0; } /* Write and close the real graphics */ dk4gra_write_and_close( pppt->out.ppt.gra, &back, erp ); pppt->out.ppt.gra = NULL; } if (0 != fclose(fout)) { back = 0; } } } break; } $? "- dk4pppt_write %d", back return back; } int dk4pppt_write_and_close( dk4_pppt_t *pppt, dk4_er_t *erp ) { int back = 0; $? "+ dk4pppt_write_and_close" #if DK4_USE_ASSERT assert(NULL != pppt); #endif if (NULL != pppt) { if (0 != dk4pppt_is_state_ok(pppt)) { back = dk4pppt_write(pppt, erp); } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); } dk4pppt_close(pppt); } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); } $? "- dk4pppt_write_and_close %d", back return back; } void dk4pppt_set_gs_for_pattern_only( dk4_pppt_t *pppt, int val, dk4_er_t *erp ) { $? "+ dk4pppt_set_gs_for_pattern_only" #if DK4_USE_ASSERT assert(NULL != pppt); #endif if (0 != dk4pppt_is_state_ok(pppt)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_set_gs_for_pattern_only( pppt->out.pgf, val, erp ); } break; default : { dk4gra_set_gs_for_pattern_only( pppt->out.ppt.gra, val, erp ); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); } $? "- dk4pppt_set_gs_for_pattern_only" } void dk4pppt_gsave( dk4_pppt_t *pppt, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_gsave" #if DK4_USE_ASSERT assert(NULL != pppt); #endif if (0 != dk4pppt_is_state_ok(pppt)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_gsave(pppt->out.pgf, backptr, erp); } break; default : { dk4gra_gsave(pppt->out.ppt.gra, backptr, erp); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_gsave" } void dk4pppt_grestore( dk4_pppt_t *pppt, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_grestore" #if DK4_USE_ASSERT assert(NULL != pppt); #endif if (0 != dk4pppt_is_state_ok(pppt)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_grestore(pppt->out.pgf, backptr, erp); } break; default : { dk4gra_grestore(pppt->out.ppt.gra, backptr, erp); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_grestore" } void dk4pppt_set_line_width( dk4_pppt_t *pppt, double lw, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_set_line_width" #if DK4_USE_ASSERT assert(NULL != pppt); #endif if ((0 != dk4pppt_is_state_ok(pppt)) && (0.0 <= lw)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_set_line_width(pppt->out.pgf, lw, backptr, erp); } break; default : { dk4gra_set_line_width(pppt->out.ppt.gra, lw, backptr, erp); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_set_line_width" } void dk4pppt_set_line_style( dk4_pppt_t *pppt, dk4_gra_ls_t ls, double sv, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_set_line_style" #if DK4_USE_ASSERT assert(NULL != pppt); #endif if ((0 != dk4pppt_is_state_ok(pppt)) && (0.0 <= sv)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_set_line_style(pppt->out.pgf, ls, sv, backptr, erp); } break; default : { dk4gra_set_line_style(pppt->out.ppt.gra, ls, sv, backptr, erp); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_set_line_style" } void dk4pppt_set_line_cap( dk4_pppt_t *pppt, dk4_gra_lc_t lc, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_set_line_cap" #if DK4_USE_ASSERT assert(NULL != pppt); #endif if (0 != dk4pppt_is_state_ok(pppt)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_set_line_cap(pppt->out.pgf, lc, backptr, erp); } break; default : { dk4gra_set_line_cap(pppt->out.ppt.gra, lc, backptr, erp); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_set_line_cap" } void dk4pppt_set_line_join( dk4_pppt_t *pppt, dk4_gra_lj_t lj, double ml, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_set_line_join" #if DK4_USE_ASSERT assert(NULL != pppt); #endif if (0 != dk4pppt_is_state_ok(pppt)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_set_line_join(pppt->out.pgf, lj, ml, backptr, erp); } break; default : { dk4gra_set_line_join(pppt->out.ppt.gra, lj, ml, backptr, erp); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_set_line_join" } void dk4pppt_set_fill_gray( dk4_pppt_t *pppt, double g, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_set_fill_gray" #if DK4_USE_ASSERT assert(NULL != pppt); #endif if ((0 != dk4pppt_is_state_ok(pppt)) && (0.0 <= g) && (1.0 >= g)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_set_fill_gray(pppt->out.pgf, g, backptr, erp); } break; default : { dk4gra_set_fill_gray(pppt->out.ppt.gra, g, backptr, erp); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_set_fill_gray" } void dk4pppt_set_fill_rgb( dk4_pppt_t *pppt, double r, double g, double b, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_set_fill_rgb" #if DK4_USE_ASSERT assert(NULL != pppt); #endif if ((0 != dk4pppt_is_state_ok(pppt)) && (dk4pppt_in_range(0.0, 1.0, r)) && (dk4pppt_in_range(0.0, 1.0, g)) && (dk4pppt_in_range(0.0, 1.0, b)) ) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { $? ". PGF" dk4gra_set_fill_rgb(pppt->out.pgf, r, g, b, backptr, erp); } break; default : { $? ". not PGF" dk4gra_set_fill_rgb(pppt->out.ppt.gra, r, g, b, backptr, erp); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_set_fill_rgb" } void dk4pppt_set_fill_cmyk( dk4_pppt_t *pppt, double c, double m, double y, double k, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_set_fill_cmyk" #if DK4_USE_ASSERT assert(NULL != pppt); #endif if ((0 != dk4pppt_is_state_ok(pppt)) && (dk4pppt_in_range(0.0, 1.0, c)) && (dk4pppt_in_range(0.0, 1.0, m)) && (dk4pppt_in_range(0.0, 1.0, y)) && (dk4pppt_in_range(0.0, 1.0, k)) ) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_set_fill_cmyk(pppt->out.pgf, c, m, y, k, backptr, erp); } break; default : { dk4gra_set_fill_cmyk(pppt->out.ppt.gra,c,m,y,k,backptr,erp); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_set_fill_cmyk" } void dk4pppt_set_stroke_gray( dk4_pppt_t *pppt, double g, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_set_stroke_gray" #if DK4_USE_ASSERT assert(NULL != pppt); #endif if ((0 != dk4pppt_is_state_ok(pppt)) && (dk4pppt_in_range(0.0, 1.0, g))) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_set_stroke_gray(pppt->out.pgf, g, backptr, erp); } break; default : { dk4gra_set_stroke_gray(pppt->out.ppt.gra, g, backptr, erp); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_set_stroke_gray" } void dk4pppt_set_stroke_rgb( dk4_pppt_t *pppt, double r, double g, double b, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_set_stroke_rgb" #if DK4_USE_ASSERT assert(NULL != pppt); #endif if ( (0 != dk4pppt_is_state_ok(pppt)) && (dk4pppt_in_range(0.0, 1.0, r)) && (dk4pppt_in_range(0.0, 1.0, g)) && (dk4pppt_in_range(0.0, 1.0, b)) ) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_set_stroke_rgb(pppt->out.pgf, r, g, b, backptr, erp); } break; default : { dk4gra_set_stroke_rgb(pppt->out.ppt.gra, r, g, b, backptr, erp); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_set_stroke_rgb" } void dk4pppt_set_stroke_cmyk( dk4_pppt_t *pppt, double c, double m, double y, double k, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_set_stroke_cmyk" #if DK4_USE_ASSERT assert(NULL != pppt); #endif if ( (0 != dk4pppt_is_state_ok(pppt)) && (dk4pppt_in_range(0.0, 1.0, c)) && (dk4pppt_in_range(0.0, 1.0, m)) && (dk4pppt_in_range(0.0, 1.0, y)) && (dk4pppt_in_range(0.0, 1.0, k)) ) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_set_stroke_cmyk(pppt->out.pgf, c, m, y, k, backptr, erp); } break; default : { dk4gra_set_stroke_cmyk(pppt->out.ppt.gra,c,m,y,k,backptr,erp); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_set_stroke_cmyk" } void dk4pppt_prepare_fill( dk4_pppt_t *pppt, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_prepare_fill" #if DK4_USE_ASSERT assert(NULL != pppt); #endif if (0 != dk4pppt_is_state_ok(pppt)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_prepare_fill(pppt->out.pgf, backptr, erp); } break; default : { dk4gra_prepare_fill(pppt->out.ppt.gra, backptr, erp); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_prepare_fill" } void dk4pppt_prepare_stroke( dk4_pppt_t *pppt, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_prepare_stroke" #if DK4_USE_ASSERT assert(NULL != pppt); #endif if (0 != dk4pppt_is_state_ok(pppt)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_prepare_stroke(pppt->out.pgf, backptr, erp); } break; default : { dk4gra_prepare_stroke(pppt->out.ppt.gra, backptr, erp); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_prepare_stroke" } void dk4pppt_prepare_fill_and_stroke( dk4_pppt_t *pppt, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_prepare_fill_and_stroke" #if DK4_USE_ASSERT assert(NULL != pppt); #endif if (0 != dk4pppt_is_state_ok(pppt)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_prepare_fill_and_stroke(pppt->out.pgf, backptr, erp); } break; default : { dk4gra_prepare_fill_and_stroke(pppt->out.ppt.gra, backptr, erp); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_prepare_fill_and_stroke" } int dk4pppt_can_fill_and_stroke( const dk4_pppt_t *pppt ) { int back = 0; $? "+ dk4pppt_can_fill_and_stroke" #if DK4_USE_ASSERT assert(NULL != pppt); #endif if (0 != dk4pppt_is_state_ok(pppt)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { back = dk4gra_can_fill_and_stroke(pppt->out.pgf); } break; default : { back = dk4gra_can_fill_and_stroke(pppt->out.ppt.gra); } break; } } $? "- dk4pppt_can_fill_and_stroke %d", back return back; } void dk4pppt_fill( dk4_pppt_t *pppt, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_fill" #if DK4_USE_ASSERT assert(NULL != pppt); #endif if (0 != dk4pppt_is_state_ok(pppt)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_fill(pppt->out.pgf, backptr, erp); } break; default : { dk4gra_fill(pppt->out.ppt.gra, backptr, erp); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_fill" } void dk4pppt_stroke( dk4_pppt_t *pppt, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_stroke" #if DK4_USE_ASSERT assert(NULL != pppt); #endif if (0 != dk4pppt_is_state_ok(pppt)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_stroke(pppt->out.pgf, backptr, erp); } break; default : { dk4gra_stroke(pppt->out.ppt.gra, backptr, erp); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_stroke" } void dk4pppt_fill_and_stroke( dk4_pppt_t *pppt, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_fill_and_stroke" #if DK4_USE_ASSERT assert(NULL != pppt); #endif if (0 != dk4pppt_is_state_ok(pppt)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_fill_and_stroke(pppt->out.pgf, backptr, erp); } break; default : { dk4gra_fill_and_stroke(pppt->out.ppt.gra, backptr, erp); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_fill_and_stroke" } void dk4pppt_clip( dk4_pppt_t *pppt, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_clip" #if DK4_USE_ASSERT assert(NULL != pppt); #endif if (0 != dk4pppt_is_state_ok(pppt)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_clip(pppt->out.pgf, backptr, erp); } break; default : { dk4gra_clip(pppt->out.ppt.gra, backptr, erp); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_clip" } void dk4pppt_set_pattern_line_width( dk4_pppt_t *pppt, double plw ) { #if DK4_USE_ASSERT assert(NULL != pppt); #endif if (NULL != pppt) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_set_pattern_line_width(pppt->out.pgf, plw); } break; default : { dk4gra_set_pattern_line_width(pppt->out.ppt.gra, plw); } break; } } } void dk4pppt_pattern( dk4_pppt_t *pppt, double xl, double xr, double yb, double yt, dk4_gra_pattern_t pn, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_pattern" #if DK4_USE_ASSERT assert(NULL != pppt); #endif if (0 != dk4pppt_is_state_ok(pppt)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_pattern(pppt->out.pgf, xl, xr, yb, yt, pn, backptr, erp); } break; default : { dk4gra_pattern(pppt->out.ppt.gra,xl,xr,yb,yt,pn,backptr,erp); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_pattern" } void dk4pppt_newpath_moveto( dk4_pppt_t *pppt, double x, double y, dk4_bb_t *bbptr, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_newpath_moveto" #if DK4_USE_ASSERT assert(NULL != pppt); #endif if (0 != dk4pppt_is_state_ok(pppt)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { $? ". PGF" dk4gra_newpath_moveto(pppt->out.pgf, x, y, bbptr, backptr, erp); } break; default : { $? ". not PGF" dk4gra_newpath_moveto(pppt->out.ppt.gra,x,y,bbptr,backptr,erp); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_newpath_moveto" } void dk4pppt_lineto( dk4_pppt_t *pppt, double x, double y, dk4_bb_t *bbptr, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_lineto" #if DK4_USE_ASSERT assert(NULL != pppt); #endif if (0 != dk4pppt_is_state_ok(pppt)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_lineto(pppt->out.pgf, x, y, bbptr, backptr, erp); } break; default : { dk4gra_lineto(pppt->out.ppt.gra, x, y, bbptr, backptr, erp); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_lineto" } void dk4pppt_curveto( dk4_pppt_t *pppt, double xc1, double yc1, double xc2, double yc2, double x, double y, dk4_bb_t *bbptr, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_curveto" #if DK4_USE_ASSERT assert(NULL != pppt); #endif if (0 != dk4pppt_is_state_ok(pppt)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_curveto( pppt->out.pgf, xc1, yc1, xc2, yc2, x, y, bbptr, backptr, erp ); } break; default : { dk4gra_curveto( pppt->out.ppt.gra,xc1,yc1,xc2,yc2,x,y,bbptr,backptr,erp ); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_curveto" } void dk4pppt_closepath( dk4_pppt_t *pppt, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_closepath" #if DK4_USE_ASSERT assert(NULL != pppt); #endif if (0 != dk4pppt_is_state_ok(pppt)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_closepath(pppt->out.pgf, backptr, erp); } break; default : { dk4gra_closepath(pppt->out.ppt.gra, backptr, erp); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_closepath" } void dk4pppt_bif_fig_image( dk4_pppt_t *pppt, double xl, double xr, double yb, double yt, dk4_bif_t *bif, const dkChar *fn, size_t fno, int pos, int ifl, dk4_bb_t *bbptr, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_bif_fig_image" #if DK4_USE_ASSERT assert(NULL != pppt); assert(NULL != bif); #endif if (0 != dk4pppt_is_state_ok(pppt)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_bif_fig_image( pppt->out.pgf, xl, xr, yb, yt, bif, fn, fno, pos, ifl, bbptr, backptr, erp ); } break; default : { dk4gra_bif_fig_image( pppt->out.ppt.gra, xl, xr, yb, yt, bif, fn, fno, pos, ifl, bbptr, backptr, erp ); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_bif_fig_image" } void dk4pppt_bif_image( dk4_pppt_t *pppt, double xl, double xr, double yb, double yt, dk4_bif_t *bif, const dkChar *fn, size_t fno, int ifl, dk4_bb_t *bbptr, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_bif_image" #if DK4_USE_ASSERT assert(NULL != pppt); assert(NULL != bif); #endif if (0 != dk4pppt_is_state_ok(pppt)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_bif_image( pppt->out.pgf, xl, xr, yb, yt, bif, fn, fno, ifl, bbptr, backptr, erp ); } break; default : { dk4gra_bif_image( pppt->out.ppt.gra, xl, xr, yb, yt, bif, fn, fno, ifl, bbptr, backptr, erp ); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_bif_image" } void dk4pppt_image( dk4_pppt_t *pppt, double xl, double xr, double yb, double yt, const dkChar *fn, size_t fno, dk4_cs_conv_ctx_t *ctx, int ifl, dk4_bb_t *bbptr, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_image" #if DK4_USE_ASSERT assert(NULL != pppt); assert(NULL != fn); #endif if (0 != dk4pppt_is_state_ok(pppt)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_image( pppt->out.pgf, xl, xr, yb, yt, fn, fno, ctx, ifl, bbptr, backptr, erp ); } break; default : { dk4gra_image( pppt->out.ppt.gra, xl, xr, yb, yt, fn, fno, ctx, ifl, bbptr, backptr, erp ); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_image" } void dk4pppt_fig_image( dk4_pppt_t *pppt, double xl, double xr, double yb, double yt, const dkChar *fn, size_t fno, dk4_cs_conv_ctx_t *ctx, int pos, int ifl, dk4_bb_t *bbptr, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_fig_image" #if DK4_USE_ASSERT assert(NULL != pppt); assert(NULL != fn); #endif if (0 != dk4pppt_is_state_ok(pppt)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_fig_image( pppt->out.pgf, xl, xr, yb, yt, fn, fno, ctx, pos, ifl, bbptr, backptr, erp ); } break; default : { dk4gra_fig_image( pppt->out.ppt.gra, xl, xr, yb, yt, fn, fno, ctx, pos, ifl, bbptr, backptr, erp ); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_fig_image" } void dk4pppt_circle( dk4_pppt_t *pppt, double xc, double yc, double r, dk4_bb_t *bbptr, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_circle" #if DK4_USE_ASSERT assert(NULL != pppt); #endif if (0 != dk4pppt_is_state_ok(pppt)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_circle(pppt->out.pgf, xc, yc, r, bbptr, backptr, erp); } break; default : { dk4gra_circle(pppt->out.ppt.gra,xc,yc,r,bbptr,backptr,erp); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_circle" } void dk4pppt_rectangle( dk4_pppt_t *pppt, double xl, double xr, double yb, double yt, double r, dk4_bb_t *bbptr, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_rectangle" #if DK4_USE_ASSERT assert(NULL != pppt); #endif if (0 != dk4pppt_is_state_ok(pppt)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_rectangle(pppt->out.pgf,xl,xr,yb,yt,r,bbptr,backptr,erp); } break; default : { dk4gra_rectangle( pppt->out.ppt.gra, xl, xr, yb, yt, r, bbptr, backptr, erp ); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_rectangle" } void dk4pppt_arc( dk4_pppt_t *pppt, double xc, double yc, double ra, double start, double end, int cl, dk4_bb_t *bbptr, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_arc" #if DK4_USE_ASSERT assert(NULL != pppt); #endif if (0 != dk4pppt_is_state_ok(pppt)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_arc( pppt->out.pgf, xc, yc, ra, start, end, cl, bbptr, backptr, erp ); } break; default : { dk4gra_arc( pppt->out.ppt.gra, xc, yc, ra, start, end, cl, bbptr, backptr, erp ); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_arc" } void dk4pppt_ellipse( dk4_pppt_t *pppt, double xc, double yc, double rx, double ry, double rot, dk4_bb_t *bbptr, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_ellipse" #if DK4_USE_ASSERT assert(NULL != pppt); #endif if (0 != dk4pppt_is_state_ok(pppt)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_ellipse( pppt->out.pgf, xc, yc, rx, ry, rot, bbptr, backptr, erp ); } break; default : { dk4gra_ellipse( pppt->out.ppt.gra, xc, yc, rx, ry, rot, bbptr, backptr, erp ); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_ellipse" } static void dk4pppt_kw_out( dk4_pppt_t *pppt, size_t kwi, int *backptr, dk4_er_t *erp ) { dk4gratool_stream_string( pppt->out.ppt.tms, dk4pppt_c8_kw[kwi], backptr, erp ); } static void dk4pppt_double_out( dk4_pppt_t *pppt, double val, int *backptr, dk4_er_t *erp ) { dk4gratool_stream_double( pppt->out.ppt.tms, val, backptr, erp ); } /** Handle one text piece, normal or special. @param pppt Output structure. @param x X position. @param y Y position. @param rot Rotation counterclockwise in degree. @param txt Text to write, dkChar for normal text, char for special. @param colspec Color specification, may be NULL to use fill color. @param ie Input encoding for normal text. @param ha Horizontal alignment. @param va Vertical alignment. @param isnt Flag: Normal text. @param fno Font id number. @param fsz Font size. @param fex Flag: Use font exactly as specified. @param uc2l Unicode to LaTeX converter, may be NULL for special text. @param flags Text flags. @param backptr Address of success variable to reset on error. @param erp Error report, may be NULL. */ static void dk4pppt_i_text( dk4_pppt_t *pppt, double x, double y, double rot, const void *txt, const char *colspec, int ie, int ha, int va, int isnt, int fno, double fsz, dk4_gra_tf_t fex, dk4_uc2l_t *uc2l, int flags, int *backptr, dk4_er_t *erp ) { dk4gra_col_t *pcolf = NULL; /* Fill color */ dk4_gra_ps_page_t *pgps = NULL; /* PS page */ dk4_gra_pdf_page_t *pgpdf = NULL; /* PDF page */ size_t fontno = 0; /* Font number */ size_t kwi = 4; /* Keyword index */ int res = 0; /* One operation result */ int dorot = 0; /* Flag: Use rotatebox */ $? "+ dk4pppt_i_text" $? ". *backptr = %d", *backptr /* Attempt to register font */ if (1.0e-8 < fabs(rot)) { dorot = 1; } if (0 != isnt) { $? ". normal text" if (0 == dk4fontc_add_font(&fontno, pppt->out.ppt.fc, fno, fsz, fex, erp)) { $? "! failed to add font" goto finished; } } /* Find non-stroking color */ switch (pppt->dr) { case DK4_PPPT_DR_PDF_TEX : { $? ". pdf tex" pgpdf = (dk4_gra_pdf_page_t *)(pppt->out.ppt.gra->curpg); if (NULL != pgpdf) { pcolf = &(pgpdf->attr.col_fill_requested); } else { $? "! curpg" goto finished; } } break; case DK4_PPPT_DR_EPS_TEX : { $? ". eps tex" pgps = (dk4_gra_ps_page_t *)(pppt->out.ppt.gra->curpg); if (NULL != pgps) { pcolf = &(pgps->attr.col_fill_requested); } else { $? "! curpg" goto finished; } } break; default : { /* Empty by intent */ } break; } if (NULL == pcolf) { $? "! no current page" goto finished; } /* put( */ dk4pppt_kw_out(pppt, 0, backptr, erp); $? ". *backptr = %d", *backptr /* X */ dk4pppt_double_out(pppt, x, backptr, erp); $? ". *backptr = %d", *backptr /* , */ dk4pppt_kw_out(pppt, 1, backptr, erp); $? ". *backptr = %d", *backptr /* Y */ dk4pppt_double_out(pppt, y, backptr, erp); $? ". *backptr = %d", *backptr /* ){ */ dk4pppt_kw_out(pppt, 2, backptr, erp); $? ". *backptr = %d", *backptr if (0 != dorot) { $? ". open rotate box" /* Open rotatebox */ dk4pppt_kw_out(pppt, 27, backptr, erp); $? ". *backptr = %d", *backptr dk4pppt_double_out(pppt, rot, backptr, erp); $? ". *backptr = %d", *backptr dk4pppt_kw_out(pppt, 28, backptr, erp); $? ". *backptr = %d", *backptr } /* Find index of makebox instruction depending on alignment */ switch (va) { case DK4_TEXT_ALIGN_V_TOP : { switch (ha) { case DK4_TEXT_ALIGN_H_CENTERED : { kwi = 11; } break; case DK4_TEXT_ALIGN_H_RIGHT : { kwi = 12; } break; default : { /* left */ kwi = 10; } break; } } break; case DK4_TEXT_ALIGN_V_CENTERED : { switch (ha) { case DK4_TEXT_ALIGN_H_CENTERED : { kwi = 8; } break; case DK4_TEXT_ALIGN_H_RIGHT : { kwi = 9; } break; default : { /* left */ kwi = 7; } break; } } break; default : { /* base or bottom */ switch (ha) { case DK4_TEXT_ALIGN_H_CENTERED : { kwi = 5; } break; case DK4_TEXT_ALIGN_H_RIGHT : { kwi = 6; } break; default : { /* left */ kwi = 4; } break; } } break; } /* Start makebox */ dk4pppt_kw_out(pppt, kwi, backptr, erp); $? ". *backptr = %d", *backptr /* Start smash */ if (DK4_TEXT_ALIGN_V_BASELINE == va) { dk4pppt_kw_out(pppt, 14, backptr, erp); $? ". *backptr = %d", *backptr } /* Start group */ dk4pppt_kw_out(pppt, 15, backptr, erp); $? ". *backptr = %d", *backptr /* Open white box */ if (0 != (DK4_GRA_TEXT_FLAG_WHITE_BOX & flags)) { dk4pppt_kw_out(pppt, 25, backptr, erp); $? ". *backptr = %d", *backptr } /* Color */ if (NULL != colspec) { res = dk4stream_write_char_string(pppt->out.ppt.tms, colspec, erp); if (0 == res) { $? "! backptr" dk4pppt_reset(backptr); $? ". *backptr = %d", *backptr } } else { dk4gratool_stream_color(pppt->out.ppt.tms, pcolf, backptr, erp); $? ". *backptr = %d", *backptr } /* Open oval box */ if (0 != (DK4_GRA_TEXT_FLAG_OVAL_BOX & flags)) { dk4pppt_kw_out(pppt, 26, backptr, erp); $? ". *backptr = %d", *backptr } /* Font */ if (0 != isnt) { dk4pppt_kw_out(pppt, 16, backptr, erp); $? ". *backptr = %d", *backptr dk4gratool_stream_num_alpha(pppt->out.ppt.tms, fontno, backptr, erp); $? ". *backptr = %d", *backptr dk4pppt_kw_out(pppt, 24, backptr, erp); $? ". *backptr = %d", *backptr } /* Text */ if (0 != isnt) { /* normal text */ res = dk4uc2l_string_encoded( pppt->out.ppt.tms, uc2l, (const dkChar *)txt, ie, erp ); if (0 == res) { $? "! backptr" dk4pppt_reset(backptr); $? ". *backptr = %d", *backptr } } else { /* special text */ res = dk4stream_write_char_string( pppt->out.ppt.tms, (const char *)txt, erp ); if (0 == res) { $? "! backptr" dk4pppt_reset(backptr); $? ". *backptr = %d", *backptr } } /* Close oval box */ if (0 != (DK4_GRA_TEXT_FLAG_OVAL_BOX & flags)) { dk4pppt_kw_out(pppt, 13, backptr, erp); $? ". *backptr = %d", *backptr } /* Close white box */ if (0 != (DK4_GRA_TEXT_FLAG_WHITE_BOX & flags)) { dk4pppt_kw_out(pppt, 13, backptr, erp); $? ". *backptr = %d", *backptr } /* End group */ dk4pppt_kw_out(pppt, 13, backptr, erp); $? ". *backptr = %d", *backptr /* End smash */ if (DK4_TEXT_ALIGN_V_BASELINE == va) { dk4pppt_kw_out(pppt, 13, backptr, erp); $? ". *backptr = %d", *backptr } /* End makebox */ dk4pppt_kw_out(pppt, 13, backptr, erp); $? ". *backptr = %d", *backptr if (0 != dorot) { /* End rotatebox */ dk4pppt_kw_out(pppt, 13, backptr, erp); $? ". *backptr = %d", *backptr } /* } newline */ dk4pppt_kw_out(pppt, 3, backptr, erp); $? ". *backptr = %d", *backptr finished: $? "- dk4pppt_i_text *backptr=%d", *backptr return; } void dk4pppt_simple_utf8_text( dk4_pppt_t *pppt, double x, double y, double rot, const char *txt, const char *colspec, dk4_text_align_h_t ha, dk4_text_align_v_t va, int fno, double fsz, dk4_gra_tf_t fex, dk4_uc2l_t *uc2l, int flags, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_simple_utf8_text" #if DK4_USE_ASSERT assert(NULL != pppt); assert(NULL != txt); #endif if ((0 != dk4pppt_is_state_ok(pppt)) && (NULL != txt)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_pgf_simple_utf8_text( pppt->out.pgf, x, y, rot, txt, colspec, ha, va, fno, fsz, fex, uc2l, flags, backptr, erp ); } break; default : { dk4pppt_i_text( pppt, x, y, rot, txt, colspec, DK4_ENCODING_UTF8, ha, va, 1, fno, fsz, fex, uc2l, flags, backptr, erp ); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_simple_utf8_text" } void dk4pppt_simple_text( dk4_pppt_t *pppt, double x, double y, double rot, const dkChar *txt, const char *colspec, int ie, dk4_text_align_h_t ha, dk4_text_align_v_t va, int fno, double fsz, dk4_gra_tf_t fex, dk4_uc2l_t *uc2l, int flags, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_simple_text" #if DK4_USE_ASSERT assert(NULL != pppt); assert(NULL != txt); #endif if ((0 != dk4pppt_is_state_ok(pppt)) && (NULL != txt)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { $? ". pgf output" dk4gra_pgf_simple_text( pppt->out.pgf, x, y, rot, txt, colspec, ie, ha, va, fno, fsz, fex, uc2l, flags, backptr, erp ); } break; default : { $? ". pdf/ps output" dk4pppt_i_text( pppt, x, y, rot, txt, colspec, ie, ha, va, 1, fno, fsz, fex, uc2l, flags, backptr, erp ); } break; } } else { $? "! invalid arguments" dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_simple_text" } void dk4pppt_special_text( dk4_pppt_t *pppt, double x, double y, double rot, const char *txt, const char *colspec, dk4_text_align_h_t ha, dk4_text_align_v_t va, int fno, double fsz, dk4_gra_tf_t fex, int flags, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_special_text" #if DK4_USE_ASSERT assert(NULL != pppt); assert(NULL != txt); #endif if ((0 != dk4pppt_is_state_ok(pppt)) && (NULL != txt)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_pgf_special_text( pppt->out.pgf, x, y, rot, txt, colspec, ha, va, fno, fsz, fex, flags, backptr, erp ); } break; default : { dk4pppt_i_text( pppt, x, y, rot, txt, colspec, DK4_FILE_ENCODING_PLAIN, ha, va, 0, fno, fsz, fex, NULL, flags, backptr, erp ); } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_special_text" } void dk4pppt_set_eorule( dk4_pppt_t *pppt, int val ) { $? "+ dk4pppt_set_eorule" #if DK4_USE_ASSERT assert(NULL != pppt); #endif if (0 != dk4pppt_is_state_ok(pppt)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_set_eorule(pppt->out.pgf, val); } break; default : { dk4gra_set_eorule(pppt->out.ppt.gra, val); } break; } } $? "- dk4pppt_set_eorule" } void dk4pppt_doc_font_size( dk4_pppt_t *pppt, double fs, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_doc_font_size" #if DK4_USE_ASSERT assert(NULL != pppt); assert(0.0 < fs); #endif if ((0 != dk4pppt_is_state_ok(pppt)) && (0.0 < fs)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_pgf_doc_font_size(pppt->out.pgf , fs, backptr, erp); } break; default : { pppt->out.ppt.dfs = fs; } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_doc_font_size" } static void dk4pppt_one_preamble_line( dk4_sto_t **ps, dk4_sto_it_t **pi, size_t *pn, char const *pline, int *backptr, dk4_er_t *erp ) { dk4_gra_preamble_line_t *pl; int back = 0; if (SIZE_MAX > *pn) { if (NULL == *ps) { *ps = dk4sto_open(erp); if (NULL != *ps) { dk4sto_set_comp(*ps, dk4gratool_compare_preamble_lines, 0); } } if (NULL != *ps) { if (NULL == *pi) { *pi = dk4sto_it_open(*ps, erp); } if (NULL != *pi) { pl = dk4gratool_preamble_new(pline, *pn, erp); if (NULL != pl) { if (0 != dk4sto_add(*ps, pl, erp)) { back = 1; } else { dk4gratool_preamble_delete(pl); } } } } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); } if (0 == back) { dk4pppt_reset(backptr); } } void dk4pppt_doc_preamble_line( dk4_pppt_t *pppt, const char *line, int tp, int *backptr, dk4_er_t *erp ) { $? "+ dk4pppt_doc_preamble_line" #if DK4_USE_ASSERT assert(NULL != pppt); assert(NULL != line); #endif if ((0 != dk4pppt_is_state_ok(pppt)) && (NULL != line)) { switch (pppt->dr) { case DK4_PPPT_DR_PGF : { dk4gra_pgf_doc_preamble_line(pppt->out.pgf,line,tp,backptr,erp); } break; default : { switch (tp) { case DK4_GRA_PREAMBLE_FONT : { dk4pppt_one_preamble_line( &(pppt->out.ppt.s_f), &(pppt->out.ppt.i_f), &(pppt->out.ppt.n_f), line, backptr, erp ); } break; case DK4_GRA_PREAMBLE_PACKAGE : { dk4pppt_one_preamble_line( &(pppt->out.ppt.s_p), &(pppt->out.ppt.i_p), &(pppt->out.ppt.n_p), line, backptr, erp ); } break; case DK4_GRA_PREAMBLE_OTHER : { dk4pppt_one_preamble_line( &(pppt->out.ppt.s_o), &(pppt->out.ppt.i_o), &(pppt->out.ppt.n_o), line, backptr, erp ); } break; default : { dk4error_set_simple_error_code( erp, DK4_E_INVALID_ARGUMENTS ); dk4pppt_reset(backptr); } break; } } break; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); dk4pppt_reset(backptr); } $? "- dk4pppt_doc_preamble_line" } /* vim: set ai sw=4 ts=4 : */