Browse Source

【2025】【Page】缩图插入页面时不选中页面时为当前页码

dinglingui 1 month ago
parent
commit
a294c40d0d

+ 12 - 4
PDF Office/PDF Master/KMClass/KMNPDFPageEdit/KMNThumbnailView/KMNThumbnailBaseViewController+Action.swift

@@ -689,8 +689,10 @@ extension KMNThumbnailBaseViewController {
     }
     
     private func insertFilePath(filePath:String,pdfPassword:String?) {
-        let selectedIndexPaths = collectionView.selectionIndexPaths
-        
+        var selectedIndexPaths = collectionView.selectionIndexPaths
+        if(selectedIndexPaths.count <= 0) {
+            selectedIndexPaths = pdfviewSelectionIndexPaths
+        }
         let insertPDF = KMNPDFInsertPDFWindowController(showDocument, filePath: filePath, password: pdfPassword, selectionIndexPaths: selectedIndexPaths)
         insertPDF.pdfCallback = { [weak self] fileAttribute, insertIdx in
             let doc = fileAttribute.pdfDocument
@@ -778,7 +780,10 @@ extension KMNThumbnailBaseViewController {
             return
         }
         
-        let selectedIndexPaths = collectionView.selectionIndexPaths
+        var selectedIndexPaths = collectionView.selectionIndexPaths
+        if(selectedIndexPaths.count <= 0) {
+            selectedIndexPaths = pdfviewSelectionIndexPaths
+        }
         
         let insertPDF = KMNPDFInsertBlankWindowController(self.showDocument, selectionIndexPaths: selectedIndexPaths)
         insertPDF.callback = { [weak self] pageSize, insertIdx in
@@ -792,7 +797,10 @@ extension KMNThumbnailBaseViewController {
             KMPurchaseCompareWindowController.sharedInstance()?.showWindow(nil)
             return
         }
-        let selectedIndexPaths = collectionView.selectionIndexPaths
+        var selectedIndexPaths = collectionView.selectionIndexPaths
+        if(selectedIndexPaths.count <= 0) {
+            selectedIndexPaths = pdfviewSelectionIndexPaths
+        }
         var maxmumIndex = 1
         if(selectedIndexPaths.count > 0) {
             let maxmumIndexPath = selectedIndexPaths.max(by: { $0 < $1 })

+ 3 - 0
PDF Office/PDF Master/KMClass/KMNPDFPageEdit/KMNThumbnailView/KMNThumbnailBaseViewController.swift

@@ -131,8 +131,11 @@ class KMNThumbnailBaseViewController: KMNBaseViewController,NSCollectionViewDele
         }
     }
     
+    var pdfviewSelectionIndexPaths: Set<IndexPath> = []
+    
     var selectionIndexPaths: Set<IndexPath> = [] {
         didSet {
+            pdfviewSelectionIndexPaths = selectionIndexPaths
             var indexpaths: Set<IndexPath> = []
             for indexpath in selectionIndexPaths {
                 if (indexpath.section >= collectionView.numberOfSections) {