Browse Source

【2025】【综合】串接对比功能

niehaoyu 2 months ago
parent
commit
e3898cc9fe
15 changed files with 100 additions and 145 deletions
  1. 2 0
      PDF Office/PDF Master/Class/AIInfo/AIConfigWindowController/AIConfigWindowController.xib
  2. 18 34
      PDF Office/PDF Master/Class/PDFTools/Compare/KMCompareWindowController.swift
  3. 0 10
      PDF Office/PDF Master/Class/PDFTools/Compare/View/CompareFilesView/KMCompareFilesView.swift
  4. 18 73
      PDF Office/PDF Master/Class/PDFTools/Compare/View/KMCompareView.swift
  5. 6 6
      PDF Office/PDF Master/Class/PDFTools/Compare/View/KMCompareView.xib
  6. 0 3
      PDF Office/PDF Master/Class/PDFTools/Compare/ViewController/ContentComplete/KMCompareContentWindowController.swift
  7. 0 2
      PDF Office/PDF Master/Class/PDFTools/Compare/ViewController/ContentComplete/View/KMCompareContentView.swift
  8. 0 2
      PDF Office/PDF Master/Class/PDFTools/Compare/ViewController/ContentComplete/View/Text/KMCompareTextHeaderView.swift
  9. 0 1
      PDF Office/PDF Master/Class/PDFTools/Compare/ViewController/ContentComplete/View/Text/KMCompareTextViewItem.swift
  10. 5 5
      PDF Office/PDF Master/Class/PDFTools/Compare/ViewController/ContentSetting/KMCompareContentSettingWindowController.xib
  11. 0 3
      PDF Office/PDF Master/Class/PDFTools/Compare/ViewController/CoveringComplete/View/KMCompareCoveringView.swift
  12. 0 2
      PDF Office/PDF Master/Class/PDFTools/Compare/ViewController/CoveringSetting/KMCompareCoveringSettingWindowController.swift
  13. 0 1
      PDF Office/PDF Master/Class/PDFTools/Compare/ViewController/CoveringSetting/View/KMCompareCoveringSettingView.swift
  14. 51 1
      PDF Office/PDF Master/KMClass/KMPDFViewController/KMMainViewController.swift
  15. 0 2
      PDF Office/PDF Master/KMClass/KMPDFViewController/Toolbar/Model/KMPDFToolbarConfig.swift

+ 2 - 0
PDF Office/PDF Master/Class/AIInfo/AIConfigWindowController/AIConfigWindowController.xib

@@ -310,6 +310,7 @@
                                                                 <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                                                                 <size key="minSize" width="348" height="276"/>
                                                                 <size key="maxSize" width="348" height="10000000"/>
+                                                                <color key="insertionPointColor" name="textInsertionPointColor" catalog="System" colorSpace="catalog"/>
                                                             </textView>
                                                         </subviews>
                                                     </clipView>
@@ -498,6 +499,7 @@
                                                                 <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                                                                 <size key="minSize" width="350" height="324"/>
                                                                 <size key="maxSize" width="355" height="10000000"/>
+                                                                <color key="insertionPointColor" name="textInsertionPointColor" catalog="System" colorSpace="catalog"/>
                                                             </textView>
                                                         </subviews>
                                                     </clipView>

+ 18 - 34
PDF Office/PDF Master/Class/PDFTools/Compare/KMCompareWindowController.swift

@@ -11,7 +11,7 @@ typealias KMCompareWindowControllerContentComplete = (_ controller: KMCompareWin
 typealias KMCompareWindowControllerCoveringComplete = (_ controller: KMCompareWindowController, _ document: CPDFDocument) -> Void
 
 class KMCompareWindowController: KMBaseWindowController {
-
+    
     @IBOutlet weak var compareView: KMCompareView!
     
     var pdfCompareContent: CPDFCompareContent?
@@ -46,7 +46,7 @@ class KMCompareWindowController: KMBaseWindowController {
     
     override func windowDidLoad() {
         super.windowDidLoad()
-
+        
         // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
         compareView.password = password
         compareView.filePath = filePath
@@ -62,7 +62,7 @@ class KMCompareWindowController: KMBaseWindowController {
     
     func compareAction(config: KMCompareFilesConfig) {
         self.showWaitting()
-
+        
         guard let pdfOldDocument = config.fileOldAttribute.pdfDocument, let pdfNewDocument = config.fileNewAttribute.pdfDocument else {
             let alert = NSAlert()
             alert.alertStyle = .critical
@@ -71,11 +71,11 @@ class KMCompareWindowController: KMBaseWindowController {
             self.hideWaitting()
             return
         }
-
+        
         let fileManager = FileManager.default
         let fileOldPath = config.fileOldAttribute.pdfDocument?.documentURL.path
         let fileNewPath = config.fileNewAttribute.pdfDocument?.documentURL.path
-
+        
         if !fileManager.fileExists(atPath: fileOldPath!) || !fileManager.fileExists(atPath: fileNewPath!){
             let alert = NSAlert()
             alert.alertStyle = .critical
@@ -84,14 +84,14 @@ class KMCompareWindowController: KMBaseWindowController {
             self.hideWaitting()
             return
         }
-
+        
         if (config.fileNewAttribute.fetchSelectPages().count == 0) ||
             (!config.fileNewAttribute.bAllPage && config.fileNewAttribute.pagesString.count < 1) {
             let alert = NSAlert()
             alert.alertStyle = .critical
             alert.messageText = String(format: "%@ %@", (config.fileNewAttribute.pdfDocument?.documentURL.path.lastPathComponent.lastPathComponent)!, NSLocalizedString("Invalid page range. Please reselect the page range.", comment: ""))
             alert.runModal()
-
+            
             config.fileNewAttribute.bAllPage = true
             config.fileNewAttribute.pagesType = .all
             
@@ -100,28 +100,28 @@ class KMCompareWindowController: KMBaseWindowController {
             self.hideWaitting()
             return
         }
-
+        
         if (config.fileOldAttribute.fetchSelectPages().count == 0) || (!config.fileOldAttribute.bAllPage && config.fileOldAttribute.pagesString.count < 1) {
             let alert = NSAlert()
             alert.alertStyle = .critical
             alert.messageText = String(format: "%@ %@", (config.fileOldAttribute.pdfDocument?.documentURL.path.lastPathComponent.lastPathComponent)!, NSLocalizedString("Invalid page range. Please reselect the page range.", comment: ""))
             alert.runModal()
-
+            
             config.fileOldAttribute.bAllPage = true
             config.fileOldAttribute.pagesType = .all
-
+            
             compareView.reloadData()
             
             self.hideWaitting()
             return
         }
-
+        
         let filePath = config.fileOldAttribute.pdfDocument?.documentURL.path
         let pdfDocument = CPDFDocument(url: URL(fileURLWithPath: filePath!))
-
+        
         let filePath1 = config.fileNewAttribute.pdfDocument?.documentURL.path
         let pdfDocument1 = CPDFDocument(url: URL(fileURLWithPath: filePath1!))
-
+        
         DispatchQueue.global().async {
             let oldDoc = CPDFDocument(url: config.fileOldAttribute.pdfDocument?.documentURL)
             oldDoc!.unlock(withPassword: config.fileOldAttribute.password)
@@ -142,7 +142,7 @@ class KMCompareWindowController: KMBaseWindowController {
                 pdfCompareOverlay?.setOldDocumentFillOpacity(config.oldFillOpacity())
                 pdfCompareOverlay?.setNoFill(config.isNOFill())
                 pdfCompareOverlay?.setBlendMod(config.blendMod())
-
+                
                 if (pdfCompareOverlay?.compare() == true) {
                     DispatchQueue.main.async {
                         self.progressController?.doubleValue = 30.0
@@ -171,14 +171,6 @@ class KMCompareWindowController: KMBaseWindowController {
                 var results: [CPDFCompareResults] = []
                 var pdfCompareContent: CPDFCompareContent? = nil
                 
-//                if let _pdfCompareContent = self._pdfCompareContent {
-//                    pdfCompareContent = _pdfCompareContent
-//                }
-//                
-//                if self._compareCancel {
-//                    return
-//                }
-                
                 pdfCompareContent = CPDFCompareContent(oldDocument: oldDoc, newDocument: doc)
                 
                 pdfCompareContent?.setDelete(config.deleteColor())
@@ -197,9 +189,6 @@ class KMCompareWindowController: KMBaseWindowController {
                     compareType = .image
                 }
                 
-//                if self._compareCancel {
-//                    return
-//                }
                 DispatchQueue.main.async {
                     self.progressController?.doubleValue = 30.0
                 }
@@ -218,16 +207,11 @@ class KMCompareWindowController: KMBaseWindowController {
                     } else {
                         newPageIndex = Int(truncating: config.fileNewAttribute.fetchSelectPages()[i] as NSNumber) - 1
                     }
-
+                    
                     if let compareResults = pdfCompareContent?.compareOldPageIndex(oldPageIndex, newPageIndex: newPageIndex, type: compareType, isDrawHighlight: true) {
                         results.append(compareResults)
                     }
                     
-//                    DispatchQueue.main.async {
-//                        if let compareLoadingWVC = self.compareLoadingWVC {
-//                            compareLoadingWVC.progress = CGFloat(i) / CGFloat(maxIndex)
-//                        }
-//                    }
                 }
                 
                 DispatchQueue.main.async {
@@ -244,7 +228,7 @@ class KMCompareWindowController: KMBaseWindowController {
                 }
             }
         }
-
+        
     }
 }
 
@@ -262,7 +246,7 @@ extension KMCompareWindowController {
         progress.window?.contentView?.layer?.backgroundColor = NSColor.km_init(hex: "#36383B").cgColor
         progress.progressField.textColor = NSColor.white
         progress.message = NSLocalizedString("Comparing documents...", comment: "")
-
+        
         progress.closeBlock = { [weak self] in
             
         }
@@ -278,7 +262,7 @@ extension KMCompareWindowController {
         }
         
         self.maskView?.removeFromSuperview()
-
+        
         if (self.progressController != nil) {
             self.window?.endSheet((self.progressController?.window)!)
             self.progressController = nil

+ 0 - 10
PDF Office/PDF Master/Class/PDFTools/Compare/View/CompareFilesView/KMCompareFilesView.swift

@@ -50,16 +50,6 @@ class KMCompareFilesView: NSView {
             return false
         }
 
-        #if VERSION_DMG
-            // Add code for VERSION_DMG
-        #else
-//            let url = URL(fileURLWithPath: path)
-//            if let bookmarkData = try? url.bookmarkData(options: .withSecurityScope, includingResourceValuesForKeys: nil) {
-//                AppSandboxFileAccess.fileAccess().bookmarkPersistanceDelegate.setBookmarkData(bookmarkData, forURL: url)
-//                AppSandboxFileAccess.fileAccess().bookmarkPersistanceDelegate.setBookmarkData(bookmarkData, forURL: URL(fileURLWithPath: url.path ?? url.absoluteString))
-//            }
-        #endif
-
         if let block = dragSuccessBlock {
             block(path)
         }

+ 18 - 73
PDF Office/PDF Master/Class/PDFTools/Compare/View/KMCompareView.swift

@@ -100,8 +100,9 @@ class KMCompareView: BaseXibView {
     
     convenience init(pdfDocument: PDFDocument) {
         self.init()
+        
         self.pdfOldDocument = pdfDocument
-        let document: PDFDocument = PDFDocument.init(url: pdfDocument.documentURL!)!
+
         let cDocument: CPDFDocument = CPDFDocument.init(url: pdfDocument.documentURL!)
         
         let file: KMFileAttribute = KMFileAttribute()
@@ -113,6 +114,7 @@ class KMCompareView: BaseXibView {
     
     convenience init(filePath: String, password: String) {
         self.init()
+        
         self.pdfOldDocument = PDFDocument.init(url: NSURL(fileURLWithPath: filePath) as URL)
         let pdfDocument = PDFDocument.init(url: NSURL(fileURLWithPath: filePath) as URL)
         let cDocument = CPDFDocument.init(url: NSURL(fileURLWithPath: filePath) as URL)
@@ -158,10 +160,8 @@ class KMCompareView: BaseXibView {
         
         oldPDFView.wantsLayer = true
         pdfNewView.wantsLayer = true
-//        vsMaskView.wantsLayer = true;
         oldPDFView.layer?.backgroundColor = NSColor.clear.cgColor
         pdfNewView.layer?.backgroundColor = NSColor.clear.cgColor
-//        vsMaskView.layer.backgroundColor = NSColor.clear.CGColor
         
         compareTypeSegment.wantsLayer = true
         compareTypeSegment.layer?.cornerRadius = 5.0
@@ -200,6 +200,8 @@ class KMCompareView: BaseXibView {
         }
         
         KMCompareFilesConfig.defaultConfig.fileNewAttribute.pdfDocument = nil
+        
+        updateLanguage()
     }
     
     func updateLanguage() {
@@ -300,12 +302,10 @@ extension KMCompareView {
             let document: PDFDocument = PDFDocument.init(url: NSURL(fileURLWithPath: filePath) as URL) ?? PDFDocument()
             let cDocument: CPDFDocument = CPDFDocument.init(url: NSURL(fileURLWithPath: filePath) as URL)!
             let file: KMFileAttribute = KMFileAttribute()
-//            file.pdfDocument = cDocument
-//            file.myPDFDocument = document
+ 
             file.password = password
             file.filePath = filePath
-
-            
+ 
             document.unlock(withPassword: password)
             cDocument.unlock(withPassword: password)
             
@@ -410,25 +410,9 @@ extension KMCompareView {
         let fileManager = FileManager.default
         for path in fileSelectedCachePaths {
             if fileManager.fileExists(atPath: path) {
-//                #if VERSION_DMG
                 fileSelectedPaths.append(path.lastPathComponent)
                 filePaths.append(path)
-//                #else
-//                let url = URL(fileURLWithPath: path)
-//                
-//                if let bookmarkData = try? url.bookmarkData(options: .withSecurityScope, includingResourceValuesForKeys: nil) {
-//                    AppSandboxFileAccess.fileAccess().bookmarkPersistanceDelegate.setBookmarkData(bookmarkData, forURL: url)
-//                    AppSandboxFileAccess.fileAccess().bookmarkPersistanceDelegate.setBookmarkData(bookmarkData, forURL: URL(fileURLWithPath: url.path ?? url.absoluteString))
-//                    
-//                    fileOldSelectedPaths.append(path)
-//                } else {
-//                    AppSandboxFileAccess.fileAccess().accessFileURL(url, persistPermission: yearMask) {
-//                        if let bookmarkData = try? url.bookmarkData(options: .withSecurityScope, includingResourceValuesForKeys: nil) {
-//                            fileOldSelectedPaths.append(path)
-//                        }
-//                    }
-//                }
-//                #endif
+
             }
         }
         
@@ -492,10 +476,6 @@ extension KMCompareView {
                 pdfDocument = KMCompareFilesConfig.defaultConfig.fileOldAttribute.pdfDocument
             }
             
-//            guard let pdfDocument = pdfDocument else {
-//                completion(nil)
-//                return
-//            }
             if (pdfDocument?.documentURL.path == filePath) {
                 let alert = NSAlert()
                 alert.alertStyle = NSAlert.Style.critical
@@ -523,17 +503,23 @@ extension KMCompareView {
     func updatePageRangeData(view: NSComboBox, file: KMFileAttribute, isNew: Bool = false) {
         switch (file.pagesType) {
         case .all:
-            view.selectItem(at: 0)
+            if view.numberOfItems > 0 {
+                view.selectItem(at: 0)
+            }
             view.isEditable = false
             view.delegate = nil
             break;
         case .odd:
-            view.selectItem(at: 1)
+            if view.numberOfItems > 0 {
+                view.selectItem(at: 1)
+            }
             view.isEditable = false
             view.delegate = nil
             break;
         case .even:
-            view.selectItem(at: 2)
+            if view.numberOfItems > 0 {
+                view.selectItem(at: 2)
+            }
             view.isEditable = false
             view.delegate = nil
             break;
@@ -726,28 +712,11 @@ extension KMCompareView {
     }
     
     func chooseFileAction(isNew: Bool = false) {
-//        fileQKNewSelectedBox.resignFirstResponder()
-//        self.window?.makeFirstResponder(nil)
-
         let openPanel = NSOpenPanel()
         openPanel.allowedFileTypes = ["pdf"]
         openPanel.allowsMultipleSelection = false
         openPanel.beginSheetModal(for: self.window!) { (result) in
             if result == NSApplication.ModalResponse.OK {
-                #if VERSION_DMG
-                    // Add code for VERSION_DMG
-                #else
-//                    if let url = openPanel.url {
-//                        do {
-//                            let bookmarkData = try url.bookmarkData(options: .withSecurityScope, includingResourceValuesForKeys: nil)
-//                            AppSandboxFileAccess.fileAccess().bookmarkPersistanceDelegate.setBookmarkData(bookmarkData, forURL: url)
-//                            AppSandboxFileAccess.fileAccess().bookmarkPersistanceDelegate.setBookmarkData(bookmarkData, forURL: URL(fileURLWithPath: url.path ?? url.absoluteString))
-//                        } catch {
-//                            // Handle error
-//                            print("Error creating bookmark data: \(error)")
-//                        }
-//                    }
-                #endif
 
                 if let filePath = openPanel.url?.path {
                     let url = NSURL(fileURLWithPath: filePath)
@@ -757,31 +726,7 @@ extension KMCompareView {
                         AppSandboxFileAccess().bookmarkPersistanceDelegate.setBookmarkData(bookmarkData! as Data, for: url as URL)
                         AppSandboxFileAccess().bookmarkPersistanceDelegate.setBookmarkData(bookmarkData! as Data, for: NSURL(fileURLWithPath: url.path!) as URL)
                     }
-                    
-//                    let isAccessFilePath = AppSandboxFileAccess().accessFileURL(url as URL, persistPermission: true) {
-//                        
-//                    }
-//    
-//                    if (isAccessFilePath) {
-//                        print("获取权限成功")
-//                        let url = NSURL(fileURLWithPath: filePath)
-//                        let bookmarkData = try?url.bookmarkData(options: .withSecurityScope, includingResourceValuesForKeys: nil, relativeTo: nil)
-//                        if bookmarkData != nil {
-//                            AppSandboxFileAccess().bookmarkPersistanceDelegate.setBookmarkData(bookmarkData, for: url as URL)
-//                            AppSandboxFileAccess().bookmarkPersistanceDelegate.setBookmarkData(bookmarkData, for: NSURL(fileURLWithPath: url.path!) as URL)
-//                        }
-//                    } else {
-//                        print("获取权限失败")
-//                    }
-                    
-//                    NSURL *url = [NSURL fileURLWithPath:folderPath];
-//                    [[AppSandboxFileAccess fileAccess] persistPermissionURL:url];
-//                    NSData *bookmarkData = [url bookmarkDataWithOptions:NSURLBookmarkCreationWithSecurityScope includingResourceValuesForKeys:nil relativeToURL:nil error:NULL];
-//                    if (bookmarkData) {
-//                        [[AppSandboxFileAccess fileAccess].bookmarkPersistanceDelegate setBookmarkData:bookmarkData forURL:url];
-//                        [[AppSandboxFileAccess fileAccess].bookmarkPersistanceDelegate setBookmarkData:bookmarkData forURL:[NSURL fileURLWithPath:(url.path?:url.absoluteString)]];
-//                    }
-                    
+                     
                     self.updateDocument(filePath: filePath, isNew: isNew) { [weak self] file in
                         if let _ = file {
                             self?.addFilePath(filePath: filePath, isNew: isNew, password: file?.password ?? "")

+ 6 - 6
PDF Office/PDF Master/Class/PDFTools/Compare/View/KMCompareView.xib

@@ -7,7 +7,7 @@
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
-        <customObject id="-2" userLabel="File's Owner" customClass="KMCompareView" customModule="PDF_Master" customModuleProvider="target">
+        <customObject id="-2" userLabel="File's Owner" customClass="KMCompareView" customModule="PDF_Reader_Pro" customModuleProvider="target">
             <connections>
                 <outlet property="addFileAddImageFramView" destination="7T1-FJ-wtx" id="tPU-4J-IZd"/>
                 <outlet property="addFileContentView" destination="dU9-33-2cR" id="J7c-AP-uVZ"/>
@@ -71,11 +71,11 @@
                                             <constraint firstAttribute="width" relation="greaterThanOrEqual" constant="44" id="d8I-aZ-cZc"/>
                                         </constraints>
                                     </button>
-                                    <customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="abd-G5-jAM" customClass="KMMaskView" customModule="PDF_Master" customModuleProvider="target">
+                                    <customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="abd-G5-jAM" customClass="KMMaskView" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                         <rect key="frame" x="0.0" y="0.0" width="490" height="395"/>
                                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                     </customView>
-                                    <customView translatesAutoresizingMaskIntoConstraints="NO" id="q2P-Ek-w51" customClass="KMCompareFilesView" customModule="PDF_Master" customModuleProvider="target">
+                                    <customView translatesAutoresizingMaskIntoConstraints="NO" id="q2P-Ek-w51" customClass="KMCompareFilesView" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                         <rect key="frame" x="10" y="16" width="204" height="352"/>
                                         <subviews>
                                             <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="kRr-R4-sGx">
@@ -223,7 +223,7 @@
                                             <constraint firstItem="jw7-gN-Ept" firstAttribute="top" secondItem="jih-HW-8sA" secondAttribute="bottom" constant="10" id="wwo-3R-2ff"/>
                                         </constraints>
                                     </customView>
-                                    <customView translatesAutoresizingMaskIntoConstraints="NO" id="E6w-5x-3SO" customClass="KMCompareFilesView" customModule="PDF_Master" customModuleProvider="target">
+                                    <customView translatesAutoresizingMaskIntoConstraints="NO" id="E6w-5x-3SO" customClass="KMCompareFilesView" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                         <rect key="frame" x="276" y="16" width="204" height="352"/>
                                         <subviews>
                                             <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="CD7-aX-zab">
@@ -274,7 +274,7 @@
                                                     <constraint firstAttribute="height" constant="254" id="lYe-PP-dsH"/>
                                                 </constraints>
                                             </pdfView>
-                                            <customView translatesAutoresizingMaskIntoConstraints="NO" id="dU9-33-2cR" customClass="KMCompareFilesView" customModule="PDF_Master" customModuleProvider="target">
+                                            <customView translatesAutoresizingMaskIntoConstraints="NO" id="dU9-33-2cR" customClass="KMCompareFilesView" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                                 <rect key="frame" x="5" y="35" width="194" height="254"/>
                                                 <subviews>
                                                     <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="LcR-ou-ANf">
@@ -309,7 +309,7 @@
                                                             <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                                                         </textFieldCell>
                                                     </textField>
-                                                    <customView translatesAutoresizingMaskIntoConstraints="NO" id="7T1-FJ-wtx" customClass="KMCompareFilesView" customModule="PDF_Master" customModuleProvider="target">
+                                                    <customView translatesAutoresizingMaskIntoConstraints="NO" id="7T1-FJ-wtx" customClass="KMCompareFilesView" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                                         <rect key="frame" x="49" y="105" width="96" height="96"/>
                                                     </customView>
                                                 </subviews>

+ 0 - 3
PDF Office/PDF Master/Class/PDFTools/Compare/ViewController/ContentComplete/KMCompareContentWindowController.swift

@@ -25,9 +25,6 @@ class KMCompareContentWindowController: NSWindowController {
         self.pdfOldDocumnet = oldDocument
         self.pdfDocument = document
         
-//        contentView.oldDocument = oldDocument
-//        contentView.document = document
-//        contentView.compareResults = results
     }
     
     override func windowDidLoad() {

+ 0 - 2
PDF Office/PDF Master/Class/PDFTools/Compare/ViewController/ContentComplete/View/KMCompareContentView.swift

@@ -261,7 +261,6 @@ class KMCompareContentView: BaseXibView, CPDFViewDelegate, KMCompareToolbarDeleg
         compareDetailView.addSubview(thumbController)
         
         refreshCompareColorView()
-//        refreshCompareTypeInfo()
     }
 
     // MARK: - Setter
@@ -701,7 +700,6 @@ class KMCompareContentView: BaseXibView, CPDFViewDelegate, KMCompareToolbarDeleg
 
             var x = max(self.pdfoldViewSPoint.x, 0)
             var y = max(self.pdfoldViewSPoint.y + offsetY, 0)
-//            self.pdfOldView.documentView().contentView.scroll(NSPoint(x: x, y: y))
             self.pdfOldView.documentView().contentView.scroll(KMSafePoint(x: x, y: y))
 
             NSObject.cancelPreviousPerformRequests(withTarget: self, selector: #selector(scrollFinishEvent), object: nil)

+ 0 - 2
PDF Office/PDF Master/Class/PDFTools/Compare/ViewController/ContentComplete/View/Text/KMCompareTextHeaderView.swift

@@ -92,8 +92,6 @@ class KMCompareTextHeaderView: BaseXibView {
             expandBtn.alternateImage = NSImage(named: "arrow_right_sel")
         }
 
-//        countLbl.stringValue = "\(String(describing: resultModel.results.insertCount())) + \(String(describing: resultModel.results.deleteCount())) + \(String(describing: resultModel.results.replaceCount()))"
-        
         countLbl.stringValue = "\(resultModel.results.insertCount() + resultModel.results.deleteCount() + resultModel.results.replaceCount())"
 
         var compareResult: CPDFCompareResult?

+ 0 - 1
PDF Office/PDF Master/Class/PDFTools/Compare/ViewController/ContentComplete/View/Text/KMCompareTextViewItem.swift

@@ -33,7 +33,6 @@ class KMCompareTextViewItem: NSCollectionViewItem {
 
         highlightColor = NSColor(red: 245.0/255.0, green: 246.0/255.0, blue: 252.0/255.0, alpha: 1.0)
         
-        // addTrackingArea()
     }
 
     func addTrackingArea() {

+ 5 - 5
PDF Office/PDF Master/Class/PDFTools/Compare/ViewController/ContentSetting/KMCompareContentSettingWindowController.xib

@@ -1,12 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22155" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
     <dependencies>
         <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
-        <customObject id="-2" userLabel="File's Owner" customClass="KMCompareContentSettingWindowController" customModule="PDF_Master" customModuleProvider="target">
+        <customObject id="-2" userLabel="File's Owner" customClass="KMCompareContentSettingWindowController" customModule="PDF_Reader_Pro" customModuleProvider="target">
             <connections>
                 <outlet property="settingView" destination="5Qu-Wa-gxe" id="5o1-KH-Hyj"/>
                 <outlet property="window" destination="F0z-JX-Cv5" id="gIp-Ho-8D9"/>
@@ -18,14 +18,14 @@
             <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
             <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
             <rect key="contentRect" x="196" y="240" width="296" height="112"/>
-            <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1415"/>
+            <rect key="screenRect" x="0.0" y="0.0" width="1920" height="1055"/>
             <value key="minSize" type="size" width="296" height="112"/>
             <value key="maxSize" type="size" width="296" height="112"/>
             <view key="contentView" id="se5-gp-TjO">
                 <rect key="frame" x="0.0" y="0.0" width="296" height="112"/>
                 <autoresizingMask key="autoresizingMask"/>
                 <subviews>
-                    <customView translatesAutoresizingMaskIntoConstraints="NO" id="5Qu-Wa-gxe" customClass="KMCompareContentSettingView" customModule="PDF_Master" customModuleProvider="target">
+                    <customView translatesAutoresizingMaskIntoConstraints="NO" id="5Qu-Wa-gxe" customClass="KMCompareContentSettingView" customModule="PDF_Reader_Pro" customModuleProvider="target">
                         <rect key="frame" x="0.0" y="0.0" width="296" height="112"/>
                     </customView>
                 </subviews>

+ 0 - 3
PDF Office/PDF Master/Class/PDFTools/Compare/ViewController/CoveringComplete/View/KMCompareCoveringView.swift

@@ -53,9 +53,6 @@ class KMCompareCoveringView: BaseXibView {
         oldPColorView.layer?.backgroundColor = KMCompareFilesConfig.defaultConfig.oldStrokeColor().cgColor
         nPDFColorView.layer?.backgroundColor = KMCompareFilesConfig.defaultConfig.newStrokeColor().cgColor
         
-//        saveBtn.setTitleColor(NSColor.white)
-//        closeBtn.setTitleColor(NSColor.white)
-        
         saveBtn.contentTintColor = NSColor.white
         
         closeBtn.contentTintColor = NSColor.white

+ 0 - 2
PDF Office/PDF Master/Class/PDFTools/Compare/ViewController/CoveringSetting/KMCompareCoveringSettingWindowController.swift

@@ -13,8 +13,6 @@ class KMCompareCoveringSettingWindowController: NSWindowController {
     override func windowDidLoad() {
         super.windowDidLoad()
 
-        // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
-        
         window?.title = NSLocalizedString("Settings", comment: "")
     }
     

+ 0 - 1
PDF Office/PDF Master/Class/PDFTools/Compare/ViewController/CoveringSetting/View/KMCompareCoveringSettingView.swift

@@ -35,7 +35,6 @@ class KMCompareCoveringSettingView: BaseXibView {
         NSColorPanel.shared.showsAlpha = true
         separatorLine1.wantsLayer = true
         separatorLine2.wantsLayer = true
-//        NotificationCenter.default.addObserver(self, selector: #selector(updateUI), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
         DistributedNotificationCenter.default().addObserver(self, selector: #selector(updateUI), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
         modelComboBox.isEditable = false
     }

+ 51 - 1
PDF Office/PDF Master/KMClass/KMPDFViewController/KMMainViewController.swift

@@ -2213,6 +2213,41 @@ struct KMNMWCFlags {
         
     }
     
+    //MARK: - 文件对比
+    func beginCompareAction(_ index: Int) {
+        let controller = KMCompareWindowController(windowNibName: "KMCompareWindowController")
+        self.currentWindowController = controller
+        controller.password = self.document?.password ?? ""
+        controller.filePath = (self.document?.documentURL.path)!
+        
+        controller.cancelAction = { [unowned self] controller in
+            self.view.window?.endSheet((self.currentWindowController.window)!)
+            self.currentWindowController = nil
+        }
+        
+        controller.contentComplete = { [unowned self] controller, pdfCompareContent, result, oldDocument, document in
+            self.view.window?.endSheet((self.currentWindowController.window)!)
+            self.currentWindowController = nil
+            
+            self.openContentCompareVC(with: pdfCompareContent, results: result, oldDocument: oldDocument, document: document)
+        }
+        
+        controller.coveringComplete = { [unowned self] controller, document in
+            self.view.window?.endSheet((self.currentWindowController.window)!)
+            self.currentWindowController = nil
+            
+            self.openCoveringCompareVC(with: document)
+        }
+    
+        if index == 1 {
+            controller.fileType = .content
+        } else {
+            controller.fileType = .coverting
+        }
+        NSWindow.currentWindow().beginSheet(controller.window!)
+        
+    }
+    
     //MARK: - TTS
     @IBAction func startSpeaking(_ sender: Any?) {
         self.showTTSWindow()
@@ -3414,7 +3449,10 @@ extension KMMainViewController: KMPDFToolbarControllerDelegate {
                 if let sideVC = self.sideBarController {
                     self.kmPDFSideBarControllerDidSidebarTypeUpdated(sideVC)
                 }
-                
+            } else if itemIdentifier == KMPDFToolbar_tools_compare_side_Identifier {
+                self.beginCompareAction(1)
+            } else if itemIdentifier == KMPDFToolbar_tools_compare_Overlay_Identifier {
+                self.beginCompareAction(2)
             }
         } else if itemIdentifier == KMPDFToolbar_ViewDisplay_Identifier {
             //MARK: -Display
@@ -3452,6 +3490,18 @@ extension KMMainViewController: KMPDFToolbarControllerDelegate {
                         shareOriginalPDF(sender: view)
                     }
                 }
+            } else if itemIdentifier == KMPDFToolbar_save_Identifier {
+                myDocument?.save(nil)
+                
+            } else if itemIdentifier == KMPDFToolbar_print_Identifier {
+                self.showPrintWindow()
+                
+            } else if itemIdentifier == KMPDFToolbar_tts_Identifier {
+                self.showTTSWindow()
+                
+            } else if itemIdentifier == KMPDFToolbar_ppt_Identifier {
+                self.togglePresentation(nil)
+                
             }
         } else if itemIdentifier == KMPDFToolbar_PageEdit_Identifier {
             //MARK: -页面编辑

+ 0 - 2
PDF Office/PDF Master/KMClass/KMPDFViewController/Toolbar/Model/KMPDFToolbarConfig.swift

@@ -134,7 +134,6 @@ let KMPDFToolbar_edit_batchRemoveBates_Identifier           = "KMPDFToolbar_edit
 
  
 //MARK: -Form
-
 let KMPDFToolbar_form_text_Identifier                  = "KMPDFToolbar_form_text_Identifier"
 let KMPDFToolbar_form_checkbox_Identifier              = "KMPDFToolbar_form_checkbox_Identifier"
 let KMPDFToolbar_form_radio_Identifier                 = "KMPDFToolbar_form_radio_Identifier"
@@ -180,7 +179,6 @@ let KMPDFToolbar_convert_Text_Identifier                  = "KMPDFToolbar_conver
 let KMPDFToolbar_convert_Json_Identifier                  = "KMPDFToolbar_convert_Json_Identifier"
 
 //MARK: -Protect
-
 let KMPDFToolbar_protect_redact_Identifier                  = "KMPDFToolbar_protect_redact_Identifier"
 let KMPDFToolbar_protect_redact_Property_Identifier         = "KMPDFToolbar_protect_redact_Property_Identifier"
 let KMPDFToolbar_protect_redact_Apply_Identifier            = "KMPDFToolbar_protect_redact_Apply_Identifier"