Browse Source

【数据兼容】页眉页脚数据兼容

lizhe 11 months ago
parent
commit
3ca6b285db
30 changed files with 1854 additions and 896 deletions
  1. 2 2
      PDF Office/PDF Master/Class/Batch/WindowController/KMBatchOperateBaseWindowController.swift
  2. 2 2
      PDF Office/PDF Master/Class/Batch/WindowController/KMBatchOperateRightViewController.swift
  3. 2 2
      PDF Office/PDF Master/Class/Batch/WindowController/KMBatchOperateSplitViewController.swift
  4. 3 3
      PDF Office/PDF Master/Class/PDFTools/AddHeaderFooter/Model/KMBatchAddHeaderFooterOperation.swift
  5. 2 2
      PDF Office/PDF Master/Class/PDFTools/AddHeaderFooter/New/KMHeaderFooterWindowController.swift
  6. 29 29
      PDF Office/PDF Master/Class/PDFTools/AddHeaderFooter/New/View/KMHeaderFooterView.swift
  7. 38 38
      PDF Office/PDF Master/Class/PDFTools/AddHeaderFooter/VC/KMBatchOperateAddHeaderFooterViewController.swift
  8. 1 1
      PDF Office/PDF Master/Class/PDFTools/AddHeaderFooter/View/KMHeaderFooterTableCellView.swift
  9. 8 8
      PDF Office/PDF Master/Class/PDFTools/AddHeaderFooter/WindowComtroller/KMHeaderFooterManagerWindowController.swift
  10. 1 1
      PDF Office/PDF Master/Class/PDFTools/Bates/Controller/KMBatesPreviewController.swift
  11. 7 7
      PDF Office/PDF Master/Class/PDFTools/Bates/Controller/KMBatesPropertyInfoController.swift
  12. 4 0
      PDF Office/PDF Master/Class/PDFTools/Bates/Model/KMBatesModel.swift
  13. 4 4
      PDF Office/PDF Master/Class/PDFTools/Bates/Tools/KMBatesManager.swift
  14. 97 5
      PDF Office/PDF Master/Class/PDFTools/HeaderFooter/Base/KMHeaderFooterAdjectiveModel.swift
  15. 4 4
      PDF Office/PDF Master/Class/PDFTools/HeaderFooter/Controller/KMCreateHeaderFooterController.swift
  16. 5 5
      PDF Office/PDF Master/Class/PDFTools/HeaderFooter/Controller/KMHeaderFooterPreviewController.swift
  17. 10 11
      PDF Office/PDF Master/Class/PDFTools/HeaderFooter/Controller/KMHeaderFooterPropertyController.swift
  18. 6 6
      PDF Office/PDF Master/Class/PDFTools/HeaderFooter/Controller/KMHeaderFooterPropertyInfoController.swift
  19. 11 13
      PDF Office/PDF Master/Class/PDFTools/HeaderFooter/Controller/KMHeaderFooterPropertyMainController.swift
  20. 52 22
      PDF Office/PDF Master/Class/PDFTools/HeaderFooter/Model/KMHeaderFooterModel.swift
  21. 2 2
      PDF Office/PDF Master/Class/PDFTools/HeaderFooter/Tools/KMDataVersionManager.swift
  22. 747 369
      PDF Office/PDF Master/Class/PDFTools/HeaderFooter/Tools/KMHeaderFooterManager.swift
  23. 1 1
      PDF Office/PDF Master/Class/PDFTools/HeaderFooter/View/KMHeaderFooterDateInfoView.swift
  24. 4 4
      PDF Office/PDF Master/Class/PDFTools/HeaderFooter/View/KMHeaderFooterMarginInfoView.swift
  25. 2 0
      PDF Office/PDF Master/Class/PDFTools/Watermark/Base/KMWatermarkAdjectiveBaseModel.swift
  26. 2 2
      PDF Office/PDF Master/Class/PDFTools/Watermark/OCPart/KMWatermarkPDFView_OC.m
  27. 10 10
      PDF Office/PDF Master/Class/PDFTools/Watermark/Tools/KMWatermarkAdjectiveTools.swift
  28. 20 20
      PDF Office/PDF Master/Class/PDFTools/Watermark/View/KMWatermarkPDFView.swift
  29. 2 2
      PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController.swift
  30. 776 321
      PDF Office/PDF Reader Pro.xcodeproj/xcuserdata/lizhe.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

+ 2 - 2
PDF Office/PDF Master/Class/Batch/WindowController/KMBatchOperateBaseWindowController.swift

@@ -77,10 +77,10 @@ import Cocoa
     func backgroundInterfaceSelectBackGround(background: KMBackgroundModel) {
         (self.contentViewController as! KMBatchOperateSplitViewController).backgroundInterfaceSelectBackground(background)
     }
-    func headerFooterInterfaceSelectHeaderFooter(headerFooter: KMHeaderFooterModel) {
+    func headerFooterInterfaceSelectHeaderFooter(headerFooter: KMHeaderFooterObject) {
         (self.contentViewController as! KMBatchOperateSplitViewController).headerFooterInterfaceSelectHeaderFooter(headerFooter)
     }
-    func batesInterfaceSelectBates(headerFooter: KMHeaderFooterModel) {
+    func batesInterfaceSelectBates(headerFooter: KMHeaderFooterObject) {
         (self.contentViewController as! KMBatchOperateSplitViewController).headerFooterInterfaceSelectHeaderFooter(headerFooter)
     }
     

+ 2 - 2
PDF Office/PDF Master/Class/Batch/WindowController/KMBatchOperateRightViewController.swift

@@ -201,13 +201,13 @@ class KMBatchOperateRightViewController: NSViewController{
         }
     }
     
-    func headerFooterInterfaceSelectHeaderFooter(_ headerFooter: KMHeaderFooterModel) {
+    func headerFooterInterfaceSelectHeaderFooter(_ headerFooter: KMHeaderFooterObject) {
         if self.currentType == .AddHeaderFooter {
             self.addHeaderFooterViewController?.headerFooterInterfaceSelectHeaderFooter(headerFooter: headerFooter)
         }
     }
     
-    func batesInterfaceSelectBates(_ headerFooter: KMHeaderFooterModel) {
+    func batesInterfaceSelectBates(_ headerFooter: KMHeaderFooterObject) {
         if self.currentType == .AddBates {
             self.addHeaderFooterViewController?.headerFooterInterfaceSelectHeaderFooter(headerFooter: headerFooter)
         }

+ 2 - 2
PDF Office/PDF Master/Class/Batch/WindowController/KMBatchOperateSplitViewController.swift

@@ -54,10 +54,10 @@ class KMBatchOperateSplitViewController: NSSplitViewController{
     func backgroundInterfaceSelectBackground(_ background: KMBackgroundModel) {
         self.rightPropertiesViewController?.backgroundInterfaceSelectBackground(background)
     }
-    func headerFooterInterfaceSelectHeaderFooter(_ headerFooter: KMHeaderFooterModel) {
+    func headerFooterInterfaceSelectHeaderFooter(_ headerFooter: KMHeaderFooterObject) {
         self.rightPropertiesViewController?.headerFooterInterfaceSelectHeaderFooter(headerFooter)
     }
-    func batesInterfaceSelectBates(_ headerFooter: KMHeaderFooterModel) {
+    func batesInterfaceSelectBates(_ headerFooter: KMHeaderFooterObject) {
         self.rightPropertiesViewController?.batesInterfaceSelectBates(headerFooter)
     }
 }

+ 3 - 3
PDF Office/PDF Master/Class/PDFTools/AddHeaderFooter/Model/KMBatchAddHeaderFooterOperation.swift

@@ -12,11 +12,11 @@ let mainBundleIdentifier = Bundle.main.bundleIdentifier ?? ""
 let kTempSavePath = supportDirectory?.stringByAppendingPathComponent(mainBundleIdentifier)
 
 class KMBatchAddHeaderFooterOperation: KMBatchOperation{
-    var headerFooter: KMHeaderFooterModel?
+    var headerFooter: KMHeaderFooterObject?
     var pdfDocument: CPDFDocument?
     var password: String?
     
-    init(file: KMBatchOperateFile, headerFooter: KMHeaderFooterModel) {
+    init(file: KMBatchOperateFile, headerFooter: KMHeaderFooterObject) {
         super.init(file: file)
         self.headerFooter = headerFooter
         
@@ -270,7 +270,7 @@ func convertPageFormat(oldString: String, startPage: String, pageCount: String)
 }
 func convertDateFormat(oldString: String) -> String { 
     var newString = oldString
-    for dateFormat in KMHeaderFooterManager.defaultManager.dateFormatArray {
+    for dateFormat in KMHeaderFooterManager.defaultManager().dateFormatArray {
         if newString.contains(dateFormat) {
             let formatString = dateFormat.replacingOccurrences(of: "m", with: "M")
             let replace = "<<\(dateFormat)>>"

+ 2 - 2
PDF Office/PDF Master/Class/PDFTools/AddHeaderFooter/New/KMHeaderFooterWindowController.swift

@@ -7,12 +7,12 @@
 
 import Cocoa
 
-typealias KMHeaderFooterWindowControllerOperateCallBack = (_ controller: NSWindowController, _ headerFooter: KMHeaderFooterModel) -> ()
+typealias KMHeaderFooterWindowControllerOperateCallBack = (_ controller: NSWindowController, _ headerFooter: KMHeaderFooterObject) -> ()
 
 class KMHeaderFooterWindowController: KMBaseWindowController {
     @IBOutlet weak var headerFooterView: KMHeaderFooterView!
 
-    var headerFooterObj: KMHeaderFooterModel = KMHeaderFooterModel()
+    var headerFooterObj: KMHeaderFooterObject = KMHeaderFooterObject()
     var type: KMBatchModifyTemplateType = .Use
     var operateCallBack: KMHeaderFooterWindowControllerOperateCallBack?
     

+ 29 - 29
PDF Office/PDF Master/Class/PDFTools/AddHeaderFooter/New/View/KMHeaderFooterView.swift

@@ -87,7 +87,7 @@ func convertDateFormat(_ oldString: String) -> String {
     return newString
 }
 
-typealias KMHeaderFooterViewDoneAction = ( _ model: KMHeaderFooterModel) -> ()
+typealias KMHeaderFooterViewDoneAction = ( _ model: KMHeaderFooterObject) -> ()
 typealias KMHeaderFooterViewCancelAction = (_ view: KMHeaderFooterView) -> Void
 
 class KMHeaderFooterView: KMBaseXibView, NSTextViewDelegate, NSComboBoxDelegate {
@@ -186,11 +186,11 @@ class KMHeaderFooterView: KMBaseXibView, NSTextViewDelegate, NSComboBoxDelegate
             self.reloadData()
         }
     }
-    var headerFooterObj: KMHeaderFooterModel = KMHeaderFooterModel()
-    var originalHeaderFooterObj: KMHeaderFooterModel = KMHeaderFooterModel()
+    var headerFooterObj: KMHeaderFooterObject = KMHeaderFooterObject()
+    var originalHeaderFooterObj: KMHeaderFooterObject = KMHeaderFooterObject()
     var dateFormatArray: [Any] {
         get {
-            return KMHeaderFooterManager.defaultManager.dateFormatArray
+            return KMHeaderFooterManager.defaultManager().dateFormatArray
         }
     }
     
@@ -198,9 +198,9 @@ class KMHeaderFooterView: KMBaseXibView, NSTextViewDelegate, NSComboBoxDelegate
     var isBates: Bool = false {
         didSet {
             if (self.isBates) {
-                headerFooterObj.id = KMHeaderFooterManager.defaultManager.fetchBatesAvailableName()
+                headerFooterObj.id = KMHeaderFooterManager.defaultManager().fetchBatesAvailableName()
             } else {
-                headerFooterObj.id = KMHeaderFooterManager.defaultManager.fetchHeaderFooterAvailableName()
+                headerFooterObj.id = KMHeaderFooterManager.defaultManager().fetchHeaderFooterAvailableName()
             }
             headerFooterObj.isBates = self.isBates
             self.reloadData()
@@ -216,12 +216,12 @@ class KMHeaderFooterView: KMBaseXibView, NSTextViewDelegate, NSComboBoxDelegate
         NotificationCenter.default.removeObserver(self)
     }
     
-    convenience init?(baseFile filePath: String, headerFooter object: KMHeaderFooterModel, password: String, type: KMBatchModifyTemplateType) {
+    convenience init?(baseFile filePath: String, headerFooter object: KMHeaderFooterObject, password: String, type: KMBatchModifyTemplateType) {
         self.init()
         
         self.filePath = filePath
         self.password = password
-        self.headerFooterObj = object.copy() as! KMHeaderFooterModel
+        self.headerFooterObj = object.copy() as! KMHeaderFooterObject
         self.originalHeaderFooterObj = object
         self.initialID = object.id
 
@@ -746,10 +746,10 @@ class KMHeaderFooterView: KMBaseXibView, NSTextViewDelegate, NSComboBoxDelegate
 
             if self.isBates {
                 if let bates = document?.bates() {
-                    bates.margin = NSEdgeInsets(top: max(self.headerFooterObj.topMargin - size.height, 0),
-                                                left: self.headerFooterObj.leftMargin,
-                                                bottom: max(self.headerFooterObj.bottomMargin - size.height, 0),
-                                                right: self.headerFooterObj.rightMargin)
+                    bates.margin = NSEdgeInsets(top: max(CGFloat(self.headerFooterObj.topMargin) - size.height, 0),
+                                                left: CGFloat(self.headerFooterObj.leftMargin),
+                                                bottom: max(CGFloat(self.headerFooterObj.bottomMargin) - size.height, 0),
+                                                right: CGFloat(self.headerFooterObj.rightMargin))
                     let pagesString = self.headerFooterObj.pageRangeString
                     if  pagesString.count != 0 {
                         bates.pageString = pagesString
@@ -777,10 +777,10 @@ class KMHeaderFooterView: KMBaseXibView, NSTextViewDelegate, NSComboBoxDelegate
             } else {
                 print(document?.headerFooter())
                 if let headerFooter = document?.headerFooter() {
-                    headerFooter.margin = NSEdgeInsets(top: max(self.headerFooterObj.topMargin - size.height, 0),
-                                                       left: self.headerFooterObj.leftMargin,
-                                                       bottom: max(self.headerFooterObj.bottomMargin - size.height, 0),
-                                                       right: self.headerFooterObj.rightMargin)
+                    headerFooter.margin = NSEdgeInsets(top: max(CGFloat(self.headerFooterObj.topMargin) - size.height, 0),
+                                                       left: CGFloat(self.headerFooterObj.leftMargin),
+                                                       bottom: max(CGFloat(self.headerFooterObj.bottomMargin) - size.height, 0),
+                                                       right: CGFloat(self.headerFooterObj.rightMargin))
 
                     let pagesString = self.headerFooterObj.pageRangeString
                     if  pagesString.count != 0 {
@@ -1038,49 +1038,49 @@ extension KMHeaderFooterView {
 
     @IBAction func topMarginTextFiedEndEdit(_ sender: NSTextField) {
         topMarginStepper.integerValue = sender.integerValue
-        headerFooterObj.topMargin = CGFloat(sender.integerValue)
+        headerFooterObj.topMargin = sender.integerValue
         self.updatePDFView()
     }
 
     @IBAction func topMarginStepperAction(_ sender: NSStepper) {
         topMargintextField.integerValue = sender.integerValue
-        headerFooterObj.topMargin = CGFloat(sender.integerValue)
+        headerFooterObj.topMargin = sender.integerValue
         self.updatePDFView()
     }
 
     @IBAction func bottomMarginTextFieldEndEdit(_ sender: NSTextField) {
         bottomMarginStepper.integerValue = sender.integerValue
-        headerFooterObj.bottomMargin = CGFloat(sender.integerValue)
+        headerFooterObj.bottomMargin = sender.integerValue
         self.updatePDFView()
     }
 
     @IBAction func bottomMarginStepperAction(_ sender: NSStepper) {
         bottomMarginTextField.integerValue = sender.integerValue
-        headerFooterObj.bottomMargin = CGFloat(sender.integerValue)
+        headerFooterObj.bottomMargin = sender.integerValue
         self.updatePDFView()
     }
 
     @IBAction func leftMarginTextFieldEndEdit(_ sender: NSTextField) {
         leftMarginStepper.integerValue = sender.integerValue
-        headerFooterObj.leftMargin = CGFloat(sender.integerValue)
+        headerFooterObj.leftMargin = sender.integerValue
         self.updatePDFView()
     }
 
     @IBAction func leftMarginStepperAction(_ sender: NSStepper) {
         leftMarginTextField.integerValue = sender.integerValue
-        headerFooterObj.leftMargin = CGFloat(sender.integerValue)
+        headerFooterObj.leftMargin = sender.integerValue
         self.updatePDFView()
     }
 
     @IBAction func rightMarginTextFieldEndEdit(_ sender: NSTextField) {
         rightMarginStepper.integerValue = sender.integerValue
-        headerFooterObj.rightMargin = CGFloat(sender.integerValue)
+        headerFooterObj.rightMargin = sender.integerValue
         self.updatePDFView()
     }
 
     @IBAction func rightMarginStepperAction(_ sender: NSStepper) {
         rightMarginTextField.integerValue = sender.integerValue
-        headerFooterObj.rightMargin = CGFloat(sender.integerValue)
+        headerFooterObj.rightMargin = sender.integerValue
         self.updatePDFView()
     }
 
@@ -1118,7 +1118,7 @@ extension KMHeaderFooterView {
             }
             
             headerFooterObj.id = templateNameTextField.stringValue
-            KMHeaderFooterManager.defaultManager.addTemplate(headerFooterObj)
+            KMHeaderFooterManager.defaultManager().addHeaderFooter(headerFooterObj)
         }
         
         if let operateCallBack = operateCallBack {
@@ -1182,7 +1182,7 @@ extension KMHeaderFooterView {
                 } else {
                     headerFooterObj.id = templateNameTextField.stringValue
                 }
-                KMHeaderFooterManager.defaultManager.addTemplate(headerFooterObj)
+                KMHeaderFooterManager.defaultManager().addHeaderFooter(headerFooterObj)
             }
             if let operateCallBack = operateCallBack {
                 operateCallBack(headerFooterObj)
@@ -1195,8 +1195,8 @@ extension KMHeaderFooterView {
                     headerFooterObj.id = templateNameTextField.stringValue
                 }
                 
-                originalHeaderFooterObj = headerFooterObj.copy() as! KMHeaderFooterModel
-                KMHeaderFooterManager.defaultManager.store()
+                originalHeaderFooterObj = headerFooterObj.copy() as! KMHeaderFooterObject
+                KMHeaderFooterManager.defaultManager().store()
             }
             if let operateCallBack = operateCallBack {
                 operateCallBack(originalHeaderFooterObj)
@@ -1225,7 +1225,7 @@ extension KMHeaderFooterView {
                         } else {
                             self.headerFooterObj.id = self.templateNameTextField.stringValue
                         }
-                        KMHeaderFooterManager.defaultManager.addTemplate(self.headerFooterObj)
+                        KMHeaderFooterManager.defaultManager().addHeaderFooter(self.headerFooterObj)
                         NotificationCenter.default.post(name: NSNotification.Name("KMBatchOperateHeaderFootersNotification"), object: self)
                     }
                 }

+ 38 - 38
PDF Office/PDF Master/Class/PDFTools/AddHeaderFooter/VC/KMBatchOperateAddHeaderFooterViewController.swift

@@ -29,7 +29,7 @@ class KMBatchOperateAddHeaderFooterViewController: KMBatchOperateBaseViewControl
     
     @IBOutlet var lineView: NSView!
     var haveFiles = false
-    var currentObject: KMHeaderFooterModel?
+    var currentObject: KMHeaderFooterObject?
     
     override var interfaceStatus: KMBatchOperateInterfaceStatus?{
         set{
@@ -244,12 +244,12 @@ class KMBatchOperateAddHeaderFooterViewController: KMBatchOperateBaseViewControl
     }
     func deleteAll() {
         if self.isBates {
-            for waterMark in KMHeaderFooterManager.defaultManager.onlyBatesObjects() {
-                KMHeaderFooterManager.defaultManager.removeHeaderFooter(waterMark)
+            for waterMark in KMHeaderFooterManager.defaultManager().onlyBatesObjects {
+                KMHeaderFooterManager.defaultManager().removeHeaderFooter(waterMark)
             }
         } else {
-            for waterMark in KMHeaderFooterManager.defaultManager.onlyHeaderFooterObjects() {
-                KMHeaderFooterManager.defaultManager.removeHeaderFooter(waterMark)
+            for waterMark in KMHeaderFooterManager.defaultManager().onlyHeaderFooterObjects {
+                KMHeaderFooterManager.defaultManager().removeHeaderFooter(waterMark)
             }
         }
         loadData()
@@ -259,15 +259,15 @@ class KMBatchOperateAddHeaderFooterViewController: KMBatchOperateBaseViewControl
     func reloadTable() {
         self.tableView.noteNumberOfRowsChanged()
         var count = 0
-        var array: [KMHeaderFooterModel] = []
+        var array: [KMHeaderFooterObject] = []
         if self.isBates {
-            count = KMHeaderFooterManager.defaultManager.onlyBatesObjects().count
-            array = KMHeaderFooterManager.defaultManager.onlyBatesObjects()
+            count = KMHeaderFooterManager.defaultManager().onlyBatesObjects.count
+            array = KMHeaderFooterManager.defaultManager().onlyBatesObjects
         } else {
-            count = KMHeaderFooterManager.defaultManager.onlyHeaderFooterObjects().count
-            array = KMHeaderFooterManager.defaultManager.onlyHeaderFooterObjects()
+            count = KMHeaderFooterManager.defaultManager().onlyHeaderFooterObjects.count
+            array = KMHeaderFooterManager.defaultManager().onlyHeaderFooterObjects
         }
-        if array.contains(self.currentObject ?? KMHeaderFooterModel()) {
+        if array.contains(self.currentObject ?? KMHeaderFooterObject()) {
             let row = array.firstIndex(of: self.currentObject!)!
             let indexSet = IndexSet(integer: row)
             self.tableView.selectRowIndexes(indexSet, byExtendingSelection: false)
@@ -333,16 +333,16 @@ class KMBatchOperateAddHeaderFooterViewController: KMBatchOperateBaseViewControl
         }
         if (self.onlyManagerTemplate) {
             if (sender.tag == 1) {
-                var headFooter: KMHeaderFooterModel?
+                var headFooter: KMHeaderFooterObject?
                 let row = self.tableView.selectedRow
                 if (row == -1) {
                     NSSound.beep()
                     return
                 } else {
                     if (self.isBates) {
-                        headFooter = KMHeaderFooterManager.defaultManager.onlyBatesObjects()[row]
+                        headFooter = KMHeaderFooterManager.defaultManager().onlyBatesObjects[row]
                     } else {
-                        headFooter = KMHeaderFooterManager.defaultManager.onlyHeaderFooterObjects()[row]
+                        headFooter = KMHeaderFooterManager.defaultManager().onlyHeaderFooterObjects[row]
                     }
                 }
 
@@ -400,16 +400,16 @@ class KMBatchOperateAddHeaderFooterViewController: KMBatchOperateBaseViewControl
                     NSSound.beep()
                     return;
                 }
-                var headFooter: KMHeaderFooterModel?
+                var headFooter: KMHeaderFooterObject?
                 let row = self.tableView.selectedRow
                 if (row == -1 || self.files?.count ?? 0 < 1) {
                     NSSound.beep()
                     return;
                 } else {
                     if (self.isBates) {
-                        headFooter = KMHeaderFooterManager.defaultManager.onlyBatesObjects()[row]
+                        headFooter = KMHeaderFooterManager.defaultManager().onlyBatesObjects[row]
                     } else {
-                        headFooter = KMHeaderFooterManager.defaultManager.onlyHeaderFooterObjects()[row]
+                        headFooter = KMHeaderFooterManager.defaultManager().onlyHeaderFooterObjects[row]
                     }
                 }
                 
@@ -448,15 +448,15 @@ class KMBatchOperateAddHeaderFooterViewController: KMBatchOperateBaseViewControl
                 for fileURL in openPanel.urls {
                     self.choosePath = fileURL.path
                     if self.isBates {
-                        self.beginAddBates(obj as! KMHeaderFooterModel)
+                        self.beginAddBates(obj as! KMHeaderFooterObject)
                     } else {
-                        self.beginAddHeaderFooter(obj as! KMHeaderFooterModel)
+                        self.beginAddHeaderFooter(obj as! KMHeaderFooterObject)
                     }
                 }
             }
         }
     }
-    func beginAddBates(_ bates: KMHeaderFooterModel) {
+    func beginAddBates(_ bates: KMHeaderFooterObject) {
         hiddenWindowCloseButtonIfNeeded()
         successFilePathURLArray?.removeAll()
         for i in 0..<(files?.count ?? 0) {
@@ -475,7 +475,7 @@ class KMBatchOperateAddHeaderFooterViewController: KMBatchOperateBaseViewControl
             interfaceStatus = .Processing
         }
     }
-    func beginAddHeaderFooter(_ headerFooter: KMHeaderFooterModel) {
+    func beginAddHeaderFooter(_ headerFooter: KMHeaderFooterObject) {
         hiddenWindowCloseButtonIfNeeded()
         successFilePathURLArray?.removeAll()
         for i in 0..<(files?.count ?? 0) {
@@ -494,7 +494,7 @@ class KMBatchOperateAddHeaderFooterViewController: KMBatchOperateBaseViewControl
             interfaceStatus = .Processing
         }
     }
-    func modify(obj: KMHeaderFooterModel) {
+    func modify(obj: KMHeaderFooterObject) {
 //        let windowController = self.view.window?.windowController
 //        var filePath: String? = nil
 //        var password: String? = nil
@@ -541,8 +541,8 @@ class KMBatchOperateAddHeaderFooterViewController: KMBatchOperateBaseViewControl
         self.km_beginSheet(windowC: windowController)
         
     }
-    func delete(obj: KMHeaderFooterModel) {
-        KMHeaderFooterManager.defaultManager.removeHeaderFooter(obj)
+    func delete(obj: KMHeaderFooterObject) {
+        KMHeaderFooterManager.defaultManager().removeHeaderFooter(obj)
         loadData()
         reloadTable()
         postNotification()
@@ -550,23 +550,23 @@ class KMBatchOperateAddHeaderFooterViewController: KMBatchOperateBaseViewControl
     func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
         let action = menuItem.action
         if action == #selector(buttonItemClick_CleanAll(_:)) {
-            if (self.isBates && KMHeaderFooterManager.defaultManager.onlyBatesObjects().count < 1) || (!self.isBates && KMHeaderFooterManager.defaultManager.onlyHeaderFooterObjects().count < 1){
+            if (self.isBates && KMHeaderFooterManager.defaultManager().onlyBatesObjects.count < 1) || (!self.isBates && KMHeaderFooterManager.defaultManager().onlyHeaderFooterObjects.count < 1){
                 return false
             }
             return true
         }
         return true
     }
-    func headerFooterInterfaceSelectHeaderFooter(headerFooter: KMHeaderFooterModel) {
+    func headerFooterInterfaceSelectHeaderFooter(headerFooter: KMHeaderFooterObject) {
         self.tableView.reloadData()
-        if let index = KMHeaderFooterManager.defaultManager.onlyHeaderFooterObjects().firstIndex(of: headerFooter) {
+        if let index = KMHeaderFooterManager.defaultManager().onlyHeaderFooterObjects.firstIndex(of: headerFooter) {
             let indexSet = IndexSet(integer: index)
             self.tableView.selectRowIndexes(indexSet, byExtendingSelection: false)
         }
     }
-    func batesInterfaceSelectBates(headerFooter: KMHeaderFooterModel) {
+    func batesInterfaceSelectBates(headerFooter: KMHeaderFooterObject) {
         self.tableView.reloadData()
-        if let index = KMHeaderFooterManager.defaultManager.onlyBatesObjects().firstIndex(of: headerFooter) {
+        if let index = KMHeaderFooterManager.defaultManager().onlyBatesObjects.firstIndex(of: headerFooter) {
             let indexSet = IndexSet(integer: index)
             self.tableView.selectRowIndexes(indexSet, byExtendingSelection: false)
         }
@@ -575,19 +575,19 @@ class KMBatchOperateAddHeaderFooterViewController: KMBatchOperateBaseViewControl
     func numberOfRows(in tableView: NSTableView) -> Int {
         var count = 0
         if self.isBates {
-            count = KMHeaderFooterManager.defaultManager.onlyBatesObjects().count
+            count = KMHeaderFooterManager.defaultManager().onlyBatesObjects.count
         } else {
-            count = KMHeaderFooterManager.defaultManager.onlyHeaderFooterObjects().count
+            count = KMHeaderFooterManager.defaultManager().onlyHeaderFooterObjects.count
         }
         self.blankView.isHidden = count != 0
         return count
     }
     func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
-        var obj: KMHeaderFooterModel? = nil
+        var obj: KMHeaderFooterObject? = nil
         if self.isBates {
-            obj = KMHeaderFooterManager.defaultManager.onlyBatesObjects()[row]
+            obj = KMHeaderFooterManager.defaultManager().onlyBatesObjects[row]
         } else {
-            obj = KMHeaderFooterManager.defaultManager.onlyHeaderFooterObjects()[row]
+            obj = KMHeaderFooterManager.defaultManager().onlyHeaderFooterObjects[row]
         }
         guard let cellView = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "mainCell"), owner: self) as? KMHeaderFooterTableCellView else {
             return nil
@@ -612,9 +612,9 @@ class KMBatchOperateAddHeaderFooterViewController: KMBatchOperateBaseViewControl
     }
     func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat { 
         if self.isBates {
-            return KMHeaderFooterManager.defaultManager.onlyBatesObjects()[row].cellHeight
+            return KMHeaderFooterManager.defaultManager().onlyBatesObjects[row].cellHeight
         } else {
-            return KMHeaderFooterManager.defaultManager.onlyHeaderFooterObjects()[row].cellHeight
+            return KMHeaderFooterManager.defaultManager().onlyHeaderFooterObjects[row].cellHeight
         }
     }
     func tableView(_ tableView: NSTableView, shouldSelect tableColumn: NSTableColumn?) -> Bool {
@@ -628,7 +628,7 @@ class KMBatchOperateAddHeaderFooterViewController: KMBatchOperateBaseViewControl
         updateActionButtonbackgroundColor()
         if row == -1 { return }
         if self.isBates {
-            let bates = KMHeaderFooterManager.defaultManager.onlyBatesObjects()[row]
+            let bates = KMHeaderFooterManager.defaultManager().onlyBatesObjects[row]
             self.currentObject = bates
             for i in 0..<(self.files?.count ?? 0) {
                 let file = self.files?[i]
@@ -644,7 +644,7 @@ class KMBatchOperateAddHeaderFooterViewController: KMBatchOperateBaseViewControl
                 }
             }
         } else {
-            let headerFooter = KMHeaderFooterManager.defaultManager.onlyHeaderFooterObjects()[row]
+            let headerFooter = KMHeaderFooterManager.defaultManager().onlyHeaderFooterObjects[row]
             self.currentObject = headerFooter
             for i in 0..<(self.files?.count ?? 0) {
                 let file = self.files?[i]

+ 1 - 1
PDF Office/PDF Master/Class/PDFTools/AddHeaderFooter/View/KMHeaderFooterTableCellView.swift

@@ -78,7 +78,7 @@ class KMHeaderFooterTableCellView: NSTableCellView {
         var appendString = string
         return appendString
     }
-    func updateInterface(_ obj: KMHeaderFooterModel) { 
+    func updateInterface(_ obj: KMHeaderFooterObject) { 
         var arr = NSMutableArray()
         if obj.topLeftString.count > 0 {
             arr.add(appendBaseString(NSLocalizedString("Left Header Text", comment: ""), withString: appendBaseString(obj.topLeftString)))

+ 8 - 8
PDF Office/PDF Master/Class/PDFTools/AddHeaderFooter/WindowComtroller/KMHeaderFooterManagerWindowController.swift

@@ -7,7 +7,7 @@
 
 import Cocoa
 
-typealias HeaderFooterOperateCallBack = (_ obj: KMHeaderFooterModel) -> ()
+typealias HeaderFooterOperateCallBack = (_ obj: KMHeaderFooterObject) -> ()
 
 class KMHeaderFooterManagerWindowController: NSWindowController{
     var operateCallBack: HeaderFooterOperateCallBack?
@@ -21,20 +21,20 @@ class KMHeaderFooterManagerWindowController: NSWindowController{
     var password: String = ""
     var type:KMBatchModifyTemplateType = .Add
     var pdfdocument: CPDFDocument?
-    lazy var headerFooterObj: KMHeaderFooterModel? = {
-        let obj = KMHeaderFooterModel()
+    lazy var headerFooterObj: KMHeaderFooterObject? = {
+        let obj = KMHeaderFooterObject()
         obj.isBates = self.isBates
         if self.isBates {
-            obj.id = KMHeaderFooterManager.defaultManager.fetchBatesAvailableName()
+            obj.id = KMHeaderFooterManager.defaultManager().fetchBatesAvailableName()
         }else {
-            obj.id = KMHeaderFooterManager.defaultManager.fetchHeaderFooterAvailableName()
+            obj.id = KMHeaderFooterManager.defaultManager().fetchHeaderFooterAvailableName()
         }
         initialID = obj.id
         return obj
     }()
-    var originalHeaderFooterObj: KMHeaderFooterModel?
+    var originalHeaderFooterObj: KMHeaderFooterObject?
     lazy var dateFormatArray: Array<Any> = {
-        let arr = KMHeaderFooterManager.defaultManager.dateFormatArray
+        let arr = KMHeaderFooterManager.defaultManager().dateFormatArray
         return arr
     }()
     var initialID: String?
@@ -121,7 +121,7 @@ class KMHeaderFooterManagerWindowController: NSWindowController{
         DistributedNotificationCenter.default().removeObserver(self)
     }
     
-    convenience init(baseFile:String, obj:KMHeaderFooterModel, password:String, type:KMBatchModifyTemplateType) {
+    convenience init(baseFile:String, obj:KMHeaderFooterObject, password:String, type:KMBatchModifyTemplateType) {
         self.init(windowNibName: "KMHeaderFooterManagerWindowController")
         self.filePath = baseFile
         self.password = password

+ 1 - 1
PDF Office/PDF Master/Class/PDFTools/Bates/Controller/KMBatesPreviewController.swift

@@ -151,7 +151,7 @@ class KMBatesPreviewController: KMWatermarkAdjectivePreViewBaseController {
             style.lineBreakMode = .byCharWrapping
             let size: NSSize = "text".boundingRect(with: NSSize(width: 1000, height: 1000), options: NSString.DrawingOptions(rawValue: 3), attributes: [NSAttributedString.Key.font : font, NSAttributedString.Key.paragraphStyle : style]).size
             
-            property?.margin = NSEdgeInsetsMake(max(model.topMargin-size.height, 0), model.leftMargin, max(model.bottomMargin-size.height, 0), model.rightMargin)
+            property?.margin = NSEdgeInsetsMake(max(CGFloat(model.topMargin)-size.height, 0), CGFloat(model.leftMargin), max(CGFloat(model.bottomMargin)-size.height, 0), CGFloat(model.rightMargin))
             
             let strings = [model.topLeftString, model.topCenterString, model.topRightString, model.bottomLeftString, model.bottomCenterString, model.bottomRightString]
             var count: Int = 0

+ 7 - 7
PDF Office/PDF Master/Class/PDFTools/Bates/Controller/KMBatesPropertyInfoController.swift

@@ -110,19 +110,19 @@ class KMBatesPropertyInfoController: NSViewController {
         marginView.frame = self.marginBox.contentView!.bounds
         marginView.autoresizingMask = NSView.AutoresizingMask(rawValue: 18)
         self.marginBox.contentView?.addSubview(marginView)
-        marginView.itemClick = { [weak self] (index: Int, value: Any) in
+        marginView.itemClick = { [unowned self] (index: Int, value: Any) in
             if (index == 1) { /// top
-                self!.model.topMargin = value as! Double
+                self.model.topMargin = value as! Int
             } else if (index == 2) { /// bottom
-                self!.model.bottomMargin = value as! Double
+                self.model.bottomMargin = value as! Int
             } else if (index == 3) { /// left
-                self!.model.leftMargin = value as! Double
+                self.model.leftMargin = value as! Int
             } else if (index == 4) { /// right
-                self!.model.rightMargin = value as! Double
+                self.model.rightMargin = value as! Int
             }
             
-            if (self!.delegate != nil) {
-                self!.delegate.propertyInfoDidChange(model: self!.model)
+            if (self.delegate != nil) {
+                self.delegate.propertyInfoDidChange(model: self.model)
             }
         }
         

+ 4 - 0
PDF Office/PDF Master/Class/PDFTools/Bates/Model/KMBatesModel.swift

@@ -19,6 +19,10 @@ import Cocoa
         self.name = "Bates Number"
     }
     
+    required init?(coder: NSCoder) {
+        fatalError("init(coder:) has not been implemented")
+    }
+    
     override func copy() -> Any {
         let model = KMBatesModel()
         model.name = self.name

+ 4 - 4
PDF Office/PDF Master/Class/PDFTools/Bates/Tools/KMBatesManager.swift

@@ -231,10 +231,10 @@ class KMBatesManager: NSObject {
         model.textColor = .color(red: dict["red"] as! CGFloat, green: dict["green"] as! CGFloat, blue: dict["blue"] as! CGFloat, alpha: dict["alpha"] as! CGFloat)
 
         /// 页边距
-        model.leftMargin = dict["leftMargin"] as! CGFloat
-        model.rightMargin = dict["rightMargin"] as! CGFloat
-        model.bottomMargin = dict["bottomMargin"] as! CGFloat
-        model.topMargin = dict["topMargin"] as! CGFloat
+        model.leftMargin = dict["leftMargin"] as! Int
+        model.rightMargin = dict["rightMargin"] as! Int
+        model.bottomMargin = dict["bottomMargin"] as! Int
+        model.topMargin = dict["topMargin"] as! Int
         
         /// 内容
         model.topLeftString = dict["topLeftString"] as! String

+ 97 - 5
PDF Office/PDF Master/Class/PDFTools/HeaderFooter/Base/KMHeaderFooterAdjectiveModel.swift

@@ -7,11 +7,11 @@
 
 import Cocoa
 
-@objcMembers class KMHeaderFooterAdjectiveModel: KMWatermarkAdjectiveBaseModel {
-    var leftMargin: CGFloat = 30.0
-    var rightMargin: CGFloat = 30.0
-    var bottomMargin: CGFloat = 30.0
-    var topMargin: CGFloat = 30.0
+@objcMembers class KMHeaderFooterAdjectiveModel: KMWatermarkAdjectiveBaseModel , NSCoding {
+    var leftMargin: Int = 30
+    var rightMargin: Int = 30
+    var bottomMargin: Int = 30
+    var topMargin: Int = 30
     var topLeftString: String = ""
     var topCenterString: String = ""
     var topRightString: String = ""
@@ -69,4 +69,96 @@ import Cocoa
         self.textFont = .font(name: "Helvetica", size: 10)
         self.textColor = .color(red: 0.0, green: 0.0, blue: 0.0, alpha: 1.0)
     }
+    
+    required init?(coder: NSCoder) {
+        super.init()
+        pageRangeType = KMWatermarkeModelPageRangeType.init(rawValue: coder.decodeInteger(forKey: "type"))!
+        leftMargin = coder.decodeInteger(forKey: "leftMargin")
+        rightMargin = coder.decodeInteger(forKey: "rightMargin")
+        bottomMargin = coder.decodeInteger(forKey: "bottomMargin")
+        topMargin = coder.decodeInteger(forKey: "topMargin")
+        topLeftString = coder.decodeObject(forKey: "topLeftString") as? String ?? ""
+        topCenterString = coder.decodeObject(forKey: "topCenterString") as? String ?? ""
+        topRightString = coder.decodeObject(forKey: "topRightString") as? String ?? ""
+        bottomLeftString = coder.decodeObject(forKey: "bottomLeftString") as? String ?? ""
+        bottomCenterString = coder.decodeObject(forKey: "bottomCenterString") as? String ?? ""
+        bottomRightString = coder.decodeObject(forKey: "bottomRightString") as? String ?? ""
+        startString = coder.decodeObject(forKey: "startString") as? String ?? ""
+        fontSize = coder.decodeFloat(forKey: "fontSize")
+        tempTextColor = coder.decodeObject(forKey: "textColor") as? NSColor ?? NSColor.black
+        id = coder.decodeObject(forKey: "headerFooterID") as? String ?? ""
+        pageCount = coder.decodeInteger(forKey: "pageChoice")
+        pageRangeString = coder.decodeObject(forKey: "pagesString") as? String ?? ""
+//        hasHeader = coder.decodeBool(forKey: "hasHeader")
+//        hasFooter = coder.decodeBool(forKey: "hasFooter")
+//        cellHeight = coder.decodeFloat(forKey: "cellHeight")
+//        dateFormatString = coder.decodeObject(forKey: "dateFormatString") as? String ?? "m/d"
+//        pageFormatString = coder.decodeObject(forKey: "pageFormatString") as? String ?? "1"
+//        isBates = coder.decodeBool(forKey: "isBates")
+//        batesPrefixString = coder.decodeObject(forKey: "batesPrefixString") as? String ?? ""
+//        batesSuffixString = coder.decodeObject(forKey: "batesSuffixString") as? String ?? ""
+//        batesDigits = coder.decodeInteger(forKey: "batesDigits")
+    }
+
+    func encode(with coder: NSCoder) {
+        coder.encode(pageRangeType.rawValue, forKey: "type")
+        coder.encode(leftMargin, forKey: "leftMargin")
+        coder.encode(rightMargin, forKey: "rightMargin")
+        coder.encode(bottomMargin, forKey: "bottomMargin")
+        coder.encode(topMargin, forKey: "topMargin")
+        coder.encode(topLeftString, forKey: "topLeftString")
+        coder.encode(topCenterString, forKey: "topCenterString")
+        coder.encode(topRightString, forKey: "topRightString")
+        coder.encode(bottomLeftString, forKey: "bottomLeftString")
+        coder.encode(bottomCenterString, forKey: "bottomCenterString")
+        coder.encode(bottomRightString, forKey: "bottomRightString")
+        coder.encode(startString, forKey: "startString")
+        coder.encode(fontSize, forKey: "fontSize")
+        coder.encode(tempTextColor, forKey: "textColor")
+//        coder.encode(hasHeader, forKey: "hasHeader")
+//        coder.encode(hasFooter, forKey: "hasFooter")
+//        coder.encode(cellHeight, forKey: "cellHeight")
+        coder.encode(id, forKey: "headerFooterID")
+        coder.encode(pageCount, forKey: "pageChoice")
+        coder.encode(pageRangeString, forKey: "pagesString")
+        
+//        coder.encode(dateFormatString, forKey: "dateFormatString")
+//        coder.encode(pageFormatString, forKey: "pageFormatString")
+//        coder.encode(isBates, forKey: "isBates")
+//        coder.encode(batesPrefixString, forKey: "batesPrefixString")
+//        coder.encode(batesSuffixString, forKey: "batesSuffixString")
+//        coder.encode(batesDigits, forKey: "batesDigits")
+    }
+
+//    func copy(with zone: NSZone? = nil) -> Any {
+//        let obj = KMHeaderFooterObject()
+//        obj.pageRangeType = pageRangeType
+//        obj.leftMargin = leftMargin
+//        obj.rightMargin = rightMargin
+//        obj.bottomMargin = bottomMargin
+//        obj.topMargin = topMargin
+//        obj.topLeftString = topLeftString
+//        obj.topCenterString = topCenterString
+//        obj.topRightString = topRightString
+//        obj.bottomLeftString = bottomLeftString
+//        obj.bottomCenterString = bottomCenterString
+//        obj.bottomRightString = bottomRightString
+//        obj.startString = startString
+//        obj.fontSize = fontSize
+//        obj.textColor = textColor
+////        obj.hasHeader = hasHeader
+////        obj.hasFooter = hasFooter
+////        obj.cellHeight = cellHeight
+//        obj.id = id
+//        obj.pageCount = pageCount
+//        obj.pageRangeString = pageRangeString
+//        
+//        obj.dateFormatString = dateFormatString
+//        obj.pageFormatString = pageFormatString
+//        obj.isBates = isBates
+//        obj.batesPrefixString = batesPrefixString
+//        obj.batesSuffixString = batesSuffixString
+//        obj.batesDigits = batesDigits
+//        return obj
+//    }
 }

+ 4 - 4
PDF Office/PDF Master/Class/PDFTools/HeaderFooter/Controller/KMCreateHeaderFooterController.swift

@@ -7,7 +7,7 @@
 
 import Cocoa
 
-typealias KMCreateHeaderFooterModelDidChange = (_ model: KMHeaderFooterModel) -> ()
+typealias KMCreateHeaderFooterModelDidChange = (_ model: KMHeaderFooterObject) -> ()
 class KMCreateHeaderFooterController: KMWatermarkAdjectivePropertyBaseController {
     
     /// 是否是编辑类型
@@ -21,7 +21,7 @@ class KMCreateHeaderFooterController: KMWatermarkAdjectivePropertyBaseController
         super.viewWillAppear()
         
         let controller: KMHeaderFooterPropertyInfoController = childViewController[0] as! KMHeaderFooterPropertyInfoController
-        controller.model = self.model as! KMHeaderFooterModel
+        controller.model = self.model as! KMHeaderFooterObject
     }
 
     override func viewDidLoad() {
@@ -57,7 +57,7 @@ class KMCreateHeaderFooterController: KMWatermarkAdjectivePropertyBaseController
             return
         }
         
-        (childViewController[0] as! KMHeaderFooterPropertyInfoController).model = self.flagModel?.copy() as! KMHeaderFooterModel
+        (childViewController[0] as! KMHeaderFooterPropertyInfoController).model = self.flagModel?.copy() as! KMHeaderFooterObject
     }
 }
 
@@ -69,6 +69,6 @@ extension KMCreateHeaderFooterController: KMWatermarkAdjectivePropertyDelegate {
             return
         }
         
-        callback(model as! KMHeaderFooterModel)
+        callback(model as! KMHeaderFooterObject)
     }
 }

+ 5 - 5
PDF Office/PDF Master/Class/PDFTools/HeaderFooter/Controller/KMHeaderFooterPreviewController.swift

@@ -40,7 +40,7 @@ class KMHeaderFooterPreviewController: KMWatermarkAdjectivePreViewBaseController
         controller.view.autoresizingMask = [.width, .height]
         self.right_gotoViewController(viewController: controller)
         controller.modelDidChange = { [weak self] model in
-            if (model == nil || (model as! KMHeaderFooterModel).hasVaild == false) {
+            if (model == nil || (model as! KMHeaderFooterObject).hasVaild == false) {
                 self!.topBarView.isCanApply(can: false)
                 self!.model = nil
             } else {
@@ -99,7 +99,7 @@ class KMHeaderFooterPreviewController: KMWatermarkAdjectivePreViewBaseController
             return
         }
         self.beginLoading()
-        self.addHeaderFooter(model: self.model! as! KMHeaderFooterModel, toPath: self.preView.document.documentURL.path, completion: {
+        self.addHeaderFooter(model: self.model! as! KMHeaderFooterObject, toPath: self.preView.document.documentURL.path, completion: {
             result in
             DispatchQueue.main.async {
                 self.preView.layoutDocumentView()
@@ -120,7 +120,7 @@ class KMHeaderFooterPreviewController: KMWatermarkAdjectivePreViewBaseController
         })
     }
     
-    private func addHeaderFooter(model: KMHeaderFooterModel, toPath: String, completion: @escaping (_ result: Bool) -> ()) {
+    private func addHeaderFooter(model: KMHeaderFooterObject, toPath: String, completion: @escaping (_ result: Bool) -> ()) {
         DispatchQueue.global().async {
             let document: CPDFDocument = self.preView.document
             var property = document.headerFooter()
@@ -142,7 +142,7 @@ class KMHeaderFooterPreviewController: KMWatermarkAdjectivePreViewBaseController
             style.lineBreakMode = .byCharWrapping
             let size: NSSize = "text".boundingRect(with: NSSize(width: 1000, height: 1000), options: NSString.DrawingOptions(rawValue: 3), attributes: [NSAttributedString.Key.font : font, NSAttributedString.Key.paragraphStyle : style]).size
             
-            property?.margin = NSEdgeInsetsMake(max(model.topMargin-size.height, 0), model.leftMargin, max(model.bottomMargin-size.height, 0), model.rightMargin)
+            property?.margin = NSEdgeInsetsMake(max(CGFloat(model.topMargin)-size.height, 0), CGFloat(model.leftMargin), max(CGFloat(model.bottomMargin)-size.height, 0), CGFloat(model.rightMargin))
             
             let strings = KMHeaderFooterPreviewController.parseModel(model: model, pageCount: Int(self.preView.document.pageCount))
             var count: Int = 0
@@ -239,7 +239,7 @@ class KMHeaderFooterPreviewController: KMWatermarkAdjectivePreViewBaseController
         }
     }
     
-    static func parseModel(model: KMHeaderFooterModel, pageCount: Int) -> [String] {
+    static func parseModel(model: KMHeaderFooterObject, pageCount: Int) -> [String] {
         var topLeftString: String = ""
         if (!model.topLeftString.isEmpty) {
             var string = KMWatermarkAdjectiveTools.parsePageFormat(formatString: model.topLeftString, startPage: model.startString, pageCount: "\(pageCount)")

+ 10 - 11
PDF Office/PDF Master/Class/PDFTools/HeaderFooter/Controller/KMHeaderFooterPropertyController.swift

@@ -7,8 +7,8 @@
 
 import Cocoa
 
-typealias KMHeaderFooterPropertyTemplateDidSelected = (_ model: KMHeaderFooterModel,_ isSelected: Bool)->()
-typealias KMHeaderFooterPropertyTemplateMenuItemClick = (_ itemIndex: Int,  _ model: KMHeaderFooterModel)->()
+typealias KMHeaderFooterPropertyTemplateDidSelected = (_ model: KMHeaderFooterObject,_ isSelected: Bool)->()
+typealias KMHeaderFooterPropertyTemplateMenuItemClick = (_ itemIndex: Int,  _ model: KMHeaderFooterObject)->()
 
 /// 页眉页脚 属性控制器
 class KMHeaderFooterPropertyController: KMWatermarkAdjectivePropertyBaseController {
@@ -41,11 +41,11 @@ class KMHeaderFooterPropertyController: KMWatermarkAdjectivePropertyBaseControll
     
     func reloadDatas () {
         let controller: KMHeaderFooterListController = childViewController[0] as! KMHeaderFooterListController
-        controller.initDatas(datas: KMHeaderFooterManager.defaultManager.datas)
+        controller.initDatas(datas: KMHeaderFooterManager.defaultManager().headFooterObjects)
     }
     
-    func deleteTemplateModel(_ templateModel: KMHeaderFooterModel) -> Bool {
-        return KMHeaderFooterManager.defaultManager.deleteTemplate(templateModel)
+    func deleteTemplateModel(_ templateModel: KMHeaderFooterObject) -> Bool {
+        return KMHeaderFooterManager.defaultManager().removeHeaderFooter(templateModel)
     }
     
     func deleteTemplateModel(in controller: KMHeaderFooterListController, index: Int) {
@@ -53,24 +53,23 @@ class KMHeaderFooterPropertyController: KMWatermarkAdjectivePropertyBaseControll
             return
         }
         
-        let templateModel: KMHeaderFooterModel = controller.datas[index] as! KMHeaderFooterModel
+        let templateModel: KMHeaderFooterObject = controller.datas[index] as! KMHeaderFooterObject
         if (deleteTemplateModel(templateModel)) { /// 删除成功,刷新数据
             reloadDatas()
         }
     }
     
     func deleteAllTemplateModel(in controller: KMHeaderFooterListController) {
-        if (KMHeaderFooterManager.defaultManager.deleteAllTemplate()) {
-            reloadDatas()
-        }
+        KMHeaderFooterManager.defaultManager().removeAllHeaderFooter()
+        reloadDatas()
     }
     
-    func findTemplateModel(in controller: KMHeaderFooterListController, index: Int) -> KMHeaderFooterModel? {
+    func findTemplateModel(in controller: KMHeaderFooterListController, index: Int) -> KMHeaderFooterObject? {
         if (index >= controller.datas.count) {
             return nil
         }
         
-        return (controller.datas[index] as! KMHeaderFooterModel)
+        return (controller.datas[index] as! KMHeaderFooterObject)
     }
 }
 

+ 6 - 6
PDF Office/PDF Master/Class/PDFTools/HeaderFooter/Controller/KMHeaderFooterPropertyInfoController.swift

@@ -33,8 +33,8 @@ class KMHeaderFooterPropertyInfoController: NSViewController {
         super.init(nibName: "KMHeaderFooterPropertyInfoController", bundle: nil)
     }
     
-    private var myModel: KMHeaderFooterModel!
-    var model: KMHeaderFooterModel {
+    private var myModel: KMHeaderFooterObject!
+    var model: KMHeaderFooterObject {
         get {
             return myModel
         }
@@ -121,13 +121,13 @@ class KMHeaderFooterPropertyInfoController: NSViewController {
         self.marginBox.contentView?.addSubview(marginView)
         marginView.itemClick = { [weak self] (index: Int, value: Any) in
             if (index == 1) { /// top
-                self!.model.topMargin = value as! Double
+                self!.model.topMargin = value as! Int
             } else if (index == 2) { /// bottom
-                self!.model.bottomMargin = value as! Double
+                self!.model.bottomMargin = value as! Int
             } else if (index == 3) { /// left
-                self!.model.leftMargin = value as! Double
+                self!.model.leftMargin = value as! Int
             } else if (index == 4) { /// right
-                self!.model.rightMargin = value as! Double
+                self!.model.rightMargin = value as! Int
             }
             
             if (self!.delegate != nil) {

+ 11 - 13
PDF Office/PDF Master/Class/PDFTools/HeaderFooter/Controller/KMHeaderFooterPropertyMainController.swift

@@ -46,7 +46,7 @@ class KMHeaderFooterPropertyMainController: KMWatermarkAdjectivePropertyMainCont
     
     override func gotoCreateController() {
         let controller = KMCreateHeaderFooterController()
-        let model: KMHeaderFooterModel = KMHeaderFooterModel()
+        let model: KMHeaderFooterObject = KMHeaderFooterObject()
         model.pageCount = self.pageCount
         controller.model = model
         
@@ -60,7 +60,7 @@ class KMHeaderFooterPropertyMainController: KMWatermarkAdjectivePropertyMainCont
             /// 保存到模板
             let createController: KMCreateHeaderFooterController = self!.currentController as! KMCreateHeaderFooterController
             if (createController.model != nil) {
-                let model: KMHeaderFooterModel = createController.model as! KMHeaderFooterModel
+                let model: KMHeaderFooterObject = createController.model as! KMHeaderFooterObject
                 if (!model.hasVaild) {
                     let alert = NSAlert()
                     alert.alertStyle = .warning
@@ -69,17 +69,15 @@ class KMHeaderFooterPropertyMainController: KMWatermarkAdjectivePropertyMainCont
                     return
                 }
                 
-                let result = KMHeaderFooterManager.defaultManager.addTemplate(createController.model as! KMHeaderFooterModel)
-                if (result) {
-                    guard let callback = self!.modelDidChange else {
-                        return
-                    }
-
-                    self?.model = model
-                    callback(self!.model)
-                    
-                    self!.gotoHomeController(model.id)
+                KMHeaderFooterManager.defaultManager().addHeaderFooter(createController.model as! KMHeaderFooterObject)
+                guard let callback = self!.modelDidChange else {
+                    return
                 }
+
+                self?.model = model
+                callback(self!.model)
+                
+                self!.gotoHomeController(model.id)
             }
         }
         
@@ -108,7 +106,7 @@ class KMHeaderFooterPropertyMainController: KMWatermarkAdjectivePropertyMainCont
             let editController: KMCreateHeaderFooterController = self!.currentController as! KMCreateHeaderFooterController
             if (editController.isEdited) {
                 /// 更新模板
-                let result = KMHeaderFooterManager.defaultManager.updateTemplate(editController.model as! KMHeaderFooterModel)
+                let result = KMHeaderFooterManager.defaultManager().store()
 //                if (result) {
                     
                 self!.gotoHomeController("")

+ 52 - 22
PDF Office/PDF Master/Class/PDFTools/HeaderFooter/Model/KMHeaderFooterModel.swift

@@ -1,5 +1,5 @@
 //
-//  KMHeaderFooterModel.swift
+//  KMHeaderFooterObject.swift
 //  PDF Reader Pro
 //
 //  Created by tangchao on 2022/12/27.
@@ -7,7 +7,8 @@
 
 import Cocoa
 
-class KMHeaderFooterModel: KMHeaderFooterAdjectiveModel {
+class KMHeaderFooterObject: KMHeaderFooterAdjectiveModel, NSCopying {
+    
     
     var dateFormatString: String = KMWatermarkAdjectiveTools.getDateFormats().first!
     var pageFormatString: String = KMWatermarkAdjectiveTools.getPageFormats().first!
@@ -22,28 +23,57 @@ class KMHeaderFooterModel: KMHeaderFooterAdjectiveModel {
         self.name = ""
     }
     
-    override func copy() -> Any {
-        let model = KMHeaderFooterModel()
-        model.name = self.name
-        
-        model.leftMargin = self.leftMargin
-        model.rightMargin = self.rightMargin
-        model.bottomMargin = self.bottomMargin
-        model.topMargin = self.topMargin
-        
-        model.topLeftString = self.topLeftString
-        model.topCenterString = self.topCenterString
-        model.topRightString = self.topRightString
-        
-        model.bottomLeftString = self.bottomLeftString
-        model.bottomCenterString = self.bottomCenterString
-        model.bottomRightString = self.bottomRightString
+    required init?(coder: NSCoder) {
+        super.init(coder: coder)
         
-        model.startString = self.startString
+        dateFormatString = coder.decodeObject(forKey: "dateFormatString") as? String ?? "m/d"
+        pageFormatString = coder.decodeObject(forKey: "pageFormatString") as? String ?? "1"
+        isBates = coder.decodeBool(forKey: "isBates")
+        batesPrefixString = coder.decodeObject(forKey: "batesPrefixString") as? String ?? ""
+        batesSuffixString = coder.decodeObject(forKey: "batesSuffixString") as? String ?? ""
+        batesDigits = coder.decodeInteger(forKey: "batesDigits")
+    }
+    
+    override func encode(with coder: NSCoder) {
+        super.encode(with: coder)
         
-        model.dateFormatString = self.dateFormatString
-        model.pageFormatString = self.pageFormatString
+        coder.encode(dateFormatString, forKey: "dateFormatString")
+        coder.encode(pageFormatString, forKey: "pageFormatString")
+        coder.encode(isBates, forKey: "isBates")
+        coder.encode(batesPrefixString, forKey: "batesPrefixString")
+        coder.encode(batesSuffixString, forKey: "batesSuffixString")
+        coder.encode(batesDigits, forKey: "batesDigits")
+    }
+    
+    func copy(with zone: NSZone? = nil) -> Any {
+        let obj = KMHeaderFooterObject()
+        obj.pageRangeType = pageRangeType
+        obj.leftMargin = leftMargin
+        obj.rightMargin = rightMargin
+        obj.bottomMargin = bottomMargin
+        obj.topMargin = topMargin
+        obj.topLeftString = topLeftString
+        obj.topCenterString = topCenterString
+        obj.topRightString = topRightString
+        obj.bottomLeftString = bottomLeftString
+        obj.bottomCenterString = bottomCenterString
+        obj.bottomRightString = bottomRightString
+        obj.startString = startString
+        obj.fontSize = fontSize
+        obj.textColor = textColor
+//        obj.hasHeader = hasHeader
+//        obj.hasFooter = hasFooter
+//        obj.cellHeight = cellHeight
+        obj.id = id
+        obj.pageCount = pageCount
+        obj.pageRangeString = pageRangeString
         
-        return model
+        obj.dateFormatString = dateFormatString
+        obj.pageFormatString = pageFormatString
+        obj.isBates = isBates
+        obj.batesPrefixString = batesPrefixString
+        obj.batesSuffixString = batesSuffixString
+        obj.batesDigits = batesDigits
+        return obj
     }
 }

+ 2 - 2
PDF Office/PDF Master/Class/PDFTools/HeaderFooter/Tools/KMDataVersionManager.swift

@@ -19,7 +19,7 @@ class KMDataVersionManager: NSObject{
         return false
     }
     
-    class func refrshBatesData(bates: KMHeaderFooterModel?) -> KMHeaderFooterModel? {
+    class func refrshBatesData(bates: KMHeaderFooterObject?) -> KMHeaderFooterObject? {
         if bates == nil {
             return nil
         }
@@ -37,7 +37,7 @@ class KMDataVersionManager: NSObject{
         bates!.bottomRightString = KMDataVersionManager.newBateString(oldString: bates!.bottomRightString, bates: bates!, match: str)
         return bates
     }
-    class func newBateString(oldString: String, bates: KMHeaderFooterModel, match: String) -> String {
+    class func newBateString(oldString: String, bates: KMHeaderFooterObject, match: String) -> String {
         let regex = try! NSRegularExpression(pattern: match, options: []) 
         let results = regex.matches(in: oldString, options: [], range: NSRange(location: 0, length: oldString.count))
         var newString = oldString

File diff suppressed because it is too large
+ 747 - 369
PDF Office/PDF Master/Class/PDFTools/HeaderFooter/Tools/KMHeaderFooterManager.swift


+ 1 - 1
PDF Office/PDF Master/Class/PDFTools/HeaderFooter/View/KMHeaderFooterDateInfoView.swift

@@ -36,7 +36,7 @@ class KMHeaderFooterDateInfoView: KMHeaderFooterAdjectiveInfoBaseView {
         set {
             super.model = newValue
             
-            let myModel: KMHeaderFooterModel = newValue as! KMHeaderFooterModel
+            let myModel: KMHeaderFooterObject = newValue as! KMHeaderFooterObject
             if (myModel.dateFormatString.isEmpty) {
                 self.comboBox.stringValue = KMWatermarkAdjectiveTools.getDateFormats().first!
             } else {

+ 4 - 4
PDF Office/PDF Master/Class/PDFTools/HeaderFooter/View/KMHeaderFooterMarginInfoView.swift

@@ -117,10 +117,10 @@ class KMHeaderFooterMarginInfoView: KMHeaderFooterAdjectiveInfoBaseView {
         set {
             super.model = newValue
             
-            self.topStepper.value = newValue.topMargin
-            self.bottomStepper.value = newValue.bottomMargin
-            self.leftStepper.value = newValue.leftMargin
-            self.rightStepper.value = newValue.rightMargin
+            self.topStepper.value = Double(newValue.topMargin)
+            self.bottomStepper.value = Double(newValue.bottomMargin)
+            self.leftStepper.value = Double(newValue.leftMargin)
+            self.rightStepper.value = Double(newValue.rightMargin)
         }
     }
     

+ 2 - 0
PDF Office/PDF Master/Class/PDFTools/Watermark/Base/KMWatermarkAdjectiveBaseModel.swift

@@ -22,7 +22,9 @@ enum KMWatermarkAdjectiveText {
 
 @objcMembers class KMWatermarkAdjectiveBaseModel: NSObject {
     var textFont: KMWatermarkAdjectiveText!
+    var fontSize: Float = 12.0
     var textColor: KMWatermarkAdjectiveText!
+    var tempTextColor: NSColor = NSColor.black
     
     var id: String = ""
     

+ 2 - 2
PDF Office/PDF Master/Class/PDFTools/Watermark/OCPart/KMWatermarkPDFView_OC.m

@@ -15,7 +15,7 @@
 @property (nonatomic, strong) KMWatermarkModel *watermark;
 @property (nonatomic, strong) KMBackgroundModel *background;
 @property (nonatomic, strong) KMBatesModel *bates;
-@property (nonatomic, strong) KMHeaderFooterModel *headerFooter;
+@property (nonatomic, strong) KMHeaderFooterObject *headerFooter;
 
 @end
 
@@ -29,7 +29,7 @@
         self.watermark = model;
     } else if ([model isKindOfClass:[KMBackgroundModel class]]) {
         self.background = model;
-    } else if ([model isKindOfClass:[KMHeaderFooterModel class]]) {
+    } else if ([model isKindOfClass:[KMHeaderFooterObject class]]) {
         self.headerFooter = model;
     } else {
         self.bates = nil;

+ 10 - 10
PDF Office/PDF Master/Class/PDFTools/Watermark/Tools/KMWatermarkAdjectiveTools.swift

@@ -151,8 +151,8 @@ case bates = 4
     class func apply(_ model: AnyObject, _ pdfView: CPDFView, _ toPath: String, completion: @escaping (_ result: Bool) -> ()) {
         if (model.isKind(of: KMBatesModel.self)) {
             KMWatermarkAdjectiveTools.applyBates(model as! KMBatesModel, pdfView, toPath, completion: completion)
-        } else if (model.isKind(of: KMHeaderFooterModel.self)) {
-            KMWatermarkAdjectiveTools.applyHeaderFooter(model as! KMHeaderFooterModel, pdfView, toPath, completion: completion)
+        } else if (model.isKind(of: KMHeaderFooterObject.self)) {
+            KMWatermarkAdjectiveTools.applyHeaderFooter(model as! KMHeaderFooterObject, pdfView, toPath, completion: completion)
         } else if (model.isKind(of: KMBackgroundModel.self)) {
             KMWatermarkAdjectiveTools.applyBackground(model as! KMBackgroundModel, pdfView, toPath, completion: completion)
         } else if (model.isKind(of: KMWatermarkModel.self)) {
@@ -235,7 +235,7 @@ case bates = 4
             style.lineBreakMode = .byCharWrapping
             let size: NSSize = "text".boundingRect(with: NSSize(width: 1000, height: 1000), options: NSString.DrawingOptions(rawValue: 3), attributes: [NSAttributedString.Key.font : font, NSAttributedString.Key.paragraphStyle : style]).size
             
-            property?.margin = NSEdgeInsetsMake(max(model.topMargin-size.height, 0), model.leftMargin, max(model.bottomMargin-size.height, 0), model.rightMargin)
+            property?.margin = NSEdgeInsetsMake(max(CGFloat(model.topMargin)-size.height, 0), CGFloat(model.leftMargin), max(CGFloat(model.bottomMargin)-size.height, 0), CGFloat(model.rightMargin))
             
             let strings = [model.topLeftString, model.topCenterString, model.topRightString, model.bottomLeftString, model.bottomCenterString, model.bottomRightString]
             var count: Int = 0
@@ -293,7 +293,7 @@ case bates = 4
         }
     }
     
-    private class func applyHeaderFooter(_ model: KMHeaderFooterModel, _ pdfView: CPDFView, _ toPath: String, completion: @escaping (_ result: Bool) -> ()) {
+    private class func applyHeaderFooter(_ model: KMHeaderFooterObject, _ pdfView: CPDFView, _ toPath: String, completion: @escaping (_ result: Bool) -> ()) {
         DispatchQueue.global().async {
             let document: CPDFDocument = pdfView.document
             var property = document.headerFooter()
@@ -315,7 +315,7 @@ case bates = 4
             style.lineBreakMode = .byCharWrapping
             let size: NSSize = "text".boundingRect(with: NSSize(width: 1000, height: 1000), options: NSString.DrawingOptions(rawValue: 3), attributes: [NSAttributedString.Key.font : font, NSAttributedString.Key.paragraphStyle : style]).size
             
-            property?.margin = NSEdgeInsetsMake(max(model.topMargin-size.height, 0), model.leftMargin, max(model.bottomMargin-size.height, 0), model.rightMargin)
+            property?.margin = NSEdgeInsetsMake(max(CGFloat(model.topMargin)-size.height, 0), CGFloat(model.leftMargin), max(CGFloat(model.bottomMargin)-size.height, 0), CGFloat(model.rightMargin))
             
             let strings = KMWatermarkAdjectiveTools.parseModel(model: model, pdfView.document.pageCount)
             var count: Int = 0
@@ -527,8 +527,8 @@ case bates = 4
     class func add(_ model: AnyObject, _ pdfView: CPDFView, completion: @escaping (_ result: Bool) -> ()) {
         if (model.isKind(of: KMBatesModel.self)) {
 //            KMWatermarkAdjectiveTools.applyBates(model as! KMBatesModel, pdfView, toPath, completion: completion)
-        } else if (model.isKind(of: KMHeaderFooterModel.self)) {
-//            KMWatermarkAdjectiveTools.applyHeaderFooter(model as! KMHeaderFooterModel, pdfView, toPath, completion: completion)
+        } else if (model.isKind(of: KMHeaderFooterObject.self)) {
+//            KMWatermarkAdjectiveTools.applyHeaderFooter(model as! KMHeaderFooterObject, pdfView, toPath, completion: completion)
         } else if (model.isKind(of: KMBackgroundModel.self)) {
 //            KMWatermarkAdjectiveTools.applyBackground(model as! KMBackgroundModel, pdfView, toPath, completion: completion)
         } else if (model.isKind(of: KMWatermarkModel.self)) {
@@ -624,8 +624,8 @@ case bates = 4
     class func update(_ model: AnyObject, _ pdfView: CPDFView, completion: @escaping (_ result: Bool) -> ()) {
         if (model.isKind(of: KMBatesModel.self)) {
 //            KMWatermarkAdjectiveTools.applyBates(model as! KMBatesModel, pdfView, toPath, completion: completion)
-        } else if (model.isKind(of: KMHeaderFooterModel.self)) {
-//            KMWatermarkAdjectiveTools.applyHeaderFooter(model as! KMHeaderFooterModel, pdfView, toPath, completion: completion)
+        } else if (model.isKind(of: KMHeaderFooterObject.self)) {
+//            KMWatermarkAdjectiveTools.applyHeaderFooter(model as! KMHeaderFooterObject, pdfView, toPath, completion: completion)
         } else if (model.isKind(of: KMBackgroundModel.self)) {
 //            KMWatermarkAdjectiveTools.applyBackground(model as! KMBackgroundModel, pdfView, toPath, completion: completion)
         } else if (model.isKind(of: KMWatermarkModel.self)) {
@@ -724,7 +724,7 @@ case bates = 4
         }
     }
     
-    private class func parseModel(model: KMHeaderFooterModel, _ pageCount: UInt) -> [String] {
+    private class func parseModel(model: KMHeaderFooterObject, _ pageCount: UInt) -> [String] {
         var topLeftString: String = ""
         if (!model.topLeftString.isEmpty) {
             var string = KMWatermarkAdjectiveTools.parsePageFormat(formatString: model.topLeftString, startPage: model.startString, pageCount: "\(pageCount)")

+ 20 - 20
PDF Office/PDF Master/Class/PDFTools/Watermark/View/KMWatermarkPDFView.swift

@@ -13,7 +13,7 @@ class KMWatermarkPDFView: CPDFView {
     
     var watermark: KMWatermarkModel?
     var background: KMBackgroundModel?
-    var headerFooter: KMHeaderFooterModel?
+    var headerFooter: KMHeaderFooterObject?
     
     override func draw(_ dirtyRect: NSRect) {
         super.draw(dirtyRect)
@@ -426,8 +426,8 @@ class KMWatermarkPDFView: CPDFView {
                                    options: [.usesLineFragmentOrigin, .usesFontLeading],
                                    attributes: attributes).size
 
-        var posY = min(pageBounds.size.height - (headerFooter.topMargin), pageBounds.size.height - size.height)
-        tString.draw(in: CGRect(x: headerFooter.leftMargin + xMargin, y: posY + yMargin, width: size.width, height: size.height), withAttributes: attributes)
+        var posY = min(pageBounds.size.height - CGFloat((headerFooter.topMargin)), pageBounds.size.height - size.height)
+        tString.draw(in: CGRect(x: Double(headerFooter.leftMargin) + xMargin, y: posY + yMargin, width: size.width, height: size.height), withAttributes: attributes)
     
 
         let topCenterString = headerFooter.topCenterString
@@ -437,7 +437,7 @@ class KMWatermarkPDFView: CPDFView {
                                    options: [.usesLineFragmentOrigin, .usesFontLeading],
                                    attributes: attributes).size
 
-        posY = min(pageBounds.size.height - (headerFooter.topMargin), pageBounds.size.height - size.height)
+        posY = min(pageBounds.size.height - CGFloat((headerFooter.topMargin)), pageBounds.size.height - size.height)
         tString.draw(in: CGRect(x: pageBounds.size.width/2 - size.width/2 + xMargin, y: posY + yMargin, width: size.width, height: size.height), withAttributes: attributes)
         
 
@@ -448,8 +448,8 @@ class KMWatermarkPDFView: CPDFView {
                                    options: [.usesLineFragmentOrigin, .usesFontLeading],
                                    attributes: attributes).size
 
-        posY = min(pageBounds.size.height - (headerFooter.topMargin), pageBounds.size.height - size.height)
-        tString.draw(in: CGRect(x: pageBounds.size.width - (headerFooter.rightMargin) - size.width + xMargin,
+        posY = min(pageBounds.size.height - CGFloat((headerFooter.topMargin)), pageBounds.size.height - size.height)
+        tString.draw(in: CGRect(x: pageBounds.size.width - CGFloat((headerFooter.rightMargin)) - size.width + xMargin,
                                 y: posY + yMargin,
                                 width: size.width,
                                 height: size.height),
@@ -463,8 +463,8 @@ class KMWatermarkPDFView: CPDFView {
                                    options: [.usesLineFragmentOrigin, .usesFontLeading],
                                    attributes: attributes).size
 
-        posY = max((headerFooter.bottomMargin) - size.height, 0)
-        tString.draw(in: CGRect(x: headerFooter.leftMargin + xMargin, y: posY + yMargin, width: size.width, height: size.height), withAttributes: attributes)
+        posY = max(CGFloat((headerFooter.bottomMargin)) - size.height, 0)
+        tString.draw(in: CGRect(x: Double(headerFooter.leftMargin) + xMargin, y: posY + yMargin, width: size.width, height: size.height), withAttributes: attributes)
         
 
         let bottomCenterString = headerFooter.bottomCenterString
@@ -474,7 +474,7 @@ class KMWatermarkPDFView: CPDFView {
                                    options: [.usesLineFragmentOrigin, .usesFontLeading],
                                    attributes: attributes).size
 
-        posY = max((headerFooter.bottomMargin) - size.height, 0)
+        posY = max(CGFloat((headerFooter.bottomMargin)) - size.height, 0)
         tString.draw(in: CGRect(x: pageBounds.size.width/2 - size.width/2 + xMargin,
                                 y: posY + yMargin,
                                 width: size.width,
@@ -489,8 +489,8 @@ class KMWatermarkPDFView: CPDFView {
                                    options: [.usesLineFragmentOrigin, .usesFontLeading],
                                    attributes: attributes).size
 
-        posY = max((headerFooter.bottomMargin) - size.height, 0)
-        tString.draw(in: CGRect(x: pageBounds.size.width - (headerFooter.rightMargin) - size.width + xMargin,
+        posY = max(CGFloat((headerFooter.bottomMargin)) - size.height, 0)
+        tString.draw(in: CGRect(x: pageBounds.size.width - CGFloat((headerFooter.rightMargin)) - size.width + xMargin,
                                 y: posY + yMargin,
                                 width: size.width,
                                 height: size.height),
@@ -500,17 +500,17 @@ class KMWatermarkPDFView: CPDFView {
         context.setStrokeColor(NSColor(red: 51.0/255.0, green: 186.0/255.0, blue: 234.0/255.0, alpha: 1.0).cgColor)
         context.setLineWidth(1.0)
 
-        context.move(to: CGPoint(x: xMargin, y: headerFooter.bottomMargin + bottomOffset))
-        context.addLine(to: CGPoint(x: xMargin + pageBounds.size.width, y: headerFooter.bottomMargin + bottomOffset))
+        context.move(to: CGPoint(x: xMargin, y: CGFloat(headerFooter.bottomMargin) + bottomOffset))
+        context.addLine(to: CGPoint(x: xMargin + pageBounds.size.width, y: CGFloat(headerFooter.bottomMargin) + bottomOffset))
 
-        context.move(to: CGPoint(x: xMargin + headerFooter.leftMargin, y: 0))
-        context.addLine(to: CGPoint(x: xMargin + headerFooter.leftMargin, y: pageBounds.size.height))
+        context.move(to: CGPoint(x: Int(xMargin) + headerFooter.leftMargin, y: 0))
+        context.addLine(to: CGPoint(x: xMargin + Double(headerFooter.leftMargin), y: pageBounds.size.height))
 
-        context.move(to: CGPoint(x: xMargin + pageBounds.size.width - (headerFooter.rightMargin), y: 0))
-        context.addLine(to: CGPoint(x: xMargin + pageBounds.size.width - (headerFooter.rightMargin), y: pageBounds.size.height))
+        context.move(to: CGPoint(x: Int(xMargin + pageBounds.size.width) - (headerFooter.rightMargin), y: 0))
+        context.addLine(to: CGPoint(x: xMargin + pageBounds.size.width - Double((headerFooter.rightMargin)), y: pageBounds.size.height))
 
-        context.move(to: CGPoint(x: xMargin, y: pageBounds.size.height - (headerFooter.topMargin) - topOffset))
-        context.addLine(to: CGPoint(x: xMargin + pageBounds.size.width, y: pageBounds.size.height - (headerFooter.topMargin) - topOffset))
+        context.move(to: CGPoint(x: xMargin, y: pageBounds.size.height - CGFloat((headerFooter.topMargin)) - topOffset))
+        context.addLine(to: CGPoint(x: xMargin + pageBounds.size.width, y: pageBounds.size.height - CGFloat((headerFooter.topMargin)) - topOffset))
 
         let arr: [CGFloat] = [8, 1]
         context.setLineDash(phase: 0, lengths: arr)
@@ -582,7 +582,7 @@ class KMWatermarkPDFView: CPDFView {
     static func convertDateFormat(_ oldString: String) -> String {
         var newString = oldString
         
-        for dateFormat in KMHeaderFooterManager.defaultManager.dateFormatArray {
+        for dateFormat in KMHeaderFooterManager.defaultManager().dateFormatArray {
             if newString.contains(dateFormat) {
                 let formatString = dateFormat.replacingOccurrences(of: "m", with: "M")
                 let replace = "<<\(dateFormat)>>"

+ 2 - 2
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController.swift

@@ -518,8 +518,8 @@ let LOCKED_KEY  = "locked"
                     } else {
                         (topBarView as! KMWatermarkAdjectiveTopBarView).isCanApply(can: false)
                     }
-                } else if ((model?.isKind(of: KMHeaderFooterModel.self))!) {
-                    if ((model as! KMHeaderFooterModel).hasVaild) {
+                } else if ((model?.isKind(of: KMHeaderFooterObject.self))!) {
+                    if ((model as! KMHeaderFooterObject).hasVaild) {
                         (topBarView as! KMWatermarkAdjectiveTopBarView).isCanApply(can: true)
                     } else {
                         (topBarView as! KMWatermarkAdjectiveTopBarView).isCanApply(can: false)

File diff suppressed because it is too large
+ 776 - 321
PDF Office/PDF Reader Pro.xcodeproj/xcuserdata/lizhe.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist