From 74f9c0e07568c37eeac373471d2ed9796a486638 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Tue, 26 Aug 2008 01:20:01 +0000 Subject: Added PDF export to Amiga port. svn path=/trunk/netsurf/; revision=5203 --- amiga/gui.c | 31 ++++++++++++++++++++++++++++- amiga/menu.c | 40 +++++++++++++++++++++++++------------ amiga/menu.h | 4 ++-- amiga/save_pdf.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ amiga/save_pdf.h | 31 +++++++++++++++++++++++++++++ 5 files changed, 150 insertions(+), 16 deletions(-) create mode 100644 amiga/save_pdf.c create mode 100644 amiga/save_pdf.h (limited to 'amiga') 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 -#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 + * Copyright 2008 Chris Young + * + * 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 . + */ + +/** \file + * Export a content as a PDF file (implementation). + */ + +#include "utils/config.h" +#ifdef WITH_PDF_EXPORT + +#include +#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 + * + * 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 . + */ + +#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 -- cgit v1.2.3