|
@@ -4888,66 +4888,70 @@ extension KMMainViewController: KMEditToolbarViewDelegate {
|
|
|
pageString = String(format: "%ld", listView.currentPageIndex)
|
|
|
}
|
|
|
if view.editType == .watermark {
|
|
|
- if let model = watermarkViewController?.currentWatermarkData {
|
|
|
- let watermark = KMWatermarkModel.returnWaterMarkWith(model, listView.document)
|
|
|
- watermark.pageString = pageString
|
|
|
- listView.document.addWatermark(watermark)
|
|
|
- listView.layoutDocumentView()
|
|
|
+ if view.editSubType == .edit {
|
|
|
|
|
|
- self.recordIsPDFDocumentEdited()
|
|
|
- }
|
|
|
- exitEditToolbarView()
|
|
|
- } else if view.editType == .background {
|
|
|
- if let model = backgroundViewController?.backgroundModel {
|
|
|
- if let background = listView.document.background() {
|
|
|
- KMBackgroundManager.defaultManager.updateBackground(background, withModel: model)
|
|
|
- background.pageString = pageString
|
|
|
- background.update()
|
|
|
-
|
|
|
- listView.document?.refreshPageData()
|
|
|
- listView.layoutDocumentView()
|
|
|
-
|
|
|
- self.recordIsPDFDocumentEdited()
|
|
|
- }
|
|
|
+ } else {
|
|
|
+ self.applyWatermarkInfo(pageString)
|
|
|
+ }
|
|
|
+ } else if view.editType == .background, let propertyVC = backgroundViewController?.propertyController {
|
|
|
+ if view.editSubType == .edit && backgroundViewController?.propertyController.isOriginalDataDictChanged() == true {
|
|
|
+ propertyVC.showSaveEditChangeAlert(completion: { response in
|
|
|
+ if response == NSApplication.ModalResponse.alertFirstButtonReturn {
|
|
|
+ //OK
|
|
|
+ propertyVC.saveDataEdit()
|
|
|
+
|
|
|
+ self.applyBackgroundInfo(pageString)
|
|
|
+ } else {
|
|
|
+ //Cancel
|
|
|
+ propertyVC.cancelDataEdit()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ self.applyBackgroundInfo(pageString)
|
|
|
}
|
|
|
- exitEditToolbarView()
|
|
|
-
|
|
|
} else if view.editType == .header_Footer {
|
|
|
- if let model = headerFooterViewController?.headerFooterModel {
|
|
|
- if let headerFooter = listView.document.headerFooter() {
|
|
|
- KMHeaderFooterManager.defaultManager.updateCPDFHeaderFooter(headerFooter, withModel: model, Int(listView.document.pageCount))
|
|
|
- headerFooter.pageString = pageString
|
|
|
- headerFooter.update()
|
|
|
-
|
|
|
- listView.document?.refreshPageData()
|
|
|
- listView.layoutDocumentView()
|
|
|
-
|
|
|
- self.recordIsPDFDocumentEdited()
|
|
|
- }
|
|
|
+ if view.editSubType == .edit {
|
|
|
|
|
|
+ } else {
|
|
|
+ self.applyHeaderFooterInfo(pageString)
|
|
|
}
|
|
|
-
|
|
|
- exitEditToolbarView()
|
|
|
-
|
|
|
} else if view.editType == .bates {
|
|
|
- if let model = batesViewController?.batesModel {
|
|
|
- if let bates = listView.document.bates() {
|
|
|
- KMBatesManager.defaultManager.updateCPDFBates(bates, withModel: model, Int(listView.document.pageCount))
|
|
|
- bates.pageString = pageString
|
|
|
- bates.update()
|
|
|
-
|
|
|
- listView.document?.refreshPageData()
|
|
|
- listView.layoutDocumentView()
|
|
|
-
|
|
|
- self.recordIsPDFDocumentEdited()
|
|
|
- }
|
|
|
+ if view.editSubType == .edit {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ self.applyBatesInfo(pageString)
|
|
|
}
|
|
|
- exitEditToolbarView()
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
func kmEditToolbarViewDidChooseExit(_ view: KMEditToolbarView) {
|
|
|
+ //在编辑数据时,先判断是否要保存数据。
|
|
|
+
|
|
|
+ if view.editType == .watermark {
|
|
|
+
|
|
|
+ } else if view.editType == .background, view.editSubType == .edit, let propertyVC = backgroundViewController?.propertyController, propertyVC.isOriginalDataDictChanged() == true {
|
|
|
+ propertyVC.showSaveEditChangeAlert { response in
|
|
|
+ if response == NSApplication.ModalResponse.alertFirstButtonReturn {
|
|
|
+ //OK
|
|
|
+ propertyVC.saveDataEdit()
|
|
|
+
|
|
|
+ self.kmEditToolbarViewDidChooseExit(view)
|
|
|
+ } else {
|
|
|
+ //Cancel
|
|
|
+ propertyVC.cancelDataEdit()
|
|
|
+
|
|
|
+ self.kmEditToolbarViewDidChooseExit(view)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+ } else if view.editType == .header_Footer {
|
|
|
+
|
|
|
+ } else if view.editType == .bates {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
if view.applyEnable {
|
|
|
let alert = NSAlert()
|
|
|
if view.editType == .watermark {
|
|
@@ -4977,6 +4981,69 @@ extension KMMainViewController: KMEditToolbarViewDelegate {
|
|
|
exitEditToolbarView()
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ func applyWatermarkInfo(_ pageString: String) {
|
|
|
+ if let model = watermarkViewController?.currentWatermarkData {
|
|
|
+ let watermark = KMWatermarkModel.returnWaterMarkWith(model, listView.document)
|
|
|
+ watermark.pageString = pageString
|
|
|
+ listView.document.addWatermark(watermark)
|
|
|
+ listView.layoutDocumentView()
|
|
|
+
|
|
|
+ self.recordIsPDFDocumentEdited()
|
|
|
+ }
|
|
|
+ exitEditToolbarView()
|
|
|
+ }
|
|
|
+
|
|
|
+ func applyBackgroundInfo(_ pageString: String) {
|
|
|
+ if let model = backgroundViewController?.backgroundModel {
|
|
|
+ if let background = listView.document.background() {
|
|
|
+ KMBackgroundManager.defaultManager.updateBackground(background, withModel: model)
|
|
|
+ background.pageString = pageString
|
|
|
+ background.update()
|
|
|
+
|
|
|
+ listView.document?.refreshPageData()
|
|
|
+ listView.layoutDocumentView()
|
|
|
+
|
|
|
+ self.recordIsPDFDocumentEdited()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ exitEditToolbarView()
|
|
|
+ }
|
|
|
+
|
|
|
+ func applyHeaderFooterInfo(_ pageString: String) {
|
|
|
+ if let model = headerFooterViewController?.headerFooterModel {
|
|
|
+ if let headerFooter = listView.document.headerFooter() {
|
|
|
+ KMHeaderFooterManager.defaultManager.updateCPDFHeaderFooter(headerFooter, withModel: model, Int(listView.document.pageCount))
|
|
|
+ headerFooter.pageString = pageString
|
|
|
+ headerFooter.update()
|
|
|
+
|
|
|
+ listView.document?.refreshPageData()
|
|
|
+ listView.layoutDocumentView()
|
|
|
+
|
|
|
+ self.recordIsPDFDocumentEdited()
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ exitEditToolbarView()
|
|
|
+ }
|
|
|
+
|
|
|
+ func applyBatesInfo(_ pageString: String) {
|
|
|
+ if let model = batesViewController?.batesModel {
|
|
|
+ if let bates = listView.document.bates() {
|
|
|
+ KMBatesManager.defaultManager.updateCPDFBates(bates, withModel: model, Int(listView.document.pageCount))
|
|
|
+ bates.pageString = pageString
|
|
|
+ bates.update()
|
|
|
+
|
|
|
+ listView.document?.refreshPageData()
|
|
|
+ listView.layoutDocumentView()
|
|
|
+
|
|
|
+ self.recordIsPDFDocumentEdited()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ exitEditToolbarView()
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//MARK: - KMCropControllerDelegate 裁剪相关代理
|