|
@@ -3855,6 +3855,10 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
|
|
|
|
|
|
Task { @MainActor in
|
|
|
if (type == .compress) { /// 压缩
|
|
|
+ if !self.documentAllowsEdit() {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
if await (KMLightMemberManager.manager.canPayFunction() == false) {
|
|
|
// self.view.window?.contentView?.superview?.beginLoading()
|
|
|
let document = self.listView.document
|
|
@@ -3919,36 +3923,38 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
|
|
|
|
|
|
if (type == .merge) { /// 合并
|
|
|
FMTrackEventManager.defaultManager.trackEvent(event: "SubTbr_Editor", withProperties: ["SubTbr_Btn": "Btn_SubTbr_Editor_Merge"])
|
|
|
- if (self.listView.document.allowsCopying == false || self.listView.document.allowsPrinting == false) {
|
|
|
- if await (KMLightMemberManager.manager.canPayFunction() == false) {
|
|
|
- KMPasswordInputWindow.openWindow(window: self.view.window!, type: .owner, url: self.listView.document.documentURL) { [unowned self] result , password in
|
|
|
- if (result == .cancel) {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- guard let _url = KMTools.saveWatermarkDocumentToTemp(document: self.listView.document, secureOptions: self.secureOptions, removePWD: self.removeSecureFlag) else {
|
|
|
- return
|
|
|
- }
|
|
|
- self.showMergeWindow(url: _url, password)
|
|
|
- }
|
|
|
- return
|
|
|
- }
|
|
|
+ if !self.documentAllowsEdit() {
|
|
|
+ return
|
|
|
|
|
|
- KMPasswordInputWindow.openWindow(window: self.view.window!, type: .owner, url: self.listView.document.documentURL) { [unowned self] result , password in
|
|
|
- if (result == .cancel) {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if (self.needSaveDocument()) {
|
|
|
- self.saveDocumentWithProgressAlert { [unowned self] params in
|
|
|
- self.showMergeWindow(password)
|
|
|
- }
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- self.showMergeWindow(password)
|
|
|
- }
|
|
|
+// if await (KMLightMemberManager.manager.canPayFunction() == false) {
|
|
|
+// KMPasswordInputWindow.openWindow(window: self.view.window!, type: .owner, url: self.listView.document.documentURL) { [unowned self] result , password in
|
|
|
+// if (result == .cancel) {
|
|
|
+// return
|
|
|
+// }
|
|
|
+//
|
|
|
+// guard let _url = KMTools.saveWatermarkDocumentToTemp(document: self.listView.document, secureOptions: self.secureOptions, removePWD: self.removeSecureFlag) else {
|
|
|
+// return
|
|
|
+// }
|
|
|
+// self.showMergeWindow(url: _url, password)
|
|
|
+// }
|
|
|
+// return
|
|
|
+// }
|
|
|
+//
|
|
|
+// KMPasswordInputWindow.openWindow(window: self.view.window!, type: .owner, url: self.listView.document.documentURL) { [unowned self] result , password in
|
|
|
+// if (result == .cancel) {
|
|
|
+// return
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// if (self.needSaveDocument()) {
|
|
|
+// self.saveDocumentWithProgressAlert { [unowned self] params in
|
|
|
+// self.showMergeWindow(password)
|
|
|
+// }
|
|
|
+// return
|
|
|
+// }
|
|
|
+//
|
|
|
+// self.showMergeWindow(password)
|
|
|
+// }
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -3971,10 +3977,16 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
|
|
|
}
|
|
|
|
|
|
if (type == .bates || type == .headerAndFooter) {
|
|
|
+
|
|
|
if !IAPProductsManager.default().isAvailableAllFunction(){
|
|
|
KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ if !self.documentAllowsEdit() {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
if (index == 1) {
|
|
|
var windowController: KMBaseWindowController = KMBaseWindowController()
|
|
|
|
|
@@ -4209,18 +4221,22 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
|
|
|
} else if (type == .secure) { /// 安全
|
|
|
if (index == 1) { /// 设置密码
|
|
|
if (!self.listView.document!.allowsCopying || !self.listView.document!.allowsPrinting) {
|
|
|
- KMPasswordInputWindow.openWindow(window: self.view.window!, type: .owner, url: self.listView.document.documentURL) { [weak self] result, password in
|
|
|
- if (result == .cancel) {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- self?.isSaveKeyChain = false
|
|
|
- self?.listView.document.unlock(withPassword: password)
|
|
|
- self?.hiddenSecureLimitTip()
|
|
|
-
|
|
|
- self?.showSecureWindow((self?.listView.document.documentURL)!)
|
|
|
+ if !self.documentAllowsEdit() {
|
|
|
+ return
|
|
|
}
|
|
|
- return
|
|
|
+
|
|
|
+// KMPasswordInputWindow.openWindow(window: self.view.window!, type: .owner, url: self.listView.document.documentURL) { [weak self] result, password in
|
|
|
+// if (result == .cancel) {
|
|
|
+// return
|
|
|
+// }
|
|
|
+//
|
|
|
+// self?.isSaveKeyChain = false
|
|
|
+// self?.listView.document.unlock(withPassword: password)
|
|
|
+// self?.hiddenSecureLimitTip()
|
|
|
+//
|
|
|
+// self?.showSecureWindow((self?.listView.document.documentURL)!)
|
|
|
+// }
|
|
|
+// return
|
|
|
}
|
|
|
self.showSecureWindow(self.listView.document.documentURL)
|
|
|
return
|
|
@@ -4370,6 +4386,10 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ if !self.documentAllowsEdit() {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
if index == 1 {
|
|
|
let controller = KMWatermarkWindowController(windowNibName: "KMWatermarkWindowController")
|
|
|
self.currentWindowController = controller
|
|
@@ -4462,7 +4482,11 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
|
|
|
KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ if !self.documentAllowsEdit() {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
if index == 1 {
|
|
|
let controller = KMBackgroundWindowController(windowNibName: "KMBackgroundWindowController")
|
|
|
self.currentWindowController = controller
|
|
@@ -4594,6 +4618,13 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
|
|
|
} else if itemID == KMDocumentScanOCRToolbarItemIdentifier {
|
|
|
showOCRWindow()
|
|
|
} else if itemID == KMDocumentDigitalSignToolbarItemIdentifier {
|
|
|
+ if !self.listView.document!.allowsPrinting || !self.listView.document!.allowsCopying {
|
|
|
+ let alert = NSAlert()
|
|
|
+ alert.alertStyle = .critical
|
|
|
+ alert.messageText = NSLocalizedString("This is a secured document. Editing is not permitted.", comment: "")
|
|
|
+ alert.runModal()
|
|
|
+ return
|
|
|
+ }
|
|
|
self.listView.toolMode = .textToolMode
|
|
|
toolbarItem.isSelected = !toolbarItem.isSelected
|
|
|
self.toolbarController.lastItemBox = toolbarItem
|
|
@@ -5363,3 +5394,18 @@ extension KMMainViewController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+extension KMMainViewController {
|
|
|
+ func documentAllowsEdit() -> Bool {
|
|
|
+ if (self.listView.document.allowsCopying == false || self.listView.document.allowsPrinting == false) {
|
|
|
+
|
|
|
+ let alert = NSAlert()
|
|
|
+ alert.alertStyle = .critical
|
|
|
+ alert.messageText = NSLocalizedString("This is a secured document. Editing is not permitted.", comment: "")
|
|
|
+ alert.runModal()
|
|
|
+ return false
|
|
|
+ } else {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|