Browse Source

Merge branch 'develop_2025' of git.kdan.cc:Mac_PDF/PDF_Office into develop_2025

tangchao 3 months ago
parent
commit
321d07c722
84 changed files with 2147 additions and 7044 deletions
  1. 20 9
      PDF Office/KMComponentLibrary/KMComponentLibrary/View/Card/ComponentCardPDFTool/ComponentCardPDFTool.xib
  2. 1 0
      PDF Office/KMComponentLibrary/KMComponentLibrary/View/Controller/Position/ComponentCPosition.swift
  3. 2 0
      PDF Office/KMComponentLibrary/KMComponentLibrary/View/Input/ComponentInput/ComponentInput.swift
  4. 13 11
      PDF Office/KMComponentLibrary/KMComponentLibrary/View/Input/ComponentInputAddon/ComponentInputAddon.swift
  5. 2 0
      PDF Office/PDF Master/AppDelegate.swift
  6. 0 805
      PDF Office/PDF Master/Class/PDFTools/Crop/Controller/KMCropPreviewController.swift
  7. 0 22
      PDF Office/PDF Master/Class/PDFTools/Crop/Controller/KMCropPreviewController.xib
  8. 0 113
      PDF Office/PDF Master/Class/PDFTools/Crop/KMCropSettingWindowController.swift
  9. 0 161
      PDF Office/PDF Master/Class/PDFTools/Crop/KMCropSettingWindowController.xib
  10. 0 1106
      PDF Office/PDF Master/Class/PDFTools/Crop/KMPDFCropWindowController.swift
  11. 0 818
      PDF Office/PDF Master/Class/PDFTools/Crop/KMPDFCropWindowController.xib
  12. 0 74
      PDF Office/PDF Master/Class/PDFTools/Crop/View/KMCropSettingPageSizeView.swift
  13. 0 79
      PDF Office/PDF Master/Class/PDFTools/Crop/View/KMCropTipView.swift
  14. 13 13
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Edit.swift
  15. 112 112
      PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/KMGeneralAnnotationViewController.xib
  16. 23 318
      PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift
  17. 4 38
      PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+MenuAction.swift
  18. 6 7
      PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift
  19. 3 0
      PDF Office/PDF Master/KMClass/KMNPDFPageEdit/KMNPDFInsert/KMNPDFInsertBlankWindowController.swift
  20. 8 8
      PDF Office/PDF Master/KMClass/KMNPDFPageEdit/KMNPDFInsert/KMNPDFInsertPDFWindowController.xib
  21. 1 0
      PDF Office/PDF Master/KMClass/KMNPDFPageEdit/KMNPDFSplit/KMNSplitPDFWindowController.swift
  22. 9 9
      PDF Office/PDF Master/KMClass/KMNPDFPageEdit/KMNPDFSplit/KMNSplitPDFWindowController.xib
  23. 4 0
      PDF Office/PDF Master/KMClass/KMNPDFPageEdit/KMNThumbnailManager.swift
  24. 15 0
      PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/Background/KMBackgroundController.swift
  25. 5 5
      PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/Background/KMBackgroundController.xib
  26. 59 17
      PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/Background/KMBackgroundManager.swift
  27. 5 3
      PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/Background/KMBackgroundModel.swift
  28. 0 0
      PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/Views/KMBGTemplateController.swift
  29. 0 0
      PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/Views/KMBGTemplateController.xib
  30. 0 0
      PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/Views/KMBGTemplateItem.swift
  31. 0 0
      PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/Views/KMBGTemplateItem.xib
  32. 69 27
      PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/Background/Views/KMBackgroundPropertyController.swift
  33. 12 9
      PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/Background/Views/KMBackgroundPropertyController.xib
  34. 49 9
      PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Bates/KMBatesController.swift
  35. 124 13
      PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Bates/KMBatesManager.swift
  36. 20 20
      PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Bates/Views/KMBatesPropertyController.swift
  37. 4 7
      PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Bates/Views/KMBatesTemplateController.swift
  38. 44 9
      PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Crop/KMCropController.swift
  39. 12 0
      PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Crop/KMCropManager.swift
  40. 2 2
      PDF Office/PDF Master/Class/PDFTools/Crop/Tools/KMCropTools.swift
  41. 130 19
      PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Crop/Views/KMCropPropertyController.swift
  42. 14 3
      PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/KMLinkViewController/Views/KMLinkPageView/KMLinkPageView.swift
  43. 0 17
      PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Watermark/Base/KMWatermarkAdjectivePreViewBaseController.swift
  44. 5 5
      PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Watermark/KMWatermarkWindowController.xib
  45. 11 0
      PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Watermark/New/Views/KMNWatermarkPropertyController.swift
  46. 4 1
      PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Watermark/New/Views/KMNWatermarkPropertyController.xib
  47. 0 66
      PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Base/KMDataVersionManager.swift
  48. 0 54
      PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Base/KMHeaderFooterAdjectiveInfoBaseView.swift
  49. 0 146
      PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Base/KMHeaderFooterAdjectiveListCell.swift
  50. 0 127
      PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Base/KMHeaderFooterAdjectiveModel.swift
  51. 0 74
      PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Controller/KMCreateHeaderFooterController.swift
  52. 0 22
      PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Controller/KMCreateHeaderFooterController.xib
  53. 0 106
      PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Controller/KMHeaderFooterListController.swift
  54. 0 22
      PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Controller/KMHeaderFooterListController.xib
  55. 0 285
      PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Controller/KMHeaderFooterPreviewController.swift
  56. 0 22
      PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Controller/KMHeaderFooterPreviewController.xib
  57. 0 128
      PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Controller/KMHeaderFooterPropertyController.swift
  58. 0 22
      PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Controller/KMHeaderFooterPropertyController.xib
  59. 0 268
      PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Controller/KMHeaderFooterPropertyInfoController.swift
  60. 0 139
      PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Controller/KMHeaderFooterPropertyInfoController.xib
  61. 0 122
      PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Controller/KMHeaderFooterPropertyMainController.swift
  62. 0 22
      PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Controller/KMHeaderFooterPropertyMainController.xib
  63. 34 13
      PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/KMHeaderFooterController.swift
  64. 115 21
      PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/KMHeaderFooterManager.swift
  65. 0 224
      PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/View/KMHeaderFooterContentInfoView.swift
  66. 0 64
      PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/View/KMHeaderFooterDateInfoView.swift
  67. 0 135
      PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/View/KMHeaderFooterFontInfoView.swift
  68. 0 127
      PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/View/KMHeaderFooterMarginInfoView.swift
  69. 0 89
      PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/View/KMHeaderFooterPageInfoView.swift
  70. 5 2
      PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Views/KMHFTemplateController.swift
  71. 28 37
      PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Views/KMHeaderPropertyController.swift
  72. 8 8
      PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Views/KMHeaderPropertyController.xib
  73. 355 149
      PDF Office/PDF Master/KMClass/KMPDFViewController/KMMainViewController.swift
  74. 12 0
      PDF Office/PDF Master/KMClass/KMPDFViewController/PDFImages.xcassets/PDF_Edit/edit_Reset.imageset/Contents.json
  75. BIN
      PDF Office/PDF Master/KMClass/KMPDFViewController/PDFImages.xcassets/PDF_Edit/edit_Reset.imageset/edit_Reset.pdf
  76. 1 0
      PDF Office/PDF Master/KMClass/KMPDFViewController/RightSideController/KMRightSideController.swift
  77. 10 0
      PDF Office/PDF Master/KMClass/KMPDFViewController/RightSideController/KMRightSideController.xib
  78. 0 1
      PDF Office/PDF Master/KMClass/KMPDFViewController/Toolbar/KMPDFSecToolbarController.swift
  79. 2 3
      PDF Office/PDF Master/KMClass/KMPDFViewController/Toolbar/Model/KMPDFToolbarManager.swift
  80. 2 2
      PDF Office/PDF Master/KMClass/Tools/Category/Foundation/NSColor+KMExtensions.swift
  81. 4 22
      PDF Office/PDF Master/KMClass/Tools/CustomAlertView/KMNCustomAlertView.swift
  82. 1 1
      PDF Office/PDF Master/KMClass/Tools/KMNFileAttribute/KMNFileAttribute.swift
  83. 14 302
      PDF Office/PDF Reader Pro.xcodeproj/project.pbxproj
  84. 751 350
      PDF Office/PDF Reader Pro.xcodeproj/xcuserdata/kdanmobile.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

+ 20 - 9
PDF Office/KMComponentLibrary/KMComponentLibrary/View/Card/ComponentCardPDFTool/ComponentCardPDFTool.xib

@@ -9,7 +9,7 @@
         <customObject id="-2" userLabel="File's Owner" customClass="ComponentCardPDFTool">
             <connections>
                 <outlet property="checkBox" destination="QPd-Y0-5Be" id="xEj-tR-fCE"/>
-                <outlet property="contendBox" destination="gRd-t4-fFz" id="JnQ-23-Pz4"/>
+                <outlet property="contendBox" destination="guV-D6-phr" id="LJU-hx-fBs"/>
                 <outlet property="iconImage" destination="Hug-T9-j0l" id="g41-Zb-F6U"/>
                 <outlet property="iconWidthConst" destination="9vY-ti-etS" id="llI-DG-BOR"/>
                 <outlet property="subTitleLabel" destination="nLl-zS-465" id="XOk-Db-0V5"/>
@@ -22,22 +22,29 @@
             <rect key="frame" x="0.0" y="0.0" width="240" height="88"/>
             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
             <subviews>
-                <box boxType="custom" cornerRadius="4" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="gRd-t4-fFz">
+                <box boxType="custom" cornerRadius="4" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="guV-D6-phr">
                     <rect key="frame" x="0.0" y="0.0" width="240" height="88"/>
-                    <view key="contentView" id="Uf6-gk-6YJ">
+                    <view key="contentView" id="rAU-IW-YdB">
                         <rect key="frame" x="1" y="1" width="238" height="86"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                    </view>
+                </box>
+                <box boxType="custom" borderWidth="0.0" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="gRd-t4-fFz">
+                    <rect key="frame" x="0.0" y="0.0" width="240" height="88"/>
+                    <view key="contentView" id="Uf6-gk-6YJ">
+                        <rect key="frame" x="0.0" y="0.0" width="240" height="88"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
                             <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Hug-T9-j0l">
-                                <rect key="frame" x="12" y="25" width="36" height="36"/>
+                                <rect key="frame" x="12" y="26" width="36" height="36"/>
                                 <constraints>
                                     <constraint firstAttribute="width" constant="36" id="9vY-ti-etS"/>
                                     <constraint firstAttribute="width" secondItem="Hug-T9-j0l" secondAttribute="height" multiplier="1:1" id="el1-mS-dcO"/>
                                 </constraints>
                                 <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="axesIndependently" image="test" id="jhs-UP-tL4"/>
                             </imageView>
-                            <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" allowsExpansionToolTips="YES" translatesAutoresizingMaskIntoConstraints="NO" id="nLl-zS-465">
-                                <rect key="frame" x="56" y="16" width="172" height="16"/>
+                            <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" allowsExpansionToolTips="YES" translatesAutoresizingMaskIntoConstraints="NO" id="nLl-zS-465">
+                                <rect key="frame" x="56" y="16" width="174" height="16"/>
                                 <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
                                 <textFieldCell key="cell" truncatesLastVisibleLine="YES" title="content content content content content content content content" id="ehH-eQ-Oeo">
                                     <font key="font" metaFont="system"/>
@@ -45,8 +52,8 @@
                                     <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                                 </textFieldCell>
                             </textField>
-                            <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="89z-7H-gqW">
-                                <rect key="frame" x="54" y="54" width="56" height="16"/>
+                            <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="89z-7H-gqW">
+                                <rect key="frame" x="54" y="56" width="56" height="16"/>
                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                                 <textFieldCell key="cell" lineBreakMode="clipping" title="Example" id="Zmc-LK-yn7">
                                     <font key="font" metaFont="system"/>
@@ -55,7 +62,7 @@
                                 </textFieldCell>
                             </textField>
                             <customView translatesAutoresizingMaskIntoConstraints="NO" id="QPd-Y0-5Be" customClass="ComponentCheckBox" customModule="KMComponentLibrary" customModuleProvider="target">
-                                <rect key="frame" x="208" y="33" width="20" height="20"/>
+                                <rect key="frame" x="210" y="34" width="20" height="20"/>
                                 <constraints>
                                     <constraint firstAttribute="height" constant="20" id="dKT-bL-LLx"/>
                                     <constraint firstAttribute="width" constant="20" id="k8R-7k-YAg"/>
@@ -73,7 +80,11 @@
             </subviews>
             <constraints>
                 <constraint firstAttribute="bottom" secondItem="gRd-t4-fFz" secondAttribute="bottom" id="0TR-rC-1Bs"/>
+                <constraint firstItem="guV-D6-phr" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" id="2qH-hn-hed"/>
+                <constraint firstAttribute="trailing" secondItem="guV-D6-phr" secondAttribute="trailing" id="6ZR-fU-Yis"/>
+                <constraint firstItem="guV-D6-phr" firstAttribute="top" secondItem="c22-O7-iKe" secondAttribute="top" id="JMp-OH-laz"/>
                 <constraint firstItem="gRd-t4-fFz" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" id="Jya-Qw-4FN"/>
+                <constraint firstAttribute="bottom" secondItem="guV-D6-phr" secondAttribute="bottom" id="QUF-61-8Xz"/>
                 <constraint firstItem="gRd-t4-fFz" firstAttribute="top" secondItem="c22-O7-iKe" secondAttribute="top" id="rtX-fW-U4x"/>
                 <constraint firstAttribute="trailing" secondItem="gRd-t4-fFz" secondAttribute="trailing" id="wV4-l0-QbU"/>
             </constraints>

+ 1 - 0
PDF Office/KMComponentLibrary/KMComponentLibrary/View/Controller/Position/ComponentCPosition.swift

@@ -165,6 +165,7 @@ public class ComponentCPosition: ComponentBaseXibView {
         
         setupUI()
         
+        reloadData()
     }
     
     public func reloadData() {

+ 2 - 0
PDF Office/KMComponentLibrary/KMComponentLibrary/View/Input/ComponentInput/ComponentInput.swift

@@ -209,6 +209,8 @@ public class ComponentInput: ComponentBaseXibView {
         } else {
             inputField.isEditable = false
         }
+        inputField.wantsLayer = true
+        inputField.layer?.masksToBounds = true
         
         updateClearButtonState()
         

+ 13 - 11
PDF Office/KMComponentLibrary/KMComponentLibrary/View/Input/ComponentInputAddon/ComponentInputAddon.swift

@@ -64,22 +64,24 @@ public class ComponentInputAddon: ComponentBaseXibView {
             let cornerRadius_bottomLeft: CGFloat = properties.propertyInfo.cornerRadius_bottomLeft
             let cornerRadius_bottomRight: CGFloat = properties.propertyInfo.cornerRadius_bottomRight
             let cornerRadius = max(cornerRadius_topLeft, cornerRadius_topRight)
+             
+            let drawBounds = bounds.insetBy(dx: 1, dy: 1)
             
             let path = NSBezierPath()
             path.lineWidth = borderWidth + 1
             if properties.addOnBefore == false {
-                path.move(to: NSPoint(x: bounds.minX, y: bounds.minY))
-                path.appendArc(from: NSPoint(x: bounds.minX, y: bounds.minY), to: NSPoint(x: bounds.minX + cornerRadius_bottomLeft, y: bounds.minY), radius: cornerRadius_bottomLeft) //左下角
-                path.line(to: NSPoint(x: bounds.maxX - cornerRadius, y: bounds.minY))
-                path.appendArc(from: NSPoint(x: bounds.maxX, y: bounds.minY), to: NSPoint(x: bounds.maxX, y: bounds.minY + cornerRadius_bottomRight), radius: cornerRadius_bottomRight) //右下角
-                path.appendArc(from: NSPoint(x: bounds.maxX, y: bounds.maxY), to: NSPoint(x: bounds.maxX - cornerRadius_topRight, y: bounds.maxY), radius: cornerRadius_topRight) // 右上角
-                path.appendArc(from: NSPoint(x: bounds.minX, y: bounds.maxY), to: NSPoint(x: bounds.minX, y: bounds.maxY - cornerRadius_topLeft), radius: cornerRadius_topLeft) //左上角
+                path.move(to: NSPoint(x: drawBounds.minX, y: drawBounds.minY))
+                path.appendArc(from: NSPoint(x: drawBounds.minX, y: drawBounds.minY), to: NSPoint(x: drawBounds.minX + cornerRadius_bottomLeft, y: drawBounds.minY), radius: cornerRadius_bottomLeft) //左下角
+                path.line(to: NSPoint(x: drawBounds.maxX - cornerRadius, y: drawBounds.minY))
+                path.appendArc(from: NSPoint(x: drawBounds.maxX, y: drawBounds.minY), to: NSPoint(x: drawBounds.maxX, y: drawBounds.minY + cornerRadius_bottomRight), radius: cornerRadius_bottomRight) //右下角
+                path.appendArc(from: NSPoint(x: drawBounds.maxX, y: drawBounds.maxY), to: NSPoint(x: drawBounds.maxX - cornerRadius_topRight, y: drawBounds.maxY), radius: cornerRadius_topRight) // 右上角
+                path.appendArc(from: NSPoint(x: drawBounds.minX, y: drawBounds.maxY), to: NSPoint(x: drawBounds.minX, y: drawBounds.maxY - cornerRadius_topLeft), radius: cornerRadius_topLeft) //左上角
             } else {
-                path.move(to: NSPoint(x: bounds.maxX, y: bounds.minY))
-                path.appendArc(from: NSPoint(x: bounds.maxX, y: bounds.minY), to: NSPoint(x: bounds.maxX, y: bounds.minY), radius: cornerRadius) //右下角
-                path.appendArc(from: NSPoint(x: bounds.minX, y: bounds.minY), to: NSPoint(x: bounds.minX, y: bounds.minY+cornerRadius), radius: cornerRadius) //左下角
-                path.appendArc(from: NSPoint(x: bounds.minX, y: bounds.maxY), to: NSPoint(x: bounds.minX+cornerRadius, y: bounds.maxY), radius: cornerRadius) //左上角
-                path.line(to: NSPoint(x: bounds.maxX, y: bounds.maxY))
+                path.move(to: NSPoint(x: drawBounds.maxX, y: drawBounds.minY))
+                path.appendArc(from: NSPoint(x: drawBounds.maxX, y: drawBounds.minY), to: NSPoint(x: drawBounds.maxX, y: drawBounds.minY), radius: cornerRadius) //右下角
+                path.appendArc(from: NSPoint(x: drawBounds.minX, y: drawBounds.minY), to: NSPoint(x: drawBounds.minX, y: drawBounds.minY+cornerRadius), radius: cornerRadius) //左下角
+                path.appendArc(from: NSPoint(x: drawBounds.minX, y: drawBounds.maxY), to: NSPoint(x: drawBounds.minX+cornerRadius, y: drawBounds.maxY), radius: cornerRadius) //左上角
+                path.line(to: NSPoint(x: drawBounds.maxX, y: drawBounds.maxY))
             }
             borderColor.setStroke()
             path.stroke()

+ 2 - 0
PDF Office/PDF Master/AppDelegate.swift

@@ -135,6 +135,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, iRateDelegate{
 #else
         appName = .PDFReaderProMacPro
 #endif
+        
+        
         KMAdvertisementManager.manager.initConfig(appName: appName,
                                                   subscribeType: .unknow,
                                                   platform: .Mac)

+ 0 - 805
PDF Office/PDF Master/Class/PDFTools/Crop/Controller/KMCropPreviewController.swift

@@ -1,805 +0,0 @@
-//
-//  KMCropPreviewController.swift
-//  PDF Reader Pro
-//
-//  Created by tangchao on 2022/12/29.
-//
-
-import Cocoa
-import PDFKit
-
-extension CPDFPage {
-    private static var _drawingPage = "cropDrawingPage"
-    var cropDrawingPage: CPDFPage? {
-        get {
-            return (objc_getAssociatedObject(self, &CPDFPage._drawingPage) as? CPDFPage)
-        }
-        set {
-            objc_setAssociatedObject(self, &CPDFPage._drawingPage, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
-        }
-    }
-    
-    var cropOffsetX: CGFloat {
-        get {
-            return objc_getAssociatedObject(self, "cropOffsetX") as! CGFloat
-        }
-        set {
-            objc_setAssociatedObject(self, "cropOffsetX", newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_ASSIGN)
-        }
-    }
-    
-    var cropOffsetY: CGFloat {
-        get {
-            return objc_getAssociatedObject(self, "cropOffsetY") as! CGFloat
-        }
-        set {
-            objc_setAssociatedObject(self, "cropOffsetY", newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_ASSIGN)
-        }
-    }
-    
-    var isChangePageSize: Bool {
-        get {
-            return objc_getAssociatedObject(self, "isChangePageSize") as! Bool
-        }
-        set {
-            objc_setAssociatedObject(self, "isChangePageSize", newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_ASSIGN)
-        }
-    }
-    
-    var cropRect: NSRect {
-        get {
-            return objc_getAssociatedObject(self, "cropRect") as! NSRect
-        }
-        set {
-            objc_setAssociatedObject(self, "cropRect", newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_ASSIGN)
-        }
-    }
-}
-
-class KMCropInfo: NSObject {
-    var drawPage: CPDFPage!
-    var cropOffsetX: CGFloat = 0
-    var cropOffsetY: CGFloat = 0
-    var isChangePageSize: Bool = false
-    var cropRect: NSRect!
-}
-
-class KMCropPDFView: CPDFView {
-    
-    var drawInfo: Array<KMCropInfo> = []
-    
-    override func draw(_ page: CPDFPage!, to context: CGContext!) {
-        super.draw(page, to: context)
-        
-        if (self.drawInfo.count > 0) {
-            drawCropPage(page, to: context)
-        }
-        drawCropPage(page: page, toContext: context)
-    }
-    
-    private func drawCropPage(page: CPDFPage, toContext context: CGContext) {
-        if (page.cropDrawingPage != nil) {
-            let originalRect = page.bounds(for: .mediaBox)
-            let drawPage = page.cropDrawingPage
-            let cropRect = drawPage?.bounds(for: .mediaBox)
-            let orgPageWidth = cropRect?.size.width
-            let orgPageHeight = cropRect?.size.height
-            
-            let spaceX = page.cropOffsetX
-            let spaceY = page.cropOffsetY
-            let scanl = min(originalRect.size.width/(orgPageWidth ?? 0), originalRect.size.height/(orgPageHeight ?? 1))
-            
-            NSGraphicsContext.saveGraphicsState()
-            
-            context.translateBy(x: spaceX, y: spaceY)
-            context.scaleBy(x: scanl, y: scanl)
-            
-            if #available(macOS 10.12, *) {
-                drawPage?.draw(with: .cropBox, to: context)
-                drawPage?.transform(context, for: .cropBox)
-            } else {
-                NSGraphicsContext.saveGraphicsState()
-                NSGraphicsContext.current = NSGraphicsContext(cgContext: context, flipped: true)
-                drawPage?.draw(with: .cropBox, to: context)
-                NSGraphicsContext.restoreGraphicsState()
-                drawPage?.transform(context, for: .cropBox)
-            }
-            
-            if !page.isChangePageSize {
-                let tCropRect = page.cropRect
-                let w1 = (orgPageWidth ?? 0) - tCropRect.size.width - tCropRect.origin.x
-                
-                context.setFillColor(red: 0, green: 0, blue: 0, alpha: 0.3)
-                let rect1 = CGRect(x: 0, y: 0, width: orgPageWidth ?? 0, height: tCropRect.origin.y)
-                let rect2 = CGRect(x: 0, y: tCropRect.origin.y + tCropRect.size.height, width: orgPageWidth ?? 0, height: (orgPageHeight ?? 0) - tCropRect.origin.y - tCropRect.size.height)
-                let rect3 = CGRect(x: 0, y: tCropRect.origin.y, width: tCropRect.origin.x, height: tCropRect.size.height)
-                let rect4 = CGRect(x: tCropRect.origin.x + tCropRect.size.width, y: tCropRect.origin.y, width: max(w1, 0), height: tCropRect.size.height)
-                context.fill(rect1)
-                context.fill(rect2)
-                context.fill(rect3)
-                context.fill(rect4)
-            }
-            
-            NSGraphicsContext.restoreGraphicsState()
-        }
-    }
-    
-    private func drawCropPage(_ cropPage: CPDFPage, to context: CGContext!) {
-//        let myPage: KMCropPDFPage = cropPage as! KMCropPDFPage
-        let info: KMCropInfo = self.drawInfo[Int(self.document.index(for: cropPage))]
-        if (info.drawPage != nil) {
-            let originalRect = cropPage.bounds(for: .mediaBox)
-            let drawPage = info.drawPage
-            let cropRect = drawPage!.bounds(for: .mediaBox)
-            /// 原始page的宽度(不管有没有旋转,都是旋转度数等于0)
-            let orgPageWidth: CGFloat = NSWidth(cropRect)
-            /// 原始page的高度
-            let orgPageHeight: CGFloat = NSHeight(cropRect)
-            
-            let spaceX = info.cropOffsetX
-            let spaceY = info.cropOffsetY
-            
-            let scale: CGFloat = min(NSWidth(originalRect)/orgPageWidth, NSHeight(originalRect)/orgPageHeight)
-            
-            NSGraphicsContext.saveGraphicsState()
-            
-            context.translateBy(x: spaceX,y: spaceY)
-            context.scaleBy(x: scale, y: scale)
-            
-            if #available(macOS 10.12, *) {
-                drawPage?.draw(with: .cropBox, to: context)
-                drawPage?.transform(context, for: .cropBox)
-            } else {
-                NSGraphicsContext.saveGraphicsState()
-                NSGraphicsContext.current = NSGraphicsContext(cgContext: context, flipped: false)
-                drawPage?.draw(with: .cropBox, to: context)
-                drawPage?.transform(context, for: .cropBox)
-            }
-            
-            if (info.isChangePageSize) {
-                let tCropRect: NSRect = cropPage.cropRect
-                let w1: CGFloat = orgPageWidth-(tCropRect.size.width)-(tCropRect.origin.x)
-                
-                context.setFillColor(red: 0, green: 0, blue: 0, alpha: 0.3)
-                let rect1: NSRect = NSMakeRect(0, 0, orgPageWidth, (tCropRect.origin.y))
-                let rect2: NSRect = NSMakeRect(0, (tCropRect.origin.y)+(tCropRect.size.height), orgPageWidth,     orgPageHeight - tCropRect.origin.y-tCropRect.size.height)
-                let rect3: NSRect = NSMakeRect(0, tCropRect.origin.y,tCropRect.origin.x,tCropRect.size.height);
-                var rect4Y = w1
-                if (w1 > 0) {
-                    rect4Y = 0
-                }
-                let rect4: NSRect = NSMakeRect(tCropRect.origin.x+tCropRect.size.width, tCropRect.origin.y,rect4Y,tCropRect.size.height)
-                
-                context.fill(rect1)
-                context.fill(rect2)
-                context.fill(rect3)
-                context.fill(rect4)
-            }
-            
-            NSGraphicsContext.restoreGraphicsState()
-        }
-    }
-}
-
-class KMCropPDFPage: CPDFPage {
-//    var drawingPage: CPDFPage!
-//    var cropOffsetX: CGFloat = 0
-//    var cropOffsetY: CGFloat = 0
-    
-//    var isChangePageSize: Bool = false
-//    var cropRect: NSRect!
-    
-    override func draw(with box: CPDFDisplayBox, to context: CGContext!) {
-        super.draw(with: box, to: context)
-        
-        let pageSize: NSSize = self.bounds(for: .mediaBox).size
-        drawPage(with: context, page: self.cropDrawingPage!, pageSize: pageSize)
-    }
-    
-    private func drawPage(with context: CGContext, page: CPDFPage, pageSize: NSSize) {
-        let myPage: KMCropPDFPage = page as! KMCropPDFPage
-        
-        var originalSize: NSSize = page.bounds(for: .mediaBox).size
-        
-        //如果page的旋转角度为90,或者270,宽高交换
-        if (page.rotation % 180 != 0) {
-            originalSize = NSMakeSize(originalSize.height, originalSize.width)
-        }
-        
-        context.saveGState()
-        context.translateBy(x: myPage.cropOffsetX, y: myPage.cropOffsetY)
-        
-        if #available(macOS 10.12, *) {
-            page.draw(with: .cropBox, to: context)
-            page.transform(context, for: .cropBox)
-        } else {
-            NSGraphicsContext.saveGraphicsState()
-            NSGraphicsContext.current = NSGraphicsContext(cgContext: context, flipped: true)
-            page.draw(with: .cropBox, to: context)
-            
-            NSGraphicsContext.restoreGraphicsState()
-            page.transform(context, for: .cropBox)
-        }
-        
-        context.restoreGState()
-    }
-}
-
-class KMCropPreviewController: KMWatermarkAdjectivePreViewBaseController {
-
-//    var testPreView: PDFView!
-    
-    var tipView = KMCropTipView()
-    
-    var windowController: KMCropSettingWindowController!
-    
-    override func viewDidLoad() {
-        super.viewDidLoad()
-        
-        let itemTitles = [["裁剪"]]
-        var itemModels: Array<Array<KMWatermarkAdjectiveTopBarItemModel>> = []
-        for items in itemTitles {
-            var array: Array<KMWatermarkAdjectiveTopBarItemModel> = []
-            for title in items {
-                let model = KMWatermarkAdjectiveTopBarItemModel()
-                model.iconName = ""
-                model.itemTitle = title
-                array.append(model)
-            }
-            itemModels.append(array)
-        }
-        
-        self.topBarView.initItemData(itemArrays: itemModels)
-        
-        let preView: CPDFListView = CPDFListView()
-        self.preView = preView
-        self.preView.frame = self.preViewBox.contentView!.bounds
-        self.preView.autoresizingMask = NSView.AutoresizingMask(rawValue: 18)
-        self.preViewBox.contentView?.addSubview(self.preView)
-        self.preView.autoScales = true
-        self.preView.displaysAsBook = true
-        self.preView.delegate = self
-        
-        let myPreView: CPDFListView = self.preView as! CPDFListView
-        myPreView.pdfListViewDelegate = self
-        
-//        NotificationCenter.default.addObserver(self, selector: #selector(preViewSelectionDidChange), name: NSNotification.Name.CPDFViewSelectionChanged, object: nil)
-        
-//        self.testPreView = PDFView()
-//        self.testPreView.frame = self.preViewBox.contentView!.bounds
-//        self.testPreView.autoresizingMask = NSView.AutoresizingMask(rawValue: 18)
-//        self.preViewBox.contentView?.addSubview(self.testPreView)
-        
-        self.topBarView.isCanApply(can: false)
-        
-        self.tipView.frame = self.tipBox.contentView!.frame
-        self.tipView.autoresizingMask = NSView.AutoresizingMask(rawValue: 18)
-        self.tipBox.addSubview(self.tipView)
-        self.tipBox.isHidden = true
-        
-        self.tipView.enterAction = {
-            () in
-            let myPreView: CPDFListView = self.preView as! CPDFListView
-            var rect = NSIntegralRect(myPreView.currentSelectionRect())
-            if (NSIsEmptyRect(rect)) {
-                return
-            }
-            
-            let window = KMCropSettingWindowController(windowNibName: "KMCropSettingWindowController")
-            self.view.window?.beginSheet(window.window!)
-            self.windowController = window
-            
-            window.itemClick = { [self]
-                (index: Int) in
-                if (index == 1) { /// 取消
-                    self.view.window?.endSheet((self.windowController?.window)!)
-                    self.windowController = nil
-                    return
-                }
-                let pageRangeType = self.windowController.pageRangeIndex
-                let pageCount: Int = Int(self.preView.document.pageCount)
-                var pages: Array<Int> = []
-                if (pageRangeType == 0) { /// 当前页面
-                    pages.append(self.preView.currentPageIndex)
-                } else if (pageRangeType == 1) { /// 全部页面
-                    for i in 0 ..< pageCount {
-                        pages.append(i)
-                    }
-                } else if (pageRangeType == 2) { /// 奇数页面
-                    var string: String = ""
-                    for i in 0 ..< pageCount {
-                        if (i % 2 == 1) {
-                            continue
-                        }
-                        
-                        pages.append(i)
-                    }
-                } else if (pageRangeType == 3) { /// 偶数页面
-                    var string: String = ""
-                    for i in 0 ..< pageCount {
-                        if (i % 2 == 0) {
-                            continue
-                        }
-                        
-                        pages.append(i)
-                    }
-                } else { /// 自定义
-                    for i in self.windowController.pageRangePages {
-                        pages.append(i)
-                    }
-                }
-                
-                if (pages.count < 0) {
-                    let alert = NSAlert()
-                    alert.messageText = "请选择页面"
-                    alert.runModal()
-                    return
-                }
-                
-                var pageSize: NSSize = NSZeroSize
-                if (self.windowController.pageSize == "None") {
-                    
-                } else {
-                    pageSize = KMCropTools.getPageSizeValue(self.windowController.pageSize)
-                }
-                
-                for i in pages {
-                    let myPreView: CPDFListView = self.preView as! CPDFListView
-                    var page: CPDFPage = self.preView.document.page(at: UInt(i))
-                    var rect = NSIntegralRect(myPreView.selectionRect)
-
-                    if (NSIsEmptyRect(rect)) {
-                        rect = getPageForegroundBox(page)
-                    }
-                    
-                    var newRect = NSIntersectionRect(rect, (page.bounds(for: .mediaBox)))
-                    page.setBounds(newRect, for: .cropBox)
-                    
-                    if (pageSize.width == 0 && pageSize.height == 0) {
-                        
-                    } else {
-                        let tiffData = page.PDFListViewTIFFData(for: rect)
-                        let index: UInt = (page.pageIndex())
-//                        let newPage: CPDFPage = CPDFPage(image: NSImage(data: tiffData!))
-                        
-                        self.preView.document.removePage(at: index)
-//                        newPage.setBounds(NSMakeRect(0, 0, pageSize.width, pageSize.height), for: .cropBox)
-                        //        let result = self.preView.document.insertPageObject(newPage, at: index)
-                        let result = self.preView.document.insertPage(pageSize, at: index)
-                    }
-                }
-                
-                /// 保存到临时路径
-                let toPath: String = self.preView.document.documentURL.path
-                let documentPath = NSTemporaryDirectory()
-                let tempPath: String = "\(documentPath)/\(toPath.lastPathComponent)"
-                if (FileManager.default.fileExists(atPath: tempPath)) {
-                    try?FileManager.default.removeItem(atPath: tempPath)
-                }
-
-                let result = self.preView.document.write(to: URL(fileURLWithPath: tempPath))
-                if (result) {
-                    if (FileManager.default.fileExists(atPath: toPath)) {
-                        try?FileManager.default.removeItem(atPath: toPath)
-                    }
-                    
-                    try?FileManager.default.moveItem(atPath: tempPath, toPath: toPath)
-                } else {
-                    try?FileManager.default.removeItem(atPath: tempPath)
-                }
-                DispatchQueue.main.async {
-                    let myPreView: CPDFListView = self.preView as! CPDFListView
-                    myPreView.toolMode = .textToolMode
-
-                    /// 刷新预览视图
-                    self.preView.layoutDocumentView()
-                    
-                    self.preView.displayBox = .cropBox
-                }
-                
-                /// 裁剪
-                self.view.window?.endSheet((self.windowController?.window)!)
-                self.windowController = nil
-                
-//                self.cropCurrentPage(in: NSZeroSize)
-                
-                let count: Int = Int(self.preView.document!.pageCount)
-//                let PDFView = KMCropPDFView()
-//                PDFView.frame = self.preView.bounds
-//                self.preView.superview?.addSubview(PDFView)
-//                PDFView.document = CPDFDocument(url: self.preView.document.documentURL)
-//                for i in 0 ..< count {
-//                    let page: KMCropPDFPage = KMCropPDFPage()
-//                    page.setBounds(NSMakeRect(0, 0, 200, 200), for: .mediaBox)
-//                    let cropPage = self.preView.document.page(at: UInt(i))
-//                    page.cropDrawingPage = cropPage
-////                    self.preView.document.insertPageObject(page, at: UInt(i))
-////                    self.preView.document.removePage(at: UInt(i))
-//                    let currentPage = page.cropDrawingPage
-//                    let drawInfo = KMCropInfo()
-//                    drawInfo.drawPage = cropPage
-//                    PDFView.drawInfo.append(drawInfo)
-//                    PDFView.document.insertPageObject(page, at: UInt(i))
-//                }
-                
-                /// 保存到临时路径
-//                let toPath: String = self.preView.document.documentURL.lastPathComponent
-//                let documentPath = NSTemporaryDirectory()
-//                let tempPath: String = "\(documentPath)/\(toPath)"
-//                if (FileManager.default.fileExists(atPath: tempPath)) {
-//                    try?FileManager.default.removeItem(atPath: tempPath)
-//                }
-//
-//                let result = PDFView.document.write(to: URL(fileURLWithPath: tempPath))
-//
-//                DispatchQueue.main.async {
-//                    let myPreView: CPDFListView = self.preView as! CPDFListView
-//                    myPreView.toolMode = .textToolMode
-//
-//                    self.preView.layoutDocumentView()
-//                }
-            }
-            
-        }
-    }
-    
-//    @objc func preViewSelectionDidChange(sender: NSNotification) {
-//        if (self.preView.isEqual(to: sender.object)) {
-////            self.preView.currentSelection
-//            print("1111111111")
-//
-////            NSUInteger eventMask = NSEventMaskLeftMouseUp | NSEventMaskLeftMouseDragged;
-////            let theEvent = [self.view.window.nextEventMatchingMask:NSEventMaskLeftMouseUp];
-////            let theEvent = self.view.window?.nextEvent(matching: .leftMouseUp.union(.rightMouseUp).union(.otherMouseUp))
-////            if (theEvent?.type == .leftMouseUp) {
-//            let myPreview: CPDFListView = self.preView as! CPDFListView
-//            if (NSIsEmptyRect(myPreview.selectionRect)) {
-//                print("end")
-//            }
-//        }
-//    }
-    
-    override func viewDidAppear() {
-        super.viewDidAppear()
-        
-//        if (self.documentURL != nil) {
-//            self.testPreView.document = PDFDocument(url: self.documentURL)
-//        }
-    }
-    
-    override func topItemClick(index: Int) {
-        let menu = NSMenu()
-        
-        let titles = ["裁剪当前页面 - 白边距", "裁剪所有页面 - 自动", "自定义裁剪区域"]
-        for title in titles {
-            let item = NSMenuItem(title: title, action: #selector(itemAction), target: self)
-            item.tag = titles.firstIndex(of: title)!
-            menu.addItem(item)
-        }
-        
-        menu.popUp(positioning: nil, at: NSPoint(x: self.topBarView.frame.midX-100, y: 0), in: self.topBarView)
-    }
-    
-    @objc private func itemAction(sender: NSMenuItem) {
-        if (sender.tag == 0) {
-            /// 裁剪当前页面 - 白边距
-            self.tipBox.isHidden = true
-            cropCurrentPage()
-            return
-        }
-        
-        if (sender.tag == 1) {
-            /// 裁剪所有页面 - 自动
-            self.tipBox.isHidden = true
-            cropAllPate()
-            return
-        }
-        
-        //// 自定义裁剪区域
-        let myPreView: CPDFListView = self.preView as! CPDFListView
-        myPreView.toolMode = .selectToolMode
-        
-        self.preView.autoScales = true
-        self.preView.autoScales = false
-        var pageHeight: CGFloat = NSHeight(self.preView.currentPage().bounds(for: self.preView.displayBox))
-        if (self.preView.displaysPageBreaks) {
-            pageHeight += 8
-        }
-        
-        var scaleFactor: CGFloat = fmax(self.preView.minimumScaleFactor, NSHeight(self.preView.frame)/pageHeight)
-//        if (scaleFactor < self.preView.scaleFactor) {
-            self.preView.scaleFactor = scaleFactor
-//        }
-        
-        self.tipBox.isHidden = false
-        self.tipView.setString(string: "请框选裁剪区域")
-    }
-    
-    private func cropCurrentPage(in pageSize: NSSize) {
-        let myPreView: CPDFListView = self.preView as! CPDFListView
-        var rect = NSIntegralRect(myPreView.currentSelectionRect())
-        var page: CPDFPage?
-        if ((myPreView.currentSelectionPage()) != nil) {
-            page = myPreView.currentSelectionPage()
-        } else {
-            page = myPreView.currentPage()
-        }
-
-        if (NSIsEmptyRect(rect)) {
-            rect = getPageForegroundBox(page!)
-        }
-        
-        let tiffData = page!.PDFListViewTIFFData(for: rect)
-        
-        let index: UInt = (page?.pageIndex())!
-        
-        var newRect = NSIntersectionRect(rect, (page?.bounds(for: .mediaBox))!)
-        page?.setBounds(newRect, for: .cropBox)
-        
-        self.preView.document.removePage(at: index)
-        
-//        let newPage: CPDFPage = CPDFPage(image: NSImage(data: tiffData!))
-//        newPage.setBounds(NSMakeRect(0, 0, pageSize.width, pageSize.height), for: .cropBox)
-//        let result = self.preView.document.insertPageObject(newPage, at: index)
-        
-        let result = self.preView.document.insertPage(pageSize, at: index)
-//        var newDoc = CPDFDocument()
-        
-        /// 刷新预览视图
-        self.preView.layoutDocumentView()
-        
-        self.preView.displayBox = .cropBox
-    }
-    
-    private func cropAllPate() {
-        var size = NSZeroSize
-        for i in 0 ..< self.preView.document.pageCount {
-            let page = self.preView.document.page(at: i)
-            var rect = getPageForegroundBox(page!)
-            size.width = fmax(size.width, NSWidth(rect))
-            size.height = fmax(size.height, NSHeight(rect))
-        }
-        
-        var rectArray: Array<NSRect> = []
-        for i in 0 ..< self.preView.document.pageCount {
-            let page = self.preView.document.page(at: i)
-            var rect = getPageForegroundBox(page!)
-            var bounds: NSRect = (page?.bounds(for: .mediaBox))!
-            if (rect.minX - bounds.minX > bounds.maxX-rect.maxX) {
-                rect.origin.x = rect.maxX-size.width
-            }
-            
-            rect.origin.y = rect.maxY-size.height
-            rect.size = size
-            
-            if (NSWidth(rect) > NSWidth(bounds)) {
-                rect.size.width = NSWidth(bounds)
-            }
-            if (NSHeight(rect) > NSHeight(bounds)) {
-                rect.size.height = NSHeight(bounds)
-            }
-            
-            if (NSMinX(rect) < NSMinX(bounds)) {
-                rect.origin.x = NSMinX(bounds)
-            } else if (NSMaxX(rect) > NSMaxX(bounds)) {
-                rect.origin.x = NSMaxX(bounds) - NSWidth(rect)
-            }
-            
-            if (NSMinY(rect) < NSMinY(bounds)) {
-                rect.origin.y = NSMinY(bounds)
-            } else if (NSMaxY(rect) > NSMaxY(bounds)) {
-                rect.origin.y = NSMaxY(bounds) - NSHeight(rect)
-            }
-            
-            rectArray.append(rect)
-        }
-        
-        cropPages(to: rectArray)
-    }
-    
-    private func cropPages(to rects: Array<NSRect>) {
-        let currentPage = self.preView.currentPage()
-        let visibleRect: NSRect = self.preView.convert(self.preView.convert(self.preView.documentView().visibleRect, from: self.preView.documentView()), to: self.preView.currentPage())
-        
-        var oldRectArray: Array<NSRect> = []
-        for i in 0 ..< self.preView.document.pageCount {
-            let page = self.preView.document.page(at: i)
-            var rect = NSIntersectionRect(rects[Int(i)], (page?.bounds(for: .mediaBox))!)
-            let oldRect = page?.bounds(for: .cropBox)
-            oldRectArray.append(oldRect!)
-            
-            page?.setBounds(rect, for: .cropBox)
-        }
-        
-        /// 刷新预览视图
-        self.preView.layoutDocumentView()
-        
-        self.preView.displayBox = .cropBox
-        
-        self.preView.go(to: currentPage)
-        self.preView.go(to: visibleRect, on: currentPage)
-
-    }
-    
-    private func cropCurrentPage() {
-        let myPreView: CPDFListView = self.preView as! CPDFListView
-        var rect = NSIntegralRect(myPreView.currentSelectionRect())
-        var page: CPDFPage?
-        if ((myPreView.currentSelectionPage()) != nil) {
-            page = myPreView.currentSelectionPage()
-        } else {
-            page = myPreView.currentPage()
-        }
-
-        if (NSIsEmptyRect(rect)) {
-            rect = getPageForegroundBox(page!)
-        }
-        
-        let index: UInt = (page?.pageIndex())!
-        cropPage(at: index, in: rect)
-    }
-    
-    func cropPage(at index: UInt, in rect: NSRect) {
-        let oldRect = self.preView.document.page(at: index)?.bounds(for: .cropBox)
-        /// undo \ redo 处理
-        
-//        NSUndoManager *undoManager = [[self document] undoManager];
-//        let undoManager = UndoManager()
-//        (undoManager.prepare(withInvocationTarget: self) as! KMCropPreviewController).cropPage(at: index, in: oldRect!)
-//        undoManager.setActionName(NSLocalizedString("Crop Page", comment: "Undo action name"))
-//        [[self document] undoableActionIsDiscardable];
-        
-        var page = self.preView.document.page(at: index)
-        var newRect = NSIntersectionRect(rect, (page?.bounds(for: .mediaBox))!)
-        page?.setBounds(newRect, for: .cropBox)
-        
-        /// 刷新预览视图
-        self.preView.layoutDocumentView()
-        
-        self.preView.displayBox = .cropBox
-    }
-
-    private func getPageForegroundBox(_ page: CPDFPage) -> NSRect {
-        let marginWidth: CGFloat = 10
-        let marginHeight: CGFloat = 10
-        
-        let imageRep = newBitmapImageRepForBox(page, .mediaBox)
-        let bounds = page.bounds(for: .mediaBox)
-        var foregroundBox = imageRep.foregroundRect()
-        if (imageRep == nil) {
-            foregroundBox = bounds
-        } else if (NSIsEmptyRect(foregroundBox)) {
-            let centerPoint = NSPoint(x: bounds.midX, y: bounds.midY)
-            let origin = NSPoint(x: round(centerPoint.x), y: round(centerPoint.y))
-            foregroundBox.origin = origin
-            foregroundBox.size = NSZeroSize
-        } else {
-            let origin = NSPoint(x: foregroundBox.origin.x+bounds.origin.x, y: foregroundBox.origin.y+bounds.origin.y)
-            foregroundBox.origin = origin
-        }
-        
-        return NSIntegralRect(NSInsetRect(foregroundBox, -marginWidth, -marginHeight))
-    }
-    
-    private func newBitmapImageRepForBox(_ page: CPDFPage, _ box: CPDFDisplayBox) -> NSBitmapImageRep {
-        let bounds = page.bounds(for: box)
-        var imageRep = NSBitmapImageRep(bitmapDataPlanes: nil,
-                                        pixelsWide: Int(NSWidth(bounds)),
-                                        pixelsHigh: Int(NSHeight(bounds)),
-                                        bitsPerSample: 8,
-                                        samplesPerPixel: 4,
-                                        hasAlpha: true,
-                                        isPlanar: false,
-                                        colorSpaceName: .calibratedRGB,
-                                        bitmapFormat: NSBitmapImageRep.Format(rawValue: 0),
-                                        bytesPerRow: 0,
-                                        bitsPerPixel: 32)
-        
-        if (imageRep != nil) {
-            NSGraphicsContext.saveGraphicsState()
-            NSGraphicsContext.current = NSGraphicsContext.init(bitmapImageRep: imageRep!)
-            NSGraphicsContext.current?.imageInterpolation = .none
-            NSGraphicsContext.current?.shouldAntialias = false
-            if (page.rotation != 0) {
-                var transform = NSAffineTransform()
-                if (page.rotation == 90) {
-                    transform.translateX(by: NSWidth(bounds), yBy: 0)
-                } else if (page.rotation == 180) {
-                    transform.translateX(by: NSHeight(bounds), yBy: NSWidth(bounds))
-                } else if (page.rotation == 270) {
-                    transform.translateX(by: 0, yBy: NSHeight(bounds))
-                }
-                
-                transform.rotate(byDegrees: CGFloat(page.rotation))
-                transform.concat()
-            }
-            
-            page.draw(with: box, to: (NSGraphicsContext.current?.cgContext as! CGContext))
-//            page.draw(with: box)
-            NSGraphicsContext.current?.imageInterpolation = .default
-            NSGraphicsContext.restoreGraphicsState()
-        }
-        
-        return imageRep!
-    }
-}
-
-extension KMCropPreviewController: CPDFViewDelegate {
-    func pdfViewEditingSelectionDidChanged(_ pdfView: CPDFView!) {
-        
-    }
-}
-
-extension KMCropPreviewController: CPDFListViewDelegate {
-    func pdfListViewDidSelectionEnd(_ pdfListView: CPDFListView!) {
-        if (self.preView.isEqual(to: pdfListView)) {
-            self.tipView.setString(string: "请按 Enter 键确定裁剪区域")
-        }
-    }
-}
-
-//extension PDFPage {
-//    func getPageForegroundBox() -> NSRect {
-//        let marginWidth: CGFloat = 10
-//        let marginHeight: CGFloat = 10
-//
-//        let imageRep = newBitmapImageRepForBox(.mediaBox)
-//        let bounds = bounds(for: .mediaBox)
-//        var foregroundBox = imageRep.foregroundRect()
-//        if (imageRep == nil) {
-//            foregroundBox = bounds
-//        } else if (NSIsEmptyRect(foregroundBox)) {
-//            let centerPoint = NSPoint(x: bounds.midX, y: bounds.midY)
-//            let origin = NSPoint(x: round(centerPoint.x), y: round(centerPoint.y))
-//            foregroundBox.origin = origin
-//            foregroundBox.size = NSZeroSize
-//        } else {
-//            let origin = NSPoint(x: foregroundBox.origin.x+bounds.origin.x, y: foregroundBox.origin.y+bounds.origin.y)
-//            foregroundBox.origin = origin
-//        }
-//
-//        return NSIntegralRect(NSInsetRect(foregroundBox, -marginWidth, -marginHeight))
-//    }
-//
-//    func newBitmapImageRepForBox(_ box: PDFDisplayBox) -> NSBitmapImageRep {
-//        let bounds = bounds(for: box)
-//        let imageRep = NSBitmapImageRep(bitmapDataPlanes: nil,
-//                                        pixelsWide: Int(NSWidth(bounds)),
-//                                        pixelsHigh: Int(NSHeight(bounds)),
-//                                        bitsPerSample: 8,
-//                                        samplesPerPixel: 4,
-//                                        hasAlpha: true,
-//                                        isPlanar: false,
-//                                        colorSpaceName: .calibratedRGB,
-//                                        bitmapFormat: NSBitmapImageRep.Format(rawValue: 0),
-//                                        bytesPerRow: 0,
-//                                        bitsPerPixel: 32)
-//
-//        if (imageRep != nil) {
-//            NSGraphicsContext.saveGraphicsState()
-//            NSGraphicsContext.current = NSGraphicsContext.init(bitmapImageRep: imageRep!)
-//            NSGraphicsContext.current?.imageInterpolation = .none
-//            NSGraphicsContext.current?.shouldAntialias = false
-//            if (self.rotation != 0) {
-//                let transform = NSAffineTransform()
-//                if (self.rotation == 90) {
-//                    transform.translateX(by: NSWidth(bounds), yBy: 0)
-//                } else if (self.rotation == 180) {
-//                    transform.translateX(by: NSHeight(bounds), yBy: NSWidth(bounds))
-//                } else if (self.rotation == 270) {
-//                    transform.translateX(by: 0, yBy: NSHeight(bounds))
-//                }
-//
-//                transform.rotate(byDegrees: CGFloat(self.rotation))
-//                transform.concat()
-//            }
-//
-//            draw(with: box)
-//            NSGraphicsContext.current?.imageInterpolation = .default
-//            NSGraphicsContext.restoreGraphicsState()
-//        }
-//
-//        return imageRep!
-//    }
-//}
- 

+ 0 - 22
PDF Office/PDF Master/Class/PDFTools/Crop/Controller/KMCropPreviewController.xib

@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
-    <dependencies>
-        <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
-        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
-    </dependencies>
-    <objects>
-        <customObject id="-2" userLabel="File's Owner" customClass="KMCropPreviewController" customModule="PDF_Reader_Pro" customModuleProvider="target">
-            <connections>
-                <outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
-            </connections>
-        </customObject>
-        <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
-        <customObject id="-3" userLabel="Application" customClass="NSObject"/>
-        <customView id="Hz6-mo-xeY">
-            <rect key="frame" x="0.0" y="0.0" width="480" height="272"/>
-            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
-            <point key="canvasLocation" x="132" y="-72"/>
-        </customView>
-    </objects>
-</document>

+ 0 - 113
PDF Office/PDF Master/Class/PDFTools/Crop/KMCropSettingWindowController.swift

@@ -1,113 +0,0 @@
-//
-//  KMCropSettingWindowController.swift
-//  PDF Reader Pro
-//
-//  Created by tangchao on 2022/12/30.
-//
-
-import Cocoa
-
-typealias KMCropSettingWindowControllerItemClick = (_ index: Int) -> ()
-class KMCropSettingWindowController: NSWindowController {
-
-    @IBOutlet weak var titleLabel: NSTextField!
-    @IBOutlet weak var pageRangeBox: NSBox!
-    @IBOutlet weak var pageSizeBox: NSBox!
-    @IBOutlet weak var applyButton: NSButton!
-    @IBOutlet weak var cancelButton: NSButton!
-    
-    private var pagePageView = KMConvertPageRangeSettingItemView.createFromNib()
-    private var pageSizeView = KMCropSettingPageSizeView()
-    
-    var itemClick: KMCropSettingWindowControllerItemClick!
-    
-    var pageCount: Int = 0
-    var pageRangeIndex: Int = 0
-    var pageRangePages: Array<Int> = []
-    var pageSize: String = "None"
-    
-    override func windowDidLoad() {
-        super.windowDidLoad()
-
-        self.titleLabel.stringValue = "裁剪设置"
-        
-        let pageRangeView = self.pagePageView
-        pageRangeView?.frame = self.pageRangeBox.contentView!.bounds
-        pageRangeView?.autoresizingMask = NSView.AutoresizingMask(rawValue: 18)
-        self.pageRangeBox.contentView?.addSubview(pageRangeView!)
-        pageRangeView!.pageSizeComboBox.removeAllItems()
-        pageRangeView!.pageSizeComboBox.addItems(withObjectValues: ["当前页面","全部页面", "奇数页面", "偶数页面", "自定义页面"])
-        pageRangeView!.pageSizeComboBox.selectItem(at: 0)
-        
-        pageRangeView?.isTextDidEndCallback = true
-        
-        pageRangeView?.itemClick = { [weak self] index, _ in
-            
-            self?.pageRangeIndex = index
-        }
-        
-        pageRangeView?.textDidEndEditingCallback = {
-            [self] (textString: String) in
-
-            let array = KMPageRangeTools.findSelectPage(pageRangeString: textString, pageCount: self.pageCount)
-            if (array.count <= 0) {
-                let alert = NSAlert()
-                alert.alertStyle = .warning
-                alert.messageText = NSLocalizedString("Invalid page range or the page number is out of range. Please try again.", comment: "")
-                alert.runModal()
-                return
-            }
-
-            self.pageRangePages.removeAll()
-            for i in array {
-                self.pageRangePages.append(i)
-            }
-        }
-        
-        let pageSizeView = self.pageSizeView
-        pageSizeView.frame = self.pageSizeBox.contentView!.bounds
-        pageSizeView.autoresizingMask = NSView.AutoresizingMask(rawValue: 18)
-        self.pageSizeBox.contentView?.addSubview(pageSizeView)
-        pageSizeView.itemClick = {
-            (index: Int, value: Any) in
-            
-            self.pageSize = value as! String
-        }
-        
-        cancelButton.title = NSLocalizedString("取消", comment: "")
-        cancelButton.isBordered = false
-        cancelButton.wantsLayer = true
-        cancelButton.layer?.borderWidth = 1
-        cancelButton.layer?.borderColor = NSColor.black.cgColor
-        cancelButton.layer?.cornerRadius = 4
-        cancelButton.target = self
-        cancelButton.action = #selector(cancelButtonAction)
-        
-        applyButton.title = NSLocalizedString("应用", comment: "")
-        applyButton.isBordered = false
-        applyButton.wantsLayer = true
-        applyButton.layer?.cornerRadius = 4
-        applyButton.target = self
-        applyButton.action = #selector(applyButtonAction)
-        applyButton.layer?.backgroundColor = NSColor.black.cgColor
-        applyButton.attributedTitle = NSMutableAttributedString(string: applyButton.title, attributes: [NSAttributedString.Key.foregroundColor : NSColor.white])
-        
-    }
-    
-    @objc func cancelButtonAction() {
-        guard let callback = self.itemClick else {
-            return
-        }
-        
-        callback(1)
-    }
-    
-    @objc func applyButtonAction() {
-        guard let callback = self.itemClick else {
-            return
-        }
-        
-        callback(2)
-    }
-    
-}

+ 0 - 161
PDF Office/PDF Master/Class/PDFTools/Crop/KMCropSettingWindowController.xib

@@ -1,161 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22155" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
-    <dependencies>
-        <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
-        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
-    </dependencies>
-    <objects>
-        <customObject id="-2" userLabel="File's Owner" customClass="KMCropSettingWindowController" customModule="PDF_Master" customModuleProvider="target">
-            <connections>
-                <outlet property="applyButton" destination="4S4-1o-RqV" id="wA8-IB-9JC"/>
-                <outlet property="cancelButton" destination="XXB-iS-n7Y" id="NBS-hq-aJj"/>
-                <outlet property="pageRangeBox" destination="S9G-Fl-99J" id="gLz-vr-JZL"/>
-                <outlet property="pageSizeBox" destination="dTT-1D-0cu" id="Xcn-gH-BiB"/>
-                <outlet property="titleLabel" destination="xlm-BU-ieV" id="ucI-2C-Raw"/>
-                <outlet property="window" destination="F0z-JX-Cv5" id="gIp-Ho-8D9"/>
-            </connections>
-        </customObject>
-        <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
-        <customObject id="-3" userLabel="Application" customClass="NSObject"/>
-        <window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="F0z-JX-Cv5">
-            <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
-            <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
-            <rect key="contentRect" x="196" y="240" width="340" height="300"/>
-            <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1415"/>
-            <value key="minSize" type="size" width="340" height="300"/>
-            <value key="maxSize" type="size" width="340" height="300"/>
-            <value key="minFullScreenContentSize" type="size" width="340" height="300"/>
-            <value key="maxFullScreenContentSize" type="size" width="340" height="300"/>
-            <view key="contentView" id="se5-gp-TjO">
-                <rect key="frame" x="0.0" y="0.0" width="340" height="300"/>
-                <autoresizingMask key="autoresizingMask"/>
-                <subviews>
-                    <box boxType="custom" borderWidth="0.0" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="uHB-hJ-FVd">
-                        <rect key="frame" x="0.0" y="256" width="340" height="44"/>
-                        <view key="contentView" id="PVS-CP-Yiw">
-                            <rect key="frame" x="0.0" y="0.0" width="340" height="44"/>
-                            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                            <subviews>
-                                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="xlm-BU-ieV">
-                                    <rect key="frame" x="18" y="13" width="44" height="19"/>
-                                    <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="ofd-Jo-wTH">
-                                        <font key="font" metaFont="system" size="16"/>
-                                        <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
-                                        <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
-                                    </textFieldCell>
-                                </textField>
-                            </subviews>
-                            <constraints>
-                                <constraint firstItem="xlm-BU-ieV" firstAttribute="leading" secondItem="PVS-CP-Yiw" secondAttribute="leading" constant="20" id="3de-Sa-hy2"/>
-                                <constraint firstItem="xlm-BU-ieV" firstAttribute="top" secondItem="PVS-CP-Yiw" secondAttribute="top" constant="12" id="n9r-13-CVH"/>
-                            </constraints>
-                        </view>
-                        <constraints>
-                            <constraint firstAttribute="height" constant="44" id="Z30-8i-q8x"/>
-                        </constraints>
-                    </box>
-                    <box boxType="custom" borderWidth="0.0" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="Kpc-6y-Eh9">
-                        <rect key="frame" x="0.0" y="60" width="340" height="196"/>
-                        <view key="contentView" id="XGW-Wv-mGn">
-                            <rect key="frame" x="0.0" y="0.0" width="340" height="196"/>
-                            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                            <subviews>
-                                <box boxType="custom" borderWidth="0.0" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="S9G-Fl-99J">
-                                    <rect key="frame" x="0.0" y="106" width="340" height="70"/>
-                                    <view key="contentView" id="IbC-cl-6rm">
-                                        <rect key="frame" x="0.0" y="0.0" width="340" height="70"/>
-                                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                                    </view>
-                                    <constraints>
-                                        <constraint firstAttribute="height" constant="70" id="9fx-SG-jBA"/>
-                                    </constraints>
-                                </box>
-                                <box boxType="custom" borderWidth="0.0" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="dTT-1D-0cu">
-                                    <rect key="frame" x="16" y="24" width="308" height="70"/>
-                                    <view key="contentView" id="oJS-bR-VrK">
-                                        <rect key="frame" x="0.0" y="0.0" width="308" height="70"/>
-                                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                                    </view>
-                                    <constraints>
-                                        <constraint firstAttribute="height" constant="70" id="Qcs-Q4-KuX"/>
-                                    </constraints>
-                                </box>
-                            </subviews>
-                            <constraints>
-                                <constraint firstItem="S9G-Fl-99J" firstAttribute="top" secondItem="XGW-Wv-mGn" secondAttribute="top" constant="20" id="3ws-YI-oFB"/>
-                                <constraint firstItem="S9G-Fl-99J" firstAttribute="leading" secondItem="XGW-Wv-mGn" secondAttribute="leading" id="Rks-gZ-CEA"/>
-                                <constraint firstItem="dTT-1D-0cu" firstAttribute="top" secondItem="S9G-Fl-99J" secondAttribute="bottom" constant="12" id="S1b-5V-LXQ"/>
-                                <constraint firstAttribute="trailing" secondItem="dTT-1D-0cu" secondAttribute="trailing" constant="16" id="VqC-Bm-RlP"/>
-                                <constraint firstAttribute="trailing" secondItem="S9G-Fl-99J" secondAttribute="trailing" id="ZfF-xr-lk7"/>
-                                <constraint firstItem="dTT-1D-0cu" firstAttribute="leading" secondItem="XGW-Wv-mGn" secondAttribute="leading" constant="16" id="d8Y-Dm-CJH"/>
-                            </constraints>
-                        </view>
-                    </box>
-                    <box boxType="custom" borderWidth="0.0" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="XU2-wI-X7Q">
-                        <rect key="frame" x="0.0" y="0.0" width="340" height="60"/>
-                        <view key="contentView" id="qcz-Dz-V8O">
-                            <rect key="frame" x="0.0" y="0.0" width="340" height="60"/>
-                            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                            <subviews>
-                                <box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="2L8-A8-1Up">
-                                    <rect key="frame" x="0.0" y="57" width="340" height="5"/>
-                                </box>
-                                <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="4S4-1o-RqV">
-                                    <rect key="frame" x="224" y="14" width="100" height="32"/>
-                                    <buttonCell key="cell" type="bevel" title="Button" bezelStyle="rounded" alignment="center" imageScaling="proportionallyDown" inset="2" id="XNo-Og-jMa">
-                                        <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
-                                        <font key="font" metaFont="system"/>
-                                    </buttonCell>
-                                    <constraints>
-                                        <constraint firstAttribute="width" constant="100" id="6fn-9K-TYQ"/>
-                                        <constraint firstAttribute="height" constant="32" id="xnD-3s-RQ0"/>
-                                    </constraints>
-                                </button>
-                                <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="XXB-iS-n7Y">
-                                    <rect key="frame" x="112" y="14" width="100" height="32"/>
-                                    <buttonCell key="cell" type="bevel" title="Button" bezelStyle="rounded" alignment="center" imageScaling="proportionallyDown" inset="2" id="3ZJ-Dy-yKV">
-                                        <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
-                                        <font key="font" metaFont="system"/>
-                                    </buttonCell>
-                                    <constraints>
-                                        <constraint firstAttribute="height" constant="32" id="eg6-3u-8Oe"/>
-                                        <constraint firstAttribute="width" constant="100" id="thm-Sz-L99"/>
-                                    </constraints>
-                                </button>
-                            </subviews>
-                            <constraints>
-                                <constraint firstAttribute="trailing" secondItem="2L8-A8-1Up" secondAttribute="trailing" id="8DE-bs-0j0"/>
-                                <constraint firstItem="4S4-1o-RqV" firstAttribute="centerY" secondItem="qcz-Dz-V8O" secondAttribute="centerY" id="IuH-ai-vfH"/>
-                                <constraint firstItem="2L8-A8-1Up" firstAttribute="top" secondItem="qcz-Dz-V8O" secondAttribute="top" id="LrM-Mn-Toi"/>
-                                <constraint firstItem="2L8-A8-1Up" firstAttribute="leading" secondItem="qcz-Dz-V8O" secondAttribute="leading" id="MP4-4F-qpm"/>
-                                <constraint firstItem="XXB-iS-n7Y" firstAttribute="centerY" secondItem="qcz-Dz-V8O" secondAttribute="centerY" id="mIg-JJ-lLA"/>
-                                <constraint firstAttribute="trailing" secondItem="4S4-1o-RqV" secondAttribute="trailing" constant="16" id="s9T-Tb-hjR"/>
-                                <constraint firstItem="4S4-1o-RqV" firstAttribute="leading" secondItem="XXB-iS-n7Y" secondAttribute="trailing" constant="12" id="xF5-aI-RMX"/>
-                            </constraints>
-                        </view>
-                        <constraints>
-                            <constraint firstAttribute="height" constant="60" id="fzc-XS-kuC"/>
-                        </constraints>
-                    </box>
-                </subviews>
-                <constraints>
-                    <constraint firstItem="uHB-hJ-FVd" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" id="1nQ-Fh-8uj"/>
-                    <constraint firstAttribute="trailing" secondItem="XU2-wI-X7Q" secondAttribute="trailing" id="3NZ-S0-QvM"/>
-                    <constraint firstAttribute="bottom" secondItem="XU2-wI-X7Q" secondAttribute="bottom" id="KKB-Q4-EI0"/>
-                    <constraint firstItem="XU2-wI-X7Q" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" id="PTg-MF-Wfr"/>
-                    <constraint firstItem="uHB-hJ-FVd" firstAttribute="top" secondItem="se5-gp-TjO" secondAttribute="top" id="Xh1-8r-7sg"/>
-                    <constraint firstItem="Kpc-6y-Eh9" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" id="Xwy-5I-n2e"/>
-                    <constraint firstItem="Kpc-6y-Eh9" firstAttribute="top" secondItem="uHB-hJ-FVd" secondAttribute="bottom" id="cQl-6c-q6R"/>
-                    <constraint firstAttribute="trailing" secondItem="uHB-hJ-FVd" secondAttribute="trailing" id="gHR-hf-aH4"/>
-                    <constraint firstAttribute="trailing" secondItem="Kpc-6y-Eh9" secondAttribute="trailing" id="jSY-MH-l08"/>
-                    <constraint firstItem="XU2-wI-X7Q" firstAttribute="top" secondItem="Kpc-6y-Eh9" secondAttribute="bottom" id="xfT-k0-Kbb"/>
-                </constraints>
-            </view>
-            <connections>
-                <outlet property="delegate" destination="-2" id="0bl-1N-AYu"/>
-            </connections>
-            <point key="canvasLocation" x="-10" y="144"/>
-        </window>
-    </objects>
-</document>

File diff suppressed because it is too large
+ 0 - 1106
PDF Office/PDF Master/Class/PDFTools/Crop/KMPDFCropWindowController.swift


+ 0 - 818
PDF Office/PDF Master/Class/PDFTools/Crop/KMPDFCropWindowController.xib

@@ -1,818 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22155" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
-    <dependencies>
-        <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
-        <plugIn identifier="com.apple.pdfkit.ibplugin" version="22155"/>
-        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
-    </dependencies>
-    <objects>
-        <customObject id="-2" userLabel="File's Owner" customClass="KMPDFCropWindowController" customModule="PDF_Master" customModuleProvider="target">
-            <connections>
-                <outlet property="applyLabel" destination="fsc-HQ-jlC" id="5eF-bA-Wva"/>
-                <outlet property="applyPopUpButton" destination="g6f-5M-brm" id="stz-Ar-qxL"/>
-                <outlet property="bottomDistanceText" destination="KAo-LQ-YE5" id="2X3-p5-60y"/>
-                <outlet property="bottomLabel" destination="VfD-a0-qeT" id="6mV-kg-XTx"/>
-                <outlet property="bottomStepper" destination="pOe-AK-MAI" id="G4R-kh-3Pc"/>
-                <outlet property="cancelButton" destination="cdg-Zn-VLp" id="CRh-q3-gIB"/>
-                <outlet property="centerButton" destination="fg9-32-HZP" id="nHf-hb-WXy"/>
-                <outlet property="cropLabel" destination="eWt-MA-l9o" id="VaD-fq-jNS"/>
-                <outlet property="currentPageIndexTextF" destination="YjI-Va-fa7" id="vAh-vV-ZML"/>
-                <outlet property="customButton" destination="CRu-dV-3vm" id="GhU-L0-eIa"/>
-                <outlet property="fixedSizeButton" destination="dHM-AO-rF7" id="pqT-0J-tf6"/>
-                <outlet property="heightLabel" destination="AoW-07-9El" id="QQX-lB-OZW"/>
-                <outlet property="heightText" destination="gGH-DJ-pie" id="M6f-V7-W05"/>
-                <outlet property="leftDistanceText" destination="Sr3-sJ-ORG" id="abE-od-Zef"/>
-                <outlet property="leftLabel" destination="UhA-JH-vB2" id="ZOs-uy-DMr"/>
-                <outlet property="leftStepper" destination="dBR-dC-b73" id="pKd-Fi-t1A"/>
-                <outlet property="marginBox" destination="8Xu-vw-ZUb" id="uuB-lC-Ixd"/>
-                <outlet property="marginLabel" destination="2x8-XK-ICO" id="6Rw-o3-0OU"/>
-                <outlet property="marginsButton" destination="DrW-yP-2Z0" id="uSb-KG-hH5"/>
-                <outlet property="nextPageButton" destination="28h-kr-kE6" id="FKS-GE-ybk"/>
-                <outlet property="pageRangeComboBox" destination="Ynj-Y3-ZFe" id="K6x-qO-c0t"/>
-                <outlet property="pageRangeLabel" destination="i2R-g4-Mfv" id="ao7-O9-TgA"/>
-                <outlet property="pageSizeBox" destination="Xul-oG-2l2" id="IBk-AM-BV3"/>
-                <outlet property="pageSizeLabel" destination="z3z-tZ-TKL" id="qBj-33-U0y"/>
-                <outlet property="pageSizePopUpButton" destination="EdY-87-wsh" id="jHV-uN-vaJ"/>
-                <outlet property="pdfView" destination="6S3-N2-DlE" id="Uhv-jY-ZXk"/>
-                <outlet property="previewPageButton" destination="yhQ-R4-wac" id="17q-I6-8fc"/>
-                <outlet property="printButton" destination="TXN-MH-f2b" id="GJN-u3-uEU"/>
-                <outlet property="proportButton" destination="1q3-OF-DR8" id="8UJ-RK-acM"/>
-                <outlet property="revertButton" destination="Awz-ZL-GW8" id="zCB-Hc-7XD"/>
-                <outlet property="rightDistanceText" destination="bf7-ec-UrO" id="TLK-8e-8Ls"/>
-                <outlet property="rightLabel" destination="sej-ZU-2AI" id="cSY-VK-2ae"/>
-                <outlet property="rightStepper" destination="AgH-Jp-OdB" id="kQq-X7-wVl"/>
-                <outlet property="saveButton" destination="XMR-VG-lFR" id="ywB-Hw-2Rm"/>
-                <outlet property="topDistanceText" destination="wNO-q7-yax" id="3gz-Sd-XDY"/>
-                <outlet property="topLabel" destination="ZQw-Cw-7NC" id="8dY-p5-9ho"/>
-                <outlet property="topStepper" destination="yBy-iX-BmZ" id="Rlc-Zz-Xnp"/>
-                <outlet property="totalPageCountLabel" destination="Jsy-8K-KJR" id="pIH-DZ-UnE"/>
-                <outlet property="unitLabel" destination="pjr-0K-HcJ" id="cjD-D8-aql"/>
-                <outlet property="unitPopUpButton" destination="b2t-Vm-9TN" id="bHY-K1-PmS"/>
-                <outlet property="widthLabel" destination="Fqc-0d-9Eq" id="95Y-yg-Dgn"/>
-                <outlet property="widthText" destination="nLW-Cw-sjg" id="dL4-ld-nj2"/>
-                <outlet property="window" destination="F0z-JX-Cv5" id="gIp-Ho-8D9"/>
-                <outlet property="xLabel" destination="wkn-bH-QLY" id="mjc-cY-aCt"/>
-                <outlet property="xText" destination="Ioi-Bj-Odn" id="fbl-am-oyc"/>
-                <outlet property="yLabel" destination="hv5-EF-rgN" id="ncU-92-Nsq"/>
-                <outlet property="yText" destination="urW-5G-Ad1" id="OQv-Ny-L5F"/>
-                <outlet property="zeroButton" destination="qI4-X3-ecf" id="PaD-dN-Dkb"/>
-            </connections>
-        </customObject>
-        <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
-        <customObject id="-3" userLabel="Application" customClass="NSObject"/>
-        <window title="Crop" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="F0z-JX-Cv5">
-            <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
-            <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
-            <rect key="contentRect" x="876" y="616" width="854" height="463"/>
-            <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1415"/>
-            <value key="minSize" type="size" width="854" height="463"/>
-            <value key="maxSize" type="size" width="854" height="463"/>
-            <view key="contentView" misplaced="YES" id="se5-gp-TjO">
-                <rect key="frame" x="0.0" y="0.0" width="854" height="463"/>
-                <autoresizingMask key="autoresizingMask"/>
-                <subviews>
-                    <box boxType="custom" borderWidth="0.0" cornerRadius="4" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="kXK-8s-GTS">
-                        <rect key="frame" x="40" y="90" width="240" height="386"/>
-                        <view key="contentView" id="0rf-LK-GWZ">
-                            <rect key="frame" x="0.0" y="0.0" width="240" height="386"/>
-                            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                            <subviews>
-                                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="eWt-MA-l9o">
-                                    <rect key="frame" x="-2" y="42" width="244" height="14"/>
-                                    <textFieldCell key="cell" alignment="center" title="裁剪后的页面大小:9.03 x 17.47 厘米" id="56B-hA-ufW">
-                                        <font key="font" metaFont="smallSystem"/>
-                                        <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
-                                        <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
-                                    </textFieldCell>
-                                </textField>
-                                <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="yhQ-R4-wac">
-                                    <rect key="frame" x="45" y="8" width="26" height="26"/>
-                                    <buttonCell key="cell" type="round" title="Button" bezelStyle="circular" image="NSGoLeftTemplate" imagePosition="only" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="OdT-g7-jzV">
-                                        <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
-                                        <font key="font" metaFont="system"/>
-                                    </buttonCell>
-                                    <connections>
-                                        <action selector="goPrevious:" target="-2" id="5W2-bq-gZl"/>
-                                    </connections>
-                                </button>
-                                <customView translatesAutoresizingMaskIntoConstraints="NO" id="Q9M-rC-zrL">
-                                    <rect key="frame" x="90" y="10" width="61" height="22"/>
-                                    <subviews>
-                                        <textField focusRingType="none" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="YjI-Va-fa7">
-                                            <rect key="frame" x="0.0" y="0.0" width="40" height="22"/>
-                                            <constraints>
-                                                <constraint firstAttribute="width" constant="40" id="hLg-2X-nEZ"/>
-                                                <constraint firstAttribute="height" constant="22" id="vT5-VK-GW4"/>
-                                            </constraints>
-                                            <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="center" drawsBackground="YES" id="mO4-bF-S9r">
-                                                <numberFormatter key="formatter" formatterBehavior="default10_4" usesGroupingSeparator="NO" groupingSize="0" minimumIntegerDigits="0" maximumIntegerDigits="42" id="fM2-Js-lTM">
-                                                    <real key="minimum" value="1"/>
-                                                </numberFormatter>
-                                                <font key="font" metaFont="system"/>
-                                                <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
-                                                <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
-                                            </textFieldCell>
-                                            <connections>
-                                                <outlet property="delegate" destination="-2" id="ELL-nn-bI5"/>
-                                            </connections>
-                                        </textField>
-                                        <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Jsy-8K-KJR">
-                                            <rect key="frame" x="43" y="3" width="20" height="16"/>
-                                            <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="/ 0" id="0O7-1n-hbF">
-                                                <font key="font" metaFont="system"/>
-                                                <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
-                                                <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
-                                            </textFieldCell>
-                                        </textField>
-                                    </subviews>
-                                    <constraints>
-                                        <constraint firstItem="Jsy-8K-KJR" firstAttribute="leading" secondItem="YjI-Va-fa7" secondAttribute="trailing" constant="5" id="DUd-02-E1J"/>
-                                        <constraint firstItem="Jsy-8K-KJR" firstAttribute="centerY" secondItem="YjI-Va-fa7" secondAttribute="centerY" id="SKm-AJ-tBS"/>
-                                        <constraint firstItem="YjI-Va-fa7" firstAttribute="leading" secondItem="Q9M-rC-zrL" secondAttribute="leading" id="SeG-ye-8Uo"/>
-                                        <constraint firstItem="YjI-Va-fa7" firstAttribute="top" secondItem="Q9M-rC-zrL" secondAttribute="top" id="eM9-dN-1Hx"/>
-                                        <constraint firstAttribute="bottom" secondItem="YjI-Va-fa7" secondAttribute="bottom" id="f48-oh-lJy"/>
-                                        <constraint firstAttribute="trailing" secondItem="Jsy-8K-KJR" secondAttribute="trailing" id="fEC-kt-g23"/>
-                                    </constraints>
-                                </customView>
-                                <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="28h-kr-kE6">
-                                    <rect key="frame" x="170" y="8" width="26" height="26"/>
-                                    <buttonCell key="cell" type="round" bezelStyle="circular" image="NSGoRightTemplate" imagePosition="only" alignment="center" borderStyle="border" inset="2" id="hg4-qp-aUo">
-                                        <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
-                                        <font key="font" metaFont="system"/>
-                                    </buttonCell>
-                                    <connections>
-                                        <action selector="goNext:" target="-2" id="qAT-MT-8tu"/>
-                                    </connections>
-                                </button>
-                                <pdfView autoresizesSubviews="NO" wantsLayer="YES" translatesAutoresizingMaskIntoConstraints="NO" id="6S3-N2-DlE" customClass="KMCropPDFView" customModule="PDF_Master" customModuleProvider="target">
-                                    <rect key="frame" x="0.0" y="71" width="240" height="310"/>
-                                    <constraints>
-                                        <constraint firstAttribute="width" constant="240" id="LoK-1N-BRZ"/>
-                                        <constraint firstAttribute="height" constant="310" id="Q4Z-Ka-epO"/>
-                                    </constraints>
-                                </pdfView>
-                            </subviews>
-                            <constraints>
-                                <constraint firstItem="6S3-N2-DlE" firstAttribute="top" secondItem="0rf-LK-GWZ" secondAttribute="top" constant="5" id="EFF-0B-RdK"/>
-                                <constraint firstAttribute="trailing" secondItem="6S3-N2-DlE" secondAttribute="trailing" id="FKs-LB-3Hf"/>
-                                <constraint firstItem="28h-kr-kE6" firstAttribute="leading" secondItem="Q9M-rC-zrL" secondAttribute="trailing" constant="22" id="GNS-Qh-gfZ"/>
-                                <constraint firstItem="Q9M-rC-zrL" firstAttribute="centerX" secondItem="0rf-LK-GWZ" secondAttribute="centerX" id="MWu-A0-6ry"/>
-                                <constraint firstItem="Q9M-rC-zrL" firstAttribute="leading" secondItem="yhQ-R4-wac" secondAttribute="trailing" constant="22" id="ORi-8V-Uc9"/>
-                                <constraint firstItem="Q9M-rC-zrL" firstAttribute="centerY" secondItem="yhQ-R4-wac" secondAttribute="centerY" id="Olg-Mn-ZLH"/>
-                                <constraint firstItem="Q9M-rC-zrL" firstAttribute="top" secondItem="eWt-MA-l9o" secondAttribute="bottom" constant="10" id="Sbv-Gy-JsO"/>
-                                <constraint firstItem="eWt-MA-l9o" firstAttribute="top" secondItem="6S3-N2-DlE" secondAttribute="bottom" constant="15" id="VRW-74-f6e"/>
-                                <constraint firstAttribute="bottom" secondItem="Q9M-rC-zrL" secondAttribute="bottom" constant="10" id="kcb-Ct-sRg"/>
-                                <constraint firstItem="28h-kr-kE6" firstAttribute="centerY" secondItem="Q9M-rC-zrL" secondAttribute="centerY" id="pgx-kF-k2j"/>
-                                <constraint firstItem="eWt-MA-l9o" firstAttribute="leading" secondItem="0rf-LK-GWZ" secondAttribute="leading" id="qAA-0t-00v"/>
-                                <constraint firstItem="6S3-N2-DlE" firstAttribute="leading" secondItem="0rf-LK-GWZ" secondAttribute="leading" id="ruy-k9-EvB"/>
-                                <constraint firstAttribute="trailing" secondItem="eWt-MA-l9o" secondAttribute="trailing" id="uwP-EG-kex"/>
-                            </constraints>
-                        </view>
-                        <constraints>
-                            <constraint firstAttribute="width" constant="240" id="ueJ-ht-S3Y"/>
-                        </constraints>
-                        <color key="fillColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="calibratedRGB"/>
-                    </box>
-                    <box boxType="custom" borderWidth="0.0" cornerRadius="4" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="b1A-Hw-Fy0">
-                        <rect key="frame" x="320" y="75" width="492" height="399"/>
-                        <view key="contentView" id="UOf-xL-wZf">
-                            <rect key="frame" x="0.0" y="0.0" width="492" height="399"/>
-                            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                            <subviews>
-                                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="pjr-0K-HcJ">
-                                    <rect key="frame" x="-2" y="381" width="33" height="16"/>
-                                    <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Unit:" id="bpg-sw-EDe">
-                                        <font key="font" metaFont="system"/>
-                                        <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
-                                        <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
-                                    </textFieldCell>
-                                </textField>
-                                <popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="b2t-Vm-9TN">
-                                    <rect key="frame" x="31" y="375" width="203" height="25"/>
-                                    <popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="GVT-ot-WaZ" id="lfV-Vk-Rpw">
-                                        <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
-                                        <font key="font" metaFont="menu"/>
-                                        <menu key="menu" id="rgm-Y0-ju4">
-                                            <items>
-                                                <menuItem title="Item 1" state="on" id="GVT-ot-WaZ"/>
-                                                <menuItem title="Item 2" id="jYU-P4-eDC"/>
-                                                <menuItem title="Item 3" id="6CB-gZ-K0Y"/>
-                                            </items>
-                                        </menu>
-                                    </popUpButtonCell>
-                                    <constraints>
-                                        <constraint firstAttribute="width" constant="196" id="tpV-PN-8ts"/>
-                                    </constraints>
-                                    <connections>
-                                        <action selector="buttonClicked_Unit:" target="-2" id="hR7-Co-hFQ"/>
-                                    </connections>
-                                </popUpButton>
-                                <box title="Box" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="8Xu-vw-ZUb">
-                                    <rect key="frame" x="-3" y="182" width="498" height="160"/>
-                                    <view key="contentView" id="qdU-Rn-M1d">
-                                        <rect key="frame" x="4" y="5" width="490" height="152"/>
-                                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                                        <subviews>
-                                            <popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="g6f-5M-brm">
-                                                <rect key="frame" x="73" y="123" width="118" height="25"/>
-                                                <popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="1Lb-qZ-17K" id="WP1-qg-b8h">
-                                                    <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
-                                                    <font key="font" metaFont="menu"/>
-                                                    <menu key="menu" id="NNj-Bj-Bch">
-                                                        <items>
-                                                            <menuItem title="Item 1" state="on" id="1Lb-qZ-17K"/>
-                                                            <menuItem title="Item 2" id="yp0-Qq-WGV"/>
-                                                            <menuItem title="Item 3" id="c6u-ik-G6v"/>
-                                                        </items>
-                                                    </menu>
-                                                </popUpButtonCell>
-                                                <constraints>
-                                                    <constraint firstAttribute="width" constant="111" id="hfU-TK-0Qo"/>
-                                                </constraints>
-                                                <connections>
-                                                    <action selector="buttonClicked_AppleType:" target="-2" id="AXZ-vy-aYS"/>
-                                                </connections>
-                                            </popUpButton>
-                                            <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="fsc-HQ-jlC">
-                                                <rect key="frame" x="14" y="129" width="59" height="16"/>
-                                                <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Apply to:" id="ldZ-ON-MKO">
-                                                    <font key="font" metaFont="system"/>
-                                                    <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
-                                                    <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
-                                                </textFieldCell>
-                                            </textField>
-                                            <textField focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="wNO-q7-yax">
-                                                <rect key="frame" x="45" y="97" width="88" height="21"/>
-                                                <constraints>
-                                                    <constraint firstAttribute="width" constant="88" id="PmF-UZ-sfd"/>
-                                                </constraints>
-                                                <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" title="30" drawsBackground="YES" id="ANw-Tt-hLS">
-                                                    <font key="font" metaFont="system"/>
-                                                    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
-                                                    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
-                                                </textFieldCell>
-                                                <connections>
-                                                    <outlet property="delegate" destination="-2" id="2qk-Jy-Bez"/>
-                                                </connections>
-                                            </textField>
-                                            <stepper horizontalHuggingPriority="750" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="yBy-iX-BmZ">
-                                                <rect key="frame" x="133" y="93" width="19" height="28"/>
-                                                <constraints>
-                                                    <constraint firstAttribute="width" constant="13" id="XnB-Jx-x2b"/>
-                                                </constraints>
-                                                <stepperCell key="cell" continuous="YES" alignment="left" increment="0.10000000000000001" maxValue="10000" doubleValue="1" id="hko-cS-APa"/>
-                                                <connections>
-                                                    <action selector="stepperItemClick_Distance:" target="-2" id="rrF-YH-tPV"/>
-                                                </connections>
-                                            </stepper>
-                                            <textField focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="KAo-LQ-YE5">
-                                                <rect key="frame" x="219" y="97" width="88" height="21"/>
-                                                <constraints>
-                                                    <constraint firstAttribute="width" constant="88" id="Zf3-cD-Vhk"/>
-                                                </constraints>
-                                                <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" title="30" drawsBackground="YES" id="WVr-Cz-Ib2">
-                                                    <font key="font" metaFont="system"/>
-                                                    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
-                                                    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
-                                                </textFieldCell>
-                                                <connections>
-                                                    <outlet property="delegate" destination="-2" id="Ow3-5E-cYM"/>
-                                                </connections>
-                                            </textField>
-                                            <stepper horizontalHuggingPriority="750" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="pOe-AK-MAI">
-                                                <rect key="frame" x="307" y="93" width="19" height="28"/>
-                                                <constraints>
-                                                    <constraint firstAttribute="width" constant="13" id="O3u-bw-bV8"/>
-                                                </constraints>
-                                                <stepperCell key="cell" continuous="YES" alignment="left" increment="0.10000000000000001" maxValue="10000" doubleValue="1" id="k0V-0x-bxA"/>
-                                                <connections>
-                                                    <action selector="stepperItemClick_Distance:" target="-2" id="09Y-4x-4P5"/>
-                                                </connections>
-                                            </stepper>
-                                            <textField focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Sr3-sJ-ORG">
-                                                <rect key="frame" x="45" y="66" width="88" height="21"/>
-                                                <constraints>
-                                                    <constraint firstAttribute="width" constant="88" id="XP2-as-NZr"/>
-                                                </constraints>
-                                                <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" title="30" drawsBackground="YES" id="aBr-YV-JdV">
-                                                    <font key="font" metaFont="system"/>
-                                                    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
-                                                    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
-                                                </textFieldCell>
-                                                <connections>
-                                                    <outlet property="delegate" destination="-2" id="zKP-F0-1Zr"/>
-                                                </connections>
-                                            </textField>
-                                            <stepper horizontalHuggingPriority="750" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="dBR-dC-b73">
-                                                <rect key="frame" x="133" y="63" width="19" height="28"/>
-                                                <constraints>
-                                                    <constraint firstAttribute="width" constant="13" id="AIl-5h-H54"/>
-                                                </constraints>
-                                                <stepperCell key="cell" continuous="YES" alignment="left" increment="0.10000000000000001" maxValue="10000" doubleValue="1" id="8wf-hS-65Y"/>
-                                                <connections>
-                                                    <action selector="stepperItemClick_Distance:" target="-2" id="mgU-Wl-xGe"/>
-                                                </connections>
-                                            </stepper>
-                                            <textField focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="bf7-ec-UrO">
-                                                <rect key="frame" x="219" y="66" width="88" height="21"/>
-                                                <constraints>
-                                                    <constraint firstAttribute="width" constant="88" id="sQo-fe-cAB"/>
-                                                </constraints>
-                                                <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" title="30" drawsBackground="YES" id="T0m-xI-40T">
-                                                    <font key="font" metaFont="system"/>
-                                                    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
-                                                    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
-                                                </textFieldCell>
-                                                <connections>
-                                                    <outlet property="delegate" destination="-2" id="AHx-dZ-dB6"/>
-                                                </connections>
-                                            </textField>
-                                            <stepper horizontalHuggingPriority="750" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="AgH-Jp-OdB">
-                                                <rect key="frame" x="307" y="63" width="19" height="28"/>
-                                                <constraints>
-                                                    <constraint firstAttribute="width" constant="13" id="7wZ-Sa-H5U"/>
-                                                </constraints>
-                                                <stepperCell key="cell" continuous="YES" alignment="left" increment="0.10000000000000001" maxValue="10000" doubleValue="1" id="kQk-np-RIG"/>
-                                                <connections>
-                                                    <action selector="stepperItemClick_Distance:" target="-2" id="02H-0p-ErG"/>
-                                                </connections>
-                                            </stepper>
-                                            <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="1q3-OF-DR8">
-                                                <rect key="frame" x="14" y="39" width="134" height="18"/>
-                                                <buttonCell key="cell" type="check" title="Constrain Proport" bezelStyle="regularSquare" imagePosition="left" inset="2" id="Afy-8Z-8b1">
-                                                    <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
-                                                    <font key="font" metaFont="system"/>
-                                                </buttonCell>
-                                                <connections>
-                                                    <action selector="buttonItemClick_Proport:" target="-2" id="HAp-8e-DCz"/>
-                                                </connections>
-                                            </button>
-                                            <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="DrW-yP-2Z0">
-                                                <rect key="frame" x="168" y="39" width="165" height="18"/>
-                                                <buttonCell key="cell" type="check" title="Remove White Margins" bezelStyle="regularSquare" imagePosition="left" inset="2" id="Ir4-jP-37y">
-                                                    <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
-                                                    <font key="font" metaFont="system"/>
-                                                </buttonCell>
-                                                <connections>
-                                                    <action selector="buttonClicked_Margin:" target="-2" id="ZD3-97-WQb"/>
-                                                </connections>
-                                            </button>
-                                            <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="qI4-X3-ecf">
-                                                <rect key="frame" x="9" y="3" width="104" height="32"/>
-                                                <buttonCell key="cell" type="push" title="Set To Zero" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Rvd-ES-Ei8">
-                                                    <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
-                                                    <font key="font" metaFont="system"/>
-                                                    <string key="keyEquivalent" base64-UTF8="YES">
-Gw
-</string>
-                                                </buttonCell>
-                                                <connections>
-                                                    <action selector="buttonItemClick_Zero:" target="-2" id="4uK-ch-gek"/>
-                                                </connections>
-                                            </button>
-                                            <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Awz-ZL-GW8">
-                                                <rect key="frame" x="119" y="3" width="152" height="32"/>
-                                                <buttonCell key="cell" type="push" title="Revert To Selection" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="IdP-4m-cR0">
-                                                    <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
-                                                    <font key="font" metaFont="system"/>
-                                                    <string key="keyEquivalent" base64-UTF8="YES">
-Gw
-</string>
-                                                </buttonCell>
-                                                <connections>
-                                                    <action selector="buttonItemClick_Revert:" target="-2" id="801-zL-Z6o"/>
-                                                </connections>
-                                            </button>
-                                            <customView translatesAutoresizingMaskIntoConstraints="NO" id="tfg-yt-TOr">
-                                                <rect key="frame" x="16" y="69" width="24" height="46"/>
-                                                <subviews>
-                                                    <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ZQw-Cw-7NC">
-                                                        <rect key="frame" x="-2" y="30" width="28" height="16"/>
-                                                        <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Top" id="n3q-Z7-4LY">
-                                                            <font key="font" metaFont="system"/>
-                                                            <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
-                                                            <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
-                                                        </textFieldCell>
-                                                    </textField>
-                                                    <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="UhA-JH-vB2">
-                                                        <rect key="frame" x="-2" y="0.0" width="28" height="16"/>
-                                                        <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Left" id="Ksz-MO-x83">
-                                                            <font key="font" metaFont="system"/>
-                                                            <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
-                                                            <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
-                                                        </textFieldCell>
-                                                    </textField>
-                                                </subviews>
-                                                <constraints>
-                                                    <constraint firstItem="ZQw-Cw-7NC" firstAttribute="top" secondItem="tfg-yt-TOr" secondAttribute="top" id="7If-c8-3Sj"/>
-                                                    <constraint firstItem="ZQw-Cw-7NC" firstAttribute="leading" secondItem="tfg-yt-TOr" secondAttribute="leading" id="Dmi-Hd-J8r"/>
-                                                    <constraint firstAttribute="trailing" secondItem="ZQw-Cw-7NC" secondAttribute="trailing" id="eSV-AR-eEH"/>
-                                                    <constraint firstAttribute="bottom" secondItem="UhA-JH-vB2" secondAttribute="bottom" id="eld-2q-i2m"/>
-                                                    <constraint firstItem="UhA-JH-vB2" firstAttribute="top" secondItem="ZQw-Cw-7NC" secondAttribute="bottom" constant="14" id="hME-rY-eGL"/>
-                                                    <constraint firstItem="UhA-JH-vB2" firstAttribute="leading" secondItem="tfg-yt-TOr" secondAttribute="leading" id="ppV-kd-p42"/>
-                                                    <constraint firstAttribute="trailing" secondItem="UhA-JH-vB2" secondAttribute="trailing" id="t8D-lK-5C2"/>
-                                                </constraints>
-                                            </customView>
-                                            <customView translatesAutoresizingMaskIntoConstraints="NO" id="Agp-Xe-fma">
-                                                <rect key="frame" x="169" y="69" width="45" height="46"/>
-                                                <subviews>
-                                                    <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="sej-ZU-2AI">
-                                                        <rect key="frame" x="-2" y="0.0" width="49" height="16"/>
-                                                        <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Right" id="aDU-3R-1YD">
-                                                            <font key="font" metaFont="system"/>
-                                                            <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
-                                                            <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
-                                                        </textFieldCell>
-                                                    </textField>
-                                                    <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="VfD-a0-qeT">
-                                                        <rect key="frame" x="-2" y="30" width="49" height="16"/>
-                                                        <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Bottom" id="jtA-Kg-WrM">
-                                                            <font key="font" metaFont="system"/>
-                                                            <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
-                                                            <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
-                                                        </textFieldCell>
-                                                    </textField>
-                                                </subviews>
-                                                <constraints>
-                                                    <constraint firstAttribute="bottom" secondItem="sej-ZU-2AI" secondAttribute="bottom" id="5JL-Hh-x96"/>
-                                                    <constraint firstAttribute="trailing" secondItem="sej-ZU-2AI" secondAttribute="trailing" id="9CD-bi-gyG"/>
-                                                    <constraint firstItem="VfD-a0-qeT" firstAttribute="top" secondItem="Agp-Xe-fma" secondAttribute="top" id="Xsn-F8-7Ry"/>
-                                                    <constraint firstAttribute="trailing" secondItem="VfD-a0-qeT" secondAttribute="trailing" id="dgw-LW-PWm"/>
-                                                    <constraint firstItem="sej-ZU-2AI" firstAttribute="leading" secondItem="Agp-Xe-fma" secondAttribute="leading" id="eSW-PR-uEr"/>
-                                                    <constraint firstItem="sej-ZU-2AI" firstAttribute="top" secondItem="VfD-a0-qeT" secondAttribute="bottom" constant="14" id="uhx-5a-WaH"/>
-                                                    <constraint firstItem="VfD-a0-qeT" firstAttribute="leading" secondItem="Agp-Xe-fma" secondAttribute="leading" id="xvW-RY-uPK"/>
-                                                </constraints>
-                                            </customView>
-                                        </subviews>
-                                        <constraints>
-                                            <constraint firstItem="Agp-Xe-fma" firstAttribute="leading" secondItem="yBy-iX-BmZ" secondAttribute="trailing" constant="20" id="0jo-2z-xmB"/>
-                                            <constraint firstItem="Awz-ZL-GW8" firstAttribute="leading" secondItem="qI4-X3-ecf" secondAttribute="trailing" constant="20" id="4ZV-WR-ziv"/>
-                                            <constraint firstItem="qI4-X3-ecf" firstAttribute="top" secondItem="1q3-OF-DR8" secondAttribute="bottom" constant="10" id="6jR-l6-Ku4"/>
-                                            <constraint firstItem="pOe-AK-MAI" firstAttribute="leading" secondItem="KAo-LQ-YE5" secondAttribute="trailing" constant="3" id="8d7-mg-hCf"/>
-                                            <constraint firstItem="g6f-5M-brm" firstAttribute="top" secondItem="qdU-Rn-M1d" secondAttribute="top" constant="5" id="ADZ-BX-TuS"/>
-                                            <constraint firstItem="tfg-yt-TOr" firstAttribute="leading" secondItem="qdU-Rn-M1d" secondAttribute="leading" constant="16" id="BKF-7R-sdv"/>
-                                            <constraint firstItem="fsc-HQ-jlC" firstAttribute="leading" secondItem="qdU-Rn-M1d" secondAttribute="leading" constant="16" id="Edj-AW-Rnk"/>
-                                            <constraint firstItem="DrW-yP-2Z0" firstAttribute="centerY" secondItem="1q3-OF-DR8" secondAttribute="centerY" id="Fyg-o9-dF4"/>
-                                            <constraint firstItem="g6f-5M-brm" firstAttribute="leading" secondItem="fsc-HQ-jlC" secondAttribute="trailing" constant="5" id="Gia-j5-puC"/>
-                                            <constraint firstItem="AgH-Jp-OdB" firstAttribute="centerY" secondItem="bf7-ec-UrO" secondAttribute="centerY" id="GsC-6T-BVM"/>
-                                            <constraint firstItem="DrW-yP-2Z0" firstAttribute="leading" secondItem="1q3-OF-DR8" secondAttribute="trailing" constant="22" id="IRG-Ev-o6B"/>
-                                            <constraint firstItem="bf7-ec-UrO" firstAttribute="centerY" secondItem="Sr3-sJ-ORG" secondAttribute="centerY" id="JTz-hc-0Hk"/>
-                                            <constraint firstItem="AgH-Jp-OdB" firstAttribute="leading" secondItem="bf7-ec-UrO" secondAttribute="trailing" constant="3" id="LP0-nm-e55"/>
-                                            <constraint firstItem="yBy-iX-BmZ" firstAttribute="top" secondItem="g6f-5M-brm" secondAttribute="bottom" constant="10" id="M5O-LV-urX"/>
-                                            <constraint firstItem="tfg-yt-TOr" firstAttribute="top" secondItem="g6f-5M-brm" secondAttribute="bottom" constant="12" id="QdK-D4-A54"/>
-                                            <constraint firstItem="KAo-LQ-YE5" firstAttribute="leading" secondItem="Agp-Xe-fma" secondAttribute="trailing" constant="5" id="UMo-h4-9SQ"/>
-                                            <constraint firstItem="dBR-dC-b73" firstAttribute="leading" secondItem="Sr3-sJ-ORG" secondAttribute="trailing" constant="3" id="UN8-tV-jFz"/>
-                                            <constraint firstItem="yBy-iX-BmZ" firstAttribute="centerY" secondItem="wNO-q7-yax" secondAttribute="centerY" id="Xqa-hm-I8K"/>
-                                            <constraint firstItem="yBy-iX-BmZ" firstAttribute="leading" secondItem="wNO-q7-yax" secondAttribute="trailing" constant="3" id="Z9s-sk-vVk"/>
-                                            <constraint firstItem="1q3-OF-DR8" firstAttribute="top" secondItem="Sr3-sJ-ORG" secondAttribute="bottom" constant="10" id="aK2-Vu-gh5"/>
-                                            <constraint firstItem="dBR-dC-b73" firstAttribute="centerY" secondItem="Sr3-sJ-ORG" secondAttribute="centerY" id="efX-j4-DlG"/>
-                                            <constraint firstAttribute="bottom" secondItem="qI4-X3-ecf" secondAttribute="bottom" constant="10" id="ekm-sR-ROc"/>
-                                            <constraint firstItem="Sr3-sJ-ORG" firstAttribute="top" secondItem="yBy-iX-BmZ" secondAttribute="bottom" constant="10" id="fVx-om-aY6"/>
-                                            <constraint firstItem="KAo-LQ-YE5" firstAttribute="leading" secondItem="bf7-ec-UrO" secondAttribute="leading" id="gBf-F1-xbK"/>
-                                            <constraint firstItem="Awz-ZL-GW8" firstAttribute="centerY" secondItem="qI4-X3-ecf" secondAttribute="centerY" id="hz1-R3-I6S"/>
-                                            <constraint firstItem="wNO-q7-yax" firstAttribute="leading" secondItem="tfg-yt-TOr" secondAttribute="trailing" constant="5" id="iTx-2Q-SHz"/>
-                                            <constraint firstItem="pOe-AK-MAI" firstAttribute="centerY" secondItem="KAo-LQ-YE5" secondAttribute="centerY" id="iY2-hc-7gw"/>
-                                            <constraint firstItem="KAo-LQ-YE5" firstAttribute="centerY" secondItem="wNO-q7-yax" secondAttribute="centerY" id="k3a-Wh-ZcB"/>
-                                            <constraint firstItem="qI4-X3-ecf" firstAttribute="leading" secondItem="fsc-HQ-jlC" secondAttribute="leading" id="lJB-qE-ZfX"/>
-                                            <constraint firstItem="Agp-Xe-fma" firstAttribute="top" secondItem="g6f-5M-brm" secondAttribute="bottom" constant="12" id="sda-1n-om6"/>
-                                            <constraint firstItem="Sr3-sJ-ORG" firstAttribute="leading" secondItem="wNO-q7-yax" secondAttribute="leading" id="snf-zj-1mk"/>
-                                            <constraint firstItem="g6f-5M-brm" firstAttribute="centerY" secondItem="fsc-HQ-jlC" secondAttribute="centerY" id="xcY-I3-r3X"/>
-                                            <constraint firstItem="1q3-OF-DR8" firstAttribute="leading" secondItem="fsc-HQ-jlC" secondAttribute="leading" id="ybK-Ee-djN"/>
-                                        </constraints>
-                                    </view>
-                                    <constraints>
-                                        <constraint firstAttribute="width" constant="492" id="kog-VM-KQh"/>
-                                    </constraints>
-                                </box>
-                                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="2x8-XK-ICO">
-                                    <rect key="frame" x="14" y="345" width="101" height="16"/>
-                                    <textFieldCell key="cell" lineBreakMode="clipping" title="Margin Controls" id="RAQ-gj-and">
-                                        <font key="font" metaFont="system"/>
-                                        <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
-                                        <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
-                                    </textFieldCell>
-                                </textField>
-                                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="z3z-tZ-TKL">
-                                    <rect key="frame" x="14" y="150" width="114" height="16"/>
-                                    <textFieldCell key="cell" lineBreakMode="clipping" title="Change Page Size" id="BHe-4r-RFO">
-                                        <font key="font" metaFont="system"/>
-                                        <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
-                                        <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
-                                    </textFieldCell>
-                                </textField>
-                                <box title="Box" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="Xul-oG-2l2">
-                                    <rect key="frame" x="-3" y="37" width="498" height="110"/>
-                                    <view key="contentView" id="cjk-kW-hGj">
-                                        <rect key="frame" x="4" y="5" width="490" height="102"/>
-                                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                                        <subviews>
-                                            <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="dHM-AO-rF7">
-                                                <rect key="frame" x="14" y="73" width="94" height="18"/>
-                                                <buttonCell key="cell" type="radio" title="Fixed Sizes" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="00k-0U-SeA">
-                                                    <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
-                                                    <font key="font" metaFont="system"/>
-                                                </buttonCell>
-                                                <connections>
-                                                    <action selector="buttonItemClick_FixedSize:" target="-2" id="xgK-aK-JjE"/>
-                                                </connections>
-                                            </button>
-                                            <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="CRu-dV-3vm">
-                                                <rect key="frame" x="14" y="43" width="73" height="18"/>
-                                                <buttonCell key="cell" type="radio" title="Custom" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="5KU-oy-NFg">
-                                                    <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
-                                                    <font key="font" metaFont="system"/>
-                                                </buttonCell>
-                                                <connections>
-                                                    <action selector="buttonItemClick_CustomSize:" target="-2" id="j5y-zN-qdp"/>
-                                                </connections>
-                                            </button>
-                                            <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Fqc-0d-9Eq">
-                                                <rect key="frame" x="95" y="44" width="44" height="16"/>
-                                                <textFieldCell key="cell" lineBreakMode="clipping" title="Width:" id="AGb-l5-ARh">
-                                                    <font key="font" metaFont="system"/>
-                                                    <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
-                                                    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
-                                                </textFieldCell>
-                                            </textField>
-                                            <popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="EdY-87-wsh">
-                                                <rect key="frame" x="115" y="68" width="150" height="25"/>
-                                                <popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="LRi-Mu-liR" id="yHx-V6-yPt">
-                                                    <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
-                                                    <font key="font" metaFont="menu"/>
-                                                    <menu key="menu" id="DYT-GX-HgG">
-                                                        <items>
-                                                            <menuItem title="Item 1" state="on" id="LRi-Mu-liR"/>
-                                                            <menuItem title="Item 2" id="I52-61-KCv"/>
-                                                            <menuItem title="Item 3" id="RwJ-G5-Yao"/>
-                                                        </items>
-                                                    </menu>
-                                                </popUpButtonCell>
-                                                <constraints>
-                                                    <constraint firstAttribute="width" constant="143" id="rR6-jT-WTz"/>
-                                                </constraints>
-                                                <connections>
-                                                    <action selector="buttonClicked_PageSize:" target="-2" id="KUB-ct-GPV"/>
-                                                </connections>
-                                            </popUpButton>
-                                            <textField focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="nLW-Cw-sjg">
-                                                <rect key="frame" x="141" y="41" width="100" height="21"/>
-                                                <constraints>
-                                                    <constraint firstAttribute="width" constant="100" id="bC9-kr-ilb"/>
-                                                </constraints>
-                                                <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="7b5-eW-Asy">
-                                                    <numberFormatter key="formatter" formatterBehavior="default10_4" usesGroupingSeparator="NO" groupingSize="0" minimumIntegerDigits="0" maximumIntegerDigits="42" id="9d1-1u-PFl">
-                                                        <real key="minimum" value="1"/>
-                                                        <real key="maximum" value="99"/>
-                                                    </numberFormatter>
-                                                    <font key="font" metaFont="system"/>
-                                                    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
-                                                    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
-                                                </textFieldCell>
-                                                <connections>
-                                                    <outlet property="delegate" destination="-2" id="16a-iu-peD"/>
-                                                </connections>
-                                            </textField>
-                                            <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="AoW-07-9El">
-                                                <rect key="frame" x="254" y="44" width="48" height="16"/>
-                                                <textFieldCell key="cell" lineBreakMode="clipping" title="Height:" id="M6h-Aa-tGh">
-                                                    <font key="font" metaFont="system"/>
-                                                    <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
-                                                    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
-                                                </textFieldCell>
-                                            </textField>
-                                            <textField focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="gGH-DJ-pie">
-                                                <rect key="frame" x="304" y="41" width="100" height="21"/>
-                                                <constraints>
-                                                    <constraint firstAttribute="width" constant="100" id="WQE-9q-bUZ"/>
-                                                </constraints>
-                                                <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="hTo-2o-sck">
-                                                    <numberFormatter key="formatter" formatterBehavior="default10_4" usesGroupingSeparator="NO" groupingSize="0" minimumIntegerDigits="0" maximumIntegerDigits="42" id="2Pw-hq-Iqp">
-                                                        <real key="minimum" value="1"/>
-                                                        <real key="maximum" value="99"/>
-                                                    </numberFormatter>
-                                                    <font key="font" metaFont="system"/>
-                                                    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
-                                                    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
-                                                </textFieldCell>
-                                                <connections>
-                                                    <outlet property="delegate" destination="-2" id="QRb-Cw-bRX"/>
-                                                </connections>
-                                            </textField>
-                                            <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="wkn-bH-QLY">
-                                                <rect key="frame" x="121" y="13" width="58" height="16"/>
-                                                <textFieldCell key="cell" lineBreakMode="clipping" title="XOffset: " id="QID-jc-PHn">
-                                                    <font key="font" metaFont="system"/>
-                                                    <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
-                                                    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
-                                                </textFieldCell>
-                                            </textField>
-                                            <textField focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Ioi-Bj-Odn">
-                                                <rect key="frame" x="181" y="10" width="100" height="21"/>
-                                                <constraints>
-                                                    <constraint firstAttribute="width" constant="100" id="LgP-3N-is8"/>
-                                                </constraints>
-                                                <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="Qrq-L2-OIv">
-                                                    <numberFormatter key="formatter" formatterBehavior="default10_4" usesGroupingSeparator="NO" groupingSize="0" minimumIntegerDigits="0" maximumIntegerDigits="42" id="Kbz-Bz-DMS">
-                                                        <real key="minimum" value="1"/>
-                                                        <real key="maximum" value="99"/>
-                                                    </numberFormatter>
-                                                    <font key="font" metaFont="system"/>
-                                                    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
-                                                    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
-                                                </textFieldCell>
-                                                <connections>
-                                                    <outlet property="delegate" destination="-2" id="i0H-TQ-qT3"/>
-                                                </connections>
-                                            </textField>
-                                            <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="hv5-EF-rgN">
-                                                <rect key="frame" x="294" y="13" width="57" height="16"/>
-                                                <textFieldCell key="cell" lineBreakMode="clipping" title="YOffset: " id="jCt-QU-G5t">
-                                                    <font key="font" metaFont="system"/>
-                                                    <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
-                                                    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
-                                                </textFieldCell>
-                                            </textField>
-                                            <textField focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="urW-5G-Ad1">
-                                                <rect key="frame" x="353" y="10" width="100" height="21"/>
-                                                <constraints>
-                                                    <constraint firstAttribute="width" constant="100" id="FAU-SC-I9m"/>
-                                                </constraints>
-                                                <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="2A9-Vs-RUG">
-                                                    <numberFormatter key="formatter" formatterBehavior="default10_4" usesGroupingSeparator="NO" groupingSize="0" minimumIntegerDigits="0" maximumIntegerDigits="42" id="2r4-rJ-bFo">
-                                                        <real key="minimum" value="1"/>
-                                                        <real key="maximum" value="99"/>
-                                                    </numberFormatter>
-                                                    <font key="font" metaFont="system"/>
-                                                    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
-                                                    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
-                                                </textFieldCell>
-                                                <connections>
-                                                    <outlet property="delegate" destination="-2" id="H1e-bI-byV"/>
-                                                </connections>
-                                            </textField>
-                                            <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="fg9-32-HZP">
-                                                <rect key="frame" x="36" y="12" width="67" height="18"/>
-                                                <buttonCell key="cell" type="check" title="Center" bezelStyle="regularSquare" imagePosition="left" inset="2" id="uer-qF-XRs">
-                                                    <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
-                                                    <font key="font" metaFont="system"/>
-                                                </buttonCell>
-                                                <connections>
-                                                    <action selector="buttonItemClick_Center:" target="-2" id="Hk9-0I-fSJ"/>
-                                                </connections>
-                                            </button>
-                                        </subviews>
-                                        <constraints>
-                                            <constraint firstItem="urW-5G-Ad1" firstAttribute="leading" secondItem="hv5-EF-rgN" secondAttribute="trailing" constant="4" id="3u6-4G-loj"/>
-                                            <constraint firstItem="hv5-EF-rgN" firstAttribute="centerY" secondItem="fg9-32-HZP" secondAttribute="centerY" id="5Vn-Gh-llU"/>
-                                            <constraint firstItem="gGH-DJ-pie" firstAttribute="centerY" secondItem="CRu-dV-3vm" secondAttribute="centerY" id="Hw7-Be-iGm"/>
-                                            <constraint firstItem="dHM-AO-rF7" firstAttribute="top" secondItem="cjk-kW-hGj" secondAttribute="top" constant="12" id="JBk-Mj-I9P"/>
-                                            <constraint firstItem="urW-5G-Ad1" firstAttribute="centerY" secondItem="fg9-32-HZP" secondAttribute="centerY" id="M0N-iB-gv7"/>
-                                            <constraint firstItem="fg9-32-HZP" firstAttribute="leading" secondItem="cjk-kW-hGj" secondAttribute="leading" constant="38" id="MZB-WW-YPp"/>
-                                            <constraint firstItem="nLW-Cw-sjg" firstAttribute="centerY" secondItem="CRu-dV-3vm" secondAttribute="centerY" id="MyU-DW-yVb"/>
-                                            <constraint firstItem="AoW-07-9El" firstAttribute="leading" secondItem="nLW-Cw-sjg" secondAttribute="trailing" constant="15" id="OF2-CX-CxS"/>
-                                            <constraint firstItem="Ioi-Bj-Odn" firstAttribute="centerY" secondItem="fg9-32-HZP" secondAttribute="centerY" id="ORB-WA-AbO"/>
-                                            <constraint firstItem="gGH-DJ-pie" firstAttribute="leading" secondItem="AoW-07-9El" secondAttribute="trailing" constant="4" id="PQI-r2-G9Z"/>
-                                            <constraint firstItem="EdY-87-wsh" firstAttribute="centerY" secondItem="dHM-AO-rF7" secondAttribute="centerY" id="RoR-65-GmL"/>
-                                            <constraint firstItem="EdY-87-wsh" firstAttribute="leading" secondItem="dHM-AO-rF7" secondAttribute="trailing" constant="10" id="Skr-v1-2Cy"/>
-                                            <constraint firstItem="dHM-AO-rF7" firstAttribute="leading" secondItem="cjk-kW-hGj" secondAttribute="leading" constant="16" id="Wlv-Nk-iAf"/>
-                                            <constraint firstItem="Fqc-0d-9Eq" firstAttribute="centerY" secondItem="CRu-dV-3vm" secondAttribute="centerY" id="Xdb-Zy-PII"/>
-                                            <constraint firstItem="AoW-07-9El" firstAttribute="centerY" secondItem="CRu-dV-3vm" secondAttribute="centerY" id="ZJA-MT-rAL"/>
-                                            <constraint firstItem="nLW-Cw-sjg" firstAttribute="top" secondItem="EdY-87-wsh" secondAttribute="bottom" constant="10" id="gQz-pg-uPX"/>
-                                            <constraint firstItem="Fqc-0d-9Eq" firstAttribute="leading" secondItem="CRu-dV-3vm" secondAttribute="trailing" constant="10" id="jwg-wh-j8l"/>
-                                            <constraint firstItem="wkn-bH-QLY" firstAttribute="centerY" secondItem="fg9-32-HZP" secondAttribute="centerY" id="oVX-qy-lzJ"/>
-                                            <constraint firstItem="wkn-bH-QLY" firstAttribute="leading" secondItem="fg9-32-HZP" secondAttribute="trailing" constant="20" id="pJk-M6-F6L"/>
-                                            <constraint firstItem="nLW-Cw-sjg" firstAttribute="leading" secondItem="Fqc-0d-9Eq" secondAttribute="trailing" constant="4" id="rKk-7g-fzg"/>
-                                            <constraint firstItem="Ioi-Bj-Odn" firstAttribute="top" secondItem="nLW-Cw-sjg" secondAttribute="bottom" constant="10" id="rgx-0l-5aS"/>
-                                            <constraint firstAttribute="bottom" secondItem="Ioi-Bj-Odn" secondAttribute="bottom" constant="10" id="tL0-VE-xGo"/>
-                                            <constraint firstItem="hv5-EF-rgN" firstAttribute="leading" secondItem="Ioi-Bj-Odn" secondAttribute="trailing" constant="15" id="v2X-tL-ejY"/>
-                                            <constraint firstItem="CRu-dV-3vm" firstAttribute="leading" secondItem="dHM-AO-rF7" secondAttribute="leading" id="x4t-GD-MDO"/>
-                                            <constraint firstItem="Ioi-Bj-Odn" firstAttribute="leading" secondItem="wkn-bH-QLY" secondAttribute="trailing" constant="4" id="yxB-y6-Cpz"/>
-                                        </constraints>
-                                    </view>
-                                </box>
-                                <box boxType="custom" borderType="none" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="c7d-vJ-aEI">
-                                    <rect key="frame" x="0.0" y="0.0" width="492" height="26"/>
-                                    <view key="contentView" id="V1W-La-7Fv">
-                                        <rect key="frame" x="0.0" y="0.0" width="492" height="26"/>
-                                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                                        <subviews>
-                                            <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="i2R-g4-Mfv">
-                                                <rect key="frame" x="-2" y="5" width="77" height="16"/>
-                                                <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Page Range" id="pff-Zr-itc">
-                                                    <font key="font" metaFont="system"/>
-                                                    <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
-                                                    <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
-                                                </textFieldCell>
-                                            </textField>
-                                            <comboBox focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Ynj-Y3-ZFe">
-                                                <rect key="frame" x="92" y="1" width="216" height="23"/>
-                                                <constraints>
-                                                    <constraint firstAttribute="width" constant="212" id="mDC-cc-mgp"/>
-                                                </constraints>
-                                                <comboBoxCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" completes="NO" numberOfVisibleItems="5" id="WKI-Vc-ChH">
-                                                    <font key="font" metaFont="system"/>
-                                                    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
-                                                    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
-                                                </comboBoxCell>
-                                                <connections>
-                                                    <action selector="comboBoxItemClick_PageRange:" target="-2" id="bVA-41-6vE"/>
-                                                </connections>
-                                            </comboBox>
-                                        </subviews>
-                                        <constraints>
-                                            <constraint firstItem="Ynj-Y3-ZFe" firstAttribute="centerY" secondItem="i2R-g4-Mfv" secondAttribute="centerY" id="KjB-Hg-7OQ"/>
-                                            <constraint firstAttribute="bottom" secondItem="Ynj-Y3-ZFe" secondAttribute="bottom" constant="3" id="cgI-aX-XOP"/>
-                                            <constraint firstItem="i2R-g4-Mfv" firstAttribute="leading" secondItem="V1W-La-7Fv" secondAttribute="leading" id="d4f-AH-fTt"/>
-                                            <constraint firstItem="Ynj-Y3-ZFe" firstAttribute="top" secondItem="V1W-La-7Fv" secondAttribute="top" constant="3" id="npv-LN-UuL"/>
-                                            <constraint firstItem="Ynj-Y3-ZFe" firstAttribute="leading" secondItem="i2R-g4-Mfv" secondAttribute="trailing" constant="20" id="s2d-jW-Irf"/>
-                                        </constraints>
-                                    </view>
-                                    <color key="fillColor" red="1" green="1" blue="1" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
-                                </box>
-                            </subviews>
-                            <constraints>
-                                <constraint firstItem="b2t-Vm-9TN" firstAttribute="centerY" secondItem="pjr-0K-HcJ" secondAttribute="centerY" id="1W8-Xh-RnY"/>
-                                <constraint firstItem="z3z-tZ-TKL" firstAttribute="leading" secondItem="UOf-xL-wZf" secondAttribute="leading" constant="16" id="DHo-OS-Co1"/>
-                                <constraint firstItem="Xul-oG-2l2" firstAttribute="trailing" secondItem="8Xu-vw-ZUb" secondAttribute="trailing" id="FHg-sY-1fk"/>
-                                <constraint firstItem="b2t-Vm-9TN" firstAttribute="leading" secondItem="pjr-0K-HcJ" secondAttribute="trailing" constant="5" id="JVG-AR-86k"/>
-                                <constraint firstItem="8Xu-vw-ZUb" firstAttribute="top" secondItem="2x8-XK-ICO" secondAttribute="bottom" constant="5" id="Ll6-6S-PWr"/>
-                                <constraint firstItem="Xul-oG-2l2" firstAttribute="top" secondItem="z3z-tZ-TKL" secondAttribute="bottom" constant="5" id="OqD-8O-gQ2"/>
-                                <constraint firstItem="c7d-vJ-aEI" firstAttribute="top" secondItem="Xul-oG-2l2" secondAttribute="bottom" constant="15" id="ThD-cb-Gb0"/>
-                                <constraint firstAttribute="trailing" secondItem="8Xu-vw-ZUb" secondAttribute="trailing" id="Tol-yQ-ru9"/>
-                                <constraint firstItem="z3z-tZ-TKL" firstAttribute="top" secondItem="8Xu-vw-ZUb" secondAttribute="bottom" constant="20" id="caK-lA-O3V"/>
-                                <constraint firstItem="2x8-XK-ICO" firstAttribute="top" secondItem="b2t-Vm-9TN" secondAttribute="bottom" constant="18" id="djz-CW-Thx"/>
-                                <constraint firstItem="b2t-Vm-9TN" firstAttribute="top" secondItem="UOf-xL-wZf" secondAttribute="top" id="iaf-QK-Znh"/>
-                                <constraint firstAttribute="bottom" secondItem="c7d-vJ-aEI" secondAttribute="bottom" id="ntP-Dr-cw7"/>
-                                <constraint firstItem="c7d-vJ-aEI" firstAttribute="leading" secondItem="Xul-oG-2l2" secondAttribute="leading" id="oFw-TJ-ijN"/>
-                                <constraint firstItem="c7d-vJ-aEI" firstAttribute="trailing" secondItem="Xul-oG-2l2" secondAttribute="trailing" id="pEa-qh-ElK"/>
-                                <constraint firstItem="8Xu-vw-ZUb" firstAttribute="leading" secondItem="UOf-xL-wZf" secondAttribute="leading" id="pLk-X8-4QF"/>
-                                <constraint firstItem="2x8-XK-ICO" firstAttribute="leading" secondItem="UOf-xL-wZf" secondAttribute="leading" constant="16" id="ptt-JL-mZl"/>
-                                <constraint firstItem="Xul-oG-2l2" firstAttribute="leading" secondItem="8Xu-vw-ZUb" secondAttribute="leading" id="xWn-kT-W4Y"/>
-                                <constraint firstItem="pjr-0K-HcJ" firstAttribute="leading" secondItem="UOf-xL-wZf" secondAttribute="leading" id="z4e-Vm-h1q"/>
-                            </constraints>
-                        </view>
-                    </box>
-                    <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="cdg-Zn-VLp">
-                        <rect key="frame" x="701" y="11" width="76" height="32"/>
-                        <buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="5lZ-eM-aY4">
-                            <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
-                            <font key="font" metaFont="system"/>
-                            <string key="keyEquivalent" base64-UTF8="YES">
-Gw
-</string>
-                        </buttonCell>
-                        <connections>
-                            <action selector="buttonItemClick_Cancel:" target="-2" id="nh7-NQ-bKA"/>
-                        </connections>
-                    </button>
-                    <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="XMR-VG-lFR">
-                        <rect key="frame" x="793" y="11" width="53" height="32"/>
-                        <buttonCell key="cell" type="push" title="OK" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="BHk-je-uZG">
-                            <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
-                            <font key="font" metaFont="system"/>
-                            <string key="keyEquivalent" base64-UTF8="YES">
-DQ
-</string>
-                        </buttonCell>
-                        <connections>
-                            <action selector="buttonItemClick_Save:" target="-2" id="oSs-ea-CgR"/>
-                        </connections>
-                    </button>
-                    <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="TXN-MH-f2b">
-                        <rect key="frame" x="8" y="11" width="63" height="32"/>
-                        <buttonCell key="cell" type="push" title="Print" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="XeP-Wk-XtG">
-                            <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
-                            <font key="font" metaFont="system"/>
-                        </buttonCell>
-                        <connections>
-                            <action selector="buttonItemClick_Print:" target="-2" id="WCp-tg-Hvt"/>
-                        </connections>
-                    </button>
-                </subviews>
-                <constraints>
-                    <constraint firstItem="kXK-8s-GTS" firstAttribute="top" secondItem="se5-gp-TjO" secondAttribute="top" constant="18" id="0Ts-pg-iUk"/>
-                    <constraint firstItem="b1A-Hw-Fy0" firstAttribute="leading" secondItem="kXK-8s-GTS" secondAttribute="trailing" constant="40" id="7YG-dc-G6u"/>
-                    <constraint firstItem="TXN-MH-f2b" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="15" id="U7k-vX-0bE"/>
-                    <constraint firstItem="b1A-Hw-Fy0" firstAttribute="top" secondItem="se5-gp-TjO" secondAttribute="top" constant="20" id="VeC-Fk-a5A"/>
-                    <constraint firstItem="XMR-VG-lFR" firstAttribute="centerY" secondItem="cdg-Zn-VLp" secondAttribute="centerY" id="a7e-7k-l2G"/>
-                    <constraint firstItem="XMR-VG-lFR" firstAttribute="leading" secondItem="cdg-Zn-VLp" secondAttribute="trailing" constant="30" id="avv-1a-qww"/>
-                    <constraint firstItem="kXK-8s-GTS" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="40" id="cF4-Gn-lat"/>
-                    <constraint firstAttribute="bottom" secondItem="XMR-VG-lFR" secondAttribute="bottom" constant="18" id="hVG-qy-uyf"/>
-                    <constraint firstAttribute="trailing" secondItem="XMR-VG-lFR" secondAttribute="trailing" constant="15" id="ihe-tD-hjc"/>
-                    <constraint firstAttribute="bottom" secondItem="b1A-Hw-Fy0" secondAttribute="bottom" constant="75" id="nUW-N1-tXo"/>
-                    <constraint firstAttribute="bottom" secondItem="TXN-MH-f2b" secondAttribute="bottom" constant="18" id="ncR-2p-hi3"/>
-                    <constraint firstAttribute="trailing" secondItem="b1A-Hw-Fy0" secondAttribute="trailing" constant="42" id="piW-oT-lLC"/>
-                </constraints>
-            </view>
-            <connections>
-                <outlet property="delegate" destination="-2" id="0bl-1N-AYu"/>
-            </connections>
-            <point key="canvasLocation" x="225" y="266.5"/>
-        </window>
-    </objects>
-    <resources>
-        <image name="NSGoLeftTemplate" width="12" height="17"/>
-        <image name="NSGoRightTemplate" width="12" height="17"/>
-    </resources>
-</document>

+ 0 - 74
PDF Office/PDF Master/Class/PDFTools/Crop/View/KMCropSettingPageSizeView.swift

@@ -1,74 +0,0 @@
-//
-//  KMCropSettingPageSizeView.swift
-//  PDF Reader Pro
-//
-//  Created by tangchao on 2022/12/30.
-//
-
-import Cocoa
-
-typealias KMCropSettingPageSizeViewItemClick = (_ index: Int, _ value: Any) -> ()
-class KMCropSettingPageSizeView: NSView {
-
-    var titleLabel = NSTextField(labelWithString: "")
-    var comboBox = NSComboBox()
-    
-    var itemClick: KMCropSettingPageSizeViewItemClick!
-    
-    override var isFlipped: Bool {
-        return true
-    }
-    
-    override init(frame frameRect: NSRect) {
-        super.init(frame: frameRect)
-        
-        initSubviews()
-    }
-    
-    required init?(coder: NSCoder) {
-        super.init(coder: coder)
-        
-        initSubviews()
-    }
-    
-    func initSubviews() {
-        self.addSubview(self.titleLabel)
-        self.addSubview(self.comboBox)
-        
-        self.titleLabel.stringValue = "页面尺寸"
-        self.comboBox.isEditable = false
-        self.comboBox.addItem(withObjectValue: "None")
-        self.comboBox.addItems(withObjectValues: KMCropTools.getPageSize())
-        self.comboBox.stringValue = "None"
-        self.comboBox.delegate = self
-    }
-    
-    override func layout() {
-        super.layout()
-        
-        self.titleLabel.frame = NSMakeRect(8, 0, NSWidth(self.bounds), 16)
-        self.comboBox.frame = NSMakeRect(8, self.titleLabel.frame.maxY+12, NSWidth(self.bounds)-16, 22)
-    }
-}
-
-extension KMCropSettingPageSizeView: NSComboBoxDelegate {
-    func comboBoxSelectionDidChange(_ notification: Notification) {
-        if (self.comboBox.isEqual(to: notification.object)) {
-            guard let callback = self.itemClick else {
-                return
-            }
-            
-            var index: Int = self.comboBox.indexOfSelectedItem
-            if (self.comboBox.indexOfSelectedItem < 0) {
-                index = 0
-            }
-            
-            var value: String = "None"
-            if (index > 0) {
-                value = KMCropTools.getPageSize()[index-1]
-            }
-            
-            callback(1, value)
-        }
-    }
-}

+ 0 - 79
PDF Office/PDF Master/Class/PDFTools/Crop/View/KMCropTipView.swift

@@ -1,79 +0,0 @@
-//
-//  KMCropTipView.swift
-//  PDF Reader Pro
-//
-//  Created by tangchao on 2023/1/4.
-//
-
-import Cocoa
-
-typealias KMCropTipViewEnterAction = ()->()
-class KMCropTipView: NSView {
-    
-    private var contentView = NSView()
-    private var label = NSTextField(labelWithString: "")
-    
-    private var localMonitor: Any!
-    
-    var enterAction: KMCropTipViewEnterAction!
-    
-    deinit {
-        NSEvent.removeMonitor(self.localMonitor as Any)
-        self.localMonitor = nil
-    }
-    
-    override init(frame frameRect: NSRect) {
-        super.init(frame: frameRect)
-        
-        initSubviews()
-    }
-    
-    required init?(coder: NSCoder) {
-        super.init(coder: coder)
-        
-        initSubviews()
-    }
-    
-    func initSubviews() {
-        self.addSubview(self.contentView)
-        self.contentView.addSubview(self.label)
-        
-        self.contentView.wantsLayer = true
-        self.contentView.layer?.backgroundColor = NSColor(red: 17.0/255.0, green: 138.0/255.0, blue: 1.0, alpha: 1.0).cgColor
-        
-        self.label.textColor = NSColor.white
-        self.label.font = NSFont.systemFont(ofSize: 14)
-        self.label.alignment = .center
-        
-        self.localMonitor = NSEvent.addLocalMonitorForEvents(matching: .keyUp, handler: {
-            [weak self] (event: NSEvent) -> NSEvent in
-            if (event.keyCode != 36) {
-                return event
-            }
-            
-            guard let callback = self!.enterAction else {
-                return event
-            }
-            
-            callback()
-            
-            return event
-        })
-    }
-    
-    override func layout() {
-        super.layout()
-        
-        let width: CGFloat = NSWidth(self.bounds)
-        let height: CGFloat = NSHeight(self.bounds)
-        
-        let contentWidth: CGFloat = 186
-        let contentHeight: CGFloat = 32
-        self.contentView.frame = NSMakeRect((width-contentWidth)*0.5, (height-contentHeight)*0.5, contentWidth, contentHeight)
-        self.label.frame = NSMakeRect(0, 5, contentWidth, 22)
-    }
-    
-    func setString(string: String) {
-        self.label.stringValue = string
-    }
-}

+ 13 - 13
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Edit.swift

@@ -27,7 +27,7 @@ extension CPDFListView {
         for area in areas {
             var data = self.opacityByRange(for: area)
             if data < 0 {
-               data = self.opacity(for: area)
+                data = self.opacity(for: area)
             }
             arr.append(data)
         }
@@ -143,7 +143,7 @@ extension CPDFListView {
     
     //MARK: - 开始&结束编辑
     func configPDFEditingInfo() {
- 
+        
         // 设置边框颜色
         self.editingConfig().editingBorderColor = .clear
         
@@ -180,7 +180,7 @@ extension CPDFListView {
             self.setOpacityEditArea(area, opacity: opacity)
         }
     }
- 
+    
     //MARK: -Text
     func changeEditingTextarea_Color(color: NSColor?) {
         guard let theColor = color else {
@@ -449,7 +449,7 @@ extension CPDFListView {
             bounds.size.width = width
         }
         self.setBoundsEditArea(area, withBounds: bounds)
-         self.editAreaBoundUpdating = false
+        self.editAreaBoundUpdating = false
         
     }
     
@@ -484,7 +484,7 @@ extension CPDFListView {
     
     //MARK: -修改对齐方式
     func changeEditingAreas(_ alignType: KMPDFActiveFormsAlignType) {
-         let editingAreas = self.km_EditingAreas()
+        let editingAreas = self.km_EditingAreas()
         
         if editingAreas.count >= 2 {
             
@@ -507,7 +507,7 @@ extension CPDFListView {
             var totalHeight = 0.0
             
             for i in 0 ... editingAreas.count-1 {
-                let area : CPDFEditArea = editingAreas[i] 
+                let area : CPDFEditArea = editingAreas[i]
                 zeroRect = zeroRect.union(area.bounds)
                 totalWidth = totalWidth + area.bounds.width
                 totalHeight = totalHeight + area.bounds.height
@@ -553,7 +553,7 @@ extension CPDFListView {
                 resultAreasArray = editingAreas
             } else if alignType == .right {
                 for i in 0 ... editingAreas.count-1 {
-                    let areas = editingAreas[i] 
+                    let areas = editingAreas[i]
                     var bounds = areas.bounds
                     bounds.origin.x = zeroRect.maxX - bounds.size.width
                     newBoundsArray.append(NSStringFromRect(bounds))
@@ -561,7 +561,7 @@ extension CPDFListView {
                 resultAreasArray = editingAreas
             } else if alignType == .top {
                 for i in 0 ... editingAreas.count-1 {
-                    let areas = editingAreas[i] 
+                    let areas = editingAreas[i]
                     var bounds = areas.bounds
                     bounds.origin.y = zeroRect.maxY - bounds.size.height
                     newBoundsArray.append(NSStringFromRect(bounds))
@@ -569,7 +569,7 @@ extension CPDFListView {
                 resultAreasArray = editingAreas
             } else if alignType == .bottom {
                 for i in 0 ... editingAreas.count-1 {
-                    let areas = editingAreas[i] 
+                    let areas = editingAreas[i]
                     var bounds = areas.bounds
                     bounds.origin.y = zeroRect.minY
                     newBoundsArray.append(NSStringFromRect(bounds))
@@ -577,7 +577,7 @@ extension CPDFListView {
                 resultAreasArray = editingAreas
             } else if alignType == .vertical {
                 for i in 0 ... editingAreas.count-1 {
-                    let areas = editingAreas[i] 
+                    let areas = editingAreas[i]
                     var bounds = areas.bounds
                     bounds.origin.y = highestRect.midY - bounds.height/2
                     newBoundsArray.append(NSStringFromRect(bounds))
@@ -585,7 +585,7 @@ extension CPDFListView {
                 resultAreasArray = editingAreas
             } else if alignType == .horizontally {
                 for i in 0 ... editingAreas.count-1 {
-                    let areas = editingAreas[i] 
+                    let areas = editingAreas[i]
                     var bounds = areas.bounds
                     bounds.origin.x = widthestRect.midX - bounds.width/2
                     newBoundsArray.append(NSStringFromRect(bounds))
@@ -596,7 +596,7 @@ extension CPDFListView {
                 let otherAreasTotalWidth = totalWidth - leftestRect.width - rightestRect.width
                 
                 let gap = (middleGap - otherAreasTotalWidth)/CGFloat(editingAreas.count - 1)
-                var areasCopyArray : [CPDFEditArea] = editingAreas 
+                var areasCopyArray : [CPDFEditArea] = editingAreas
                 areasCopyArray.sorted(by: { obj1, obj2 in
                     let area1 = obj1
                     let area2 = obj2
@@ -661,7 +661,7 @@ extension CPDFListView {
             for i in 0 ... resultAreasArray.count-1 {
                 let area : CPDFEditArea = resultAreasArray[i] as! CPDFEditArea
                 if newBoundsArray.count > i {
-                    let boundString = newBoundsArray[i] 
+                    let boundString = newBoundsArray[i]
                     self.setBoundsEditArea(area, withBounds: NSRectFromString(boundString))
                 }
             }

+ 112 - 112
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/KMGeneralAnnotationViewController.xib

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
     <dependencies>
         <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
         <capability name="Named colors" minToolsVersion="9.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
@@ -122,10 +122,10 @@
                 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                 <subviews>
                     <view translatesAutoresizingMaskIntoConstraints="NO" id="VrJ-Nh-rtz">
-                        <rect key="frame" x="0.0" y="151" width="481" height="1442"/>
+                        <rect key="frame" x="0.0" y="145" width="481" height="1448"/>
                         <subviews>
                             <box boxType="custom" borderWidth="0.0" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="6cI-tS-CM8">
-                                <rect key="frame" x="16" y="1362" width="449" height="80"/>
+                                <rect key="frame" x="16" y="1368" width="449" height="80"/>
                                 <view key="contentView" id="i1Q-jc-zH1">
                                     <rect key="frame" x="0.0" y="0.0" width="449" height="80"/>
                                     <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
@@ -136,9 +136,9 @@
                                 <color key="fillColor" red="0.99999600649999998" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                             </box>
                             <customView translatesAutoresizingMaskIntoConstraints="NO" id="Zyc-cU-wPJ">
-                                <rect key="frame" x="16" y="1191" width="449" height="161"/>
+                                <rect key="frame" x="16" y="1197" width="449" height="161"/>
                                 <subviews>
-                                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Bad-vN-F8Q">
+                                    <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Bad-vN-F8Q">
                                         <rect key="frame" x="-2" y="131" width="35" height="20"/>
                                         <constraints>
                                             <constraint firstAttribute="height" constant="20" id="5kQ-Zc-9ki"/>
@@ -151,23 +151,20 @@
                                     </textField>
                                     <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="8hZ-bB-sqv">
                                         <rect key="frame" x="433" y="133" width="16" height="16"/>
-                                        <constraints>
-                                            <constraint firstAttribute="width" constant="16" id="G3w-Ht-VPo"/>
-                                            <constraint firstAttribute="height" constant="16" id="SM5-tQ-a9b"/>
-                                        </constraints>
                                         <buttonCell key="cell" type="bevel" bezelStyle="regularSquare" image="KMImageNameUXIconBtnFontsetNor" imagePosition="only" alignment="center" imageScaling="proportionallyDown" inset="2" id="b3h-fF-20x">
                                             <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                             <font key="font" metaFont="system"/>
                                         </buttonCell>
+                                        <constraints>
+                                            <constraint firstAttribute="width" constant="16" id="G3w-Ht-VPo"/>
+                                            <constraint firstAttribute="height" constant="16" id="SM5-tQ-a9b"/>
+                                        </constraints>
                                         <connections>
                                             <action selector="fontButtonAction:" target="-2" id="dkT-3i-wVF"/>
                                         </connections>
                                     </button>
                                     <popUpButton translatesAutoresizingMaskIntoConstraints="NO" id="cAF-1K-YAd" customClass="KMPopUpButton" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                         <rect key="frame" x="0.0" y="33" width="346" height="24"/>
-                                        <constraints>
-                                            <constraint firstAttribute="height" constant="24" id="mXO-xI-qSq"/>
-                                        </constraints>
                                         <popUpButtonCell key="cell" type="square" title="UltraLight" bezelStyle="shadowlessSquare" alignment="left" lineBreakMode="truncatingTail" state="on" inset="2" arrowPosition="noArrow" selectedItem="9nh-AB-IE0" id="5Vn-Fa-ghP">
                                             <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                             <font key="font" usesAppearanceFont="YES"/>
@@ -185,20 +182,23 @@
                                                 </items>
                                             </menu>
                                         </popUpButtonCell>
+                                        <constraints>
+                                            <constraint firstAttribute="height" constant="24" id="mXO-xI-qSq"/>
+                                        </constraints>
                                         <connections>
                                             <action selector="fontStylePopUpButtonAction:" target="-2" id="BLZ-AY-QBT"/>
                                         </connections>
                                     </popUpButton>
                                     <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="MSv-hI-17r">
                                         <rect key="frame" x="0.0" y="0.0" width="41" height="24"/>
-                                        <constraints>
-                                            <constraint firstAttribute="width" constant="40.5" id="JVw-BX-rH5"/>
-                                            <constraint firstAttribute="height" constant="24" id="XgZ-QR-1Y3"/>
-                                        </constraints>
                                         <buttonCell key="cell" type="bevel" bezelStyle="rounded" image="KMImageNameUXIconPropertybarTextalignLeftNor" imagePosition="only" alignment="center" imageScaling="proportionallyDown" inset="2" id="db9-JK-omx">
                                             <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                             <font key="font" metaFont="system"/>
                                         </buttonCell>
+                                        <constraints>
+                                            <constraint firstAttribute="width" constant="40.5" id="JVw-BX-rH5"/>
+                                            <constraint firstAttribute="height" constant="24" id="XgZ-QR-1Y3"/>
+                                        </constraints>
                                         <connections>
                                             <action selector="alignButtonAction:" target="-2" id="YjF-rd-1BJ"/>
                                         </connections>
@@ -210,16 +210,16 @@
                                             <constraint firstAttribute="height" constant="16" id="KpK-iX-bqn"/>
                                         </constraints>
                                     </box>
-                                    <button verticalHuggingPriority="750" tag="1" translatesAutoresizingMaskIntoConstraints="NO" id="lv5-5o-kZW">
+                                    <button tag="1" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="lv5-5o-kZW">
                                         <rect key="frame" x="42" y="0.0" width="40" height="24"/>
-                                        <constraints>
-                                            <constraint firstAttribute="width" constant="40.5" id="6aV-xr-5Iq"/>
-                                            <constraint firstAttribute="height" constant="24" id="fwW-vP-O1U"/>
-                                        </constraints>
                                         <buttonCell key="cell" type="bevel" bezelStyle="rounded" image="KMImageNameUXIconPropertybarTextalignCenterNor" imagePosition="only" alignment="center" imageScaling="proportionallyDown" inset="2" id="4YK-bV-svt">
                                             <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                             <font key="font" metaFont="system"/>
                                         </buttonCell>
+                                        <constraints>
+                                            <constraint firstAttribute="width" constant="40.5" id="6aV-xr-5Iq"/>
+                                            <constraint firstAttribute="height" constant="24" id="fwW-vP-O1U"/>
+                                        </constraints>
                                         <connections>
                                             <action selector="alignButtonAction:" target="-2" id="wZk-Ne-C6Y"/>
                                         </connections>
@@ -231,36 +231,36 @@
                                             <constraint firstAttribute="height" constant="16" id="lzg-uR-Ofh"/>
                                         </constraints>
                                     </box>
-                                    <button verticalHuggingPriority="750" tag="2" translatesAutoresizingMaskIntoConstraints="NO" id="8Nh-ho-juj">
+                                    <button tag="2" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="8Nh-ho-juj">
                                         <rect key="frame" x="83" y="0.0" width="41" height="24"/>
-                                        <constraints>
-                                            <constraint firstAttribute="height" constant="24" id="BjW-fk-FnB"/>
-                                            <constraint firstAttribute="width" constant="41" id="aef-WP-wXE"/>
-                                        </constraints>
                                         <buttonCell key="cell" type="bevel" bezelStyle="rounded" image="KMImageNameUXIconPropertybarTextalignRightNor" imagePosition="only" alignment="center" imageScaling="proportionallyDown" inset="2" id="gca-kG-mq1">
                                             <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                             <font key="font" metaFont="system"/>
                                         </buttonCell>
+                                        <constraints>
+                                            <constraint firstAttribute="height" constant="24" id="BjW-fk-FnB"/>
+                                            <constraint firstAttribute="width" constant="41" id="aef-WP-wXE"/>
+                                        </constraints>
                                         <connections>
                                             <action selector="alignButtonAction:" target="-2" id="KCd-nU-dPy"/>
                                         </connections>
                                     </button>
                                     <popUpButton translatesAutoresizingMaskIntoConstraints="NO" id="AHs-kd-sAo" customClass="KMPopUpButton" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                         <rect key="frame" x="0.0" y="65" width="449" height="24"/>
-                                        <constraints>
-                                            <constraint firstAttribute="height" constant="24" id="gdZ-Gv-m63"/>
-                                        </constraints>
                                         <popUpButtonCell key="cell" type="square" bezelStyle="shadowlessSquare" alignment="left" lineBreakMode="truncatingTail" inset="2" arrowPosition="noArrow" id="Vv5-1P-Y1g" customClass="KMPopUpButtonCell" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                             <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                             <font key="font" usesAppearanceFont="YES"/>
                                             <menu key="menu" id="fW2-Mn-ucz"/>
                                         </popUpButtonCell>
+                                        <constraints>
+                                            <constraint firstAttribute="height" constant="24" id="gdZ-Gv-m63"/>
+                                        </constraints>
                                         <connections>
                                             <action selector="fontPopUpButtonAction:" target="-2" id="umX-SG-GYl"/>
                                         </connections>
                                     </popUpButton>
-                                    <comboBox verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ddA-v5-KF1" customClass="KMComboBox" customModule="PDF_Reader_Pro" customModuleProvider="target">
-                                        <rect key="frame" x="354" y="33" width="95" height="23"/>
+                                    <comboBox focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ddA-v5-KF1" customClass="KMComboBox" customModule="PDF_Reader_Pro" customModuleProvider="target">
+                                        <rect key="frame" x="353" y="33" width="96" height="23"/>
                                         <constraints>
                                             <constraint firstAttribute="width" constant="92" id="oJG-Z9-pzj"/>
                                         </constraints>
@@ -336,9 +336,9 @@
                                 </constraints>
                             </customView>
                             <customView translatesAutoresizingMaskIntoConstraints="NO" id="luB-mj-Fhz">
-                                <rect key="frame" x="16" y="970" width="449" height="211"/>
+                                <rect key="frame" x="16" y="976" width="449" height="211"/>
                                 <subviews>
-                                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="7YY-gk-Luy">
+                                    <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="7YY-gk-Luy">
                                         <rect key="frame" x="-2" y="181" width="42" height="20"/>
                                         <constraints>
                                             <constraint firstAttribute="height" constant="20" id="FIr-3y-aVc"/>
@@ -403,7 +403,7 @@
                                             <rect key="frame" x="0.0" y="0.0" width="449" height="56"/>
                                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                             <subviews>
-                                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="KtL-ng-iuz">
+                                                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="KtL-ng-iuz">
                                                     <rect key="frame" x="-2" y="30" width="453" height="16"/>
                                                     <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="uyf-m8-jc3">
                                                         <font key="font" usesAppearanceFont="YES"/>
@@ -411,8 +411,8 @@
                                                         <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                                                     </textFieldCell>
                                                 </textField>
-                                                <comboBox verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Qzi-o3-DRu" customClass="KMComboBox" customModule="PDF_Reader_Pro" customModuleProvider="target">
-                                                    <rect key="frame" x="377" y="-4" width="75" height="30"/>
+                                                <comboBox focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Qzi-o3-DRu" customClass="KMComboBox" customModule="PDF_Reader_Pro" customModuleProvider="target">
+                                                    <rect key="frame" x="376" y="-2" width="76" height="27"/>
                                                     <constraints>
                                                         <constraint firstAttribute="width" constant="72" id="Agl-cI-DK9"/>
                                                         <constraint firstAttribute="height" constant="24" id="rOY-qg-B8b"/>
@@ -465,10 +465,10 @@
                                 </constraints>
                             </customView>
                             <customView translatesAutoresizingMaskIntoConstraints="NO" id="Iip-As-rOA">
-                                <rect key="frame" x="16" y="685" width="449" height="122"/>
+                                <rect key="frame" x="16" y="685" width="449" height="125"/>
                                 <subviews>
-                                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="lwg-7N-a25">
-                                        <rect key="frame" x="-2" y="92" width="52" height="20"/>
+                                    <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="lwg-7N-a25">
+                                        <rect key="frame" x="-2" y="95" width="52" height="20"/>
                                         <constraints>
                                             <constraint firstAttribute="height" constant="20" id="4SR-5b-IVl"/>
                                         </constraints>
@@ -479,7 +479,7 @@
                                         </textFieldCell>
                                     </textField>
                                     <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="6Lb-GS-vTh">
-                                        <rect key="frame" x="433" y="94" width="16" height="16"/>
+                                        <rect key="frame" x="433" y="97" width="16" height="16"/>
                                         <buttonCell key="cell" type="bevel" title="Button" bezelStyle="rounded" image="KMImageNameUXIconBtnStrikeNor" imagePosition="only" alignment="center" imageScaling="proportionallyDown" inset="2" id="vT7-GU-Jhe">
                                             <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                             <font key="font" metaFont="system"/>
@@ -488,8 +488,8 @@
                                             <action selector="borderButtonAction:" target="-2" id="yhp-LA-40f"/>
                                         </connections>
                                     </button>
-                                    <comboBox verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="DvE-Q8-vIM" customClass="KMComboBox" customModule="PDF_Reader_Pro" customModuleProvider="target">
-                                        <rect key="frame" x="377" y="63" width="72" height="23"/>
+                                    <comboBox focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="DvE-Q8-vIM" customClass="KMComboBox" customModule="PDF_Reader_Pro" customModuleProvider="target">
+                                        <rect key="frame" x="376" y="65" width="73" height="23"/>
                                         <constraints>
                                             <constraint firstAttribute="width" constant="69" id="RT6-4A-iQr"/>
                                         </constraints>
@@ -512,13 +512,13 @@
                                         </connections>
                                     </comboBox>
                                     <slider verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="LGR-ek-Rjl">
-                                        <rect key="frame" x="-2" y="60" width="373" height="28"/>
+                                        <rect key="frame" x="-2" y="61" width="373" height="28"/>
                                         <sliderCell key="cell" state="on" alignment="left" minValue="0.5" maxValue="18" doubleValue="0.5" tickMarkPosition="above" sliderType="linear" id="KZY-fm-DtC"/>
                                         <connections>
                                             <action selector="lineWidthSliderAction:" target="-2" id="URX-gp-Tf1"/>
                                         </connections>
                                     </slider>
-                                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="zV9-T2-KOp">
+                                    <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="zV9-T2-KOp">
                                         <rect key="frame" x="-2" y="31" width="453" height="16"/>
                                         <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="1lV-Zh-HTu">
                                             <font key="font" metaFont="system"/>
@@ -535,13 +535,13 @@
                                     </box>
                                     <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="qpN-xA-FDn" customClass="KMButton" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                         <rect key="frame" x="0.0" y="0.0" width="144" height="24"/>
-                                        <constraints>
-                                            <constraint firstAttribute="height" constant="24" id="zW5-tC-COX"/>
-                                        </constraints>
                                         <buttonCell key="cell" type="square" title="Button" bezelStyle="shadowlessSquare" imagePosition="only" alignment="center" imageScaling="proportionallyDown" inset="2" id="XWY-h5-eoR">
                                             <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                             <font key="font" metaFont="system"/>
                                         </buttonCell>
+                                        <constraints>
+                                            <constraint firstAttribute="height" constant="24" id="zW5-tC-COX"/>
+                                        </constraints>
                                         <connections>
                                             <action selector="lineTypeButtonAction:" target="-2" id="cdI-5x-EZl"/>
                                         </connections>
@@ -553,15 +553,15 @@
                                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                         </view>
                                     </box>
-                                    <button verticalHuggingPriority="750" tag="1" translatesAutoresizingMaskIntoConstraints="NO" id="oGT-YN-wXO" customClass="KMButton" customModule="PDF_Reader_Pro" customModuleProvider="target">
+                                    <button tag="1" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="oGT-YN-wXO" customClass="KMButton" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                         <rect key="frame" x="153" y="0.0" width="143" height="24"/>
-                                        <constraints>
-                                            <constraint firstAttribute="height" constant="24" id="YWr-iy-XVX"/>
-                                        </constraints>
                                         <buttonCell key="cell" type="square" title="Button" bezelStyle="shadowlessSquare" imagePosition="only" alignment="center" imageScaling="proportionallyDown" inset="2" id="yVa-dQ-A17">
                                             <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                             <font key="font" metaFont="system"/>
                                         </buttonCell>
+                                        <constraints>
+                                            <constraint firstAttribute="height" constant="24" id="YWr-iy-XVX"/>
+                                        </constraints>
                                         <connections>
                                             <action selector="lineTypeButtonAction:" target="-2" id="Jor-h2-6N9"/>
                                         </connections>
@@ -573,15 +573,15 @@
                                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                         </view>
                                     </box>
-                                    <button verticalHuggingPriority="750" tag="2" translatesAutoresizingMaskIntoConstraints="NO" id="ZjM-D6-rzr" customClass="KMButton" customModule="PDF_Reader_Pro" customModuleProvider="target">
+                                    <button tag="2" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ZjM-D6-rzr" customClass="KMButton" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                         <rect key="frame" x="305" y="0.0" width="144" height="24"/>
-                                        <constraints>
-                                            <constraint firstAttribute="height" constant="24" id="yrC-QK-pLc"/>
-                                        </constraints>
                                         <buttonCell key="cell" type="square" title="Button" bezelStyle="shadowlessSquare" imagePosition="only" alignment="center" imageScaling="proportionallyDown" inset="2" id="udR-nJ-pZY">
                                             <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                             <font key="font" metaFont="system"/>
                                         </buttonCell>
+                                        <constraints>
+                                            <constraint firstAttribute="height" constant="24" id="yrC-QK-pLc"/>
+                                        </constraints>
                                         <connections>
                                             <action selector="lineTypeButtonAction:" target="-2" id="atb-rS-7Sl"/>
                                         </connections>
@@ -625,10 +625,10 @@
                                 </constraints>
                             </customView>
                             <customView translatesAutoresizingMaskIntoConstraints="NO" id="RvS-7l-bgc">
-                                <rect key="frame" x="16" y="817" width="449" height="51"/>
+                                <rect key="frame" x="16" y="820" width="449" height="54"/>
                                 <subviews>
-                                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="FwF-01-QBW">
-                                        <rect key="frame" x="-2" y="31" width="453" height="20"/>
+                                    <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="FwF-01-QBW">
+                                        <rect key="frame" x="-2" y="34" width="453" height="20"/>
                                         <constraints>
                                             <constraint firstAttribute="height" constant="20" id="dhS-GB-vO7"/>
                                         </constraints>
@@ -639,7 +639,7 @@
                                         </textFieldCell>
                                     </textField>
                                     <comboBox focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="RfV-LZ-n4w" customClass="KMComboBox" customModule="PDF_Reader_Pro" customModuleProvider="target">
-                                        <rect key="frame" x="377" y="0.0" width="72" height="23"/>
+                                        <rect key="frame" x="376" y="2" width="73" height="23"/>
                                         <constraints>
                                             <constraint firstAttribute="width" constant="69" id="8OG-pa-Aq1"/>
                                         </constraints>
@@ -659,7 +659,7 @@
                                         </connections>
                                     </comboBox>
                                     <slider verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="6ox-uY-Xd9">
-                                        <rect key="frame" x="-2" y="-3" width="371" height="28"/>
+                                        <rect key="frame" x="-2" y="-2" width="371" height="28"/>
                                         <sliderCell key="cell" alignment="left" maxValue="1" tickMarkPosition="above" sliderType="linear" id="02E-sv-zXi"/>
                                         <connections>
                                             <action selector="opacitySliderAction:" target="-2" id="2vM-r9-SaR"/>
@@ -681,7 +681,7 @@
                             <customView translatesAutoresizingMaskIntoConstraints="NO" id="joR-lq-lUb">
                                 <rect key="frame" x="16" y="611" width="449" height="64"/>
                                 <subviews>
-                                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="eJ4-EW-YPt">
+                                    <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="eJ4-EW-YPt">
                                         <rect key="frame" x="-2" y="34" width="50" height="20"/>
                                         <constraints>
                                             <constraint firstAttribute="height" constant="20" id="xLM-Hk-PW8"/>
@@ -758,7 +758,7 @@
                             <customView translatesAutoresizingMaskIntoConstraints="NO" id="Yht-jz-1VV">
                                 <rect key="frame" x="16" y="537" width="449" height="64"/>
                                 <subviews>
-                                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="K0o-2w-Okl">
+                                    <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="K0o-2w-Okl">
                                         <rect key="frame" x="-2" y="34" width="39" height="20"/>
                                         <constraints>
                                             <constraint firstAttribute="height" constant="20" id="eXX-uF-6Ej"/>
@@ -774,60 +774,60 @@
                                         <subviews>
                                             <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ukt-HS-mUF">
                                                 <rect key="frame" x="0.0" y="0.0" width="24" height="24"/>
-                                                <constraints>
-                                                    <constraint firstAttribute="width" constant="24" id="XzW-er-LUO"/>
-                                                    <constraint firstAttribute="height" constant="24" id="uyl-hS-gP1"/>
-                                                </constraints>
                                                 <buttonCell key="cell" type="bevel" bezelStyle="rounded" image="KMImageNameUXIconPropertybarFillsignTickNor" imagePosition="only" alignment="center" imageScaling="proportionallyDown" inset="2" id="z7x-v7-Pob">
                                                     <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                                     <font key="font" metaFont="system"/>
                                                 </buttonCell>
+                                                <constraints>
+                                                    <constraint firstAttribute="width" constant="24" id="XzW-er-LUO"/>
+                                                    <constraint firstAttribute="height" constant="24" id="uyl-hS-gP1"/>
+                                                </constraints>
                                             </button>
                                             <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="lfs-Al-Pi6">
                                                 <rect key="frame" x="106" y="0.0" width="24" height="24"/>
-                                                <constraints>
-                                                    <constraint firstAttribute="height" constant="24" id="1og-ji-xzZ"/>
-                                                    <constraint firstAttribute="width" constant="24" id="aeR-Vq-NOe"/>
-                                                </constraints>
                                                 <buttonCell key="cell" type="bevel" bezelStyle="rounded" image="KMImageNameUXIconPropertybarFillsignForkNor" imagePosition="only" alignment="center" imageScaling="proportionallyDown" inset="2" id="ZHe-lG-2fF">
                                                     <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                                     <font key="font" metaFont="system"/>
                                                 </buttonCell>
+                                                <constraints>
+                                                    <constraint firstAttribute="height" constant="24" id="1og-ji-xzZ"/>
+                                                    <constraint firstAttribute="width" constant="24" id="aeR-Vq-NOe"/>
+                                                </constraints>
                                             </button>
                                             <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="M0W-kD-80i">
                                                 <rect key="frame" x="213" y="0.0" width="24" height="24"/>
-                                                <constraints>
-                                                    <constraint firstAttribute="height" constant="24" id="doP-M6-xZk"/>
-                                                    <constraint firstAttribute="width" constant="24" id="tIC-xZ-ACw"/>
-                                                </constraints>
                                                 <buttonCell key="cell" type="bevel" bezelStyle="rounded" image="KMImageNameUXIconPropertybarFillsignRoundedrecNor" imagePosition="only" alignment="center" imageScaling="proportionallyDown" inset="2" id="FWZ-tb-YwG">
                                                     <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                                     <font key="font" metaFont="system"/>
                                                 </buttonCell>
+                                                <constraints>
+                                                    <constraint firstAttribute="height" constant="24" id="doP-M6-xZk"/>
+                                                    <constraint firstAttribute="width" constant="24" id="tIC-xZ-ACw"/>
+                                                </constraints>
                                             </button>
                                             <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="EUu-AQ-1vt">
                                                 <rect key="frame" x="319" y="0.0" width="24" height="24"/>
-                                                <constraints>
-                                                    <constraint firstAttribute="height" constant="24" id="Ld7-qc-gUH"/>
-                                                    <constraint firstAttribute="width" constant="24" id="dJM-yY-gRu"/>
-                                                </constraints>
                                                 <buttonCell key="cell" type="bevel" bezelStyle="rounded" image="KMImageNameUXIconPropertybarFillsignLineNor" imagePosition="only" alignment="center" imageScaling="proportionallyDown" inset="2" id="7Hb-Le-cQu">
                                                     <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                                     <font key="font" metaFont="system"/>
                                                 </buttonCell>
+                                                <constraints>
+                                                    <constraint firstAttribute="height" constant="24" id="Ld7-qc-gUH"/>
+                                                    <constraint firstAttribute="width" constant="24" id="dJM-yY-gRu"/>
+                                                </constraints>
                                             </button>
                                             <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="HUY-7m-MAh">
                                                 <rect key="frame" x="425" y="0.0" width="24" height="24"/>
-                                                <constraints>
-                                                    <constraint firstAttribute="width" constant="24" id="0px-Ms-77p"/>
-                                                    <constraint firstAttribute="height" constant="24" id="Orc-fV-85S"/>
-                                                </constraints>
                                                 <buttonCell key="cell" type="bevel" bezelStyle="rounded" image="KMImageNameUXIconPropertybarFillsignPointNor" imagePosition="only" alignment="center" imageScaling="proportionallyDown" inset="2" id="ADb-1x-YJl">
                                                     <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                                     <font key="font" metaFont="system"/>
                                                 </buttonCell>
+                                                <constraints>
+                                                    <constraint firstAttribute="width" constant="24" id="0px-Ms-77p"/>
+                                                    <constraint firstAttribute="height" constant="24" id="Orc-fV-85S"/>
+                                                </constraints>
                                             </button>
-                                            <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="QSn-tN-yKq">
+                                            <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="QSn-tN-yKq">
                                                 <rect key="frame" x="22" y="4" width="86" height="16"/>
                                                 <textFieldCell key="cell" lineBreakMode="clipping" id="zig-4h-RlL">
                                                     <font key="font" metaFont="system"/>
@@ -835,7 +835,7 @@
                                                     <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                                                 </textFieldCell>
                                             </textField>
-                                            <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="2Rq-R5-NNa">
+                                            <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="2Rq-R5-NNa">
                                                 <rect key="frame" x="128" y="4" width="87" height="16"/>
                                                 <textFieldCell key="cell" lineBreakMode="clipping" id="6NB-UM-esl">
                                                     <font key="font" metaFont="system"/>
@@ -843,7 +843,7 @@
                                                     <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                                                 </textFieldCell>
                                             </textField>
-                                            <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="h7b-Mq-6cG">
+                                            <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="h7b-Mq-6cG">
                                                 <rect key="frame" x="235" y="4" width="86" height="16"/>
                                                 <textFieldCell key="cell" lineBreakMode="clipping" id="NNh-RR-Lqn">
                                                     <font key="font" metaFont="system"/>
@@ -851,7 +851,7 @@
                                                     <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                                                 </textFieldCell>
                                             </textField>
-                                            <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="v1b-mb-wLg">
+                                            <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="v1b-mb-wLg">
                                                 <rect key="frame" x="341" y="4" width="86" height="16"/>
                                                 <textFieldCell key="cell" lineBreakMode="clipping" id="T0Y-Wv-y6H">
                                                     <font key="font" metaFont="system"/>
@@ -900,7 +900,7 @@
                             <customView translatesAutoresizingMaskIntoConstraints="NO" id="PaC-YN-6O9">
                                 <rect key="frame" x="16" y="434" width="449" height="93"/>
                                 <subviews>
-                                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="98v-4b-0OB">
+                                    <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="98v-4b-0OB">
                                         <rect key="frame" x="-2" y="63" width="37" height="20"/>
                                         <constraints>
                                             <constraint firstAttribute="height" constant="20" id="uZ5-aL-PoH"/>
@@ -913,9 +913,6 @@
                                     </textField>
                                     <popUpButton translatesAutoresizingMaskIntoConstraints="NO" id="oZl-TH-Bvx" customClass="KMPopUpButton" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                         <rect key="frame" x="-5" y="29" width="454" height="24"/>
-                                        <constraints>
-                                            <constraint firstAttribute="height" constant="24" id="xWe-Zh-6dg"/>
-                                        </constraints>
                                         <popUpButtonCell key="cell" type="square" title="Item 1" bezelStyle="shadowlessSquare" alignment="left" lineBreakMode="truncatingTail" state="on" imageScaling="proportionallyDown" inset="2" arrowPosition="noArrow" selectedItem="fEY-zW-raT" id="JrJ-qI-5wL">
                                             <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                             <font key="font" metaFont="menu"/>
@@ -927,6 +924,9 @@
                                                 </items>
                                             </menu>
                                         </popUpButtonCell>
+                                        <constraints>
+                                            <constraint firstAttribute="height" constant="24" id="xWe-Zh-6dg"/>
+                                        </constraints>
                                         <connections>
                                             <action selector="dateCheckButtonAction:" target="-2" id="UVL-pn-LDb"/>
                                         </connections>
@@ -956,7 +956,7 @@
                             <customView translatesAutoresizingMaskIntoConstraints="NO" id="jhc-Pb-0cV">
                                 <rect key="frame" x="16" y="260" width="449" height="164"/>
                                 <subviews>
-                                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ZHR-Sp-5tZ">
+                                    <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ZHR-Sp-5tZ">
                                         <rect key="frame" x="-2" y="130" width="34" height="24"/>
                                         <constraints>
                                             <constraint firstAttribute="height" constant="24" id="3Ou-mK-X6d"/>
@@ -975,14 +975,14 @@
                                             <subviews>
                                                 <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="3Ed-Ae-CMS">
                                                     <rect key="frame" x="28" y="0.0" width="50" height="56"/>
-                                                    <constraints>
-                                                        <constraint firstAttribute="width" constant="50" id="OPO-Ry-2DB"/>
-                                                        <constraint firstAttribute="height" constant="56" id="y9b-b7-L6i"/>
-                                                    </constraints>
                                                     <buttonCell key="cell" type="square" title="Button" bezelStyle="shadowlessSquare" image="KMImageNameUXIconPropertybarNoteAnnotationNor" imagePosition="above" alignment="center" scrollable="YES" lineBreakMode="clipping" imageScaling="proportionallyDown" inset="2" id="8we-yJ-WKl" customClass="KMNoteIconButtonCell" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                                         <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                                         <font key="font" metaFont="smallSystem"/>
                                                     </buttonCell>
+                                                    <constraints>
+                                                        <constraint firstAttribute="width" constant="50" id="OPO-Ry-2DB"/>
+                                                        <constraint firstAttribute="height" constant="56" id="y9b-b7-L6i"/>
+                                                    </constraints>
                                                     <connections>
                                                         <action selector="iconButtonAction:" target="-2" id="9w4-tQ-4B5"/>
                                                     </connections>
@@ -1003,7 +1003,7 @@
                                             <rect key="frame" x="0.0" y="0.0" width="107" height="56"/>
                                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                             <subviews>
-                                                <button verticalHuggingPriority="750" tag="1" translatesAutoresizingMaskIntoConstraints="NO" id="pNP-oo-3HC">
+                                                <button tag="1" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="pNP-oo-3HC">
                                                     <rect key="frame" x="28" y="0.0" width="50" height="56"/>
                                                     <buttonCell key="cell" type="square" title="Button" bezelStyle="shadowlessSquare" image="KMImageNameUXIconPropertybarNoteKeywordNor" imagePosition="above" alignment="center" scrollable="YES" lineBreakMode="clipping" imageScaling="proportionallyDown" inset="2" id="x9S-PD-K5t" customClass="KMNoteIconButtonCell" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                                         <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@@ -1029,7 +1029,7 @@
                                             <rect key="frame" x="0.0" y="0.0" width="106" height="56"/>
                                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                             <subviews>
-                                                <button verticalHuggingPriority="750" tag="3" translatesAutoresizingMaskIntoConstraints="NO" id="VCq-Fv-Klu">
+                                                <button tag="3" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="VCq-Fv-Klu">
                                                     <rect key="frame" x="28" y="0.0" width="50" height="56"/>
                                                     <buttonCell key="cell" type="square" title="Button" bezelStyle="shadowlessSquare" image="KMImageNameUXIconPropertybarNoteHelpNor" imagePosition="above" alignment="center" scrollable="YES" lineBreakMode="clipping" imageScaling="proportionallyDown" inset="2" id="kSq-7X-thX" customClass="KMNoteIconButtonCell" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                                         <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@@ -1055,7 +1055,7 @@
                                             <rect key="frame" x="0.0" y="0.0" width="106" height="56"/>
                                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                             <subviews>
-                                                <button verticalHuggingPriority="750" tag="4" translatesAutoresizingMaskIntoConstraints="NO" id="d7b-6U-kd3">
+                                                <button tag="4" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="d7b-6U-kd3">
                                                     <rect key="frame" x="28" y="0.0" width="50" height="56"/>
                                                     <buttonCell key="cell" type="square" title="Button" bezelStyle="shadowlessSquare" image="KMImageNameUXIconPropertybarNoteNewparagraphNor" imagePosition="above" alignment="center" scrollable="YES" lineBreakMode="clipping" imageScaling="proportionallyDown" inset="2" id="Xdy-yH-fug" customClass="KMNoteIconButtonCell" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                                         <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@@ -1081,7 +1081,7 @@
                                             <rect key="frame" x="0.0" y="0.0" width="107" height="56"/>
                                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                             <subviews>
-                                                <button verticalHuggingPriority="750" tag="5" translatesAutoresizingMaskIntoConstraints="NO" id="sxj-hT-PcD">
+                                                <button tag="5" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="sxj-hT-PcD">
                                                     <rect key="frame" x="28" y="0.0" width="50" height="56"/>
                                                     <buttonCell key="cell" type="square" title="Button" bezelStyle="shadowlessSquare" image="KMImageNameUXIconPropertybarNoteParagraphNor" imagePosition="above" alignment="center" scrollable="YES" lineBreakMode="clipping" imageScaling="proportionallyDown" inset="2" id="uwc-Vw-AjX" customClass="KMNoteIconButtonCell" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                                         <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@@ -1107,7 +1107,7 @@
                                             <rect key="frame" x="0.0" y="0.0" width="106" height="56"/>
                                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                             <subviews>
-                                                <button verticalHuggingPriority="750" tag="6" translatesAutoresizingMaskIntoConstraints="NO" id="fgj-OF-eg6">
+                                                <button tag="6" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="fgj-OF-eg6">
                                                     <rect key="frame" x="28" y="0.0" width="50" height="56"/>
                                                     <buttonCell key="cell" type="square" title="Button" bezelStyle="shadowlessSquare" image="KMImageNameUXIconPropertybarNoteInsertNor" imagePosition="above" alignment="center" scrollable="YES" lineBreakMode="clipping" imageScaling="proportionallyDown" inset="2" id="OSE-y6-2oj" customClass="KMNoteIconButtonCell" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                                         <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@@ -1133,7 +1133,7 @@
                                             <rect key="frame" x="0.0" y="0.0" width="106" height="56"/>
                                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                             <subviews>
-                                                <button verticalHuggingPriority="750" tag="2" translatesAutoresizingMaskIntoConstraints="NO" id="InC-Sr-498">
+                                                <button tag="2" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="InC-Sr-498">
                                                     <rect key="frame" x="28" y="0.0" width="50" height="56"/>
                                                     <buttonCell key="cell" type="square" title="Button" bezelStyle="shadowlessSquare" image="KMImageNameUXIconPropertybarNoteNotesNor" imagePosition="above" alignment="center" scrollable="YES" lineBreakMode="clipping" imageScaling="proportionallyDown" inset="2" id="4HQ-Cw-eAg" customClass="KMNoteIconButtonCell" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                                         <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@@ -1196,7 +1196,7 @@
                             <customView translatesAutoresizingMaskIntoConstraints="NO" id="sRx-9T-I8q">
                                 <rect key="frame" x="16" y="10" width="449" height="240"/>
                                 <subviews>
-                                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="s1l-c4-MtY">
+                                    <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="s1l-c4-MtY">
                                         <rect key="frame" x="-2" y="210" width="37" height="20"/>
                                         <constraints>
                                             <constraint firstAttribute="height" constant="20" id="NUR-LV-pJP"/>
@@ -1247,9 +1247,9 @@
                                 </constraints>
                             </customView>
                             <customView translatesAutoresizingMaskIntoConstraints="NO" id="CS7-HL-m8i">
-                                <rect key="frame" x="16" y="888" width="449" height="72"/>
+                                <rect key="frame" x="16" y="894" width="449" height="72"/>
                                 <subviews>
-                                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Xnj-9I-IIC">
+                                    <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Xnj-9I-IIC">
                                         <rect key="frame" x="-2" y="42" width="62" height="20"/>
                                         <constraints>
                                             <constraint firstAttribute="height" constant="20" id="m3d-WT-9YN"/>
@@ -1354,27 +1354,27 @@
                             </imageView>
                             <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="sYo-IE-4Vd">
                                 <rect key="frame" x="406" y="32" width="16" height="16"/>
-                                <constraints>
-                                    <constraint firstAttribute="width" constant="16" id="4Ey-Cn-WTH"/>
-                                    <constraint firstAttribute="height" constant="16" id="iLk-Q3-Y73"/>
-                                </constraints>
                                 <buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="KMImageNameUXIconBtnTriDownNor" imagePosition="overlaps" alignment="center" imageScaling="proportionallyDown" inset="2" id="oHx-Zm-zTd">
                                     <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                     <font key="font" metaFont="system"/>
                                 </buttonCell>
+                                <constraints>
+                                    <constraint firstAttribute="width" constant="16" id="4Ey-Cn-WTH"/>
+                                    <constraint firstAttribute="height" constant="16" id="iLk-Q3-Y73"/>
+                                </constraints>
                                 <connections>
                                     <action selector="textImageBoxButtonAction:" target="-2" id="WEW-d2-aI8"/>
                                 </connections>
                             </button>
                             <button hidden="YES" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="VlT-10-Y8y">
                                 <rect key="frame" x="356" y="30" width="42" height="20"/>
-                                <constraints>
-                                    <constraint firstAttribute="height" constant="20" id="J9f-Se-4X9"/>
-                                </constraints>
                                 <buttonCell key="cell" type="square" title="Button" bezelStyle="shadowlessSquare" alignment="center" imageScaling="proportionallyDown" inset="2" id="vyy-7c-IqO">
                                     <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                     <font key="font" metaFont="cellTitle"/>
                                 </buttonCell>
+                                <constraints>
+                                    <constraint firstAttribute="height" constant="20" id="J9f-Se-4X9"/>
+                                </constraints>
                             </button>
                         </subviews>
                         <constraints>

+ 23 - 318
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

@@ -255,10 +255,6 @@ extension KMMainViewController {
     
     func cropMenu() -> NSMenu {
         let menu = NSMenu()
-        _ = menu.insertItem(withTitle: NSLocalizedString("Crop Current Page", comment: ""), action:#selector(cropCurrentPage), target: self, at: 0)
-        _ = menu.insertItem(withTitle: NSLocalizedString("Crop All Pages", comment: ""), action:#selector(cropAllPage), target: self, at: 1)
-        _ = menu.insertItem(withTitle: NSLocalizedString("Auto Crop – Separate", comment: ""), action:#selector(autoCropAll), target: self, at: 2)
-        _ = menu.insertItem(withTitle: NSLocalizedString("Auto Crop – Combined", comment: ""), action:#selector(smartAutoCropAll), target: self, at: 2)
         return menu
     }
     
@@ -527,11 +523,7 @@ extension KMMainViewController {
     func setCropStype() -> NSMenuItem {
         let stypItem = NSMenuItem(title: NSLocalizedString("Crop", comment: ""), action: nil, target: self)
         let stypeMenu = NSMenu()
-        _ = stypeMenu.addItem(withTitle: NSLocalizedString("Crop All Pages", comment: ""), action: #selector(cropAllPageItem), target: self, tag: 0)
-        _ = stypeMenu.addItem(withTitle: NSLocalizedString("Crop Current Page", comment: ""), action: #selector(cropCurrentPageItem), target: self, tag: 1)
-        _ = stypeMenu.addItem(withTitle: NSLocalizedString("Auto Crop – Separate", comment: ""), action: #selector(autoCropAllItem), target: self, tag: 2)
-        _ = stypeMenu.addItem(withTitle: NSLocalizedString("Auto Crop – Combined", comment: ""), action: #selector(smartAutoCropAllItem), target: self, tag: 3)
-        if NSIsEmptyRect(listView.selectionRect){
+         if NSIsEmptyRect(listView.selectionRect){
             _ = stypeMenu.addItem(withTitle: NSLocalizedString("Select Area", comment: ""), action: #selector(selectToolModel), target: self, tag: 4)
             _ = stypeMenu.addItem(withTitle: NSLocalizedString("Crop Options...", comment: ""), action: #selector(customCropModel), target: self, tag: 5)
         }
@@ -816,44 +808,9 @@ extension KMMainViewController {
     @objc func OpenItemAction(sender: NSMenuItem) {
         
     }
-    
-    @objc func cropAllPageItem(sender: NSMenuItem) {
-        self.cropAll(nil)
-    }
-    @objc func cropCurrentPageItem(sender: NSMenuItem) {
-        self.crop(nil)
-    }
-    @objc func autoCropAllItem(sender: NSMenuItem) {
-        self.autoCropAll(nil)
-    }
-    @objc func smartAutoCropAllItem(sender: NSMenuItem) {
-        self.smartAutoCropAll(nil)
-    }
+     
     @objc func customCropModel(sender: NSMenuItem) {
-        let pdfDoc: CPDFDocument = self.listView.document
-        if !pdfDoc.allowsCopying || !pdfDoc.allowsPrinting {
-            let alert = NSAlert()
-            alert.alertStyle = .critical
-            alert.messageText = NSLocalizedString("This is a secured document. Editing is not permitted.", comment: "")
-            alert.runModal()
-            return
-        }
-        let window = NSWindow.currentWindow()
-        let currentPage = pdfDoc.index(for: self.listView.currentPage())
-        let cropVC = KMPDFCropWindowController(document: pdfDoc, pwd: "", currentPage: Int(currentPage), cropSize: NSMakeRect(100, 100, 50, 80), selectPageString: "\(currentPage)")
-        window.km_beginSheet(windowC: cropVC)
-        cropVC.cropWindowCloseBlock = { [weak self] doc in
-            window.km_quick_endSheet()
-            let isSuccessful = doc.write(to: self?.listView.document?.documentURL)
-            if isSuccessful {
-                if let documen = CPDFDocument(url: self?.document?.documentURL) {
-                    if documen.isLocked {
-                        documen.unlock(withPassword: pdfDoc.password)
-                    }
-                    self?.setDocument = documen
-                }
-            }
-        }
+        
     }
     @objc func rotateRightAction(sender: NSMenuItem) {
         
@@ -1033,13 +990,13 @@ extension KMMainViewController {
                     annotation = self.listView.addAnnotation(with: .line, selection: nil, page: currentPage, bounds: bounds)
                 case 7:
                     self.listView.annotationType = CAnnotationType.link
-                    self.openRightPane()
+                    toggleOpenRightSide()
                 case 8:
                     self.listView.annotationType = CAnnotationType.stamp
-                    self.openRightPane()
+                    toggleOpenRightSide()
                 case 9:
                     self.listView.annotationType = CAnnotationType.signSignature
-                    self.openRightPane()
+                    toggleOpenRightSide()
                 default:
                     break
                 }
@@ -1095,13 +1052,13 @@ extension KMMainViewController {
                     annotation = self.listView.addAnnotation(with: .line, selection: nil, page: currentPage, bounds: bounds)
                 case 7:
                     self.listView.annotationType = CAnnotationType.link
-                    self.openRightPane()
+                    toggleOpenRightSide()
                 case 8:
                     self.listView.annotationType = CAnnotationType.stamp
-                    self.openRightPane()
+                    toggleOpenRightSide()
                 case 9:
                     self.listView.annotationType = CAnnotationType.signSignature
-                    self.openRightPane()
+                    toggleOpenRightSide()
                 case 10:
                     self.addImgAnnotationToView(center: pagePoint)
                 default:
@@ -1730,226 +1687,6 @@ extension KMMainViewController {
     
     //MARK: - action
     
-    @objc func cropCurrentPage() {
-        var rect = NSIntegralRect(self.listView.currentSelectionRect())
-        var page: CPDFPage?
-        if let data = self.listView.currentSelectionPage() {
-            page = data
-        } else {
-            page = self.listView.currentPage()
-        }
-        
-        if (NSIsEmptyRect(rect)) {
-            rect = KMCropTools.getPageForegroundBox(page!)
-        }
-        
-        let index: UInt = (page?.pageIndex()) ?? 0
-        self._cropPage(at: index, in: rect)
-        
-        // 执行右键操作后,需要取消框选区域
-        if self.listView.toolMode == .selectToolMode {
-            objc_sync_enter(self)
-            self.listView.selectionRect = NSZeroRect
-            self.listView.selectionPageIndex = UInt(NSNotFound)
-            objc_sync_exit(self)
-        }
-        self.handlePageBoundsDidChange(page: page, action: CPDFPage.Action.crop)
-    }
-    
-    @objc private func _cropPage(at index: UInt, in rect: NSRect) {
-        let oldRect = self.listView.document?.page(at: index)?.bounds(for: .cropBox) ?? .zero
-        let undoManager = self.listView.undoManager
-        (undoManager?.prepare(withInvocationTarget: self) as? AnyObject)?._cropPage(at: index, in: oldRect)
-        
-        let page = self.listView.document.page(at: index)
-        let newRect = NSIntersectionRect(rect, (page?.bounds(for: .mediaBox)) ?? .zero)
-        page?.setBounds(newRect, for: .cropBox)
-        
-        /// 刷新预览视图
-        self.listView.layoutDocumentView()
-        self.listView.displayBox = .cropBox
-    }
-    
-    func beginProgressSheet(with message: String, maxValue: UInt) { 
-        let progress = SKProgressController()
-        progress.window?.contentView?.wantsLayer = true
-        progress.message = NSLocalizedString("Converting...", comment: "")
-        self.progressC = progress
-        self.progressC?.message = message
-        if maxValue > 0 {
-            progressC?.indeterminate = false
-            progressC?.maxValue = Double(maxValue)
-        } else {
-            progressC?.indeterminate = true
-        }
-        self.view.km_beginSheet(windowC: progressC!)
-    }
-    
-    // 白边距
-    @objc func smart_cropAllPage() {
-        var size = NSZeroSize
-        for i in 0 ..< self.listView.document.pageCount {
-            let page = self.listView.document.page(at: i)
-            let rect = KMCropTools.getPageForegroundBox(page!)
-            size.width = fmax(size.width, NSWidth(rect))
-            size.height = fmax(size.height, NSHeight(rect))
-        }
-        beginProgressSheet(with: KMLocalizedString("Cropping Pages"), maxValue: min(18, self.listView.document.pageCount))
-        var rectArray: Array<NSRect> = []
-        for i in 0 ..< self.listView.document.pageCount {
-            progressC?.increment(by: Double(i))
-            progressC?.doubleValue = Double(i)
-            let page = self.listView.document.page(at: i)
-            var rect = KMCropTools.getPageForegroundBox(page!)
-            let bounds: NSRect = (page?.bounds(for: .mediaBox))!
-            
-            rectArray.append(rect)
-        }
-        
-        cropPages(to: rectArray)
-        self.handlePageBoundsDidChange(page: nil, action: CPDFPage.Action.crop)
-    }
-    
-    // 自动
-    @objc func auto_cropAllPage() {
-        var size = NSZeroSize
-        for i in 0 ..< self.listView.document.pageCount {
-            let page = self.listView.document.page(at: i)
-            let rect = KMCropTools.getPageForegroundBox(page!)
-            size.width = fmax(size.width, NSWidth(rect))
-            size.height = fmax(size.height, NSHeight(rect))
-        }
-        beginProgressSheet(with: KMLocalizedString("Cropping Pages"), maxValue: min(18, self.listView.document.pageCount))
-        var rectArray: Array<NSRect> = []
-        for i in 0 ..< self.listView.document.pageCount {
-            progressC?.increment(by: Double(i))
-            progressC?.doubleValue = Double(i)
-            let page = self.listView.document.page(at: i)
-            var rect = KMCropTools.getPageForegroundBox(page!)
-            let bounds: NSRect = (page?.bounds(for: .mediaBox))!
-            if (rect.minX - bounds.minX > bounds.maxX-rect.maxX) {
-                rect.origin.x = rect.maxX-size.width
-            }
-            
-            rect.origin.y = rect.maxY-size.height
-            rect.size = size
-            
-            if (NSWidth(rect) > NSWidth(bounds)) {
-                rect.size.width = NSWidth(bounds)
-            }
-            if (NSHeight(rect) > NSHeight(bounds)) {
-                rect.size.height = NSHeight(bounds)
-            }
-            
-            if (NSMinX(rect) < NSMinX(bounds)) {
-                rect.origin.x = NSMinX(bounds)
-            } else if (NSMaxX(rect) > NSMaxX(bounds)) {
-                rect.origin.x = NSMaxX(bounds) - NSWidth(rect)
-            }
-            
-            if (NSMinY(rect) < NSMinY(bounds)) {
-                rect.origin.y = NSMinY(bounds)
-            } else if (NSMaxY(rect) > NSMaxY(bounds)) {
-                rect.origin.y = NSMaxY(bounds) - NSHeight(rect)
-            }
-            
-            rectArray.append(rect)
-        }
-        
-        cropPages(to: rectArray)
-        self.handlePageBoundsDidChange(page: nil, action: CPDFPage.Action.crop)
-    }
-    
-    @objc func cropAllPage() {
-        var rect = [NSIntegralRect(self.listView.currentSelectionRect() ?? .zero), .zero]
-        var rectArray: Array<NSRect> = []
-        let emptySelection = NSIsEmptyRect(rect.first ?? .zero)
-        if (emptySelection) {
-            guard let count = self.listView.document?.pageCount, count > 0 else {
-                KMPrint("listView | document is nil.", beep: true)
-                return
-            }
-            rect[0] = .zero
-            rect[1] = .zero
-            self.beginProgressSheet(withMessage: NSLocalizedString("Cropping Pages", comment: "Message for progress sheet"), maxValue: min(18, count))
-            if (count == 1) {
-                if let page = self.listView.document.page(at: 0) {
-                    rect[0] = KMCropTools.getPageForegroundBox(page)
-                }
-                progressC?.increment(by: 1)
-            } else if (count < 19) {
-                for i in 0 ..< 19 {
-                    if let page = self.listView.document.page(at: UInt(i)) {
-                        rect[i % 2] = NSUnionRect(rect[i % 2], KMCropTools.getPageForegroundBox(page))
-                        progressC?.increment(by: Double(i))
-                    }
-                }
-            } else {
-                let start = [1, (count - 5) / 2, count - 6]
-                var cnt = 0
-                for j in 0 ..< 3 {
-                    for i in 0 ..< 6 {
-                        let k = Int(start[j] + UInt(i))
-                        if let page = self.listView.document.page(at: UInt(k)) {
-                            rect[k % 2] = NSUnionRect(rect[k % 2], KMCropTools.getPageForegroundBox(page))
-                            cnt += 1
-                            progressC?.increment(by: Double(cnt))
-                        }
-                    }
-                }
-            }
-            let w = fmax(NSWidth(rect[0]), NSWidth(rect[1]))
-            let h = fmax(NSHeight(rect[0]), NSHeight(rect[1]))
-            for j in 0 ..< 2 {
-                rect[j] = NSMakeRect(floor(NSMidX(rect[j]) - 0.5 * w), floor(NSMidY(rect[j]) - 0.5 * h), w, h)
-            }
-            rectArray.append(rect.first ?? .zero)
-            rectArray.append(rect.last ?? .zero)
-        } else {
-            rectArray.append(rect.first ?? .zero)
-        }
-        
-        self.cropPages(to: rectArray)
-        // 执行右键操作后,需要取消框选区域
-        if self.listView.toolMode == .selectToolMode {
-            objc_sync_enter(self)
-            self.listView.selectionRect = NSZeroRect
-            self.listView.selectionPageIndex = UInt(NSNotFound)
-            objc_sync_exit(self)
-        }
-        self.handlePageBoundsDidChange(page: nil, action: CPDFPage.Action.crop)
-    }
-    
-    func cropPages(to rects: Array<NSRect>) {
-        let currentPage = self.listView.currentPage()
-        let visibleRect: NSRect = self.listView.convert(self.listView.convert(self.listView.documentView().visibleRect, from: self.listView.documentView()), to: self.listView.currentPage())
-        
-        var oldRectArray: Array<NSRect> = []
-        let rectCount = rects.count
-        for i in 0 ..< self.listView.document.pageCount {
-            let page = self.listView.document.page(at: i)
-            let rect = NSIntersectionRect(rects[Int(i) % rectCount], (page?.bounds(for: .mediaBox))!)
-            let oldRect = page?.bounds(for: .cropBox)
-            oldRectArray.append(oldRect!)
-            
-            page?.setBounds(rect, for: .cropBox)
-        }
-        
-        let undoManager = self.listView.undoManager
-        (undoManager?.prepare(withInvocationTarget: self) as AnyObject).cropPages(to: oldRectArray)
-        
-        /// 刷新预览视图
-        self.listView.layoutDocumentView()
-        
-        self.listView.displayBox = .cropBox
-        
-        self.listView.go(to: currentPage)
-        self.listView.go(to: visibleRect, on: currentPage)
-        DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.25) { [self] in
-            self.dismissProgressSheet()
-        }
-    }
-    
     
     // 开启/关闭左边栏
     @objc func toggleLeftPane() -> Void {
@@ -2115,29 +1852,7 @@ extension KMMainViewController {
             splitView(withTag: menuItem.tag)
         }
     }
-    
-    
-    func handlePageBoundsDidChange(page: CPDFPage?, action: String) {
-        let displayChanged = action == CPDFPage.Action.crop || self.listView.displayBox == .cropBox
-        
-        if (displayChanged) {
-            self.listView.layoutDocumentView()
-        }
-        if (page != nil) {
-            let idx = page!.pageIndex()
-            if (displayChanged) {
-                self.leftSideViewController.updateThumbnail(at: Int(idx))
-            }
-        } else {
-            if (displayChanged) {
-                self.leftSideViewController.allThumbnailsNeedUpdate()
-            }
-        }
-        self.leftSideViewController.updateSnapshotsIfNeed(for: page)
-        
-        if UserDefaults.standard.bool(forKey: SKDisplayPageBoundsKey) {
-        }
-    }
+     
     
     func changeLineAttribute(_ sender: Any?) {
         var inspector = sender as? KMLineInspector
@@ -2633,7 +2348,7 @@ extension KMMainViewController {
             return
         }
         listView.addAnnotationWithTable()
-        openRightPane()
+        toggleOpenRightSide()
     }
     
     func isDamageImage(_ image: NSImage, imagePath path: String) -> Bool {
@@ -2851,7 +2566,7 @@ extension KMMainViewController : KMToolbarViewControllerDelegate {
         alert.messageText = NSLocalizedString("Processing times may be longer for larger documents. Thank you for your patience.", comment: "")
         alert.addButton(withTitle: NSLocalizedString("Continue", comment: ""))
         alert.addButton(withTitle: NSLocalizedString("Cancel", comment: ""))
-        alert.beginSheetModal(for: view.window!) { [unowned self] result in
+        alert.beginSheetModal(for: view.window!) { [weak self] result in
             if (result == .alertFirstButtonReturn) {
                 
             } else if result == .alertSecondButtonReturn {
@@ -2934,8 +2649,7 @@ extension KMMainViewController : KMToolbarViewControllerDelegate {
         }else if type == .Form {
             self.showFormAlertView()
         }else if type == .Select {
-
-            self.closeRightPane()
+            toggleCloseRightSide()
         }
     }
     
@@ -3078,7 +2792,7 @@ extension KMMainViewController : KMToolbarViewControllerDelegate {
                 }
                 if (index == 1) { /// 取消
                     ///
-                    self.closeRightPane()
+                    toggleCloseRightSide()
                     return
                 } else if index == 3 {
                     let fpath = self.document?.documentURL?.path ?? ""
@@ -3144,7 +2858,7 @@ extension KMMainViewController : KMToolbarViewControllerDelegate {
                 } else if (index == 2) { /// 应用
                      
                 } else if index == 5 {
-                     self.openRightPane()
+                     self.toggleOpenRightSide()
                 }
             } else if (type == .redact) { /// 标记密文
                 if !IAPProductsManager.default().isAvailableAllFunction(){
@@ -3461,7 +3175,7 @@ extension KMMainViewController : KMToolbarViewControllerDelegate {
                     let fpath = self.document?.documentURL?.path ?? ""
                     self.showBatchWindow(type: .RemoveWatermark, filepaths: [fpath])
                 } else if index == 5 {
-                     self.openRightPane()
+                    toggleOpenRightSide()
                     return
                 }
             } else if type == .background {
@@ -3512,7 +3226,7 @@ extension KMMainViewController : KMToolbarViewControllerDelegate {
                     let fpath = self.document?.documentURL?.path ?? ""
                     self.showBatchWindow(type: .RemoveBackground, filepaths: [fpath])
                 } else if index == 5 {
-                     self.openRightPane()
+                    toggleOpenRightSide()
                     return
                 }
             } else if type == .measure {
@@ -3632,7 +3346,7 @@ extension KMMainViewController : KMToolbarViewControllerDelegate {
                     
                 }
                 
-                 self.openRightPane()
+                toggleOpenRightSide()
             }
         }
     }
@@ -3664,9 +3378,9 @@ extension KMMainViewController : KMToolbarViewControllerDelegate {
                     if toolbarItem.isSelected {
                         FMTrackEventManager.defaultManager.trackEvent(event: "SubTbr_PageDisplay", withProperties: ["SubTbr_Btn": "Btn_SubTbr_PageDisplay_ViewSetting"])
  
-                        self.openRightPane()
+                        toggleOpenRightSide()
                     }else{
-                         closeRightPane()
+                        toggleCloseRightSide()
                     }
                     if toolbarItem.isSelected {
                         FMTrackEventManager.defaultManager.trackEvent(event: "Tbr", withProperties: ["Tbr_Btn": "Btn_Tbr_PageDisplay"])
@@ -3738,10 +3452,9 @@ extension KMMainViewController : KMToolbarViewControllerDelegate {
                     toolbarItem.isSelected = !toolbarItem.isSelected
                      self.listView.annotationType = .unkown
                     if toolbarItem.isSelected {
- 
-                         self.openRightPane()
+                        toggleOpenRightSide()
                     }else{
-                         closeRightPane()
+                        toggleCloseRightSide()
                     }
                 } else if toolbarItem.itemIdentifier == KMToolbarSnapshotIdentifier {
                     FMTrackEventManager.defaultManager.trackEvent(event: "SubTbr_PageDisplay", withProperties: ["SubTbr_Btn": "Btn_SubTbr_PageDisplay_Snapshot"])
@@ -3889,15 +3602,7 @@ extension KMMainViewController : KMToolbarViewControllerDelegate {
         } else if (toolbarItem.itemIdentifier == KMToolbarConversionCreatePDFItemIdentifier) {
             self.createPdf(index: index)
         } else if (toolbarItem.itemIdentifier == KMToolbarCropIdentifier) {
-            if index == 2 { // 裁剪当前页面
-                self.cropCurrentPage()
-            } else if index == 3 { // Auto Crop – Separate
-                self.smart_cropAllPage()
-            } else if index == 4 { // Auto Crop – Combined
-                self.auto_cropAllPage()
-            } else if index == 5 { // Select Area
-             }
-            FMTrackEventManager.defaultManager.trackEvent(event: "SubTbr_PageDisplay", withProperties: ["SubTbr_Btn": "Btn_SubTbr_PageDisplay_Crop"])
+            
         } else if (toolbarItem.itemIdentifier == KMToolbarToolSecureItemIdentifier) {
             self.clickChildTool(type: .secure, index: index)
             FMTrackEventManager.defaultManager.trackEvent(event: "SubTbr_Editor", withProperties: ["SubTbr_Btn": "Btn_SubTbr_Editor_Security"])

+ 4 - 38
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+MenuAction.swift

@@ -551,19 +551,7 @@ extension KMMainViewController {
 // MARK: - KMSystemPDFMenuProtocol
 
 extension KMMainViewController: KMSystemPDFMenuProtocol {
-    func changeDisplayMode(_ sender: Any?) {
-        
-    }
-    
-    func toggleDisplayAsBook(_ sender: Any?) {
-       
-    }
-    
-    func toggleDisplayPageBreaks(_ sender: Any?) {
-        self.listView.displaysPageBreaks = !(self.listView.displaysPageBreaks ?? false)
-        self.listView.layoutDocumentView()
-    }
-    
+      
     func changeDisplayBox(_ sender: Any?) {
         guard let item = sender as? NSMenuItem else {
             NSSound.beep()
@@ -860,27 +848,6 @@ extension KMMainViewController: KMSystemToolMenuProtocol {
     func decryption(_ sender: Any?) {
      }
     
-    func cropAll(_ sender: Any?) {
-        self.cropAllPage()
-    }
-    
-    func crop(_ sender: Any?) {
-        self.cropCurrentPage()
-    }
-    
-    // 白边距
-    func autoCropAll(_ sender: Any?) {
-        self.smart_cropAllPage()
-    }
-    
-    // 自动
-    func smartAutoCropAll(_ sender: Any?) {
-        self.auto_cropAllPage()
-    }
-    
-    func cropOptionsModel(_ sender: Any?) {
-        KMPrint("cropOptionsModel ...")
-    }
     
     func selectToolModel(_ sender: Any?) {
      }
@@ -1014,7 +981,7 @@ extension KMMainViewController: KMSystemToolMenuProtocol {
             page.leftRotate()
             
             self.rotatePageItems(pageItems: [KMThumbnailPageItem(page: page, rotate: page.rotation, oldRotate: rotation)])
-            self.handlePageBoundsDidChange(page: page, action: CPDFPage.Action.rotate)
+
         }
     }
     
@@ -1033,7 +1000,7 @@ extension KMMainViewController: KMSystemToolMenuProtocol {
             page.rightRotate()
             
             self.rotatePageItems(pageItems: [KMThumbnailPageItem(page: page, rotate: page.rotation, oldRotate: rotation)])
-            self.handlePageBoundsDidChange(page: page, action: CPDFPage.Action.rotate)
+
         }
     }
     
@@ -1053,7 +1020,7 @@ extension KMMainViewController: KMSystemToolMenuProtocol {
             }
             
             self.rotatePageItems(pageItems: pageItems)
-            self.handlePageBoundsDidChange(page: nil, action: CPDFPage.Action.rotate)
+
         }
     }
     
@@ -1073,7 +1040,6 @@ extension KMMainViewController: KMSystemToolMenuProtocol {
             }
             
             self.rotatePageItems(pageItems: pageItems)
-            self.handlePageBoundsDidChange(page: nil, action: CPDFPage.Action.rotate)
         }
     }
     

+ 6 - 7
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift

@@ -258,7 +258,7 @@ extension KMMainViewController: KMToolbarControllerDelegate {
                 }
             }
             self.listView.annotationType = .unkown
-            self.closeRightPane()
+            toggleCloseRightSide()
         } else {
             let type = CAnnotationType(rawValue: item.tag) ?? CAnnotationType.unkown
             self.trackEvent(annotationType: type)
@@ -295,24 +295,24 @@ extension KMMainViewController: KMToolbarControllerDelegate {
             let toolMode = self.listView.toolMode ?? .none
            
             if !viewManager.isPDFReadMode {
-                self.openRightPane()
+                toggleOpenRightSide()
             }
         } else if self.listView.toolMode == .editPDFToolMode {
             if editSelectd {
                 self.listView.setShouAddEdit([])
                 self.listView.change([.text, .image])
                 self.listView.annotationType = .editTextImage
-                self.closeRightPane()
+                toggleCloseRightSide()
             } else if self.listView.annotationType == .addText {
                 if !viewManager.isPDFReadMode {
-                    self.openRightPane()
+                    toggleOpenRightSide()
                 }
                 FMTrackEventManager.defaultManager.trackEvent(event: "SubTbr_EditPDF", withProperties: ["SubTbr_Btn" : "Btn_SubTbr_EditPDF_AddText"])
                 self.listView.setShouAddEdit(.text)
                 self.listView.change(.text)
             } else if self.listView.annotationType == .addImage {
                 if !viewManager.isPDFReadMode {
-                    self.openRightPane()
+                    toggleOpenRightSide()
                 }
                 FMTrackEventManager.defaultManager.trackEvent(event: "SubTbr_EditPDF", withProperties: ["SubTbr_Btn" : "Btn_SubTbr_EditPDF_AddImage"])
  
@@ -321,8 +321,7 @@ extension KMMainViewController: KMToolbarControllerDelegate {
 
             }
         } else {
-
-            self.closeRightPane()
+            toggleCloseRightSide()
         }
     }
     

+ 3 - 0
PDF Office/PDF Master/KMClass/KMNPDFPageEdit/KMNPDFInsert/KMNPDFInsertBlankWindowController.swift

@@ -642,6 +642,7 @@ class KMNPDFInsertBlankWindowController: KMNBaseWindowController {
     
 }
 
+//MARK: - ComponentInputNumberDelegate
 extension KMNPDFInsertBlankWindowController: ComponentInputNumberDelegate {
     func componentInputNumberDidValueChanged(inputNumber: ComponentInputNumber?) {
         if(inputNumber == pageNumInput) {
@@ -650,6 +651,7 @@ extension KMNPDFInsertBlankWindowController: ComponentInputNumberDelegate {
     }
 }
 
+//MARK: - ComponentSelectDelegate
 extension KMNPDFInsertBlankWindowController: ComponentSelectDelegate {
     func componentSelectDidSelect(view: ComponentSelect?, menuItemProperty: ComponentMenuitemProperty?) {
         if(view == unitSelect) {
@@ -671,6 +673,7 @@ extension KMNPDFInsertBlankWindowController: ComponentSelectDelegate {
     
 }
 
+//MARK: - ComponentInputDelegate
 extension KMNPDFInsertBlankWindowController: ComponentInputDelegate {
    
     //文字变化

+ 8 - 8
PDF Office/PDF Master/KMClass/KMNPDFPageEdit/KMNPDFInsert/KMNPDFInsertPDFWindowController.xib

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
     <dependencies>
         <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
@@ -35,7 +35,7 @@
             <windowStyleMask key="styleMask" titled="YES" fullSizeContentView="YES"/>
             <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
             <rect key="contentRect" x="196" y="240" width="557" height="563"/>
-            <rect key="screenRect" x="0.0" y="0.0" width="1512" height="944"/>
+            <rect key="screenRect" x="0.0" y="0.0" width="1920" height="1055"/>
             <view key="contentView" id="se5-gp-TjO">
                 <rect key="frame" x="0.0" y="0.0" width="480" height="372"/>
                 <autoresizingMask key="autoresizingMask"/>
@@ -46,7 +46,7 @@
                             <rect key="frame" x="0.0" y="0.0" width="432" height="340"/>
                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                             <subviews>
-                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="nVt-ye-20v">
+                                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="nVt-ye-20v">
                                     <rect key="frame" x="-2" y="324" width="436" height="16"/>
                                     <textFieldCell key="cell" lineBreakMode="clipping" title="Insert File" id="S0u-WL-oBc">
                                         <font key="font" usesAppearanceFont="YES"/>
@@ -72,7 +72,7 @@
                                                     <constraint firstAttribute="height" constant="32" id="vqe-8f-ty4"/>
                                                 </constraints>
                                             </customView>
-                                            <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="vLC-Uy-bWz">
+                                            <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="vLC-Uy-bWz">
                                                 <rect key="frame" x="-2" y="84" width="436" height="16"/>
                                                 <textFieldCell key="cell" lineBreakMode="clipping" title="Form File" id="ELj-Y5-Gb3">
                                                     <font key="font" usesAppearanceFont="YES"/>
@@ -80,7 +80,7 @@
                                                     <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                                                 </textFieldCell>
                                             </textField>
-                                            <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="2mp-wK-3MJ">
+                                            <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="2mp-wK-3MJ">
                                                 <rect key="frame" x="-2" y="8" width="80" height="16"/>
                                                 <textFieldCell key="cell" lineBreakMode="clipping" title="Page Range:" id="fiE-1K-NiO">
                                                     <font key="font" usesAppearanceFont="YES"/>
@@ -132,7 +132,7 @@
                                                     <constraint firstAttribute="height" constant="20" id="X4e-au-sQo"/>
                                                 </constraints>
                                             </customView>
-                                            <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="e7a-sg-bz8">
+                                            <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="e7a-sg-bz8">
                                                 <rect key="frame" x="-2" y="108" width="436" height="16"/>
                                                 <textFieldCell key="cell" lineBreakMode="clipping" title="Form File" id="IcN-r8-Kef">
                                                     <font key="font" usesAppearanceFont="YES"/>
@@ -160,7 +160,7 @@
                                                     <constraint firstAttribute="height" constant="32" id="Bvo-ul-zuG"/>
                                                 </constraints>
                                             </customView>
-                                            <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="dMn-2x-fc2">
+                                            <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="dMn-2x-fc2">
                                                 <rect key="frame" x="194" y="16" width="32" height="16"/>
                                                 <textFieldCell key="cell" lineBreakMode="clipping" title="/200" id="d0w-sT-Tgo">
                                                     <font key="font" usesAppearanceFont="YES"/>

+ 1 - 0
PDF Office/PDF Master/KMClass/KMNPDFPageEdit/KMNPDFSplit/KMNSplitPDFWindowController.swift

@@ -672,6 +672,7 @@ extension KMNSplitPDFWindowController: ComponentSelectDelegate {
     }
 }
 
+//MARK: - ComponentInputDelegate
 extension KMNSplitPDFWindowController: ComponentInputDelegate {
     func componentInputDidEndEditing(inputView: ComponentInput) {
         

+ 9 - 9
PDF Office/PDF Master/KMClass/KMNPDFPageEdit/KMNPDFSplit/KMNSplitPDFWindowController.xib

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
     <dependencies>
         <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
@@ -45,7 +45,7 @@
             <windowStyleMask key="styleMask" titled="YES" fullSizeContentView="YES"/>
             <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
             <rect key="contentRect" x="196" y="240" width="480" height="270"/>
-            <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1415"/>
+            <rect key="screenRect" x="0.0" y="0.0" width="1920" height="1055"/>
             <view key="contentView" id="se5-gp-TjO">
                 <rect key="frame" x="0.0" y="0.0" width="480" height="502"/>
                 <autoresizingMask key="autoresizingMask"/>
@@ -56,7 +56,7 @@
                             <rect key="frame" x="0.0" y="0.0" width="432" height="470"/>
                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                             <subviews>
-                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="jDk-6k-wPg">
+                                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="jDk-6k-wPg">
                                     <rect key="frame" x="-2" y="454" width="436" height="16"/>
                                     <textFieldCell key="cell" lineBreakMode="clipping" title="Split" id="cYm-fs-fJs">
                                         <font key="font" usesAppearanceFont="YES"/>
@@ -84,7 +84,7 @@
                                                     <constraint firstAttribute="height" constant="32" id="gdP-n3-RdE"/>
                                                 </constraints>
                                             </customView>
-                                            <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="UQm-9R-ufX">
+                                            <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="UQm-9R-ufX">
                                                 <rect key="frame" x="-2" y="138" width="436" height="16"/>
                                                 <textFieldCell key="cell" lineBreakMode="clipping" title="Split Method" id="cI1-Kj-hfi">
                                                     <font key="font" usesAppearanceFont="YES"/>
@@ -112,7 +112,7 @@
                                                     <constraint firstAttribute="height" constant="32" id="wWO-v0-kf7"/>
                                                 </constraints>
                                             </customView>
-                                            <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="taE-wg-hAl">
+                                            <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="taE-wg-hAl">
                                                 <rect key="frame" x="208" y="102" width="226" height="16"/>
                                                 <textFieldCell key="cell" lineBreakMode="clipping" title="page(s) split into a PDF file" id="Xjj-Vz-9HY">
                                                     <font key="font" metaFont="system"/>
@@ -127,7 +127,7 @@
                                                     <constraint firstAttribute="height" constant="32" id="xt9-QO-Oc7"/>
                                                 </constraints>
                                             </customView>
-                                            <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="hSV-Fh-E6f">
+                                            <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="hSV-Fh-E6f">
                                                 <rect key="frame" x="210" y="62" width="224" height="16"/>
                                                 <textFieldCell key="cell" lineBreakMode="clipping" title="PDF files" id="uMu-7j-jve">
                                                     <font key="font" metaFont="system"/>
@@ -199,7 +199,7 @@
                                         <rect key="frame" x="0.0" y="0.0" width="432" height="64"/>
                                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                         <subviews>
-                                            <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="E7d-kr-3NP">
+                                            <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="E7d-kr-3NP">
                                                 <rect key="frame" x="-2" y="40" width="436" height="16"/>
                                                 <textFieldCell key="cell" lineBreakMode="clipping" title="File Name" id="zp9-BF-8N0">
                                                     <font key="font" usesAppearanceFont="YES"/>
@@ -213,7 +213,7 @@
                                                     <rect key="frame" x="0.0" y="0.0" width="432" height="32"/>
                                                     <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                                     <subviews>
-                                                        <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="G4G-Lb-K8M">
+                                                        <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="G4G-Lb-K8M">
                                                             <rect key="frame" x="3" y="8" width="426" height="16"/>
                                                             <textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="Split Method" id="SGc-TN-nF0">
                                                                 <font key="font" usesAppearanceFont="YES"/>

+ 4 - 0
PDF Office/PDF Master/KMClass/KMNPDFPageEdit/KMNThumbnailManager.swift

@@ -29,6 +29,10 @@ public class KMNThumbnail: NSObject {
         }
     }
     
+    deinit {
+        print("\(self.className) deinit")
+    }
+    
     public init(document: CPDFDocument,currentPageIndex:Int) {
         thumbnailDocument = document
         pageIndex = currentPageIndex

+ 15 - 0
PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/Background/KMBackgroundController.swift

@@ -128,6 +128,12 @@ class KMBackgroundController: NSViewController {
         }
     }
     
+    override func mouseUp(with event: NSEvent) {
+        super.mouseUp(with: event)
+        
+        
+    }
+    
 }
 
 //MARK: - KMBackgroundPropertyControllerDelegate
@@ -149,6 +155,13 @@ extension KMBackgroundController: KMBackgroundPropertyControllerDelegate {
     }
     
     func backgroundPropertyControllerSaveTemplateSuccess(_ controller: KMBackgroundPropertyController, _ data: KMBackgroundModel) {
+        saveTemplateMessage.frame = CGRectMake((CGRectGetWidth(self.view.frame) - saveTemplateMessage.properties.propertyInfo.viewWidth)/2,
+                                               CGRectGetHeight(self.view.frame) - saveTemplateMessage.properties.propertyInfo.viewHeight - 8,
+                                               saveTemplateMessage.properties.propertyInfo.viewWidth,
+                                               saveTemplateMessage.properties.propertyInfo.viewHeight)
+        saveTemplateMessage.reloadData()
+        saveTemplateMessage.show(inView: self.view, autoHideSeconde: 2)
+        
         editSubType = .template
         delegate?.kmBackgroundControllerDidUpdateMode?(self)
         
@@ -196,6 +209,8 @@ extension KMBackgroundController: KMBGTemplateControllerDelegate {
         backgroundModel = propertyController.backgroundData
         
         reloadData()
+        
+        documentPreview.layoutDocumentView()
     }
     
     func templateControllerDidEditData(_ controller: KMBGTemplateController, _ data: KMBackgroundModel) {

+ 5 - 5
PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/Background/KMBackgroundController.xib

@@ -17,17 +17,17 @@
         <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
         <customObject id="-3" userLabel="Application" customClass="NSObject"/>
         <customView id="Hz6-mo-xeY">
-            <rect key="frame" x="0.0" y="0.0" width="480" height="272"/>
+            <rect key="frame" x="0.0" y="0.0" width="666" height="299"/>
             <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
             <subviews>
                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="vwj-JT-Jnm">
-                    <rect key="frame" x="0.0" y="0.0" width="480" height="272"/>
+                    <rect key="frame" x="0.0" y="0.0" width="666" height="299"/>
                     <subviews>
                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="lFn-9k-oLs">
-                            <rect key="frame" x="0.0" y="0.0" width="216" height="272"/>
+                            <rect key="frame" x="0.0" y="0.0" width="402" height="299"/>
                         </customView>
                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="hy0-v8-4wP">
-                            <rect key="frame" x="216" y="0.0" width="264" height="272"/>
+                            <rect key="frame" x="402" y="0.0" width="264" height="299"/>
                             <constraints>
                                 <constraint firstAttribute="width" constant="264" id="Vbq-03-cBK"/>
                             </constraints>
@@ -50,7 +50,7 @@
                 <constraint firstAttribute="trailing" secondItem="vwj-JT-Jnm" secondAttribute="trailing" id="w3R-MK-LXp"/>
                 <constraint firstItem="vwj-JT-Jnm" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="yS4-U5-92v"/>
             </constraints>
-            <point key="canvasLocation" x="123" y="144"/>
+            <point key="canvasLocation" x="-40" y="98"/>
         </customView>
     </objects>
 </document>

+ 59 - 17
PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/Background/KMBackgroundManager.swift

@@ -69,6 +69,7 @@ class KMBackgroundManager: NSObject  {
         }
     }
     
+    //MARK: - 增删改查
     func addTemplate(model: KMBackgroundModel) -> Bool {
         if (!FileManager.default.fileExists(atPath: kBackgroundFolderPath!)) {
             let create: ()? = try?FileManager.default.createDirectory(atPath: kBackgroundFolderPath!, withIntermediateDirectories: false)
@@ -174,8 +175,7 @@ class KMBackgroundManager: NSObject  {
         }
         
         KMDataManager.ud_set(nil, forKey: Self.kRemovedKey)
-        self._clearStored()
-        
+ 
         return result
     }
     
@@ -208,9 +208,7 @@ class KMBackgroundManager: NSObject  {
                 self.datas.removeObject(model)
             }
         }
-        
-        self._clearStored()
-        
+         
         return result
     }
     
@@ -244,8 +242,6 @@ class KMBackgroundManager: NSObject  {
             }
         }
         
-        self._clearStored()
-        
         return result
     }
     
@@ -343,9 +339,8 @@ class KMBackgroundManager: NSObject  {
         
     }
      
+    //MARK: - parse
     func parseModelToDict(model: KMBackgroundModel) -> Dictionary<String, Any> {
-        let tag = model.backgroundID
-        
         var dict: [String : Any] = [:]
         if (model.type == .color) {
             dict["color"] = model.color?.colorToHexString()
@@ -380,7 +375,6 @@ class KMBackgroundManager: NSObject  {
                 model.color = NSColor.km_init(hex: value as! String)
             }
         }
-        
         model.scale = dict.object(forKey: "scale") as! CGFloat
         model.rotation = CGFloat(Int(dict.object(forKey: "rotation") as! CGFloat))
         model.opacity = (dict.object(forKey: "opacity") as! CGFloat)
@@ -391,21 +385,69 @@ class KMBackgroundManager: NSObject  {
         if let value = dict.object(forKey: "backgroundID") {
             model.backgroundID = value as! String
         }
-        
         if let value = dict.object(forKey: "name") {
             model.name = value as! String
         }
-        
- 
         return model
     }
     
-    private func _clearStored() {
-        let defaults = UserDefaults.standard
-        defaults.set(nil, forKey: "kBackgroundInfoSaveKey")
-        defaults.synchronize()
+    //MARK: - Compare
+    class func compareIsChangedModel(_ model: KMBackgroundModel, withDict dict: NSDictionary) -> Bool {
+        if let value = dict["type"] {
+            if model.type != CPDFBackgroundType(rawValue: value as! Int)! {
+                return true
+            }
+        }
+        
+        if let value = dict["color"] {
+            if model.color?.colorToHexString() != (value as! String) {
+                return true
+            }
+        }
+         
+        if let value = dict["rotation"] {
+            if model.rotation != (value as! CGFloat) {
+                return true
+            }
+        }
+         
+        if let value = dict["opacity"] {
+            if model.opacity != (value as! CGFloat) {
+                return true
+            }
+        }
+         
+        if let value = dict["scale"] {
+            if model.scale != (value as! CGFloat) {
+                return true
+            }
+        }
+        
+        if let value = dict["verticalMode"] {
+            if model.verticalMode != (value as! Int) {
+                return true
+            }
+        }
+        if let value = dict["verticalSpace"] {
+            if model.verticalSpace != (value as! CGFloat) {
+                return true
+            }
+        }
+        if let value = dict["horizontalMode"] {
+            if model.horizontalMode != (value as! Int) {
+                return true
+            }
+        }
+        if let value = dict["horizontalSpace"] {
+            if model.horizontalSpace != (value as! CGFloat) {
+                return true
+            }
+        }
+         
+        return false
     }
     
+    //MARK: - Get
     func fetchAvailableBackgroundName() -> String {
         var availableIndex = 0
         

+ 5 - 3
PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/Background/KMBackgroundModel.swift

@@ -172,8 +172,10 @@ import Cocoa
                                                   rect.origin.y+(rect.size.height-size.height)/2.0,
                                                   size.width, size.height));
         } else if (self.type == .image) {
-            let image = self.image()
-            var size: NSSize = image!.size
+            var size: NSSize = CGSizeZero
+            if let image = self.image() {
+                size = image.size
+            }
             size.width *= self.scale
             size.height *= self.scale
             
@@ -217,7 +219,7 @@ import Cocoa
             let finalRect = NSMakeRect(rect.origin.x+(rect.size.width-size.width)/2.0,
                                        rect.origin.y+(rect.size.height-size.height)/2.0,
                                        size.width, size.height)
-            image?.draw(in: NSMakeRect(rect.origin.x+(rect.size.width-size.width)/2.0,
+            image.draw(in: NSMakeRect(rect.origin.x+(rect.size.width-size.width)/2.0,
                                        rect.origin.y+(rect.size.height-size.height)/2.0,
                                        size.width, size.height), from: NSZeroRect, operation: .sourceOver, fraction: self.opacity)
         }

PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/Background/Views/KMBGTemplateController.swift → PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/Views/KMBGTemplateController.swift


PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/Background/Views/KMBGTemplateController.xib → PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/Views/KMBGTemplateController.xib


PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/Background/Views/KMBGTemplateItem.swift → PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/Views/KMBGTemplateItem.swift


PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/Background/Views/KMBGTemplateItem.xib → PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/Views/KMBGTemplateItem.xib


+ 69 - 27
PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/Background/Views/KMBackgroundPropertyController.swift

@@ -33,8 +33,11 @@ class KMBackgroundPropertyController: NSViewController {
     @IBOutlet var titleLabel: NSTextField!
     @IBOutlet var templateButton: ComponentButton!
     
+    @IBOutlet var typeTabsBGView: NSView!
     @IBOutlet var typeTabs: ComponentTabs!
     
+    @IBOutlet var infoContendView: NSView!
+    @IBOutlet var infoContendTopConst: NSLayoutConstraint!
     //Text
     @IBOutlet var textBGView: NSView!
     @IBOutlet var colorLabel: NSTextField!
@@ -68,7 +71,6 @@ class KMBackgroundPropertyController: NSViewController {
     private var textTabProperty = ComponentTabsProperty(tabsType: .underline_Fill, state: .normal, showIcon: false, title: KMLocalizedString("Text"))
     private var fileTabProperty = ComponentTabsProperty(tabsType: .underline_Fill, state: .normal, showIcon: false, title: KMLocalizedString("File"))
     
-    private var isEditModeChanged: Bool = false //修改时,记录是否有做过调整
     
     weak open var delegate: KMBackgroundPropertyControllerDelegate?
     
@@ -77,6 +79,7 @@ class KMBackgroundPropertyController: NSViewController {
 
     var editSubType: KMPDFEditSubModeType = .none
  
+    //MARK: - func
     override func viewDidLoad() {
         super.viewDidLoad()
         // Do view setup here.
@@ -142,7 +145,8 @@ class KMBackgroundPropertyController: NSViewController {
                                                                        state: .normal,
                                                                        creatable: true,
                                                                        text: "0°",
-                                                                       regexString: "0123456789°-")
+                                                                       textUnit: "°",
+                                                                       regexString: "0123456789-")
         var rotateItems: [ComponentMenuitemProperty] = []
         for string in ["0°", "45°", "-45°", "90°", "-90°"] {
             let item = ComponentMenuitemProperty(type: .normal, text: string)
@@ -155,7 +159,8 @@ class KMBackgroundPropertyController: NSViewController {
                                                                         state: .normal,
                                                                         creatable: true,
                                                                         text: "100%",
-                                                                        regexString: "0123456789%")
+                                                                        textUnit: "%",
+                                                                        regexString: "0123456789")
         var opacityItems: [ComponentMenuitemProperty] = []
         for string in ["25%", "50%", "75%", "100%"] {
             let item = ComponentMenuitemProperty(type: .normal, text: string)
@@ -171,7 +176,8 @@ class KMBackgroundPropertyController: NSViewController {
                                                                      state: .normal,
                                                                      creatable: true,
                                                                      text: "100%",
-                                                                     regexString: "0123456789%")
+                                                                     textUnit: "%",
+                                                                     regexString: "0123456789")
         var appearanceScaleItems: [ComponentMenuitemProperty] = []
         for string in ["25%", "50%", "75%", "100%", "125%", "150%","200%"] {
             let item = ComponentMenuitemProperty(type: .normal, text: string)
@@ -216,11 +222,24 @@ class KMBackgroundPropertyController: NSViewController {
         leftTopButton.isHidden = true
         saveTemplateBGView.isHidden = false
         templateButton.properties.icon = NSImage(named: "icon_wm_template")
+        templateButton.properties.isDisabled = false
+        
+        infoContendTopConst.constant = 56
+        typeTabsBGView.isHidden = false
         if editSubType == .edit {
+            infoContendTopConst.constant = 8
+            typeTabsBGView.isHidden = true
+            
             titleLabel.stringValue = KMLocalizedString("Edit Background")
             leftTopButton.isHidden = false
             saveTemplateBGView.isHidden = true
             templateButton.properties.icon = NSImage(named: "edit_save")
+            
+            if backgroundData.type == .image {
+                if backgroundData.imagePath == nil {
+                    templateButton.properties.isDisabled = true
+                }
+            }
         }
         templateButton.reloadData()
         
@@ -266,14 +285,40 @@ class KMBackgroundPropertyController: NSViewController {
         appearanceScaleSelect.properties.text = String(format: "%.0f", backgroundData.scale*100) + "%"
         appearanceScaleSelect.reloadData()
   
-        
         //Position
+        if backgroundData.verticalMode == 2 {
+            positionItemView.properties.selRow = 0
+        } else if backgroundData.verticalMode == 1 {
+            positionItemView.properties.selRow = 1
+        } else if backgroundData.verticalMode == 0 {
+            positionItemView.properties.selRow = 2
+        }
+        
+        if backgroundData.horizontalMode == 0 {
+            positionItemView.properties.selColumn = 0
+        } else if backgroundData.horizontalMode == 1 {
+            positionItemView.properties.selColumn = 1
+        } else if backgroundData.horizontalMode == 2 {
+            positionItemView.properties.selColumn = 2
+        }
+        positionItemView.reloadData()
+        
         positionXInput.properties.text = String(format: "%.0f", backgroundData.horizontalSpace)
         positionXInput.reloadData()
         
         positionYInput.properties.text = String(format: "%.0f", backgroundData.verticalSpace)
         positionYInput.reloadData()
 
+        if backgroundData.type == .color {
+            saveButton.properties.isDisabled = false
+        } else if backgroundData.type == .image {
+            if let path = backgroundData.imagePath {
+                saveButton.properties.isDisabled = false
+            } else {
+                saveButton.properties.isDisabled = true
+            }
+        }
+        saveButton.reloadData()
          
     }
     
@@ -286,7 +331,12 @@ class KMBackgroundPropertyController: NSViewController {
     //MARK: - Action
     @objc func leftTopButtonClicked(_ sender: ComponentButton) {
         if sender == leftTopButton {
-            if isEditModeChanged == true {
+            var isChanged = false
+            if let dict = self.originalDataDict {
+                isChanged = KMBackgroundManager.compareIsChangedModel(backgroundData, withDict: dict as NSDictionary)
+             }
+            
+            if isChanged == true {
                 let alert = NSAlert()
                 alert.alertStyle = .critical
                 alert.messageText = KMLocalizedString("Save template changes?")
@@ -298,8 +348,7 @@ class KMBackgroundPropertyController: NSViewController {
                         let _ = KMBackgroundManager.defaultManager.updateTemplate(model: self.backgroundData)
                         
                         self.delegate?.backgroundPropertyControllerFinishTemplateEdit?(self)
-                        
-                        self.isEditModeChanged = false
+                         
                     } else {
                         if let dict = self.originalDataDict {
                             KMBackgroundManager.defaultManager.updateModel(self.backgroundData, withDict: dict as NSDictionary)
@@ -307,14 +356,12 @@ class KMBackgroundPropertyController: NSViewController {
                             let _ = KMBackgroundManager.defaultManager.updateTemplate(model: self.backgroundData)
                         }
                         self.delegate?.backgroundPropertyControllerFinishTemplateEdit?(self)
-                        
-                        self.isEditModeChanged = false
+                         
                     }
                 }
             } else {
                 delegate?.backgroundPropertyControllerCancelTemplateEdit?(self)
-
-                isEditModeChanged = false
+ 
             }
         }
         
@@ -334,8 +381,6 @@ class KMBackgroundPropertyController: NSViewController {
         if sender == appearanceScaleCheckbox {
             backgroundData.isScale = appearanceScaleCheckbox.properties.checkboxType == .selected ? true : false
         }
-        isEditModeChanged = true
-        
         reloadData()
         
         delegate?.backgroundPropertyControllerDidUpdate?(self)
@@ -459,6 +504,14 @@ class KMBackgroundPropertyController: NSViewController {
             return nil
         }
     }
+    
+    //MARK: - Mouse
+    override func mouseDown(with event: NSEvent) {
+        super.mouseDown(with: event)
+        
+        view.window?.makeFirstResponder(nil)
+        
+    }
 }
 
 //MARK: - ComponentTabsDelegate
@@ -469,8 +522,6 @@ extension KMBackgroundPropertyController: ComponentTabsDelegate {
         } else if property == fileTabProperty {
             backgroundData.type = .image
         }
-        isEditModeChanged = true
-        
         reloadData()
         
         delegate?.backgroundPropertyControllerDidUpdate?(self)
@@ -483,8 +534,6 @@ extension KMBackgroundPropertyController: ComponentCColorDelegate {
         if view == fontColorGroup {
             backgroundData.color = color ?? NSColor.clear
         }
-        isEditModeChanged = true
-        
         reloadData()
         
         delegate?.backgroundPropertyControllerDidUpdate?(self)
@@ -510,8 +559,6 @@ extension KMBackgroundPropertyController: ComponentSelectDelegate {
                 backgroundData.scale = result.stringToCGFloat()/100
             }
         }
-        isEditModeChanged = true
-        
         reloadData()
         
         delegate?.backgroundPropertyControllerDidUpdate?(self)
@@ -531,10 +578,9 @@ extension KMBackgroundPropertyController: ComponentSelectDelegate {
         } else if view == appearanceScaleSelect {
             if let text = appearanceScaleSelect.properties.text {
                 let result = text.stringByDeleteCharString("%")
-                backgroundData.scale = result.stringToCGFloat()/100
+                backgroundData.scale = min(10, result.stringToCGFloat()/100)
             }
         }
-        isEditModeChanged = true
         
         reloadData()
         
@@ -564,8 +610,6 @@ extension KMBackgroundPropertyController: ComponentCPositionDelegate {
                 backgroundData.horizontalMode = 2
             }
         }
-        isEditModeChanged = true
-        
         reloadData()
         
         delegate?.backgroundPropertyControllerDidUpdate?(self)
@@ -583,9 +627,7 @@ extension KMBackgroundPropertyController: ComponentInputNumberDelegate {
             if let text = inputNumber?.properties.text {
                 backgroundData.verticalSpace = text.stringToCGFloat()
             }
-        }
-        isEditModeChanged = true
-        
+        } 
         reloadData()
         
         delegate?.backgroundPropertyControllerDidUpdate?(self)

+ 12 - 9
PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/Background/Views/KMBackgroundPropertyController.xib

@@ -21,6 +21,8 @@
                 <outlet property="fileInputAddonView" destination="td8-2n-Z9H" id="NWb-q6-Ccr"/>
                 <outlet property="fileInputView" destination="dMT-80-cRR" id="eXe-DS-6X3"/>
                 <outlet property="fontColorGroup" destination="HRP-Of-jmt" id="AGC-aG-TIW"/>
+                <outlet property="infoContendTopConst" destination="bqf-4L-XCU" id="j1X-q1-Ttk"/>
+                <outlet property="infoContendView" destination="2r8-sI-aCB" id="eKf-y5-7xw"/>
                 <outlet property="leftTopButton" destination="fkD-oz-UOI" id="jl8-Oa-sDw"/>
                 <outlet property="positionBGView" destination="cw7-VT-eh2" id="fdL-Qy-gMn"/>
                 <outlet property="positionItemView" destination="lnN-m1-X5q" id="am5-Xb-2Bg"/>
@@ -33,20 +35,21 @@
                 <outlet property="textBGView" destination="MiZ-mc-j5Q" id="Ple-aS-UXa"/>
                 <outlet property="titleLabel" destination="wwm-pR-ypi" id="6Pa-fG-lUe"/>
                 <outlet property="typeTabs" destination="7I9-B4-CbU" id="OM1-Tv-jbr"/>
+                <outlet property="typeTabsBGView" destination="3bI-RP-0y4" id="ZEh-Nm-fZ4"/>
                 <outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
             </connections>
         </customObject>
         <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
         <customObject id="-3" userLabel="Application" customClass="NSObject"/>
         <customView id="Hz6-mo-xeY">
-            <rect key="frame" x="0.0" y="0.0" width="281" height="800"/>
+            <rect key="frame" x="0.0" y="0.0" width="281" height="831"/>
             <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
             <subviews>
                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="rFc-TS-7es">
-                    <rect key="frame" x="0.0" y="0.0" width="281" height="800"/>
+                    <rect key="frame" x="0.0" y="0.0" width="281" height="831"/>
                     <subviews>
                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="4tG-T7-TSW">
-                            <rect key="frame" x="0.0" y="760" width="281" height="40"/>
+                            <rect key="frame" x="0.0" y="791" width="281" height="40"/>
                             <subviews>
                                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="fkD-oz-UOI" customClass="ComponentButton" customModule="KMComponentLibrary">
                                     <rect key="frame" x="8" y="8" width="24" height="24"/>
@@ -91,7 +94,7 @@
                             </constraints>
                         </customView>
                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="3bI-RP-0y4">
-                            <rect key="frame" x="0.0" y="704" width="281" height="56"/>
+                            <rect key="frame" x="0.0" y="735" width="281" height="56"/>
                             <subviews>
                                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="7I9-B4-CbU" customClass="ComponentTabs" customModule="KMComponentLibrary">
                                     <rect key="frame" x="25" y="16" width="232" height="32"/>
@@ -108,7 +111,7 @@
                             </constraints>
                         </customView>
                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="2r8-sI-aCB">
-                            <rect key="frame" x="0.0" y="38" width="281" height="666"/>
+                            <rect key="frame" x="0.0" y="69" width="281" height="666"/>
                             <subviews>
                                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="MiZ-mc-j5Q">
                                     <rect key="frame" x="25" y="594" width="232" height="72"/>
@@ -153,10 +156,9 @@
                                     <rect key="frame" x="25" y="634" width="232" height="32"/>
                                     <subviews>
                                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="dMT-80-cRR" customClass="ComponentInput" customModule="KMComponentLibrary">
-                                            <rect key="frame" x="0.0" y="0.0" width="199" height="32"/>
+                                            <rect key="frame" x="0.0" y="0.0" width="201" height="32"/>
                                             <constraints>
                                                 <constraint firstAttribute="height" constant="32" id="tDe-dp-0aJ"/>
-                                                <constraint firstAttribute="width" constant="199" id="tdW-lB-rIi"/>
                                             </constraints>
                                         </customView>
                                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="td8-2n-Z9H" customClass="ComponentInputAddon" customModule="KMComponentLibrary">
@@ -170,6 +172,7 @@
                                     <constraints>
                                         <constraint firstItem="td8-2n-Z9H" firstAttribute="centerY" secondItem="SYp-51-eQM" secondAttribute="centerY" id="HWG-h3-C39"/>
                                         <constraint firstAttribute="height" constant="32" id="I4J-fi-dDy"/>
+                                        <constraint firstItem="td8-2n-Z9H" firstAttribute="leading" secondItem="dMT-80-cRR" secondAttribute="trailing" constant="-1" id="Z6O-aX-eKc"/>
                                         <constraint firstItem="dMT-80-cRR" firstAttribute="leading" secondItem="SYp-51-eQM" secondAttribute="leading" id="aje-dG-QiM"/>
                                         <constraint firstAttribute="width" constant="232" id="fkz-he-pM2"/>
                                         <constraint firstItem="dMT-80-cRR" firstAttribute="centerY" secondItem="SYp-51-eQM" secondAttribute="centerY" id="gbk-We-ohK"/>
@@ -393,11 +396,11 @@
                     <constraints>
                         <constraint firstItem="2r8-sI-aCB" firstAttribute="leading" secondItem="rFc-TS-7es" secondAttribute="leading" id="0L3-GC-jfn"/>
                         <constraint firstAttribute="trailing" secondItem="4tG-T7-TSW" secondAttribute="trailing" id="4dj-ve-myU"/>
-                        <constraint firstItem="2r8-sI-aCB" firstAttribute="top" secondItem="3bI-RP-0y4" secondAttribute="bottom" id="6iF-b2-7BW"/>
                         <constraint firstItem="3bI-RP-0y4" firstAttribute="leading" secondItem="rFc-TS-7es" secondAttribute="leading" id="Bwn-2s-2OS"/>
                         <constraint firstItem="NEs-0d-c4M" firstAttribute="leading" secondItem="rFc-TS-7es" secondAttribute="leading" id="EgW-H3-SQj"/>
                         <constraint firstAttribute="trailing" secondItem="3bI-RP-0y4" secondAttribute="trailing" id="Kf8-Hc-yPg"/>
                         <constraint firstItem="4tG-T7-TSW" firstAttribute="top" secondItem="rFc-TS-7es" secondAttribute="top" id="O51-fq-Ctd"/>
+                        <constraint firstItem="2r8-sI-aCB" firstAttribute="top" secondItem="4tG-T7-TSW" secondAttribute="bottom" constant="56" id="bqf-4L-XCU"/>
                         <constraint firstAttribute="bottom" secondItem="NEs-0d-c4M" secondAttribute="bottom" id="dAJ-yE-bvr"/>
                         <constraint firstAttribute="trailing" secondItem="NEs-0d-c4M" secondAttribute="trailing" id="dM0-33-Qbx"/>
                         <constraint firstItem="4tG-T7-TSW" firstAttribute="leading" secondItem="rFc-TS-7es" secondAttribute="leading" id="mqP-Zb-Nm0"/>
@@ -412,7 +415,7 @@
                 <constraint firstAttribute="trailing" secondItem="rFc-TS-7es" secondAttribute="trailing" id="XQD-h0-Twd"/>
                 <constraint firstItem="rFc-TS-7es" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="rOm-T5-hIC"/>
             </constraints>
-            <point key="canvasLocation" x="30.5" y="314"/>
+            <point key="canvasLocation" x="30.5" y="329.5"/>
         </customView>
     </objects>
     <resources>

+ 49 - 9
PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Bates/KMBatesController.swift

@@ -72,7 +72,6 @@ class KMBatesController: NSViewController {
         
         if editSubType == .template {
             templatesController.view.isHidden = false
-            templatesController.reloadData()
             
         } else if editSubType == .add {
             propertyController.view.isHidden = false
@@ -87,14 +86,23 @@ class KMBatesController: NSViewController {
     }
     
     func reloadData() {
-        resetUI()
         
         propertyController.totalPDFCount = totalPDFCount
-        propertyController.reloadData()
-        
+ 
         documentPreview.pdfDocument = pdfDocument
         documentPreview.reloadData()
-         
+        
+        if editSubType == .template {
+            templatesController.reloadData()
+            
+        } else if editSubType == .add {
+            propertyController.editSubType = editSubType
+            propertyController.reloadData()
+            
+        } else if editSubType == .edit {
+            propertyController.editSubType = editSubType
+            propertyController.reloadData()
+        }
     }
     
     func updatePDFDocumentBates() {
@@ -102,8 +110,8 @@ class KMBatesController: NSViewController {
             let cPDFBates = documentPreview.pdfDocument?.bates()
             cPDFBates?.pageString = "0"
             
-            var fontSize = data.fontsize
-            var fontName: String = data.fontName
+            let fontSize = data.fontsize
+            let fontName: String = data.fontName
 
             let font = NSFont.boldSystemFont(ofSize:fontSize)
             let style = NSMutableParagraphStyle()
@@ -159,15 +167,25 @@ extension KMBatesController: KMBatesPropertyControllerDelegate {
     }
     
     func batesPropertyControllerSaveTemplateSuccess(_ controller: KMBatesPropertyController, _ data: KMBatesModel) {
+        saveTemplateMessage.frame = CGRectMake((CGRectGetWidth(self.view.frame) - saveTemplateMessage.properties.propertyInfo.viewWidth)/2,
+                                               CGRectGetHeight(self.view.frame) - saveTemplateMessage.properties.propertyInfo.viewHeight - 8,
+                                               saveTemplateMessage.properties.propertyInfo.viewWidth,
+                                               saveTemplateMessage.properties.propertyInfo.viewHeight)
+        saveTemplateMessage.reloadData()
+        saveTemplateMessage.show(inView: self.view, autoHideSeconde: 2)
+        
         editSubType = .template
+        resetUI()
+        delegate?.kmBatesControllerDidUpdateMode?(self)
         
+        templatesController.selectedDataModel = data
         reloadData()
         
-        delegate?.kmBatesControllerDidUpdateMode?(self)
     }
     
     func batesPropertyControllerCancelTemplateEdit(_ controller: KMBatesPropertyController) {
         editSubType = .template
+        resetUI()
         
         reloadData()
         
@@ -177,6 +195,7 @@ extension KMBatesController: KMBatesPropertyControllerDelegate {
     
     func batesPropertyControllerFinishTemplateEdit(_ controller: KMBatesPropertyController) {
         editSubType = .template
+        resetUI()
         
         reloadData()
         
@@ -211,11 +230,32 @@ extension KMBatesController: KMBatesTemplateControllerDelegate {
     
     func templateControllerDidEditData(_ controller: KMBatesTemplateController, _ data: KMBatesModel) {
         editSubType = .edit
+        resetUI()
+        
+        if data.bottomLeftString.count > 0 {
+            propertyController.positionSelRow = 0
+            propertyController.positionSelColumn = 0
+        } else if data.bottomCenterString.count > 0 {
+            propertyController.positionSelRow = 0
+            propertyController.positionSelColumn = 1
+        } else if data.bottomRightString.count > 0 {
+            propertyController.positionSelRow = 0
+            propertyController.positionSelColumn = 2
+        } else if data.topLeftString.count > 0 {
+            propertyController.positionSelRow = 1
+            propertyController.positionSelColumn = 0
+        } else if data.topCenterString.count > 0 {
+            propertyController.positionSelRow = 1
+            propertyController.positionSelColumn = 1
+        } else if data.topRightString.count > 0 {
+            propertyController.positionSelRow = 1
+            propertyController.positionSelColumn = 2
+        }
         
         propertyController.batesModel = data
         propertyController.originalDataDict = KMBatesManager.defaultManager.parseModel(model: data)
         
-        resetUI()
+        reloadData()
         
         delegate?.kmBatesControllerDidUpdateMode?(self)
         

+ 124 - 13
PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Bates/KMBatesManager.swift

@@ -40,6 +40,20 @@ class KMBatesManager: NSObject {
         }
     }
     
+    //MARK: - Get
+    func fetchBatesAvailableName() -> String {
+        var availableIndex = 0
+        for item in datas {
+            if item.name.hasPrefix("Bates") {
+                if let index = Int(item.name.dropFirst("Bates".count)), index >= availableIndex {
+                    availableIndex = index + 1
+                }
+            }
+        }
+        return "Bates\(availableIndex)"
+    }
+    
+    //MARK: - 增删改查
     func addTemplate(_ model: KMBatesModel) -> Bool {
         if (!FileManager.default.fileExists(atPath: kBatesFolderPath!)) {
             let create: ()? = try?FileManager.default.createDirectory(atPath: kBatesFolderPath!, withIntermediateDirectories: false)
@@ -202,11 +216,12 @@ class KMBatesManager: NSObject {
         model.startString = dict["startString"] as! String
         model.tag = dict["tag"] as! String
         
+        if let value = dict.object(forKey: "name") {
+            model.name = value as! String
+        }
     }
     
-    /**
-        `Private Methods`
-     */
+    //MARK: - Parse
     func parseModel(model: KMBatesModel) -> Dictionary<String, Any> {
         var dict: [String : Any] = [:]
         /// 字体相关
@@ -233,6 +248,7 @@ class KMBatesManager: NSObject {
         dict["digits"] = model.digits
         dict["startString"] = model.startString
         dict["tag"] = model.tag
+        dict["name"] = model.name
          
         return dict
     }
@@ -268,21 +284,116 @@ class KMBatesManager: NSObject {
         if let value = dict["tag"] {
             model.tag = value as! String
         }
-        
-         
+        if let value = dict["name"] {
+            model.name = value as! String
+        }
         return model
     }
 
-    func fetchBatesAvailableName() -> String {
-        var availableIndex = 0
-        for item in datas {
-            if item.name.hasPrefix("Bates") {
-                if let index = Int(item.name.dropFirst("Bates".count)), index >= availableIndex {
-                    availableIndex = index + 1
-                }
+    //MARK: - Compare
+    class func compareIsChangedModel(_ model: KMBatesModel, withDict dict: NSDictionary) -> Bool {
+        if let value = dict["fontName"] {
+            if model.fontName != (value as! String) {
+                return true
             }
         }
-        return "Bates\(availableIndex)"
+        
+        if let value = dict["fontsize"] {
+            if model.fontsize != (value as! CGFloat) {
+                return true
+            }
+        }
+         
+        if let value = dict["color"] {
+            if model.color.toHex() != (value as! String) {
+                return true
+            }
+        }
+        
+        if let value = dict["leftMargin"] {
+            if model.leftMargin != (value as! Int) {
+                return true
+            }
+        }
+        if let value = dict["rightMargin"] {
+            if model.rightMargin != (value as! Int) {
+                return true
+            }
+        }
+        if let value = dict["bottomMargin"] {
+            if model.bottomMargin != (value as! Int) {
+                return true
+            }
+        }
+        if let value = dict["topMargin"] {
+            if model.topMargin != (value as! Int) {
+                return true
+            }
+        }
+        
+        
+        if let value = dict["topLeftString"] {
+            if model.topLeftString != (value as! String) {
+                return true
+            }
+        }
+        
+        if let value = dict["topCenterString"] {
+            if model.topCenterString != (value as! String) {
+                return true
+            }
+        }
+        
+        if let value = dict["topRightString"] {
+            if model.topRightString != (value as! String) {
+                return true
+            }
+        }
+        
+        if let value = dict["bottomLeftString"] {
+            if model.bottomLeftString != (value as! String) {
+                return true
+            }
+        }
+        
+        if let value = dict["bottomCenterString"] {
+            if model.bottomCenterString != (value as! String) {
+                return true
+            }
+        }
+        
+        if let value = dict["bottomRightString"] {
+            if model.bottomRightString != (value as! String) {
+                return true
+            }
+        }
+        
+        if let value = dict["prefixString"] {
+            if model.prefixString != (value as! String) {
+                return true
+            }
+        }
+        if let value = dict["suffixString"] {
+            if model.suffixString != (value as! String) {
+                return true
+            }
+        }
+        
+        
+        if let value = dict["digits"] {
+            if model.digits != (value as! Int) {
+                return true
+            }
+        }
+        
+        
+        if let value = dict["startString"] {
+            if model.startString != (value as! String) {
+                return true
+            }
+        }
+        
+        return false
     }
      
 }

+ 20 - 20
PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Bates/Views/KMBatesPropertyController.swift

@@ -75,9 +75,8 @@ class KMBatesPropertyController: NSViewController {
     var groupView: ComponentGroup!
     
     private var familyNames = CPDFFont.familyNames
-    private var positionSelRow: Int = -1
-    private var positionSelColumn: Int = -1
-    private var isEditModeChanged: Bool = false //修改时,记录是否有做过调整
+    var positionSelRow: Int = 1
+    var positionSelColumn: Int = 0
     
     var batesModel: KMBatesModel = KMBatesModel()
     var totalPDFCount: Int = 1
@@ -108,7 +107,7 @@ class KMBatesPropertyController: NSViewController {
         
         leftTopButton.properties = ComponentButtonProperty(type: .text_gray, size: .xxs, onlyIcon: true, icon: NSImage(named: "watermark_arrowLeft"), keepPressState: false)
         leftTopButton.setTarget(self, action: #selector(leftTopButtonClicked(_:)))
- 
+        
         //Font
         fontLabel.stringValue = KMLocalizedString("Font")
         fontLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/2")
@@ -235,8 +234,8 @@ class KMBatesPropertyController: NSViewController {
     }
     
     func clearData() {
-        positionSelRow = -1
-        positionSelColumn = -1
+        positionSelRow = 1
+        positionSelColumn = 0
         totalPDFCount = 1
     }
     
@@ -308,7 +307,7 @@ class KMBatesPropertyController: NSViewController {
         }
         startPageSelect.properties.text = batesModel.startString
         startPageSelect.reloadData()
-         
+        
         //Layout
         layoutPosition.properties.selRow = positionSelRow
         layoutPosition.properties.selColumn = positionSelColumn
@@ -360,7 +359,11 @@ class KMBatesPropertyController: NSViewController {
     //MARK: - Action
     @objc func leftTopButtonClicked(_ sender: ComponentButton) {
         if sender == leftTopButton {
-            if isEditModeChanged == true {
+            var didChanged = false
+            if let dict = self.originalDataDict {
+                didChanged = KMBatesManager.compareIsChangedModel(batesModel, withDict: dict as NSDictionary)
+            }
+            if didChanged {
                 let alert = NSAlert()
                 alert.alertStyle = .critical
                 alert.messageText = KMLocalizedString("Save template changes?")
@@ -373,7 +376,6 @@ class KMBatesPropertyController: NSViewController {
                         
                         self.delegate?.batesPropertyControllerFinishTemplateEdit?(self)
                         
-                        self.isEditModeChanged = false
                     } else {
                         if let dict = self.originalDataDict {
                             KMBatesManager.defaultManager.updateModel(self.batesModel, with: dict as NSDictionary)
@@ -381,13 +383,11 @@ class KMBatesPropertyController: NSViewController {
                         }
                         self.delegate?.batesPropertyControllerCancelTemplateEdit?(self)
                         
-                        self.isEditModeChanged = false
                     }
                 }
             } else {
                 delegate?.batesPropertyControllerCancelTemplateEdit?(self)
-
-                isEditModeChanged = false
+                
             }
         }
     }
@@ -441,6 +441,14 @@ class KMBatesPropertyController: NSViewController {
         }
     }
     
+    //MARK: - Mouse
+    override func mouseDown(with event: NSEvent) {
+        super.mouseDown(with: event)
+        
+        view.window?.makeFirstResponder(nil)
+        
+    }
+    
 }
 
 //MARK: - ComponentInputNumberDelegate
@@ -467,7 +475,6 @@ extension KMBatesPropertyController: ComponentInputNumberDelegate {
                 batesModel.digits = Int(text) ?? 1
             }
         }
-        isEditModeChanged = true
         
         reloadData()
         
@@ -495,7 +502,6 @@ extension KMBatesPropertyController: ComponentSelectDelegate {
                 batesModel.startString = text
             }
         }
-        isEditModeChanged = true
         
         reloadData()
         
@@ -541,9 +547,7 @@ extension KMBatesPropertyController: ComponentGroupDelegate {
             } else if positionSelRow == 1 && positionSelColumn == 2 {
                 batesModel.topRightString = batesModel.topRightString + tString
             }
-            
         }
-        isEditModeChanged = true
         
         reloadData()
         
@@ -561,8 +565,6 @@ extension KMBatesPropertyController: ComponentCPositionDelegate {
             positionSelRow = row
             positionSelColumn = column
             
-            isEditModeChanged = true
-            
             reloadData()
             
             delegate?.batesPropertyControllerDidUpdate?(self)
@@ -589,8 +591,6 @@ extension KMBatesPropertyController: ComponentTextareaDelegate {
             batesModel.topRightString = layoutTextarea.properties.text
         }
         
-        isEditModeChanged = true
-        
         reloadData()
         
         delegate?.batesPropertyControllerDidUpdate?(self)

+ 4 - 7
PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Bates/Views/KMBatesTemplateController.swift

@@ -85,6 +85,7 @@ class KMBatesTemplateController: NSViewController {
             collectionView.isHidden = false
             collectionView.reloadData()
             
+            updateSelectedState()
         }
     }
     
@@ -112,8 +113,9 @@ class KMBatesTemplateController: NSViewController {
         } else {
             selectedDataModel = nil
         }
-        
-        delegate?.templateControllerDidSelectedChanged?(self)
+        DispatchQueue.main.async {
+            self.delegate?.templateControllerDidSelectedChanged?(self)
+        }
     }
     
     //MARK: - action
@@ -146,11 +148,6 @@ extension KMBatesTemplateController: NSCollectionViewDelegate, NSCollectionViewD
         let item: KMBatesTemplateItem = collectionView.makeItem(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "KMBatesTemplateItem"), for: indexPath) as! KMBatesTemplateItem
         item.delegate = self
         item.dataModel = KMBatesManager.defaultManager.datas[indexPath.item]
-        if let selData = selectedDataModel {
-            if item.dataModel == selData {
-                item.isSelected = true
-            }
-        }
         item.reloadData()
         
         return item

+ 44 - 9
PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Crop/KMCropController.swift

@@ -8,21 +8,31 @@
 import Cocoa
 import KMComponentLibrary
 
+@objc protocol KMCropControllerDelegate: AnyObject {
+    
+    @objc optional func kmCropControllerDidCrop(_ controller: KMCropController, _ cropRect: CGRect, _ view: KMPageRangeSelectView)
+     
+    @objc optional func kmCropControllerDidCropSeparate(_ controller: KMCropController, _ view: KMPageRangeSelectView)
+    
+    @objc optional func kmCropControllerDidCropAuto(_ controller: KMCropController, _ view: KMPageRangeSelectView)
+}
+
 class KMCropController: NSViewController {
 
     @IBOutlet var contendView: NSView!
     
     @IBOutlet var preInfoView: NSView!
     @IBOutlet var propertyInfoView: NSView!
-    
+     
+    private var documentPreview: KMEditDocumentController = KMEditDocumentController.init()
+    private var propertyController: KMCropPropertyController = KMCropPropertyController.init()
+
+    private var coverController: KMCropCoverController?
     
     var pdfDocument: CPDFDocument?
+    var selectionRect: CGRect = .zero
 
-    var documentPreview: KMEditDocumentController = KMEditDocumentController.init()
-    var propertyController: KMCropPropertyController = KMCropPropertyController.init()
-
-    
-    var coverController: KMCropCoverController?
+    weak open var delegate: KMCropControllerDelegate?
     
     
     override func viewDidLoad() {
@@ -44,6 +54,7 @@ class KMCropController: NSViewController {
         
         propertyController.view.frame = propertyInfoView.bounds
         propertyController.view.autoresizingMask = [.width, .height]
+        propertyController.delegate = self
         propertyInfoView.addSubview(propertyController.view)
         
 //        if coverController == nil {
@@ -68,8 +79,14 @@ class KMCropController: NSViewController {
         let bounds = page?.bounds ?? CGRectZero
         
         documentPreview.pdfView.toolMode = .selectToolMode
-        documentPreview.pdfView.selectionRect = bounds
-        documentPreview.pdfView.setNeedsDisplayForVisiblePages()
+        documentPreview.pdfView.selectionPageIndex = 0
+        
+        if CGRectEqualToRect(selectionRect, CGRectZero) {
+            selectionRect = bounds
+        } else {
+            documentPreview.pdfView.selectionRect = selectionRect
+            documentPreview.pdfView.setNeedsDisplayForVisiblePages()
+        }
      
         propertyController.pdfView = documentPreview.pdfView
         propertyController.reloadData()
@@ -78,12 +95,15 @@ class KMCropController: NSViewController {
     
 }
 
-
+//MARK: - CPDFListViewDelegate
 extension KMCropController: CPDFListViewDelegate {
     
     func pdfListViewChangedSelectionOrMagnification(_ pdfListView: CPDFListView!) {
         print("pdfListViewChangedSelectionOrMagnification")
         
+        propertyController.cropSeparateOn = false
+        propertyController.cropAutoOn = false
+        
         propertyController.reloadData()
     }
     
@@ -93,3 +113,18 @@ extension KMCropController: CPDFListViewDelegate {
         propertyController.reloadData()
     }
 }
+
+//MARK: - KMCropPropertyControllerDelegate
+extension KMCropController: KMCropPropertyControllerDelegate {
+    func kmCropControllerDidCrop(_ controller: KMCropPropertyController, _ cropRect: CGRect, _ view: KMPageRangeSelectView) {
+        delegate?.kmCropControllerDidCrop?(self, cropRect, view)
+    }
+    
+    func kmCropControllerDidCropAuto(_ controller: KMCropPropertyController, _ view: KMPageRangeSelectView) {
+        delegate?.kmCropControllerDidCropAuto?(self, view)
+    }
+    
+    func kmCropControllerDidCropSeparate(_ controller: KMCropPropertyController, _ view: KMPageRangeSelectView) {
+        delegate?.kmCropControllerDidCropSeparate?(self, view)
+    }
+}

+ 12 - 0
PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Crop/KMCropManager.swift

@@ -0,0 +1,12 @@
+//
+//  KMCropManager.swift
+//  PDF Reader Pro
+//
+//  Created by Niehaoyu on 2024/11/22.
+//
+
+import Cocoa
+
+class KMCropManager: NSObject {
+
+}

+ 2 - 2
PDF Office/PDF Master/Class/PDFTools/Crop/Tools/KMCropTools.swift

@@ -75,7 +75,7 @@ import Cocoa
     
     class func newBitmapImageRepForBox(_ page: CPDFPage, _ box: CPDFDisplayBox) -> NSBitmapImageRep? {
         let bounds = page.bounds(for: box)
-        var imageRep = NSBitmapImageRep(bitmapDataPlanes: nil,
+        let imageRep = NSBitmapImageRep(bitmapDataPlanes: nil,
                                         pixelsWide: Int(NSWidth(bounds)),
                                         pixelsHigh: Int(NSHeight(bounds)),
                                         bitsPerSample: 8,
@@ -93,7 +93,7 @@ import Cocoa
             NSGraphicsContext.current?.imageInterpolation = .none
             NSGraphicsContext.current?.shouldAntialias = false
             if (page.rotation != 0) {
-                var transform = NSAffineTransform()
+                let transform = NSAffineTransform()
                 if (page.rotation == 90) {
                     transform.translateX(by: NSWidth(bounds), yBy: 0)
                 } else if (page.rotation == 180) {

+ 130 - 19
PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Crop/Views/KMCropPropertyController.swift

@@ -8,6 +8,15 @@
 import Cocoa
 import KMComponentLibrary
 
+@objc protocol KMCropPropertyControllerDelegate: AnyObject {
+    
+    @objc optional func kmCropControllerDidCrop(_ controller: KMCropPropertyController, _ cropRect: CGRect, _ view: KMPageRangeSelectView)
+    
+    @objc optional func kmCropControllerDidCropSeparate(_ controller: KMCropPropertyController, _ view: KMPageRangeSelectView)
+    
+    @objc optional func kmCropControllerDidCropAuto(_ controller: KMCropPropertyController, _ view: KMPageRangeSelectView)
+}
+
 class KMCropPropertyController: NSViewController {
     
     @IBOutlet var contendView: NSView!
@@ -45,19 +54,64 @@ class KMCropPropertyController: NSViewController {
     
     @IBOutlet var cropButton: ComponentButton!
     
-    private var syncChangeBounds: Bool = true //同步修改宽高
+    private var _cropSeparateOn: Bool = false
+    private var _cropAutoOn: Bool = false
+    private var _syncChangeBounds: Bool = false //同步修改宽高
+    
+    weak open var delegate: KMCropPropertyControllerDelegate?
     
-    var pdfView: CPDFListView?
+    public var pdfView: CPDFListView?
     
     override func viewDidLoad() {
         super.viewDidLoad()
         // Do view setup here.
         
+        cropSeparateOn = UserDefaults.standard.bool(forKey: "CropSeparateOnKey")
+        cropAutoOn = UserDefaults.standard.bool(forKey: "CropAutoOnKey")
+        if UserDefaults.standard.object(forKey: "CropSyncChangeBoundsKey") == nil {
+            UserDefaults.standard.setValue(true, forKey: "CropSyncChangeBoundsKey")
+        }
+        syncChangeBounds = UserDefaults.standard.bool(forKey: "CropSyncChangeBoundsKey")
+        
         setupProperty()
         
         reloadData()
     }
     
+    //MARK: - Setter and Getter
+    public var cropSeparateOn : Bool {
+        get {
+            return _cropSeparateOn
+        }
+        set {
+            _cropSeparateOn = newValue
+          
+            UserDefaults.standard.setValue(_cropSeparateOn, forKey: "CropSeparateOnKey")
+         }
+    }
+    
+    public var cropAutoOn : Bool {
+        get {
+            return _cropAutoOn
+        }
+        set {
+            _cropAutoOn = newValue
+          
+            UserDefaults.standard.setValue(_cropAutoOn, forKey: "CropAutoOnKey")
+         }
+    }
+    
+    public var syncChangeBounds : Bool {
+        get {
+            return _syncChangeBounds
+        }
+        set {
+            _syncChangeBounds = newValue
+          
+            UserDefaults.standard.setValue(_syncChangeBounds, forKey: "CropSyncChangeBoundsKey")
+         }
+    }
+    
     func setupProperty() {
         //White Margin
         whiteMarginLabel.stringValue = KMLocalizedString("Crop White Margins")
@@ -69,6 +123,7 @@ class KMCropPropertyController: NSViewController {
         separateLabel.font = ComponentLibrary.shared.getFontFromKey("mac/body-m-regular")
         
         separateSwitch.properties = ComponentSwitchProperty(size: .s, open: false, isDisabled: false)
+        separateSwitch.setTarget(self, action: #selector(switchAction(_:)))
         
         autoLabel.stringValue = KMLocalizedString("Auto")
         autoLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("comp-form/colorText-label")
@@ -79,6 +134,7 @@ class KMCropPropertyController: NSViewController {
         autoTipsView.toolTip = KMLocalizedString("autoTipsView tooltips")
         
         autoSwitch.properties = ComponentSwitchProperty(size: .s, open: false, isDisabled: false)
+        autoSwitch.setTarget(self, action: #selector(switchAction(_:)))
         
         //PageSize
         whiteMarginLabel.stringValue = KMLocalizedString("Crop Page Size")
@@ -149,9 +205,8 @@ class KMCropPropertyController: NSViewController {
         pageRangeLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/2")
         pageRangeLabel.font = ComponentLibrary.shared.getFontFromKey("mac/body-s-medium")
         
-         
         cropButton.properties = ComponentButtonProperty(type: .primary, size: .m, buttonText: KMLocalizedString("Apply"), keepPressState: false)
-        
+        cropButton.setTarget(self, action: #selector(cropButtonClicked(_:)))
     }
     
     func reloadData() {
@@ -163,10 +218,14 @@ class KMCropPropertyController: NSViewController {
             return
         }
         let pageBounds = page.bounds
-        
-        var selectionRect = pdfView.selectionRect
+        let selectionRect = pdfView.selectionRect
         
         //White Margin
+        separateSwitch.properties.open = cropSeparateOn
+        separateSwitch.reloadData()
+        
+        autoSwitch.properties.open = cropAutoOn
+        autoSwitch.reloadData()
         
         //PageSize
         sizeWidthInput.properties.maxSize = Int(pageBounds.size.width)
@@ -177,6 +236,12 @@ class KMCropPropertyController: NSViewController {
         sizeHeightInput.properties.text = String(format: "%.0f", selectionRect.size.height)
         sizeHeightInput.reloadData()
         
+        if syncChangeBounds {
+            sizeSyncButton.properties.state = .pressed
+        } else {
+            sizeSyncButton.properties.state = .normal
+        }
+        sizeSyncButton.reloadData()
         //PageMargin
         
         pageLeftInput.properties.maxSize = Int(pageBounds.size.width)
@@ -196,26 +261,61 @@ class KMCropPropertyController: NSViewController {
         pageBottomInput.reloadData()
         
         //PageRange
-         
-        
+        if CGRectEqualToRect(pageBounds, selectionRect) {
+            cropButton.properties.isDisabled = true
+        } else {
+            cropButton.properties.isDisabled = false
+        }
+        cropButton.reloadData()
     }
     
     //MARK: - Action
     @objc func sizeSyncButtonClicked(_ sender: ComponentButton) {
         syncChangeBounds = !syncChangeBounds
         
-        if syncChangeBounds {
-            sizeSyncButton.properties.state = .pressed
+        reloadData()
+    }
+    
+    @objc func cropButtonClicked(_ sender: ComponentButton) {
+        if cropSeparateOn {
+            delegate?.kmCropControllerDidCropSeparate?(self, pangeRangeSelectView)
+        } else if cropAutoOn {
+            delegate?.kmCropControllerDidCropAuto?(self, pangeRangeSelectView)
         } else {
-            sizeSyncButton.properties.state = .normal
+            delegate?.kmCropControllerDidCrop?(self, pdfView?.selectionRect ?? CGRectZero, pangeRangeSelectView)
         }
-        sizeSyncButton.reloadData()
     }
     
-    @objc func cropButtonClicked(_ sender: ComponentButton) {
+    @objc func switchAction(_ sender: ComponentSwitch) {
+        guard let pdfView = self.pdfView else {
+            return
+        }
         
+        guard let page = pdfView.document.page(at: 0) else {
+            return
+        }
+        
+        if sender == separateSwitch {
+            cropSeparateOn = sender.properties.open
+            cropAutoOn = false
+            
+            let rect = KMCropTools.getPageForegroundBox(page)
+            pdfView.selectionRect = rect
+            pdfView.setNeedsDisplayForVisiblePages()
+            
+        } else if sender == autoSwitch {
+            cropAutoOn = sender.properties.open
+            cropSeparateOn = false
+            
+            let rect = KMCropTools.getPageForegroundBox(page)
+            pdfView.selectionRect = rect
+            pdfView.setNeedsDisplayForVisiblePages()
+            
+        }
+        reloadData()
     }
     
+    
 }
 
 //MARK: - ComponentInputNumberDelegate
@@ -237,8 +337,22 @@ extension KMCropPropertyController: ComponentInputNumberDelegate {
   
         var rect = pdfView.selectionRect
         if inputNumber == sizeWidthInput {
+            if syncChangeBounds {
+                var scale: CGFloat = 0
+                if rect.size.width != 0 {
+                    scale = value / rect.size.width
+                }
+                rect.size.height *= scale
+            }
             rect.size.width = value
         } else if inputNumber == sizeHeightInput {
+            if syncChangeBounds {
+                var scale: CGFloat = 0
+                if rect.size.height != 0 {
+                    scale = value / rect.size.height
+                }
+                rect.size.width *= scale
+             }
             rect.size.height = value
         } else if inputNumber == pageLeftInput {
             rect.origin.x = value
@@ -252,12 +366,9 @@ extension KMCropPropertyController: ComponentInputNumberDelegate {
         pdfView.selectionRect = rect
         pdfView.setNeedsDisplayForVisiblePages()
         
+        cropAutoOn = false
+        cropSeparateOn = false
+
         reloadData()
     }
 }
-
-//MARK: - ComponentSelectDelegate
-extension KMCropPropertyController: ComponentSelectDelegate {
-    
-}
-

+ 14 - 3
PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/KMLinkViewController/Views/KMLinkPageView/KMLinkPageView.swift

@@ -58,8 +58,6 @@ public class KMLinkPageView: BaseXibView {
         self.setUpUI()
     }
     
-    
-    
     func setUpUI() {
         infoContendView.wantsLayer = true
         if let value = ComponentLibrary.shared.getComponentValueFromKey("radius/m") {
@@ -113,7 +111,18 @@ public class KMLinkPageView: BaseXibView {
         
         choosedIndex = paginationView.properties.currentIndex
         startPageIndex = paginationView.properties.currentIndex
-        
+         
+        refreshPage()
+    }
+    
+    func refreshPage() {
+        guard let pdfView = self.pdfView else {
+            return
+        }
+        let thumbnail = KMNThumbnail.init(document: pdfView.document, currentPageIndex: choosedIndex-1)
+        thumbnail.generateThumImage { image in
+            self.pageImage.image = image
+        }
     }
     
     func refreshGoButton() {
@@ -156,6 +165,8 @@ extension KMLinkPageView: ComponentPaginationDelegate {
             
             isGo = false
             
+            refreshPage()
+            
             refreshGoButton()
         }
     }

+ 0 - 17
PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Watermark/Base/KMWatermarkAdjectivePreViewBaseController.swift

@@ -7,23 +7,6 @@
 
 import Cocoa
 
-class KMWatermarkTestWindow: NSWindow {
-    
-    var controller: KMWatermarkAdjectivePreViewBaseController!
-    
-    override init(contentRect: NSRect, styleMask style: NSWindow.StyleMask, backing backingStoreType: NSWindow.BackingStoreType, defer flag: Bool) {
-        super.init(contentRect: contentRect, styleMask: style, backing: backingStoreType, defer: flag);
-        
-        isReleasedWhenClosed = false
-        
-        let controller_: KMCropPreviewController = KMCropPreviewController()
-        contentView?.addSubview(controller_.view)
-        controller_.view.frame = CGRect(x: 0, y: 0, width: contentRect.size.width, height: contentRect.size.height)
-        controller = controller_
-    }
-    
-}
-
 typealias KMWatermarkAdjectivePageNumberViewCallback = (_ value: String) -> ()
 class KMWatermarkAdjectivePageNumberView: NSView , NSTextFieldDelegate{
     var numberTextField = NSTextField()

+ 5 - 5
PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Watermark/KMWatermarkWindowController.xib

@@ -1,12 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22155" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
     <dependencies>
         <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
-        <customObject id="-2" userLabel="File's Owner" customClass="KMWatermarkWindowController" customModule="PDF_Master" customModuleProvider="target">
+        <customObject id="-2" userLabel="File's Owner" customClass="KMWatermarkWindowController" customModule="PDF_Reader_Pro" customModuleProvider="target">
             <connections>
                 <outlet property="watermarkView" destination="2bB-Bb-1ck" id="ZSH-fm-dzh"/>
                 <outlet property="window" destination="F0z-JX-Cv5" id="gIp-Ho-8D9"/>
@@ -18,12 +18,12 @@
             <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
             <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
             <rect key="contentRect" x="196" y="240" width="998" height="525"/>
-            <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1415"/>
+            <rect key="screenRect" x="0.0" y="0.0" width="1920" height="1055"/>
             <view key="contentView" id="se5-gp-TjO">
                 <rect key="frame" x="0.0" y="0.0" width="998" height="525"/>
                 <autoresizingMask key="autoresizingMask"/>
                 <subviews>
-                    <customView translatesAutoresizingMaskIntoConstraints="NO" id="2bB-Bb-1ck" customClass="KMWatermarkView" customModule="PDF_Master" customModuleProvider="target">
+                    <customView translatesAutoresizingMaskIntoConstraints="NO" id="2bB-Bb-1ck" customClass="KMWatermarkView" customModule="PDF_Reader_Pro" customModuleProvider="target">
                         <rect key="frame" x="0.0" y="0.0" width="998" height="525"/>
                     </customView>
                 </subviews>

+ 11 - 0
PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Watermark/New/Views/KMNWatermarkPropertyController.swift

@@ -31,8 +31,12 @@ class KMNWatermarkPropertyController: NSViewController {
     @IBOutlet var titleLabel: NSTextField!
     @IBOutlet var templateButton: ComponentButton!
     
+    @IBOutlet var typeTabsBGView: NSView!
     @IBOutlet var typeTabs: ComponentTabs!
     
+    @IBOutlet var infoContendView: NSView!
+    @IBOutlet var infoContendTopConst: NSLayoutConstraint!
+    
     //Text
     @IBOutlet var textBGView: NSView!
     @IBOutlet var text_textareaView: ComponentTextarea!
@@ -88,6 +92,7 @@ class KMNWatermarkPropertyController: NSViewController {
     
     weak open var delegate: KMNWatermarkPropertyControllerDelegate?
 
+    //MARK: - func
     override func viewDidLoad() {
         super.viewDidLoad()
         // Do view setup here.
@@ -291,7 +296,13 @@ class KMNWatermarkPropertyController: NSViewController {
         leftTopButton.isHidden = true
         saveTemplateBGView.isHidden = false
         templateButton.properties.icon = NSImage(named: "icon_wm_template")
+        typeTabsBGView.isHidden = false
+        infoContendTopConst.constant = 56
+        
         if editSubType == .edit {
+            typeTabsBGView.isHidden = true
+            infoContendTopConst.constant = 8
+            
             titleLabel.stringValue = KMLocalizedString("Edit Template")
             leftTopButton.isHidden = false
             saveTemplateBGView.isHidden = true

+ 4 - 1
PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Watermark/New/Views/KMNWatermarkPropertyController.xib

@@ -25,6 +25,8 @@
                 <outlet property="fontNameSelect" destination="YYQ-vV-Qfw" id="Q27-LU-02w"/>
                 <outlet property="fontSizeSelect" destination="dlH-9Z-5E0" id="Mhe-CQ-JDO"/>
                 <outlet property="fontStyleSelect" destination="Wdl-DJ-XxU" id="hU6-0J-tKs"/>
+                <outlet property="infoContendTopConst" destination="JQF-We-7un" id="yc2-R2-wya"/>
+                <outlet property="infoContendView" destination="0BT-YI-uuZ" id="2sZ-VA-OZc"/>
                 <outlet property="leftTopButton" destination="WHs-GW-3o7" id="Jmn-IX-orV"/>
                 <outlet property="positionBGView" destination="nTM-xd-HIx" id="QrI-tv-xuG"/>
                 <outlet property="positionItemView" destination="vd3-5J-Jcb" id="8pT-KI-aHC"/>
@@ -43,6 +45,7 @@
                 <outlet property="text_textareaView" destination="wJd-KI-caZ" id="Lnu-Rh-fNi"/>
                 <outlet property="titleLabel" destination="jkG-Uv-4gv" id="0Ao-BB-7UZ"/>
                 <outlet property="typeTabs" destination="3ld-PC-yBt" id="3ZC-KK-o1W"/>
+                <outlet property="typeTabsBGView" destination="Gk1-Vc-pA7" id="It2-8S-rLF"/>
                 <outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
             </connections>
         </customObject>
@@ -499,11 +502,11 @@
                         <constraint firstAttribute="trailing" secondItem="4VY-fx-x7j" secondAttribute="trailing" id="Gdb-bT-aG8"/>
                         <constraint firstItem="4VY-fx-x7j" firstAttribute="top" secondItem="WSD-S7-Nbi" secondAttribute="top" id="I9S-qG-bSb"/>
                         <constraint firstAttribute="bottom" secondItem="dTL-It-CfQ" secondAttribute="bottom" id="IXc-2b-Pra"/>
+                        <constraint firstItem="0BT-YI-uuZ" firstAttribute="top" secondItem="4VY-fx-x7j" secondAttribute="bottom" constant="56" id="JQF-We-7un"/>
                         <constraint firstItem="Gk1-Vc-pA7" firstAttribute="leading" secondItem="WSD-S7-Nbi" secondAttribute="leading" id="Jie-Dp-sYt"/>
                         <constraint firstItem="4VY-fx-x7j" firstAttribute="leading" secondItem="WSD-S7-Nbi" secondAttribute="leading" id="N1m-JB-XTh"/>
                         <constraint firstItem="Gk1-Vc-pA7" firstAttribute="top" secondItem="4VY-fx-x7j" secondAttribute="bottom" id="YCg-Wb-ayK"/>
                         <constraint firstAttribute="trailing" secondItem="0BT-YI-uuZ" secondAttribute="trailing" id="gqU-2g-Dva"/>
-                        <constraint firstItem="0BT-YI-uuZ" firstAttribute="top" secondItem="Gk1-Vc-pA7" secondAttribute="bottom" id="tqe-Yf-WMm"/>
                     </constraints>
                 </customView>
             </subviews>

+ 0 - 66
PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Base/KMDataVersionManager.swift

@@ -1,66 +0,0 @@
-//
-//  KMDataVersionManager.swift
-//  PDF Reader Pro
-//
-//  Created by liujiajie on 2023/11/7.
-//
-
-import Foundation
-
-let KMHeaderFooterManagerVersion = "KMHeaderFooterManagerVersion"
-
-class KMDataVersionManager: NSObject{
-    class func updateBatesData() -> Bool {
-        var defaults = UserDefaults.standard
-        if  (defaults.object(forKey: KMHeaderFooterManagerVersion) != nil) {
-            defaults.setValue("1", forKey: KMHeaderFooterManagerVersion)
-            return true
-        }
-        return false
-    }
-    
-    class func refrshBatesData(bates: KMHeaderFooterObject?) -> KMHeaderFooterObject? {
-        if bates == nil {
-            return nil
-        }
-        var str: String 
-//        if bates?.batesDigits ?? 0 > 0 {
-//            str = String(format: "%@<<%@,%ld>>%@", bates!.batesPrefixString, bates!.startString, bates!.batesDigits, bates!.batesSuffixString)
-//        } else {
-//            str =  String(format: "%@<<%@>>%@", bates!.batesPrefixString, bates!.startString, bates!.batesSuffixString)
-//        }
-//        bates!.topLeftString = KMDataVersionManager.newBateString(oldString: bates!.topLeftString, bates: bates!, match: str)
-//        bates!.topCenterString = KMDataVersionManager.newBateString(oldString: bates!.topCenterString, bates: bates!, match: str)
-//        bates!.topRightString = KMDataVersionManager.newBateString(oldString: bates!.topRightString, bates: bates!, match: str)
-//        bates!.bottomLeftString = KMDataVersionManager.newBateString(oldString: bates!.bottomLeftString, bates: bates!, match: str)
-//        bates!.bottomCenterString = KMDataVersionManager.newBateString(oldString: bates!.bottomCenterString, bates: bates!, match: str)
-//        bates!.bottomRightString = KMDataVersionManager.newBateString(oldString: bates!.bottomRightString, bates: bates!, match: str)
-        return bates
-    }
-    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
-        for object in results {
-            let range = object.range 
-            var tString: String
-//            if bates.batesDigits > 0 {
-//                tString = "<<#(bates.batesDigits)#(bates.startString)"
-//            } else {
-//                tString = "<<#(bates.startString)"
-//            }
-//            if bates.batesPrefixString.count > 0 {
-//                tString += "#\(bates.batesPrefixString)"
-//            } else if bates.batesPrefixString.count < 1 && bates.batesSuffixString.count > 0 {
-//                tString += "#"
-//            }
-//            if bates.batesSuffixString.count > 0 {
-//                tString += "#\(bates.batesSuffixString)"
-//            }
-//            tString += ">>"
-//            let resultStr = (oldString as NSString).substring(with: range) 
-//            newString = newString.replacingOccurrences(of: resultStr, with: tString)
-        }
-        return newString
-    }
-}

+ 0 - 54
PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Base/KMHeaderFooterAdjectiveInfoBaseView.swift

@@ -1,54 +0,0 @@
-//
-//  KMHeaderFooterAdjectiveInfoBaseView.swift
-//  PDF Reader Pro
-//
-//  Created by tangchao on 2022/12/27.
-//
-
-import Cocoa
-
-typealias KMHeaderFooterAdjectiveInfoItemClick = (_ index: Int,_ value: Any) -> ()
-class KMHeaderFooterAdjectiveInfoBaseView: NSView {
-
-    var titleLabel = NSTextField(labelWithString: "")
-    var contentInset = NSEdgeInsets(top: 0, left: 16, bottom: 0, right: 16)
-    
-    private var myModel: KMHeaderFooterAdjectiveModel!
-    var model: KMHeaderFooterAdjectiveModel {
-        get {
-            return myModel
-        }
-        set {
-            myModel = newValue
-        }
-    }
-    
-    var itemClick: KMHeaderFooterAdjectiveInfoItemClick!
-    
-    override init(frame frameRect: NSRect) {
-        super.init(frame: frameRect)
-        
-        initSubviews()
-    }
-    
-    required init?(coder: NSCoder) {
-        super.init(coder: coder)
-        
-        initSubviews()
-    }
-    
-    override var isFlipped: Bool {
-        return true
-    }
-    
-    func initSubviews() {
-        self.addSubview(self.titleLabel)
-    }
-    
-    override func layout() {
-        super.layout()
-        
-        self.titleLabel.frame = NSMakeRect(self.contentInset.left, 0, NSWidth(self.bounds)-self.contentInset.left-self.contentInset.right, 20)
-    }
-    
-}

+ 0 - 146
PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Base/KMHeaderFooterAdjectiveListCell.swift

@@ -1,146 +0,0 @@
-//
-//  KMHeaderFooterAdjectiveListCell.swift
-//  PDF Reader Pro
-//
-//  Created by tangchao on 2022/12/27.
-//
-
-import Cocoa
-
-class KMHeaderFooterAdjectiveListCell: KMWatermarkAdjectiveListTableCellView {
-    
-    var titleLabel = NSTextField(labelWithString: "")
-    var firstLabel = NSTextField(labelWithString: "")
-    var secondLabel = NSTextField(labelWithString: "")
-    var threeLabel = NSTextField(labelWithString: "")
-    var fourLabel = NSTextField(labelWithString: "")
-    var fiveLabel = NSTextField(labelWithString: "")
-    var sixLabel = NSTextField(labelWithString: "")
-    
-    override var isFlipped: Bool {
-        return true
-    }
-    
-    var myCellModel: KMHeaderFooterAdjectiveModel!
-    var cellModel: KMHeaderFooterAdjectiveModel {
-        get {
-            return myCellModel
-        }
-        set {
-            myCellModel = newValue
-            
-            if (newValue.topLeftString.isEmpty) {
-                self.firstLabel.isHidden = true
-            } else {
-                self.firstLabel.isHidden = false
-                var string: String = "\(newValue.topLeftString)"
-                self.firstLabel.stringValue = string
-            }
-            
-            if (newValue.topCenterString.isEmpty) {
-                self.secondLabel.isHidden = true
-            } else {
-                self.secondLabel.isHidden = false
-                var string: String = "\(newValue.topCenterString)"
-                self.secondLabel.stringValue = string
-            }
-            
-            if (newValue.topRightString.isEmpty) {
-                self.threeLabel.isHidden = true
-            } else {
-                self.threeLabel.isHidden = false
-                var string: String = "\(newValue.topRightString)"
-                self.threeLabel.stringValue = string
-            }
-            
-            if (newValue.bottomLeftString.isEmpty) {
-                self.fourLabel.isHidden = true
-            } else {
-                self.fourLabel.isHidden = false
-                var string: String = "\(newValue.bottomLeftString)"
-                self.fourLabel.stringValue = string
-            }
-            
-            if (newValue.bottomCenterString.isEmpty) {
-                self.fiveLabel.isHidden = true
-            } else {
-                self.fiveLabel.isHidden = false
-                var string: String = "\(newValue.bottomCenterString)"
-                self.fiveLabel.stringValue = string
-            }
-            
-            if (newValue.bottomRightString.isEmpty) {
-                self.sixLabel.isHidden = true
-            } else {
-                self.sixLabel.isHidden = false
-                var string: String = "\(newValue.bottomRightString)"
-                self.sixLabel.stringValue = string
-            }
-            
-            self.layoutSubtreeIfNeeded()
-        }
-    }
-    
-    override func isSelected(selected: Bool) {
-        super.isSelected(selected: selected)
-        
-        if (selected) {
-            self.contentView.layer?.backgroundColor = NSColor.lightGray.cgColor
-        } else {
-            self.contentView.layer?.backgroundColor = NSColor.clear.cgColor
-        }
-    }
-    
-    override func initSubviews() {
-        super.initSubviews()
-        
-        self.contentView.addSubview(self.titleLabel)
-        
-        for label in [self.firstLabel, self.secondLabel, self.threeLabel,
-                      self.fourLabel, self.fiveLabel, self.sixLabel] {
-            self.contentView.addSubview(label)
-            label.lineBreakMode = .byTruncatingTail
-        }
-        
-        self.contentView.wantsLayer = true
-        self.contentView.layer?.borderWidth = 1
-        self.contentView.layer?.borderColor = NSColor.black.cgColor
-        self.contentView.layer?.cornerRadius = 4
-        
-        self.selectCheckButton.isHidden = true
-    }
-    
-    override func layout() {
-        super.layout()
-        
-        let width: CGFloat = NSWidth(self.bounds)
-        let height: CGFloat = NSHeight(self.bounds)
-        self.contentView.frame = NSMakeRect(11, 12, width-22, height-24)
-        
-        let leftMargin: CGFloat = 11
-        let contentWidth: CGFloat = NSWidth(self.contentView.frame)
-        self.titleLabel.frame = NSMakeRect(leftMargin, 12, contentWidth-2*leftMargin, 22)
-        
-        let labelWidth: CGFloat = contentWidth-2*leftMargin
-        let labelY: CGFloat = 6 + self.titleLabel.frame.maxY
-        let labelVSpace: CGFloat = 4
-        let labelH: CGFloat = 22
-        var count: Int = 0
-        for label in [self.firstLabel, self.secondLabel, self.threeLabel,
-                      self.fourLabel, self.fiveLabel, self.sixLabel] {
-            if (label.isHidden) {
-                continue
-            }
-            label.frame = NSMakeRect(leftMargin, labelY+(labelH+labelVSpace)*CGFloat(count), labelWidth, labelH)
-            count += 1
-        }
-        
-        self.selectView.frame = self.contentView.bounds
-        let bottomBarWidth: CGFloat = 128
-        let bottomBarX: CGFloat = (NSWidth(self.frame)-bottomBarWidth) * 0.5
-        let bottomBarH: CGFloat = 43
-        let bottomBarY: CGFloat = self.contentView.frame.maxY-bottomBarH
-        self.bottomBar.frame = NSMakeRect(bottomBarX, bottomBarY, bottomBarWidth, bottomBarH)
-    }
-    
-}

+ 0 - 127
PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Base/KMHeaderFooterAdjectiveModel.swift

@@ -1,127 +0,0 @@
-//
-//  KMHeaderFooterAdjectiveModel.swift
-//  PDF Reader Pro
-//
-//  Created by tangchao on 2022/12/27.
-//
-
-import Cocoa
-
-enum KMHeaderFooterObjectType: Int {
-    case headerFooter = 0
-    case bates
-}
-
-@objcMembers class KMHeaderFooterAdjectiveModel: KMWatermarkAdjectiveBaseModel , NSCoding {
-    var type: KMHeaderFooterObjectType = .headerFooter
-    
-    // 是否数据迁移(原App数据迁移)
-    var isMigrate = false
-    // 是否已被更新
-    var isUpdated = false
-    
-    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 = ""
-    var bottomLeftString: String = ""
-    var bottomCenterString: String = ""
-    var bottomRightString: String = ""
-    
-    var startString: String = "1"
-    
-    var name: String = ""
-    
-    var cellHeight: CGFloat {
-        get {
-            var height: CGFloat = 45.0
-            
-            if (self.topLeftString.count > 0) {
-                height += 20.0
-            }
-            if (self.topCenterString.count > 0) {
-                height += 20.0
-            }
-            if (self.topRightString.count > 0) {
-                height += 20.0
-            }
-            if (self.bottomLeftString.count > 0) {
-                height += 20.0
-            }
-            if (self.bottomCenterString.count > 0) {
-                height += 20.0
-            }
-            if (self.bottomRightString.count > 0) {
-                height += 20.0
-            }
-            
-            return height
-        }
-    }
-    
-    var hasVaild: Bool {
-        get {
-            for string in [self.topLeftString, self.topCenterString, self.topRightString,
-                           self.bottomLeftString, self.bottomCenterString, self.bottomRightString] {
-                if (!string.isEmpty) {
-                    return true
-                }
-            }
-            
-            return false
-        }
-    }
-    
-    override init() {
-        super.init()
-        
-        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()
-        type = KMHeaderFooterObjectType.init(rawValue: coder.decodeInteger(forKey: "type"))!
-        pageRangeType = KMWatermarkeModelPageRangeType.init(rawValue: coder.decodeInteger(forKey: "pageChoice"))!
-        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 ?? ""
-        pageRangeString = coder.decodeObject(forKey: "pagesString") as? String ?? ""
- 
-    }
-
-    func encode(with coder: NSCoder) {
-        coder.encode(type.rawValue, forKey: "type")
-        coder.encode(pageRangeType.rawValue, forKey: "pageChoice")
-        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(self.getTextColor(), forKey: "textColor")
-         coder.encode(id, forKey: "headerFooterID")
-        coder.encode(pageRangeString, forKey: "pagesString")
-         
-    } 
-}

+ 0 - 74
PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Controller/KMCreateHeaderFooterController.swift

@@ -1,74 +0,0 @@
-//
-//  KMCreateHeaderFooterController.swift
-//  PDF Reader Pro
-//
-//  Created by tangchao on 2022/12/27.
-//
-
-import Cocoa
-
-typealias KMCreateHeaderFooterModelDidChange = (_ model: KMHeaderFooterObject) -> ()
-class KMCreateHeaderFooterController: KMWatermarkAdjectivePropertyBaseController {
-    
-    /// 是否是编辑类型
-    var isEdit: Bool = false
-    /// 是否已编辑
-    var isEdited: Bool = false
-    
-    var modelDidChange: KMCreateHeaderFooterModelDidChange!
-    
-    override func viewWillAppear() {
-        super.viewWillAppear()
-        
-        let controller: KMHeaderFooterPropertyInfoController = childViewController[0] as! KMHeaderFooterPropertyInfoController
-        controller.model = self.model as! KMHeaderFooterObject
-    }
-
-    override func viewDidLoad() {
-        super.viewDidLoad()
-        
-        self.backButtton.title = NSLocalizedString("", comment: "")
-        self.showBack(show: true)
-        if (self.isEdit) {
-            self.addButton.attributedTitle = NSAttributedString(string: NSLocalizedString("", comment: ""), attributes: [NSAttributedString.Key.foregroundColor : NSColor(red: 24.0/255.0, green: 160.0/255.0, blue: 251.0/255.0, alpha: 1.0),NSAttributedString.Key.font : NSFont.systemFont(ofSize: 12), NSAttributedString.Key.underlineStyle : true])
-            self.titleLabel.stringValue = NSLocalizedString("Edit HeaderFoote", comment: "")
-        } else {
-            self.titleLabel.stringValue = NSLocalizedString("Add HeaderFooter", comment: "")
-            self.addButton.attributedTitle = NSAttributedString(string: NSLocalizedString("", comment: ""), attributes: [NSAttributedString.Key.foregroundColor : NSColor(red: 24.0/255.0, green: 160.0/255.0, blue: 251.0/255.0, alpha: 1.0),NSAttributedString.Key.font : NSFont.systemFont(ofSize: 12), NSAttributedString.Key.underlineStyle : true])
-        }
-        
-
-        self.segementControl.isHidden = true
-        self.segementControlHeightConst.constant = 0
-        
-        let item = NSTabViewItem(identifier: "tabID")
-        item.label = "tab1";
-        let controller = KMHeaderFooterPropertyInfoController()
-        item.viewController = controller
-        controller.delegate = self
-
-        self.tabView.addTabViewItem(item)
-
-        childViewController.append(controller)
-    }
-    
-    override func resume() {
-        if (self.needResume() == false) {
-            return
-        }
-        
-        (childViewController[0] as! KMHeaderFooterPropertyInfoController).model = self.flagModel?.copy() as! KMHeaderFooterObject
-    }
-}
-
-extension KMCreateHeaderFooterController: KMWatermarkAdjectivePropertyDelegate {
-    func propertyInfoDidChange(model: AnyObject) {
-        self.isEdited = true
-        
-        guard let callback = modelDidChange else {
-            return
-        }
-        
-        callback(model as! KMHeaderFooterObject)
-    }
-}

+ 0 - 22
PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Controller/KMCreateHeaderFooterController.xib

@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22155" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
-    <dependencies>
-        <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
-        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
-    </dependencies>
-    <objects>
-        <customObject id="-2" userLabel="File's Owner" customClass="KMCreateHeaderFooterController" customModule="PDF_Master" customModuleProvider="target">
-            <connections>
-                <outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
-            </connections>
-        </customObject>
-        <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
-        <customObject id="-3" userLabel="Application" customClass="NSObject"/>
-        <customView id="Hz6-mo-xeY">
-            <rect key="frame" x="0.0" y="0.0" width="480" height="272"/>
-            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
-            <point key="canvasLocation" x="132" y="-72"/>
-        </customView>
-    </objects>
-</document>

+ 0 - 106
PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Controller/KMHeaderFooterListController.swift

@@ -1,106 +0,0 @@
-//
-//  KMHeaderFooterListController.swift
-//  PDF Reader Pro
-//
-//  Created by tangchao on 2022/12/27.
-//
-
-import Cocoa
-
-class KMHeaderFooterListController: KMWatermarkAdjectiveListController {
-    
-    override func viewDidLoad() {
-        super.viewDidLoad()
-        
-    }
-    
-    override func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
-        var cellView = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "cellID"), owner: self)
-        if (cellView == nil) {
-            cellView = KMHeaderFooterAdjectiveListCell()
-        }
-        
-        let listCellView: KMHeaderFooterAdjectiveListCell = cellView! as! KMHeaderFooterAdjectiveListCell
-        
-        let model: KMHeaderFooterAdjectiveModel = self.datas[row] as! KMHeaderFooterAdjectiveModel
-        if (self.selectedTemplateID == model.id) {
-            listCellView.isSelected(selected: true)
-        } else {
-            listCellView.isSelected(selected: false)
-        }
-        
-        listCellView.titleLabel.stringValue = "\(model.name) \(row+1)"
-        listCellView.cellModel = model
-        
-        listCellView.bottomBarClick = { [weak self] (index: Int) in
-            if (row < 0 || row >= self!.datas.count) {
-                return
-            }
-            
-            if (self!.delegate == nil) {
-                if (index == 2) {
-                    self!.datas.remove(at: row)
-                    self!.tableView.reloadData()
-                }
-                return
-            }
-            
-            
-            if (index == 1) { /// 编辑
-                let result = self!.delegate.controller?(controller: self!, shouldEditAtRow : row)
-                if (result == nil || result!) {
-                    self!.delegate.controller?(controller: self!, didEditAtRow: row)
-                }
-            } else if (index == 2) { /// 删除
-                let result = self!.delegate.controller?(controller: self!, shouldRemoveAtRow: row)
-                if (result == nil || result!) {
-                    self!.delegate.controller?(controller: self!, didRemoveAtRow: row)
-                }
-            }
-        }
-        
-        listCellView.itemClick = { [weak self] (index: Int) in
-            if (self!.delegate != nil) {
-                if (self!.delegate.controller!(controller: self!, shouldSelectAtRow: row)) {
-                    let templateModel: KMHeaderFooterAdjectiveModel =  self!.datas[row] as! KMHeaderFooterAdjectiveModel
-                    if (self!.selectedTemplateID != templateModel.id) {
-                        self!.selectedTemplateID = templateModel.id
-                    } else {
-                        self!.selectedTemplateID = ""
-                    }
-                    
-                    self!.tableView.reloadData()
-                    
-                    self!.delegate.controller!(controller: self!, didSelectAtRow: row)
-                } else {
-                    self!.selectedTemplateID = ""
-                }
-            } else {
-                let templateModel: KMHeaderFooterAdjectiveModel =  self!.datas[row] as! KMHeaderFooterAdjectiveModel
-                if (self!.selectedTemplateID != templateModel.id) {
-                    self!.selectedTemplateID = templateModel.id
-                } else {
-                    self!.selectedTemplateID = ""
-                }
-                self!.tableView.reloadData()
-            }
-        }
-
-        return cellView
-    }
-    
-    override func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat {
-        let model: KMHeaderFooterAdjectiveModel = self.datas[row] as! KMHeaderFooterAdjectiveModel
-        return model.cellHeight
-    }
-    
-    override func initDatas(datas: Array<AnyObject>) {
-        self.datas.removeAll()
-        
-        for model in datas {
-            self.datas.append(model)
-        }
-        
-        self.refreshUI()
-    }
-}

+ 0 - 22
PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Controller/KMHeaderFooterListController.xib

@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22155" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
-    <dependencies>
-        <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
-        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
-    </dependencies>
-    <objects>
-        <customObject id="-2" userLabel="File's Owner" customClass="KMHeaderFooterListController" customModule="PDF_Master" customModuleProvider="target">
-            <connections>
-                <outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
-            </connections>
-        </customObject>
-        <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
-        <customObject id="-3" userLabel="Application" customClass="NSObject"/>
-        <customView id="Hz6-mo-xeY">
-            <rect key="frame" x="0.0" y="0.0" width="480" height="272"/>
-            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
-            <point key="canvasLocation" x="132" y="-72"/>
-        </customView>
-    </objects>
-</document>

+ 0 - 285
PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Controller/KMHeaderFooterPreviewController.swift

@@ -1,285 +0,0 @@
-//
-//  KMHeaderFooterPreviewController.swift
-//  PDF Reader Pro
-//
-//  Created by tangchao on 2022/12/26.
-//
-
-import Cocoa
-/// 页眉页脚 预览控制器
-class KMHeaderFooterPreviewController: KMWatermarkAdjectivePreViewBaseController {
-    
-    override func viewDidLoad() {
-        super.viewDidLoad()
-        
-        let itemTitles = [[NSLocalizedString("Add HeaderAndFooter", comment: ""), NSLocalizedString("Delete HeaderAndFooter", comment: "")], [NSLocalizedString("Batch", comment: "")]]
-        var itemModels: Array<Array<KMWatermarkAdjectiveTopBarItemModel>> = []
-        for items in itemTitles {
-            var array: Array<KMWatermarkAdjectiveTopBarItemModel> = []
-            for title in items {
-                let model = KMWatermarkAdjectiveTopBarItemModel()
-                model.iconName = ""
-                model.itemTitle = title
-                array.append(model)
-            }
-            itemModels.append(array)
-        }
-        
-        self.topBarView.initItemData(itemArrays: itemModels)
-        self.topBarView.selectTopItem(index: 0)
-        
-        let preView: KMWatermarkPDFView_OC = KMWatermarkPDFView_OC()
-        self.preView = preView
-        self.preView.frame = self.preViewBox.contentView!.bounds
-        self.preView.autoresizingMask = [.width, .height]
-        self.preViewBox.contentView?.addSubview(self.preView)
-        self.preView.setDisplay(.singlePage)
-        
-        let controller = KMHeaderFooterPropertyMainController()
-        controller.view.frame = self.rightBox.contentView!.bounds
-        controller.view.autoresizingMask = [.width, .height]
-        self.right_gotoViewController(viewController: controller)
-        controller.modelDidChange = { [weak self] model in
-//            if (model == nil || (model as! KMHeaderFooterObject).hasVaild == false) {
-//                self!.topBarView.isCanApply(can: false)
-//                self!.model = nil
-//            } else {
-//                self!.topBarView.isCanApply(can: true)
-//                self!.model = model
-//                self?.model?.pageCount = Int((self?.preView.document.pageCount)!)
-//            }
-            
-            (self?.preView as! KMWatermarkPDFView_OC).model = model
-        }
-    }
-    
-    override func viewDidAppear() {
-        super.viewDidAppear()
-        
-        (self.rightViewController as! KMHeaderFooterPropertyMainController).pageCount = Int(self.preView.document.pageCount)
-    }
-    
-    override func topItemClick(index: Int) {
-        if (index == 0) { /// 添加
-            return
-        }
-        if (index == 2) { /// 批量
-//            KMBatchWindowController.openFile(nil, .HeaderAndFooter)
-            return
-        }
-        if (index == 2) { /// 批量
-//            KMBatchWindowController.openFile(nil, .HeaderAndFooter)
-            return
-        }
-        
-         /// 移除
-        self.beginLoading()
-        self.deleteHeaderFooter(toPath: self.preView.document.documentURL.path) {
-            result in
-            self.endLoading()
-            if (result) {
-                DispatchQueue.main.async {
-                    self.preView.document = CPDFDocument(url: self.preView.document.documentURL)
-                }
-            } else {
-                let alert = NSAlert()
-                alert.alertStyle = .critical
-                alert.messageText = NSLocalizedString("Failure", comment: "")
-                alert.runModal()
-            }
-        }
-    }
-    
-    override func applyAction() {
-        if (self.model == nil) {
-            let alert = NSAlert()
-            alert.alertStyle = .critical
-            alert.messageText = NSLocalizedString("Failure", comment: "")
-            alert.runModal()
-            return
-        }
-        self.beginLoading()
-        self.addHeaderFooter(model: self.model! as! KMHeaderFooterObject, toPath: self.preView.document.documentURL.path, completion: {
-            result in
-            DispatchQueue.main.async {
-                self.preView.layoutDocumentView()
-                self.preView.setNeedsDisplayForVisiblePages()
-            }
-            self.endLoading()
-            if (result) {
-                guard let callback = self.itemClick else {
-                    return
-                }
-                callback(1, nil)
-            } else {
-                let alert = NSAlert()
-                alert.alertStyle = .critical
-                alert.messageText = NSLocalizedString("Failure", comment: "")
-                alert.runModal()
-            }
-        })
-    }
-    
-    private func addHeaderFooter(model: KMHeaderFooterObject, toPath: String, completion: @escaping (_ result: Bool) -> ()) {
-        DispatchQueue.global().async {
-            let document: CPDFDocument = self.preView.document
-            var property = document.headerFooter()
-            
-            var fontSize = 0.0
-            var fontName: String = ""
-//            switch model.textFont {
-//            case .font(name: let name, size: let size):
-//                fontSize = size
-//                fontName = name
-//                break
-//            default:
-//                break
-//            }
-            
-            let font = NSFont.boldSystemFont(ofSize:fontSize)
-            let style = NSMutableParagraphStyle()
-            style.alignment = .center
-            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(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
-            
-            var color: NSColor!
-//            switch model.textColor {
-//            case .color(red: let red, green: let green, blue: let blue, alpha: let alpha):
-//                color = NSColor(red: red, green: green, blue: blue, alpha: alpha)
-//            default:
-//                break
-//            }
-            
-            if (color == nil) {
-                color = NSColor.black
-            }
-            
-            for text in strings {
-                property?.setText(text, at: UInt(count))
-                property?.setTextColor(color, at: UInt(count))
-                property?.setFontSize(fontSize, at: UInt(count))
-                property?.setFontName(fontName, at: UInt(count))
-                count += 1
-            }
-//            let pagesString = self.findPagesString(model)
-//            if (pagesString.isEmpty) {
-//                property?.pageString = "0-\(document.pageCount-1)"
-//            } else {
-//                property?.pageString = pagesString
-//            }
-            
-            property?.update()
-            
-            /// 保存到临时路径
-            let documentPath = NSTemporaryDirectory()
-            let tempPath: String = "\(documentPath)/\(toPath.lastPathComponent)"
-            if (FileManager.default.fileExists(atPath: tempPath)) {
-                try?FileManager.default.removeItem(atPath: tempPath)
-            }
-            
-            let result = document.write(to: URL(fileURLWithPath: tempPath))
-            if (result) {
-                if (FileManager.default.fileExists(atPath: toPath)) {
-                    try?FileManager.default.removeItem(atPath: toPath)
-                }
-                
-                try?FileManager.default.moveItem(atPath: tempPath, toPath: toPath)
-            } else {
-                try?FileManager.default.removeItem(atPath: tempPath)
-            }
-            
-            DispatchQueue.main.async {
-                completion(result)
-            }
-        }
-    }
-    
-    func deleteHeaderFooter(toPath: String, completion: @escaping (_ result: Bool) -> ()) {
-        if (self.preView.document.allowsPrinting == false || self.preView.document.allowsCopying == false) {
-            let alert = NSAlert()
-            alert.alertStyle = .critical
-            alert.messageText = NSLocalizedString("This PDF document's user permissions does not allow modifying, content copying and printing.", comment: "")
-            alert.runModal()
-            
-            completion(false)
-            return
-        }
-        
-        DispatchQueue.global().async {
-            let document: CPDFDocument = self.preView.document
-            var property = document.headerFooter()
-            property?.clear()
-            
-            /// 保存到临时路径
-            let documentPath = NSTemporaryDirectory()
-            let tempPath: String = "\(documentPath)/\(toPath.lastPathComponent)"
-            if (FileManager.default.fileExists(atPath: tempPath)) {
-                try?FileManager.default.removeItem(atPath: tempPath)
-            }
-            
-            let result = document.write(to: URL(fileURLWithPath: tempPath))
-            if (result) {
-                if (FileManager.default.fileExists(atPath: toPath)) {
-                    try?FileManager.default.removeItem(atPath: toPath)
-                }
-                
-                try?FileManager.default.moveItem(atPath: tempPath, toPath: toPath)
-            } else {
-                try?FileManager.default.removeItem(atPath: tempPath)
-            }
-            
-            DispatchQueue.main.async {
-                completion(result)
-            }
-        }
-    }
-    
-    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)")
-            string = KMWatermarkAdjectiveTools.parseDateFormat(formatString: string)
-            topLeftString = string
-        }
-        
-        var topCenterString: String = ""
-        if (!model.topCenterString.isEmpty) {
-            var string = KMWatermarkAdjectiveTools.parsePageFormat(formatString: model.topCenterString, startPage: model.startString, pageCount: "\(pageCount)")
-            string = KMWatermarkAdjectiveTools.parseDateFormat(formatString: string)
-            topCenterString = string
-        }
-        
-        var topRightString: String = ""
-        if (!model.topRightString.isEmpty) {
-            var string = KMWatermarkAdjectiveTools.parsePageFormat(formatString: model.topRightString, startPage: model.startString, pageCount: "\(pageCount)")
-            string = KMWatermarkAdjectiveTools.parseDateFormat(formatString: string)
-            topRightString = string
-        }
-        
-        var bottomLeftString: String = ""
-        if (!model.bottomLeftString.isEmpty) {
-            var string = KMWatermarkAdjectiveTools.parsePageFormat(formatString: model.bottomLeftString, startPage: model.startString, pageCount: "\(pageCount)")
-            string = KMWatermarkAdjectiveTools.parseDateFormat(formatString: string)
-            bottomLeftString = string
-        }
-        var bottomCenterString: String = ""
-        if (!model.bottomCenterString.isEmpty) {
-            var string = KMWatermarkAdjectiveTools.parsePageFormat(formatString: model.bottomCenterString, startPage: model.startString, pageCount: "\(pageCount)")
-            string = KMWatermarkAdjectiveTools.parseDateFormat(formatString: string)
-            bottomCenterString = string
-        }
-        var bottomRightString: String = ""
-        if (!model.bottomRightString.isEmpty) {
-            var string = KMWatermarkAdjectiveTools.parsePageFormat(formatString: model.bottomRightString, startPage: model.startString, pageCount: "\(pageCount)")
-            string = KMWatermarkAdjectiveTools.parseDateFormat(formatString: string)
-            bottomRightString = string
-        }
-        
-        return [topLeftString, topCenterString, topRightString, bottomLeftString, bottomCenterString, bottomRightString]
-    }
-}

+ 0 - 22
PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Controller/KMHeaderFooterPreviewController.xib

@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22155" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
-    <dependencies>
-        <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
-        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
-    </dependencies>
-    <objects>
-        <customObject id="-2" userLabel="File's Owner" customClass="KMHeaderFooterPreviewController" customModule="PDF_Master" customModuleProvider="target">
-            <connections>
-                <outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
-            </connections>
-        </customObject>
-        <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
-        <customObject id="-3" userLabel="Application" customClass="NSObject"/>
-        <customView id="Hz6-mo-xeY">
-            <rect key="frame" x="0.0" y="0.0" width="480" height="272"/>
-            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
-            <point key="canvasLocation" x="34" y="-72"/>
-        </customView>
-    </objects>
-</document>

+ 0 - 128
PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Controller/KMHeaderFooterPropertyController.swift

@@ -1,128 +0,0 @@
-//
-//  KMHeaderFooterPropertyController.swift
-//  PDF Reader Pro
-//
-//  Created by tangchao on 2022/12/27.
-//
-
-import Cocoa
-
-typealias KMHeaderFooterPropertyTemplateDidSelected = (_ model: KMHeaderFooterObject,_ isSelected: Bool)->()
-typealias KMHeaderFooterPropertyTemplateMenuItemClick = (_ itemIndex: Int,  _ model: KMHeaderFooterObject)->()
-
-/// 页眉页脚 属性控制器
-class KMHeaderFooterPropertyController: KMWatermarkAdjectivePropertyBaseController {
-    
-    var templateDidSelected: KMHeaderFooterPropertyTemplateDidSelected!
-    var menuItemClick: KMHeaderFooterPropertyTemplateMenuItemClick!
-    
-    var controller = KMHeaderFooterListController()
-    
-    override func viewDidLoad() {
-        super.viewDidLoad()
-        
-        self.showBack(show: false)
-        self.titleLabel.stringValue = NSLocalizedString("HeaderAndFooter", comment: "")
-        self.segementControl.isHidden = true
-        self.segementControlHeightConst.constant = 0
-        
-        let item = NSTabViewItem(identifier: "tabID")
-        item.label = "tab1";
-        let controller = self.controller
-        item.viewController = controller
-        controller.emptyView.despLabel.stringValue = NSLocalizedString("Click the Add button in the upper right corner to create a new header & footer.", comment: "")
-        controller.delegate = self
-        
-        self.tabView.addTabViewItem(item)
-        childViewController.append(controller)
-        
-        reloadDatas()
-    }
-    
-    func reloadDatas () {
-        let controller: KMHeaderFooterListController = childViewController[0] as! KMHeaderFooterListController
-        controller.initDatas(datas: KMHeaderFooterManager.defaultManager.headFooterObjects)
-    }
-    
-    func deleteTemplateModel(_ templateModel: KMHeaderFooterObject) -> Bool {
-        return KMHeaderFooterManager.defaultManager.removeHeaderFooter(templateModel)
-    }
-    
-    func deleteTemplateModel(in controller: KMHeaderFooterListController, index: Int) {
-        if (index >= controller.datas.count) {
-            return
-        }
-        
-        let templateModel: KMHeaderFooterObject = controller.datas[index] as! KMHeaderFooterObject
-        if (deleteTemplateModel(templateModel)) { /// 删除成功,刷新数据
-            reloadDatas()
-        }
-    }
-    
-    func deleteAllTemplateModel(in controller: KMHeaderFooterListController) {
-        
-        reloadDatas()
-    }
-    
-    func findTemplateModel(in controller: KMHeaderFooterListController, index: Int) -> KMHeaderFooterObject? {
-        if (index >= controller.datas.count) {
-            return nil
-        }
-        
-        return (controller.datas[index] as! KMHeaderFooterObject)
-    }
-}
-
-extension KMHeaderFooterPropertyController: KMWatermarkAdjectiveListControllerDelegate {
-    func controller(controller: KMWatermarkAdjectiveListController, shouldSelectAtRow: Int) -> Bool {
-        return true
-    }
-    func controller(controller: KMWatermarkAdjectiveListController, didSelectAtRow: Int) {
-        guard let callback = templateDidSelected else {
-            return
-        }
-
-        let isSelected = controller.selectedTemplateID.isEmpty == false
-        callback(findTemplateModel(in: controller as! KMHeaderFooterListController, index: didSelectAtRow)!, isSelected)
-    }
-    
-    func controller(controller: KMWatermarkAdjectiveListController, didRemoveAtRow: Int) {
-        deleteTemplateModel(in: controller as! KMHeaderFooterListController, index: didRemoveAtRow)
-    }
-    
-    func controller(controller: KMWatermarkAdjectiveListController, didEditAtRow: Int) {
-        guard let callback = menuItemClick else {
-            return
-        }
-        
-        callback(2, findTemplateModel(in: controller as! KMHeaderFooterListController, index: didEditAtRow)!)
-    }
-    
-    func controller(controller: KMWatermarkAdjectiveListController, item: NSMenuItem, itemIndex: Int) {
-        if (itemIndex == 1) { /// 删除
-            deleteTemplateModel(in: controller as! KMHeaderFooterListController, index: item.tag)
-            return
-        }
-        
-        if (itemIndex == 2) { /// 删除全部
-            let alert = NSAlert()
-            alert.messageText = "确认删除全部模板吗?"
-            alert.addButton(withTitle: "删除")
-            alert.addButton(withTitle: "取消")
-            let result = alert.runModal()
-            if (result == .alertSecondButtonReturn) { /// 取消
-                return
-            }
-            
-            deleteAllTemplateModel(in: controller as! KMHeaderFooterListController)
-            return
-        }
-        
-        /// 编辑
-        guard let callback = menuItemClick else {
-            return
-        }
-        
-        callback(2, findTemplateModel(in: controller as! KMHeaderFooterListController, index: item.tag)!)
-    }
-}

+ 0 - 22
PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Controller/KMHeaderFooterPropertyController.xib

@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22155" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
-    <dependencies>
-        <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
-        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
-    </dependencies>
-    <objects>
-        <customObject id="-2" userLabel="File's Owner" customClass="KMHeaderFooterPropertyController" customModule="PDF_Master" customModuleProvider="target">
-            <connections>
-                <outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
-            </connections>
-        </customObject>
-        <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
-        <customObject id="-3" userLabel="Application" customClass="NSObject"/>
-        <customView id="Hz6-mo-xeY">
-            <rect key="frame" x="0.0" y="0.0" width="480" height="272"/>
-            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
-            <point key="canvasLocation" x="27" y="-36"/>
-        </customView>
-    </objects>
-</document>

+ 0 - 268
PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Controller/KMHeaderFooterPropertyInfoController.swift

@@ -1,268 +0,0 @@
-//
-//  KMHeaderFooterPropertyInfoController.swift
-//  PDF Reader Pro
-//
-//  Created by tangchao on 2022/12/27.
-//
-
-import Cocoa
-
-class KMHeaderFooterPropertyInfoController: NSViewController {
-    
-    @IBOutlet weak var fontBox: NSBox!
-    var fontView = KMHeaderFooterFontInfoView()
-    @IBOutlet weak var marginBox: NSBox!
-    var marginView = KMHeaderFooterMarginInfoView()
-    @IBOutlet weak var dateBox: NSBox!
-    var dateView = KMHeaderFooterDateInfoView()
-    @IBOutlet weak var pageBox: NSBox!
-    var pageView = KMHeaderFooterPageInfoView()
-    @IBOutlet weak var contentBox: NSBox!
-    var contentView = KMHeaderFooterContentInfoView()
-    @IBOutlet weak var pageRangeBox: NSBox!
-    
-    var pagePageView = KMConvertPageRangeSettingItemView.createFromNib()
-    
-    weak var delegate: KMWatermarkAdjectivePropertyDelegate!
-    
-    init() {
-        super.init(nibName: "KMHeaderFooterPropertyInfoController", bundle: nil)
-    }
-    
-    required init?(coder: NSCoder) {
-        super.init(nibName: "KMHeaderFooterPropertyInfoController", bundle: nil)
-    }
-    
-    private var myModel: KMHeaderFooterObject!
-    var model: KMHeaderFooterObject {
-        get {
-            return myModel
-        }
-        set {
-            myModel = newValue
-            
-//            self.fontView.model = newValue
-//            self.marginView.model = newValue
-//            self.dateView.model = newValue
-//            
-//            self.pageView.leftComboBox.removeAllItems()
-//            self.pageView.leftComboBox.addItems(withObjectValues: KMWatermarkAdjectiveTools.getPageFormats())
-//            if (newValue.pageFormatString.isEmpty) {
-//                self.pageView.leftComboBox.stringValue = KMWatermarkAdjectiveTools.getPageFormats().first!
-//            } else {
-//                self.pageView.leftComboBox.stringValue = newValue.pageFormatString
-//            }
-//            self.pageView.rightComboBox.removeAllItems()
-//            for i in 0 ..< newValue.pageCount {
-//                self.pageView.rightComboBox.addItem(withObjectValue: i+1)
-//            }
-//            
-//            if (newValue.startString.isEmpty) {
-//                self.pageView.rightComboBox.stringValue = "1"
-//            } else {
-//                self.pageView.rightComboBox.stringValue = newValue.startString
-//            }
-//            
-//            self.contentView.model = newValue
-        }
-    }
-    
-    override func viewWillAppear() {
-        super.viewWillAppear()
-        
-        /// 滚动到顶部
-        DispatchQueue.main.async {
-            let contentView = self.fontBox.enclosingScrollView!.contentView;
-            contentView.scroll(to: NSMakePoint(0, NSHeight(self.fontBox.enclosingScrollView!.documentView!.frame)-NSHeight(contentView.frame)))
-        }
-    }
-    
-    override func viewDidLoad() {
-        super.viewDidLoad()
-        
-        let fontView = self.fontView
-        fontView.frame = self.fontBox.contentView!.bounds
-        fontView.autoresizingMask = NSView.AutoresizingMask(rawValue: 18)
-        self.fontBox.contentView?.addSubview(fontView)
-        fontView.itemClick = { [weak self] (index: Int, value: Any) in
-            if (index == 1) { /// 字体名称
-//                switch self!.model.textFont {
-//                case .font(name: _, size: let size):
-//                    self!.model.textFont = .font(name: value as! String, size: size)
-//                default:
-//                    break
-//                }
-//                
-                if (self!.delegate != nil) {
-                    self!.delegate.propertyInfoDidChange(model: self!.model)
-                }
-            } else if (index == 2) { /// 字体大小
-//                switch self!.model.textFont {
-//                case .font(name: let name, size: _):
-//                    self!.model.textFont = .font(name: name, size: CGFloat(value as! Int))
-//                default:
-//                    break
-//                }
-                
-                if (self!.delegate != nil) {
-                    self!.delegate.propertyInfoDidChange(model: self!.model)
-                }
-            } else if (index == 3) { /// 字体颜色
-                let panel = NSColorPanel.shared
-                panel.setTarget(self!)
-                panel.setAction(#selector(self!.colorPanelAction))
-                panel.orderFront(nil)
-            }
-        }
-        
-        let marginView = self.marginView
-        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
-            if (index == 1) { /// top
-                self!.model.topMargin = value as! Int
-            } else if (index == 2) { /// bottom
-                self!.model.bottomMargin = value as! Int
-            } else if (index == 3) { /// left
-                self!.model.leftMargin = value as! Int
-            } else if (index == 4) { /// right
-                self!.model.rightMargin = value as! Int
-            }
-            
-            if (self!.delegate != nil) {
-                self!.delegate.propertyInfoDidChange(model: self!.model)
-            }
-        }
-        
-        let dateView = self.dateView
-        dateView.frame = self.dateBox.contentView!.bounds
-        dateView.autoresizingMask = NSView.AutoresizingMask(rawValue: 18)
-        self.dateBox.contentView?.addSubview(dateView)
-        dateView.itemClick = { [weak self] (index: Int, value: Any) in
-            
-            self!.model.dateFormatString = value as! String
-            if (self!.delegate != nil) {
-                self!.delegate.propertyInfoDidChange(model: self!.model)
-            }
-        }
-        
-        let pageView = self.pageView
-        pageView.frame = self.pageBox.contentView!.bounds
-        pageView.autoresizingMask = NSView.AutoresizingMask(rawValue: 18)
-        self.pageBox.contentView?.addSubview(pageView)
-        pageView.leftLabel.stringValue = NSLocalizedString("Page:", comment: "")
-        pageView.itemClick = { [weak self] (index: Int, value: Any) in
-            if (index == 1) { /// 页面
-                self!.model.pageFormatString = KMWatermarkAdjectiveTools.getPageFormats()[value as! Int]
-            } else if (index == 2) { /// 起始页
-                self!.model.startString = "\(value as! Int+1)"
-            }
-            if (self!.delegate != nil) {
-                self!.delegate.propertyInfoDidChange(model: self!.model)
-            }
-        }
-        
-        let contentView = self.contentView
-        contentView.frame = self.contentBox.contentView!.bounds
-        contentView.autoresizingMask = NSView.AutoresizingMask(rawValue: 18)
-        self.contentBox.contentView?.addSubview(contentView)
-        contentView.addAction = { [weak self]
-            (index: Int, sender: NSButton) in
-            let menu = NSMenu()
-            let item = menu.addItem(withTitle: NSLocalizedString("Insert Page Number", comment: ""), action: #selector(self!.insertPageAction), keyEquivalent: "")
-            item.target = self
-            let item2 = menu.addItem(withTitle: NSLocalizedString("Insert Date", comment: ""), action: #selector(self!.insertDateAction), keyEquivalent: "")
-            item2.target = self
-            menu.popUp(positioning: nil, at: NSPoint(x: sender.bounds.midX, y: sender.bounds.maxY), in: sender)
-        }
-        contentView.itemClick = { [weak self] (index: Int, value: Any) in
-            self!.updateModelForContentInfo(index: index, value: value as! String)
-        }
-        
-        let pageRangeView = self.pagePageView
-        pageRangeView?.frame = self.pageRangeBox.contentView!.bounds
-        pageRangeView?.autoresizingMask = NSView.AutoresizingMask(rawValue: 18)
-        self.pageRangeBox.contentView?.addSubview(pageRangeView!)
-        pageRangeView!.pageSizeComboBox.removeAllItems()
-        pageRangeView!.pageSizeComboBox.addItems(withObjectValues: [NSLocalizedString("All Pages", comment: ""), NSLocalizedString("Odd Pages", comment: ""), NSLocalizedString("Even Pages", comment: ""), NSLocalizedString("Customized", comment: "")])
-        pageRangeView!.pageSizeComboBox.selectItem(at: 0)
-        
-        pageRangeView?.isTextDidEndCallback = true
-        
-        pageRangeView?.itemClick = { [unowned self] index, _ in
-//            self.model.pageRangeType = KMWatermarkeModelPageRangeType(rawValue: index)!
-            
-            if (self.delegate != nil) {
-                self.delegate.propertyInfoDidChange(model: self.model)
-            }
-        }
-        
-        pageRangeView?.textDidEndEditingCallback = { [weak self] (textString: String) in
-//            let array = KMPageRangeTools.findSelectPage(pageRangeString: textString, pageCount: self!.model.pageCount)
-//            if (array.count <= 0) {
-//                let alert = NSAlert()
-//                alert.alertStyle = .warning
-//                alert.messageText = NSLocalizedString("Invalid page range or the page number is out of range. Please try again.", comment: "")
-//                alert.runModal()
-//                return
-//            }
-
-//            var pageString: String = ""
-//            for i in 0 ..< array.count {
-//                pageString.append("\(array[i]-1)")
-//
-//                if (i != array.count-1) {
-//                    pageString.append(",")
-//                }
-//            }
-//            self!.model.pageRangeString = pageString
-            
-            if (self!.delegate != nil) {
-                self!.delegate.propertyInfoDidChange(model: self!.model)
-            }
-        }
-    }
-    
-    private func updateModelForContentInfo(index: Int, value: String) {
-        if (index == 1) {
-            self.model.topLeftString = value
-        } else if (index == 2) {
-            self.model.topCenterString = value
-        } else if (index == 3) {
-            self.model.topRightString = value
-        } else if (index == 4) {
-            self.model.bottomLeftString = value
-        } else if (index == 5) {
-            self.model.bottomCenterString = value
-        } else if (index == 6) {
-            self.model.bottomRightString = value
-        }
-        
-        if (self.delegate != nil) {
-            self.delegate.propertyInfoDidChange(model: self.model)
-        }
-    }
-    
-    @objc func colorPanelAction(sender: NSColorPanel) {
-        let color = KMWatermarkAdjectiveTools.parseColor(color: sender.color)
-//        self.model.textColor = .color(red: color.red, green: color.green, blue: color.blue, alpha: color.alpha)
-        
-        self.fontView.colorView.layer?.backgroundColor = sender.color.cgColor
-        if (self.delegate != nil) {
-            self.delegate.propertyInfoDidChange(model: self.model)
-        }
-    }
-
-    @objc private func insertPageAction(sender: NSMenuItem) {
-        let string: String = "<<\(self.pageView.leftComboBox.stringValue)>>"
-        self.contentView.textView.string = "\(self.contentView.textView.string)".appending(string)
-        self.updateModelForContentInfo(index: self.contentView.indexForSelectedItem, value: self.contentView.textView.string)
-    }
-    
-    @objc private func insertDateAction(sender: NSMenuItem) {
-        let string: String = "<<\(self.myModel.dateFormatString)>>"
-        self.contentView.textView.string = "\(self.contentView.textView.string)".appending(string)
-        self.updateModelForContentInfo(index: self.contentView.indexForSelectedItem, value: self.contentView.textView.string)
-    }
-}

+ 0 - 139
PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Controller/KMHeaderFooterPropertyInfoController.xib

@@ -1,139 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22155" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
-    <dependencies>
-        <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
-        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
-    </dependencies>
-    <objects>
-        <customObject id="-2" userLabel="File's Owner" customClass="KMHeaderFooterPropertyInfoController" customModule="PDF_Master" customModuleProvider="target">
-            <connections>
-                <outlet property="contentBox" destination="ScF-Br-HOU" id="YBx-8E-bCy"/>
-                <outlet property="dateBox" destination="lD6-l9-T1s" id="QQ9-0c-D8S"/>
-                <outlet property="fontBox" destination="54Z-AJ-dAS" id="gzT-0d-eFT"/>
-                <outlet property="marginBox" destination="mfJ-bL-F8H" id="5bU-ZN-u7b"/>
-                <outlet property="pageBox" destination="FW6-Po-xgO" id="ij5-Uq-Gy0"/>
-                <outlet property="pageRangeBox" destination="N4K-r9-bXa" id="xex-an-fDu"/>
-                <outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
-            </connections>
-        </customObject>
-        <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
-        <customObject id="-3" userLabel="Application" customClass="NSObject"/>
-        <customView id="Hz6-mo-xeY">
-            <rect key="frame" x="0.0" y="0.0" width="260" height="620"/>
-            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
-            <subviews>
-                <scrollView borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="x0f-uc-PDc">
-                    <rect key="frame" x="0.0" y="0.0" width="260" height="620"/>
-                    <clipView key="contentView" drawsBackground="NO" id="fe8-fE-g98">
-                        <rect key="frame" x="0.0" y="0.0" width="245" height="605"/>
-                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                        <subviews>
-                            <view id="hcM-Rb-nqQ">
-                                <rect key="frame" x="0.0" y="0.0" width="260" height="620"/>
-                                <autoresizingMask key="autoresizingMask"/>
-                                <subviews>
-                                    <box boxType="custom" borderWidth="0.0" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="54Z-AJ-dAS">
-                                        <rect key="frame" x="0.0" y="500" width="260" height="120"/>
-                                        <view key="contentView" id="mYJ-m0-7Ia">
-                                            <rect key="frame" x="0.0" y="0.0" width="260" height="120"/>
-                                            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                                        </view>
-                                        <constraints>
-                                            <constraint firstAttribute="height" constant="120" id="hOh-c2-5U1"/>
-                                        </constraints>
-                                    </box>
-                                    <box boxType="custom" borderWidth="0.0" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="mfJ-bL-F8H">
-                                        <rect key="frame" x="0.0" y="370" width="260" height="130"/>
-                                        <view key="contentView" id="NXU-6u-qLb">
-                                            <rect key="frame" x="0.0" y="0.0" width="260" height="130"/>
-                                            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                                        </view>
-                                        <constraints>
-                                            <constraint firstAttribute="height" constant="130" id="t9g-qC-bzp"/>
-                                        </constraints>
-                                    </box>
-                                    <box boxType="custom" borderWidth="0.0" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="lD6-l9-T1s">
-                                        <rect key="frame" x="0.0" y="300" width="260" height="70"/>
-                                        <view key="contentView" id="P12-P5-8kS">
-                                            <rect key="frame" x="0.0" y="0.0" width="260" height="70"/>
-                                            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                                        </view>
-                                        <constraints>
-                                            <constraint firstAttribute="height" constant="70" id="7We-lo-7Fv"/>
-                                        </constraints>
-                                    </box>
-                                    <box boxType="custom" borderWidth="0.0" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="FW6-Po-xgO">
-                                        <rect key="frame" x="0.0" y="240" width="260" height="60"/>
-                                        <view key="contentView" id="Ona-4g-7IN">
-                                            <rect key="frame" x="0.0" y="0.0" width="260" height="60"/>
-                                            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                                        </view>
-                                        <constraints>
-                                            <constraint firstAttribute="height" constant="60" id="F0K-Oc-2Ou"/>
-                                        </constraints>
-                                    </box>
-                                    <box boxType="custom" borderWidth="0.0" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="ScF-Br-HOU">
-                                        <rect key="frame" x="0.0" y="80" width="260" height="160"/>
-                                        <view key="contentView" id="kbu-aS-HMz">
-                                            <rect key="frame" x="0.0" y="0.0" width="260" height="160"/>
-                                            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                                        </view>
-                                        <constraints>
-                                            <constraint firstAttribute="height" constant="160" id="sMI-8g-WJh"/>
-                                        </constraints>
-                                    </box>
-                                    <box boxType="custom" borderWidth="0.0" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="N4K-r9-bXa">
-                                        <rect key="frame" x="0.0" y="0.0" width="260" height="70"/>
-                                        <view key="contentView" id="PjS-61-8Ek">
-                                            <rect key="frame" x="0.0" y="0.0" width="260" height="70"/>
-                                            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                                        </view>
-                                        <constraints>
-                                            <constraint firstAttribute="height" constant="70" id="IqK-Uw-es0"/>
-                                        </constraints>
-                                    </box>
-                                </subviews>
-                                <constraints>
-                                    <constraint firstItem="FW6-Po-xgO" firstAttribute="leading" secondItem="hcM-Rb-nqQ" secondAttribute="leading" id="18r-ri-xcs"/>
-                                    <constraint firstItem="N4K-r9-bXa" firstAttribute="leading" secondItem="hcM-Rb-nqQ" secondAttribute="leading" id="3K3-BZ-SKy"/>
-                                    <constraint firstItem="N4K-r9-bXa" firstAttribute="top" secondItem="ScF-Br-HOU" secondAttribute="bottom" constant="10" id="91e-iU-Yi5"/>
-                                    <constraint firstItem="ScF-Br-HOU" firstAttribute="top" secondItem="FW6-Po-xgO" secondAttribute="bottom" id="AhC-Qr-bel"/>
-                                    <constraint firstAttribute="trailing" secondItem="mfJ-bL-F8H" secondAttribute="trailing" id="Ch5-sY-u0Y"/>
-                                    <constraint firstAttribute="trailing" secondItem="FW6-Po-xgO" secondAttribute="trailing" id="E5a-hQ-zH9"/>
-                                    <constraint firstItem="mfJ-bL-F8H" firstAttribute="top" secondItem="54Z-AJ-dAS" secondAttribute="bottom" id="H34-7a-Qn9"/>
-                                    <constraint firstAttribute="trailing" secondItem="ScF-Br-HOU" secondAttribute="trailing" id="HYl-69-WO8"/>
-                                    <constraint firstAttribute="trailing" secondItem="lD6-l9-T1s" secondAttribute="trailing" id="Hdg-ps-m4z"/>
-                                    <constraint firstItem="54Z-AJ-dAS" firstAttribute="leading" secondItem="hcM-Rb-nqQ" secondAttribute="leading" id="HwH-Bj-wfj"/>
-                                    <constraint firstItem="lD6-l9-T1s" firstAttribute="top" secondItem="mfJ-bL-F8H" secondAttribute="bottom" id="Il8-5f-JvF"/>
-                                    <constraint firstItem="ScF-Br-HOU" firstAttribute="leading" secondItem="hcM-Rb-nqQ" secondAttribute="leading" id="LTg-Dk-08Q"/>
-                                    <constraint firstItem="lD6-l9-T1s" firstAttribute="leading" secondItem="hcM-Rb-nqQ" secondAttribute="leading" id="Nx6-9v-nOM"/>
-                                    <constraint firstAttribute="trailing" secondItem="54Z-AJ-dAS" secondAttribute="trailing" id="XC6-wP-IfA"/>
-                                    <constraint firstAttribute="trailing" secondItem="N4K-r9-bXa" secondAttribute="trailing" id="aSV-sc-Lme"/>
-                                    <constraint firstItem="mfJ-bL-F8H" firstAttribute="leading" secondItem="hcM-Rb-nqQ" secondAttribute="leading" id="aWG-QF-Emt"/>
-                                    <constraint firstItem="FW6-Po-xgO" firstAttribute="top" secondItem="lD6-l9-T1s" secondAttribute="bottom" id="bIg-V0-di9"/>
-                                    <constraint firstItem="54Z-AJ-dAS" firstAttribute="top" secondItem="hcM-Rb-nqQ" secondAttribute="top" id="x4V-HW-0gJ"/>
-                                </constraints>
-                            </view>
-                        </subviews>
-                    </clipView>
-                    <scroller key="horizontalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="Ol4-Uh-B51">
-                        <rect key="frame" x="0.0" y="605" width="245" height="15"/>
-                        <autoresizingMask key="autoresizingMask"/>
-                    </scroller>
-                    <scroller key="verticalScroller" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="KUL-Js-Nhi">
-                        <rect key="frame" x="245" y="0.0" width="15" height="605"/>
-                        <autoresizingMask key="autoresizingMask"/>
-                    </scroller>
-                </scrollView>
-            </subviews>
-            <constraints>
-                <constraint firstAttribute="bottom" secondItem="x0f-uc-PDc" secondAttribute="bottom" id="6n4-mv-5yy"/>
-                <constraint firstItem="x0f-uc-PDc" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="DEe-MM-3MV"/>
-                <constraint firstItem="x0f-uc-PDc" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="GI5-jm-MQF"/>
-                <constraint firstAttribute="trailing" secondItem="x0f-uc-PDc" secondAttribute="trailing" id="kQz-v3-JGC"/>
-            </constraints>
-            <point key="canvasLocation" x="183" y="167"/>
-        </customView>
-    </objects>
-</document>

+ 0 - 122
PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Controller/KMHeaderFooterPropertyMainController.swift

@@ -1,122 +0,0 @@
-//
-//  KMHeaderFooterController.swift
-//  PDF Reader Pro
-//
-//  Created by tangchao on 2022/12/26.
-//
-
-import Cocoa
-/// 页眉页脚 属性主控制器
-class KMHeaderFooterPropertyMainController: KMWatermarkAdjectivePropertyMainController {
-
-    override func viewDidLoad() {
-        super.viewDidLoad()
-    }
-    
-    override func gotoHomeController(_ selectedModelID: String) {
-        let controller = KMHeaderFooterPropertyController()
-        controller.controller.selectedTemplateID = selectedModelID
-        
-        self.showController(controller)
-        
-        controller.rightButtonClick = { [weak self] index in
-            self!.gotoCreateController()
-        }
-        
-        controller.menuItemClick = { [weak self] index, model in
-            if (index == 2) { /// 编辑
-//                self!.gotoEditController(model)
-            }
-        }
-        
-        controller.templateDidSelected = { [weak self] model, selected in
-            if (selected) { /// 模板已选中,
-//                self!.model = model
-            } else { /// 模板取消选中
-                self!.model = nil
-            }
-            
-            guard let callback = self!.modelDidChange else {
-                return
-            }
-            
-            callback(self!.model)
-        }
-    }
-    
-    override func gotoCreateController() {
-        let controller = KMCreateHeaderFooterController()
-        let model: KMHeaderFooterObject = KMHeaderFooterObject()
-//        model.pageCount = self.pageCount
-        controller.model = model
-        
-        self.showController(controller)
-        
-        controller.backClick = { [weak self] in
-            self!.gotoHomeController("")
-        }
-        
-        controller.rightButtonClick = { [weak self] index in
-            /// 保存到模板
-            let createController: KMCreateHeaderFooterController = self!.currentController as! KMCreateHeaderFooterController
-            if (createController.model != nil) {
-                let model: KMHeaderFooterObject = createController.model as! KMHeaderFooterObject
-//                if (!model.hasVaild) {
-//                    let alert = NSAlert()
-//                    alert.alertStyle = .warning
-//                    alert.messageText = NSLocalizedString("未找到内容", comment: "")
-//                    alert.runModal()
-//                    return
-//                }
-                
-                KMHeaderFooterManager.defaultManager.addHeaderFooter(createController.model as! KMHeaderFooterObject)
-                guard let callback = self!.modelDidChange else {
-                    return
-                }
-
-//                self?.model = model
-                callback(self!.model)
-                
-//                self!.gotoHomeController(model.id)
-            }
-        }
-        
-        controller.modelDidChange = { [weak self] model in
-            /// 模型已经修改,可以再这里刷新预览视图
-//            self?.model = model
-            guard let callback = self!.modelDidChange else {
-                return
-            }
-            
-            callback(self?.model)
-        }
-    }
-    
-    
-    override func gotoEditController(_ model: KMWatermarkAdjectiveBaseModel) {
-        let controller = KMCreateHeaderFooterController()
-        controller.isEdit = true
-        model.pageCount = self.pageCount
-        controller.model = model
-        controller.flagModel = model.copy() as AnyObject
-        
-        self.showController(controller)
-        
-        controller.backClick = { [weak self] in
-            let editController: KMCreateHeaderFooterController = self!.currentController as! KMCreateHeaderFooterController
-            if (editController.isEdited) {
-                /// 更新模板
- //                if (result) {
-                    
-                self!.gotoHomeController("")
-//                }
-            } else {
-                self!.gotoHomeController("")
-            }
-        }
-        controller.rightButtonClick = { [weak self] index in
-            let editController: KMCreateHeaderFooterController = self!.currentController as! KMCreateHeaderFooterController
-            editController.resume()
-        }
-    }
-}

+ 0 - 22
PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Controller/KMHeaderFooterPropertyMainController.xib

@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22155" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
-    <dependencies>
-        <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
-        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
-    </dependencies>
-    <objects>
-        <customObject id="-2" userLabel="File's Owner" customClass="KMHeaderFooterPropertyMainController" customModule="PDF_Master" customModuleProvider="target">
-            <connections>
-                <outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
-            </connections>
-        </customObject>
-        <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
-        <customObject id="-3" userLabel="Application" customClass="NSObject"/>
-        <customView id="Hz6-mo-xeY">
-            <rect key="frame" x="0.0" y="0.0" width="260" height="450"/>
-            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
-            <point key="canvasLocation" x="226" y="39"/>
-        </customView>
-    </objects>
-</document>

+ 34 - 13
PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/KMHeaderFooterController.swift

@@ -71,39 +71,45 @@ class KMHeaderFooterController: NSViewController {
         
         if editSubType == .template {
             templatesController.view.isHidden = false
-            templatesController.reloadData()
             
         } else if editSubType == .add {
             propertyController.view.isHidden = false
             propertyController.editSubType = editSubType
-            propertyController.reloadData()
             
         } else if editSubType == .edit {
             propertyController.view.isHidden = false
             propertyController.editSubType = editSubType
-            propertyController.reloadData()
             
         }
     }
     
     func reloadData() {
-        resetUI()
+        documentPreview.pdfDocument = self.pdfDocument
+        documentPreview.reloadData()
         
         propertyController.totalPDFCount = totalPDFCount
-        propertyController.reloadData()
         
-        documentPreview.pdfDocument = self.pdfDocument
-        documentPreview.reloadData()
-         
+        if editSubType == .template {
+            templatesController.reloadData()
+            headerFooterModel = templatesController.selectedModel
+            
+        } else if editSubType == .add {
+            propertyController.editSubType = editSubType
+            propertyController.totalPDFCount = totalPDFCount
+            propertyController.reloadData()
+            
+        } else if editSubType == .edit {
+            propertyController.reloadData()
+        }
     }
     
     func updatePDFDocumentHeaderFooter() {
         if let data = headerFooterModel {
-            let cPDFHeaderFooter = documentPreview.pdfDocument?.headerFooter()
+            let cPDFHeaderFooter = documentPreview.pdfDocument?.headerFooter()            
             cPDFHeaderFooter?.pageString = "0"
             
-            var fontSize = data.fontsize
-            var fontName: String = data.fontName
+            let fontSize = data.fontsize
+            let fontName: String = data.fontName
 
             let font = NSFont.boldSystemFont(ofSize:fontSize)
             let style = NSMutableParagraphStyle()
@@ -126,8 +132,8 @@ class KMHeaderFooterController: NSViewController {
             }
             
             cPDFHeaderFooter?.update()
-            
-            self.documentPreview.refreshUI()
+             
+            documentPreview.refreshUI()
         } else {
             pdfDocument?.headerFooter().clear()
             documentPreview.refreshUI()
@@ -164,6 +170,8 @@ extension KMHeaderFooterController: KMHeaderPropertyControllerDelegate {
         editSubType = .template
         resetUI()
         
+        templatesController.selectedModel = data
+        
         reloadData()
         
         updatePDFDocumentHeaderFooter()
@@ -186,6 +194,19 @@ extension KMHeaderFooterController: KMHeaderPropertyControllerDelegate {
         delegate?.kmHeaderFooterControllerDidModelDataUpdated?(self)
         
     }
+    
+    func headerFooterPropertyControllerFinishTemplateEdit(_ controller: KMHeaderPropertyController) {
+        editSubType = .template
+        resetUI()
+        
+        updatePDFDocumentHeaderFooter()
+        
+        reloadData()
+        
+        delegate?.kmHeaderFooterControllerDidUpdateMode?(self)
+        
+        delegate?.kmHeaderFooterControllerDidModelDataUpdated?(self)
+    }
 }
 
 

+ 115 - 21
PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/KMHeaderFooterManager.swift

@@ -4,9 +4,7 @@ let kHeaderFooterFolderPath = NSSearchPathForDirectoriesInDomains(FileManager.Se
 
 let kHeaderFooterPlistPath = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.applicationSupportDirectory, FileManager.SearchPathDomainMask.userDomainMask, true).last?.stringByAppendingPathComponent(Bundle.main.bundleIdentifier!).stringByAppendingPathComponent("headerFooter").stringByAppendingPathComponent("headerFooter2025.plist")
 
-
 let kHeaderFooterRemovedKey = "kHeaderFooterRemovedKey"
-
 private let kHeaderFooterInfoSaveKey = "kHeaderFooterInfoSaveKey"
 let kHeaderFooterManagerInit = "kHeaderFooterManagerInit"
 
@@ -16,7 +14,6 @@ class KMHeaderFooterManager: NSObject {
     
     static let defaultManager = KMHeaderFooterManager()
     
-    
     override init() {
         super.init()
         
@@ -40,6 +37,7 @@ class KMHeaderFooterManager: NSObject {
         }
     }
     
+    //MARK: - 增删改查
     func addHeaderFooter(_ obj: KMHeaderFooterObject) -> Bool {
          if (!FileManager.default.fileExists(atPath: kHeaderFooterFolderPath!)) {
             let create: ()? = try?FileManager.default.createDirectory(atPath: kHeaderFooterFolderPath!, withIntermediateDirectories: false)
@@ -115,7 +113,6 @@ class KMHeaderFooterManager: NSObject {
     }
     
     func updateHeaderFooter(theModel: KMHeaderFooterObject) -> Bool {
-         
         var flagModel: KMHeaderFooterObject!
         for model in self.headFooterObjects {
             if (model.tag == theModel.tag) {
@@ -152,11 +149,9 @@ class KMHeaderFooterManager: NSObject {
                 self.headFooterObjects[index] = theModel
             }
         }
-        
         return result
     }
     
-    
     func updateModel(_ model: KMHeaderFooterObject, with dict: NSDictionary) {
         model.fontName = dict.object(forKey: "fontName") as! String
         model.fontsize = dict.object(forKey: "fontsize") as! CGFloat
@@ -185,10 +180,35 @@ class KMHeaderFooterManager: NSObject {
         if let value = dict.object(forKey: "tag") {
             model.tag = value as! String
         }
-        
     }
     
-    //Parse
+    func updateCPDFHeaderFooter(_ headerFooter: CPDFHeaderFooter, withModel model: KMHeaderFooterObject, _ totalPDFCount: Int) {
+          
+        let fontSize = model.fontsize
+        let fontName: String = model.fontName
+
+        let font = NSFont.boldSystemFont(ofSize:fontSize)
+        let style = NSMutableParagraphStyle()
+        style.alignment = .center
+        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
+        
+        headerFooter.margin = NSEdgeInsetsMake(max(CGFloat(model.topMargin)-size.height, 0), CGFloat(model.leftMargin), max(CGFloat(model.bottomMargin)-size.height, 0), CGFloat(model.rightMargin))
+        
+        let strings = KMHeaderFooterObject.parseModel(model: model, pageCount: totalPDFCount)
+        var count: Int = 0
+        let color = model.color
+        
+        for text in strings {
+            headerFooter.setText(text, at: UInt(count))
+            headerFooter.setTextColor(color, at: UInt(count))
+            headerFooter.setFontSize(fontSize, at: UInt(count))
+            headerFooter.setFontName(fontName, at: UInt(count))
+            count += 1
+        }
+    }
+    
+    //MARK: - Parse
     func parseModel(model: KMHeaderFooterObject) -> Dictionary<String, Any> {
         var dict: [String : Any] = [:]
         
@@ -248,9 +268,8 @@ class KMHeaderFooterManager: NSObject {
          
         return model
     }
-    
-    
-
+     
+    //MARK: - Get
     func fetchHeaderFooterAvailableName() -> String {
         var availableIndex = 0
         for item in headFooterObjects {
@@ -263,19 +282,94 @@ class KMHeaderFooterManager: NSObject {
         return "HeaderFooter\(availableIndex)"
     }
     
-    
-    
-}
-
-extension KMHeaderFooterManager {
-    func fetchPlistData() -> [KMHeaderFooterObject] {
+    //MARK: - Compare
+    class func compareIsChangedModel(_ model: KMHeaderFooterObject, withDict dict: NSDictionary) -> Bool {
+        if let value = dict["fontName"] {
+            if model.fontName != (value as! String) {
+                return true
+            }
+        }
         
-        return []
+        if let value = dict["fontsize"] {
+            if model.fontsize != (value as! CGFloat) {
+                return true
+            }
+        }
         
-    }
-    
-    func savePlistData() {
+        if let value = dict["color"] {
+            if model.color.toHex() != (value as! String) {
+                return true
+            }
+        }
         
+        if let value = dict["leftMargin"] {
+            if model.leftMargin != (value as! Int) {
+                return true
+            }
+        }
+        if let value = dict["rightMargin"] {
+            if model.rightMargin != (value as! Int) {
+                return true
+            }
+        }
+        if let value = dict["bottomMargin"] {
+            if model.bottomMargin != (value as! Int) {
+                return true
+            }
+        }
+        if let value = dict["topMargin"] {
+            if model.topMargin != (value as! Int) {
+                return true
+            }
+        }
+         
+        if let value = dict["topLeftString"] {
+            if model.topLeftString != (value as! String) {
+                return true
+            }
+        }
+        if let value = dict["topCenterString"] {
+            if model.topCenterString != (value as! String) {
+                return true
+            }
+        }
+        if let value = dict["topRightString"] {
+            if model.topRightString != (value as! String) {
+                return true
+            }
+        }
+        if let value = dict["bottomLeftString"] {
+            if model.bottomLeftString != (value as! String) {
+                return true
+            }
+        }
+        if let value = dict["bottomCenterString"] {
+            if model.bottomCenterString != (value as! String) {
+                return true
+            }
+        }
+        if let value = dict["bottomRightString"] {
+            if model.bottomRightString != (value as! String) {
+                return true
+            }
+        }
+         
+        if let value = dict["dateFormatString"] {
+            if model.dateFormatString != (value as! String) {
+                return true
+            }
+        }
+        if let value = dict["pageFormatString"] {
+            if model.pageFormatString != (value as! String) {
+                return true
+            }
+        }
+        if let value = dict["startString"] {
+            if model.startString != (value as! String) {
+                return true
+            }
+        } 
+        return false
     }
 }
 

+ 0 - 224
PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/View/KMHeaderFooterContentInfoView.swift

@@ -1,224 +0,0 @@
-//
-//  KMHeaderFooterContentInfoView.swift
-//  PDF Reader Pro
-//
-//  Created by tangchao on 2022/12/28.
-//
-
-import Cocoa
-
-typealias KMHeaderFooterContentInfoView_selectAreaViewItemClick = (_ index: Int) -> ()
-private class KMHeaderFooterContentInfoView_selectAreaView: NSView {
-    
-    private var hLine = NSView()
-    private var vLine = NSView()
-    private var vLine2 = NSView()
-    
-    private var buttons: Array<NSButton> = []
-    
-    var itemClick: KMHeaderFooterContentInfoView_selectAreaViewItemClick!
-    
-    override init(frame frameRect: NSRect) {
-        super.init(frame: frameRect)
-        
-        self.initSubViews()
-    }
-    
-    required init?(coder: NSCoder) {
-        super.init(coder: coder)
-        
-        self.initSubViews()
-    }
-    
-    override var isFlipped: Bool {
-        return true
-    }
-    
-    private func initSubViews() {
-        self.addSubview(self.hLine)
-        self.addSubview(self.vLine)
-        self.addSubview(self.vLine2)
-        
-        self.wantsLayer = true
-        self.layer?.borderWidth = 1
-        self.layer?.borderColor = NSColor.black.cgColor
-        self.layer?.cornerRadius = 2
-        for line in [self.hLine, self.vLine, self.vLine2] {
-            line.wantsLayer = true
-            line.layer?.backgroundColor = NSColor.black.cgColor
-        }
-        
-        self.buttons.removeAll()
-        for i in 0 ... 1 {
-            for j in 0 ... 2 {
-                let button = NSButton()
-                button.isBordered = false
-                button.title = ""
-                self.addSubview(button)
-                self.buttons.append(button)
-                
-                button.tag = i * 3 + j + 1
-                button.target = self
-                button.action = #selector(buttonAction)
-            }
-        }
-    }
-    
-    override func layout() {
-        super.layout()
-        
-        let width: CGFloat = NSWidth(self.bounds)
-        let height: CGFloat = NSHeight(self.bounds)
-        
-        let itemSize: NSSize = NSMakeSize(width/3, height*0.5)
-        self.hLine.frame = NSMakeRect(0, itemSize.height, width, 1)
-        self.vLine.frame = NSMakeRect(itemSize.width, 0, 1, height)
-        self.vLine2.frame = NSMakeRect(itemSize.width*2, 0, 1, height)
-        
-        for i in 0 ... 1 {
-            for j in 0 ... 2 {
-                let button = self.buttons[i*3+j]
-                button.frame = NSMakeRect(CGFloat(j)*itemSize.width, CGFloat(i)*itemSize.height, itemSize.width, itemSize.height)
-            }
-        }
-    }
-    
-    func selectIndex(index: Int) {
-        for button in self.buttons {
-            button.wantsLayer = true
-            if (button.tag == index) {
-                button.layer?.backgroundColor = NSColor.black.cgColor
-            } else {
-                button.layer?.backgroundColor = NSColor.clear.cgColor
-            }
-        }
-    }
-    
-    @objc private func buttonAction(sender: NSButton) {
-        guard let callback = self.itemClick else {
-            return
-        }
-        
-        self.selectIndex(index: sender.tag)
-        callback(sender.tag)
-    }
-}
-
-typealias KMHeaderFooterContentInfoViewAddAction = (_ index: Int, _ sender: NSButton) -> ()
-class KMHeaderFooterContentInfoView: KMHeaderFooterAdjectiveInfoBaseView {
-    
-    var addButton = NSButton()
-    private var selectAreaView = KMHeaderFooterContentInfoView_selectAreaView()
-    var textViewBox = NSView()
-    var scrollView = NSScrollView()
-    var textView = NSTextView()
-    
-    var addAction: KMHeaderFooterContentInfoViewAddAction!
-    
-    private var selectedIndex: Int = 1
-    var indexForSelectedItem: Int {
-        get {
-            return self.selectedIndex
-        }
-    }
-    
-    override func initSubviews() {
-        super.initSubviews()
-        
-        self.addSubview(self.addButton)
-        self.addSubview(self.selectAreaView)
-        self.addSubview(self.textViewBox)
-        self.addSubview(self.scrollView)
-        self.scrollView.documentView = self.textView
-        
-        self.titleLabel.stringValue = NSLocalizedString("Layout & Content", comment: "")
-        self.addButton.isBordered = false
-        self.addButton.title = "+"
-        self.addButton.target = self
-        self.addButton.action = #selector(addButtonAction)
-        
-        self.textViewBox.wantsLayer = true
-        self.textViewBox.layer?.borderWidth = 1
-        self.textViewBox.layer?.borderColor = NSColor.black.cgColor
-        self.textViewBox.layer?.cornerRadius = 4
-        
-        self.scrollView.borderType = .noBorder
-        self.scrollView.wantsLayer = true
-        self.scrollView.layer?.borderWidth = 1
-        self.scrollView.layer?.borderColor = NSColor.black.cgColor
-        self.scrollView.layer?.cornerRadius = 2
-        self.scrollView.layer?.masksToBounds = true
-        self.textView.textContainerInset = NSMakeSize(6, 8)
-        self.textView.isRichText = false
-        self.textView.drawsBackground = false
-        self.scrollView.drawsBackground = false
-        self.textView.delegate = self
-        
-        self.selectAreaView.itemClick = {
-            (index: Int) in
-            self.selectedIndex = index
-            
-            if (index == 1) {
-                self.textView.string = self.model.topLeftString
-            } else if (index == 2) {
-                self.textView.string = self.model.topCenterString
-            } else if (index == 3) {
-                self.textView.string = self.model.topRightString
-            } else if (index == 4) {
-                self.textView.string = self.model.bottomLeftString
-            } else if (index == 5) {
-                self.textView.string = self.model.bottomCenterString
-            } else if (index == 6) {
-                self.textView.string = self.model.bottomRightString
-            }
-        }
-    }
-    
-    override func layout() {
-        super.layout()
-        
-        let leftMargin = self.contentInset.left
-        let width: CGFloat = NSWidth(self.bounds)
-        let contentWidth: CGFloat = width-leftMargin-self.contentInset.right
-        
-        let buttonSize: CGFloat = 22
-        let buttonX: CGFloat = width-self.contentInset.right-buttonSize
-        self.addButton.frame = NSMakeRect(buttonX, 0, buttonSize, buttonSize)
-        
-        self.selectAreaView.frame = NSMakeRect(leftMargin, self.titleLabel.frame.maxY+10, contentWidth, 40)
-        self.textViewBox.frame = NSMakeRect(leftMargin, self.selectAreaView.frame.maxY+10, contentWidth, 80)
-        self.scrollView.frame = NSMakeRect(leftMargin+1, self.selectAreaView.frame.maxY+11, contentWidth-2, 78)
-        self.textView.frame = NSMakeRect(1, 1, contentWidth-2, 78)
-    }
-    
-    override var model: KMHeaderFooterAdjectiveModel {
-        get {
-            return super.model
-        }
-        set {
-            super.model = newValue
-            
-            self.selectAreaView.selectIndex(index: 1)
-            self.selectedIndex = 1
-            self.textView.string = model.topLeftString
-        }
-    }
-    
-    @objc private func addButtonAction() {
-        guard let callback = self.addAction else {
-            return
-        }
-        
-        callback(self.selectedIndex, self.addButton)
-    }
-}
-
-extension KMHeaderFooterContentInfoView: NSTextViewDelegate {
-    func textDidChange(_ notification: Notification) {
-        guard let callback = self.itemClick else {
-            return
-        }
-        
-        callback(self.selectedIndex, self.textView.string)
-    }
-}

+ 0 - 64
PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/View/KMHeaderFooterDateInfoView.swift

@@ -1,64 +0,0 @@
-//
-//  KMHeaderFooterDateInfoView.swift
-//  PDF Reader Pro
-//
-//  Created by tangchao on 2022/12/27.
-//
-
-import Cocoa
-
-class KMHeaderFooterDateInfoView: KMHeaderFooterAdjectiveInfoBaseView {
-
-    var comboBox = NSComboBox()
-    
-    override func initSubviews() {
-        super.initSubviews()
-        
-        self.addSubview(self.comboBox)
-        
-        self.titleLabel.stringValue = NSLocalizedString("Date:", comment: "")
-        
-        self.comboBox.addItems(withObjectValues: KMWatermarkAdjectiveTools.getDateFormats())
-        self.comboBox.isEditable = false
-        self.comboBox.delegate = self
-    }
-    
-    override func layout() {
-        super.layout()
-        
-        self.comboBox.frame = NSMakeRect(self.contentInset.left, self.titleLabel.frame.maxY+10, NSWidth(self.bounds)-self.contentInset.left-self.contentInset.right, 22)
-    }
-    
-    override var model: KMHeaderFooterAdjectiveModel {
-        get {
-            return super.model
-        }
-        set {
-            super.model = newValue
-            
-            let myModel: KMHeaderFooterObject = newValue as! KMHeaderFooterObject
-            if (myModel.dateFormatString.isEmpty) {
-                self.comboBox.stringValue = KMWatermarkAdjectiveTools.getDateFormats().first!
-            } else {
-                self.comboBox.stringValue = myModel.dateFormatString
-            }
-        }
-    }
-}
-
-extension KMHeaderFooterDateInfoView: NSComboBoxDelegate {
-    func comboBoxSelectionDidChange(_ notification: Notification) {
-        if (self.comboBox.isEqual(to: notification.object)) {
-            guard let callback = self.itemClick else {
-                return
-            }
-            
-            var index: Int = self.comboBox.indexOfSelectedItem
-            if (index < 0) {
-                index = 0
-            }
-            
-            callback(1, KMWatermarkAdjectiveTools.getDateFormats()[index])
-        }
-    }
-}

+ 0 - 135
PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/View/KMHeaderFooterFontInfoView.swift

@@ -1,135 +0,0 @@
-//
-//  KMHeaderFooterFontInfoView.swift
-//  PDF Reader Pro
-//
-//  Created by tangchao on 2022/12/27.
-//
-
-import Cocoa
-
-class KMHeaderFooterFontInfoView: KMHeaderFooterAdjectiveInfoBaseView {
-
-    let fontSizes: Array<Int> = [8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72]
-    
-    var fontNameComboBox = NSComboBox()
-    var fontSizeComboBox = NSComboBox()
-    var colorBox = NSView()
-    var colorView = NSView()
-    var colorPlateButton = NSButton()
-    
-    override func initSubviews() {
-        super.initSubviews()
-        
-        self.addSubview(self.fontNameComboBox)
-        self.addSubview(self.fontSizeComboBox)
-        self.addSubview(self.colorBox)
-        
-        self.colorBox.addSubview(self.colorView)
-        self.colorBox.addSubview(self.colorPlateButton)
-        
-        self.titleLabel.stringValue = NSLocalizedString("Font", comment: "")
-        
-        let fonts = KMWatermarkAdjectiveTools.fetchAvailableFonts(10)
-        self.fontNameComboBox.addItems(withObjectValues: fonts)
-        self.fontNameComboBox.delegate = self
-        self.fontNameComboBox.isEditable = false
-        
-        for i in self.fontSizes {
-            self.fontSizeComboBox.addItem(withObjectValue: "\(i)")
-        }
-        self.fontSizeComboBox.delegate = self
-        self.fontSizeComboBox.isEditable = false
-        
-        self.colorBox.wantsLayer = true
-        self.colorBox.layer?.borderWidth = 1
-        self.colorBox.layer?.borderColor = NSColor.black.cgColor
-        self.colorView.wantsLayer = true
-        self.colorView.layer?.cornerRadius = 10
-        
-        self.colorPlateButton.isBordered = false
-        self.colorPlateButton.title = ""
-        self.colorPlateButton.target = self
-        self.colorPlateButton.action = #selector(colorPlateButtonAction)
-    }
-
-    override func layout() {
-        super.layout()
-        
-        let leftMargin: CGFloat = self.contentInset.left
-        let contentWidth = NSWidth(self.bounds)-2*leftMargin
-        let fontSizeWidth: CGFloat = 80
-        
-        self.fontNameComboBox.frame = NSMakeRect(leftMargin, self.titleLabel.frame.maxY+12, contentWidth-fontSizeWidth-10, 22)
-        self.fontSizeComboBox.frame = NSMakeRect(self.fontNameComboBox.frame.maxX+10, self.titleLabel.frame.maxY+12, fontSizeWidth, 22)
-        
-        self.colorBox.frame = NSMakeRect(leftMargin, self.fontNameComboBox.frame.maxY+12, 66, 32)
-        let colorItemSize: CGFloat = 20
-        self.colorView.frame = NSMakeRect(8, 6, colorItemSize, colorItemSize)
-        self.colorPlateButton.frame = NSMakeRect(self.colorView.frame.maxX+10, 6, colorItemSize, colorItemSize)
-    }
-    
-    override var model: KMHeaderFooterAdjectiveModel {
-        get {
-            return super.model
-        }
-        set {
-            super.model = newValue
-            
-            switch newValue.textFont {
-            case .font(name: let name, size: let size):
-                let string = KMWatermarkAdjectiveTools.fontNameToAttribute(name, 10)
-                if (string != nil) {
-                    self.fontNameComboBox.selectItem(withObjectValue: string)
-                } else {
-                    self.fontNameComboBox.selectItem(at: 0)
-                }
-                
-                self.fontSizeComboBox.stringValue = String(format: "%.0f", size)
-            default:
-                break
-            }
-            
-            switch newValue.textColor {
-            case .color(red: let red, green: let green, blue: let blue, alpha: let alpha):
-                self.colorView.layer?.backgroundColor = NSColor(calibratedRed: red, green: green, blue: blue, alpha: alpha).cgColor
-            default:
-                break
-            }
-        }
-    }
-    
-    @objc func colorPlateButtonAction() {
-        guard let callback = itemClick else {
-            return
-        }
-        
-        callback(3, "")
-    }
-}
-
-extension KMHeaderFooterFontInfoView: NSComboBoxDelegate {
-    func comboBoxSelectionDidChange(_ notification: Notification) {
-        if (self.fontNameComboBox.isEqual(to: notification.object)) {
-            guard let callback = itemClick else {
-                return
-            }
-            var index: Int = self.fontSizeComboBox.indexOfSelectedItem
-            if (index < 0) {
-                index = 0
-            }
-            
-            
-            callback(1, KMWatermarkAdjectiveTools.fetchAvailableFonts(10)[index].string)
-        } else if (self.fontSizeComboBox.isEqual(to: notification.object)) {
-            guard let callback = itemClick else {
-                return
-            }
-            
-            var index: Int = self.fontSizeComboBox.indexOfSelectedItem
-            if (index < 0) {
-                index = 0
-            }
-            callback(2, self.fontSizes[index])
-        }
-    }
-}

+ 0 - 127
PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/View/KMHeaderFooterMarginInfoView.swift

@@ -1,127 +0,0 @@
-//
-//  KMHeaderFooterMarginInfoView.swift
-//  PDF Reader Pro
-//
-//  Created by tangchao on 2022/12/27.
-//
-
-import Cocoa
-
-class KMHeaderFooterMarginInfoView: KMHeaderFooterAdjectiveInfoBaseView {
-    
-    var topLabel = NSTextField(labelWithString: "")
-    var topStepper = KMWatermarkAdjectiveStepper()
-    var bottomLabel = NSTextField(labelWithString: "")
-    var bottomStepper = KMWatermarkAdjectiveStepper()
-    var leftLabel = NSTextField(labelWithString: "")
-    var leftStepper = KMWatermarkAdjectiveStepper()
-    var rightLabel = NSTextField(labelWithString: "")
-    var rightStepper = KMWatermarkAdjectiveStepper()
-
-    override func initSubviews() {
-        super.initSubviews()
-        
-        self.addSubview(self.topLabel)
-        self.addSubview(self.topStepper)
-        self.addSubview(self.bottomLabel)
-        self.addSubview(self.bottomStepper)
-        self.addSubview(self.leftLabel)
-        self.addSubview(self.leftStepper)
-        self.addSubview(self.rightLabel)
-        self.addSubview(self.rightStepper)
-        
-        self.titleLabel.stringValue = NSLocalizedString("Margin(mm)", comment: "")
-        self.topLabel.stringValue = NSLocalizedString("", comment: "")
-        self.bottomLabel.stringValue = NSLocalizedString("", comment: "")
-        self.leftLabel.stringValue = NSLocalizedString("", comment: "")
-        self.rightLabel.stringValue = NSLocalizedString("", comment: "")
-        
-        for label in [self.topLabel, self.bottomLabel, self.leftLabel, self.rightLabel] {
-            label.alignment = .center
-        }
-        
-        for stepper in [self.topStepper, self.bottomStepper, self.leftStepper, self.rightStepper] {
-            stepper.wantsLayer = true
-            stepper.layer?.borderWidth = 1
-            stepper.layer?.borderColor = NSColor.black.cgColor
-        }
-        
-        self.topStepper.valueDidChange = {
-            (value: Double) in
-            
-            guard let callback = self.itemClick else {
-                return
-            }
-            
-            callback(1, value)
-        }
-        self.bottomStepper.valueDidChange = {
-            (value: Double) in
-            
-            guard let callback = self.itemClick else {
-                return
-            }
-            
-            callback(2, value)
-        }
-        self.leftStepper.valueDidChange = {
-            (value: Double) in
-            
-            guard let callback = self.itemClick else {
-                return
-            }
-            
-            callback(3, value)
-        }
-        self.rightStepper.valueDidChange = {
-            (value: Double) in
-            
-            guard let callback = self.itemClick else {
-                return
-            }
-            
-            callback(4, value)
-        }
-    }
-    
-    override func layout() {
-        super.layout()
-        
-        let width: CGFloat = NSWidth(self.bounds)
-        
-        let leftMargin = self.contentInset.left
-        let topY = self.titleLabel.frame.maxY + 10
-        
-        let stepperSize: NSSize = NSMakeSize(60, 32)
-        let labelSize: NSSize = NSMakeSize(32, 20)
-        
-        self.topLabel.frame = NSMakeRect(leftMargin-8, topY+8, labelSize.width, labelSize.height)
-        self.topStepper.frame = NSMakeRect(self.topLabel.frame.maxX, topY, stepperSize.width, stepperSize.height)
-        
-        let rightLabelX: CGFloat = width-self.contentInset.right-stepperSize.width-10-labelSize.width
-        self.bottomLabel.frame = NSMakeRect(rightLabelX, topY+8, labelSize.width, labelSize.height)
-        self.bottomStepper.frame = NSMakeRect(self.bottomLabel.frame.maxX, topY, stepperSize.width, stepperSize.height)
-        
-        self.leftLabel.frame = NSMakeRect(leftMargin-8, self.topStepper.frame.maxY+18, labelSize.width, labelSize.height)
-        self.leftStepper.frame = NSMakeRect(self.topLabel.frame.maxX, self.topStepper.frame.maxY+18, stepperSize.width, stepperSize.height)
-        
-        self.rightLabel.frame = NSMakeRect(rightLabelX, self.topStepper.frame.maxY+18, labelSize.width, labelSize.height)
-        self.rightStepper.frame = NSMakeRect(self.rightLabel.frame.maxX, self.topStepper.frame.maxY+18, stepperSize.width, stepperSize.height)
-        
-    }
-    
-    override var model: KMHeaderFooterAdjectiveModel {
-        get {
-            return super.model
-        }
-        set {
-            super.model = newValue
-            
-            self.topStepper.value = Double(newValue.topMargin)
-            self.bottomStepper.value = Double(newValue.bottomMargin)
-            self.leftStepper.value = Double(newValue.leftMargin)
-            self.rightStepper.value = Double(newValue.rightMargin)
-        }
-    }
-    
-}

+ 0 - 89
PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/View/KMHeaderFooterPageInfoView.swift

@@ -1,89 +0,0 @@
-//
-//  KMHeaderFooterPageInfoView.swift
-//  PDF Reader Pro
-//
-//  Created by tangchao on 2022/12/28.
-//
-
-import Cocoa
-
-class KMHeaderFooterPageInfoView: KMHeaderFooterAdjectiveInfoBaseView {
-
-    var leftLabel = NSTextField(labelWithString: "")
-    var leftComboBox = NSComboBox()
-    private var rigthLabel = NSTextField(labelWithString: "")
-    var rightComboBox = NSComboBox()
-    
-    override func initSubviews() {
-        super.initSubviews()
-        
-        self.addSubview(self.leftLabel)
-        self.addSubview(self.leftComboBox)
-        self.addSubview(self.rigthLabel)
-        self.addSubview(self.rightComboBox)
-        
-        self.titleLabel.isHidden = true
-        self.rigthLabel.stringValue = NSLocalizedString("Start Page:", comment: "")
-        self.leftComboBox.isEditable = false
-        self.leftComboBox.delegate = self
-        
-        self.rightComboBox.isEditable = false
-        self.rightComboBox.delegate = self
-    }
-    
-    override func layout() {
-        super.layout()
-        
-        let width: CGFloat = NSWidth(self.bounds)
-        let hSpace: CGFloat = 10
-        
-        let leftMargin = self.contentInset.left
-        let labelWidth: CGFloat = (width-leftMargin*2-hSpace)*0.5
-        let labelHeight: CGFloat = 16
-        self.leftLabel.frame = NSMakeRect(leftMargin, 0, labelWidth, labelHeight)
-        self.rigthLabel.frame = NSMakeRect(self.rigthLabel.frame.maxX+hSpace, 0, labelWidth, labelHeight)
-        
-        let comboBoxY: CGFloat = self.leftLabel.frame.maxY+6
-        let comboBoxSize: NSSize = NSMakeSize(labelWidth, 22)
-        self.leftComboBox.frame = NSMakeRect(leftMargin, comboBoxY, comboBoxSize.width, comboBoxSize.height)
-        self.rightComboBox.frame = NSMakeRect(self.leftComboBox.frame.maxX+hSpace, comboBoxY, comboBoxSize.width, comboBoxSize.height)
-    }
-    
-    override var model: KMHeaderFooterAdjectiveModel {
-        get {
-            super.model
-        }
-        set {
-            super.model = newValue
-        }
-    }
-}
-
-extension KMHeaderFooterPageInfoView: NSComboBoxDelegate {
-    func comboBoxSelectionDidChange(_ notification: Notification) {
-        guard let callback = self.itemClick else {
-            return
-        }
-        
-        var sender: NSComboBox?
-        var itemID: Int = 0
-        if (self.leftComboBox.isEqual(to: notification.object)) {
-            sender = self.leftComboBox
-            itemID = 1
-        } else if (self.rightComboBox.isEqual(to: notification.object)) {
-            sender = self.rightComboBox
-            itemID = 2
-        }
-        
-        if (sender == nil) {
-            return
-        }
-        
-        var index: Int = sender!.indexOfSelectedItem
-        if (index < 0) {
-            index = 0
-        }
-        
-        callback(itemID, index)
-    }
-}

+ 5 - 2
PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Views/KMHFTemplateController.swift

@@ -81,6 +81,8 @@ class KMHFTemplateController: NSViewController {
             emptyView.isHidden = true
             collectionView.isHidden = false
             collectionView.reloadData()
+            
+            updateSelectedState()
         }
     }
     
@@ -108,8 +110,9 @@ class KMHFTemplateController: NSViewController {
         } else {
             selectedModel = nil
         }
-        
-        delegate?.templateControllerDidSelectedChanged?(self)
+        DispatchQueue.main.async {
+            self.delegate?.templateControllerDidSelectedChanged?(self)
+        }
     }
     
     //MARK: - action

+ 28 - 37
PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Views/KMHeaderPropertyController.swift

@@ -10,7 +10,7 @@ import KMComponentLibrary
 
 @objc protocol KMHeaderPropertyControllerDelegate: AnyObject {
     
-    //水印数据有更新
+    //数据有更新
     @objc optional func headerFooterPropertyControllerDidUpdate(_ controller: KMHeaderPropertyController)
     
     //切换到模板界面
@@ -22,6 +22,8 @@ import KMComponentLibrary
     //取消修改模板信息
     @objc optional func headerFooterPropertyControllerCancelTemplateEdit(_ controller: KMHeaderPropertyController)
 
+    @objc optional func headerFooterPropertyControllerFinishTemplateEdit(_ controller: KMHeaderPropertyController)
+
 }
 
 class KMHeaderPropertyController: NSViewController {
@@ -72,11 +74,9 @@ class KMHeaderPropertyController: NSViewController {
     
     private var familyNames = CPDFFont.familyNames
     
-    private var positionSelRow: Int = -1
-    private var positionSelColumn: Int = -1
-     
-    private var isEditModeChanged: Bool = false //修改时,记录是否有做过调整
-    
+    private var positionSelRow: Int = 1
+    private var positionSelColumn: Int = 0
+         
     var totalPDFCount: Int = 1
     var originalDataDict: Dictionary<String, Any>?
     var headerFooterModel: KMHeaderFooterObject = KMHeaderFooterObject()
@@ -240,8 +240,8 @@ class KMHeaderPropertyController: NSViewController {
     }
     
     func clearData() {
-        positionSelRow = -1
-        positionSelColumn = -1
+        positionSelRow = 1
+        positionSelColumn = 0
         totalPDFCount = 1
     }
     
@@ -316,12 +316,8 @@ class KMHeaderPropertyController: NSViewController {
             }
             startPageSelect.updateMenuItemsArr(sizeItemArr)
         }
+        startPageSelect.properties.text = headerFooterModel.startString
         
-        if let index = KMHeaderFooterManager.getPageFormats().firstIndex(of: headerFooterModel.startString) {
-            startPageSelect.selectItemAtIndex(index)
-        } else {
-            startPageSelect.properties.text = headerFooterModel.startString
-        }
         startPageSelect.reloadData()
         
         //Layout
@@ -374,7 +370,11 @@ class KMHeaderPropertyController: NSViewController {
     //MARK: - Action
     @objc func leftTopButtonClicked(_ sender: ComponentButton) {
         if sender == leftTopButton {
-            if isEditModeChanged == true {
+            var isChanged = false
+            if let dict = self.originalDataDict {
+                isChanged = KMHeaderFooterManager.compareIsChangedModel(headerFooterModel, withDict: dict as NSDictionary)
+            }
+            if isChanged == true {
                 let alert = NSAlert()
                 alert.alertStyle = .critical
                 alert.messageText = KMLocalizedString("Save template changes?")
@@ -384,22 +384,18 @@ class KMHeaderPropertyController: NSViewController {
                 alert.beginSheetModal(for: NSApp.mainWindow!) { (response) in
                     if response == NSApplication.ModalResponse.alertFirstButtonReturn {
                         let _ = KMHeaderFooterManager.defaultManager.updateHeaderFooter(theModel: self.headerFooterModel)
-
-                        self.isEditModeChanged = false
+                        
+                        self.delegate?.headerFooterPropertyControllerFinishTemplateEdit?(self)
                     } else {
                         if let dict = self.originalDataDict {
                             KMHeaderFooterManager.defaultManager.updateModel(self.headerFooterModel, with: dict as NSDictionary)
                             let _ = KMHeaderFooterManager.defaultManager.updateHeaderFooter(theModel: self.headerFooterModel)
                         }
                         self.delegate?.headerFooterPropertyControllerCancelTemplateEdit?(self)
-                        
-                        self.isEditModeChanged = false
                     }
                 }
             } else {
                 delegate?.headerFooterPropertyControllerCancelTemplateEdit?(self)
-
-                isEditModeChanged = false
             }
         }
     }
@@ -451,6 +447,13 @@ class KMHeaderPropertyController: NSViewController {
         }
     }
     
+    //MARK: - Mouse
+    override func mouseDown(with event: NSEvent) {
+        super.mouseDown(with: event)
+        
+        view.window?.makeFirstResponder(nil)
+    }
+    
 }
 
 //MARK: - ComponentCColorDelegate
@@ -462,9 +465,7 @@ extension KMHeaderPropertyController: ComponentCColorDelegate {
         reloadData()
         
         delegate?.headerFooterPropertyControllerDidUpdate?(self)
-        
-        isEditModeChanged = true
-        
+         
     }
 }
 
@@ -490,8 +491,6 @@ extension KMHeaderPropertyController: ComponentInputNumberDelegate {
         }
         reloadData()
         
-        isEditModeChanged = true
-        
         delegate?.headerFooterPropertyControllerDidUpdate?(self)
     }
 }
@@ -522,9 +521,7 @@ extension KMHeaderPropertyController: ComponentSelectDelegate {
         }
         
         reloadData()
-        
-        isEditModeChanged = true
-        
+         
         delegate?.headerFooterPropertyControllerDidUpdate?(self)
         
     }
@@ -572,9 +569,7 @@ extension KMHeaderPropertyController: ComponentGroupDelegate {
             }
         }
         reloadData()
-        
-        isEditModeChanged = true
-        
+         
         updateTextAreaText()
         
         delegate?.headerFooterPropertyControllerDidUpdate?(self)
@@ -592,9 +587,7 @@ extension KMHeaderPropertyController: ComponentCPositionDelegate {
             positionSelColumn = column
             
             reloadData()
-            
-            isEditModeChanged = true
-            
+             
             delegate?.headerFooterPropertyControllerDidUpdate?(self)
             
         }
@@ -620,9 +613,7 @@ extension KMHeaderPropertyController: ComponentTextareaDelegate {
         }
         
         reloadData()
-        
-        isEditModeChanged = true
-        
+         
         delegate?.headerFooterPropertyControllerDidUpdate?(self)
         
     }

+ 8 - 8
PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Views/KMHeaderPropertyController.xib

@@ -53,7 +53,7 @@
                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="oDv-te-osP">
                             <rect key="frame" x="0.0" y="791" width="320" height="40"/>
                             <subviews>
-                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="XcY-yp-Dg5">
+                                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="XcY-yp-Dg5">
                                     <rect key="frame" x="94" y="12" width="132" height="16"/>
                                     <textFieldCell key="cell" lineBreakMode="clipping" title="Add Header &amp; Footer" id="5aw-vJ-O3w">
                                         <font key="font" usesAppearanceFont="YES"/>
@@ -104,7 +104,7 @@
                                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="COI-6x-UXb">
                                             <rect key="frame" x="0.0" y="72" width="232" height="40"/>
                                             <subviews>
-                                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="bpS-cS-091">
+                                                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="bpS-cS-091">
                                                     <rect key="frame" x="-2" y="12" width="32" height="16"/>
                                                     <textFieldCell key="cell" lineBreakMode="clipping" title="Font" id="rZY-dw-5M0">
                                                         <font key="font" usesAppearanceFont="YES"/>
@@ -161,7 +161,7 @@
                                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="WET-Do-OrY">
                                             <rect key="frame" x="0.0" y="72" width="232" height="40"/>
                                             <subviews>
-                                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="fMm-Yh-O6N">
+                                                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="fMm-Yh-O6N">
                                                     <rect key="frame" x="-2" y="12" width="82" height="16"/>
                                                     <textFieldCell key="cell" lineBreakMode="clipping" title="Margin (mm)" id="UcQ-3y-2HK">
                                                         <font key="font" usesAppearanceFont="YES"/>
@@ -278,7 +278,7 @@
                                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="lDc-1g-lQL">
                                             <rect key="frame" x="0.0" y="112" width="232" height="40"/>
                                             <subviews>
-                                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Gmb-UW-4Dx">
+                                                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Gmb-UW-4Dx">
                                                     <rect key="frame" x="-2" y="12" width="49" height="16"/>
                                                     <textFieldCell key="cell" lineBreakMode="clipping" title="Display" id="mR2-q4-DPD">
                                                         <font key="font" usesAppearanceFont="YES"/>
@@ -293,7 +293,7 @@
                                                 <constraint firstItem="Gmb-UW-4Dx" firstAttribute="centerY" secondItem="lDc-1g-lQL" secondAttribute="centerY" id="JLb-nz-FbX"/>
                                             </constraints>
                                         </customView>
-                                        <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="TNS-KG-jRl">
+                                        <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="TNS-KG-jRl">
                                             <rect key="frame" x="-2" y="88" width="37" height="16"/>
                                             <textFieldCell key="cell" lineBreakMode="clipping" title="Date:" id="yng-gX-MHn">
                                                 <font key="font" usesAppearanceFont="YES"/>
@@ -307,7 +307,7 @@
                                                 <constraint firstAttribute="height" constant="32" id="xiM-uk-RKG"/>
                                             </constraints>
                                         </customView>
-                                        <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="VCq-Ro-Dfg">
+                                        <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="VCq-Ro-Dfg">
                                             <rect key="frame" x="-2" y="48" width="42" height="16"/>
                                             <textFieldCell key="cell" lineBreakMode="clipping" title="Page: " id="hkj-dn-rz8">
                                                 <font key="font" usesAppearanceFont="YES"/>
@@ -321,7 +321,7 @@
                                                 <constraint firstAttribute="height" constant="32" id="8WU-xb-NwW"/>
                                             </constraints>
                                         </customView>
-                                        <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="iYo-cq-cCE">
+                                        <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="iYo-cq-cCE">
                                             <rect key="frame" x="-2" y="8" width="75" height="16"/>
                                             <textFieldCell key="cell" lineBreakMode="clipping" title="Start Page: " id="v5L-Rc-Xgp">
                                                 <font key="font" usesAppearanceFont="YES"/>
@@ -365,7 +365,7 @@
                                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="6Ox-DM-ufe">
                                             <rect key="frame" x="0.0" y="120" width="232" height="40"/>
                                             <subviews>
-                                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Xg1-2G-aDD">
+                                                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Xg1-2G-aDD">
                                                     <rect key="frame" x="-2" y="12" width="110" height="16"/>
                                                     <textFieldCell key="cell" lineBreakMode="clipping" title="Layout &amp; Content" id="Led-Ha-rjq">
                                                         <font key="font" usesAppearanceFont="YES"/>

File diff suppressed because it is too large
+ 355 - 149
PDF Office/PDF Master/KMClass/KMPDFViewController/KMMainViewController.swift


+ 12 - 0
PDF Office/PDF Master/KMClass/KMPDFViewController/PDFImages.xcassets/PDF_Edit/edit_Reset.imageset/Contents.json

@@ -0,0 +1,12 @@
+{
+  "images" : [
+    {
+      "filename" : "edit_Reset.pdf",
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
PDF Office/PDF Master/KMClass/KMPDFViewController/PDFImages.xcassets/PDF_Edit/edit_Reset.imageset/edit_Reset.pdf


+ 1 - 0
PDF Office/PDF Master/KMClass/KMPDFViewController/RightSideController/KMRightSideController.swift

@@ -15,6 +15,7 @@ class KMRightSideController: NSViewController {
     
     @IBOutlet var headerBGView: NSView!
     @IBOutlet var titleLabel: NSTextField!
+    @IBOutlet var headerRightButton: ComponentButton!
     
     @IBOutlet var infoContendView: NSView!
     

+ 10 - 0
PDF Office/PDF Master/KMClass/KMPDFViewController/RightSideController/KMRightSideController.xib

@@ -12,6 +12,7 @@
                 <outlet property="contendView" destination="Sx1-Eg-QqT" id="6gg-wx-Pn7"/>
                 <outlet property="emptyView" destination="caV-0D-KSQ" id="y5j-1P-GHx"/>
                 <outlet property="headerBGView" destination="TcN-JR-Ldb" id="0Ok-kE-c9g"/>
+                <outlet property="headerRightButton" destination="Rab-FM-SLM" id="y9O-Jc-gdm"/>
                 <outlet property="infoContendView" destination="5et-6F-yVg" id="ibb-Ic-3DS"/>
                 <outlet property="titleLabel" destination="Rtf-SN-4Bo" id="ddV-ja-Zc8"/>
                 <outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
@@ -49,13 +50,22 @@
                                         <constraint firstAttribute="height" constant="1" id="Wcr-yw-mvt"/>
                                     </constraints>
                                 </customView>
+                                <customView translatesAutoresizingMaskIntoConstraints="NO" id="Rab-FM-SLM" customClass="ComponentButton" customModule="KMComponentLibrary">
+                                    <rect key="frame" x="232" y="8" width="24" height="24"/>
+                                    <constraints>
+                                        <constraint firstAttribute="width" constant="24" id="iLC-7V-qmC"/>
+                                        <constraint firstAttribute="height" constant="24" id="wD0-ls-QYy"/>
+                                    </constraints>
+                                </customView>
                             </subviews>
                             <constraints>
                                 <constraint firstItem="Rtf-SN-4Bo" firstAttribute="centerX" secondItem="TcN-JR-Ldb" secondAttribute="centerX" id="GZV-pG-XPa"/>
                                 <constraint firstItem="S7y-0d-xw5" firstAttribute="leading" secondItem="TcN-JR-Ldb" secondAttribute="leading" id="Kzb-5g-wtX"/>
                                 <constraint firstAttribute="height" constant="40" id="NoW-2A-4bC"/>
                                 <constraint firstAttribute="trailing" secondItem="S7y-0d-xw5" secondAttribute="trailing" id="bOI-W8-3Am"/>
+                                <constraint firstItem="Rab-FM-SLM" firstAttribute="centerY" secondItem="TcN-JR-Ldb" secondAttribute="centerY" id="lJE-fh-IgR"/>
                                 <constraint firstItem="Rtf-SN-4Bo" firstAttribute="centerY" secondItem="TcN-JR-Ldb" secondAttribute="centerY" id="nRW-oz-YOE"/>
+                                <constraint firstAttribute="trailing" secondItem="Rab-FM-SLM" secondAttribute="trailing" constant="8" id="vI7-lv-UKG"/>
                                 <constraint firstAttribute="bottom" secondItem="S7y-0d-xw5" secondAttribute="bottom" id="xKr-rQ-GAj"/>
                             </constraints>
                         </customView>

+ 0 - 1
PDF Office/PDF Master/KMClass/KMPDFViewController/Toolbar/KMPDFSecToolbarController.swift

@@ -469,7 +469,6 @@ class KMPDFSecToolbarController: NSViewController {
 //MARK: - ComponentDropdownToolDelegate
 extension KMPDFSecToolbarController: ComponentDropdownToolDelegate {
     func componentDropdownToolDidShowPopupView(_ view: ComponentDropdownTool) {
-        viewManager?.subToolMode = .None
         
         refreshToolbarModeInfo()
     }

+ 2 - 3
PDF Office/PDF Master/KMClass/KMPDFViewController/Toolbar/Model/KMPDFToolbarManager.swift

@@ -300,9 +300,8 @@ class KMPDFToolbarManager: NSObject {
                                                ComponentMenuitemProperty.divider(),
                                                edit_bates_batchAdd_Property, edit_bates_batchRemove_Property]
             
-            return [edit_text_Property, edit_image_Property, edit_link_Property, dividerProperty,
-                     edit_crop_Property, edit_watermark_Property, edit_background_Property, edit_headerfooter_Property,
-                     edit_bates_Property]
+            return [edit_text_Property, edit_image_Property, edit_link_Property, dividerProperty, edit_watermark_Property, edit_background_Property, edit_headerfooter_Property,
+                     edit_bates_Property, edit_crop_Property]
             
         } else if modeType == .Form {
             return [form_text_Property, form_checkbox_Property, form_radio_Property, form_list_Property,

+ 2 - 2
PDF Office/PDF Master/KMClass/Tools/Category/Foundation/NSColor+KMExtensions.swift

@@ -47,9 +47,9 @@ public extension NSColor {
             a = Float(components[3])
         }
         if alpha {
-            return String(format: "%02lX%02lX%02lX%02lX", lroundf(r * 255), lroundf(g * 255), lroundf(b * 255), lroundf(a * 255))
+            return String(format: "#%02lX%02lX%02lX%02lX", lroundf(r * 255), lroundf(g * 255), lroundf(b * 255), lroundf(a * 255))
         } else {
-            return String(format: "%02lX%02lX%02lX", lroundf(r * 255), lroundf(g * 255), lroundf(b * 255))
+            return String(format: "#%02lX%02lX%02lX", lroundf(r * 255), lroundf(g * 255), lroundf(b * 255))
         }
     }
     

+ 4 - 22
PDF Office/PDF Master/KMClass/Tools/CustomAlertView/KMNCustomAlertView.swift

@@ -15,35 +15,17 @@ class KMNCustomAlertView: NSView {
         super.draw(dirtyRect)
     }
     
-    static func alertView(message: String, type: ComponentMessageType, fromView supverView: NSView, point:NSPoint) -> ComponentMessage? {
+    static func alertView(message: String, type: ComponentMessageType, fromView supverView: NSView, point: NSPoint) -> ComponentMessage? {
         let properties: ComponentMessageProperty = ComponentMessageProperty(messageType: type, title: message)
         
         let componentMessage = ComponentMessage()
         componentMessage.properties = properties
-        
-        let style = NSMutableParagraphStyle()
-        style.lineBreakMode = .byWordWrapping
-        style.alignment = .center
-        
-        let font  = componentMessage.properties.propertyInfo.textFont
-        
-        var offsetSize = CGSize.zero
-        
-        let attributes: [NSAttributedString.Key: Any] = [
-            .font: font,
-            .paragraphStyle: style
-        ]
-        
-        let maxSize = CGSize(width: min(supverView.frame.size.width - 80, 500), height: supverView.frame.size.height - 40)
-        let size = message.boundingRect(with: maxSize, options: [.usesLineFragmentOrigin], attributes: attributes).size
-        
-        let ceilSize = NSSize(width: ceil(size.width), height: ceil(size.height))
-        
-        offsetSize = NSSize(width: ceilSize.width + 60, height: ceilSize.height + 30)
+ 
+        let offsetSize = NSSize(width: componentMessage.properties.propertyInfo.viewWidth, height: componentMessage.properties.propertyInfo.viewHeight)
         componentMessage.frame = NSRect(x: (point.x - offsetSize.width/2),
                                         y: (point.y - offsetSize.height/2),
                                         width: offsetSize.width, height: offsetSize.height)
-        
+        componentMessage.reloadData()
         
         supverView.addSubview(componentMessage)
         

+ 1 - 1
PDF Office/PDF Master/KMClass/Tools/KMNFileAttribute/KMNFileAttribute.swift

@@ -18,12 +18,12 @@ import Cocoa
     var filePath: String = ""
     var pdfDocument: CPDFDocument?
     var bAllPage = false
-    private var selectPages: [Int] = []
     var pagesString: String = ""
     var isLocked = false
     var password: String?
     
     var pagesType: KMNFileAttributePageType = .AllPages
+    private var selectPages: [Int] = []
     
     func fetchSelectPages() -> [Int] {
         if let doc = self.pdfDocument, doc.isLocked {

File diff suppressed because it is too large
+ 14 - 302
PDF Office/PDF Reader Pro.xcodeproj/project.pbxproj


File diff suppressed because it is too large
+ 751 - 350
PDF Office/PDF Reader Pro.xcodeproj/xcuserdata/kdanmobile.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist