diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Postscript.H | 4 | ||||
-rw-r--r-- | src/Postscript.cxx | 76 | ||||
-rw-r--r-- | src/flpsed.cxx | 6 |
3 files changed, 50 insertions, 36 deletions
diff --git a/src/Postscript.H b/src/Postscript.H index 735f72f..62c9513 100644 --- a/src/Postscript.H +++ b/src/Postscript.H @@ -1,5 +1,5 @@ // -// "$Id: Postscript.H,v 1.5 2004/10/26 16:58:49 hofmann Exp $" +// "$Id: Postscript.H,v 1.6 2005/02/28 19:53:58 hofmann Exp $" // // X11 header file for the Fast Light Tool Kit (FLTK). // @@ -74,6 +74,8 @@ class PSWriter { void write_string(FILE *out, char *s); + void write_main_block(FILE *out); + void write_internal_format(FILE *out); int write_text(FILE *out, PSEditText *t); diff --git a/src/Postscript.cxx b/src/Postscript.cxx index b3995aa..fb93423 100644 --- a/src/Postscript.cxx +++ b/src/Postscript.cxx @@ -1,5 +1,5 @@ // -// "$Id: Postscript.cxx,v 1.13 2004/11/10 18:32:59 hofmann Exp $" +// "$Id: Postscript.cxx,v 1.14 2005/02/28 19:53:58 hofmann Exp $" // // Postscript handling routines. // @@ -45,7 +45,7 @@ #define PSEDIT_TEXT_FORMAT_SCAN "%% PSEditWidget: TEXT (%[^)])\n" #define PSEDIT_SIZE_FORMAT "%% PSEditWidget: SIZE %d\n" #define PSEDIT_GLYPH_FORMAT "%% PSEditWidget: GLYPH %s\n" -#define PSEDIT_TAG_FORMAT "%% PSEditWidget: TAG %s\n" +#define PSEDIT_TAG_FORMAT "%% PSEditWidget: TAG %s\n" // // Marker to set page number. This is necessary for viewers like ghostview @@ -197,42 +197,24 @@ int PSWriter::write(FILE *in, FILE *out) { int done=0, page = 1; while (fgets(linebuf, 1024, in) != NULL) { + // Try to write main block before %%EndSetup or %%EndProlog if (!done && - (strncmp(linebuf, "%%EndSetup", 10) == 0 || - strncmp(linebuf, "%%EndProlog", 10) == 0)) { + (strncmp(linebuf, "%%EndSetup", strlen("%%EndSetup")) == 0 || + strncmp(linebuf, "%%EndProlog", strlen("%%EndProlog")) == 0)) { done++; - - fprintf(out, "\n"); - fprintf(out, "%s", PSEDIT_BEGIN); - fprintf(out, "\n"); - - write_internal_format(out); - pos_format = PS_POS_FORMAT; - size_format = PS_SIZE_FORMAT; - text_format = PS_TEXT_FORMAT; - glyph_format = PS_GLYPH_FORMAT; - tag_format = PS_TAG_FORMAT; - - fprintf(out, "\n"); - fprintf(out, ps_header()); - - for (int i=1;i<pse->get_max_pages();i++) { - if (pse->get_text(i)) { - fprintf(out, "dup %d eq { \n", i); - write_text(out, pse->get_text(i)); - fprintf(out, "} if\n"); - } - } - - fprintf(out, ps_trailer()); - fprintf(out, "\n"); - fprintf(out, "%s", PSEDIT_END); - fprintf(out, "\n"); + write_main_block(out); } fprintf(out, "%s", linebuf); - if (strncmp(linebuf, "%%Page:", 7) == 0) { + // Try to write main block after %%BeginProlog + if (!done && + (strncmp(linebuf, "%%BeginProlog", strlen("%%BeginProlog")) == 0)) { + done++; + write_main_block(out); + } + + if (strncmp(linebuf, "%%Page:", strlen("%%Page:")) == 0) { fprintf(out, PSEDIT_PAGE_MARKER, page++); } } @@ -240,6 +222,36 @@ int PSWriter::write(FILE *in, FILE *out) { return 0; } +void PSWriter::write_main_block(FILE *out) { + fprintf(out, "\n"); + fprintf(out, "%s", PSEDIT_BEGIN); + fprintf(out, "\n"); + + write_internal_format(out); + pos_format = PS_POS_FORMAT; + size_format = PS_SIZE_FORMAT; + text_format = PS_TEXT_FORMAT; + glyph_format = PS_GLYPH_FORMAT; + tag_format = PS_TAG_FORMAT; + + fprintf(out, "\n"); + fprintf(out, ps_header()); + + for (int i=1;i<pse->get_max_pages();i++) { + if (pse->get_text(i)) { + fprintf(out, "dup %d eq { \n", i); + write_text(out, pse->get_text(i)); + fprintf(out, "} if\n"); + } + } + + fprintf(out, ps_trailer()); + fprintf(out, "\n"); + fprintf(out, "%s", PSEDIT_END); + fprintf(out, "\n"); +} + + void PSWriter::write_internal_format(FILE *out) { pos_format = PSEDIT_POS_FORMAT; size_format = PSEDIT_SIZE_FORMAT; diff --git a/src/flpsed.cxx b/src/flpsed.cxx index 3c712c2..4e31a57 100644 --- a/src/flpsed.cxx +++ b/src/flpsed.cxx @@ -1,5 +1,5 @@ // -// "$Id: flpsed.cxx,v 1.31 2005/02/28 17:56:51 hofmann Exp $" +// "$Id: flpsed.cxx,v 1.32 2005/02/28 19:53:58 hofmann Exp $" // // flpsed program. // @@ -254,9 +254,9 @@ Fl_Menu_Item menuitems[] = { { "&File", 0, 0, 0, FL_SUBMENU }, { "&Open File...", FL_CTRL + 'o', (Fl_Callback *)open_cb }, { "&Save File as...", FL_CTRL + 's', (Fl_Callback *)save_cb }, - { "Import PDF...", 0, (Fl_Callback *)import_pdf_cb }, - { "Export PDF...", 0, (Fl_Callback *)export_pdf_cb }, { "I&mport Tags from File...", FL_CTRL + 'm', (Fl_Callback *)import_cb }, + { "&Import PDF...", FL_CTRL + 'I', (Fl_Callback *)import_pdf_cb }, + { "&Export PDF...", FL_CTRL + 'E', (Fl_Callback *)export_pdf_cb }, { "&Print...", FL_CTRL + 'p', (Fl_Callback *)print_cb, 0, FL_MENU_DIVIDER }, { "&Quit", FL_CTRL + 'q', (Fl_Callback *)quit_cb, 0 }, { 0 }, |