Browse Source

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

jiajie 1 year ago
parent
commit
d3546931ad
32 changed files with 829 additions and 258 deletions
  1. 8 0
      PDF Office/PDF Master.xcodeproj/project.pbxproj
  2. 2 34
      PDF Office/PDF Master.xcodeproj/xcuserdata/kdanmobile.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
  3. 22 0
      PDF Office/PDF Master/Class/Appearance/Image.xcassets/LeftSide/KMImageNameInkIcon.imageset/Contents.json
  4. BIN
      PDF Office/PDF Master/Class/Appearance/Image.xcassets/LeftSide/KMImageNameInkIcon.imageset/ic_sidebar_annotation_pen.pdf
  5. 83 0
      PDF Office/PDF Master/Class/Appearance/Image.xcassets/LeftSide/KMImageNameInkIcon.imageset/light_ic_sidebar_annotation_pen.pdf
  6. 22 0
      PDF Office/PDF Master/Class/Appearance/Image.xcassets/LeftSide/KMImageNameStikeoutIcon.imageset/Contents.json
  7. BIN
      PDF Office/PDF Master/Class/Appearance/Image.xcassets/LeftSide/KMImageNameStikeoutIcon.imageset/ic_sidebar_annotation_hightlight.pdf
  8. 79 0
      PDF Office/PDF Master/Class/Appearance/Image.xcassets/LeftSide/KMImageNameStikeoutIcon.imageset/light_ic_sidebar_annotation_stikeout.pdf
  9. 8 0
      PDF Office/PDF Master/Class/Common/Category/NSObject+KMExtension.swift
  10. 7 3
      PDF Office/PDF Master/Class/Home/View/HomeContentView/QucikTools/KMQucikToolsView.swift
  11. 1 0
      PDF Office/PDF Master/Class/Home/View/HomeContentView/QucikTools/Model/KMQucikToolsModel.swift
  12. 4 0
      PDF Office/PDF Master/Class/Home/View/HomeContentView/QucikTools/View/KMQucikToolCollectionViewItem.swift
  13. 2 2
      PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController.xib
  14. 29 9
      PDF Office/PDF Master/Class/Home/WindowController/HomeQuickToolsWindowController/View/KMHomeQuickToolsWindowCollectionViewItem.swift
  15. 5 1
      PDF Office/PDF Master/Class/KMAdvertisement/View/View/KMAdvertisementShowView.swift
  16. 11 1
      PDF Office/PDF Master/Class/PDFTools/AddHeaderFooter/New/KMHeaderFooterWindowController.swift
  17. 1 5
      PDF Office/PDF Master/Class/PDFTools/AddHeaderFooter/New/View/KMHeaderFooterView.swift
  18. 1 0
      PDF Office/PDF Master/Class/PDFTools/Background/Model/KMBackgroundModel.swift
  19. 9 2
      PDF Office/PDF Master/Class/PDFTools/Background/New/KMBackgroundWindowController.swift
  20. 11 14
      PDF Office/PDF Master/Class/PDFTools/Background/New/View/KMAddBackgroundView.swift
  21. 11 3
      PDF Office/PDF Master/Class/PDFTools/Merge/MergeNew/View/KMMergeView.swift
  22. 4 4
      PDF Office/PDF Master/Class/PDFTools/Merge/MergeNew/View/KMMergeView.xib
  23. 1 0
      PDF Office/PDF Master/Class/PDFTools/Merge/Model/KMFileAttribute.swift
  24. 12 0
      PDF Office/PDF Master/Class/PDFTools/Watermark/New/KMWatermarkWindowController.swift
  25. 9 12
      PDF Office/PDF Master/Class/PDFTools/Watermark/New/View/KMWatermarkView.swift
  26. 1 1
      PDF Office/PDF Master/Class/PDFTools/Watermark/New/View/KMWatermarkView.xib
  27. 41 19
      PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/Annotation/View/KMNoteTypeImageView.swift
  28. 34 0
      PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMBotaTableRowView.swift
  29. 395 135
      PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController.swift
  30. 8 8
      PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/LeftSideView.xib
  31. 3 0
      PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/Thumbnail/Base/KMPDFThumbViewBaseController.swift
  32. 5 5
      PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

+ 8 - 0
PDF Office/PDF Master.xcodeproj/project.pbxproj

@@ -3278,6 +3278,9 @@
 		BBA00AC42B157C880043D903 /* KMToolbarZoomItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBA00AC32B157C880043D903 /* KMToolbarZoomItemView.swift */; };
 		BBA00AC52B157C880043D903 /* KMToolbarZoomItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBA00AC32B157C880043D903 /* KMToolbarZoomItemView.swift */; };
 		BBA00AC62B157C880043D903 /* KMToolbarZoomItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBA00AC32B157C880043D903 /* KMToolbarZoomItemView.swift */; };
+		BBA00AC92B1604D30043D903 /* KMBotaTableRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBA00AC82B1604D30043D903 /* KMBotaTableRowView.swift */; };
+		BBA00ACA2B1604D30043D903 /* KMBotaTableRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBA00AC82B1604D30043D903 /* KMBotaTableRowView.swift */; };
+		BBA00ACB2B1604D30043D903 /* KMBotaTableRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBA00AC82B1604D30043D903 /* KMBotaTableRowView.swift */; };
 		BBA19F3229ADAC81001A285A /* signPicture_hover.pdf in Resources */ = {isa = PBXBuildFile; fileRef = BBA19F3129ADAC81001A285A /* signPicture_hover.pdf */; };
 		BBA19F3329ADAC81001A285A /* signPicture_hover.pdf in Resources */ = {isa = PBXBuildFile; fileRef = BBA19F3129ADAC81001A285A /* signPicture_hover.pdf */; };
 		BBA19F3429ADAC81001A285A /* signPicture_hover.pdf in Resources */ = {isa = PBXBuildFile; fileRef = BBA19F3129ADAC81001A285A /* signPicture_hover.pdf */; };
@@ -5336,6 +5339,7 @@
 		BB9DCC9E2A0A2B0A0024A6F1 /* KMConvertSettingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMConvertSettingView.swift; sourceTree = "<group>"; };
 		BB9E2F722A495BCD000DC68D /* KMConvertSettingLimitTipView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMConvertSettingLimitTipView.swift; sourceTree = "<group>"; };
 		BBA00AC32B157C880043D903 /* KMToolbarZoomItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMToolbarZoomItemView.swift; sourceTree = "<group>"; };
+		BBA00AC82B1604D30043D903 /* KMBotaTableRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMBotaTableRowView.swift; sourceTree = "<group>"; };
 		BBA19F3129ADAC81001A285A /* signPicture_hover.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = signPicture_hover.pdf; sourceTree = "<group>"; };
 		BBA19F3529ADACC5001A285A /* signPicture_nor.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = signPicture_nor.pdf; sourceTree = "<group>"; };
 		BBA19F3D29ADE40A001A285A /* KMCellEmptyView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KMCellEmptyView.h; sourceTree = "<group>"; };
@@ -5945,6 +5949,7 @@
 				BB3A668B2B06FD0100575343 /* KMBotaEnum.swift */,
 				BB4F7E6F2B0C3DC40077EC8C /* KMButtonLayer.swift */,
 				BBD512A02B0DE86C005BFE8A /* KMBotaLeftView.swift */,
+				BBA00AC82B1604D30043D903 /* KMBotaTableRowView.swift */,
 				BB4F7E732B0C42160077EC8C /* KMPopupMenuObject.swift */,
 				BBC28F452B0F352000D73206 /* KMImageToolTipContext.swift */,
 				BBC28F492B0F509B00D73206 /* KMAnimatedBorderlessWindow.swift */,
@@ -12474,6 +12479,7 @@
 				BB1BFF8A2AEA4725003EB179 /* KMTableHeaderCell.swift in Sources */,
 				BB003015298CA446002DD1A0 /* KMPreferenceGeneralController.swift in Sources */,
 				ADAFD9F32AE68A7400F084BC /* KMCreatPDFView.swift in Sources */,
+				BBA00AC92B1604D30043D903 /* KMBotaTableRowView.swift in Sources */,
 				ADE86AC82B034CB200414DFA /* KMAddBackgroundView.swift in Sources */,
 				BBB9B32E299A5D6D004F3235 /* GTMAppAuthFetcherAuthorization.m in Sources */,
 				BB3198162AC55E6D00107371 /* CPDFDocument+KMExtension.swift in Sources */,
@@ -13028,6 +13034,7 @@
 				BB74DA7C2AC41DE9006EDFE7 /* NSString+KMExtension.swift in Sources */,
 				ADDEEA972AD7A0F300EF675D /* TextFieldFormatter.swift in Sources */,
 				BB3198172AC55E6D00107371 /* CPDFDocument+KMExtension.swift in Sources */,
+				BBA00ACA2B1604D30043D903 /* KMBotaTableRowView.swift in Sources */,
 				BBEC00C8295C319400A26C98 /* KMBatesManager.swift in Sources */,
 				ADA9102B2A272CE2003352F0 /* KMEditPDFTextManager.swift in Sources */,
 				ADAFDA042AE8BD5C00F084BC /* KMConvertURLToPDF.m in Sources */,
@@ -14155,6 +14162,7 @@
 				BBC3483D2955A60B008D2CD1 /* KMBackgroundPropertyInfoController.swift in Sources */,
 				89D2D30A295A83B500BFF5FE /* KMEditPDFTextPropertyViewController.swift in Sources */,
 				BB03D69A2B0221FF008C9976 /* NSImage+KMExtension.swift in Sources */,
+				BBA00ACB2B1604D30043D903 /* KMBotaTableRowView.swift in Sources */,
 				ADBC2CFC299CA6B9006280C8 /* KMPrintDuplexPrintingSetView.swift in Sources */,
 				BBC4F9EC2AEB58290098A1A8 /* KMAlertWindowController.swift in Sources */,
 				BB897248294C19980045787C /* KMWatermarkAdjectiveListController.swift in Sources */,

+ 2 - 34
PDF Office/PDF Master.xcodeproj/xcuserdata/kdanmobile.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -260,38 +260,6 @@
             </Locations>
          </BreakpointContent>
       </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "7A815601-D92D-4133-9AD5-135810C22224"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "PDF Master/Class/PDFWindowController/PDFListView/CPDFListView.m"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "125"
-            endingLineNumber = "125"
-            landmarkName = "-goToDestination:"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "E3D2735D-BC29-49D0-8560-DAA6C7C1EBB1"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "PDF Master/Class/PDFWindowController/PDFListView/CPDFListView.m"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "129"
-            endingLineNumber = "129"
-            landmarkName = "-goToRect:onPage:animated:"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
@@ -462,8 +430,8 @@
             filePath = "PDF Master/Class/PDFWindowController/Side/LeftSide/Thumbnail/Base/KMPDFThumbViewBaseController.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "1113"
-            endingLineNumber = "1113"
+            startingLineNumber = "1116"
+            endingLineNumber = "1116"
             landmarkName = "menuItemAction_share(_:)"
             landmarkType = "7">
          </BreakpointContent>

+ 22 - 0
PDF Office/PDF Master/Class/Appearance/Image.xcassets/LeftSide/KMImageNameInkIcon.imageset/Contents.json

@@ -0,0 +1,22 @@
+{
+  "images" : [
+    {
+      "filename" : "light_ic_sidebar_annotation_pen.pdf",
+      "idiom" : "universal"
+    },
+    {
+      "appearances" : [
+        {
+          "appearance" : "luminosity",
+          "value" : "dark"
+        }
+      ],
+      "filename" : "ic_sidebar_annotation_pen.pdf",
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
PDF Office/PDF Master/Class/Appearance/Image.xcassets/LeftSide/KMImageNameInkIcon.imageset/ic_sidebar_annotation_pen.pdf


+ 83 - 0
PDF Office/PDF Master/Class/Appearance/Image.xcassets/LeftSide/KMImageNameInkIcon.imageset/light_ic_sidebar_annotation_pen.pdf

@@ -0,0 +1,83 @@
+%PDF-1.3
+%ÿÿÿÿ
+7 0 obj
+<<
+/Type /ExtGState
+/ca 1
+>>
+endobj
+6 0 obj
+<<
+/Type /Page
+/Parent 1 0 R
+/MediaBox [0 0 16 16]
+/Contents 4 0 R
+/Resources 5 0 R
+>>
+endobj
+5 0 obj
+<<
+/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
+/ExtGState <<
+/Gs1 7 0 R
+>>
+>>
+endobj
+8 0 obj
+<<
+/Producer (PDFKit)
+/Creator (PDFKit)
+/CreationDate (D:20201219095601Z)
+>>
+endobj
+3 0 obj
+<<
+>>
+endobj
+2 0 obj
+<<
+/Type /Catalog
+/Pages 1 0 R
+>>
+endobj
+1 0 obj
+<<
+/Type /Pages
+/Count 1
+/Kids [6 0 R]
+>>
+endobj
+4 0 obj
+<<
+/Length 247
+/Filter /FlateDecode
+>>
+stream
+xœu�ÛjÃ0†ïý¾ÄÕѲoÇ ×ÝÍ tÈ
+%°çŸÜ”tn:,å‹ôÿŽ0‚Ç€~`Žãw8¼ åtp÷z­pœ=M-ù3XÒgx‹§íÈ¿``ÎîN„=gÖ¸¥�
+zÐz“d`×bØ¢œª�’£TLÕ¤
ï^Ž?_ãñuÿÇÙ…P©
+¢e1ÐRH]€ø:ã"Œl¤RkÆ8�§°ÛÏ?æP×lnåNÙG‹ï©1/ÑQÉ×´Ü	8¢$†Ü~t
+’¤XUë:/°“œشůF¾!¥«ûµD–Ö?’=kÞ·áé‘b3z
+‡.~CÍsƒ
+endstream
+endobj
+xref
+0 9
+0000000000 65535 f 
+0000000418 00000 n 
+0000000369 00000 n 
+0000000348 00000 n 
+0000000475 00000 n 
+0000000161 00000 n 
+0000000059 00000 n 
+0000000015 00000 n 
+0000000256 00000 n 
+trailer
+<<
+/Size 9
+/Root 2 0 R
+/Info 8 0 R
+>>
+startxref
+794
+%%EOF

+ 22 - 0
PDF Office/PDF Master/Class/Appearance/Image.xcassets/LeftSide/KMImageNameStikeoutIcon.imageset/Contents.json

@@ -0,0 +1,22 @@
+{
+  "images" : [
+    {
+      "filename" : "light_ic_sidebar_annotation_stikeout.pdf",
+      "idiom" : "universal"
+    },
+    {
+      "appearances" : [
+        {
+          "appearance" : "luminosity",
+          "value" : "dark"
+        }
+      ],
+      "filename" : "ic_sidebar_annotation_hightlight.pdf",
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
PDF Office/PDF Master/Class/Appearance/Image.xcassets/LeftSide/KMImageNameStikeoutIcon.imageset/ic_sidebar_annotation_hightlight.pdf


+ 79 - 0
PDF Office/PDF Master/Class/Appearance/Image.xcassets/LeftSide/KMImageNameStikeoutIcon.imageset/light_ic_sidebar_annotation_stikeout.pdf

@@ -0,0 +1,79 @@
+%PDF-1.3
+%ÿÿÿÿ
+7 0 obj
+<<
+/Type /ExtGState
+/ca 1
+>>
+endobj
+6 0 obj
+<<
+/Type /Page
+/Parent 1 0 R
+/MediaBox [0 0 16 16]
+/Contents 4 0 R
+/Resources 5 0 R
+>>
+endobj
+5 0 obj
+<<
+/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
+/ExtGState <<
+/Gs1 7 0 R
+>>
+>>
+endobj
+8 0 obj
+<<
+/Producer (PDFKit)
+/Creator (PDFKit)
+/CreationDate (D:20201219095125Z)
+>>
+endobj
+3 0 obj
+<<
+>>
+endobj
+2 0 obj
+<<
+/Type /Catalog
+/Pages 1 0 R
+>>
+endobj
+1 0 obj
+<<
+/Type /Pages
+/Count 1
+/Kids [6 0 R]
+>>
+endobj
+4 0 obj
+<<
+/Length 264
+/Filter /FlateDecode
+>>
+stream
+xœu’ËjÃ0E÷ú
+­™hzmK!ëvÓ0éÜ@0ôû{U·X¶d4¾ÝÑõ`öëÀØ8ùáË]ÿ¢yØÈ«k/À	elÏèÂ\>Ü«¿ì-wÁAƒáv^ó†A÷vÚ‡$»yÉñéüý9œ_N�~˜\ ŽR�9'Ë!–"NÑ
ÓbÊš%Z
\ûi¸¸ãibÿ>¹B©&�Å3ea‹¹MB¨TE\Ö†0›¥IIR;(fˆz�öV&Éyݹ³øŠ(u&ar@V¦Hhˆþ«æìrÈVu%iÕ7“M&Ë@ÆCj?FñF(–ˆ·,q+|PþÏ6ßÛƒ{Þ¬RáˆÈ
+endstream
+endobj
+xref
+0 9
+0000000000 65535 f 
+0000000418 00000 n 
+0000000369 00000 n 
+0000000348 00000 n 
+0000000475 00000 n 
+0000000161 00000 n 
+0000000059 00000 n 
+0000000015 00000 n 
+0000000256 00000 n 
+trailer
+<<
+/Size 9
+/Root 2 0 R
+/Info 8 0 R
+>>
+startxref
+811
+%%EOF

+ 8 - 0
PDF Office/PDF Master/Class/Common/Category/NSObject+KMExtension.swift

@@ -341,6 +341,10 @@ func KMContextRestoreGState(_ ctx: CGContext?) {
     ctx?.restoreGState()
 }
 
+func KMContextBeginPath(_ ctx: CGContext?) {
+    ctx?.beginPath()
+}
+
 func KMContextScaleCTM(_ ctx: CGContext?, _ sx: CGFloat, _ sy: CGFloat) {
     ctx?.scaleBy(x: sx, y: sy)
 }
@@ -442,6 +446,10 @@ func KMContextSetStrokeColorWithColor(_ ctx: CGContext?, _ color: CGColor?) {
     }
 }
 
+func KMContextAddCurveToPoint(_ ctx: CGContext?, _ cp1x: CGFloat, _ cp1y: CGFloat, _ cp2x: CGFloat, _ cp2y: CGFloat, _ x: CGFloat, _ y: CGFloat) {
+    ctx?.addCurve(to: NSPoint(x: x, y: y), control1: NSPoint(x: cp1x, y: cp1y), control2: NSPoint(x: cp2x, y: cp2y))
+}
+
 // MARK: - CGPath
 
 func KMPathMoveToPoint(_ path: CGMutablePath?, _ m: CGAffineTransform?, _ x: CGFloat, _ y: CGFloat) {

+ 7 - 3
PDF Office/PDF Master/Class/Home/View/HomeContentView/QucikTools/KMQucikToolsView.swift

@@ -59,7 +59,11 @@ class KMQucikToolsView: KMBaseXibView {
         self.data.removeAll()
         
         for type in KMQucikToolsModel.showType() {
-            self.data.append(KMQucikToolsModel.init(type: type))
+            let model = KMQucikToolsModel.init(type: type)
+            if model.type == .FileCompare {
+                model.isNew = true
+            }
+            self.data.append(model)
         }
         self.collectionView.reloadData()
     }
@@ -137,9 +141,9 @@ extension KMQucikToolsView: NSCollectionViewDelegateFlowLayout {
         if type == .collapse {
             return NSSize(width: 172, height: 48)
         } else if type == .expand {
-            return NSSize(width: 216, height: 96)
+            return NSSize(width: 260, height: 96)
         } else {
-            return NSSize(width: 216, height: 96)
+            return NSSize(width: 260, height: 96)
         }
     }
     

+ 1 - 0
PDF Office/PDF Master/Class/Home/View/HomeContentView/QucikTools/Model/KMQucikToolsModel.swift

@@ -13,6 +13,7 @@ class KMQucikToolsModel: NSObject {
     }
     
     var type: DataNavigationViewButtonActionType?
+    var isNew: Bool = false
     
     static func allType() -> [DataNavigationViewButtonActionType] {
         let array: [DataNavigationViewButtonActionType] = [.Batch, .ConvertPDF, .PDFToWord, .PDFToExcel, .FileCompare, .PDFToPPT, .ImageToPDF, .OCR, .PageEdit, .MergePDF, .BreakUp, .Insert, .Compression, .Security, .Watermark, .Background, .HeaderAndFooter, .BatesCode, .PrintPoster, .PrintMultipage, .PrintBooklet]

+ 4 - 0
PDF Office/PDF Master/Class/Home/View/HomeContentView/QucikTools/View/KMQucikToolCollectionViewItem.swift

@@ -53,6 +53,8 @@ class KMQucikToolCollectionViewItem: NSCollectionViewItem {
     }
     
     func setup() {
+        self.view.wantsLayer = true
+        self.view.layer?.masksToBounds = true
         self.tagView.isHidden = true
         
         self.handleView.backgroundColor(KMAppearance.Interactive.a0Color())
@@ -128,6 +130,8 @@ class KMQucikToolCollectionViewItem: NSCollectionViewItem {
             handerViewTopConstraint.constant = 8
             subTitleLabel.isHidden = true
         }
+    
+        self.tagView.isHidden = !model.isNew
         
         self.titleLabel.stringValue = model.titleString()
         self.subTitleLabel.stringValue = model.subTitleString()

+ 2 - 2
PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController.xib

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22154" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<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="22154"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>

+ 29 - 9
PDF Office/PDF Master/Class/Home/WindowController/HomeQuickToolsWindowController/View/KMHomeQuickToolsWindowCollectionViewItem.swift

@@ -12,6 +12,22 @@ class KMHomeQuickToolsWindowCollectionViewItem: NSCollectionViewItem {
     @IBOutlet weak var titleLabel: NSTextField!
     @IBOutlet weak var box: KMBox!
     
+    
+    override var highlightState: NSCollectionViewItem.HighlightState {
+        didSet {
+            if highlightState == .forSelection {
+                self.updateState(isHight: true)
+            } else if highlightState == .forDeselection {
+                self.updateState(isHight: false)
+            }
+        }
+    }
+    override var isSelected: Bool {
+        didSet {
+            self.updateState(isHight: false)
+        }
+    }
+    
     var model: KMQucikToolsModel? {
         didSet {
             self.reloadData()
@@ -28,15 +44,7 @@ class KMHomeQuickToolsWindowCollectionViewItem: NSCollectionViewItem {
         self.titleLabel.textColor = KMAppearance.Layout.h2Color()
         
         self.box.moveCallback = {  [unowned self]  mouseEntered, mouseBox in
-            if mouseEntered {
-                box.fillColor = KMAppearance.Interactive.a0Color()
-                titleLabel.textColor = KMAppearance.Layout.w0Color()
-                iconImageView.image = model?.iconImage(true)
-            } else {
-                box.fillColor = NSColor.clear
-                titleLabel.textColor = KMAppearance.Layout.h2Color()
-                iconImageView.image = model?.iconImage(false)
-            }
+            self.updateState(isHight: mouseEntered)
         }
     }
     
@@ -46,4 +54,16 @@ class KMHomeQuickToolsWindowCollectionViewItem: NSCollectionViewItem {
         titleLabel.stringValue = model.titleString()
         iconImageView.image = model.iconImage()
     }
+    
+    func updateState(isHight: Bool) {
+        if isHight || self.isSelected {
+            box.fillColor = KMAppearance.Interactive.a0Color()
+            titleLabel.textColor = KMAppearance.Layout.w0Color()
+            iconImageView.image = model?.iconImage(true)
+        } else {
+            box.fillColor = NSColor.clear
+            titleLabel.textColor = KMAppearance.Layout.h2Color()
+            iconImageView.image = model?.iconImage(false)
+        }
+    }
 }

+ 5 - 1
PDF Office/PDF Master/Class/KMAdvertisement/View/View/KMAdvertisementShowView.swift

@@ -57,7 +57,11 @@ class KMAdvertisementShowView: NSView {
     }
     
     func reloadData() {
-        guard let model = inputData.content?.first else { return }
+        guard let model = inputData.content?.first else { 
+            self.contentView.isHidden = true
+            return
+        }
+        self.contentView.isHidden = false
         
         let url = URL(string: KMAdvertisementModelTransition.transitionImagePath(image: model.image, highlight: false))
         self.iconImage.image = KMAdvertisementImage.imageWithURL(url: url, completion: { [weak self] image in

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

@@ -7,9 +7,14 @@
 
 import Cocoa
 
+typealias KMHeaderFooterWindowControllerOperateCallBack = (_ controller: NSWindowController, _ headerFooter: KMHeaderFooterModel) -> ()
+
 class KMHeaderFooterWindowController: KMBaseWindowController {
     @IBOutlet weak var headerFooterView: KMHeaderFooterView!
 
+    var type: KMBatchModifyTemplateType = .Use
+    var operateCallBack: KMHeaderFooterWindowControllerOperateCallBack?
+    
     override func windowDidLoad() {
         super.windowDidLoad()
 
@@ -17,8 +22,13 @@ class KMHeaderFooterWindowController: KMBaseWindowController {
         headerFooterView.isHiddenBatchBtn = isBatch
         headerFooterView.isBates = isBates
         headerFooterView.pdfDocument = pdfDocument
+        headerFooterView.type = type
         headerFooterView.cancelAction = { [unowned self] view in
-            self.cancelAction?(self)
+            cancelAction?(self)
+        }
+        
+        headerFooterView.operateCallBack = { [unowned self] model in
+            operateCallBack?(self, model)
         }
     }
 }

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

@@ -256,11 +256,7 @@ class KMHeaderFooterView: KMBaseXibView, NSTextViewDelegate, NSComboBoxDelegate
         self.bottomCenterLabel.allowsExpansionToolTips = true
         self.bottomRightLabel.allowsExpansionToolTips = true
 
-        
-        if !self.onlyManagerTemplate {
-            self.saveToTemplateButton.isEnabled = false
-        }
-        
+        self.saveToTemplateButton.isEnabled = onlyManagerTemplate
 
         self.pageRangeCombobox.removeAllItems()
         self.pageRangeCombobox.addItems(withObjectValues: [

+ 1 - 0
PDF Office/PDF Master/Class/PDFTools/Background/Model/KMBackgroundModel.swift

@@ -11,6 +11,7 @@ import Cocoa
     case color = 0
     case file = 1
 }
+
 @objcMembers class KMBackgroundModel: KMWatermarkAdjectiveBaseModel {
     var type: KMBackgroundType = .color
     var color: NSColor? = NSColor.red

+ 9 - 2
PDF Office/PDF Master/Class/PDFTools/Background/New/KMBackgroundWindowController.swift

@@ -7,21 +7,28 @@
 
 import Cocoa
 
+typealias KMBackgroundWindowControllerOperateCallBack = (_ controller: NSWindowController, _ background: KMBackgroundModel, _ countType: Int) -> ()
 class KMBackgroundWindowController: KMBaseWindowController {
-
+    
     @IBOutlet weak var addBackgroundView: KMAddBackgroundView!
+    
+    var type: KMBackgroundManagerType = .use
+    
+    var operateCallBack: KMBackgroundWindowControllerOperateCallBack?
+    
     override func windowDidLoad() {
         super.windowDidLoad()
         
         // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
         addBackgroundView.isHiddenBatchBtn = isBatch
         addBackgroundView.pdfDocument = self.pdfDocument
+        addBackgroundView.type = type
         addBackgroundView.cancelAction = { [unowned self] view in
             cancelAction?(self)
         }
         
         addBackgroundView.operateCallBack = { [unowned self] background, countType in
-            
+            operateCallBack?(self, background, countType)
         }
     }
 }

+ 11 - 14
PDF Office/PDF Master/Class/PDFTools/Background/New/View/KMAddBackgroundView.swift

@@ -78,9 +78,8 @@ class KMAddBackgroundView: KMBaseXibView, NSComboBoxDelegate {
             self.reloadData()
         }
     }
-    var backgroundType: KMBackgroundType!
-    
-    
+    var backgroundType: KMBackgroundType = .color
+        
     var initialID: String!
     var currentType: Int = 0
     
@@ -88,7 +87,7 @@ class KMAddBackgroundView: KMBaseXibView, NSComboBoxDelegate {
     var batchAction: KMAddBackgroundViewCancelAction?
     var operateCallBack: KMAddBackgroundViewOperateCallBack?
 
-    var onlyManagerTemplate: Bool = false
+    var onlyManagerTemplate: Bool = true
 
     // MARK: - Dealloc
 
@@ -195,17 +194,15 @@ class KMAddBackgroundView: KMBaseXibView, NSComboBoxDelegate {
 
         appearanceBox.titleFont = NSFont.systemFont(ofSize: 13)
 
-        if !onlyManagerTemplate {
-            saveToTemplateButton.isEnabled = false
-        }
+        saveToTemplateButton.isEnabled = onlyManagerTemplate
 
-        if type == .use {
-            saveToTemplateButton.isHidden = true
-            saveToTemplateButton.state = .off
-        } else {
-            saveToTemplateButton.isHidden = false
-            saveToTemplateButton.state = .on
-        }
+//        if type == .use {
+//            saveToTemplateButton.isHidden = true
+//            saveToTemplateButton.state = .off
+//        } else {
+//            saveToTemplateButton.isHidden = false
+//            saveToTemplateButton.state = .on
+//        }
 
         pageRangeComboBox.removeAllItems()
         pageRangeComboBox.addItems(withObjectValues: [

+ 11 - 3
PDF Office/PDF Master/Class/PDFTools/Merge/MergeNew/View/KMMergeView.swift

@@ -46,8 +46,16 @@ class KMMergeView: KMBaseXibView {
     
     
     let MyTableCellViewDataType = NSPasteboard.PasteboardType(rawValue: "KMLocalForDraggedTypes")
-    var files: [KMFileAttribute] = [] //导入文件
-    var lockFiles: [KMFileAttribute] = [] //存在密码文件
+    var files: [KMFileAttribute] = [] {
+        didSet {
+            self.reloadData()
+        }
+    }
+    var lockFiles: [KMFileAttribute] = [] {
+        didSet {
+            self.reloadData()
+        }
+    }//存在密码文件
     var lockFilesIndex: Int = 0
     var newPageSize = CGSizeZero
     
@@ -98,7 +106,7 @@ class KMMergeView: KMBaseXibView {
         cancelButton.title = NSLocalizedString("Cancel",  comment: "");
         clearButton.title = NSLocalizedString("Clear",  comment: "");
         addFilesButton.title = NSLocalizedString("Add Files",  comment: "")
-        mergeButton.title = NSLocalizedString("Merge",  comment: "")
+        mergeButton.title = NSLocalizedString("Append",  comment: "")
         
         boxLabel.stringValue = NSLocalizedString("Page size:", comment: "")
     }

+ 4 - 4
PDF Office/PDF Master/Class/PDFTools/Merge/MergeNew/View/KMMergeView.xib

@@ -42,20 +42,20 @@
                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="etf-2M-YwD">
                             <rect key="frame" x="40" y="60" width="480" height="489"/>
                             <subviews>
-                                <scrollView borderType="none" autohidesScrollers="YES" horizontalLineScroll="60" horizontalPageScroll="10" verticalLineScroll="60" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="EWX-cc-X5u">
+                                <scrollView autohidesScrollers="YES" horizontalLineScroll="60" horizontalPageScroll="10" verticalLineScroll="60" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="EWX-cc-X5u">
                                     <rect key="frame" x="0.0" y="0.0" width="480" height="489"/>
                                     <clipView key="contentView" drawsBackground="NO" id="Kx1-Yj-S3W">
-                                        <rect key="frame" x="0.0" y="0.0" width="480" height="489"/>
+                                        <rect key="frame" x="1" y="1" width="478" height="487"/>
                                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                         <subviews>
                                             <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" multipleSelection="NO" autosaveColumns="NO" rowHeight="60" translatesAutoresizingMaskIntoConstraints="NO" id="hSd-xd-6WS">
-                                                <rect key="frame" x="0.0" y="0.0" width="480" height="489"/>
+                                                <rect key="frame" x="0.0" y="0.0" width="478" height="487"/>
                                                 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                                 <size key="intercellSpacing" width="17" height="0.0"/>
                                                 <color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
                                                 <color key="gridColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
                                                 <tableColumns>
-                                                    <tableColumn width="448" minWidth="10" maxWidth="3.4028234663852886e+38" id="pXw-Iw-CqQ">
+                                                    <tableColumn width="466" minWidth="10" maxWidth="3.4028234663852886e+38" id="pXw-Iw-CqQ">
                                                         <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border">
                                                             <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
                                                             <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>

+ 1 - 0
PDF Office/PDF Master/Class/PDFTools/Merge/Model/KMFileAttribute.swift

@@ -38,6 +38,7 @@ import Cocoa
             
             let document = CPDFDocument.init(url: URL(string: filePath))
             isLocked = document!.isLocked
+            self.pdfDocument = document
             
             fileImage = NSImage.previewForFile(path: URL(fileURLWithPath: filePath), ofSize: CGSizeMake(136, 214), asIcon: true) ?? NSImage()
         }

+ 12 - 0
PDF Office/PDF Master/Class/PDFTools/Watermark/New/KMWatermarkWindowController.swift

@@ -7,19 +7,31 @@
 
 import Cocoa
 
+
+typealias KMWatermarkWindowControllerOperateCallBack = (_ controller: NSWindowController, _ watermark: KMWatermarkModel, _ countType: Int) -> ()
+
 class KMWatermarkWindowController: KMBaseWindowController {
 
     @IBOutlet weak var watermarkView: KMWatermarkView!
     
+    var operateCallBack:KMWatermarkWindowControllerOperateCallBack?
+    
+    var type: KMWatermarkManagerType = .use
+    
     override func windowDidLoad() {
         super.windowDidLoad()
 
         // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
         watermarkView.isHiddenBatchBtn = isBatch
         watermarkView.pdfDocument = self.pdfDocument
+        watermarkView.type = type
         watermarkView.cancelAction = { [unowned self] view in
             cancelAction?(self)
         }
+        
+        watermarkView.operateCallBack = { [unowned self] watermark, countType in
+            operateCallBack?(self, watermark, countType)
+        }
     }
     
 }

+ 9 - 12
PDF Office/PDF Master/Class/PDFTools/Watermark/New/View/KMWatermarkView.swift

@@ -102,7 +102,7 @@ class KMWatermarkView: KMBaseXibView, NSTextFieldDelegate, NSComboBoxDelegate, N
         }
     }
     
-    var onlyManagerTemplate: Bool = false
+    var onlyManagerTemplate: Bool = true
     var isHiddenBatchBtn: Bool = false
 
     var cancelAction: KMWatermarkViewCancelAction?
@@ -181,19 +181,16 @@ class KMWatermarkView: KMBaseXibView, NSTextFieldDelegate, NSComboBoxDelegate, N
             self.pdfView.needsDisplay = true
         }
         
-        if !onlyManagerTemplate {
-            saveToTemplateButton.isEnabled = false
-        }
+        saveToTemplateButton.isEnabled = onlyManagerTemplate
         
-        if type == .use {
-            saveToTemplateButton.isHidden = true
-            saveToTemplateButton.state = .off
-        } else {
-            saveToTemplateButton.isHidden = false
-            saveToTemplateButton.state = .on
-        }
+//        if type == .use {
+//            saveToTemplateButton.isHidden = true
+//            saveToTemplateButton.state = .off
+//        } else {
+//            saveToTemplateButton.isHidden = false
+//            saveToTemplateButton.state = .on
+//        }
     
-        
         if type == .add {
             applyButton.title = NSLocalizedString("Apply", comment: "")
             batchButton.isHidden = true

+ 1 - 1
PDF Office/PDF Master/Class/PDFTools/Watermark/New/View/KMWatermarkView.xib

@@ -26,7 +26,6 @@
                 <outlet property="colorLabel" destination="eyF-7r-PRp" id="pIr-iu-zUr"/>
                 <outlet property="colorWell" destination="t2T-nR-zYm" id="9bz-oy-gU9"/>
                 <outlet property="currentPageIndexTextF" destination="rYB-8G-bLk" id="knp-Pw-Dob"/>
-                <outlet property="doneButton" destination="UzR-Kd-Vc4" id="NCB-E1-8wf"/>
                 <outlet property="fileButton" destination="a7f-rK-RaC" id="qyc-xU-nOi"/>
                 <outlet property="filePathLabel" destination="R2N-lb-dpG" id="aR3-xT-Xyd"/>
                 <outlet property="fontComboBox" destination="QNT-n6-7iF" id="HZx-vq-T6l"/>
@@ -113,6 +112,7 @@
                                                     <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                                                     <size key="minSize" width="247" height="58"/>
                                                     <size key="maxSize" width="262" height="10000000"/>
+                                                    <color key="insertionPointColor" name="textInsertionPointColor" catalog="System" colorSpace="catalog"/>
                                                 </textView>
                                             </subviews>
                                         </clipView>

+ 41 - 19
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/Annotation/View/KMNoteTypeImageView.swift

@@ -63,7 +63,7 @@ class KMNoteTypeImageView: NSImageView {
         var image: NSImage?
         
         var strikePath = "KMImageNameAnnotationStrikeout"
-        var highlight = "KMImageNameAnnotationHightlight"
+        var highlight = "KMImageNameStikeoutIcon"
         var underline = "KMImageNameAnnotationUnderline"
         var inkImagePath = Bundle.main.path(forResource: "KMImageNameAnnotationFreehand", ofType: "pdf")
         
@@ -71,16 +71,17 @@ class KMNoteTypeImageView: NSImageView {
             let appearanceName = NSApp.effectiveAppearance.bestMatch(from: [.aqua, .darkAqua])
             if appearanceName == .darkAqua {
                 strikePath = "KMImageNameAnnotationStrikeout"
-                highlight = "KMImageNameAnnotationHightlight"
+                highlight = "KMImageNameStikeoutIcon"
                 underline = "KMImageNameAnnotationUnderline"
                 inkImagePath = "KMImageNameAnnotationFreehandDrak"
             }
         }
 
         if type == SKNNoteString {
-            image = NSImage.colorWithImage(baseImage: NSImage(named: "KMImagePropertTextStyleOne_background")!, frameImage: NSImage(named:"KMImagePropertTextStyleOne_above")!, withColor: color)
+//            image = NSImage.colorWithImage(baseImage: NSImage(named: "KMImagePropertTextStyleOne_background")!, frameImage: NSImage(named:"KMImagePropertTextStyleOne_above")!, withColor: color)
+            image = NSImage(named: KMImageNameUXIconSubtoolbarMytoolsNote)
         } else if type == SKNFreeTextString {
-            image = NSImage(named: "KMImageNameMainToolFreeText")
+            image = NSImage(named: KMImageNameUXIconSidebarAnnotationText)
         } else if type == SKNCircleString {
             image = NSImage(size: CGSize(width: 16, height: 16))
             image?.lockFocus()
@@ -133,21 +134,24 @@ class KMNoteTypeImageView: NSImageView {
                 image?.unlockFocus()
             }
         } else if type == SKNUnderlineString {
-            image = NSImage(named: underline)
-            image?.lockFocus()
-            if let context = NSGraphicsContext.current?.cgContext {
-                context.beginPath()
-                context.move(to: CGPoint(x: 0, y: 1))
-                context.addLine(to: CGPoint(x: image!.size.width, y: 1))
-                let newColor = color.usingColorSpaceName(NSColorSpaceName.calibratedRGB)
-                let newUnderlineColor = NSColor(red: newColor!.redComponent, green: newColor!.greenComponent, blue: newColor!.blueComponent, alpha: 1)
-                newUnderlineColor.setStroke()
-                context.setLineWidth(2)
-                context.strokePath()
+            if let baseImage = NSImage(named: highlight) {
+                image = NSImage(size: baseImage.size)
+                image?.lockFocus()
+                if let context = NSGraphicsContext.current?.cgContext {
+                    context.beginPath()
+                    context.move(to: CGPoint(x: 0, y: 1))
+                    context.addLine(to: CGPoint(x: image!.size.width, y: 1))
+                    let newColor = color.usingColorSpaceName(NSColorSpaceName.calibratedRGB)
+                    let newUnderlineColor = NSColor(red: newColor!.redComponent, green: newColor!.greenComponent, blue: newColor!.blueComponent, alpha: 1)
+                    newUnderlineColor.setStroke()
+                    context.setLineWidth(2)
+                    context.strokePath()
+                    baseImage.draw(in: CGRect(x: 0, y: 0, width: image!.size.width, height: image!.size.height))
+                }
+                image?.unlockFocus()
             }
-            image?.unlockFocus()
         } else if type == SKNStrikeOutString {
-            if let strikeImage = NSImage(named: strikePath) {
+            if let strikeImage = NSImage(named: highlight) {
                 image = NSImage(size: strikeImage.size)
                 image?.lockFocus()
                 if let context = NSGraphicsContext.current?.cgContext {
@@ -159,6 +163,7 @@ class KMNoteTypeImageView: NSImageView {
                     strikenColor.setStroke()
                     context.setLineWidth(2)
                     context.strokePath()
+                    strikeImage.draw(in: CGRect(x: 0, y: 0, width: image!.size.width, height: image!.size.height))
                 }
                 image?.unlockFocus()
             }
@@ -195,9 +200,26 @@ class KMNoteTypeImageView: NSImageView {
             }
             image?.unlockFocus()
         } else if type == SKNInkString {
-            image = NSImage(named: "KMImageNameMainToolPen")?.copy() as? NSImage
+            if let baseImage = NSImage(named: "KMImageNameInkIcon")?.copy() as? NSImage {
+                image = NSImage(size: baseImage.size)
+                image?.lockFocus()
+                let ref3 = NSGraphicsContext.current?.cgContext
+                KMContextSaveGState(ref3)
+                KMContextBeginPath(ref3)
+                KMContextMoveToPoint(ref3, 2, 3)
+                KMContextAddCurveToPoint(ref3, image!.size.width/2, -5,  3 * image!.size.width/4, 3 * image!.size.width/4, image!.size.width, 4)
+                KMContextSetLineWidth(ref3, 1);
+                if let newColor = color.usingColorSpaceName(.calibratedRGB) {
+                    let newInkColor = NSColor(red: newColor.redComponent, green: newColor.greenComponent, blue: newColor.blueComponent, alpha: 1)
+                    newInkColor.set()
+                }
+                KMContextStrokePath(ref3);
+                KMContextRestoreGState(ref3);
+                baseImage.draw(in: CGRect(x: 0, y: 0, width: image!.size.width, height: image!.size.height))
+                image?.unlockFocus()
+            }
         } else if type == SKNStampString {
-            image = NSImage(named: "KMImageNameMainToolStamp")?.copy() as? NSImage
+            image = NSImage(named: KMImageNameUXIconSidebarAnnotationStamp)?.copy() as? NSImage
         } else if type == SKNLinkString {
             image = NSImage(named: "KMImageNameAnnotationLink")?.copy() as? NSImage
         } else if type == SKNStamp_ImageString {

+ 34 - 0
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMBotaTableRowView.swift

@@ -0,0 +1,34 @@
+//
+//  KMBotaTableRowView.swift
+//  PDF Master
+//
+//  Created by tangchao on 2023/11/28.
+//
+
+import Cocoa
+
+class KMBotaTableRowView: NSTableRowView {
+    convenience init() {
+        self.init(frame: .zero)
+        
+        self.addTrackingArea()
+    }
+
+    override func draw(_ dirtyRect: NSRect) {
+        super.draw(dirtyRect)
+
+        // Drawing code here.
+    }
+    
+    func addTrackingArea() {
+        let trackingArea = NSTrackingArea(rect: self.bounds, options: [.mouseEnteredAndExited, .inVisibleRect, .activeAlways, .mouseMoved], owner: self, userInfo: nil)
+        self.addTrackingArea(trackingArea)
+    }
+    
+    override func drawSelection(in dirtyRect: NSRect) {
+        let selectionRect = self.bounds
+        KMAppearance.Status.selColor().setFill()
+        let selectionPath = NSBezierPath(roundedRect: selectionRect, xRadius: 0, yRadius: 0)
+        selectionRect.fill()
+    }
+}

+ 395 - 135
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController.swift

@@ -298,7 +298,12 @@ class KMLeftSideViewController: KMSideViewController {
 //        [noteOutlineView setTypeSelectHelper:[SKTypeSelectHelper typeSelectHelperWithMatchOption:SKSubstringMatch]];
         self.noteOutlineView.indentationPerLevel = 0
 //        [noteOutlineView registerForDraggedTypes:[NSColor readableTypesForPasteboard:[NSPasteboard pasteboardWithName:NSDragPboard]]];
+        self.noteOutlineView.target = self
+        self.noteOutlineView.doubleAction = #selector(selectSelectedNote)
         
+        self.tocOutlineView.menu = NSMenu()
+        self.tocOutlineView.menu?.delegate = self
+        self.outlineSearchField.delegate = self
         self.snapshotSearchField.backgroundColor = KMAppearance.Layout.l_1Color()
          self.outlineSearchField.backgroundColor = KMAppearance.Layout.l_1Color()
          self.noteSearchField.backgroundColor = KMAppearance.Layout.l_1Color()
@@ -413,6 +418,7 @@ class KMLeftSideViewController: KMSideViewController {
         self.noteDoneButton.isHidden = true
         
         self.noteSearchButton.toolTip = KMLocalizedString("Search", nil)
+        self.noteSearchField.delegate = self
         self.noteSearchField.isHidden = true
         self.noteSearchField.endEditCallBack = { [unowned self] isEndEdit in
             if (isEndEdit) {
@@ -959,8 +965,8 @@ class KMLeftSideViewController: KMSideViewController {
             for (i, label) in pageLabels.enumerated() {
                 let firstPage = self.listView.document.page(at: UInt(i))
                 let size = NSMakeSize(self.thumbnailCacheSize, self.thumbnailCacheSize)
-                let pageImage = firstPage!.thumbnail(of: size)
-                let thumbnail = KMThumbnail(image: pageImage, label: label, pageIndex: i)
+//                let pageImage = firstPage!.thumbnail(of: size)
+                let thumbnail = KMThumbnail(image: nil, label: label, pageIndex: i)
                 //                thumbnail.delegate = self
                 thumbnail.dirty = true
                 self.thumbnails.append(thumbnail)
@@ -1366,7 +1372,7 @@ class KMLeftSideViewController: KMSideViewController {
         self.outlineSearchField.becomeFirstResponder()
     }
     
-    @objc func outlineContextMenuItemClicked_AddEntry(_ sender: NSMenuItem) {
+//    @objc func outlineContextMenuItemClicked_AddEntry(_ sender: NSMenuItem) {
 //        NSMutableArray *PDFOutlineArray = [[NSMutableArray new] autorelease];
 //        NSIndexSet *rowSet = [self selectedRowIndexes] ;
 //
@@ -1410,7 +1416,7 @@ class KMLeftSideViewController: KMSideViewController {
 //            [self.leftSideController.tocOutlineView deselectRow:currentIndex+1];
 //
 //        }
-    }
+//    }
     
     @IBAction func toc_expandAllComments(_ sender: AnyObject?) {
         if (self.tocType == .unfold) {
@@ -1432,17 +1438,18 @@ class KMLeftSideViewController: KMSideViewController {
     
     @objc func leftSideEmptyAnnotationClick_DeleteOutline(_ sender: AnyObject?) {
         KMPrint("leftSideEmptyAnnotationClick_DeleteOutline")
-//        NSAlert *alert = [[NSAlert alloc] init];
-//        [alert setAlertStyle:NSAlertStyleCritical];
-//        [alert setMessageText:@""];
-//        [alert setInformativeText:NSLocalizedString(@"This will permanently remove all outlines. Are you sure to continue?", nil)];
-//        [alert addButtonWithTitle:NSLocalizedString(@"Yes", nil)];
-//        [alert addButtonWithTitle:NSLocalizedString(@"No", nil)];
-//        NSModalResponse response  = [alert runModal];
-//        if (response == NSAlertFirstButtonReturn) {
-//            PDFOutline * item = [[pdfView document] outlineRoot];
-//            [self removeAllOutline:item];
-//        }
+        let alert = NSAlert()
+        alert.alertStyle = .critical
+        alert.messageText = ""
+        alert.informativeText = KMLocalizedString("This will permanently remove all outlines. Are you sure to continue?", nil)
+        alert.addButton(withTitle: KMLocalizedString("Yes", nil))
+        alert.addButton(withTitle: KMLocalizedString("No", nil))
+        let response = alert.runModal()
+        if response == .alertFirstButtonReturn {
+            if let item = self.listView.document.outlineRoot() {
+                self.removeAllOutline(item)
+            }
+        }
     }
     
     @IBAction func thumbnailSizeScaling(_ sender: NSButton) {
@@ -1456,8 +1463,14 @@ class KMLeftSideViewController: KMSideViewController {
             }
             if (tag == 0) { // thumbnail Zoom In
                 scaling += 0.1
+                if scaling >= 2.2 {
+                    return
+                }
             } else if (tag == 1) { // thumbnail Zoom Out
                 scaling -= 0.1
+                if scaling <= 0.4 {
+                    return
+                }
             }
             sud.setValue(scaling, forKey: "KMThumbnailSizeScalingKey")
 
@@ -1605,6 +1618,95 @@ class KMLeftSideViewController: KMSideViewController {
             }
         }
     }
+    
+    func showSearchOutlineBlankState(_ toShowState: Bool) {
+        if (toShowState) {
+            self.leftSideEmptyVC.outlineSearchView.frame = CGRectMake((self.tocOutlineView.enclosingScrollView!.documentView!.frame.size.width - self.leftSideEmptyVC.outlineSearchView.bounds.size.width)/2.0, (self.tocOutlineView.enclosingScrollView!.documentView!.frame.size.height - self.leftSideEmptyVC.outlineSearchView.bounds.size.height)/2.0, self.leftSideEmptyVC.outlineSearchView.bounds.size.width, self.leftSideEmptyVC.outlineSearchView.bounds.size.height);
+            self.tocOutlineView.enclosingScrollView?.documentView?.addSubview(self.leftSideEmptyVC.outlineSearchView)
+            self.leftSideEmptyVC.outlineSearchView.autoresizingMask = [.minXMargin, .maxXMargin, .minYMargin, .maxYMargin]
+        } else {
+            self.leftSideEmptyVC.outlineSearchView.removeFromSuperview()
+        }
+    }
+    
+//    func allRangeOfRoughString(_ roughString: String, searchString: String) -> [NSRange] {
+//
+//    }
+    
+    func removeAllOutline(_ outline: CPDFOutline) {
+        let ol = CPDFOutline()
+        self.listView.document.setOutlineRoot(ol)
+        
+        for i in 0 ..< self.listView.document.pageCount {
+            self.listView.document.removeBookmark(forPageIndex: i)
+        }
+        self.listView.layoutDocumentView()
+        DispatchQueue.main.async {
+            self.tocOutlineView.reloadData()
+        }
+    }
+    
+    func updateNoteFilterPredicate() {
+        //注释筛选
+    //    [rightSideController.noteArrayController setFilterPredicate:[noteTypeSheetController filterPredicateForSearchString:[rightSideController.searchField stringValue] caseInsensitive:mwcFlags.caseInsensitiveNoteSearch]];
+        
+//        NSPredicate *predicate = [noteTypeSheetController filterPredicateForSearchString:[rightSideController.searchField stringValue] caseInsensitive:mwcFlags.caseInsensitiveNoteSearch];
+//        [self loadAnnotationSortData:[NSArray arrayWithObjects:predicate, nil]];
+//        [rightSideController.noteOutlineView reloadData];
+    }
+    
+    @objc func selectSelectedNote(_ sender: AnyObject?) {
+        if self.listView.hideNotes == false {
+            let selectedNotes = self.selectedNotes()
+            if selectedNotes.count == 1 {
+                let annotation = selectedNotes.last!
+                self.listView.go(to: annotation.bounds, on: annotation.page, animated: true)
+                
+//                [pdfView scrollAnnotationToVisible:annotation];
+//                [pdfView setActiveAnnotation:annotation];
+                    
+                    self.listView.updateActiveAnnotations([annotation])
+                    self.listView.setNeedsDisplayAnnotationViewForVisiblePages()
+//                }
+                
+            }
+//            NSInteger column = [sender clickedColumn];
+//            if (column != -1) {
+//                NSString *colID = [[[sender tableColumns] objectAtIndex:column] identifier];
+//
+//                if ([colID isEqualToString:@"color"]){
+//                    for (PDFAnnotation *annotation  in self.pdfView.activeAnnotations) {
+//                       if (![annotation isKindOfClass:[PDFAnnotationChoiceWidget class]] &&
+//                         ![annotation isKindOfClass:[PDFAnnotationButtonWidget class]] &&
+//                         ![annotation isKindOfClass:[PDFAnnotationTextWidget class]]) {
+//                            [[NSColorPanel sharedColorPanel] orderFront:nil];
+//                            break;
+//                        }
+//
+//                    }
+//                }
+//            }
+        }
+    }
+    
+    func selectedNotes() -> [CPDFAnnotation] {
+        var selectedNotes: [CPDFAnnotation] = []
+        let rowIndexes = self.noteOutlineView.selectedRowIndexes
+        for row in rowIndexes {
+            let item = self.noteOutlineView.item(atRow: row)
+            if item is KMBOTAAnnotationItem {
+                if let anno = (item as! KMBOTAAnnotationItem).annotation {
+                    //                if anno.type == nil {
+                    //                item = [(SKNoteText *)item note];
+                    //                }
+                    if selectedNotes.contains(anno) == false {
+                        selectedNotes.append(anno)
+                    }
+                }
+            }
+        }
+        return selectedNotes
+    }
 }
 
 // MARK: - KMBotaTableViewDelegate
@@ -1992,19 +2094,25 @@ extension KMLeftSideViewController {
     }
     
     private func _hasContainString(_ searchString: String, rootOutline outline: CPDFOutline) -> Bool {
+        let label_low = outline.label.lowercased()
+        let searchString_low = searchString.lowercased()
+        if label_low.contains(searchString_low) {
 //        if ([outline.label rangeOfString:searchString options:self.outlineIgnoreCaseFlag?NSCaseInsensitiveSearch:0].location != NSNotFound){
-//            return YES;
-//        } else {
-//            BOOL subHas = NO;
-//            for (NSUInteger i = 0; i < outline.numberOfChildren; i ++) {
-//                PDFOutline *subOutline = [outline childAtIndex:i];
-//                subHas = [self hasContainString:searchString rootOutline:subOutline];
-//                if (subHas) {
-//                    break;
-//                }
-//            }
-//            return subHas;
-//        }
+            return true
+        } else {
+            var subHas = false
+            for i in 0 ..< outline.numberOfChildren {
+                if let subOutline = outline.child(at: i) {
+                    subHas = self._hasContainString(searchString, rootOutline: subOutline)
+                } else {
+                    continue
+                }
+                if (subHas) {
+                    break
+                }
+            }
+            return subHas
+        }
         return false
     }
 }
@@ -2111,7 +2219,8 @@ extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
     func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat {
         if tableView.isEqual(to: self.thumbnailTableView) {
             let scaling = UserDefaults.standard.float(forKey: "KMThumbnailSizeScalingKey")
-            let thumbnailSize = self.thumbnails[row].size
+//            let thumbnailSize = self.thumbnails[row].size
+            let thumbnailSize = NSMakeSize(self.thumbnailCacheSize, self.thumbnailCacheSize)
             
             let newScaling: CGFloat = scaling.cgFloat + 0.1
             let newThumbnailHeight = thumbnailSize.width * newScaling
@@ -2971,74 +3080,96 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
     func outlineView(_ outlineView: NSOutlineView, numberOfChildrenOfItem item: Any?) -> Int {
         if outlineView.isEqual(to: self.tocOutlineView) {
             let isLocked = self.listView.document?.isLocked ?? true
-            if item == nil && isLocked == false {
-                var item = self.listView.document.outlineRoot()
-                if let data = item?.numberOfChildren, data == 0 && !self.isSearchOutlineMode {
-                    let view = self.tocOutlineView.enclosingScrollView!
-                    let emptyVcSize =  self.leftSideEmptyVC.emptyOutlineView.frame.size
-//
-                    self.leftSideEmptyVC.emptyOutlineView.frame = NSMakeRect((view.frame.size.width-emptyVcSize.width)/2.0,(view.frame.size.height-emptyVcSize.height)/2.0, emptyVcSize.width, emptyVcSize.height)
-                    
-                    self.leftSideEmptyVC.emptyOutlineView.autoresizingMask = [.minXMargin, .maxXMargin, .minYMargin, .maxYMargin]
-                    self.tocOutlineView.enclosingScrollView?.documentView?.addSubview(self.leftSideEmptyVC.emptyOutlineView)
-                    self.leftSideEmptyVC.deleteOutlineBtn.isEnabled = false
+            if isLocked { // 文档不存在 或 已加锁
+                return 0
+            }
+            if item == nil { // 第一层
+                // 获取根
+                guard let outline = self.listView.document.outlineRoot() else {
+                    return 0
+                }
+                if outline.numberOfChildren == 0 {
+                    return 0
+                }
+                
+                if self.isSearchOutlineMode { // 是否为搜索模块
+                    if self._hasContainString(self.outlineSearchField.stringValue, rootOutline: outline) {
+                        self.showSearchOutlineBlankState(false)
+                    } else {
+                        self.showSearchOutlineBlankState(true)
+                        return 0
+                    }
                 } else {
-                    self.leftSideEmptyVC.emptyOutlineView.removeFromSuperview()
-                    self.leftSideEmptyVC.deleteOutlineBtn.isEnabled = true
+                    if outline.numberOfChildren > 0 { // 有数据
+                        self.leftSideEmptyVC.emptyOutlineView.removeFromSuperview()
+                        self.leftSideEmptyVC.deleteOutlineBtn.isEnabled = true
+                    } else { // 没有数据
+                        let view = self.tocOutlineView.enclosingScrollView!
+                        let emptyVcSize =  self.leftSideEmptyVC.emptyOutlineView.frame.size
+    //
+                        self.leftSideEmptyVC.emptyOutlineView.frame = NSMakeRect((view.frame.size.width-emptyVcSize.width)/2.0,(view.frame.size.height-emptyVcSize.height)/2.0, emptyVcSize.width, emptyVcSize.height)
+                        self.leftSideEmptyVC.emptyOutlineView.autoresizingMask = [.minXMargin, .maxXMargin, .minYMargin, .maxYMargin]
+                        self.tocOutlineView.enclosingScrollView?.documentView?.addSubview(self.leftSideEmptyVC.emptyOutlineView)
+                        self.leftSideEmptyVC.deleteOutlineBtn.isEnabled = false
+                        return 0
+                    }
                 }
-                if let data = item?.numberOfChildren, data > 0 {
+
+                // 搜索按钮
+                if outline.numberOfChildren > 0 {
                     self.outlineSearchButton.isEnabled = true
                 } else {
                     self.outlineSearchButton.isEnabled = false
                 }
                 
                 if (self.isSearchOutlineMode) {
-                    if self._hasContainString(self.outlineSearchField.stringValue, rootOutline: item!) {
-//                        [self showSearchOutlineBlankState:NO];
-                    } else {
-//                        [self showSearchOutlineBlankState:YES];
+                    var num = 0
+                    for i in 0 ..< outline.numberOfChildren {
+                        if let child = outline.child(at: i) {
+                            if self._hasContainString(self.outlineSearchField.stringValue, rootOutline: child) {
+                                num += 1
+                            }
+                        }
+                    }
+                    return num
+                } else {
+                    let array = self.listView.document.bookmarks() ?? [CPDFBookmark]()
+                    var bookmarkNum = 0
+                    if array.isEmpty == false {
+                        bookmarkNum = 1
                     }
+                    return Int(outline.numberOfChildren) + bookmarkNum
                 }
-                
-                let array = self.listView.document.bookmarks() ?? [CPDFBookmark]()
-//                var bookMarks: [KMBookMarkItem] = []
-//                for bookMark in array {
-//                    let item = KMBookMarkItem()
-//                    item.bookMark = bookMark
-//                    item.index = UInt(bookMark.pageIndex)
-//                    item.label = bookMark.label
-//                    bookMarks.append(item)
-//                }
-                var bookmarkNum = 0
-                if array.isEmpty == false {
-                    bookmarkNum = 1
+            } else { // 第二层 +
+                if self.isSearchOutlineMode {
+                    if let data = item as? String, data == "Bookmarks" { // 书签group
+                        return 0
+                    } else if item is CPDFOutline { // 大纲
+                        let child = item as! CPDFOutline
+                        if child.numberOfChildren == 0 {
+                            return 0
+                        }
+                        var num = 0
+                        for i in 0 ..< child.numberOfChildren {
+                            if let _child = child.child(at: i) {
+                                if self._hasContainString(self.outlineSearchField.stringValue, rootOutline: _child) {
+                                    num += 1
+                                }
+                            }
+                        }
+                        return num
+                    } else if item is CPDFBookmark { // 书签
+                        return 0
+                    }
+                } else {
+                    if let data = item as? String, data == "Bookmarks" { // 书签group
+                        return (self.listView.document?.bookmarks().count) ?? 0
+                    } else if item is CPDFOutline { // 大纲
+                        return Int((item as? CPDFOutline)?.numberOfChildren ?? 0)
+                    } else if item is CPDFBookmark { // 书签
+                        return 0
+                    }
                 }
-                return Int(item?.numberOfChildren ?? 0) + bookmarkNum
-            }
-            if (self.isSearchOutlineMode) {
-//                var num = 0
-//                for (NSUInteger i = 0; i < [(PDFOutline *)item numberOfChildren]; i++) {
-//                    PDFOutline *outline = [(PDFOutline *)item childAtIndex:i];
-//                    if ([self hasContainString:self.leftSideController.outlineSearchField.stringValue rootOutline:outline]) {
-//                        num ++;
-//                    }
-//                }
-//                return num;
-            } else {
-//                return [(PDFOutline *)item numberOfChildren];
-            }
-//            if item is CPDFBookmark {
-//                return 0
-//            }
-//            return Int((item as? CPDFOutline)?.numberOfChildren ?? 0)
-            let array = self.listView.document?.bookmarks() ?? [CPDFBookmark]()
-            if let data = item as? String, data == "Bookmarks" {
-                return array.count
-            } else if item is CPDFOutline {
-//                return Int(item?.numberOfChildren ?? 0)
-                return Int((item as? CPDFOutline)?.numberOfChildren ?? 0)
-            } else if item is CPDFBookmark {
-                return 0
             }
         } else if outlineView.isEqual(to: self.noteOutlineView) {
             var count = 0
@@ -3094,21 +3225,46 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
     
     func outlineView(_ outlineView: NSOutlineView, child index: Int, ofItem item: Any?) -> Any {
         if outlineView.isEqual(to: self.tocOutlineView) {
+            let isLocked = self.listView.document?.isLocked ?? true
+            if isLocked { // 文档不存在 或 已加锁
+                return ""
+            }
+            
             let array = self.listView.document.bookmarks() ?? [CPDFBookmark]()
             var bookmarkNum = 0
             if array.isEmpty == false {
                 bookmarkNum = 1
             }
-            
-            if item == nil && self.listView.document.isLocked == false {
-                if index == 0 && bookmarkNum == 1 {
-                    return "Bookmarks"
+            if item == nil {
+                if self.isSearchOutlineMode {
+                    guard let outline = self.listView.document.outlineRoot() else {
+                        return ""
+                    }
+                    if outline.numberOfChildren == 0 {
+                        return ""
+                    }
+                    var array: [CPDFOutline] = []
+                    for i in 0 ..< outline.numberOfChildren {
+                        if let child = outline.child(at: i) {
+                            if self._hasContainString(self.outlineSearchField.stringValue, rootOutline: child) {
+                                array.append(child)
+                            }
+                        }
+                    }
+                    
+                    if index < array.count {
+                        return array[index]
+                    }
+                    return ""
                 } else {
-                    var _index = bookmarkNum == 1 ? index-1 : index
-                    var _item: CPDFOutline?
-                    _item = self.listView.document.outlineRoot()
-                    var obj = _item?.child(at: UInt(_index))
-                    return obj as Any
+                    if index == 0 && bookmarkNum == 1 {
+                        return "Bookmarks"
+                    } else {
+                        var _index = bookmarkNum == 1 ? index-1 : index
+                        let outline = self.listView.document.outlineRoot()
+                        var obj = outline?.child(at: UInt(_index))
+                        return obj as Any
+                    }
                 }
             } else {
                 if let data = item as? String, data == "Bookmarks" {
@@ -3116,23 +3272,9 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
                 } else if item is CPDFOutline {
                     return (item as! CPDFOutline).child(at: UInt(index))
                 } else if item is CPDFBookmark {
-//                    return nil?
+                    return ""
                 }
             }
-//            var obj = _item?.child(at: UInt(index))
-//            if (self.isSearchOutlineMode) {
-//                NSMutableArray *array = [NSMutableArray array];
-//                for (NSUInteger i = 0; i < [(PDFOutline *)item numberOfChildren]; i ++) {
-//                    PDFOutline *subOutline = [(PDFOutline *)item childAtIndex:i];
-//                    if ([self hasContainString:self.leftSideController.outlineSearchField.stringValue rootOutline:subOutline]) {
-//                        [array addObject:subOutline];
-//                    }
-//                }
-//                return [array objectAtIndex:anIndex];
-//            } else {
-//             return obj;
-//            }
-//            return obj as Any
         } else if outlineView.isEqual(to: self.noteOutlineView) {
 //            if (item == nil)
 //            {
@@ -3242,17 +3384,21 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
             let tcID = tableColumn?.identifier.rawValue
             
             var title = ""
+            var pageLabel = ""
             if let data = item as? String, data == "Bookmarks" {
                 title = NSLocalizedString("Bookmarks", comment: "")
             } else if item is CPDFOutline {
                 title = (item as! CPDFOutline).label
+                pageLabel = "\(((item as! CPDFOutline).destination?.pageIndex ?? 0) + 1)"
             } else if item is CPDFBookmark {
                 title = (item as! CPDFBookmark).label
+                pageLabel = "\((item as! CPDFBookmark).pageIndex + 1)"
             }
             
             if tcID == LABEL_COLUMNID {
                 if (self.isSearchOutlineMode) {
 //                    NSString *roughString = [[ol label] stringByCollapsingWhitespaceAndNewlinesAndRemovingSurroundingWhitespaceAndNewlines];
+                    let roughString = title
 //                    NSArray *arr = [self allRangeOfRoughString:roughString searchString:self.leftSideController.outlineSearchField.stringValue];
 //                    NSMutableAttributedString *attributeString = [[[NSMutableAttributedString alloc] initWithString:roughString] autorelease];
 //
@@ -3263,11 +3409,11 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
 //                        [attributeString addAttribute:NSFontAttributeName value:[NSFont boldSystemFontOfSize:13] range:range];
 //                    }
 //                    cell.tocLabel.attributedStringValue = attributeString;
+                    cell.tocLabel.stringValue = title
                 } else {
                     cell.tocLabel.stringValue = title
                 }
-                // TODO:  不确定是哪个字段
-                cell.pageLabel.stringValue = ""
+                cell.pageLabel.stringValue = pageLabel
             }
 //                else if([tcID isEqualToString:PAGE_COLUMNID]) {
 //                cell.pageLabel.stringValue = [ol pageLabel];
@@ -3386,6 +3532,15 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
                 noteType = SKNSignatureString
             } else if note.isKind(of: CPDFInkAnnotation.self) {
                 noteType = SKNInkString
+            } else if note.isKind(of: CPDFMarkupAnnotation.self) {
+                let anno = note as! CPDFMarkupAnnotation
+                if anno.markupType() == .highlight {
+                    noteType = SKNHighlightString
+                } else if anno.markupType() == .underline {
+                    noteType = SKNUnderlineString
+                } else if anno.markupType() == .strikeOut {
+                    noteType = SKNStrikeOutString
+                }
             }
             
             cell.typeImageView.image = imageView.noteTypeImage(withType: noteType, color: noteColor ?? .red)
@@ -3615,15 +3770,26 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
     
     func outlineView(_ outlineView: NSOutlineView, rowViewForItem item: Any) -> NSTableRowView? {
         if outlineView.isEqual(self.tocOutlineView) {
-            let itemView = KMCustomTableRowView()
+            let itemView = KMBotaTableRowView()
             return itemView
         } else if outlineView.isEqual(self.noteOutlineView) {
-            let itemView = KMCustomTableRowView()
+            let itemView = KMBotaTableRowView()
             return itemView;
         }
         return nil
     }
     
+    func outlineViewSelectionDidChange(_ notification: Notification) {
+        if self.tocOutlineView.isEqual(to: notification.object) {
+//        if ([[notification object] isEqual:leftSideController.tocOutlineView] && (mwcFlags.updatingOutlineSelection == 0)){
+//            mwcFlags.updatingOutlineSelection = 1;
+            self.goToSelectedOutlineItem(nil)
+//            mwcFlags.updatingOutlineSelection = 0;
+//            if ([self interactionMode] == SKPresentationMode && [[NSUserDefaults standardUserDefaults] boolForKey:SKAutoHidePresentationContentsKey])
+//                [self hideLeftSideWindow];
+        }
+    }
+    
     /*
      #pragma mark NSOutlineView datasource protocol
 
@@ -3817,17 +3983,6 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
          }
      }
 
-     - (void)outlineViewSelectionDidChange:(NSNotification *)notification{
-         // Get the destination associated with the search result list. Tell the PDFView to go there.
-         if ([[notification object] isEqual:leftSideController.tocOutlineView] && (mwcFlags.updatingOutlineSelection == 0)){
-             mwcFlags.updatingOutlineSelection = 1;
-             [self goToSelectedOutlineItem:nil];
-             mwcFlags.updatingOutlineSelection = 0;
-             if ([self interactionMode] == SKPresentationMode && [[NSUserDefaults standardUserDefaults] boolForKey:SKAutoHidePresentationContentsKey])
-                 [self hideLeftSideWindow];
-         }
-     }
-
      - (NSString *)outlineView:(NSOutlineView *)ov toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tableColumn item:(id)item mouseLocation:(NSPoint)mouseLocation {
          if ([ov isEqual:rightSideController.noteOutlineView] &&
              (tableColumn == nil || [[tableColumn identifier] isEqualToString:NOTE_COLUMNID])) {
@@ -4144,12 +4299,65 @@ extension KMLeftSideViewController: KMNoteOutlineViewDelegate {
 }
 
 extension KMLeftSideViewController: NSSearchFieldDelegate {
-    
+    func controlTextDidChange(_ obj: Notification) {
+        if self.outlineSearchField.isEqual(to: obj.object) {
+            if (self.outlineSearchField.stringValue.isEmpty == false) {
+                self.isSearchOutlineMode = true
+                
+                self.tocOutlineView.reloadData()
+                self.tocOutlineView.expandItem(nil, expandChildren: true)
+                self.tocType = .unfold
+            } else {
+                self.isSearchOutlineMode = false
+                self.showSearchOutlineBlankState(false)
+                self.tocOutlineView.reloadData()
+            }
+    //        self.leftSideEmptyVC.addOutlineBtn.enabled = !self.isSearchOutlineMode;
+            self.outlineAddButton.isEnabled = !self.isSearchOutlineMode
+        }
+//        else if ([obj.object isEqual:self.leftSideController.snapshotSearchField]) {
+//            NSString *searchString = [self.leftSideController.snapshotSearchField stringValue];
+//            NSPredicate *filterPredicate = nil;
+//            if ([searchString length] > 0) {
+//                NSExpression *lhs = [NSExpression expressionForConstantValue:searchString];
+//                NSExpression *rhs = [NSExpression expressionForKeyPath:@"string"];
+//                NSUInteger options = NSDiacriticInsensitivePredicateOption;
+//                if (mwcFlags.caseInsensitiveNoteSearch)
+//                    options |= NSCaseInsensitivePredicateOption;
+//                filterPredicate = [NSComparisonPredicate predicateWithLeftExpression:lhs rightExpression:rhs modifier:NSDirectPredicateModifier type:NSInPredicateOperatorType options:options];
+//            }
+//            [rightSideController.snapshotArrayController setFilterPredicate:filterPredicate];
+//
+//            NSArray * snapshots = [rightSideController.snapshotArrayController arrangedObjects];
+//            if (snapshots.count > 0) {
+//                [self.leftSideEmptyVC.outlineSearchView removeFromSuperview];
+//            } else {
+//                NSView *view = rightSideController.snapshotTableView.enclosingScrollView;
+//                CGSize emptyVcSize =  self.leftSideEmptyVC.outlineSearchView.frame.size;
+//                self.leftSideEmptyVC.outlineSearchView.frame = NSMakeRect((view.frame.size.width-emptyVcSize.width)/2.0,(view.frame.size.height-emptyVcSize.height)/2.0, emptyVcSize.width, emptyVcSize.height);
+//                self.leftSideEmptyVC.outlineSearchView.autoresizingMask = NSViewMinXMargin | NSViewMaxXMargin| NSViewMaxYMargin | NSViewMinYMargin;
+//                [rightSideController.snapshotTableView.enclosingScrollView.documentView addSubview:self.leftSideEmptyVC.outlineSearchView];
+//            }
+//        }
+    }
 }
 
 extension KMLeftSideViewController: NSMenuDelegate {
     func menuNeedsUpdate(_ menu: NSMenu) {
         if menu.isEqual(to: self.tocOutlineView.menu) {
+            menu.removeAllItems()
+            var item = menu.addItem(withTitle: NSLocalizedString("Add Item", comment: ""), action: #selector(outlineContextMenuItemClicked_AddEntry), target: self, tag: 1)
+            item = menu.addItem(withTitle: NSLocalizedString("Add Sub-Item", comment: ""), action: #selector(outlineContextMenuItemClicked_AddChildEntry), target: self, tag: 2)
+            item = menu.addItem(withTitle: NSLocalizedString("Add To A Higher Level", comment: ""), action: #selector(outlineContextMenuItemClicked_AddAuntEntry), target: self, tag: 3)
+            menu.addItem(.separator())
+            item = menu.addItem(withTitle: NSLocalizedString("Delete", comment: ""), action: #selector(outlineContextMenuItemClicked_RemoveEntry), target: self, tag: 4)
+            menu.addItem(.separator())
+            item = menu.addItem(withTitle: NSLocalizedString("Edit", comment: ""), action: #selector(outlineContextMenuItemClicked_Edit), target: self, tag: 5)
+            item = menu.addItem(withTitle: NSLocalizedString("Change Destination", comment: ""), action: #selector(outlineContextMenuItemClicked_SetDestination), target: self, tag: 6)
+            item = menu.addItem(withTitle: NSLocalizedString("Rename", comment: ""), action: #selector(outlineContextMenuItemClicked_Rename), target: self, tag: 7)
+            menu.addItem(.separator())
+            item = menu.addItem(withTitle: NSLocalizedString("Promote", comment: ""), action: #selector(outlineContextMenuItemClicked_Promote), target: self, tag: 8)
+            item = menu.addItem(withTitle: NSLocalizedString("Demote", comment: ""), action: #selector(outlineContextMenuItemClicked_Demote), target: self, tag: 9)
             return
         }
         var item: NSMenuItem?
@@ -4559,7 +4767,17 @@ extension KMLeftSideViewController {
     }
     
     @objc func searchNotes(_ sender: AnyObject?) {
-        KMPrint("KMLeftSideViewController-searchNotes...")
+        if self.findState == .note {
+            //        if (mwcFlags.findState == SKFindStateNote)
+//            [self updateNoteFilterPredicate];
+        }
+//        else
+//            [self updateSnapshotFilterPredicate];
+//        if ([[sender stringValue] length]) {
+//            NSPasteboard *findPboard = [NSPasteboard pasteboardWithName:NSPasteboardNameFind];
+//            [findPboard clearContents];
+//            [findPboard writeObjects:[NSArray arrayWithObjects:[sender stringValue], nil]];
+//        }
     }
     
     @objc func toggleSelectedSnapshots(_ sender: AnyObject?) {
@@ -4570,6 +4788,42 @@ extension KMLeftSideViewController {
         KMPrint("KMLeftSideViewController-toggleOutlineCaseInsensitiveSearch...")
     }
     
+    @objc func outlineContextMenuItemClicked_AddEntry(_ sender: AnyObject?) {
+        KMPrint("KMLeftSideViewController-outlineContextMenuItemClicked_AddEntry...")
+    }
+    
+    @objc func outlineContextMenuItemClicked_AddChildEntry(_ sender: AnyObject?) {
+        KMPrint("KMLeftSideViewController-outlineContextMenuItemClicked_AddChildEntry...")
+    }
+    
+    @objc func outlineContextMenuItemClicked_AddAuntEntry(_ sender: AnyObject?) {
+        KMPrint("KMLeftSideViewController-outlineContextMenuItemClicked_AddAuntEntry...")
+    }
+    
+    @objc func outlineContextMenuItemClicked_RemoveEntry(_ sender: AnyObject?) {
+        KMPrint("KMLeftSideViewController-outlineContextMenuItemClicked_RemoveEntry...")
+    }
+    
+    @objc func outlineContextMenuItemClicked_Edit(_ sender: AnyObject?) {
+        KMPrint("KMLeftSideViewController-outlineContextMenuItemClicked_Edit...")
+    }
+    
+    @objc func outlineContextMenuItemClicked_SetDestination(_ sender: AnyObject?) {
+        KMPrint("KMLeftSideViewController-outlineContextMenuItemClicked_SetDestination...")
+    }
+    
+    @objc func outlineContextMenuItemClicked_Rename(_ sender: AnyObject?) {
+        KMPrint("KMLeftSideViewController-outlineContextMenuItemClicked_Rename...")
+    }
+    
+    @objc func outlineContextMenuItemClicked_Promote(_ sender: AnyObject?) {
+        KMPrint("KMLeftSideViewController-outlineContextMenuItemClicked_Promote...")
+    }
+    
+    @objc func outlineContextMenuItemClicked_Demote(_ sender: AnyObject?) {
+        KMPrint("KMLeftSideViewController-outlineContextMenuItemClicked_Demote...")
+    }
+    
     private func _tableView(_ tv: NSTableView, cutRowsWithIndexes rowIndexes: IndexSet) {
 //        if tv.isEqual(to: self.thumbnailTableView) {
 //            self._copysPages.removeAll()
@@ -4588,15 +4842,21 @@ extension KMLeftSideViewController {
 
 extension KMLeftSideViewController {
     @objc func goToSelectedOutlineItem(_ sender: AnyObject?) {
-        KMPrint("KMLeftSideViewController-goToSelectedOutlineItem...")
-//        PDFOutline *outlineItem = [leftSideController.tocOutlineView itemAtRow:[leftSideController.tocOutlineView selectedRow]];
-//        NSOutlineView *outline = (NSOutlineView *)leftSideController.tocOutlineView;
-//        if (outline.selectedRowIndexes.count == 1) {
-//            if ([outlineItem destination])
-//                [pdfView goToDestination:[outlineItem destination]];
-//            else if ([outlineItem action])
-//                [pdfView performAction:[outlineItem action]];
-//        }
+        let outlineItem = self.tocOutlineView.item(atRow: self.tocOutlineView.selectedRow)
+        let outline = self.tocOutlineView
+        if let cnt = outline?.selectedRowIndexes.count, cnt == 1 {
+            if outlineItem is CPDFOutline {
+                let outline = (outlineItem as! CPDFOutline)
+                if let des = outline.destination {
+                    self.listView.go(to: des)
+                } else if let action = outline.action {
+                    self.listView.perform(action)
+                }
+            } else if outlineItem is CPDFBookmark {
+                let bookmark = outlineItem as! CPDFBookmark
+                self.listView.go(toPageIndex: bookmark.pageIndex, animated: true)
+            }
+        }
     }
     
     @objc func goToSelectedFindResults(_ sender: AnyObject?) {

File diff suppressed because it is too large
+ 8 - 8
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/LeftSideView.xib


+ 3 - 0
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/Thumbnail/Base/KMPDFThumbViewBaseController.swift

@@ -184,6 +184,9 @@ class KMPDFThumbViewBaseController: KMBaseViewController {
         let panel = NSOpenPanel()
         panel.allowedFileTypes = ["pdf"]
         panel.beginSheetModal(for: self.view.window!) { response in
+            if response == .cancel {
+                return
+            }
             let windowC = KMPDFEditInsertPageWindow(document: self.thumbnailView.document!, path: panel.urls.first!, password: self.thumbnailView.document?.password)
             windowC.callback = { [weak self] pdfDoc, pwd, pages, insertIdx in
                 var indexs = IndexSet()

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

@@ -2032,12 +2032,12 @@ extension KMMainViewController {
         let windowController = KMCompressWIndowControllerNew(windowNibName: "KMCompressWIndowControllerNew")
         self.view.window?.beginSheet(windowController.window!)
         self.currentWindowController = windowController
-        if let _url = url {
-            windowController.documentURL = _url
-            windowController.oriDocumentUrl = self.listView.document.documentURL
-        } else {
+//        if let _url = url {
+//            windowController.oriDocumentUrl = self.listView.document.documentURL
+//            windowController.documentURL = _url
+//        } else {
             windowController.documentURL = self.listView.document.documentURL
-        }
+//        }
         windowController.password = self.listView.document.password
         
         windowController.itemClick = { [weak self] in