[evince/wip/chpe/xmp: 9/9] djvu: Extract XMP metadata




commit a2352f56bff99a468fe4f02ff0108467a657168e
Author: Christian Persch <chpe src gnome org>
Date:   Sat Dec 4 01:06:21 2021 +0100

    djvu: Extract XMP metadata
    
    Based on a patch by Daniel Bershatsky.
    
    https://gitlab.gnome.org/GNOME/evince/-/merge_requests/342

 backend/djvu/djvu-document.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)
---
diff --git a/backend/djvu/djvu-document.c b/backend/djvu/djvu-document.c
index 45cf33d15..f52d414ce 100644
--- a/backend/djvu/djvu-document.c
+++ b/backend/djvu/djvu-document.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
 /*
  * Copyright (C) 2005, Nickolay V. Shmyrev <nshmyrev yandex ru>
  *
@@ -522,6 +521,31 @@ djvu_document_get_thumbnail_surface (EvDocument      *document,
        return surface;
 }
 
+static EvDocumentInfo *
+djvu_document_get_info (EvDocument *document)
+{
+        DjvuDocument *djvu_document = DJVU_DOCUMENT (document);
+        const char *xmp;
+        miniexp_t anno;
+        EvDocumentInfo *info;
+
+        info = ev_document_info_new ();
+
+        anno = ddjvu_document_get_anno (djvu_document->d_document, 1);
+        if (anno == miniexp_nil) {
+                ddjvu_miniexp_release (djvu_document->d_document, anno);
+                return info;
+        }
+
+        xmp = ddjvu_anno_get_xmp (anno);
+        if (xmp != NULL) {
+                ev_document_info_set_from_xmp (info, xmp);
+        }
+
+        ddjvu_miniexp_release (djvu_document->d_document, anno);
+        return info;
+}
+
 static void
 djvu_document_finalize (GObject *object)
 {
@@ -566,6 +590,7 @@ djvu_document_class_init (DjvuDocumentClass *klass)
        ev_document_class->render = djvu_document_render;
        ev_document_class->get_thumbnail = djvu_document_get_thumbnail;
        ev_document_class->get_thumbnail_surface = djvu_document_get_thumbnail_surface;
+       ev_document_class->get_info = djvu_document_get_info;
 }
 
 static gchar *


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]