diff options
Diffstat (limited to 'riscos')
-rw-r--r-- | riscos/font.c | 26 | ||||
-rw-r--r-- | riscos/menus.c | 20 | ||||
-rw-r--r-- | riscos/menus.h | 1 | ||||
-rw-r--r-- | riscos/plotters.c | 8 | ||||
-rw-r--r-- | riscos/save.c | 25 | ||||
-rw-r--r-- | riscos/save_draw.c | 8 | ||||
-rw-r--r-- | riscos/save_pdf.c | 55 | ||||
-rw-r--r-- | riscos/save_pdf.h | 30 |
8 files changed, 149 insertions, 24 deletions
diff --git a/riscos/font.c b/riscos/font.c index d320b2070..54a985ae0 100644 --- a/riscos/font.c +++ b/riscos/font.c @@ -35,20 +35,32 @@ #include "utils/messages.h" #include "utils/utils.h" - -/** desktop font, size and style being used */ -char ro_gui_desktop_font_family[80]; -int ro_gui_desktop_font_size = 12; -rufl_style ro_gui_desktop_font_style = rufl_WEIGHT_400; - - static void nsfont_check_option(char **option, const char *family, const char *fallback); static int nsfont_list_cmp(const void *keyval, const void *datum); static void nsfont_check_fonts(void); static void ro_gui_wimp_desktop_font(char *family, size_t bufsize, int *psize, rufl_style *pstyle); +static bool nsfont_width(const struct css_style *style, + const char *string, size_t length, + int *width); +static bool nsfont_position_in_string(const struct css_style *style, + const char *string, size_t length, + int x, size_t *char_offset, int *actual_x); +static bool nsfont_split(const struct css_style *style, + const char *string, size_t length, + int x, size_t *char_offset, int *actual_x); + +/** desktop font, size and style being used */ +char ro_gui_desktop_font_family[80]; +int ro_gui_desktop_font_size = 12; +rufl_style ro_gui_desktop_font_style = rufl_WEIGHT_400; +const struct font_functions nsfont = { + nsfont_width, + nsfont_position_in_string, + nsfont_split +}; /** * Initialize font handling. diff --git a/riscos/menus.c b/riscos/menus.c index adfb9a109..bee1890c4 100644 --- a/riscos/menus.c +++ b/riscos/menus.c @@ -182,9 +182,16 @@ void ro_gui_menu_init(void) { "Page", BROWSER_PAGE, 0 }, { "Page.PageInfo",BROWSER_PAGE_INFO, dialog_pageinfo }, { "Page.Save", BROWSER_SAVE, dialog_saveas }, +#ifdef WITH_SAVE_COMPLETE { "Page.SaveComp", BROWSER_SAVE_COMPLETE, dialog_saveas }, +#endif { "Page.Export", NO_ACTION, 0 }, +#ifdef WITH_DRAW_EXPORT { "Page.Export.Draw", BROWSER_EXPORT_DRAW, dialog_saveas }, +#endif +#ifdef WITH_PDF_EXPORT + { "Page.Export.PDF", BROWSER_EXPORT_PDF, dialog_saveas }, +#endif { "Page.Export.Text", BROWSER_EXPORT_TEXT, dialog_saveas }, { "Page.SaveURL", NO_ACTION, 0 }, { "Page.SaveURL.URI", BROWSER_SAVE_URL_URI, dialog_saveas }, @@ -1520,15 +1527,18 @@ bool ro_gui_menu_handle_action(wimp_w owner, menu_action action, case BROWSER_OBJECT_SAVE_URL_TEXT: c = current_menu_object_box ? current_menu_object_box->object : NULL; + /* Fall through */ case BROWSER_SAVE: case BROWSER_SAVE_COMPLETE: case BROWSER_EXPORT_DRAW: + case BROWSER_EXPORT_PDF: case BROWSER_EXPORT_TEXT: case BROWSER_SAVE_URL_URI: case BROWSER_SAVE_URL_URL: case BROWSER_SAVE_URL_TEXT: if (!c) return false; + /* Fall through */ case HOTLIST_EXPORT: case HISTORY_EXPORT: ro_gui_menu_prepare_action(owner, action, true); @@ -1872,6 +1882,7 @@ void ro_gui_menu_prepare_action(wimp_w owner, menu_action action, if ((windows) && (current_menu_object_box)) ro_gui_menu_prepare_objectinfo( current_menu_object_box); + /* Fall through */ case BROWSER_OBJECT_RELOAD: ro_gui_menu_set_entry_shaded(current_menu, action, !current_menu_object_box); @@ -1917,6 +1928,12 @@ void ro_gui_menu_prepare_action(wimp_w owner, menu_action action, if ((c) && (windows)) ro_gui_save_prepare(GUI_SAVE_DRAW, c); break; + case BROWSER_EXPORT_PDF: + ro_gui_menu_set_entry_shaded(current_menu, + action, !c); + if ((c) && (windows)) + ro_gui_save_prepare(GUI_SAVE_PDF, c); + break; case BROWSER_EXPORT_TEXT: ro_gui_menu_set_entry_shaded(current_menu, action, !c); @@ -1926,6 +1943,7 @@ void ro_gui_menu_prepare_action(wimp_w owner, menu_action action, case BROWSER_OBJECT_SAVE_URL_URI: c = current_menu_object_box ? current_menu_object_box->object : NULL; + /* Fall through */ case BROWSER_SAVE_URL_URI: ro_gui_menu_set_entry_shaded(current_menu, action, !c); @@ -1935,6 +1953,7 @@ void ro_gui_menu_prepare_action(wimp_w owner, menu_action action, case BROWSER_OBJECT_SAVE_URL_URL: c = current_menu_object_box ? current_menu_object_box->object : NULL; + /* Fall through */ case BROWSER_SAVE_URL_URL: ro_gui_menu_set_entry_shaded(current_menu, action, !c); @@ -1944,6 +1963,7 @@ void ro_gui_menu_prepare_action(wimp_w owner, menu_action action, case BROWSER_OBJECT_SAVE_URL_TEXT: c = current_menu_object_box ? current_menu_object_box->object : NULL; + /* Fall through */ case BROWSER_SAVE_URL_TEXT: ro_gui_menu_set_entry_shaded(current_menu, action, !c); diff --git a/riscos/menus.h b/riscos/menus.h index 8e7708413..edc439346 100644 --- a/riscos/menus.h +++ b/riscos/menus.h @@ -76,6 +76,7 @@ typedef enum { BROWSER_SAVE, BROWSER_SAVE_COMPLETE, BROWSER_EXPORT_DRAW, + BROWSER_EXPORT_PDF, BROWSER_EXPORT_TEXT, BROWSER_SAVE_URL_URI, BROWSER_SAVE_URL_URL, diff --git a/riscos/plotters.c b/riscos/plotters.c index 3650e2246..512e0572e 100644 --- a/riscos/plotters.c +++ b/riscos/plotters.c @@ -52,10 +52,10 @@ static bool ro_plot_disc(int x, int y, int radius, colour colour, bool filled); static bool ro_plot_arc(int x, int y, int radius, int angle1, int angle2, colour c); static bool ro_plot_bitmap(int x, int y, int width, int height, - struct bitmap *bitmap, colour bg); + struct bitmap *bitmap, colour bg, struct content *content); static bool ro_plot_bitmap_tile(int x, int y, int width, int height, struct bitmap *bitmap, colour bg, - bool repeat_x, bool repeat_y); + bool repeat_x, bool repeat_y, struct content *content); struct plotter_table plot; @@ -496,7 +496,7 @@ bool ro_plot_arc(int x, int y, int radius, int angle1, int angle2, colour c) } bool ro_plot_bitmap(int x, int y, int width, int height, - struct bitmap *bitmap, colour bg) + struct bitmap *bitmap, colour bg, struct content *content) { char *buffer; @@ -521,7 +521,7 @@ bool ro_plot_bitmap(int x, int y, int width, int height, bool ro_plot_bitmap_tile(int x, int y, int width, int height, struct bitmap *bitmap, colour bg, - bool repeat_x, bool repeat_y) + bool repeat_x, bool repeat_y, struct content *content) { char *buffer; diff --git a/riscos/save.c b/riscos/save.c index b701bd1d1..549b9e003 100644 --- a/riscos/save.c +++ b/riscos/save.c @@ -28,13 +28,13 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "oslib/dragasprite.h" -#include "oslib/osbyte.h" -#include "oslib/osfile.h" -#include "oslib/osmodule.h" +#include <oslib/dragasprite.h> +#include <oslib/osbyte.h> +#include <oslib/osfile.h> +#include <oslib/osmodule.h> #include <oslib/osspriteop.h> -#include "oslib/wimp.h" -#include "oslib/wimpspriteop.h" +#include <oslib/wimp.h> +#include <oslib/wimpspriteop.h> #include "desktop/netsurf.h" #include "desktop/save_text.h" #include "desktop/selection.h" @@ -47,6 +47,7 @@ #include "riscos/save.h" #include "riscos/save_complete.h" #include "riscos/save_draw.h" +#include "riscos/save_pdf.h" #include "riscos/textselection.h" #include "riscos/thumbnail.h" #include "riscos/wimp.h" @@ -92,10 +93,12 @@ struct gui_save_table_entry { /** Table of filetypes and default filenames. Must be in sync with * gui_save_type (riscos/gui.h). A filetype of 0 indicates the content should - * be used. */ -struct gui_save_table_entry gui_save_table[] = { + * be used. + */ +static const struct gui_save_table_entry gui_save_table[] = { /* GUI_SAVE_SOURCE, */ { 0, "SaveSource" }, /* GUI_SAVE_DRAW, */ { 0xaff, "SaveDraw" }, + /* GUI_SAVE_PDF, */ { 0xadf, "SavePDF" }, /* GUI_SAVE_TEXT, */ { 0xfff, "SaveText" }, /* GUI_SAVE_COMPLETE, */ { 0xfaf, "SaveComplete" }, /* GUI_SAVE_OBJECT_ORIG, */ { 0, "SaveObject" }, @@ -633,7 +636,7 @@ void ro_gui_save_datasave_ack(wimp_message *message) /** * Does the actual saving * - * \param c content to save (or 0 for other) + * \param c content to save (or NULL for other) * \param path path to save as * \return true on success, false on error and error reported */ @@ -647,6 +650,10 @@ bool ro_gui_save_content(struct content *c, char *path) case GUI_SAVE_DRAW: return save_as_draw(c, path); #endif +#ifdef WITH_PDF_EXPORT + case GUI_SAVE_PDF: + return save_as_pdf(c, path); +#endif case GUI_SAVE_TEXT: save_as_text(c, path); xosfile_set_type(path, 0xfff); diff --git a/riscos/save_draw.c b/riscos/save_draw.c index 5df1c0089..1af1db6f9 100644 --- a/riscos/save_draw.c +++ b/riscos/save_draw.c @@ -54,10 +54,10 @@ static bool ro_save_draw_disc(int x, int y, int radius, colour colour, static bool ro_save_draw_arc(int x, int y, int radius, int angle1, int angle2, colour c); static bool ro_save_draw_bitmap(int x, int y, int width, int height, - struct bitmap *bitmap, colour bg); + struct bitmap *bitmap, colour bg, struct content *content); static bool ro_save_draw_bitmap_tile(int x, int y, int width, int height, struct bitmap *bitmap, colour bg, - bool repeat_x, bool repeat_y); + bool repeat_x, bool repeat_y, struct content *content); static bool ro_save_draw_group_start(const char *name); static bool ro_save_draw_group_end(void); static bool ro_save_draw_error(pencil_code code); @@ -377,7 +377,7 @@ bool ro_save_draw_arc(int x, int y, int radius, int angle1, int angle2, } bool ro_save_draw_bitmap(int x, int y, int width, int height, - struct bitmap *bitmap, colour bg) + struct bitmap *bitmap, colour bg, struct content *content) { pencil_code code; char *buffer; @@ -401,7 +401,7 @@ bool ro_save_draw_bitmap(int x, int y, int width, int height, bool ro_save_draw_bitmap_tile(int x, int y, int width, int height, struct bitmap *bitmap, colour bg, - bool repeat_x, bool repeat_y) + bool repeat_x, bool repeat_y, struct content *content) { return true; } diff --git a/riscos/save_pdf.c b/riscos/save_pdf.c new file mode 100644 index 000000000..a5d2b010a --- /dev/null +++ b/riscos/save_pdf.c @@ -0,0 +1,55 @@ +/* + * Copyright 2008 John Tytgat <John.Tytgat@aaug.net> + * + * 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 <oslib/osfile.h> +#include "content/content.h" +#include "desktop/print.h" +#include "pdf/pdf_plotters.h" +#include "riscos/save_pdf.h" +#include "utils/log.h" +#include "utils/config.h" + +#ifdef WITH_PDF_EXPORT + +/** + * 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); + if (psettings == NULL) + return false; + + psettings->output = path; + if (!print_basic_run(c, &pdf_printer, psettings)) + return false; + xosfile_set_type(path, 0xadf); + return true; +} + +#endif diff --git a/riscos/save_pdf.h b/riscos/save_pdf.h new file mode 100644 index 000000000..69f998764 --- /dev/null +++ b/riscos/save_pdf.h @@ -0,0 +1,30 @@ +/* + * Copyright 2008 John Tytgat <John.Tytgat@aaug.net> + * + * 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 + +#endif |