Browse Source

【综合】链接注释修复bug

tangchao 1 year ago
parent
commit
c237c3e195

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

@@ -436,21 +436,5 @@
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "90A10999-2290-4C20-B983-553DE9938461"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "867"
-            endingLineNumber = "867"
-            landmarkName = "menuItemAnnotationClick_addStype(sender:)"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
    </Breakpoints>
 </Bucket>

+ 4 - 2
PDF Office/PDF Master/Class/PDFTools/TTS/Model/KMTTSManager.swift

@@ -137,7 +137,7 @@ class KMTTSManager: NSObject, NSSpeechSynthesizerDelegate{
         let _ = delegate?.ttsManangerDidFinishSpeech?(self)
     }
     func speechSynthesizer(_ sender: NSSpeechSynthesizer, willSpeakWord characterRange: NSRange, of string: String) {
-        var selection: CPDFSelection!
+        var selection: CPDFSelection?
         if let page = speechPDFPage {
             if characterRange.length > 0 {
                 selection = page.selection(for: characterRange)
@@ -145,7 +145,9 @@ class KMTTSManager: NSObject, NSSpeechSynthesizerDelegate{
         } else if let pdfSelection = speechPDFSelection {
             selection = pdfSelection
         }
-        delegate?.ttsMananger?(self, willSpeak: selection)
+        if let data = selection {
+            delegate?.ttsMananger?(self, willSpeak: data)
+        }
     }
     func speechSynthesizer(_ sender: NSSpeechSynthesizer, didEncounterErrorAt characterIndex: Int, of string: String, message: String) {
         delegate?.ttsManangerdidErrorSpeech?(self, message: message)

+ 7 - 5
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/KMAnnotationSelectLinkViewController.swift

@@ -20,7 +20,7 @@ enum KMAnnotationLinkType: UInt {
     
     var _annotations: [CPDFAnnotation]?
     var pdfDocument: CPDFDocument?
-    var _pdfview: CPDFListView?
+    weak var _pdfview: CPDFListView?
     
     @IBOutlet var linkPageBox: KMBox!
     @IBOutlet var linkPageImageView: NSImageView!
@@ -247,10 +247,11 @@ enum KMAnnotationLinkType: UInt {
         }
     }
     
-    var pdfview: CPDFListView? {
+    weak var pdfview: CPDFListView? {
         set {
             _pdfview = newValue
-            startPage = _pdfview?.currentPage().label
+//            startPage = _pdfview?.currentPage().label
+            self.startPage = "\((self._pdfview?.currentPage().pageIndex() ?? 1)+1)"
         }
         get {
             return _pdfview
@@ -473,7 +474,7 @@ enum KMAnnotationLinkType: UInt {
         }
 
         goButton.layer?.backgroundColor = KMAppearance.Interactive.m0Color().cgColor
-        Timer.scheduledTimer(timeInterval: 0.1, target: false, selector: #selector(timered(_:)), userInfo: nil, repeats: false)
+        Timer.scheduledTimer(timeInterval: 0.1, target: self, selector: #selector(timered(_:)), userInfo: nil, repeats: false)
 
         switch linkType {
         case .page:
@@ -586,7 +587,8 @@ enum KMAnnotationLinkType: UInt {
                 goButton.setTitleColor(KMAppearance.Layout.w0Color().withAlphaComponent(0.4))
             }
 
-            let page = pdfDocument!.page(at: UInt(dexPage - 1))
+            let pageIndex = UInt(max(dexPage-1, 0))
+            let page = pdfDocument!.page(at: pageIndex)
             let bounds = page?.bounds(for: .cropBox) ?? .zero
             let destination = CPDFDestination(page: page, at: NSMakePoint(0, bounds.size.height))
             

+ 1 - 1
PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMToolbarViewController.swift

@@ -1772,7 +1772,7 @@ extension KMToolbarViewController {
             item?.titleName = NSLocalizedString("Crop", comment: "")
             item?.boxImagePosition = .imageExpandLeft
             item?.needExpandAction = true
-            item?.btnAction = #selector(cropMenuAction)
+//            item?.btnAction = #selector(cropMenuAction)
             
             let menuItem = NSMenuItem.init(title: "Crop", action: #selector(cropMenuAction), target: self)
             let subMenu = NSMenu()