Przeglądaj źródła

【页面编辑】以独立窗口打开两个文档,拖拽A文档的缩略图插入到文档B的缩略图列表中,直接关闭文档B,未提示是否保存(已修复)

tangchao 1 rok temu
rodzic
commit
adfe26fddf

+ 16 - 32
PDF Office/PDF Master.xcodeproj/xcuserdata/kdanmobile.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -132,22 +132,6 @@
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "BB151374-6477-4D44-9954-EDFA5470314B"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "PDF Master/Class/ChromiumTabs/src/Browser Window/CTBrowserWindowController.m"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "479"
-            endingLineNumber = "479"
-            landmarkName = "-moveTabView:fromController:"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
@@ -164,22 +148,6 @@
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "2C5B8114-9652-408E-8C12-C35368AB3EAC"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "PDF Master/Class/PDFWindowController/ViewController/KMMainViewController.swift"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "1407"
-            endingLineNumber = "1407"
-            landmarkName = "pdfViewPerformGo(toPage:)"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
@@ -228,5 +196,21 @@
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "832A9F00-7E4C-4433-8CA0-FF1602042546"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDF Master/Class/Document/KMMainDocument.swift"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "313"
+            endingLineNumber = "313"
+            landmarkName = "pdfChangedNotification(_:)"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
    </Breakpoints>
 </Bucket>

+ 2 - 2
PDF Office/PDF Master/Class/Common/Category/NSView+KMExtension.swift

@@ -42,7 +42,7 @@ extension NSView: KMLoadingProtocol {
         }
     }
     
-    // MARK:- do in main thread.
+    // MARK: - do in main thread.
     
     private func beginLoadingInMainThread() {
         let maskView = self.createLoadingMaskView()
@@ -77,7 +77,7 @@ extension NSView: KMLoadingProtocol {
         maskView?.removeFromSuperview()
     }
     
-    // MARK:- Init View
+    // MARK: - Init View
     
     private func createLoadingMaskView() -> NSButton {
         let mask = NSButton()

+ 8 - 9
PDF Office/PDF Master/Class/Document/KMMainDocument.swift

@@ -385,18 +385,13 @@ typealias KMMainDocumentCloudUploadHanddler = (@escaping(Bool, String)->()) -> (
     }
     
     func setDataFromTmpData() {
-        if self.mainViewController == nil {
+        guard let _document = self.mainViewController?.document else {
             return
         }
-        let document = self.mainViewController!.document
-        if (document == nil) {
-            return
-        }
-        
 //        self.tryToUnlockDocument(document!)
-        if (document!.permissionsStatus != .owner) {
+        if (_document.permissionsStatus != .owner) {
             var password: NSString? = nil
-            let fileId = self.fileId(for: document!)
+            let fileId = self.fileId(for: _document)
             if (fileId.isEmpty) {
                 return
             }
@@ -404,7 +399,7 @@ typealias KMMainDocumentCloudUploadHanddler = (@escaping(Bool, String)->()) -> (
             if (password != nil) {
                 self.isUnlockFromKeychain = true
 //                document.unlock(withPassword: password! as String)
-                self.mainViewController!.password = password as String?
+                self.mainViewController?.password = password as String?
             }
         }
     }
@@ -424,6 +419,10 @@ typealias KMMainDocumentCloudUploadHanddler = (@escaping(Bool, String)->()) -> (
         }
     }
     
+    func km_updateChangeCount(_ change: NSDocument.ChangeType) {
+        super.updateChangeCount(change)
+    }
+    
     private func _km_write(to url: URL, ofType typeName: String, for saveOperation: NSDocument.SaveOperationType, originalContentsURL absoluteOriginalContentsURL: URL?) throws {
         var success = true
         if !self.isHome {

+ 11 - 3
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/Thumbnail/KMThumbnailViewController.swift

@@ -433,14 +433,22 @@ class KMThumbnailViewController: KMBaseViewController {
             count += 1
         }
         
-        self.listView.undoManager?.registerUndo(withTarget: self, selector: #selector(deletePages), object: indexs)
+//        self.listView.undoManager?.registerUndo(withTarget: self, selector: #selector(deletePages), object: indexs)
+        // 设置文档已编辑
+        DispatchQueue.main.asyncAfter(deadline: .now() + 0.7, execute: {
+            let currentDocument = NSDocumentController.shared.document(for: self.listView.document.documentURL)
+            (currentDocument as? KMMainDocument)?.km_updateChangeCount(.changeDone)
+        })
+        
+        (self.listView.undoManager?.prepare(withInvocationTarget: self) as AnyObject).deletePages(indexs: indexs)
         
         self.listView?.layoutDocumentView()
         self.thumbnailView.reloadData()
     }
     
     /// MARK: indexs 需要降序排序后
-    @objc private func deletePages(indexs: IndexSet) {
+    /// dynamic 动态派发
+    @objc private dynamic func deletePages(indexs: IndexSet) {
         let newIndexs = indexs.sorted()
         var array: Array<CPDFPage> = []
         for i in indexs {
@@ -807,7 +815,7 @@ extension KMThumbnailViewController : KMThumbnailViewDelegate {
     }
     
     func thumbnailView(thumbanView: KMThumbnailView, didDragAddFiles files: [URL], indexpath: IndexPath) {
-        self.km_add_file_multi(fileUrls: files) { index, params in
+        self.km_add_file_multi(fileUrls: files) { [unowned self] index, params in
             if (self.fetchProgressBlockParamsIsPasswordFile(params: params)) { // 加密文档进度回调
                 return
             }