/* Copyright (C) 2018-2020, Dirk Krause SPDX-License-Identifier: BSD-3-Clause */ /* WARNING: This file was generated by the dkct program (see http://dktools.sourceforge.net/ for details). Changes you make here will be lost if dkct is run again! You should modify the original source and run dkct on it. Original source: dk4graa.ctr */ /** @file dk4graa.c The dk4graa module. */ #line 1052 "dk4graa.ctr" #include "dk4conf.h" #if DK4_HAVE_FCNTL_H #ifndef FCNTL_H_INCLUDED #include #define FCNTL_H_INCLUDED 1 #endif #endif #if DK4_HAVE_IO_H #ifndef IO_H_INCLUDED #include #define IO_H_INCLUDED 1 #endif #endif #ifndef DK4GRAA_H_INCLUDED #include "dk4graa.h" #endif #ifndef DK4GRALO_H_INCLUDED #include "dk4gralo.h" #endif #ifndef DK4BIF_H_INCLUDED #include "dk4bif.h" #endif #ifndef DK4BIFAP_H_INCLUDED #include "dk4bifap.h" #endif #ifndef DK4FOPDA_H_INCLUDED #include "dk4fopda.h" #endif #ifndef DK4ISADM_H_INCLUDED #include "dk4isadm.h" #endif #ifndef DK4_UNUSED_H_INCLUDED #include "dk4unused.h" #endif #line 1100 "dk4graa.ctr" /** Error codes in error counting to avoid repeated error messages. */ enum { /** Failed to add graphics contents. */ E_ADD_CONTENTS = 1 , /** Failed to change graphics setup. */ E_CHANGE_SETUP , /** Failed to write graphics contents to file. */ E_WRITE_FILE , /** Image type not supported for PGF output. */ E_PGF_IMAGE_TYPE , }; /** Show error message. @param app Application structure. @param fn Name of file to print with error message. @param erp Error report, used for details. @param si Index of primary message text in dk4gra_app_kw array. */ static void dk4gra_app_error( dk4_app_t *app, dkChar const *fn, dk4_er_t const *erp, size_t si ) { const dkChar * const *msg = NULL; dkChar const *oldsourcefile = NULL; dk4_um_t oldsourceline = 0UL; size_t szmsg = 0; #line 1144 "dk4graa.ctr" /* Find localized message texts */ szmsg = dk4gralog_sz_localized_texts(); msg = dk4gralog_localized_texts(app); /* Save source file and line */ oldsourcefile = dk4app_get_log_source_file(app); oldsourceline = dk4app_get_log_source_line(app); /* Set source file and line */ dk4app_set_log_source_file(app, fn); dk4app_set_log_source_line(app, (dk4_um_t)0UL); /* Show error message, provide details if possible */ dk4app_log_1(app, msg, szmsg, DK4_LL_ERROR, si); switch (erp->ec) { case DK4_E_INVALID_ARGUMENTS : { dk4app_log_1(app, msg, szmsg, DK4_LL_ERROR, 1); } break; case DK4_E_MATH_OVERFLOW : { dk4app_log_1(app, msg, szmsg, DK4_LL_ERROR, 2); } break; case DK4_E_MEMORY_ALLOCATION_FAILED : { dk4app_log_base1(app, DK4_LL_ERROR, 90); } break; case DK4_E_WRITE_FAILED : { dk4app_log_1(app, msg, szmsg, DK4_LL_ERROR, 3); } break; case DK4_E_FLUSH_FAILED : { dk4app_log_1(app, msg, szmsg, DK4_LL_ERROR, 4); } break; case DK4_E_CLOSE_FAILED : { dk4app_log_1(app, msg, szmsg, DK4_LL_ERROR, 4); } break; } /* Restore old source file and line */ dk4app_set_log_source_file(app, oldsourcefile); dk4app_set_log_source_line(app, oldsourceline); #line 1188 "dk4graa.ctr" } /** Check whether or not to print current error message. We want to avoid repeating the same message again and again. */ static int dk4gra_app_check_error( dk4_gra_t *gra, int ce, int ec ) { int back = 0; #line 1205 "dk4graa.ctr" if (NULL != gra) { if ((gra->le == ce) && (gra->lec == ec)) { #line 1207 "dk4graa.ctr" if (4 > gra->len) { #line 1208 "dk4graa.ctr" back = 1; gra->len += 1; } } else { #line 1213 "dk4graa.ctr" back = 1; gra->le = ce; gra->lec = ec; gra->len = 0; } } else { #line 1220 "dk4graa.ctr" back = 1; } #line 1223 "dk4graa.ctr" return back; } dk4_gra_t * dk4gra_app_open_pdf( const dkChar *fn, size_t w, size_t h, int docfl, dk4_app_t *app ) { dk4_er_t er; dk4_gra_t *back = NULL; #line 1240 "dk4graa.ctr" dk4error_init(&er); back = dk4gra_open_pdf(fn, w, h, docfl, &er); if ((NULL == back) && (NULL != app)) { dk4gra_app_error(app, fn, &er, 52); } #line 1246 "dk4graa.ctr" return back; } dk4_gra_t * dk4gra_app_open_ps( const dkChar *fn, size_t w, size_t h, int docfl, dk4_app_t *app ) { dk4_er_t er; dk4_gra_t *back = NULL; #line 1262 "dk4graa.ctr" dk4error_init(&er); back = dk4gra_open_ps(fn, w, h, docfl, &er); if ((NULL == back) && (NULL != app)) { dk4gra_app_error(app, fn, &er, 52); } #line 1268 "dk4graa.ctr" return back; } dk4_gra_t * dk4gra_app_open_pgf( const dkChar *fn, size_t w, size_t h, int docfl, int sa, dk4_app_t *app ) { dk4_er_t er; dk4_gra_t *back = NULL; #line 1286 "dk4graa.ctr" dk4error_init(&er); back = dk4gra_open_pgf(fn, w, h, docfl, sa, &er); if ((NULL == back) && (NULL != app)) { dk4gra_app_error(app, fn, &er, 52); } #line 1292 "dk4graa.ctr" return back; } void dk4gra_app_write_file_and_close( FILE *fout, dk4_gra_t *gra, int *backptr, dk4_app_t * DK4_ARG_UNUSED(app) ) { dk4_er_t er; #if 0 dkChar *fn = NULL; #endif int back = 1; DK4_UNUSED_ARG(app) #line 1312 "dk4graa.ctr" dk4error_init(&er); dk4gra_write_file_and_close(fout, gra, &back, &er); gra = NULL; if (0 == back) { #line 1316 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } #if 0 if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_WRITE_FILE, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 59); } } #endif } #line 1327 "dk4graa.ctr" } void dk4gra_app_write_and_close( dk4_gra_t *gra, int *backptr, dk4_app_t *app ) { dk4_er_t er; FILE *fout = NULL; int tests = DK4_FOPEN_SC_USER; int back = 0; int invala = 0; #if DK4_ON_WINDOWS int oldm = _O_TEXT; #endif #line 1347 "dk4graa.ctr" if (NULL != gra) { if ((NULL != gra->s_pages) && (NULL != gra->i_pages)) { if ((0 != gra->pages) && (NULL != gra->curpg)) { if (NULL != gra->fn) { #line 1352 "dk4graa.ctr" if (0 != dk4isadmin()) { tests = DK4_FOPEN_SC_PRIVILEGED; } fout = dk4fopen_app(gra->fn, dkT("wb"), tests, app); if (NULL != fout) { #line 1355 "dk4graa.ctr" back = 1; dk4gra_app_write_file_and_close(fout, gra, &back, app); gra = NULL; dk4error_init(&er); if (0 != fclose(fout)) { dk4error_set_simple_error_code( &er, DK4_E_CLOSE_FAILED ); back = 0; #if 0 /* 2019-03-06 Graphics is closed, we can not access components. */ if (NULL != app) { if ( 0 != dk4gra_app_check_error( gra, E_WRITE_FILE, er.ec ) ) { dk4gra_app_error(app, gra->fn, &er, 59); } } #endif } } else { #line 1383 "dk4graa.ctr" dk4gra_close(gra); gra = NULL; } } else { #line 1388 "dk4graa.ctr" back = 1; #if DK4_ON_WINDOWS oldm = _setmode(_fileno(stdout), _O_BINARY); #endif dk4gra_app_write_file_and_close(stdout, gra, &back, app); gra = NULL; #if DK4_ON_WINDOWS _setmode(_fileno(stdout), oldm); #endif } } else { /* ERROR: Invalid arguments */ invala = 1; dk4gra_close(gra); gra = NULL; } } else { /* ERROR: Invalid arguments */ invala = 1; dk4gra_close(gra); gra = NULL; } } else { /* ERROR: Invalid arguments */ invala = 1; } if (0 != invala) { /* ERROR: Invalid arguments */ dk4error_init(&er); dk4error_set_simple_error_code(&er, DK4_E_INVALID_ARGUMENTS); if (NULL != app) { #if 0 /* 2019-03-06 Graphics is closed, we can no longer access components. */ if (0 != dk4gra_app_check_error(gra, E_WRITE_FILE, er.ec)) { dk4gra_app_error(app, gra->fn, &er, 59); } #endif } } #line 1433 "dk4graa.ctr" if ((NULL != backptr) && (0 == back)) { *backptr = 0; } } void dk4gra_app_set_color_conversion( dk4_gra_t *gra, dk4_cs_conv_ctx_t const *ctx, int *backptr, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 1450 "dk4graa.ctr" dk4error_init(&er); dk4gra_set_color_conversion(gra, ctx, &back, &er); if (0 == back) { #line 1453 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_CHANGE_SETUP, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 58); } } } #line 1462 "dk4graa.ctr" } void dk4gra_app_page( dk4_gra_t *gra, int *backptr, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 1477 "dk4graa.ctr" dk4error_init(&er); dk4gra_page(gra, &back, &er); if (0 == back) { #line 1480 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } #line 1489 "dk4graa.ctr" } void dk4gra_app_page_with_flags( dk4_gra_t *gra, int flags, int *backptr, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 1505 "dk4graa.ctr" dk4error_init(&er); dk4gra_page_with_flags(gra, flags, &back, &er); if (0 == back) { #line 1508 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } #line 1517 "dk4graa.ctr" } void dk4gra_app_set_gs_for_pattern_only( dk4_gra_t *gra, int val, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; #line 1531 "dk4graa.ctr" dk4error_init(&er); dk4gra_set_gs_for_pattern_only(gra, val, &er); if (0 != er.ec) { #line 1534 "dk4graa.ctr" if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_CHANGE_SETUP, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 58); } } } #line 1542 "dk4graa.ctr" } void dk4gra_app_gsave( dk4_gra_t *gra, int *backptr, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 1557 "dk4graa.ctr" dk4error_init(&er); dk4gra_gsave(gra, &back, &er); if (0 == back) { #line 1560 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } #line 1569 "dk4graa.ctr" } void dk4gra_app_grestore( dk4_gra_t *gra, int *backptr, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 1584 "dk4graa.ctr" dk4error_init(&er); dk4gra_grestore(gra, &back, &er); if (0 == back) { #line 1587 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } #line 1596 "dk4graa.ctr" } void dk4gra_app_set_line_width( dk4_gra_t *gra, double lw, int *backptr, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 1612 "dk4graa.ctr" dk4error_init(&er); dk4gra_set_line_width(gra, lw, &back, &er); if (0 == back) { #line 1615 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } #line 1624 "dk4graa.ctr" } void dk4gra_app_set_line_style( dk4_gra_t *gra, dk4_gra_ls_t ls, double sv, int *backptr, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 1641 "dk4graa.ctr" dk4error_init(&er); dk4gra_set_line_style(gra, ls, sv, &back, &er); if (0 == back) { #line 1644 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } #line 1653 "dk4graa.ctr" } void dk4gra_app_set_line_cap( dk4_gra_t *gra, dk4_gra_lc_t lc, int *backptr, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 1669 "dk4graa.ctr" dk4error_init(&er); dk4gra_set_line_cap(gra, lc, &back, &er); if (0 == back) { #line 1672 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } #line 1681 "dk4graa.ctr" } void dk4gra_app_set_line_join( dk4_gra_t *gra, dk4_gra_lj_t lj, double ml, int *backptr, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 1698 "dk4graa.ctr" dk4error_init(&er); dk4gra_set_line_join(gra, lj, ml, &back, &er); if (0 == back) { #line 1701 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } #line 1710 "dk4graa.ctr" } void dk4gra_app_set_fill_gray( dk4_gra_t *gra, double g, int *backptr, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 1726 "dk4graa.ctr" dk4error_init(&er); dk4gra_set_fill_gray(gra, g, &back, &er); if (0 == back) { #line 1729 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } #line 1738 "dk4graa.ctr" } void dk4gra_app_set_fill_rgb( dk4_gra_t *gra, double r, double g, double b, int *backptr, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 1756 "dk4graa.ctr" dk4error_init(&er); dk4gra_set_fill_rgb(gra, r, g, b, &back, &er); if (0 == back) { #line 1759 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } #line 1768 "dk4graa.ctr" } void dk4gra_app_set_fill_cmyk( dk4_gra_t *gra, double c, double m, double y, double k, int *backptr, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 1787 "dk4graa.ctr" dk4error_init(&er); dk4gra_set_fill_cmyk(gra, c, m, y, k, &back, &er); if (0 == back) { #line 1790 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } #line 1799 "dk4graa.ctr" } void dk4gra_app_set_stroke_gray( dk4_gra_t *gra, double g, int *backptr, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 1815 "dk4graa.ctr" dk4error_init(&er); dk4gra_set_stroke_gray(gra, g, &back, &er); if (0 == back) { #line 1818 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } #line 1827 "dk4graa.ctr" } void dk4gra_app_set_stroke_rgb( dk4_gra_t *gra, double r, double g, double b, int *backptr, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 1845 "dk4graa.ctr" dk4error_init(&er); dk4gra_set_stroke_rgb(gra, r, g, b, &back, &er); if (0 == back) { #line 1848 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } #line 1857 "dk4graa.ctr" } void dk4gra_app_set_stroke_cmyk( dk4_gra_t *gra, double c, double m, double y, double k, int *backptr, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 1876 "dk4graa.ctr" dk4error_init(&er); dk4gra_set_stroke_cmyk(gra, c, m, y, k, &back, &er); if (0 == back) { #line 1879 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } #line 1888 "dk4graa.ctr" } void dk4gra_app_prepare_fill( dk4_gra_t *gra, int *backptr, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 1904 "dk4graa.ctr" dk4error_init(&er); dk4gra_prepare_fill(gra, &back, &er); if (0 == back) { #line 1907 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } #line 1916 "dk4graa.ctr" } void dk4gra_app_prepare_stroke( dk4_gra_t *gra, int *backptr, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 1931 "dk4graa.ctr" dk4error_init(&er); dk4gra_prepare_stroke(gra, &back, &er); if (0 == back) { #line 1934 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } #line 1943 "dk4graa.ctr" } void dk4gra_app_prepare_fill_and_stroke( dk4_gra_t *gra, int *backptr, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 1958 "dk4graa.ctr" dk4error_init(&er); dk4gra_prepare_fill_and_stroke(gra, &back, &er); if (0 == back) { #line 1961 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } #line 1970 "dk4graa.ctr" } void dk4gra_app_fill( dk4_gra_t *gra, int *backptr, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 1986 "dk4graa.ctr" dk4error_init(&er); dk4gra_fill(gra, &back, &er); if (0 == back) { #line 1989 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } #line 1998 "dk4graa.ctr" } void dk4gra_app_stroke( dk4_gra_t *gra, int *backptr, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 2013 "dk4graa.ctr" dk4error_init(&er); dk4gra_stroke(gra, &back, &er); if (0 == back) { #line 2016 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } #line 2025 "dk4graa.ctr" } void dk4gra_app_fill_and_stroke( dk4_gra_t *gra, int *backptr, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 2040 "dk4graa.ctr" dk4error_init(&er); dk4gra_fill_and_stroke(gra, &back, &er); if (0 == back) { #line 2043 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } #line 2052 "dk4graa.ctr" } void dk4gra_app_clip( dk4_gra_t *gra, int *backptr, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 2067 "dk4graa.ctr" dk4error_init(&er); dk4gra_clip(gra, &back, &er); if (0 == back) { #line 2070 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } #line 2079 "dk4graa.ctr" } void dk4gra_app_pattern( dk4_gra_t *gra, double xl, double xr, double yb, double yt, dk4_gra_pattern_t pn, int *backptr, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 2099 "dk4graa.ctr" dk4error_init(&er); dk4gra_pattern(gra, xl, xr, yb, yt, pn, &back, &er); if (0 == back) { #line 2102 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } #line 2111 "dk4graa.ctr" } void dk4gra_app_newpath_moveto( dk4_gra_t *gra, double x, double y, dk4_bb_t *bbptr, int *backptr, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 2130 "dk4graa.ctr" dk4error_init(&er); dk4gra_newpath_moveto(gra, x, y, bbptr, &back, &er); if (0 == back) { #line 2133 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } #line 2142 "dk4graa.ctr" } void dk4gra_app_lineto( dk4_gra_t *gra, double x, double y, dk4_bb_t *bbptr, int *backptr, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 2160 "dk4graa.ctr" dk4error_init(&er); dk4gra_lineto(gra, x, y, bbptr, &back, &er); if (0 == back) { #line 2163 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } #line 2172 "dk4graa.ctr" } void dk4gra_app_curveto( dk4_gra_t *gra, double xc1, double yc1, double xc2, double yc2, double x, double y, dk4_bb_t *bbptr, int *backptr, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 2194 "dk4graa.ctr" dk4error_init(&er); dk4gra_curveto(gra, xc1, yc1, xc2, yc2, x, y, bbptr, &back, &er); if (0 == back) { #line 2197 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } #line 2206 "dk4graa.ctr" } void dk4gra_app_closepath( dk4_gra_t *gra, int *backptr, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 2221 "dk4graa.ctr" dk4error_init(&er); dk4gra_closepath(gra, &back, &er); if (0 == back) { #line 2224 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } #line 2233 "dk4graa.ctr" } void dk4gra_app_circle( dk4_gra_t *gra, double xc, double yc, double r, dk4_bb_t *bbptr, int *backptr, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 2252 "dk4graa.ctr" dk4error_init(&er); dk4gra_circle(gra, xc, yc, r, bbptr, &back, &er); if (0 == back) { #line 2255 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } #line 2264 "dk4graa.ctr" } void dk4gra_app_rectangle( dk4_gra_t *gra, double xl, double xr, double yb, double yt, double r, dk4_bb_t *bbptr, int *backptr, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 2285 "dk4graa.ctr" dk4error_init(&er); dk4gra_rectangle(gra, xl, xr, yb, yt, r, bbptr, &back, &er); if (0 == back) { #line 2288 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } #line 2297 "dk4graa.ctr" } void dk4gra_app_arc( dk4_gra_t *gra, double xc, double yc, double ra, double start, double end, int cl, dk4_bb_t *bbptr, int *backptr, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 2319 "dk4graa.ctr" dk4error_init(&er); dk4gra_arc(gra, xc, yc, ra, start, end, cl, bbptr, &back, &er); if (0 == back) { #line 2322 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } #line 2331 "dk4graa.ctr" } void dk4gra_app_ellipse( dk4_gra_t *gra, double xc, double yc, double rx, double ry, double rot, dk4_bb_t *bbptr, int *backptr, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 2352 "dk4graa.ctr" dk4error_init(&er); dk4gra_ellipse(gra, xc, yc, rx, ry, rot, bbptr, &back, &er); if (0 == back) { #line 2355 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } #line 2364 "dk4graa.ctr" } void dk4gra_app_pgf_simple_text( dk4_gra_t *gra, 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_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 2392 "dk4graa.ctr" dk4error_init(&er); dk4gra_pgf_simple_text( gra, x, y, rot, txt, colspec, ie, ha, va, fno, fsz, fex, uc2l, flags, &back, &er ); if (0 == back) { #line 2398 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } #line 2407 "dk4graa.ctr" } void dk4gra_app_pgf_special_text( dk4_gra_t *gra, 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_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 2433 "dk4graa.ctr" dk4error_init(&er); dk4gra_pgf_special_text( gra, x, y, rot, txt, colspec, ha, va, fno, fsz, fex, flags, &back, &er ); if (0 == back) { #line 2438 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } #line 2447 "dk4graa.ctr" } /** Check whether the graphics driver supports the image type. @param gra Graphics output structure. @param bif Bitmap image file. @return 1 if image type is supported, 0 otherwise. */ static int dk4gra_app_check_driver_and_image_type( dk4_gra_t const *gra, dk4_bif_t const *bif ) { int back = 0; #line 2464 "dk4graa.ctr" if ((NULL != gra) && (NULL != bif)) { back = 1; switch (gra->dr) { case DK4_GRA_DRIVER_PGF : { switch (dk4bif_get_image_type(bif)) { case DK4_BIF_TYPE_NETPBM : case DK4_BIF_TYPE_TIFF : { back = 0; } break; } } break; } } #line 2477 "dk4graa.ctr" return back; } void dk4gra_app_bif_cotra_image( dk4_gra_t *gra, double *cotra, dk4_bif_t *bif, const dkChar *fn, size_t fno, int ifl, int *backptr, dk4_app_t *app ) { dk4_er_t er; int back = 1; #line 2497 "dk4graa.ctr" dk4error_init(&er); if (0 != dk4gra_app_check_driver_and_image_type(gra, bif)) { dk4gra_bif_cotra_image( gra, cotra, bif, fn, fno, ifl, &back, &er ); if (0 == back) { #line 2504 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } } else { #line 2515 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_PGF_IMAGE_TYPE, 0)) { if (NULL != bif) { fn = bif->filename; } dk4gra_app_error(app, fn, &er, 60); } } } #line 2524 "dk4graa.ctr" } void dk4gra_app_bif_fig_image( dk4_gra_t *gra, 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_app_t *app ) { dk4_er_t er; int back = 1; #line 2548 "dk4graa.ctr" dk4error_init(&er); if (0 != dk4gra_app_check_driver_and_image_type(gra, bif)) { dk4gra_bif_fig_image( gra, xl, xr, yb, yt, bif, fn, fno, pos, ifl, bbptr, &back, &er ); if (0 == back) { #line 2555 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { #line 2557 "dk4graa.ctr" if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { #line 2559 "dk4graa.ctr" if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } } else { #line 2566 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { #line 2568 "dk4graa.ctr" if (0 != dk4gra_app_check_error(gra, E_PGF_IMAGE_TYPE, 0)) { #line 2570 "dk4graa.ctr" if (NULL != bif) { fn = bif->filename; } dk4gra_app_error(app, fn, &er, 60); } } } #line 2576 "dk4graa.ctr" } void dk4gra_app_bif_image( dk4_gra_t *gra, 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_app_t *app ) { dk4_er_t er; int back = 1; #line 2599 "dk4graa.ctr" dk4error_init(&er); if (0 != dk4gra_app_check_driver_and_image_type(gra, bif)) { dk4gra_bif_image( gra, xl, xr, yb, yt, bif, fn, fno, ifl, bbptr, &back, &er ); if (0 == back) { #line 2606 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { #line 2608 "dk4graa.ctr" if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { #line 2610 "dk4graa.ctr" if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 57); } } } } else { #line 2617 "dk4graa.ctr" if (NULL != backptr) { *backptr = 0; } if (NULL != app) { #line 2619 "dk4graa.ctr" if (0 != dk4gra_app_check_error(gra, E_PGF_IMAGE_TYPE, 0)) { #line 2621 "dk4graa.ctr" if (NULL != bif) { fn = bif->filename; } dk4gra_app_error(app, fn, &er, 60); } } } #line 2627 "dk4graa.ctr" } void dk4gra_app_image( dk4_gra_t *gra, 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_app_t *app ) { dk4_er_t er; dk4_bif_t *bifptr = NULL; /* Bitmap image */ int back = 0; /* Function result */ int ho = 0; /* Flag: Read image header only */ #line 2652 "dk4graa.ctr" #line 2653 "dk4graa.ctr" #line 2654 "dk4graa.ctr" #line 2655 "dk4graa.ctr" #line 2656 "dk4graa.ctr" #line 2657 "dk4graa.ctr" #line 2658 "dk4graa.ctr" #line 2659 "dk4graa.ctr" #line 2660 "dk4graa.ctr" #line 2661 "dk4graa.ctr" #line 2662 "dk4graa.ctr" #line 2663 "dk4graa.ctr" #line 2664 "dk4graa.ctr" #line 2665 "dk4graa.ctr" #line 2666 "dk4graa.ctr" #line 2667 "dk4graa.ctr" #line 2668 "dk4graa.ctr" #line 2669 "dk4graa.ctr" #line 2670 "dk4graa.ctr" #line 2671 "dk4graa.ctr" #line 2672 "dk4graa.ctr" if ((NULL != gra) && (NULL != fn) && (xr > xl) && (yt > yb)) { /* Register coordinates in bounding box */ if (NULL != bbptr) { dk4bb_add_x(bbptr, xl); dk4bb_add_x(bbptr, xr); dk4bb_add_y(bbptr, yb); dk4bb_add_y(bbptr, yt); } /* Set header-only flag for opening BIF */ if (DK4_GRA_DRIVER_PGF == gra->dr) { ho = 1; } if ( (0 != (DK4_GRA_IMG_FLAG_DCT & ifl)) && (DK4_BIF_TYPE_JPEG == dk4bif_type_for_suffix(fn)) ) { if (0 != (DK4_GRA_IMG_FLAG_COLOR & ifl)) { ho = 1; } } /* Open bitmap image file */ bifptr = dk4bif_open_app(fn, ho, ctx, app); if (NULL != bifptr) { back = 1; dk4gra_app_bif_image( gra, xl, xr, yb, yt, bifptr, fn, fno, ifl, bbptr, &back, app ); #line 2704 "dk4graa.ctr" dk4bif_close(bifptr); } } else { /* ERROR: Invalid arguments */ dk4error_init(&er); dk4error_set_simple_error_code(&er, DK4_E_INVALID_ARGUMENTS); if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { dk4gra_app_error(app, fn, &er, 57); } } } if ((0 == back) && (NULL != backptr)) { *backptr = 0; } #line 2719 "dk4graa.ctr" } void dk4gra_app_fig_image( dk4_gra_t *gra, 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_app_t *app ) { dk4_er_t er; dk4_bif_t *bifptr = NULL; int ho = 0; int back = 0; #line 2745 "dk4graa.ctr" #line 2746 "dk4graa.ctr" #line 2747 "dk4graa.ctr" #line 2748 "dk4graa.ctr" #line 2749 "dk4graa.ctr" #line 2750 "dk4graa.ctr" #line 2751 "dk4graa.ctr" #line 2752 "dk4graa.ctr" #line 2753 "dk4graa.ctr" #line 2754 "dk4graa.ctr" #line 2755 "dk4graa.ctr" #line 2756 "dk4graa.ctr" #line 2757 "dk4graa.ctr" #line 2758 "dk4graa.ctr" #line 2759 "dk4graa.ctr" #line 2760 "dk4graa.ctr" #line 2761 "dk4graa.ctr" #line 2762 "dk4graa.ctr" #line 2763 "dk4graa.ctr" #line 2764 "dk4graa.ctr" #line 2765 "dk4graa.ctr" if ((NULL != gra) && (NULL != fn) && (xr > xl) && (yt > yb)) { if (NULL != bbptr) { dk4bb_add_x(bbptr, xl); dk4bb_add_x(bbptr, xr); dk4bb_add_y(bbptr, yb); dk4bb_add_y(bbptr, yt); } if (DK4_GRA_DRIVER_PGF == gra->dr) { ho = 1; } if ( (0 != (DK4_GRA_IMG_FLAG_DCT & ifl)) && (DK4_BIF_TYPE_JPEG == dk4bif_type_for_suffix(fn)) ) { if (0 != (DK4_GRA_IMG_FLAG_COLOR & ifl)) { ho = 1; } } bifptr = dk4bif_open_app(fn, ho, ctx, app); if (NULL != bifptr) { back = 1; dk4gra_app_bif_fig_image( gra, xl, xr, yb, yt, bifptr, fn, fno, pos, ifl, bbptr, &back, app ); #line 2790 "dk4graa.ctr" dk4bif_close(bifptr); } } else { /* ERROR: Invalid arguments */ dk4error_init(&er); dk4error_set_simple_error_code(&er, DK4_E_INVALID_ARGUMENTS); if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_ADD_CONTENTS, er.ec)) { dk4gra_app_error(app, fn, &er, 57); } } } #line 2804 "dk4graa.ctr" if ((NULL != backptr) && (0 == back)) { *backptr = 0; } } void dk4gra_app_pgf_doc_font_size( dk4_gra_t *gra, double fs, int *backptr, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 2820 "dk4graa.ctr" dk4error_init(&er); dk4gra_pgf_doc_font_size(gra, fs, &back, &er); if (0 == back) { if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_CHANGE_SETUP, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 58); } } } #line 2832 "dk4graa.ctr" } void dk4gra_app_pgf_doc_preamble_line( dk4_gra_t *gra, const char *line, int tp, int *backptr, dk4_app_t *app ) { dk4_er_t er; dkChar *fn = NULL; int back = 1; #line 2849 "dk4graa.ctr" dk4error_init(&er); dk4gra_pgf_doc_preamble_line(gra, line, tp, &back, &er); if (0 == back) { if (NULL != backptr) { *backptr = 0; } if (NULL != app) { if (0 != dk4gra_app_check_error(gra, E_CHANGE_SETUP, er.ec)) { if (NULL != gra) { fn = gra->fn; } dk4gra_app_error(app, fn, &er, 58); } } } #line 2861 "dk4graa.ctr" } /* vim: set ai sw=4 ts=4 : */