Browse Source

Merge branch 'develop_PDFReaderProNew' of git.kdan.cc:Mac_PDF/PDF_Office into develop_PDFReaderProNew

tangchao 1 year ago
parent
commit
351fa1e501

+ 8 - 5
PDF Office/PDF Master/Class/Batch/Operation/KMBatchConvertOperation.swift

@@ -35,15 +35,18 @@ class KMBatchConvertOperation: KMBatchOperation, CPDFConverterDelegate, CPDFConv
         self.operateFile?.convertType = convertType
         self.hasExcuting = false
         self.hasFinished = false
-        self.pdfDocument = CPDFDocument(url: URL(fileURLWithPath: file.filePath))
-        if ((self.pdfDocument?.isLocked) != nil) {
-            self.pdfDocument?.unlock(withPassword: file.password)
-        }
+//        self.pdfDocument = CPDFDocument(url: URL(fileURLWithPath: file.filePath))
+//        if ((self.pdfDocument?.isLocked) != nil) {
+//            self.pdfDocument?.unlock(withPassword: file.password)
+//        }
     }
     
     override func start() {
         if !self.isCancelled {
-            
+            self.pdfDocument = CPDFDocument(url: URL(fileURLWithPath: self.operateFile?.filePath ?? ""))
+            if let data = self.pdfDocument?.isLocked, data {
+                self.pdfDocument?.unlock(withPassword: self.operateFile?.password)
+            }
             willChangeValue(forKey: "isExecuting")
             self.hasExcuting = true
             didChangeValue(forKey: "isExecuting")

+ 5 - 5
PDF Office/PDF Master/Class/Batch/Operation/KMCompressOperation.swift

@@ -15,14 +15,14 @@ class KMCompressOperation: KMBatchOperation{
     init(file: KMBatchOperateFile, compressValue dpiType: NSNumber) {
         super.init(file: file)
         self.dpiValue = dpiType
-        self.pdfDocument = CPDFDocument(url: URL(fileURLWithPath: file.filePath))
-        if ((self.pdfDocument?.isLocked) != nil) {
-            self.pdfDocument?.unlock(withPassword: file.password)
-        }
+       
     }
     override func start() {
         if !self.isCancelled {
-            
+            self.pdfDocument = CPDFDocument(url: URL(fileURLWithPath: self.operateFile?.filePath ?? ""))
+            if let data = self.pdfDocument?.isLocked, data {
+                self.pdfDocument?.unlock(withPassword: self.operateFile?.password)
+            }
             self.delegate?.fileBeginOperate?(self.operateFile!, info: self.operateFile!.compressInfo)
             
             willChangeValue(forKey: "isExecuting")

+ 5 - 4
PDF Office/PDF Master/Class/Batch/Tools/KMBatchRemoveHeaderFooterOperation.swift

@@ -13,10 +13,7 @@ class KMBatchRemoveHeaderFooterOperation: KMBatchOperation{
     
     override init(file: KMBatchOperateFile) {
         super.init(file: file)
-        self.pdfDocument = CPDFDocument(url: URL(fileURLWithPath: file.filePath))
-        if ((self.pdfDocument?.isLocked) != nil) {
-            self.pdfDocument?.unlock(withPassword: file.password)
-        }
+       
     }
     override func cancel() {
         if isExecuting {
@@ -41,6 +38,10 @@ class KMBatchRemoveHeaderFooterOperation: KMBatchOperation{
         return self.operateFile!.removeHeaderFooterInfo
     }
     override func start() {
+        self.pdfDocument = CPDFDocument(url: URL(fileURLWithPath: self.operateFile?.filePath ?? ""))
+        if let data = self.pdfDocument?.isLocked, data {
+            self.pdfDocument?.unlock(withPassword: self.operateFile?.password)
+        }
         if !self.isCancelled {
             self.delegate?.fileBeginOperate?(self.operateFile!, info: self.currentParameter())
             willChangeValue(forKey: "isExecuting")

+ 1 - 0
PDF Office/PDF Master/Class/ChromiumTabs/KMBrowserWindowController.swift

@@ -62,6 +62,7 @@ import Cocoa
 //                }
 //            }
 //        }
+        updateViewColor()
     }
     
     @objc func closeAction() {

+ 6 - 5
PDF Office/PDF Master/Class/PDFTools/AddHeaderFooter/Model/KMBatchAddHeaderFooterOperation.swift

@@ -19,11 +19,7 @@ class KMBatchAddHeaderFooterOperation: KMBatchOperation{
     init(file: KMBatchOperateFile, headerFooter: KMHeaderFooterModel) {
         super.init(file: file)
         self.headerFooter = headerFooter
-        self.pdfDocument = CPDFDocument(url: URL(fileURLWithPath: file.filePath))
-        self.password = file.password
-        if ((self.pdfDocument?.isLocked) != nil) {
-            self.pdfDocument?.unlock(withPassword: file.password)
-        }
+        
     }
     func currentParameter() -> KMBatchBaseParameter {
         if headerFooter!.isBates{
@@ -32,6 +28,11 @@ class KMBatchAddHeaderFooterOperation: KMBatchOperation{
         return operateFile!.addHeaderFooterInfo
     }
     override func start() {
+        self.pdfDocument = CPDFDocument(url: URL(fileURLWithPath: self.operateFile?.filePath ?? ""))
+        self.password = self.operateFile?.password
+        if let data = self.pdfDocument?.isLocked, data {
+            self.pdfDocument?.unlock(withPassword: self.operateFile?.password)
+        }
         if !self.isCancelled {
             self.delegate?.fileBeginOperate?(self.operateFile!, info: self.currentParameter())
             willChangeValue(forKey: "isExecuting")

+ 2 - 2
PDF Office/PDF Master/Class/PDFTools/AddHeaderFooter/WindowComtroller/KMHeaderFooterManagerWindowController.swift

@@ -130,10 +130,10 @@ class KMHeaderFooterManagerWindowController: NSWindowController{
         self.initialID = obj.id
         self.type = type
         self.pdfdocument = CPDFDocument(url: URL(fileURLWithPath: self.filePath))
-        if ((self.pdfdocument?.isLocked) != nil) {
+        if let data = self.pdfdocument?.isLocked, data {
             self.pdfdocument?.unlock(withPassword: password)
         }
-        if ((self.pdfdocument?.isLocked) != nil) {
+        if let data = self.pdfdocument?.isLocked, data {
             return
         }
     }

+ 5 - 4
PDF Office/PDF Master/Class/PDFTools/AddPassword/Model/KMBatchAddPasswordOperation.swift

@@ -14,12 +14,13 @@ class KMBatchAddPasswordOperation: KMBatchOperation{
     init(file: KMBatchOperateFile, password: KMSetPasswordObject) {
         super.init(file: file)
         self.passwordObj = password
-        self.pdfDocument = CPDFDocument(url: URL(fileURLWithPath: file.filePath))
-        if ((self.pdfDocument?.isLocked) != nil) {
-            self.pdfDocument?.unlock(withPassword: file.password)
-        }
+        
     }
     override func start() {
+        self.pdfDocument = CPDFDocument(url: URL(fileURLWithPath: self.operateFile?.filePath ?? ""))
+        if let data = self.pdfDocument?.isLocked, data {
+            self.pdfDocument?.unlock(withPassword: self.operateFile?.password)
+        }
         if !self.isCancelled {
             self.delegate?.fileBeginOperate?(self.operateFile!, info: self.operateFile!.removeWatermarkInfo)
             willChangeValue(forKey: "isExecuting")

+ 5 - 4
PDF Office/PDF Master/Class/PDFTools/RemovePassword/Model/KMBatchRemovePasswordOperation.swift

@@ -12,12 +12,13 @@ class KMBatchRemovePasswordOperation: KMBatchOperation{
     
     override init(file: KMBatchOperateFile) {
         super.init(file: file)
-        self.pdfDocument = PDFDocument(url: URL(fileURLWithPath: file.filePath))
-        if ((self.pdfDocument?.isLocked) != nil) {
-            self.pdfDocument?.unlock(withPassword: file.password)
-        }
+        
     }
     override func start() {
+        self.pdfDocument = PDFDocument(url: URL(fileURLWithPath: self.operateFile?.filePath ?? ""))
+        if let data = self.pdfDocument?.isLocked, data {
+            self.pdfDocument?.unlock(withPassword: self.operateFile?.password ?? "")
+        }
         if !self.isCancelled {
             self.delegate?.fileBeginOperate?(self.operateFile!, info: self.operateFile!.removePasswordInfo)
             willChangeValue(forKey: "isExecuting")

+ 5 - 4
PDF Office/PDF Master/Class/PDFTools/RemoveWatermark/Model/KMBatchRemoveBackgroundOperation.swift

@@ -12,12 +12,13 @@ class KMBatchRemoveBackgroundOperation: KMBatchOperation{
     
     override init(file: KMBatchOperateFile) {
         super.init(file: file)
-        self.pdfDocument = CPDFDocument(url: URL(fileURLWithPath: file.filePath))
-        if ((self.pdfDocument?.isLocked) != nil) {
-            self.pdfDocument?.unlock(withPassword: file.password)
-        }
+       
     }
     override func start() {
+        self.pdfDocument = CPDFDocument(url: URL(fileURLWithPath: self.operateFile?.filePath ?? ""))
+        if let data = self.pdfDocument?.isLocked, data {
+            self.pdfDocument?.unlock(withPassword: self.operateFile?.password)
+        }
         if !self.isCancelled {
             self.delegate?.fileBeginOperate?(self.operateFile!, info: self.operateFile!.removeBackgroundInfo)
             willChangeValue(forKey: "isExecuting")

+ 5 - 4
PDF Office/PDF Master/Class/PDFTools/RemoveWatermark/Model/KMBatchRemoveWatermarkOperation.swift

@@ -12,12 +12,13 @@ class KMBatchRemoveWatermarkOperation: KMBatchOperation{
     
     override init(file: KMBatchOperateFile) {
         super.init(file: file)
-        self.pdfDocument = CPDFDocument(url: URL(fileURLWithPath: file.filePath))
-        if ((self.pdfDocument?.isLocked) != nil) {
-            self.pdfDocument?.unlock(withPassword: file.password)
-        }
+       
     }
     override func start() {
+        self.pdfDocument = CPDFDocument(url: URL(fileURLWithPath: self.operateFile?.filePath ?? ""))
+        if let data = self.pdfDocument?.isLocked, data {
+            self.pdfDocument?.unlock(withPassword: self.operateFile?.password)
+        }
         if !self.isCancelled {
             self.delegate?.fileBeginOperate?(self.operateFile!, info: self.operateFile!.removeWatermarkInfo)
             willChangeValue(forKey: "isExecuting")

+ 5 - 4
PDF Office/PDF Master/Class/PDFTools/Watermark/Model/KMBatchAddBackgroundOperation.swift

@@ -15,14 +15,15 @@ class KMBatchAddBackgroundOperation: KMBatchOperation{
     init(file: KMBatchOperateFile, backgroundM: KMBackgroundModel) {
         super.init(file: file)
         self.background = backgroundM
-        self.pdfDocument = CPDFDocument(url: URL(fileURLWithPath: file.filePath))
-        if ((self.pdfDocument?.isLocked) != nil) {
-            self.pdfDocument?.unlock(withPassword: file.password)
-        }
+       
         self.password = file.password
     }
     
     override func start() {
+        self.pdfDocument = CPDFDocument(url: URL(fileURLWithPath: self.operateFile?.filePath ?? ""))
+        if let data = self.pdfDocument?.isLocked, data {
+            self.pdfDocument?.unlock(withPassword: self.operateFile?.password)
+        }
         if !self.isCancelled {
             self.delegate?.fileBeginOperate?(self.operateFile!, info: self.operateFile!.addBackgroundInfo)
             willChangeValue(forKey: "isExecuting")

+ 9 - 8
PDF Office/PDF Master/Class/PDFTools/Watermark/Model/KMBatchAddWatermarkOperation.swift

@@ -15,17 +15,18 @@ class KMBatchAddWatermarkOperation: KMBatchOperation{
     init(file: KMBatchOperateFile, waterMarkM: KMWatermarkModel) {
         super.init(file: file)
         self.waterMark = waterMarkM
-        self.pdfDocument = CPDFDocument(url: URL(fileURLWithPath: file.filePath))
-        if ((self.pdfDocument?.isLocked) != nil) {
-            self.pdfDocument?.unlock(withPassword: file.password)
-        }
-//        let docum = CPDFDocument(url: self.pdfDocument.documentURL)
-        if file.password.count > 0 {
-            self.pdfDocument?.unlock(withPassword: file.password)
-        }
+       
     }
     
     override func start() {
+        self.pdfDocument = CPDFDocument(url: URL(fileURLWithPath: self.operateFile?.filePath ?? ""))
+        if let data = self.pdfDocument?.isLocked, data {
+            self.pdfDocument?.unlock(withPassword: self.operateFile?.password)
+        }
+//        let docum = CPDFDocument(url: self.pdfDocument.documentURL)
+//        if self.operateFile?.password.count ?? 0 > 0 {
+//            self.pdfDocument?.unlock(withPassword: self.operateFile?.password)
+//        }
         if !self.isCancelled {
             self.delegate?.fileBeginOperate?(self.operateFile!, info: self.operateFile!.addWatermarkInfo)
             willChangeValue(forKey: "isExecuting")