Pārlūkot izejas kodu

【fix】【书签】书签列表,添加书签未同步变化

tangchao 9 mēneši atpakaļ
vecāks
revīzija
0b9a1a575d

+ 7 - 19
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

@@ -1365,32 +1365,20 @@ extension KMMainViewController {
     }
     
     @objc func menuItemBookMarkClick_add(sender:NSMenuItem) {
-        if self.listView.document.bookmark(forPageIndex: UInt(self.listView.currentPageIndex)) == nil {
+        if self.listView?.document?.bookmark(forPageIndex: UInt(self.listView.currentPageIndex)) == nil {
             let index = self.listView.currentPageIndex
-            self.listView.document.addBookmark("\(NSLocalizedString("Page", comment: "")) \(index+1)", forPageIndex: UInt(index))
-            self.listView.setNeedsDisplayForVisiblePages()
+            self.listView?.document?.addBookmark("\(NSLocalizedString("Page", comment: "")) \(index+1)", forPageIndex: UInt(index))
+            self.listView?.setNeedsDisplayForVisiblePages()
         } else {
-            self.listView.document.removeBookmark(forPageIndex: UInt(self.listView.currentPageIndex))
-            self.listView.setNeedsDisplayForVisiblePages()
+            self.listView?.document?.removeBookmark(forPageIndex: UInt(self.listView.currentPageIndex))
+            self.listView?.setNeedsDisplayForVisiblePages()
         }
         
+        self.setDocumentEditedState(window: self.view.window)
         if self.isReadMode {
             
         } else {
-            if self.model.leftPanelOpen == false || self.leftSideViewController.type.methodType != .BookMark {
-                self.leftSideViewController.refreshMethodType(methodType: .BookMark)
-            }
-            let bookMark = self.listView.document.bookmark(forPageIndex: UInt(self.listView.currentPageIndex))
-            if bookMark != nil {
-                let item = KMBookMarkItem()
-                item.bookMark = bookMark!
-                item.label = (bookMark?.label)!
-                item.index = UInt(bookMark!.pageIndex)
-//                self.leftSideViewController.bookViewController.reloadData()
-//                self.leftSideViewController.bookViewController.addBookMarkAndEdit(newBookMark: item)
-            } else {
-//                self.leftSideViewController.bookViewController.reloadData()
-            }
+            self.leftSideViewController.refreshUIOfOutlineIfNeed()
         }
     }
     

+ 26 - 1
PDF Office/PDF Master/Class/README.md

@@ -39,7 +39,32 @@
 
 * 维护建议
 1. 新增功能或修复bug,尽量通过重写类来处理,保证三方库内部尽可能少的改动.
- 
+
+## Apple Event 开发注意项
+
+- NSAppleScript 开发注意项 [脚本开发]
+
+1. Apple Events 设置项 开启
+2. info.plist 新增一项 [Privacy - AppleEvents Sending Usage Description] 授权提示语,在请求系统授权时弹起的授权窗口里提示语.缺失会引起crash,App Store 版本也可能会被拒.
+3. 开启其他程序授权 xx.entitlements 新增一项 [com.apple.security.temporary-exception.apple-events]
+- Office Word       [com.microsoft.word]
+- Office Excel      [com.microsoft.excel]
+- Office PPT        [com.microsoft.powerpoint]
+- ...
+4. 编码脚本执行 [可见: KMConvertPDFManager] 
+
+- Office 转 PDF 
+1. 创建空白 PDF 文件
+2. 开启 Office 程序,并把原文件路径和需要存储的路径 [空白PDF文件的路径] 传递给 Office 程序. [脚本执行]
+
+* 脚本执行时会有两处授权 
+1. 开启 Office 程序需要授权,只授权一次. [授权后可以在 偏好设置->安全性与隐私->隐私->自动化 里查看授权情况]
+2 Office 程序将数据保存为PDF文件时需要授权 [因空白PDF文件是 App的私有路径]
+
+* 脚本执行错误
+1. 没有授权 [可以在 偏好设置->安全性与隐私->隐私->自动化 里查看授权情况]
+2. Office 程序没有运行 [检查 NSAppleScript 开发注意项里的 1. 2. 3.]
+... 
 
 ## App 主要模块的入口