summaryrefslogtreecommitdiff
path: root/xps
diff options
context:
space:
mode:
Diffstat (limited to 'xps')
-rw-r--r--xps/xps_doc.c16
-rw-r--r--xps/xps_glyphs.c2
-rw-r--r--xps/xps_image.c6
-rw-r--r--xps/xps_outline.c1
-rw-r--r--xps/xps_resource.c3
-rw-r--r--xps/xps_zip.c40
6 files changed, 38 insertions, 30 deletions
diff --git a/xps/xps_doc.c b/xps/xps_doc.c
index 0bee4931..9953cb37 100644
--- a/xps/xps_doc.c
+++ b/xps/xps_doc.c
@@ -400,7 +400,7 @@ xps_read_page_list(xps_document *doc)
xps_read_and_process_metadata_part(doc, "/_rels/.rels", NULL);
if (!doc->start_part)
- fz_throw(doc->ctx, "cannot find fixed document sequence start part");
+ fz_throw(doc->ctx, FZ_ERROR_GENERIC, "cannot find fixed document sequence start part");
xps_read_and_process_metadata_part(doc, doc->start_part, NULL);
@@ -414,6 +414,7 @@ xps_read_page_list(xps_document *doc)
}
fz_catch(doc->ctx)
{
+ /* FIXME: TryLater ? */
fz_warn(doc->ctx, "cannot process FixedDocument rels part");
}
xps_read_and_process_metadata_part(doc, fixdoc->name, fixdoc);
@@ -446,10 +447,11 @@ xps_load_fixed_page(xps_document *doc, xps_page *page)
}
fz_catch(ctx)
{
+ /* FIXME: TryLater ? */
root = NULL;
}
if (!root)
- fz_throw(doc->ctx, "FixedPage missing root element");
+ fz_throw(doc->ctx, FZ_ERROR_GENERIC, "FixedPage missing root element");
if (!strcmp(fz_xml_tag(root), "mc:AlternateContent"))
{
@@ -457,7 +459,7 @@ xps_load_fixed_page(xps_document *doc, xps_page *page)
if (!node)
{
fz_free_xml(doc->ctx, root);
- fz_throw(doc->ctx, "FixedPage missing alternate root element");
+ fz_throw(doc->ctx, FZ_ERROR_GENERIC, "FixedPage missing alternate root element");
}
fz_detach_xml(node);
fz_free_xml(doc->ctx, root);
@@ -467,21 +469,21 @@ xps_load_fixed_page(xps_document *doc, xps_page *page)
if (strcmp(fz_xml_tag(root), "FixedPage"))
{
fz_free_xml(doc->ctx, root);
- fz_throw(doc->ctx, "expected FixedPage element");
+ fz_throw(doc->ctx, FZ_ERROR_GENERIC, "expected FixedPage element");
}
width_att = fz_xml_att(root, "Width");
if (!width_att)
{
fz_free_xml(doc->ctx, root);
- fz_throw(doc->ctx, "FixedPage missing required attribute: Width");
+ fz_throw(doc->ctx, FZ_ERROR_GENERIC, "FixedPage missing required attribute: Width");
}
height_att = fz_xml_att(root, "Height");
if (!height_att)
{
fz_free_xml(doc->ctx, root);
- fz_throw(doc->ctx, "FixedPage missing required attribute: Height");
+ fz_throw(doc->ctx, FZ_ERROR_GENERIC, "FixedPage missing required attribute: Height");
}
page->width = atoi(width_att);
@@ -507,7 +509,7 @@ xps_load_page(xps_document *doc, int number)
n ++;
}
- fz_throw(doc->ctx, "cannot find page %d", number + 1);
+ fz_throw(doc->ctx, FZ_ERROR_GENERIC, "cannot find page %d", number + 1);
return NULL;
}
diff --git a/xps/xps_glyphs.c b/xps/xps_glyphs.c
index dd4487d4..72f37ca1 100644
--- a/xps/xps_glyphs.c
+++ b/xps/xps_glyphs.c
@@ -510,6 +510,7 @@ xps_parse_glyphs(xps_document *doc, const fz_matrix *ctm,
}
fz_catch(doc->ctx)
{
+ /* FIXME: TryLater ? */
fz_warn(doc->ctx, "cannot find font resource part '%s'", partname);
return;
}
@@ -526,6 +527,7 @@ xps_parse_glyphs(xps_document *doc, const fz_matrix *ctm,
}
fz_catch(doc->ctx)
{
+ /* FIXME: TryLater ? */
fz_warn(doc->ctx, "cannot load font resource '%s'", partname);
xps_free_part(doc, part);
return;
diff --git a/xps/xps_image.c b/xps/xps_image.c
index c00c96ae..eb0d876f 100644
--- a/xps/xps_image.c
+++ b/xps/xps_image.c
@@ -38,7 +38,7 @@ xps_find_image_brush_source_part(xps_document *doc, char *base_uri, fz_xml *root
image_source_att = fz_xml_att(root, "ImageSource");
if (!image_source_att)
- fz_throw(doc->ctx, "cannot find image source attribute");
+ fz_throw(doc->ctx, FZ_ERROR_GENERIC, "cannot find image source attribute");
/* "{ColorConvertedBitmap /Resources/Image.tiff /Resources/Profile.icc}" */
if (strstr(image_source_att, "{ColorConvertedBitmap") == image_source_att)
@@ -69,7 +69,7 @@ xps_find_image_brush_source_part(xps_document *doc, char *base_uri, fz_xml *root
}
if (!image_name)
- fz_throw(doc->ctx, "cannot find image source");
+ fz_throw(doc->ctx, FZ_ERROR_GENERIC, "cannot find image source");
if (image_part)
{
@@ -102,6 +102,7 @@ xps_parse_image_brush(xps_document *doc, const fz_matrix *ctm, const fz_rect *ar
}
fz_catch(doc->ctx)
{
+ /* FIXME: TryLater ? */
fz_warn(doc->ctx, "cannot find image source");
return;
}
@@ -116,6 +117,7 @@ xps_parse_image_brush(xps_document *doc, const fz_matrix *ctm, const fz_rect *ar
}
fz_catch(doc->ctx)
{
+ /* FIXME: TryLater ? */
fz_warn(doc->ctx, "cannot decode image resource");
return;
}
diff --git a/xps/xps_outline.c b/xps/xps_outline.c
index bb5eccb0..b87460a4 100644
--- a/xps/xps_outline.c
+++ b/xps/xps_outline.c
@@ -131,6 +131,7 @@ xps_load_outline(xps_document *doc)
}
fz_catch(doc->ctx)
{
+ /* FIXME: TryLater ? */
outline = NULL;
}
if (!outline)
diff --git a/xps/xps_resource.c b/xps/xps_resource.c
index 658129c9..5c927e1d 100644
--- a/xps/xps_resource.c
+++ b/xps/xps_resource.c
@@ -75,6 +75,7 @@ xps_parse_remote_resource_dictionary(xps_document *doc, char *base_uri, char *so
}
fz_catch(ctx)
{
+ /* FIXME: TryLater ? */
xml = NULL;
}
@@ -84,7 +85,7 @@ xps_parse_remote_resource_dictionary(xps_document *doc, char *base_uri, char *so
if (strcmp(fz_xml_tag(xml), "ResourceDictionary"))
{
fz_free_xml(doc->ctx, xml);
- fz_throw(doc->ctx, "expected ResourceDictionary element");
+ fz_throw(doc->ctx, FZ_ERROR_GENERIC, "expected ResourceDictionary element");
}
fz_strlcpy(part_uri, part_name, sizeof part_uri);
diff --git a/xps/xps_zip.c b/xps/xps_zip.c
index 0bda1341..70b643af 100644
--- a/xps/xps_zip.c
+++ b/xps/xps_zip.c
@@ -113,7 +113,7 @@ xps_read_zip_entry(xps_document *doc, xps_entry *ent, unsigned char *outbuf)
sig = getlong(doc->file);
if (sig != ZIP_LOCAL_FILE_SIG)
{
- fz_throw(doc->ctx, "wrong zip local file signature (0x%x)", sig);
+ fz_throw(doc->ctx, FZ_ERROR_GENERIC, "wrong zip local file signature (0x%x)", sig);
}
(void) getshort(doc->file); /* version */
@@ -152,27 +152,27 @@ xps_read_zip_entry(xps_document *doc, xps_entry *ent, unsigned char *outbuf)
if (code != Z_OK)
{
fz_free(ctx, inbuf);
- fz_throw(ctx, "zlib inflateInit2 error: %s", stream.msg);
+ fz_throw(ctx, FZ_ERROR_GENERIC, "zlib inflateInit2 error: %s", stream.msg);
}
code = inflate(&stream, Z_FINISH);
if (code != Z_STREAM_END)
{
inflateEnd(&stream);
fz_free(ctx, inbuf);
- fz_throw(ctx, "zlib inflate error: %s", stream.msg);
+ fz_throw(ctx, FZ_ERROR_GENERIC, "zlib inflate error: %s", stream.msg);
}
code = inflateEnd(&stream);
if (code != Z_OK)
{
fz_free(ctx, inbuf);
- fz_throw(ctx, "zlib inflateEnd error: %s", stream.msg);
+ fz_throw(ctx, FZ_ERROR_GENERIC, "zlib inflateEnd error: %s", stream.msg);
}
fz_free(ctx, inbuf);
}
else
{
- fz_throw(ctx, "unknown compression method (%d)", method);
+ fz_throw(ctx, FZ_ERROR_GENERIC, "unknown compression method (%d)", method);
}
}
@@ -192,7 +192,7 @@ xps_read_zip_dir(xps_document *doc, int start_offset)
sig = getlong(doc->file);
if (sig != ZIP_END_OF_CENTRAL_DIRECTORY_SIG)
- fz_throw(doc->ctx, "wrong zip end of central directory signature (0x%x)", sig);
+ fz_throw(doc->ctx, FZ_ERROR_GENERIC, "wrong zip end of central directory signature (0x%x)", sig);
(void) getshort(doc->file); /* this disk */
(void) getshort(doc->file); /* start disk */
@@ -208,18 +208,18 @@ xps_read_zip_dir(xps_document *doc, int start_offset)
sig = getlong(doc->file);
if (sig != ZIP64_END_OF_CENTRAL_DIRECTORY_LOCATOR_SIG)
- fz_throw(doc->ctx, "wrong zip64 end of central directory locator signature (0x%x)", sig);
+ fz_throw(doc->ctx, FZ_ERROR_GENERIC, "wrong zip64 end of central directory locator signature (0x%x)", sig);
(void) getlong(doc->file); /* start disk */
offset = getlong64(doc->file); /* offset to end of central directory record */
if (offset < 0)
- fz_throw(doc->ctx, "zip64 files larger than 2 GB aren't supported");
+ fz_throw(doc->ctx, FZ_ERROR_GENERIC, "zip64 files larger than 2 GB aren't supported");
fz_seek(doc->file, offset, 0);
sig = getlong(doc->file);
if (sig != ZIP64_END_OF_CENTRAL_DIRECTORY_SIG)
- fz_throw(doc->ctx, "wrong zip64 end of central directory signature (0x%x)", sig);
+ fz_throw(doc->ctx, FZ_ERROR_GENERIC, "wrong zip64 end of central directory signature (0x%x)", sig);
(void) getlong64(doc->file); /* size of record */
(void) getshort(doc->file); /* version made by */
@@ -232,7 +232,7 @@ xps_read_zip_dir(xps_document *doc, int start_offset)
offset = getlong64(doc->file); /* offset to central directory */
if (count < 0 || offset < 0)
- fz_throw(doc->ctx, "zip64 files larger than 2 GB aren't supported");
+ fz_throw(doc->ctx, FZ_ERROR_GENERIC, "zip64 files larger than 2 GB aren't supported");
}
doc->zip_table = fz_malloc_array(doc->ctx, count, sizeof(xps_entry));
@@ -245,7 +245,7 @@ xps_read_zip_dir(xps_document *doc, int start_offset)
{
sig = getlong(doc->file);
if (sig != ZIP_CENTRAL_DIRECTORY_SIG)
- fz_throw(doc->ctx, "wrong zip central directory signature (0x%x)", sig);
+ fz_throw(doc->ctx, FZ_ERROR_GENERIC, "wrong zip central directory signature (0x%x)", sig);
(void) getshort(doc->file); /* version made by */
(void) getshort(doc->file); /* version to extract */
@@ -283,7 +283,7 @@ xps_read_zip_dir(xps_document *doc, int start_offset)
metasize -= 4 + size;
}
if (doc->zip_table[i].usize < 0 || doc->zip_table[i].csize < 0 || doc->zip_table[i].offset < 0)
- fz_throw(doc->ctx, "zip64 files larger than 2 GB aren't supported");
+ fz_throw(doc->ctx, FZ_ERROR_GENERIC, "zip64 files larger than 2 GB aren't supported");
fz_seek(doc->file, commentsize, 1);
}
@@ -321,7 +321,7 @@ xps_find_and_read_zip_dir(xps_document *doc)
back += sizeof buf - 4;
}
- fz_throw(ctx, "cannot find end of central directory");
+ fz_throw(ctx, FZ_ERROR_GENERIC, "cannot find end of central directory");
}
/*
@@ -377,7 +377,7 @@ xps_read_zip_part(xps_document *doc, char *partname)
size += ent->usize;
}
if (!seen_last)
- fz_throw(doc->ctx, "cannot find all pieces for part '%s'", partname);
+ fz_throw(doc->ctx, FZ_ERROR_GENERIC, "cannot find all pieces for part '%s'", partname);
/* Inflate the pieces */
if (count)
@@ -405,7 +405,7 @@ xps_read_zip_part(xps_document *doc, char *partname)
return part;
}
- fz_throw(doc->ctx, "cannot find part '%s'", partname);
+ fz_throw(doc->ctx, FZ_ERROR_GENERIC, "cannot find part '%s'", partname);
return NULL;
}
@@ -475,7 +475,7 @@ xps_read_dir_part(xps_document *doc, char *name)
fclose(file);
}
if (!seen_last)
- fz_throw(doc->ctx, "cannot find all pieces for part '%s'", name);
+ fz_throw(doc->ctx, FZ_ERROR_GENERIC, "cannot find all pieces for part '%s'", name);
/* Inflate the pieces */
if (count)
@@ -492,7 +492,7 @@ xps_read_dir_part(xps_document *doc, char *name)
if (!file)
{
xps_free_part(doc, part);
- fz_throw(doc->ctx, "cannot open file '%s'", buf);
+ fz_throw(doc->ctx, FZ_ERROR_GENERIC, "cannot open file '%s'", buf);
}
n = fread(part->data + offset, 1, size - offset, file);
offset += n;
@@ -501,7 +501,7 @@ xps_read_dir_part(xps_document *doc, char *name)
return part;
}
- fz_throw(doc->ctx, "cannot find part '%s'", name);
+ fz_throw(doc->ctx, FZ_ERROR_GENERIC, "cannot find part '%s'", name);
return NULL;
}
@@ -619,7 +619,7 @@ xps_open_document(fz_context *ctx, const char *filename)
file = fz_open_file(ctx, filename);
if (!file)
- fz_throw(ctx, "cannot open file '%s': %s", filename, strerror(errno));
+ fz_throw(ctx, FZ_ERROR_GENERIC, "cannot open file '%s': %s", filename, strerror(errno));
fz_try(ctx)
{
@@ -631,7 +631,7 @@ xps_open_document(fz_context *ctx, const char *filename)
}
fz_catch(ctx)
{
- fz_throw(ctx, "cannot load document '%s'", filename);
+ fz_rethrow_message(ctx, "cannot load document '%s'", filename);
}
return doc;
}