Просмотр исходного кода

open collabora file without download the file

Marino Faggiana 6 лет назад
Родитель
Сommit
0bda54644f

+ 3 - 20
iOSClient/Main/CCDetail.m

@@ -189,9 +189,7 @@
     
     // DOCUMENT
     if ([self.metadataDetail.typeFile isEqualToString: k_metadataTypeFile_document]) {
-        
-        BOOL openWithRichDocument = false;
-        
+                
         fileNameExtension = [[self.metadataDetail.fileNameView pathExtension] uppercaseString];
         
         if ([fileNameExtension isEqualToString:@"PDF"]) {
@@ -203,23 +201,8 @@
             return;
         }
         
-        // Very if mimeType is compatible with Rich Document viewer
-        NSString *mimeType = [CCUtility getMimeType:self.metadataDetail.fileNameView];
-        NSArray *richdocumentsMimetypes = [[NCManageDatabase sharedInstance] getRichdocumentsMimetypes];
-        
-        if (richdocumentsMimetypes.count > 0 & mimeType != nil && [mimeType componentsSeparatedByString:@"."].count > 2) {
-            
-            NSArray *mimeTypeArray = [mimeType componentsSeparatedByString:@"."];
-            NSString *mimeType = [NSString stringWithFormat:@"%@.%@",mimeTypeArray[mimeTypeArray.count-2], mimeTypeArray[mimeTypeArray.count-1]];
-            
-            for (NSString *richdocumentMimetype in richdocumentsMimetypes) {
-                if ([richdocumentMimetype containsString:mimeType]) {
-                    openWithRichDocument = true;
-                }
-            }
-        }
-
-        if (openWithRichDocument) {
+        // RichDocument
+        if ([[NCViewerRichdocument sharedInstance] isRichDocument:self.metadataDetail]) {
             
             OCnetworking *ocNetworking = [[OCnetworking alloc] initWithDelegate:nil metadataNet:nil withUser:appDelegate.activeUser withUserID:appDelegate.activeUserID withPassword:appDelegate.activePassword withUrl:appDelegate.activeUrl];
             

+ 4 - 0
iOSClient/Main/CCMain.m

@@ -4381,6 +4381,10 @@
                     
                     [self shouldPerformSegue];
                     
+                } if ([self.metadata.typeFile isEqualToString: k_metadataTypeFile_document] && [[NCViewerRichdocument sharedInstance] isRichDocument:self.metadata]) {
+                    
+                    [self shouldPerformSegue];
+                    
                 } else {
                    
                     self.metadata.session = k_download_session;

+ 0 - 26
iOSClient/Viewer/NCViewerDocumentWeb.swift

@@ -33,32 +33,6 @@ class NCViewerDocumentWeb: NSObject {
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
     var safeAreaBottom: Int = 0
     
-    @objc func isRichDocument( _ metadata: tableMetadata) -> Bool {
-        
-        var isRichDocument = false
-        
-        guard let mimeType = CCUtility.getMimeType(metadata.fileNameView) else {
-            return isRichDocument
-        }
-        guard let richdocumentsMimetypes = NCManageDatabase.sharedInstance.getRichdocumentsMimetypes() else {
-            return isRichDocument
-        }
-        
-        if richdocumentsMimetypes.count > 0 && mimeType.components(separatedBy: ".").count > 2 {
-            
-            let mimeTypeArray = mimeType.components(separatedBy: ".")
-            let mimeType = mimeTypeArray[mimeTypeArray.count - 2] + "." + mimeTypeArray[mimeTypeArray.count - 1]
-            
-            for richdocumentMimetype: String in richdocumentsMimetypes {
-                if richdocumentMimetype.contains(mimeType) {
-                    isRichDocument = true
-                }
-            }
-        }
-        
-        return isRichDocument
-    }
-    
     @objc func viewDocumentWebAt(_ metadata: tableMetadata, detail: CCDetail) {
         
         if !CCUtility.fileProviderStorageExists(metadata.fileID, fileNameView: metadata.fileNameView) {

+ 25 - 0
iOSClient/Viewer/NCViewerRichdocument.swift

@@ -151,5 +151,30 @@ class NCViewerRichdocument: NSObject, WKNavigationDelegate, WKScriptMessageHandl
     public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
         print("didFinish");
     }
+ 
+    //MARK: -
     
+    @objc func isRichDocument( _ metadata: tableMetadata) -> Bool {
+        
+        guard let mimeType = CCUtility.getMimeType(metadata.fileNameView) else {
+            return false
+        }
+        guard let richdocumentsMimetypes = NCManageDatabase.sharedInstance.getRichdocumentsMimetypes() else {
+            return false
+        }
+        
+        if richdocumentsMimetypes.count > 0 && mimeType.components(separatedBy: ".").count > 2 {
+            
+            let mimeTypeArray = mimeType.components(separatedBy: ".")
+            let mimeType = mimeTypeArray[mimeTypeArray.count - 2] + "." + mimeTypeArray[mimeTypeArray.count - 1]
+            
+            for richdocumentMimetype: String in richdocumentsMimetypes {
+                if richdocumentMimetype.contains(mimeType) {
+                    return true
+                }
+            }
+        }
+        
+        return false
+    }
 }