KMHeaderFooterModel.swift 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. //
  2. // KMHeaderFooterObject.swift
  3. // Cisdem PDFMaster
  4. //
  5. // Created by tangchao on 2022/12/27.
  6. //
  7. import Cocoa
  8. class KMHeaderFooterObject: KMHeaderFooterAdjectiveModel, NSCopying {
  9. var dateFormatString: String = KMWatermarkAdjectiveTools.getDateFormats().first!
  10. var pageFormatString: String = KMWatermarkAdjectiveTools.getPageFormats().first!
  11. var batesPrefixString: String = ""
  12. var batesSuffixString: String = ""
  13. var batesDigits: Int = 1
  14. var isBates: Bool = false
  15. override init() {
  16. super.init()
  17. self.name = ""
  18. }
  19. required init?(coder: NSCoder) {
  20. super.init(coder: coder)
  21. dateFormatString = coder.decodeObject(forKey: "dateFormatString") as? String ?? "m/d"
  22. pageFormatString = coder.decodeObject(forKey: "pageFormatString") as? String ?? "1"
  23. isBates = coder.decodeBool(forKey: "isBates")
  24. batesPrefixString = coder.decodeObject(forKey: "batesPrefixString") as? String ?? ""
  25. batesSuffixString = coder.decodeObject(forKey: "batesSuffixString") as? String ?? ""
  26. batesDigits = coder.decodeInteger(forKey: "batesDigits")
  27. }
  28. override func encode(with coder: NSCoder) {
  29. super.encode(with: coder)
  30. coder.encode(dateFormatString, forKey: "dateFormatString")
  31. coder.encode(pageFormatString, forKey: "pageFormatString")
  32. coder.encode(isBates, forKey: "isBates")
  33. coder.encode(batesPrefixString, forKey: "batesPrefixString")
  34. coder.encode(batesSuffixString, forKey: "batesSuffixString")
  35. coder.encode(batesDigits, forKey: "batesDigits")
  36. }
  37. func copy(with zone: NSZone? = nil) -> Any {
  38. let obj = KMHeaderFooterObject()
  39. obj.type = type
  40. obj.pageRangeType = pageRangeType
  41. obj.leftMargin = leftMargin
  42. obj.rightMargin = rightMargin
  43. obj.bottomMargin = bottomMargin
  44. obj.topMargin = topMargin
  45. obj.topLeftString = topLeftString
  46. obj.topCenterString = topCenterString
  47. obj.topRightString = topRightString
  48. obj.bottomLeftString = bottomLeftString
  49. obj.bottomCenterString = bottomCenterString
  50. obj.bottomRightString = bottomRightString
  51. obj.startString = startString
  52. obj.fontSize = fontSize
  53. obj.textColor = textColor
  54. // obj.hasHeader = hasHeader
  55. // obj.hasFooter = hasFooter
  56. // obj.cellHeight = cellHeight
  57. obj.id = id
  58. obj.pageCount = pageCount
  59. obj.pageRangeString = pageRangeString
  60. obj.dateFormatString = dateFormatString
  61. obj.pageFormatString = pageFormatString
  62. obj.isBates = isBates
  63. obj.batesPrefixString = batesPrefixString
  64. obj.batesSuffixString = batesSuffixString
  65. obj.batesDigits = batesDigits
  66. return obj
  67. }
  68. }