From 76cfea4acb19ed99a31b84d1d6d3d83d1ac5f225 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 2 Sep 2014 22:51:20 +0200 Subject: xps: Add fz_xml_is_tag to simplify tag matching. --- source/xps/xps-common.c | 22 +++++++++++----------- source/xps/xps-doc.c | 10 +++++----- source/xps/xps-glyphs.c | 8 ++++---- source/xps/xps-gradient.c | 10 +++++----- source/xps/xps-outline.c | 8 ++++---- source/xps/xps-path.c | 24 ++++++++++++------------ source/xps/xps-tile.c | 16 ++++++++-------- 7 files changed, 49 insertions(+), 49 deletions(-) (limited to 'source/xps') diff --git a/source/xps/xps-common.c b/source/xps/xps-common.c index 63e4dc40..04b78d2b 100644 --- a/source/xps/xps-common.c +++ b/source/xps/xps-common.c @@ -13,7 +13,7 @@ xps_lookup_alternate_content(fz_xml *node) { for (node = fz_xml_down(node); node; node = fz_xml_next(node)) { - if (!strcmp(fz_xml_tag(node), "Choice") && fz_xml_att(node, "Requires")) + if (fz_xml_is_tag(node, "Choice") && fz_xml_att(node, "Requires")) { char list[64]; char *next = list, *item; @@ -22,7 +22,7 @@ xps_lookup_alternate_content(fz_xml *node) if (!item) return fz_xml_down(node); } - else if (!strcmp(fz_xml_tag(node), "Fallback")) + else if (fz_xml_is_tag(node, "Fallback")) return fz_xml_down(node); } return NULL; @@ -34,13 +34,13 @@ xps_parse_brush(xps_document *doc, const fz_matrix *ctm, const fz_rect *area, ch if (doc->cookie && doc->cookie->abort) return; /* SolidColorBrushes are handled in a special case and will never show up here */ - if (!strcmp(fz_xml_tag(node), "ImageBrush")) + if (fz_xml_is_tag(node, "ImageBrush")) xps_parse_image_brush(doc, ctm, area, base_uri, dict, node); - else if (!strcmp(fz_xml_tag(node), "VisualBrush")) + else if (fz_xml_is_tag(node, "VisualBrush")) xps_parse_visual_brush(doc, ctm, area, base_uri, dict, node); - else if (!strcmp(fz_xml_tag(node), "LinearGradientBrush")) + else if (fz_xml_is_tag(node, "LinearGradientBrush")) xps_parse_linear_gradient_brush(doc, ctm, area, base_uri, dict, node); - else if (!strcmp(fz_xml_tag(node), "RadialGradientBrush")) + else if (fz_xml_is_tag(node, "RadialGradientBrush")) xps_parse_radial_gradient_brush(doc, ctm, area, base_uri, dict, node); else fz_warn(doc->ctx, "unknown brush tag: %s", fz_xml_tag(node)); @@ -51,13 +51,13 @@ xps_parse_element(xps_document *doc, const fz_matrix *ctm, const fz_rect *area, { if (doc->cookie && doc->cookie->abort) return; - if (!strcmp(fz_xml_tag(node), "Path")) + if (fz_xml_is_tag(node, "Path")) xps_parse_path(doc, ctm, base_uri, dict, node); - if (!strcmp(fz_xml_tag(node), "Glyphs")) + if (fz_xml_is_tag(node, "Glyphs")) xps_parse_glyphs(doc, ctm, base_uri, dict, node); - if (!strcmp(fz_xml_tag(node), "Canvas")) + if (fz_xml_is_tag(node, "Canvas")) xps_parse_canvas(doc, ctm, area, base_uri, dict, node); - if (!strcmp(fz_xml_tag(node), "AlternateContent")) + if (fz_xml_is_tag(node, "AlternateContent")) { node = xps_lookup_alternate_content(node); if (node) @@ -159,7 +159,7 @@ xps_parse_matrix_transform(xps_document *doc, fz_xml *root, fz_matrix *matrix) *matrix = fz_identity; - if (!strcmp(fz_xml_tag(root), "MatrixTransform")) + if (fz_xml_is_tag(root, "MatrixTransform")) { transform = fz_xml_att(root, "Matrix"); if (transform) diff --git a/source/xps/xps-doc.c b/source/xps/xps-doc.c index e2058fbc..4bcf92cb 100644 --- a/source/xps/xps-doc.c +++ b/source/xps/xps-doc.c @@ -280,7 +280,7 @@ xps_parse_metadata_imp(xps_document *doc, fz_xml *item, xps_fixdoc *fixdoc) { while (item) { - if (!strcmp(fz_xml_tag(item), "Relationship")) + if (fz_xml_is_tag(item, "Relationship")) { char *target = fz_xml_att(item, "Target"); char *type = fz_xml_att(item, "Type"); @@ -297,7 +297,7 @@ xps_parse_metadata_imp(xps_document *doc, fz_xml *item, xps_fixdoc *fixdoc) } } - if (!strcmp(fz_xml_tag(item), "DocumentReference")) + if (fz_xml_is_tag(item, "DocumentReference")) { char *source = fz_xml_att(item, "Source"); if (source) @@ -308,7 +308,7 @@ xps_parse_metadata_imp(xps_document *doc, fz_xml *item, xps_fixdoc *fixdoc) } } - if (!strcmp(fz_xml_tag(item), "PageContent")) + if (fz_xml_is_tag(item, "PageContent")) { char *source = fz_xml_att(item, "Source"); char *width_att = fz_xml_att(item, "Width"); @@ -323,7 +323,7 @@ xps_parse_metadata_imp(xps_document *doc, fz_xml *item, xps_fixdoc *fixdoc) } } - if (!strcmp(fz_xml_tag(item), "LinkTarget")) + if (fz_xml_is_tag(item, "LinkTarget")) { char *name = fz_xml_att(item, "Name"); if (name) @@ -453,7 +453,7 @@ xps_load_fixed_page(xps_document *doc, xps_page *page) if (!root) fz_throw(doc->ctx, FZ_ERROR_GENERIC, "FixedPage missing root element"); - if (!strcmp(fz_xml_tag(root), "AlternateContent")) + if (fz_xml_is_tag(root, "AlternateContent")) { fz_xml *node = xps_lookup_alternate_content(root); if (!node) diff --git a/source/xps/xps-glyphs.c b/source/xps/xps-glyphs.c index d917b517..ee16fb6f 100644 --- a/source/xps/xps-glyphs.c +++ b/source/xps/xps-glyphs.c @@ -446,13 +446,13 @@ xps_parse_glyphs(xps_document *doc, const fz_matrix *ctm, for (node = fz_xml_down(root); node; node = fz_xml_next(node)) { - if (!strcmp(fz_xml_tag(node), "Glyphs.RenderTransform")) + if (fz_xml_is_tag(node, "Glyphs.RenderTransform")) transform_tag = fz_xml_down(node); - if (!strcmp(fz_xml_tag(node), "Glyphs.OpacityMask")) + if (fz_xml_is_tag(node, "Glyphs.OpacityMask")) opacity_mask_tag = fz_xml_down(node); - if (!strcmp(fz_xml_tag(node), "Glyphs.Clip")) + if (fz_xml_is_tag(node, "Glyphs.Clip")) clip_tag = fz_xml_down(node); - if (!strcmp(fz_xml_tag(node), "Glyphs.Fill")) + if (fz_xml_is_tag(node, "Glyphs.Fill")) fill_tag = fz_xml_down(node); } diff --git a/source/xps/xps-gradient.c b/source/xps/xps-gradient.c index 76188e91..4c1d0851 100644 --- a/source/xps/xps-gradient.c +++ b/source/xps/xps-gradient.c @@ -51,7 +51,7 @@ xps_parse_gradient_stops(xps_document *doc, char *base_uri, fz_xml *node, count = 0; while (node && count < maxcount) { - if (!strcmp(fz_xml_tag(node), "GradientStop")) + if (fz_xml_is_tag(node, "GradientStop")) { char *offset = fz_xml_att(node, "Offset"); char *color = fz_xml_att(node, "Color"); @@ -463,13 +463,13 @@ xps_parse_gradient_brush(xps_document *doc, const fz_matrix *ctm, const fz_rect for (node = fz_xml_down(root); node; node = fz_xml_next(node)) { - if (!strcmp(fz_xml_tag(node), "LinearGradientBrush.Transform")) + if (fz_xml_is_tag(node, "LinearGradientBrush.Transform")) transform_tag = fz_xml_down(node); - if (!strcmp(fz_xml_tag(node), "RadialGradientBrush.Transform")) + if (fz_xml_is_tag(node, "RadialGradientBrush.Transform")) transform_tag = fz_xml_down(node); - if (!strcmp(fz_xml_tag(node), "LinearGradientBrush.GradientStops")) + if (fz_xml_is_tag(node, "LinearGradientBrush.GradientStops")) stop_tag = fz_xml_down(node); - if (!strcmp(fz_xml_tag(node), "RadialGradientBrush.GradientStops")) + if (fz_xml_is_tag(node, "RadialGradientBrush.GradientStops")) stop_tag = fz_xml_down(node); } diff --git a/source/xps/xps-outline.c b/source/xps/xps-outline.c index 3a10ff41..e314e83e 100644 --- a/source/xps/xps-outline.c +++ b/source/xps/xps-outline.c @@ -22,7 +22,7 @@ xps_parse_document_outline(xps_document *doc, fz_xml *root) int last_level = 1, this_level; for (node = fz_xml_down(root); node; node = fz_xml_next(node)) { - if (!strcmp(fz_xml_tag(node), "OutlineEntry")) + if (fz_xml_is_tag(node, "OutlineEntry")) { char *level = fz_xml_att(node, "OutlineLevel"); char *target = fz_xml_att(node, "OutlineTarget"); @@ -63,13 +63,13 @@ static fz_outline * xps_parse_document_structure(xps_document *doc, fz_xml *root) { fz_xml *node; - if (!strcmp(fz_xml_tag(root), "DocumentStructure")) + if (fz_xml_is_tag(root, "DocumentStructure")) { node = fz_xml_down(root); - if (node && !strcmp(fz_xml_tag(node), "DocumentStructure.Outline")) + if (node && fz_xml_is_tag(node, "DocumentStructure.Outline")) { node = fz_xml_down(node); - if (node && !strcmp(fz_xml_tag(node), "DocumentOutline")) + if (node && fz_xml_is_tag(node, "DocumentOutline")) return xps_parse_document_outline(doc, node); } } diff --git a/source/xps/xps-path.c b/source/xps/xps-path.c index cf4f2ff7..49240ee4 100644 --- a/source/xps/xps-path.c +++ b/source/xps/xps-path.c @@ -668,13 +668,13 @@ xps_parse_path_figure(fz_context *doc, fz_path *path, fz_xml *root, int stroking for (node = fz_xml_down(root); node; node = fz_xml_next(node)) { - if (!strcmp(fz_xml_tag(node), "ArcSegment")) + if (fz_xml_is_tag(node, "ArcSegment")) xps_parse_arc_segment(doc, path, node, stroking, &skipped_stroke); - if (!strcmp(fz_xml_tag(node), "PolyBezierSegment")) + if (fz_xml_is_tag(node, "PolyBezierSegment")) xps_parse_poly_bezier_segment(doc, path, node, stroking, &skipped_stroke); - if (!strcmp(fz_xml_tag(node), "PolyLineSegment")) + if (fz_xml_is_tag(node, "PolyLineSegment")) xps_parse_poly_line_segment(doc, path, node, stroking, &skipped_stroke); - if (!strcmp(fz_xml_tag(node), "PolyQuadraticBezierSegment")) + if (fz_xml_is_tag(node, "PolyQuadraticBezierSegment")) xps_parse_poly_quadratic_bezier_segment(doc, path, node, stroking, &skipped_stroke); } @@ -708,7 +708,7 @@ xps_parse_path_geometry(xps_document *doc, xps_resource *dict, fz_xml *root, int for (node = fz_xml_down(root); node; node = fz_xml_next(node)) { - if (!strcmp(fz_xml_tag(node), "PathGeometry.Transform")) + if (fz_xml_is_tag(node, "PathGeometry.Transform")) transform_tag = fz_xml_down(node); } @@ -739,7 +739,7 @@ xps_parse_path_geometry(xps_document *doc, xps_resource *dict, fz_xml *root, int for (node = fz_xml_down(root); node; node = fz_xml_next(node)) { - if (!strcmp(fz_xml_tag(node), "PathFigure")) + if (fz_xml_is_tag(node, "PathFigure")) xps_parse_path_figure(doc->ctx, path, node, stroking); } @@ -855,17 +855,17 @@ xps_parse_path(xps_document *doc, const fz_matrix *ctm, char *base_uri, xps_reso for (node = fz_xml_down(root); node; node = fz_xml_next(node)) { - if (!strcmp(fz_xml_tag(node), "Path.RenderTransform")) + if (fz_xml_is_tag(node, "Path.RenderTransform")) transform_tag = fz_xml_down(node); - if (!strcmp(fz_xml_tag(node), "Path.OpacityMask")) + if (fz_xml_is_tag(node, "Path.OpacityMask")) opacity_mask_tag = fz_xml_down(node); - if (!strcmp(fz_xml_tag(node), "Path.Clip")) + if (fz_xml_is_tag(node, "Path.Clip")) clip_tag = fz_xml_down(node); - if (!strcmp(fz_xml_tag(node), "Path.Fill")) + if (fz_xml_is_tag(node, "Path.Fill")) fill_tag = fz_xml_down(node); - if (!strcmp(fz_xml_tag(node), "Path.Stroke")) + if (fz_xml_is_tag(node, "Path.Stroke")) stroke_tag = fz_xml_down(node); - if (!strcmp(fz_xml_tag(node), "Path.Data")) + if (fz_xml_is_tag(node, "Path.Data")) data_tag = fz_xml_down(node); } diff --git a/source/xps/xps-tile.c b/source/xps/xps-tile.c index 0225d76e..b65981a2 100644 --- a/source/xps/xps-tile.c +++ b/source/xps/xps-tile.c @@ -99,9 +99,9 @@ xps_parse_tiling_brush(xps_document *doc, const fz_matrix *ctm, const fz_rect *a for (node = fz_xml_down(root); node; node = fz_xml_next(node)) { - if (!strcmp(fz_xml_tag(node), "ImageBrush.Transform")) + if (fz_xml_is_tag(node, "ImageBrush.Transform")) transform_tag = fz_xml_down(node); - if (!strcmp(fz_xml_tag(node), "VisualBrush.Transform")) + if (fz_xml_is_tag(node, "VisualBrush.Transform")) transform_tag = fz_xml_down(node); } @@ -232,7 +232,7 @@ xps_parse_visual_brush(xps_document *doc, const fz_matrix *ctm, const fz_rect *a for (node = fz_xml_down(root); node; node = fz_xml_next(node)) { - if (!strcmp(fz_xml_tag(node), "VisualBrush.Visual")) + if (fz_xml_is_tag(node, "VisualBrush.Visual")) visual_tag = fz_xml_down(node); } @@ -273,7 +273,7 @@ xps_parse_canvas(xps_document *doc, const fz_matrix *ctm, const fz_rect *area, c for (node = fz_xml_down(root); node; node = fz_xml_next(node)) { - if (!strcmp(fz_xml_tag(node), "Canvas.Resources") && fz_xml_down(node)) + if (fz_xml_is_tag(node, "Canvas.Resources") && fz_xml_down(node)) { if (new_dict) { @@ -290,11 +290,11 @@ xps_parse_canvas(xps_document *doc, const fz_matrix *ctm, const fz_rect *area, c } } - if (!strcmp(fz_xml_tag(node), "Canvas.RenderTransform")) + if (fz_xml_is_tag(node, "Canvas.RenderTransform")) transform_tag = fz_xml_down(node); - if (!strcmp(fz_xml_tag(node), "Canvas.Clip")) + if (fz_xml_is_tag(node, "Canvas.Clip")) clip_tag = fz_xml_down(node); - if (!strcmp(fz_xml_tag(node), "Canvas.OpacityMask")) + if (fz_xml_is_tag(node, "Canvas.OpacityMask")) opacity_mask_tag = fz_xml_down(node); } @@ -360,7 +360,7 @@ xps_parse_fixed_page(xps_document *doc, const fz_matrix *ctm, xps_page *page) for (node = fz_xml_down(page->root); node; node = fz_xml_next(node)) { - if (!strcmp(fz_xml_tag(node), "FixedPage.Resources") && fz_xml_down(node)) + if (fz_xml_is_tag(node, "FixedPage.Resources") && fz_xml_down(node)) { if (dict) fz_warn(doc->ctx, "ignoring follow-up resource dictionaries"); -- cgit v1.2.3