]> www.fi.muni.cz Git - evince.git/blobdiff - backend/ev-document-factory.c
Enable print to a PDF. Fixes bug #332121.
[evince.git] / backend / ev-document-factory.c
index 278a21a1be1976a4531d5b55c620fffc8dc48139..f524e1a0e0724f0f0e4a3be36527c3e812eea9d2 100644 (file)
 
 /* The various document type backends: */
 #include "ev-poppler.h"
-#include "pixbuf-document.h"
-#include "tiff-document.h"
-#include "impress-document.h"
 
 #ifdef ENABLE_PS
 #include "ps-document.h"
 #endif
+#ifdef ENABLE_TIFF
+#include "tiff-document.h"
+#endif
 #ifdef ENABLE_DVI
 #include "dvi-document.h"
 #endif
+#ifdef ENABLE_PIXBUF
+#include "pixbuf-document.h"
+#endif
 #ifdef ENABLE_DJVU
 #include "djvu-document.h"
 #endif
 #ifdef ENABLE_COMICS
 #include "comics-document.h"
 #endif
+#ifdef ENABLE_IMPRESS
+#include "impress-document.h"
+#endif
 
 #include <string.h>
 #include <glib/gi18n.h>
@@ -69,11 +75,6 @@ const EvDocumentType document_types[] = {
        {"image/x-eps",                EV_BACKEND_PS,   ps_document_get_type},
 #endif
 
-#ifdef ENABLE_IMPRESS
-       /* Impress slides: */
-       {"application/vnd.sun.xml.impress", EV_BACKEND_IMPRESS, impress_document_get_type},
-#endif
-
 #ifdef ENABLE_TIFF
        /* Tiff: */
        {"image/tiff",                 EV_BACKEND_TIFF, tiff_document_get_type},
@@ -94,6 +95,13 @@ const EvDocumentType document_types[] = {
        {"application/x-cbr",           EV_BACKEND_COMICS,  comics_document_get_type},
        {"application/x-cbz",           EV_BACKEND_COMICS,  comics_document_get_type},
 #endif
+
+#ifdef ENABLE_IMPRESS
+       /* Impress slides: */
+       {"application/vnd.sun.xml.impress", EV_BACKEND_IMPRESS, impress_document_get_type},
+       {"application/vnd.oasis.opendocument.presentation", EV_BACKEND_IMPRESS, impress_document_get_type},
+#endif
+
 };
 
 #ifdef ENABLE_PIXBUF
@@ -291,19 +299,23 @@ ev_document_factory_get_document (const char *uri, GError **error)
 
        document = get_document_from_uri (uri, FALSE, error);
 
-       if (*error != NULL) {
-               return NULL;
-       }
+       if (*error == NULL) {
+               result = ev_document_load (document, uri, error);
 
-       result = ev_document_load (document, uri, error);
-       
-       if (result == FALSE || *error) {
-               if (document)
-                       g_object_unref (document);
-               document = NULL;
-       } else {
-               return document;
+               if (result == FALSE || *error) {
+                       if (*error &&
+                           (*error)->domain == EV_DOCUMENT_ERROR &&
+                           (*error)->code == EV_DOCUMENT_ERROR_ENCRYPTED)
+                               return document;
+               } else {
+                       return document;
+               }
        }
+       
+       /* Try again with slow mime detection */
+       if (document)
+               g_object_unref (document);
+       document = NULL;
 
        if (*error)
                g_error_free (*error);
@@ -316,20 +328,23 @@ ev_document_factory_get_document (const char *uri, GError **error)
        }
 
        result = ev_document_load (document, uri, error);
-       
-       if (result == FALSE || *error) {
+
+       if (result == FALSE) {
+               if (*error == NULL) {
+                       g_set_error (error,
+                                    EV_DOCUMENT_ERROR,
+                                    0,
+                                    _("Unknown MIME Type"));
+               } else if ((*error)->domain == EV_DOCUMENT_ERROR &&
+                          (*error)->code == EV_DOCUMENT_ERROR_ENCRYPTED) {
+                       return document;
+               }
+
                if (document)
                        g_object_unref (document);
                document = NULL;
        }
-
-       if (result == FALSE && *error == NULL)  {
-               g_set_error (error,
-                            EV_DOCUMENT_ERROR,
-                            0,
-                            _("Unknown MIME Type"));
-       }
-
+       
        return document;
 }