summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mupdf/pdf/annot.h33
-rw-r--r--platform/java/mupdf_native.c25
-rw-r--r--platform/java/mupdf_native.h16
-rw-r--r--platform/java/src/com/artifex/mupdf/fitz/PDFAnnotation.java8
-rw-r--r--source/pdf/pdf-annot-edit.c101
5 files changed, 114 insertions, 69 deletions
diff --git a/include/mupdf/pdf/annot.h b/include/mupdf/pdf/annot.h
index 1fb0ab0e..4c3a8b75 100644
--- a/include/mupdf/pdf/annot.h
+++ b/include/mupdf/pdf/annot.h
@@ -32,7 +32,7 @@ enum pdf_annot_type
};
const char *pdf_string_from_annot_type(fz_context *ctx, enum pdf_annot_type type);
-int pdf_annot_type_from_string(fz_context *ctx, const char *subtype);
+enum pdf_annot_type pdf_annot_type_from_string(fz_context *ctx, const char *subtype);
enum
{
@@ -48,20 +48,25 @@ enum
PDF_ANNOT_IS_LOCKED_CONTENTS = 1 << (10-1)
};
-enum
+enum pdf_line_ending
{
- PDF_ANNOT_LINE_ENDING_NONE = 0,
- PDF_ANNOT_LINE_ENDING_SQUARE,
- PDF_ANNOT_LINE_ENDING_CIRCLE,
- PDF_ANNOT_LINE_ENDING_DIAMOND,
- PDF_ANNOT_LINE_ENDING_OPENARROW,
- PDF_ANNOT_LINE_ENDING_CLOSEDARROW,
- PDF_ANNOT_LINE_ENDING_BUTT,
- PDF_ANNOT_LINE_ENDING_ROPENARROW,
- PDF_ANNOT_LINE_ENDING_RCLOSEDARROW,
- PDF_ANNOT_LINE_ENDING_SLASH
+ PDF_ANNOT_LE_NONE = 0,
+ PDF_ANNOT_LE_SQUARE,
+ PDF_ANNOT_LE_CIRCLE,
+ PDF_ANNOT_LE_DIAMOND,
+ PDF_ANNOT_LE_OPEN_ARROW,
+ PDF_ANNOT_LE_CLOSED_ARROW,
+ PDF_ANNOT_LE_BUTT,
+ PDF_ANNOT_LE_R_OPEN_ARROW,
+ PDF_ANNOT_LE_R_CLOSED_ARROW,
+ PDF_ANNOT_LE_SLASH
};
+enum pdf_line_ending pdf_line_ending_from_name(fz_context *ctx, pdf_obj *end);
+enum pdf_line_ending pdf_line_ending_from_string(fz_context *ctx, const char *end);
+pdf_obj *pdf_name_from_line_ending(fz_context *ctx, enum pdf_line_ending end);
+const char *pdf_string_from_line_ending(fz_context *ctx, enum pdf_line_ending end);
+
/*
pdf_first_annot: Return the first annotation on a page.
*/
@@ -174,11 +179,11 @@ void pdf_set_annot_ink_list(fz_context *ctx, pdf_annot *annot, int n, const int
void pdf_clear_annot_ink_list(fz_context *ctx, pdf_annot *annot);
void pdf_add_annot_ink_list(fz_context *ctx, pdf_annot *annot, int n, fz_point stroke[]);
-void pdf_set_annot_line_ending_styles(fz_context *ctx, pdf_annot *annot, int start_style, int end_style);
+void pdf_set_annot_line_ending_styles(fz_context *ctx, pdf_annot *annot, enum pdf_line_ending start_style, enum pdf_line_ending end_style);
void pdf_set_annot_icon_name(fz_context *ctx, pdf_annot *annot, const char *name);
void pdf_set_annot_is_open(fz_context *ctx, pdf_annot *annot, int is_open);
-void pdf_annot_line_ending_styles(fz_context *ctx, pdf_annot *annot, int *start_style, int *end_style);
+void pdf_annot_line_ending_styles(fz_context *ctx, pdf_annot *annot, enum pdf_line_ending *start_style, enum pdf_line_ending *end_style);
const char *pdf_annot_icon_name(fz_context *ctx, pdf_annot *annot);
int pdf_annot_is_open(fz_context *ctx, pdf_annot *annot);
diff --git a/platform/java/mupdf_native.c b/platform/java/mupdf_native.c
index 69546564..29e87b8b 100644
--- a/platform/java/mupdf_native.c
+++ b/platform/java/mupdf_native.c
@@ -247,16 +247,16 @@ static int check_enums()
valid &= com_artifex_mupdf_fitz_PDFAnnotation_TYPE_3D == PDF_ANNOT_3D;
valid &= com_artifex_mupdf_fitz_PDFAnnotation_TYPE_UNKNOWN == PDF_ANNOT_UNKNOWN;
- valid &= com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_NONE == PDF_ANNOT_LINE_ENDING_NONE;
- valid &= com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_SQUARE == PDF_ANNOT_LINE_ENDING_SQUARE;
- valid &= com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_CIRCLE == PDF_ANNOT_LINE_ENDING_CIRCLE;
- valid &= com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_DIAMOND == PDF_ANNOT_LINE_ENDING_DIAMOND;
- valid &= com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_OPENARROW == PDF_ANNOT_LINE_ENDING_OPENARROW;
- valid &= com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_CLOSEDARROW == PDF_ANNOT_LINE_ENDING_CLOSEDARROW;
- valid &= com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_BUTT == PDF_ANNOT_LINE_ENDING_BUTT;
- valid &= com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_ROPENARR == PDF_ANNOT_LINE_ENDING_ROPENARROW;
- valid &= com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_RCLOSEDARROW == PDF_ANNOT_LINE_ENDING_RCLOSEDARROW;
- valid &= com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_SLASH == PDF_ANNOT_LINE_ENDING_SLASH;
+ valid &= com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_NONE == PDF_ANNOT_LE_NONE;
+ valid &= com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_SQUARE == PDF_ANNOT_LE_SQUARE;
+ valid &= com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_CIRCLE == PDF_ANNOT_LE_CIRCLE;
+ valid &= com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_DIAMOND == PDF_ANNOT_LE_DIAMOND;
+ valid &= com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_OPEN_ARROW == PDF_ANNOT_LE_OPEN_ARROW;
+ valid &= com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_CLOSED_ARROW == PDF_ANNOT_LE_CLOSED_ARROW;
+ valid &= com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_BUTT == PDF_ANNOT_LE_BUTT;
+ valid &= com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_R_OPEN_ARROW == PDF_ANNOT_LE_R_OPEN_ARROW;
+ valid &= com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_R_CLOSED_ARROW == PDF_ANNOT_LE_R_CLOSED_ARROW;
+ valid &= com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_SLASH == PDF_ANNOT_LE_SLASH;
return valid ? 1 : 0;
}
@@ -9379,16 +9379,19 @@ FUN(PDFAnnotation_getLineEndingStyles)(JNIEnv *env, jobject self)
{
fz_context *ctx = get_context(env);
pdf_annot *annot = from_PDFAnnotation(env, self);
+ enum pdf_line_ending s = 0, e = 0;
int line_endings[2];
jintArray jline_endings = NULL;
if (!ctx || !annot) return NULL;
fz_try(ctx)
- pdf_annot_line_ending_styles(ctx, annot, &line_endings[0], &line_endings[1]);
+ pdf_annot_line_ending_styles(ctx, annot, &s, &e);
fz_catch(ctx)
jni_rethrow(env, ctx);
+ line_endings[0] = s;
+ line_endings[1] = e;
jline_endings = (*env)->NewIntArray(env, 2);
(*env)->SetIntArrayRegion(env, jline_endings, 0, 2, &line_endings[0]);
if ((*env)->ExceptionCheck(env)) return NULL;
diff --git a/platform/java/mupdf_native.h b/platform/java/mupdf_native.h
index 2ccaf01f..8bfe3480 100644
--- a/platform/java/mupdf_native.h
+++ b/platform/java/mupdf_native.h
@@ -1423,16 +1423,16 @@ extern "C" {
#define com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_CIRCLE 2L
#undef com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_DIAMOND
#define com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_DIAMOND 3L
-#undef com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_OPENARROW
-#define com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_OPENARROW 4L
-#undef com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_CLOSEDARROW
-#define com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_CLOSEDARROW 5L
+#undef com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_OPEN_ARROW
+#define com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_OPEN_ARROW 4L
+#undef com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_CLOSED_ARROW
+#define com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_CLOSED_ARROW 5L
#undef com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_BUTT
#define com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_BUTT 6L
-#undef com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_ROPENARR
-#define com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_ROPENARR 7L
-#undef com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_RCLOSEDARROW
-#define com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_RCLOSEDARROW 8L
+#undef com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_R_OPEN_ARROW
+#define com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_R_OPEN_ARROW 7L
+#undef com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_R_CLOSED_ARROW
+#define com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_R_CLOSED_ARROW 8L
#undef com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_SLASH
#define com_artifex_mupdf_fitz_PDFAnnotation_LINE_ENDING_SLASH 9L
/*
diff --git a/platform/java/src/com/artifex/mupdf/fitz/PDFAnnotation.java b/platform/java/src/com/artifex/mupdf/fitz/PDFAnnotation.java
index 52a433de..2e4a83cd 100644
--- a/platform/java/src/com/artifex/mupdf/fitz/PDFAnnotation.java
+++ b/platform/java/src/com/artifex/mupdf/fitz/PDFAnnotation.java
@@ -42,11 +42,11 @@ public class PDFAnnotation extends Annotation
public static final int LINE_ENDING_SQUARE = 1;
public static final int LINE_ENDING_CIRCLE = 2;
public static final int LINE_ENDING_DIAMOND = 3;
- public static final int LINE_ENDING_OPENARROW = 4;
- public static final int LINE_ENDING_CLOSEDARROW = 5;
+ public static final int LINE_ENDING_OPEN_ARROW = 4;
+ public static final int LINE_ENDING_CLOSED_ARROW = 5;
public static final int LINE_ENDING_BUTT = 6;
- public static final int LINE_ENDING_ROPENARR = 7;
- public static final int LINE_ENDING_RCLOSEDARROW = 8;
+ public static final int LINE_ENDING_R_OPEN_ARROW = 7;
+ public static final int LINE_ENDING_R_CLOSED_ARROW = 8;
public static final int LINE_ENDING_SLASH = 9;
public native int getType();
diff --git a/source/pdf/pdf-annot-edit.c b/source/pdf/pdf-annot-edit.c
index 1138e72d..20cc8edd 100644
--- a/source/pdf/pdf-annot-edit.c
+++ b/source/pdf/pdf-annot-edit.c
@@ -350,36 +350,69 @@ pdf_set_annot_icon_name(fz_context *ctx, pdf_annot *annot, const char *name)
pdf_dirty_annot(ctx, annot);
}
-static int line_ending_value(fz_context *ctx, pdf_obj *line_ending)
-{
- if (pdf_name_eq(ctx, line_ending, PDF_NAME_None)) return PDF_ANNOT_LINE_ENDING_NONE;
- else if (pdf_name_eq(ctx, line_ending, PDF_NAME_Square)) return PDF_ANNOT_LINE_ENDING_SQUARE;
- else if (pdf_name_eq(ctx, line_ending, PDF_NAME_Circle)) return PDF_ANNOT_LINE_ENDING_CIRCLE;
- else if (pdf_name_eq(ctx, line_ending, PDF_NAME_Diamond)) return PDF_ANNOT_LINE_ENDING_DIAMOND;
- else if (pdf_name_eq(ctx, line_ending, PDF_NAME_OpenArrow)) return PDF_ANNOT_LINE_ENDING_OPENARROW;
- else if (pdf_name_eq(ctx, line_ending, PDF_NAME_ClosedArrow)) return PDF_ANNOT_LINE_ENDING_CLOSEDARROW;
- else if (pdf_name_eq(ctx, line_ending, PDF_NAME_Butt)) return PDF_ANNOT_LINE_ENDING_BUTT;
- else if (pdf_name_eq(ctx, line_ending, PDF_NAME_ROpenArrow)) return PDF_ANNOT_LINE_ENDING_ROPENARROW;
- else if (pdf_name_eq(ctx, line_ending, PDF_NAME_RClosedArrow)) return PDF_ANNOT_LINE_ENDING_RCLOSEDARROW;
- else if (pdf_name_eq(ctx, line_ending, PDF_NAME_Slash)) return PDF_ANNOT_LINE_ENDING_SLASH;
- else return PDF_ANNOT_LINE_ENDING_NONE;
+enum pdf_line_ending pdf_line_ending_from_name(fz_context *ctx, pdf_obj *end)
+{
+ if (pdf_name_eq(ctx, end, PDF_NAME_None)) return PDF_ANNOT_LE_NONE;
+ else if (pdf_name_eq(ctx, end, PDF_NAME_Square)) return PDF_ANNOT_LE_SQUARE;
+ else if (pdf_name_eq(ctx, end, PDF_NAME_Circle)) return PDF_ANNOT_LE_CIRCLE;
+ else if (pdf_name_eq(ctx, end, PDF_NAME_Diamond)) return PDF_ANNOT_LE_DIAMOND;
+ else if (pdf_name_eq(ctx, end, PDF_NAME_OpenArrow)) return PDF_ANNOT_LE_OPEN_ARROW;
+ else if (pdf_name_eq(ctx, end, PDF_NAME_ClosedArrow)) return PDF_ANNOT_LE_CLOSED_ARROW;
+ else if (pdf_name_eq(ctx, end, PDF_NAME_Butt)) return PDF_ANNOT_LE_BUTT;
+ else if (pdf_name_eq(ctx, end, PDF_NAME_ROpenArrow)) return PDF_ANNOT_LE_R_OPEN_ARROW;
+ else if (pdf_name_eq(ctx, end, PDF_NAME_RClosedArrow)) return PDF_ANNOT_LE_R_CLOSED_ARROW;
+ else if (pdf_name_eq(ctx, end, PDF_NAME_Slash)) return PDF_ANNOT_LE_SLASH;
+ else return PDF_ANNOT_LE_NONE;
+}
+
+enum pdf_line_ending pdf_line_ending_from_string(fz_context *ctx, const char *end)
+{
+ if (!strcmp(end, "None")) return PDF_ANNOT_LE_NONE;
+ else if (!strcmp(end, "Square")) return PDF_ANNOT_LE_SQUARE;
+ else if (!strcmp(end, "Circle")) return PDF_ANNOT_LE_CIRCLE;
+ else if (!strcmp(end, "Diamond")) return PDF_ANNOT_LE_DIAMOND;
+ else if (!strcmp(end, "OpenArrow")) return PDF_ANNOT_LE_OPEN_ARROW;
+ else if (!strcmp(end, "ClosedArrow")) return PDF_ANNOT_LE_CLOSED_ARROW;
+ else if (!strcmp(end, "Butt")) return PDF_ANNOT_LE_BUTT;
+ else if (!strcmp(end, "ROpenArrow")) return PDF_ANNOT_LE_R_OPEN_ARROW;
+ else if (!strcmp(end, "RClosedArrow")) return PDF_ANNOT_LE_R_CLOSED_ARROW;
+ else if (!strcmp(end, "Slash")) return PDF_ANNOT_LE_SLASH;
+ else return PDF_ANNOT_LE_NONE;
+}
+
+pdf_obj *pdf_name_from_line_ending(fz_context *ctx, enum pdf_line_ending end)
+{
+ switch (end)
+ {
+ default:
+ case PDF_ANNOT_LE_NONE: return PDF_NAME_None;
+ case PDF_ANNOT_LE_SQUARE: return PDF_NAME_Square;
+ case PDF_ANNOT_LE_CIRCLE: return PDF_NAME_Circle;
+ case PDF_ANNOT_LE_DIAMOND: return PDF_NAME_Diamond;
+ case PDF_ANNOT_LE_OPEN_ARROW: return PDF_NAME_OpenArrow;
+ case PDF_ANNOT_LE_CLOSED_ARROW: return PDF_NAME_ClosedArrow;
+ case PDF_ANNOT_LE_BUTT: return PDF_NAME_Butt;
+ case PDF_ANNOT_LE_R_OPEN_ARROW: return PDF_NAME_ROpenArrow;
+ case PDF_ANNOT_LE_R_CLOSED_ARROW: return PDF_NAME_RClosedArrow;
+ case PDF_ANNOT_LE_SLASH: return PDF_NAME_Slash;
+ }
}
-static pdf_obj *line_ending_name(fz_context *ctx, int line_ending)
+const char *pdf_string_from_line_ending(fz_context *ctx, enum pdf_line_ending end)
{
- switch (line_ending)
+ switch (end)
{
- case PDF_ANNOT_LINE_ENDING_NONE: return PDF_NAME_None;
- case PDF_ANNOT_LINE_ENDING_SQUARE: return PDF_NAME_Square;
- case PDF_ANNOT_LINE_ENDING_CIRCLE: return PDF_NAME_Circle;
- case PDF_ANNOT_LINE_ENDING_DIAMOND: return PDF_NAME_Diamond;
- case PDF_ANNOT_LINE_ENDING_OPENARROW: return PDF_NAME_OpenArrow;
- case PDF_ANNOT_LINE_ENDING_CLOSEDARROW: return PDF_NAME_ClosedArrow;
- case PDF_ANNOT_LINE_ENDING_BUTT: return PDF_NAME_Butt;
- case PDF_ANNOT_LINE_ENDING_ROPENARROW: return PDF_NAME_ROpenArrow;
- case PDF_ANNOT_LINE_ENDING_RCLOSEDARROW: return PDF_NAME_RClosedArrow;
- case PDF_ANNOT_LINE_ENDING_SLASH: return PDF_NAME_Slash;
- default: fz_throw(ctx, FZ_ERROR_GENERIC, "invalid line ending style");
+ default:
+ case PDF_ANNOT_LE_NONE: return "None";
+ case PDF_ANNOT_LE_SQUARE: return "Square";
+ case PDF_ANNOT_LE_CIRCLE: return "Circle";
+ case PDF_ANNOT_LE_DIAMOND: return "Diamond";
+ case PDF_ANNOT_LE_OPEN_ARROW: return "OpenArrow";
+ case PDF_ANNOT_LE_CLOSED_ARROW: return "ClosedArrow";
+ case PDF_ANNOT_LE_BUTT: return "Butt";
+ case PDF_ANNOT_LE_R_OPEN_ARROW: return "ROpenArrow";
+ case PDF_ANNOT_LE_R_CLOSED_ARROW: return "RClosedArrow";
+ case PDF_ANNOT_LE_SLASH: return "Slash";
}
}
@@ -398,25 +431,29 @@ pdf_annot_has_line_ending_styles(fz_context *ctx, pdf_annot *annot)
}
void
-pdf_annot_line_ending_styles(fz_context *ctx, pdf_annot *annot, int *start_style, int *end_style)
+pdf_annot_line_ending_styles(fz_context *ctx, pdf_annot *annot,
+ enum pdf_line_ending *start_style,
+ enum pdf_line_ending *end_style)
{
pdf_obj *style;
check_allowed_subtypes(ctx, annot, PDF_NAME_LE, line_ending_subtypes);
style = pdf_dict_get(ctx, annot->obj, PDF_NAME_LE);
- *start_style = line_ending_value(ctx, pdf_array_get(ctx, style, 0));
- *end_style = line_ending_value(ctx, pdf_array_get(ctx, style, 1));
+ *start_style = pdf_line_ending_from_name(ctx, pdf_array_get(ctx, style, 0));
+ *end_style = pdf_line_ending_from_name(ctx, pdf_array_get(ctx, style, 1));
}
void
-pdf_set_annot_line_ending_styles(fz_context *ctx, pdf_annot *annot, int start_style, int end_style)
+pdf_set_annot_line_ending_styles(fz_context *ctx, pdf_annot *annot,
+ enum pdf_line_ending start_style,
+ enum pdf_line_ending end_style)
{
pdf_document *doc = annot->page->doc;
pdf_obj *style;
check_allowed_subtypes(ctx, annot, PDF_NAME_LE, line_ending_subtypes);
style = pdf_new_array(ctx, doc, 2);
pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_LE, style);
- pdf_array_put_drop(ctx, style, 0, line_ending_name(ctx, start_style));
- pdf_array_put_drop(ctx, style, 1, line_ending_name(ctx, end_style));
+ pdf_array_put_drop(ctx, style, 0, pdf_name_from_line_ending(ctx, start_style));
+ pdf_array_put_drop(ctx, style, 1, pdf_name_from_line_ending(ctx, end_style));
pdf_dirty_annot(ctx, annot);
}