From 03fdf02272ce68f4ad515404a653cd770163a91b Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Tue, 16 Sep 2008 13:45:59 +0000 Subject: Fix warnings. svn path=/trunk/netsurf/; revision=5349 --- desktop/save_pdf/pdf_plotters.c | 306 ++++++++++++++++++++-------------------- 1 file changed, 153 insertions(+), 153 deletions(-) (limited to 'desktop') diff --git a/desktop/save_pdf/pdf_plotters.c b/desktop/save_pdf/pdf_plotters.c index 10ddc10bf..2dfea9779 100644 --- a/desktop/save_pdf/pdf_plotters.c +++ b/desktop/save_pdf/pdf_plotters.c @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - + /** \file * Target independent PDF plotting using Haru Free PDF Library. */ @@ -41,7 +41,7 @@ #define R(x) (( (x) & 0x0000ff )/256.0) #define G(x) ((( (x) & 0x00ff00)>>8 )/256.0) #define B(x) ((( (x) & 0xff0000)>>16)/256.0) - + /*#define PDF_DEBUG*/ static bool pdf_plot_clg(colour c); @@ -137,48 +137,48 @@ bool pdf_plot_rectangle(int x0, int y0, int width, int height, { #ifdef PDF_DEBUG LOG((".")); -#endif +#endif apply_clip_and_mode(); - - HPDF_Page_SetLineWidth(pdf_page, line_width); - + + HPDF_Page_SetLineWidth(pdf_page, line_width); + if (dotted) pdf_set_dotted(); else if (dashed) pdf_set_dashed(); - + HPDF_Page_SetRGBStroke(pdf_page, R(c), G(c), B(c)); HPDF_Page_Rectangle(pdf_page, x0, page_height - y0 + height, width, height); HPDF_Page_Stroke(pdf_page); - + if (dotted||dashed) pdf_set_solid(); return true; } -bool pdf_plot_line(int x0, int y0, int x1, int y1, int width, +bool pdf_plot_line(int x0, int y0, int x1, int y1, int width, colour c, bool dotted, bool dashed) { #ifdef PDF_DEBUG LOG((".")); -#endif - +#endif + apply_clip_and_mode(); - + HPDF_Page_SetLineWidth(pdf_page, width); - + if (dotted) pdf_set_dotted(); else if (dashed) pdf_set_dashed(); - + HPDF_Page_SetRGBStroke(pdf_page, R(c), G(c), B(c)); HPDF_Page_SetLineWidth(pdf_page, width); HPDF_Page_MoveTo(pdf_page, x0, page_height - y0); HPDF_Page_LineTo(pdf_page, x1, page_height - y1); HPDF_Page_Stroke(pdf_page); - + if (dotted||dashed) pdf_set_solid(); @@ -187,22 +187,22 @@ bool pdf_plot_line(int x0, int y0, int x1, int y1, int width, bool pdf_plot_polygon(int *p, unsigned int n, colour fill) { - int i; + unsigned int i; #ifdef PDF_DEBUG int pmaxx = p[0], pmaxy = p[1]; int pminx = p[0], pminy = p[1]; LOG((".")); -#endif +#endif if (n == 0) return true; - + apply_clip_and_mode(); - - HPDF_Page_SetRGBFill(pdf_page, R(fill), G(fill), B(fill)); + + HPDF_Page_SetRGBFill(pdf_page, R(fill), G(fill), B(fill)); HPDF_Page_MoveTo(pdf_page, p[0], page_height - p[1]); - + for (i = 1 ; ifont_size.value.length.unit == CSS_UNIT_PX) size = style->font_size.value.length.value; else size = css_len2pt(&style->font_size.value.length, style); - + /*this can be removed when export options get added for riscos*/ #ifdef riscos size *= DEFAULT_EXPORT_SCALE; -#else +#else size *= pdf_scale; #endif - + if (size <= 0) return true; - + if (size > HPDF_MAX_FONTSIZE) size = HPDF_MAX_FONTSIZE; - + haru_nsfont_apply_style(style, pdf_doc, pdf_page, &pdf_font); - + descent = size * (HPDF_Font_GetDescent(pdf_font) / 1000.0); text_bottom_position = page_height - y + descent; - + word = (char*) malloc( sizeof(char) * (length+1) ); if (word == NULL) return false; - + memcpy(word, text, length); word[length] = '\0'; - + HPDF_Page_SetRGBFill(pdf_page, R(c), G(c), B(c)); - + HPDF_Page_SetFontAndSize (pdf_page, pdf_font, size); HPDF_Page_TextOut (pdf_page, x, page_height - y, word); - + free(word); - + return true; } @@ -326,21 +326,21 @@ bool pdf_plot_disc(int x, int y, int radius, colour c, bool filled) { #ifdef PDF_DEBUG LOG((".")); -#endif +#endif apply_clip_and_mode(); - + if (filled) HPDF_Page_SetRGBFill(pdf_page, R(c), G(c), B(c)); else HPDF_Page_SetRGBStroke(pdf_page, R(c), G(c), B(c)); - + HPDF_Page_Circle(pdf_page, x, page_height-y, radius); - + if (filled) HPDF_Page_Fill(pdf_page); else HPDF_Page_Stroke(pdf_page); - + return true; } @@ -348,20 +348,20 @@ bool pdf_plot_arc(int x, int y, int radius, int angle1, int angle2, colour c) { #ifdef PDF_DEBUG LOG(("%d %d %d %d %d %X", x, y, radius, angle1, angle2, c)); -#endif - +#endif + /*Normalize angles*/ angle1 %= 360; angle2 %= 360; if (angle1 > angle2) angle1 -= 360; - + apply_clip_and_mode(); - + HPDF_Page_SetRGBStroke(pdf_page, R(c), G(c), B(c)); - + HPDF_Page_Arc(pdf_page, x, page_height-y, radius, angle1, angle2); - + HPDF_Page_Stroke(pdf_page); return true; } @@ -377,19 +377,19 @@ bool pdf_plot_bitmap(int x, int y, int width, int height, #endif if (width == 0 || height == 0) return true; - + apply_clip_and_mode(); - - image = pdf_extract_image(bitmap, content); - + + image = pdf_extract_image(bitmap, content); + if (!image) return false; - + HPDF_Page_DrawImage(pdf_page, image, x, page_height-y-height, - width, height); + width, height); return true; - + } @@ -398,39 +398,39 @@ bool pdf_plot_bitmap_tile(int x, int y, int width, int height, bool repeat_x, bool repeat_y, struct content *content) { HPDF_Image image; - + #ifdef PDF_DEBUG LOG(("%d %d %d %d %X %X %X", x, y, width, height, bitmap, bg, content)); #endif if (width == 0 || height == 0) - return true; - + return true; + apply_clip_and_mode(); - - image = pdf_extract_image(bitmap, content); - + + image = pdf_extract_image(bitmap, content); + if (image) { /*The position of the next tile*/ - HPDF_REAL current_x, current_y ; + HPDF_REAL current_x, current_y ; HPDF_REAL max_width, max_height; - + max_width = (repeat_x ? page_width : width); max_height = (repeat_y ? page_height: height); - - + + for (current_y=0; current_y < max_height; current_y += height) for (current_x=0; current_x < max_width; current_x += width) HPDF_Page_DrawImage(pdf_page, image, current_x + x, page_height-current_y - y - height, width, height); - + return true; } else return false; - + return true; } @@ -440,7 +440,7 @@ HPDF_Image pdf_extract_image(struct bitmap *bitmap, struct content *content) char *img_buffer, *rgb_buffer, *alpha_buffer; int img_width, img_height, img_rowstride; int i, j; - + if (content) { /*Not sure if I don't have to check if downloading has been finished. @@ -453,102 +453,102 @@ HPDF_Image pdf_extract_image(struct bitmap *bitmap, struct content *content) content->source_data, content->source_size); break; - + /*Disabled until HARU PNG support will be more stable. - + case CONTENT_PNG: image = HPDF_LoadPngImageFromMem(pdf_doc, content->source_data, content->total_size); - break;*/ + break;*/ default: break; - } + } } - + if (!image) { /*Handle pixmaps*/ img_buffer = bitmap_get_buffer(bitmap); img_width = bitmap_get_width(bitmap); img_height = bitmap_get_height(bitmap); img_rowstride = bitmap_get_rowstride(bitmap); - + rgb_buffer = (char*)malloc(3 * img_width * img_height); if (rgb_buffer == NULL) { LOG(("Not enough memory to create RGB buffer")); return NULL; } - + alpha_buffer = (char*)malloc(img_width * img_height); if (alpha_buffer == NULL) { LOG(("Not enough memory to create alpha buffer")); free(rgb_buffer); return NULL; } - - + + for (i = 0; ipage_width - settings->margins[MARGINLEFT] - + + page_width = settings->page_width - settings->margins[MARGINLEFT] - settings->margins[MARGINRIGHT]; - + page_height = settings->page_height - settings->margins[MARGINTOP]; - + if (option_enable_PDF_compression) HPDF_SetCompressionMode(pdf_doc, HPDF_COMP_ALL); /*Compression on*/ pdf_font = HPDF_GetFont (pdf_doc, "Times-Roman", "StandardEncoding"); - + pdf_page = NULL; - + #ifdef PDF_DEBUG LOG(("pdf_begin finishes")); -#endif +#endif return true; } @@ -711,22 +711,22 @@ bool pdf_next_page(void) pdf_page = HPDF_AddPage(pdf_doc); if (pdf_page == NULL) return false; - + HPDF_Page_SetWidth (pdf_page, settings->page_width); HPDF_Page_SetHeight(pdf_page, settings->page_height); - + HPDF_Page_Concat(pdf_page,1,0,0,1,settings->margins[MARGINLEFT],0); - + page_clipped = false; HPDF_Page_GSave(pdf_page); - + text_mode_request = false; in_text_mode = false; - + #ifdef PDF_DEBUG LOG(("%f %f", page_width, page_height)); #endif - + return true; } @@ -744,12 +744,12 @@ void pdf_end(void) pdf_plot_grid(100, 100, 0xCCCCFF); } #endif - + if (settings->output != NULL) path = strdup(settings->output); else path = NULL; - + /*Encryption on*/ if (option_enable_PDF_password) PDF_Password(&owner_pass, &user_pass, path); @@ -763,26 +763,26 @@ void pdf_end(void) void save_pdf(char *path) { bool success = false; - + if (option_enable_PDF_password && owner_pass != NULL ) { HPDF_SetPassword(pdf_doc, owner_pass, user_pass); HPDF_SetEncryptionMode(pdf_doc, HPDF_ENCRYPT_R3, 16); free(owner_pass); free(user_pass); } - + if (path != NULL) { if (HPDF_SaveToFile(pdf_doc, path) != HPDF_OK) remove(path); else success = true; - - free(path); + + free(path); } - + if (!success) warn_user("Unable to save PDF file.", 0); - + HPDF_Free(pdf_doc); } @@ -798,9 +798,9 @@ static void error_handler(HPDF_STATUS error_no, HPDF_STATUS detail_no, { LOG(("ERROR:\n\terror_no=%x\n\tdetail_no=%d\n", (HPDF_UINT)error_no, (HPDF_UINT)detail_no)); -#ifdef PDF_DEBUG +#ifdef PDF_DEBUG exit(1); -#endif +#endif } /** @@ -811,13 +811,13 @@ static void error_handler(HPDF_STATUS error_no, HPDF_STATUS detail_no, void pdf_plot_grid(int x_dist, int y_dist, unsigned int colour) { int i; - + for (int i = x_dist ; i < page_width ; i += x_dist) pdf_plot_line(i, 0, i, page_height, 1, colour, false, false); - + for (int i = y_dist ; i < page_height ; i += x_dist) pdf_plot_line(0, i, page_width, i, 1, colour, false, false); - + } #endif -- cgit v1.2.3