summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Hofmann <johannes.hofmann@gmx.de>2005-02-28 18:53:58 +0000
committerJohannes Hofmann <johannes.hofmann@gmx.de>2005-02-28 18:53:58 +0000
commit640d4d4bf9f088b9d7f0fab415bec4ba26f8439f (patch)
treefe5cec314f534e46d4fc75667620326c8e72ca98
parent886a904459e87f46f3f43df434307a294f85e52d (diff)
fix Postscript for some sort of docs by putting PSEditWidget block directly after %%BeginProlog
fix Postscript for some sort of docs by putting PSEditWidget block directly after %%BeginProlog
-rw-r--r--NEWS7
-rw-r--r--src/Postscript.H4
-rw-r--r--src/Postscript.cxx76
-rw-r--r--src/flpsed.cxx6
4 files changed, 57 insertions, 36 deletions
diff --git a/NEWS b/NEWS
index 1043a42..8191142 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,13 @@
flpsed ChangeLog
=================
+flpsed-0.3.3
+ - Implement PDF import/export based on pdftops and ps2pdf.
+ - Fix segfault when using arrow keys on empty document
+ (reported by Arho Virkki).
+ - Remove beeping sound (requested by Arho Virkki).
+ - Fix PostScript output for certain documents (reported by Petr Baum).
+
flpsed-0.3.2
- Implement zooming (thanks to Jochen Eisinger for the suggestion).
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 },