From 3eabd20dcf0f030cebac90b0081b8c8f0fb4f1be Mon Sep 17 00:00:00 2001 From: John Tytgat Date: Tue, 29 Jul 2008 23:59:38 +0000 Subject: [PATCH] Code style changes. svn path=/trunk/netsurf/; revision=4813 --- pdf/font_haru.c | 31 ++++++++----------- pdf/pdf_plotters.c | 77 ++++++++++++++++++++++++---------------------- 2 files changed, 53 insertions(+), 55 deletions(-) diff --git a/pdf/font_haru.c b/pdf/font_haru.c index e1d576027..7a158d5d1 100644 --- a/pdf/font_haru.c +++ b/pdf/font_haru.c @@ -68,13 +68,11 @@ const struct font_functions haru_nsfont = { * as it would otherwise flood the user with all resulting complications, * covering the most important error source. */ -static void error_handler(HPDF_STATUS error_no, - HPDF_STATUS detail_no, - void *user_data) +static void error_handler(HPDF_STATUS error_no, HPDF_STATUS detail_no, + void *user_data) { LOG(("ERROR: in font_haru \n\terror_no=%x\n\tdetail_no=%d\n", - (HPDF_UINT)error_no, - (HPDF_UINT)detail_no)); + (HPDF_UINT)error_no, (HPDF_UINT)detail_no)); #ifdef FONT_HARU_DEBUG exit(1); #endif @@ -189,7 +187,7 @@ bool haru_nsfont_position_in_string(const struct css_style *style, offset = HPDF_Page_MeasureText(page, string_nt, x, - HPDF_FALSE, &real_width); + HPDF_FALSE, &real_width); if (real_width < x) @@ -205,7 +203,7 @@ bool haru_nsfont_position_in_string(const struct css_style *style, #ifdef FONT_HARU_DEBUG LOG(("Position in string: %s at x: %i; Calculated position: %i", - string_nt, x, *char_offset)); + string_nt, x, *char_offset)); #endif free(string_nt); HPDF_Free(pdf); @@ -227,8 +225,8 @@ bool haru_nsfont_position_in_string(const struct css_style *style, */ bool haru_nsfont_split(const struct css_style *style, - const char *string, size_t length, - int x, size_t *char_offset, int *actual_x) + const char *string, size_t length, + int x, size_t *char_offset, int *actual_x) { HPDF_Doc pdf; HPDF_Page page; @@ -248,7 +246,7 @@ bool haru_nsfont_split(const struct css_style *style, } offset = HPDF_Page_MeasureText(page, string_nt, x, - HPDF_TRUE, &real_width); + HPDF_TRUE, &real_width); #ifdef FONT_HARU_DEBUG LOG(("Splitting string: %s for width: %i ; Calculated position: %i Calculated real_width: %f", @@ -278,10 +276,8 @@ bool haru_nsfont_split(const struct css_style *style, */ bool haru_nsfont_apply_style(const struct css_style *style, - HPDF_Doc doc, HPDF_Page page, - HPDF_Font *font) + HPDF_Doc doc, HPDF_Page page, HPDF_Font *font) { - HPDF_Font pdf_font; HPDF_REAL size; char font_name[50]; @@ -320,14 +316,12 @@ bool haru_nsfont_apply_style(const struct css_style *style, strcat(font_name, "-Bold"); bold = true; } - - - - + switch (style->font_style) { case CSS_FONT_STYLE_ITALIC: case CSS_FONT_STYLE_OBLIQUE: - if (!bold) strcat(font_name,"-"); + if (!bold) + strcat(font_name,"-"); if (roman) strcat(font_name,"Italic"); else @@ -353,7 +347,6 @@ bool haru_nsfont_apply_style(const struct css_style *style, *font = pdf_font; } else { - if (style->font_size.value.length.unit == CSS_UNIT_PX) size = style->font_size.value.length.value; else diff --git a/pdf/pdf_plotters.c b/pdf/pdf_plotters.c index 49828a0a6..ac4e9b69c 100644 --- a/pdf/pdf_plotters.c +++ b/pdf/pdf_plotters.c @@ -77,7 +77,7 @@ static void pdf_page_apply_notext_clip(void); static HPDF_Image pdf_extract_image(struct bitmap *bitmap, struct content *content); static void error_handler(HPDF_STATUS error_no, HPDF_STATUS detail_no, - void*user_data); + void *user_data); #ifdef PDF_DEBUG static void pdf_plot_grid(int x_dist,int y_dist,unsigned int colour); @@ -124,12 +124,14 @@ struct printer pdf_printer= { pdf_end }; -bool pdf_plot_clg(colour c){ +bool pdf_plot_clg(colour c) +{ return true; } bool pdf_plot_rectangle(int x0, int y0, int width, int height, - int line_width, colour c, bool dotted, bool dashed){ + int line_width, colour c, bool dotted, bool dashed) +{ #ifdef PDF_DEBUG LOG((".")); #endif @@ -151,7 +153,8 @@ bool pdf_plot_rectangle(int x0, int y0, int width, int height, } bool pdf_plot_line(int x0, int y0, int x1, int y1, int width, - colour c, bool dotted, bool dashed){ + colour c, bool dotted, bool dashed) +{ #ifdef PDF_DEBUG LOG((".")); #endif @@ -174,7 +177,8 @@ bool pdf_plot_line(int x0, int y0, int x1, int y1, int width, return true; } -bool pdf_plot_polygon(int *p, unsigned int n, colour fill){ +bool pdf_plot_polygon(int *p, unsigned int n, colour fill) +{ int i; #ifdef PDF_DEBUG int pmaxx = p[0], pmaxy = p[1]; @@ -207,8 +211,8 @@ bool pdf_plot_polygon(int *p, unsigned int n, colour fill){ return true; } -bool pdf_plot_fill(int x0, int y0, int x1, int y1, colour c){ - +bool pdf_plot_fill(int x0, int y0, int x1, int y1, colour c) +{ #ifdef PDF_DEBUG LOG(("%d %d %d %d %f %X", x0, y0, x1, y1, page_height-y0, c)); #endif @@ -230,9 +234,8 @@ bool pdf_plot_fill(int x0, int y0, int x1, int y1, colour c){ return true; } -bool pdf_plot_clip(int clip_x0, int clip_y0, - int clip_x1, int clip_y1){ - +bool pdf_plot_clip(int clip_x0, int clip_y0, int clip_x1, int clip_y1) +{ #ifdef PDF_DEBUG LOG(("%d %d %d %d", clip_x0, clip_y0, clip_x1, clip_y1)); #endif @@ -264,9 +267,10 @@ bool pdf_plot_clip(int clip_x0, int clip_y0, } bool pdf_plot_text(int x, int y, const struct css_style *style, - const char *text, size_t length, colour bg, colour c){ + const char *text, size_t length, colour bg, colour c) +{ #ifdef PDF_DEBUG - LOG((". %d %d %s", x, y, text)); + LOG((". %d %d %s", x, y, text)); #endif char *word; HPDF_REAL size; @@ -320,7 +324,8 @@ bool pdf_plot_text(int x, int y, const struct css_style *style, return true; } -bool pdf_plot_disc(int x, int y, int radius, colour c, bool filled){ +bool pdf_plot_disc(int x, int y, int radius, colour c, bool filled) +{ #ifdef PDF_DEBUG LOG((".")); #endif @@ -339,8 +344,8 @@ bool pdf_plot_disc(int x, int y, int radius, colour c, bool filled){ return true; } -bool pdf_plot_arc(int x, int y, int radius, int angle1, int angle2, - colour c){ +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 @@ -360,8 +365,8 @@ bool pdf_plot_arc(int x, int y, int radius, int angle1, int angle2, } bool pdf_plot_bitmap(int x, int y, int width, int height, - struct bitmap *bitmap, colour bg, struct content *content){ - + struct bitmap *bitmap, colour bg, struct content *content) +{ HPDF_Image image; #ifdef PDF_DEBUG @@ -386,8 +391,8 @@ bool pdf_plot_bitmap(int x, int y, int width, int height, bool pdf_plot_bitmap_tile(int x, int y, int width, int height, struct bitmap *bitmap, colour bg, - bool repeat_x, bool repeat_y, struct content *content){ - + bool repeat_x, bool repeat_y, struct content *content) +{ HPDF_Image image; #ifdef PDF_DEBUG @@ -423,7 +428,8 @@ bool pdf_plot_bitmap_tile(int x, int y, int width, int height, return true; } -HPDF_Image pdf_extract_image(struct bitmap *bitmap, struct content *content){ +HPDF_Image pdf_extract_image(struct bitmap *bitmap, struct content *content) +{ HPDF_Image image = NULL,smask; char *img_buffer, *rgb_buffer, *alpha_buffer; int img_width, img_height, img_rowstride; @@ -456,7 +462,6 @@ HPDF_Image pdf_extract_image(struct bitmap *bitmap, struct content *content){ } if (!image) { - /*Handle pixmaps*/ img_buffer = bitmap_get_buffer(bitmap); img_width = bitmap_get_width(bitmap); @@ -511,22 +516,26 @@ HPDF_Image pdf_extract_image(struct bitmap *bitmap, struct content *content){ } -bool pdf_plot_flush(){ +bool pdf_plot_flush(void) +{ return true; } -static inline float transform_x(float *transform,float x,float y){ +static inline float transform_x(float *transform,float x,float y) +{ return ((transform[0] * x) + (transform[2] * (-y) ) + transform[4]) * 2; } -static inline float transform_y(float *transform,float x,float y){ +static inline float transform_y(float *transform,float x,float y) +{ return page_height - (((transform[1] * x) + (transform[3] * (-y)) - transform[5]) * 2); } bool pdf_plot_path(float *p, unsigned int n, colour fill, float width, - colour c, float *transform){ + colour c, float *transform) +{ #ifdef PDF_DEBUG LOG((".")); #endif @@ -625,9 +634,8 @@ void pdf_set_dotted() * \param pg_width page width * \param pg_height page height */ -bool pdf_begin(struct print_settings* print_settings) +bool pdf_begin(struct print_settings *print_settings) { - pdf_doc = NULL; pdf_doc = HPDF_New(error_handler, NULL); @@ -657,7 +665,7 @@ bool pdf_begin(struct print_settings* print_settings) } -bool pdf_next_page() +bool pdf_next_page(void) { #ifdef PDF_DEBUG if (pdf_page != NULL) { @@ -689,7 +697,7 @@ bool pdf_next_page() } -void pdf_end() +void pdf_end(void) { #ifdef PDF_DEBUG LOG(("pdf_end begins")); @@ -706,7 +714,6 @@ void pdf_end() if (settings->output) HPDF_SaveToFile(pdf_doc, settings->output); - HPDF_Free(pdf_doc); #ifdef PDF_DEBUG @@ -721,13 +728,11 @@ void pdf_end() * as it would otherwise flood the user with all resulting complications, * covering the most important error source. */ -static void error_handler(HPDF_STATUS error_no, - HPDF_STATUS detail_no, +static void error_handler(HPDF_STATUS error_no, HPDF_STATUS detail_no, void *user_data) { - LOG(("ERROR:\n\terror_no=%x\n\tdetail_no=%d\n", - (HPDF_UINT)error_no, - (HPDF_UINT)detail_no)); + LOG(("ERROR:\n\terror_no=%x\n\tdetail_no=%d\n", (HPDF_UINT)error_no, + (HPDF_UINT)detail_no)); #ifdef PDF_DEBUG exit(1); #endif @@ -755,7 +760,7 @@ void pdf_plot_grid(int x_dist, int y_dist, unsigned int colour) * A solution for fuzzy margins - saves the current clipping and puts the main * clip frame (page without margins) over it. */ -void pdf_page_apply_notext_clip() +void pdf_page_apply_notext_clip(void) { /*Save state underneath*/ HPDF_Page_GSave(pdf_page);