summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2008-08-26 01:20:01 +0000
committerChris Young <chris@unsatisfactorysoftware.co.uk>2008-08-26 01:20:01 +0000
commit74f9c0e07568c37eeac373471d2ed9796a486638 (patch)
tree320ff4db9cc65eda66a0903200db5489b0d57c57
parent553c4aac8bf369ae7b9a61e702279b7ef55eae44 (diff)
downloadnetsurf-74f9c0e07568c37eeac373471d2ed9796a486638.tar.gz
netsurf-74f9c0e07568c37eeac373471d2ed9796a486638.tar.bz2
Added PDF export to Amiga port.
svn path=/trunk/netsurf/; revision=5203
-rw-r--r--Makefile.config4
-rw-r--r--Makefile.sources4
-rwxr-xr-xamiga/gui.c31
-rwxr-xr-xamiga/menu.c40
-rwxr-xr-xamiga/menu.h4
-rw-r--r--amiga/save_pdf.c60
-rw-r--r--amiga/save_pdf.h31
7 files changed, 152 insertions, 22 deletions
diff --git a/Makefile.config b/Makefile.config
index 85685a2e5..8c5946e2a 100644
--- a/Makefile.config
+++ b/Makefile.config
@@ -151,10 +151,6 @@ ifeq ($(TARGET),amiga)
# Valid options: YES, NO, AUTO
NETSURF_USE_ROSPRITE := YES
- # Use libharu to enable PDF export and GTK printing support.
- # Valid options: YES, NO
- NETSURF_USE_HARU_PDF := NO
-
# Enable using Hubbub to parse HTML rather than libxml2
# Valid options: YES, NO, AUTO
NETSURF_USE_HUBBUB := YES
diff --git a/Makefile.sources b/Makefile.sources
index 998eafc2c..3f5b660c2 100644
--- a/Makefile.sources
+++ b/Makefile.sources
@@ -85,7 +85,7 @@ S_DEBUG := netsurfd.c debug_bitmap.c filetyped.c fontd.c
S_DEBUG := $(addprefix debug/,$(S_DEBUG))
# S_AMIGA are sources purely for the Amiga build
-S_AMIGA := compat.c gui.c tree.c history.c hotlist.c schedule.c thumbnail.c misc.c bitmap.c font.c filetype.c utf8.c login.c plotters.c object.c menu.c
+S_AMIGA := compat.c gui.c tree.c history.c hotlist.c schedule.c thumbnail.c misc.c bitmap.c font.c filetype.c utf8.c login.c plotters.c object.c menu.c save_pdf.c
S_AMIGA := $(addprefix amiga/,$(S_AMIGA))
# Some extra rules for building the scanner etc.
@@ -156,7 +156,7 @@ EXETARGET := nsdebug
endif
ifeq ($(TARGET),amiga)
-SOURCES := $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_AMIGA)
+SOURCES := $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_AMIGA) $(S_PDF)
EXETARGET := NetSurf
endif
diff --git a/amiga/gui.c b/amiga/gui.c
index 641c4a05d..31263083e 100755
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -476,7 +476,33 @@ void ami_get_msg(void)
bw = browser_window_create(gwin->bw->current_content->url, 0, 0, true, false);
break;
- case 2: // close
+ case 2: // save
+ switch(subnum)
+ {
+ BPTR fh=0;
+
+ case 0:
+ save_as_text(gwin->bw->current_content,"ram:ns_text");
+ break;
+
+ case 1:
+ if(fh = FOpen("ram:ns_source",MODE_NEWFILE,0))
+ {
+ FWrite(fh,gwin->bw->current_content->source_data,1,gwin->bw->current_content->source_size);
+ FClose(fh);
+ }
+ break;
+
+ case 2:
+#ifdef WITH_PDF_EXPORT
+ pdf_set_scale(DEFAULT_EXPORT_SCALE);
+ save_as_pdf(gwin->bw->current_content,"ram:ns_pdf");
+#endif
+ break;
+ }
+ break;
+
+ case 4: // close
browser_window_destroy(gwin->bw);
break;
}
@@ -1000,6 +1026,8 @@ void gui_window_update_box(struct gui_window *g,
xoffset=bbox->Left;
yoffset=bbox->Top;
+ plot=amiplot;
+
// if (c->type == CONTENT_HTML) scale = 1;
content_redraw(data->redraw.object,
@@ -1061,6 +1089,7 @@ LAYA_MinX,0,LAYA_MinY,0,LAYA_MaxX,1024,LAYA_MaxY,768,TAG_DONE);
height=bbox->Height;
xoffset=bbox->Left;
yoffset=bbox->Top;
+ plot = amiplot;
// if (c->type == CONTENT_HTML) scale = 1;
diff --git a/amiga/menu.c b/amiga/menu.c
index 172316e6d..8848541ca 100755
--- a/amiga/menu.c
+++ b/amiga/menu.c
@@ -37,18 +37,23 @@ void ami_init_menulabs(void)
menulab[0] = ami_utf8_easy((char *)messages_get("Project"));
menulab[1] = ami_utf8_easy((char *)messages_get("NewWindow"));
menulab[2] = NM_BARLABEL;
- menulab[3] = ami_utf8_easy((char *)messages_get("CloseWindow"));
- menulab[4] = ami_utf8_easy((char *)messages_get("Edit"));
- menulab[5] = ami_utf8_easy((char *)messages_get("Copy"));
- menulab[6] = ami_utf8_easy((char *)messages_get("Paste"));
- menulab[7] = ami_utf8_easy((char *)messages_get("SelectAll"));
- menulab[8] = ami_utf8_easy((char *)messages_get("Clear"));
- menulab[9] = ami_utf8_easy((char *)messages_get("Hotlist"));
- menulab[10] = ami_utf8_easy((char *)messages_get("HotlistAdd"));
- menulab[11] = ami_utf8_easy((char *)messages_get("HotlistShow"));
- menulab[12] = ami_utf8_easy((char *)messages_get("Settings"));
- menulab[13] = ami_utf8_easy((char *)messages_get("SnapshotWindow"));
- menulab[14] = ami_utf8_easy((char *)messages_get("SettingsSave"));
+ menulab[3] = ami_utf8_easy((char *)messages_get("SaveAs"));
+ menulab[4] = ami_utf8_easy((char *)messages_get("Text"));
+ menulab[5] = ami_utf8_easy((char *)messages_get("Source"));
+ menulab[6] = ami_utf8_easy((char *)messages_get("PDF"));
+ menulab[7] = NM_BARLABEL;
+ menulab[8] = ami_utf8_easy((char *)messages_get("CloseWindow"));
+ menulab[9] = ami_utf8_easy((char *)messages_get("Edit"));
+ menulab[10] = ami_utf8_easy((char *)messages_get("Copy"));
+ menulab[11] = ami_utf8_easy((char *)messages_get("Paste"));
+ menulab[12] = ami_utf8_easy((char *)messages_get("SelectAll"));
+ menulab[13] = ami_utf8_easy((char *)messages_get("Clear"));
+ menulab[14] = ami_utf8_easy((char *)messages_get("Hotlist"));
+ menulab[15] = ami_utf8_easy((char *)messages_get("HotlistAdd"));
+ menulab[16] = ami_utf8_easy((char *)messages_get("HotlistShow"));
+ menulab[17] = ami_utf8_easy((char *)messages_get("Settings"));
+ menulab[18] = ami_utf8_easy((char *)messages_get("SnapshotWindow"));
+ menulab[19] = ami_utf8_easy((char *)messages_get("SettingsSave"));
}
struct NewMenu *ami_create_menu(ULONG type)
@@ -59,6 +64,11 @@ struct NewMenu *ami_create_menu(ULONG type)
{NM_TITLE,0,0,0,0,0,}, // project
{ NM_ITEM,0,"N",0,0,0,}, // new window
{ NM_ITEM,NM_BARLABEL,0,0,0,0,},
+ { NM_ITEM,0,0,0,0,0,}, // save
+ { NM_SUB,0,0,0,0,0,}, // save as text
+ { NM_SUB,0,0,0,0,0,}, // save as source
+ { NM_SUB,0,0,0,0,0,}, // save as pdf
+ { NM_ITEM,NM_BARLABEL,0,0,0,0,},
{ NM_ITEM,0,"K",0,0,0,}, // close window
{NM_TITLE,0,0,0,0,0,}, // edit
{ NM_ITEM,0,"C",0,0,0,}, // copy
@@ -85,7 +95,11 @@ struct NewMenu *ami_create_menu(ULONG type)
}
menu[1].nm_Flags = menuflags;
- menu[3].nm_Flags = menuflags;
+ menu[8].nm_Flags = menuflags;
+
+#ifndef WITH_PDF_EXPORT
+ menu[6].nm_Flags = NM_ITEMDISABLED;
+#endif
return(menu);
}
diff --git a/amiga/menu.h b/amiga/menu.h
index d53d3bc73..6e74c48ad 100755
--- a/amiga/menu.h
+++ b/amiga/menu.h
@@ -20,8 +20,8 @@
#define AMIGA_MENU_H
#include <exec/types.h>
-#define AMI_MENU_MAX 14
-char *menulab[AMI_MENU_MAX];
+#define AMI_MENU_MAX 19
+char *menulab[AMI_MENU_MAX+1];
struct NewMenu *ami_create_menu(ULONG type);
void ami_init_menulabs(void);
diff --git a/amiga/save_pdf.c b/amiga/save_pdf.c
new file mode 100644
index 000000000..36b090549
--- /dev/null
+++ b/amiga/save_pdf.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2008 John Tytgat <joty@netsurf-browser.org>
+ * Copyright 2008 Chris Young <chris@unsatisfactorysoftware.co.uk>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** \file
+ * Export a content as a PDF file (implementation).
+ */
+
+#include "utils/config.h"
+#ifdef WITH_PDF_EXPORT
+
+#include <stdbool.h>
+#include "content/content.h"
+#include "desktop/print.h"
+#include "desktop/save_pdf/pdf_plotters.h"
+#include "amiga/save_pdf.h"
+#include "utils/log.h"
+#include "utils/config.h"
+
+/**
+ * Export a content as a PDF file.
+ *
+ * \param c content to export
+ * \param path path to save PDF as
+ * \return true on success, false on error and error reported
+ */
+bool save_as_pdf(struct content *c, const char *path)
+{
+ struct print_settings *psettings;
+
+ psettings = print_make_settings(DEFAULT, path);
+ if (psettings == NULL)
+ return false;
+
+ if (!print_basic_run(c, &pdf_printer, psettings))
+ return false;
+ return true;
+}
+
+void PDF_Password(char **owner_pass, char **user_pass, char *path)
+{
+ /*TODO:this waits to be written, until then no PDF encryption*/
+ *owner_pass = NULL;
+}
+#endif
diff --git a/amiga/save_pdf.h b/amiga/save_pdf.h
new file mode 100644
index 000000000..5a204bf02
--- /dev/null
+++ b/amiga/save_pdf.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2008 John Tytgat <joty@netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _NETSURF_RISCOS_SAVE_PDF_H_
+#define _NETSURF_RISCOS_SAVE_PDF_H_
+
+#include "utils/config.h"
+#ifdef WITH_PDF_EXPORT
+
+struct content;
+
+bool save_as_pdf(struct content *c, const char *path);
+
+#endif /* WITH_PDF_EXPORT */
+
+#endif