[gnome-documents/wip/lokdocview-rebase: 5/8] Move LO supported mime-types to the backend



commit a31257f147d0b6093c3113329504eeba5efa828a
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Dec 4 18:17:39 2015 +0100

    Move LO supported mime-types to the backend
    
    We'll need to keep it so that it's available when LOK isn't.

 src/documents.js |   37 +------------------------------------
 src/embed.js     |    2 +-
 src/lokview.js   |   36 +++++++++++++++++++++++++++++++++++-
 3 files changed, 37 insertions(+), 38 deletions(-)
---
diff --git a/src/documents.js b/src/documents.js
index 8ddba8e..2bea4c6 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -45,29 +45,6 @@ const Search = imports.search;
 const TrackerUtils = imports.trackerUtils;
 const Utils = imports.utils;
 
-const openDocumentFormats = ['application/vnd.oasis.opendocument.text',
-                             'application/vnd.oasis.opendocument.text-template',
-                             'application/vnd.oasis.opendocument.text-web',
-                             'application/vnd.oasis.opendocument.text-master',
-                             'application/vnd.oasis.opendocument.graphics',
-                             'application/vnd.oasis.opendocument.graphics-template',
-                             'application/vnd.oasis.opendocument.presentation',
-                             'application/vnd.oasis.opendocument.presentation-template',
-                             'application/vnd.oasis.opendocument.spreadsheet',
-                             'application/vnd.oasis.opendocument.spreadsheet-template',
-                             'application/vnd.oasis.opendocument.chart',
-                             'application/vnd.oasis.opendocument.formula',
-                             'application/vnd.oasis.opendocument.database',
-                             'application/vnd.oasis.opendocument.image',
-                             'application/vnd.openofficeorg.extension'];
-
-// These are the documents consisting of document parts.
-const openDocumentPartFormats = ['application/vnd.oasis.opendocument.presentation',
-                                 'application/vnd.oasis.opendocument.presentation-template',
-                                 'application/vnd.oasis.opendocument.spreadsheet',
-                                 'application/vnd.oasis.opendocument.spreadsheet-template',];
-
-
 const DeleteItemJob = new Lang.Class({
     Name: 'DeleteItemJob',
 // deletes the given resource
@@ -690,18 +667,6 @@ const DocCommon = new Lang.Class({
 
         return retval;
     },
-
-    isOpenDocumentPartDocument: function() {
-        if (openDocumentPartFormats.indexOf(this.mimeType) != -1)
-            return true;
-        return false;
-    },
-
-    isOpenDocumentFormat: function() {
-        if (openDocumentFormats.indexOf(this.mimeType) != -1)
-            return true;
-        return false;
-    }
 });
 Signals.addSignalMethods(DocCommon.prototype);
 
@@ -777,7 +742,7 @@ const LocalDocument = new Lang.Class({
             return;
         }
 
-        if (this.isOpenDocumentFormat() && !Application.application.isBooks) {
+        if (LOKView.isOpenDocumentFormat(this.mimeType) && !Application.application.isBooks) {
             let exception = null;
             if (!LOKView.isAvailable()) {
                 exception = new GLib.Error(Gio.IOErrorEnum,
diff --git a/src/embed.js b/src/embed.js
index 8c69376..dca45f1 100644
--- a/src/embed.js
+++ b/src/embed.js
@@ -335,7 +335,7 @@ const Embed = new Lang.Class({
     },
 
     _onLoadStarted: function(manager, doc) {
-        if (doc.isOpenDocumentFormat())
+        if (LOKView.isOpenDocumentFormat(doc.mimeType))
             Application.modeController.setWindowMode(WindowMode.WindowMode.PREVIEW_LOK);
         else
             Application.modeController.setWindowMode(WindowMode.WindowMode.PREVIEW);
diff --git a/src/lokview.js b/src/lokview.js
index 671100e..fcf0b34 100644
--- a/src/lokview.js
+++ b/src/lokview.js
@@ -52,10 +52,44 @@ const Documents = imports.documents;
 // FIXME: https://bugs.documentfoundation.org/show_bug.cgi?id=96247
 const LO_PATH = '/usr/lib64/libreoffice/program'
 
+const openDocumentFormats = ['application/vnd.oasis.opendocument.text',
+                             'application/vnd.oasis.opendocument.text-template',
+                             'application/vnd.oasis.opendocument.text-web',
+                             'application/vnd.oasis.opendocument.text-master',
+                             'application/vnd.oasis.opendocument.graphics',
+                             'application/vnd.oasis.opendocument.graphics-template',
+                             'application/vnd.oasis.opendocument.presentation',
+                             'application/vnd.oasis.opendocument.presentation-template',
+                             'application/vnd.oasis.opendocument.spreadsheet',
+                             'application/vnd.oasis.opendocument.spreadsheet-template',
+                             'application/vnd.oasis.opendocument.chart',
+                             'application/vnd.oasis.opendocument.formula',
+                             'application/vnd.oasis.opendocument.database',
+                             'application/vnd.oasis.opendocument.image',
+                             'application/vnd.openofficeorg.extension'];
+
+// These are the documents consisting of document parts.
+const openDocumentPartFormats = ['application/vnd.oasis.opendocument.presentation',
+                                 'application/vnd.oasis.opendocument.presentation-template',
+                                 'application/vnd.oasis.opendocument.spreadsheet',
+                                 'application/vnd.oasis.opendocument.spreadsheet-template',];
+
 function isAvailable() {
     return (LOKDocView != undefined);
 }
 
+function isOpenDocumentPartDocument(mimeType) {
+     if (openDocumentPartFormats.indexOf(mimeType) != -1)
+         return true;
+     return false;
+}
+
+function isOpenDocumentFormat(mimeType) {
+    if (openDocumentFormats.indexOf(mimeType) != -1)
+        return true;
+    return false;
+}
+
 const LOKView = new Lang.Class({
     Name: 'LOKView',
     Extends: Gtk.Stack,
@@ -121,7 +155,7 @@ const LOKView = new Lang.Class({
 
     open_document_cb: function(res, doc) {
         // TODO: Call _finish and check failure
-        if (this._doc.isOpenDocumentPartDocument()) {
+        if (isOpenDocumentPartDocument(this._doc.mimeType)) {
             this.hasParts = true;
             this.totalParts = this.view.get_parts();
             this.currentPart = this.view.get_part();


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