mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-27 08:50:02 +03:00
Added PDF export to Amiga port.
svn path=/trunk/netsurf/; revision=5203
This commit is contained in:
parent
553c4aac8b
commit
74f9c0e075
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
31
amiga/gui.c
31
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;
|
||||
|
||||
|
40
amiga/menu.c
40
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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
60
amiga/save_pdf.c
Normal file
60
amiga/save_pdf.c
Normal file
@ -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
|
31
amiga/save_pdf.h
Normal file
31
amiga/save_pdf.h
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user