Browse Source

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

niehaoyu 11 months ago
parent
commit
ff88feed84
46 changed files with 392 additions and 544 deletions
  1. 9 9
      PDF Office/PDF Master/Base.lproj/Main.storyboard
  2. 1 1
      PDF Office/PDF Master/Class/Batch/WindowController/KMBatchOperateLeftViewController.swift
  3. 1 1
      PDF Office/PDF Master/Class/Batch/WindowController/VC/KMBatchOperateImageToPDFViewController.swift
  4. 9 9
      PDF Office/PDF Master/Class/Batch/WindowController/VC/KMBatchOperateImageToPDFViewController.xib
  5. 17 1
      PDF Office/PDF Master/Class/ChromiumTabs/KMBrowserWindowController.swift
  6. 5 0
      PDF Office/PDF Master/Class/ChromiumTabs/src/Tab Strip/CTTabStripDragController.m
  7. 2 2
      PDF Office/PDF Master/Class/Common/Base/KMBaseWindowController.swift
  8. 7 7
      PDF Office/PDF Master/Class/GuideInfo/Controllers/FunctionGuide/KMCustomColorGuideView.xib
  9. 5 1
      PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController+Action.swift
  10. 26 15
      PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController.swift
  11. 1 1
      PDF Office/PDF Master/Class/PDFTools/Compare/View/KMCompareView.swift
  12. 2 2
      PDF Office/PDF Master/Class/PDFTools/Compare/ViewController/ContentComplete/View/KMCompareContentView.swift
  13. 1 1
      PDF Office/PDF Master/Class/PDFTools/Compress/Controller/KMCompressWIndowControllerNew.swift
  14. 2 2
      PDF Office/PDF Master/Class/PDFTools/Convert/NewController/KMConvertWindowController.swift
  15. 6 7
      PDF Office/PDF Master/Class/PDFTools/Crop/KMPDFCropWindowController.swift
  16. 2 2
      PDF Office/PDF Master/Class/PDFTools/Insert/KMPDFInsertWindowController.swift
  17. 22 2
      PDF Office/PDF Master/Class/PDFTools/Merge/MergeNew/KMMergeWindowController.swift
  18. 1 1
      PDF Office/PDF Master/Class/PDFTools/Merge/MergeNew/View/KMMergeView.swift
  19. 2 3
      PDF Office/PDF Master/Class/PDFTools/Merge/Model/KMFileAttribute.swift
  20. 1 1
      PDF Office/PDF Master/Class/PDFTools/OCRNew/Controller/KMOCRPDFWindowController.swift
  21. 2 2
      PDF Office/PDF Master/Class/PDFTools/PageEdit/Window/KMPDFEditInsertPageWindow.swift
  22. 1 1
      PDF Office/PDF Master/Class/PDFTools/PageEdit/Window/SplitWindowController.swift
  23. 8 9
      PDF Office/PDF Master/Class/PDFTools/Secure/Window/KMPasswordInputWindow.swift
  24. 2 2
      PDF Office/PDF Master/Class/PDFTools/Secure/Window/KMPasswordInputWindow.xib
  25. 2 0
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/Split/KMSecondaryViewController.h
  26. 13 4
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/Split/KMSecondaryViewController.m
  27. 6 6
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/Split/KMSecondaryViewController.xib
  28. 1 1
      PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController+Thumbnail.swift
  29. 2 2
      PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController.swift
  30. 19 19
      PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/KMPropertiesViewPopController.swift
  31. 1 1
      PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/StampList/KMAnnotationStampViewController.swift
  32. 1 1
      PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMToolbarItemView.swift
  33. 3 1
      PDF Office/PDF Master/Class/PDFWindowController/Tools/FMTrackEventManager.swift
  34. 9 11
      PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift
  35. 5 3
      PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift
  36. 1 1
      PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController.swift
  37. 2 17
      PDF Office/PDF Master/Class/Preference/Controller/KMDisplayPreferences.swift
  38. 0 45
      PDF Office/PDF Master/Class/Preference/Controller/KMGeneralPreferences.swift
  39. 14 9
      PDF Office/PDF Master/Class/Preference/Controller/KMSyncPreferences.swift
  40. 120 130
      PDF Office/PDF Master/Class/Preference/Tools/KMPreferenceManager.swift
  41. 5 3
      PDF Office/PDF Master/Class/Preference/View/KMFontWell.swift
  42. 0 36
      PDF Office/PDF Master/Class/Preference/View/KMLineWell.swift
  43. 34 109
      PDF Office/PDF Master/Class/Preference/Window/KMPreferenceController.swift
  44. 2 0
      PDF Office/PDF Master/Strings/zh-Hans.lproj/Localizable.strings
  45. 2 0
      PDF Office/PDF Master/Strings/zh-Hant.lproj/Localizable.strings
  46. 15 63
      PDF Office/PDF Reader Pro.xcodeproj/xcuserdata/kdanmobile.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

+ 9 - 9
PDF Office/PDF Master/Base.lproj/Main.storyboard

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
+<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
     <dependencies>
         <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <scenes>
@@ -357,15 +357,15 @@
                                                 <action selector="saveArchive:" target="Ady-hI-5gd" id="bcQ-Wf-JtI"/>
                                             </connections>
                                         </menuItem>
-                                        <menuItem isSeparatorItem="YES" id="3X9-nS-taN">
+                                        <menuItem isSeparatorItem="YES" hidden="YES" id="3X9-nS-taN">
                                             <modifierMask key="keyEquivalentModifierMask" command="YES"/>
                                         </menuItem>
-                                        <menuItem title="Read Notes…" id="Bra-Ld-saC">
+                                        <menuItem title="Read Notes…" hidden="YES" id="Bra-Ld-saC">
                                             <connections>
                                                 <action selector="readNotes:" target="Ady-hI-5gd" id="2gF-PJ-PUF"/>
                                             </connections>
                                         </menuItem>
-                                        <menuItem title="Convert Notes…" id="vJ1-Ny-iKH">
+                                        <menuItem title="Convert Notes…" hidden="YES" id="vJ1-Ny-iKH">
                                             <connections>
                                                 <action selector="convertNotes:" target="Ady-hI-5gd" id="xWf-K4-TwZ"/>
                                             </connections>
@@ -1273,10 +1273,10 @@ CA
                                                 </items>
                                             </menu>
                                         </menuItem>
-                                        <menuItem isSeparatorItem="YES" id="50l-Sr-fOo">
+                                        <menuItem isSeparatorItem="YES" hidden="YES" id="50l-Sr-fOo">
                                             <modifierMask key="keyEquivalentModifierMask" command="YES"/>
                                         </menuItem>
-                                        <menuItem title="Show Status Bar" keyEquivalent="I" id="sSx-1y-2RR">
+                                        <menuItem title="Show Status Bar" hidden="YES" keyEquivalent="I" id="sSx-1y-2RR">
                                             <connections>
                                                 <action selector="toggleStatusBar:" target="Ady-hI-5gd" id="PUg-ML-c3m"/>
                                             </connections>
@@ -1289,7 +1289,7 @@ CA
                                                 <action selector="toggleToolbarShow:" target="Ady-hI-5gd" id="L3r-JW-kIC"/>
                                             </connections>
                                         </menuItem>
-                                        <menuItem title="Customize Toolbar…" id="vza-bW-dOt">
+                                        <menuItem title="Customize Toolbar…" hidden="YES" id="vza-bW-dOt">
                                             <connections>
                                                 <action selector="runToolbarCustomizationPalette:" target="Ady-hI-5gd" id="MyM-5W-Ucw"/>
                                             </connections>
@@ -2050,7 +2050,7 @@ CA
                                             </connections>
                                         </menuItem>
                                         <menuItem isSeparatorItem="YES" id="ZQG-Mr-5hZ"/>
-                                        <menuItem title="Downloads" keyEquivalent="D" id="tyw-cv-T7k">
+                                        <menuItem title="Downloads" hidden="YES" keyEquivalent="D" id="tyw-cv-T7k">
                                             <connections>
                                                 <action selector="showDownloads:" target="Voe-Tx-rLC" id="6kK-HN-wZf"/>
                                             </connections>

+ 1 - 1
PDF Office/PDF Master/Class/Batch/WindowController/KMBatchOperateLeftViewController.swift

@@ -281,7 +281,7 @@ class KMBatchOperateLeftViewController: NSViewController,NSTableViewDelegate,NST
         
         if lockFilePathArr!.count > lockFileIndex {
             let filePath = lockFilePathArr![lockFileIndex] as! String
-            KMBaseWindowController.checkPassword(url: URL(fileURLWithPath: filePath)) { [unowned self] success, resultPassword in
+            KMBaseWindowController.checkPassword(url: URL(fileURLWithPath: filePath), type: .owner) { [unowned self] success, resultPassword in
                 self.closePwd()
                 if !resultPassword.isEmpty {
                     let file = KMBatchOperateFile(filePath: filePath, type: self.type!)

+ 1 - 1
PDF Office/PDF Master/Class/Batch/WindowController/VC/KMBatchOperateImageToPDFViewController.swift

@@ -504,7 +504,7 @@ class KMBatchOperateImageToPDFViewController: KMBatchOperateBaseViewController,
                 }
                 
                 if document.isLocked {
-                    KMBaseWindowController.checkPassword(url: url) { [unowned self] success, resultPassword in
+                    KMBaseWindowController.checkPassword(url: url, type: .owner) { [unowned self] success, resultPassword in
                         if success {
                             self.password = password
                             self.appendTextField.stringValue = url.path

+ 9 - 9
PDF Office/PDF Master/Class/Batch/WindowController/VC/KMBatchOperateImageToPDFViewController.xib

@@ -134,7 +134,7 @@
                     </buttonCell>
                 </button>
                 <button horizontalHuggingPriority="750" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="gJA-ad-BvI">
-                    <rect key="frame" x="212" y="97" width="26" height="26"/>
+                    <rect key="frame" x="440" y="97" width="26" height="26"/>
                     <buttonCell key="cell" type="help" bezelStyle="helpButton" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Ik9-0w-YNF">
                         <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                         <font key="font" metaFont="system"/>
@@ -148,13 +148,13 @@
                     </connections>
                 </button>
                 <box boxType="custom" cornerRadius="1" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="0xe-05-6j8">
-                    <rect key="frame" x="34" y="99" width="176" height="24"/>
+                    <rect key="frame" x="34" y="99" width="404" height="24"/>
                     <view key="contentView" id="Sfo-EK-dRW">
-                        <rect key="frame" x="1" y="1" width="174" height="22"/>
+                        <rect key="frame" x="1" y="1" width="402" height="22"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
                             <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Que-YG-sCE">
-                                <rect key="frame" x="0.0" y="-2" width="170" height="24"/>
+                                <rect key="frame" x="0.0" y="-2" width="398" height="24"/>
                                 <buttonCell key="cell" type="bevel" bezelStyle="rounded" image="NSDescendingSortIndicator" imagePosition="right" alignment="left" imageScaling="proportionallyDown" inset="2" id="RHP-PZ-KGD">
                                     <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                     <font key="font" metaFont="system"/>
@@ -175,7 +175,6 @@
                     </view>
                     <constraints>
                         <constraint firstAttribute="height" constant="24" id="W4o-2n-HHz"/>
-                        <constraint firstAttribute="width" constant="176" id="bbE-xq-Vz0"/>
                     </constraints>
                 </box>
                 <button translatesAutoresizingMaskIntoConstraints="NO" id="DvB-9f-Xgt">
@@ -189,13 +188,13 @@
                     </connections>
                 </button>
                 <box boxType="custom" cornerRadius="1" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="xu7-RV-DKR">
-                    <rect key="frame" x="34" y="163" width="204" height="24"/>
+                    <rect key="frame" x="34" y="163" width="430" height="24"/>
                     <view key="contentView" id="U53-s6-6nW">
-                        <rect key="frame" x="1" y="1" width="202" height="22"/>
+                        <rect key="frame" x="1" y="1" width="428" height="22"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
                             <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="9go-Ka-u3z">
-                                <rect key="frame" x="0.0" y="-2" width="198" height="24"/>
+                                <rect key="frame" x="0.0" y="-2" width="424" height="24"/>
                                 <buttonCell key="cell" type="bevel" bezelStyle="rounded" image="NSDescendingSortIndicator" imagePosition="right" alignment="left" imageScaling="proportionallyDown" inset="2" id="2zY-MC-UG7">
                                     <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                     <font key="font" metaFont="system"/>
@@ -216,7 +215,6 @@
                     </view>
                     <constraints>
                         <constraint firstAttribute="height" constant="24" id="GZN-BA-UHl"/>
-                        <constraint firstAttribute="width" constant="204" id="eca-sg-oYC"/>
                     </constraints>
                 </box>
                 <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="LnK-B0-rGp">
@@ -245,6 +243,7 @@
                 <constraint firstItem="gJA-ad-BvI" firstAttribute="centerY" secondItem="0xe-05-6j8" secondAttribute="centerY" id="b5C-zZ-uoa"/>
                 <constraint firstItem="aPB-Pb-64w" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" constant="16" id="cm2-wz-AP3"/>
                 <constraint firstAttribute="trailing" secondItem="k0c-vv-NPP" secondAttribute="trailing" constant="16" id="dEN-Bs-9oC"/>
+                <constraint firstItem="xu7-RV-DKR" firstAttribute="trailing" secondItem="k0c-vv-NPP" secondAttribute="trailing" id="ePZ-m2-erM"/>
                 <constraint firstItem="mXd-Rx-c3O" firstAttribute="top" secondItem="0xe-05-6j8" secondAttribute="bottom" constant="11" id="evq-KN-Xwq"/>
                 <constraint firstItem="xu7-RV-DKR" firstAttribute="leading" secondItem="Sf1-WE-VzB" secondAttribute="leading" id="fyS-0U-CJM"/>
                 <constraint firstItem="LnK-B0-rGp" firstAttribute="top" secondItem="xu7-RV-DKR" secondAttribute="bottom" constant="16" id="g6b-iG-T0X"/>
@@ -253,6 +252,7 @@
                 <constraint firstItem="lwQ-xY-nsX" firstAttribute="leading" secondItem="aPB-Pb-64w" secondAttribute="leading" id="kVr-oh-CY2"/>
                 <constraint firstItem="DvB-9f-Xgt" firstAttribute="top" secondItem="hyp-2H-elp" secondAttribute="bottom" constant="18" id="kxm-lu-bCL"/>
                 <constraint firstItem="hyp-2H-elp" firstAttribute="leading" secondItem="aPB-Pb-64w" secondAttribute="leading" id="mdU-8E-lPS"/>
+                <constraint firstItem="gJA-ad-BvI" firstAttribute="trailing" secondItem="k0c-vv-NPP" secondAttribute="trailing" id="nTH-mg-Z0g"/>
                 <constraint firstItem="hyp-2H-elp" firstAttribute="top" secondItem="k0c-vv-NPP" secondAttribute="bottom" constant="32" id="qP4-2t-rG9"/>
                 <constraint firstItem="mXd-Rx-c3O" firstAttribute="leading" secondItem="0xe-05-6j8" secondAttribute="leading" id="rJ4-0r-4NH"/>
                 <constraint firstItem="HkY-4k-ShL" firstAttribute="top" relation="greaterThanOrEqual" secondItem="mXd-Rx-c3O" secondAttribute="bottom" constant="20" id="rqm-ei-Qo0"/>

+ 17 - 1
PDF Office/PDF Master/Class/ChromiumTabs/KMBrowserWindowController.swift

@@ -489,7 +489,23 @@ import Cocoa
             KMPrint("openDocument error: window is nil.", beep: true)
             return
         }
-        
+        if self.browser.tabCount() > 1 && !IAPProductsManager.default().isAvailableAllFunction() {
+            if !KMDataManager.default.isTabbingWin{
+                KMDataManager.default.isTabbingWin = true
+                let tabbingWin: KMTabbingHintWindowController = KMTabbingHintWindowController()
+                tabbingWin.selectCallBack = { [weak self] continueOrNot in
+                    KMDataManager.default.isTabbingWin = false
+                    if continueOrNot {
+                        self?.reopenDocument(forPaths: [])
+                    } else {
+                        
+                    }
+                }
+                self.km_beginSheet(windowC: tabbingWin)
+            }
+            return
+        }
+
         NSOpenPanel.km_open_multi_success(_window) { panel in
             panel.allowedFileTypes = KMTools.imageExtensions + KMTools.pdfExtensions
         } completion: { urls in

+ 5 - 0
PDF Office/PDF Master/Class/ChromiumTabs/src/Tab Strip/CTTabStripDragController.m

@@ -11,6 +11,7 @@
 #import "CTTabWindowController.h"
 #import "CTBrowserWindowController.h"
 #import "common.h"
+#import "IAPProductsManager.h"
 
 // Replicate specific 10.7 SDK declarations for building with prior SDKs.
 #if !defined(MAC_OS_X_VERSION_10_7) || \
@@ -73,6 +74,10 @@ const NSTimeInterval kTearDuration = 0.333;
             return NO;
         }
     }
+//    CTBrowserWindowController *tBrowserWindowController  = (CTBrowserWindowController *)draggedController_;
+    if (![IAPProductsManager defaultManager].isAvailableAllFunction /*&& tBrowserWindowController.browser.tabCount > 1*/) {
+        return NO;
+    }
 
 	NSWindowController* controller = [sourceWindow_ windowController];
 	if ([controller isKindOfClass:[CTTabWindowController class]]) {

+ 2 - 2
PDF Office/PDF Master/Class/Common/Base/KMBaseWindowController.swift

@@ -63,7 +63,7 @@ extension KMBaseWindowController {
 }
 
 extension KMBaseWindowController {
-    static func checkPassword(url: URL, password: String = "", completion: @escaping ((_ success: Bool, _ resultPassword: String) -> Void)) {
+    static func checkPassword(url: URL, type: KMPasswordInputWindowType, password: String = "", completion: @escaping ((_ success: Bool, _ resultPassword: String) -> Void)) {
         // 判断路径 + document
         guard let document = CPDFDocument.init(url: url) else {
             return completion(false, "")
@@ -92,7 +92,7 @@ extension KMBaseWindowController {
         
         // 弹密码弹窗
         Task { @MainActor in
-            KMPasswordInputWindow.openWindow(window: NSWindow.currentWindow(), url: url) { result , password in
+            KMPasswordInputWindow.openWindow(window: NSWindow.currentWindow(), type: type, url: url) { result , password in
                 if (result == .cancel) {
                     completion(false, "")
                     return

+ 7 - 7
PDF Office/PDF Master/Class/GuideInfo/Controllers/FunctionGuide/KMCustomColorGuideView.xib

@@ -1,8 +1,8 @@
 <?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="21507" 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="21507"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
@@ -40,7 +40,7 @@
                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="WB5-SO-mvF">
                             <rect key="frame" x="166" y="68" width="300" height="126"/>
                             <subviews>
-                                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="tvJ-xF-71m">
+                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="tvJ-xF-71m">
                                     <rect key="frame" x="18" y="89" width="96" height="17"/>
                                     <textFieldCell key="cell" alignment="left" title="PDF to Office" id="CH9-8z-XVt">
                                         <font key="font" metaFont="systemBold" size="14"/>
@@ -48,7 +48,7 @@
                                         <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                                     </textFieldCell>
                                 </textField>
-                                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="rWm-ru-kMX">
+                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="rWm-ru-kMX">
                                     <rect key="frame" x="18" y="64" width="264" height="17"/>
                                     <constraints>
                                         <constraint firstAttribute="width" constant="260" id="Bw4-qg-ejW"/>
@@ -59,13 +59,13 @@
                                         <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                                     </textFieldCell>
                                 </textField>
-                                <box boxType="custom" borderType="line" cornerRadius="2" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="WX1-bZ-Pfr" customClass="KMBox">
+                                <box boxType="custom" borderType="line" cornerRadius="2" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="WX1-bZ-Pfr" customClass="KMBox" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                     <rect key="frame" x="226" y="20" width="54" height="24"/>
                                     <view key="contentView" id="3pq-7c-eUt">
                                         <rect key="frame" x="1" y="1" width="52" height="22"/>
                                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                         <subviews>
-                                            <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="WQ7-ua-ZcP">
+                                            <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="WQ7-ua-ZcP">
                                                 <rect key="frame" x="7" y="3" width="39" height="16"/>
                                                 <textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="Next" id="QAH-51-4An">
                                                     <font key="font" metaFont="systemBold"/>
@@ -73,7 +73,7 @@
                                                     <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                                                 </textFieldCell>
                                             </textField>
-                                            <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="rx1-Rj-nA5" customClass="KMButton">
+                                            <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="rx1-Rj-nA5" customClass="KMButton" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                                 <rect key="frame" x="0.0" y="0.0" width="52" height="22"/>
                                                 <buttonCell key="cell" type="bevel" bezelStyle="rounded" alignment="center" imageScaling="proportionallyDown" inset="2" id="PMy-In-n4q">
                                                     <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>

+ 5 - 1
PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController+Action.swift

@@ -460,6 +460,10 @@ extension KMHomeViewController {
                 alert.runModal()
                 return
             }
+            if needShowTabbingHintWindow() {
+                showTabbingHintWindow()
+                return
+            }
             NSDocumentController.shared.openDocument(withContentsOf: path, display: true) { document, documentWasAlreadyOpen, error in
                 if error != nil {
                     NSApp.presentError(error!)
@@ -1283,7 +1287,7 @@ extension KMHomeViewController {
                 return
             }
             
-            KMBaseWindowController.checkPassword(url: URL(fileURLWithPath: openPanel.url!.path)) { [unowned self] success, resultPassword in
+            KMBaseWindowController.checkPassword(url: URL(fileURLWithPath: openPanel.url!.path), type: .owner) { [unowned self] success, resultPassword in
                 if success {
                     DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) {
                         let controller = KMCompareWindowController(windowNibName: "KMCompareWindowController")

+ 26 - 15
PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController.swift

@@ -660,21 +660,8 @@ extension KMHomeViewController: NSPopoverDelegate {
 
 extension KMHomeViewController {
     func openPDFAction(_ sender: KMBox) {
-        let controll: KMBrowserWindowController? = self.view.window?.windowController as? KMBrowserWindowController
-        if controll?.browser.tabCount() ?? 0 > 1 && !IAPProductsManager.default().isAvailableAllFunction() {
-            if !KMDataManager.default.isTabbingWin{
-                KMDataManager.default.isTabbingWin = true
-                let tabbingWin: KMTabbingHintWindowController = KMTabbingHintWindowController()
-                tabbingWin.selectCallBack = { [weak self] continueOrNot in
-                    KMDataManager.default.isTabbingWin = false
-                    if continueOrNot {
-                        self?.reopenDocument(forPaths: [])
-                    } else {
-                        
-                    }
-                }
-                self.km_beginSheet(windowC: tabbingWin)
-            }
+        if needShowTabbingHintWindow() {
+            showTabbingHintWindow()
             return
         }
         let openPanel = NSOpenPanel()
@@ -689,6 +676,30 @@ extension KMHomeViewController {
         }
     }
     
+    func needShowTabbingHintWindow() -> Bool {
+        let controll: KMBrowserWindowController? = self.view.window?.windowController as? KMBrowserWindowController
+        if controll?.browser.tabCount() ?? 0 > 1 && !IAPProductsManager.default().isAvailableAllFunction() {
+            return true
+        }
+        return false
+    }
+    
+    func showTabbingHintWindow(){
+        if !KMDataManager.default.isTabbingWin{
+            KMDataManager.default.isTabbingWin = true
+            let tabbingWin: KMTabbingHintWindowController = KMTabbingHintWindowController()
+            tabbingWin.selectCallBack = { [weak self] continueOrNot in
+                KMDataManager.default.isTabbingWin = false
+                if continueOrNot {
+                    self?.reopenDocument(forPaths: [])
+                } else {
+                    
+                }
+            }
+            self.km_beginSheet(windowC: tabbingWin)
+        }
+    }
+    
     func creatPDFAction(_ sender: KMBox) {
         let popViewDataArr: [String] = [NSLocalizedString("New Blank Page", comment: ""),
                                         NSLocalizedString("New From Images", comment: ""),

+ 1 - 1
PDF Office/PDF Master/Class/PDFTools/Compare/View/KMCompareView.swift

@@ -495,7 +495,7 @@ extension KMCompareView {
                 completion(nil)
                 return
             } else {
-                KMBaseWindowController.checkPassword(url: NSURL(fileURLWithPath: filePath) as URL) { success, resultPassword in
+                KMBaseWindowController.checkPassword(url: NSURL(fileURLWithPath: filePath) as URL, type: .owner) { success, resultPassword in
                     if success {
                         let file = KMFileAttribute()
                         file.pdfDocument = pdfDocument

+ 2 - 2
PDF Office/PDF Master/Class/PDFTools/Compare/ViewController/ContentComplete/View/KMCompareContentView.swift

@@ -686,8 +686,8 @@ class KMCompareContentView: KMBaseXibView, CPDFViewDelegate, KMCompareToolbarDel
 
             var x = max(self.pdfoldViewSPoint.x, 0)
             var y = max(self.pdfoldViewSPoint.y + offsetY, 0)
-            self.pdfOldView.documentView().contentView.scroll(NSPoint(x: x, y: y))
-//            self.pdfOldView.documentView().contentView.scroll(KMSafePoint(x: x, y: y))
+//            self.pdfOldView.documentView().contentView.scroll(NSPoint(x: x, y: y))
+            self.pdfOldView.documentView().contentView.scroll(KMSafePoint(x: x, y: y))
 
             NSObject.cancelPreviousPerformRequests(withTarget: self, selector: #selector(scrollFinishEvent), object: nil)
             self.perform(#selector(scrollFinishEvent), with: nil, afterDelay: 0.25)

+ 1 - 1
PDF Office/PDF Master/Class/PDFTools/Compress/Controller/KMCompressWIndowControllerNew.swift

@@ -23,7 +23,7 @@ class KMCompressWIndowControllerNew: KMBaseWindowController {
             if self.password.count != 0 {
                 self.compressView.documentURL = self.documentURL
             } else {
-                KMBaseWindowController.checkPassword(url: documentURL) { [unowned self] success, paasswordString in
+                KMBaseWindowController.checkPassword(url: documentURL, type: .owner) { [unowned self] success, paasswordString in
                     if success {
                         self.password = paasswordString
                         self.compressView.documentURL = self.documentURL

+ 2 - 2
PDF Office/PDF Master/Class/PDFTools/Convert/NewController/KMConvertWindowController.swift

@@ -115,7 +115,7 @@ let kConvertFileSavePath = (kTempSavePath?.stringByAppendingPathComponent("conve
         if (isLoc) {
             DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.5) {
                 let url = self.pdfDocument?.documentURL
-                KMBaseWindowController.checkPassword(url: url!) { [unowned self] success, resultPassword in
+                KMBaseWindowController.checkPassword(url: url!, type: .owner) { [unowned self] success, resultPassword in
                     if success {
                         self.lockPassword = resultPassword
                         self.pdfDocument?.unlock(withPassword: resultPassword)
@@ -141,7 +141,7 @@ let kConvertFileSavePath = (kTempSavePath?.stringByAppendingPathComponent("conve
             self.showWaitting()
             DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
                 let url = URL(fileURLWithPath: self.pdfDocument!.documentURL.path)
-                KMBaseWindowController.checkPassword(url: url) { result, password in
+                KMBaseWindowController.checkPassword(url: url, type: .owner) { result, password in
                     self.hideWaitting()
                     if password.count > 0 {
                         let unlockSuccess: Bool = ((self.pdfDocument?.unlock(withPassword: password)) != nil)

+ 6 - 7
PDF Office/PDF Master/Class/PDFTools/Crop/KMPDFCropWindowController.swift

@@ -82,6 +82,8 @@ class KMPDFCropWindowController: NSWindowController, CPDFViewDelegate, NSWindowD
     @IBOutlet var pdfView: KMCropPDFView!
     @IBOutlet var cropLabel: NSTextField!
     
+    var fileAttribute: KMFileAttribute!
+    
     var isChangePageSize = false
     var cropWindowCloseBlock: cropWindowCloseBlock?
     
@@ -118,7 +120,8 @@ class KMPDFCropWindowController: NSWindowController, CPDFViewDelegate, NSWindowD
     override func windowDidLoad() {
         super.windowDidLoad()
         self.cropRect = self.defaultCropRect
-        
+        fileAttribute = KMFileAttribute()
+        fileAttribute.filePath = self.originalDocument?.documentURL.path ?? ""
         self.pdfView.wantsLayer = true
         self.pdfView.layer?.borderColor = NSColor.black.cgColor
         self.pdfView.layer?.borderWidth = 2
@@ -265,15 +268,10 @@ class KMPDFCropWindowController: NSWindowController, CPDFViewDelegate, NSWindowD
                 }
             }
         } else {
-            let fileAttribute = KMFileAttribute()
-            fileAttribute.filePath = self.originalDocument?.documentURL.path ?? ""
             fileAttribute.bAllPage = false
+            fileAttribute.pagesType = .custom
             fileAttribute.pagesString = self.pageRangeComboBox.stringValue
             
-//            if !fileAttribute.selectPages {
-//                
-//            }
-            
             for num in fileAttribute.fetchSelectPages() {
                 pages.add(num - 1)
             }
@@ -985,6 +983,7 @@ class KMPDFCropWindowController: NSWindowController, CPDFViewDelegate, NSWindowD
             self.previewDocument?.insertPageObject(page, at: self.previewDocument?.pageCount ?? 0)
         }
         self.pdfView.document = self.previewDocument
+        self.pdfView.layoutDocumentView()
         self.pdfView.needsDisplay = true
         let tPage = self.previewDocument?.page(at: 0)!
         self.pdfView.go(to: tPage)

+ 2 - 2
PDF Office/PDF Master/Class/PDFTools/Insert/KMPDFInsertWindowController.swift

@@ -135,7 +135,7 @@ class KMPDFInsertWindowController: KMBaseWindowController {
         self.locationRangePopUpButton.isEnabled = false
         
         if let data = self._pdfDocument?.isLocked, data {
-            Self.checkPassword(url: self._pdfDocument!.documentURL) { [weak self] success, resultPassword in
+            Self.checkPassword(url: self._pdfDocument!.documentURL, type: .owner) { [weak self] success, resultPassword in
                 if success {
                     self?._pdfDocument?.unlock(withPassword: resultPassword)
                     self?._password = resultPassword
@@ -361,7 +361,7 @@ class KMPDFInsertWindowController: KMBaseWindowController {
                     }
                     
                     if (pdfDoc.isLocked) {
-                        Self.checkPassword(url: fileURL) { [weak self] success, resultPassword in
+                        Self.checkPassword(url: fileURL, type: .owner) { [weak self] success, resultPassword in
                             if success {
                                 self?._fromFilePassword = resultPassword
                                 self?._fromFilePath = fileURL

+ 22 - 2
PDF Office/PDF Master/Class/PDFTools/Merge/MergeNew/KMMergeWindowController.swift

@@ -24,6 +24,7 @@ class KMMergeWindowController: KMBaseWindowController {
     var oriDucumentUrl: URL? {
         didSet {
             oldPDFDocument = PDFDocument(url: oriDucumentUrl!)!
+            oldPDFDocument.unlock(withPassword: self.password)
         }
     }
     
@@ -54,6 +55,7 @@ class KMMergeWindowController: KMBaseWindowController {
 //    }
     convenience init(document: PDFDocument, password: String) {
         self.init(windowNibName: "KMMergeWindowController")
+        self.password = password
         
     }
     
@@ -229,8 +231,26 @@ extension KMMergeWindowController {
                 self.handleReDraw()
                 
                 if self.oriDucumentUrl != nil {
-                    var success = self.oldPDFDocument.write(toFile: self.oldPDFDocument.documentURL!.path)
-                    self.mergeAction?(self, self.oldPDFDocument.documentURL!.path)
+                    
+                    let newPath = self.oldPDFDocument.documentURL!.path
+                    var options: [PDFDocumentWriteOption : Any] = [:]
+                    var success = false
+                    let password = self.password
+                    let pdf = self.oldPDFDocument
+                    if pdf.isEncrypted {
+                        options.updateValue(password, forKey: .userPasswordOption)
+                        options.updateValue(password, forKey: .ownerPasswordOption)
+                        success = pdf.write(toFile: newPath, withOptions: options)
+                    } else {
+                        success = pdf.write(toFile: newPath)
+                    }
+                    
+//                    var success = self.oldPDFDocument.write(toFile: self.oldPDFDocument.documentURL!.path)
+                    if success {
+                        self.mergeAction?(self, self.oldPDFDocument.documentURL!.path)
+                    } else {
+                        print("合并失败")
+                    }
                 } else {
                     let savePanelAccessoryViewController = KMSavePanelAccessoryController.init()
                     let savePanel = NSSavePanel()

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

@@ -385,7 +385,7 @@ extension KMMergeView {
     func openPasswordFile(completion: @escaping ((_ success: Bool, _ resultPassword: String) -> Void)) {
         if lockFiles.count != 0 {
             let file = lockFiles[lockFilesIndex]
-            KMBaseWindowController.checkPassword(url: URL(fileURLWithPath: file.filePath)) { [unowned self] success, resultPassword in
+            KMBaseWindowController.checkPassword(url: URL(fileURLWithPath: file.filePath), type: .owner) { [unowned self] success, resultPassword in
                 if success {
                     file.password = resultPassword
                     lockFilesIndex = lockFilesIndex + 1

+ 2 - 3
PDF Office/PDF Master/Class/PDFTools/Merge/Model/KMFileAttribute.swift

@@ -46,14 +46,13 @@ import Cocoa
     func reloadData() {
         if filePath.count != 0 {
             let attribe = try?FileManager.default.attributesOfItem(atPath: filePath)
-            fileSize = attribe?[FileAttributeKey.size] as! CGFloat
+            fileSize = attribe?[FileAttributeKey.size] as? CGFloat ?? 0
             
             let document = CPDFDocument.init(url: URL(fileURLWithPath: filePath))
             document?.unlock(withPassword: self.password)
-            isLocked = document!.isLocked
+            isLocked = document?.isLocked ?? false
             self.pdfDocument = document
             
-            
             let page = document?.page(at: 0) ?? CPDFPage()
             let image = page.thumbnail(of: page.size)
             fileImage = image ?? NSImage()

+ 1 - 1
PDF Office/PDF Master/Class/PDFTools/OCRNew/Controller/KMOCRPDFWindowController.swift

@@ -212,7 +212,7 @@ class KMOCRPDFWindowController: NSWindowController, NSWindowDelegate, KMGOCRMana
         if !(self.pdfDocument?.isLocked ?? false) && ((self.pdfDocument?.unlock(withPassword: self.password)) != nil) {
             
         } else {
-            KMBaseWindowController.checkPassword(url: self.pdfDocument!.documentURL) { success, pwd in
+            KMBaseWindowController.checkPassword(url: self.pdfDocument!.documentURL, type: .owner) { success, pwd in
                 if success {
                     self.pdfDocument?.unlock(withPassword: pwd)
                     self.password = pwd

+ 2 - 2
PDF Office/PDF Master/Class/PDFTools/PageEdit/Window/KMPDFEditInsertPageWindow.swift

@@ -140,7 +140,7 @@ class KMPDFEditInsertPageWindow: NSWindowController {
         
         if let data = self.pdfDocument?.isLocked, data {
             DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
-                KMBaseWindowController.checkPassword(url: self.pdfDocument!.documentURL) { success, resultPassword in
+                KMBaseWindowController.checkPassword(url: self.pdfDocument!.documentURL, type: .owner) { success, resultPassword in
                     if (resultPassword.isEmpty == false) {
                         self.pdfDocument?.unlock(withPassword: resultPassword)
                         self._password = resultPassword
@@ -325,7 +325,7 @@ class KMPDFEditInsertPageWindow: NSWindowController {
                     let pdfDoc = CPDFDocument(url: fileURL)
                     if let data = pdfDoc?.isLocked, data {
                         DispatchQueue.main.asyncAfter(deadline: .now()+0.5) {
-                            KMBaseWindowController.checkPassword(url: fileURL) { result, pwd in
+                            KMBaseWindowController.checkPassword(url: fileURL, type: .owner) { result, pwd in
                                 if (pwd.isEmpty == false) {
                                     self._password = pwd
                                     self.fromFilePath = fileURL

+ 1 - 1
PDF Office/PDF Master/Class/PDFTools/PageEdit/Window/SplitWindowController.swift

@@ -425,7 +425,7 @@ extension SplitWindowController {
     private func _setInputRange() {
         if let data = self._PDFDocument?.isLocked, data {
             if let url = self._fileURL {
-                Self.checkPassword(url: url) { [weak self] success, pwd in
+                Self.checkPassword(url: url, type: .owner) { [weak self] success, pwd in
                     if success {
                         self?.password = pwd
                         self?._PDFDocument?.unlock(withPassword: pwd)

+ 8 - 9
PDF Office/PDF Master/Class/PDFTools/Secure/Window/KMPasswordInputWindow.swift

@@ -85,15 +85,11 @@ private var passwordInputWindow_private: KMPasswordInputWindow?
                 
                 let ps = NSMutableParagraphStyle()
                 ps.lineSpacing = 5
-//                ps.lineBreakMode = .byTruncatingTail
-//                if (newValue == .open) {
-//                    despLabel!.stringValue = "\"\(fileName)\"\(NSLocalizedString("is protected, please enter a Document Open Password.", comment: ""))"
-//                    despLabel!.attributedStringValue = NSAttributedString(string: despLabel!.stringValue, attributes: [.foregroundColor : NSColor.titleColor(), .font : NSFont.SFProTextRegularFont(14), .paragraphStyle : ps])
-//                } else {
-                    despLabel!.stringValue = "\"\(fileName)\"\(NSLocalizedString("is protected, please enter the password to unlock it.", comment: ""))"
+
+                    despLabel!.stringValue = "\"\(fileName)\"\(NSLocalizedString("This PDF is password protected. Please enter the password below to access this PDF.", comment: ""))"
                     despLabel!.attributedStringValue = NSAttributedString(string: despLabel!.stringValue, attributes: [.foregroundColor : NSColor.titleColor(), .font : NSFont.SFProTextRegularFont(14), .paragraphStyle : ps])
-//                }
             }
+            
         }
     }
     
@@ -121,7 +117,7 @@ private var passwordInputWindow_private: KMPasswordInputWindow?
         }
         
         if despLabel != nil {
-            despLabel.stringValue = NSLocalizedString("is protected, please enter the password to unlock it.", comment: "")
+            despLabel.stringValue = NSLocalizedString("This PDF is password protected. Please enter the password below to access this PDF.", comment: "")
             self.despLabel.textColor = NSColor.titleColor()
             despLabel.font = NSFont.SFProTextRegularFont(14)
             despLabel.isSelectable = false
@@ -191,7 +187,7 @@ private var passwordInputWindow_private: KMPasswordInputWindow?
         }
         
         if passwordErrorLabel != nil {
-            passwordErrorLabel.stringValue = NSLocalizedString("Password error", comment: "")
+            passwordErrorLabel.stringValue = NSLocalizedString("Incorrect password. Please try again.", comment: "")
             passwordErrorLabel.font = NSFont.systemFont(ofSize: 12)
             passwordErrorLabel.wantsLayer = true
             passwordErrorLabel.textColor = NSColor.km_init(hex: "#F3465B")
@@ -304,6 +300,7 @@ private var passwordInputWindow_private: KMPasswordInputWindow?
                 } else { /// 密码错误
                     if passwordErrorLabel != nil {
                         passwordErrorLabel.isHidden = false
+                        passwordErrorLabel.stringValue = NSLocalizedString("Incorrect password. Please try again.", comment: "")
                     }
                     if secureTextFiled != nil {
                         secureTextFiled.backgroundView.layer?.borderColor = NSColor.km_init(hex: "#F3465B").cgColor
@@ -329,6 +326,7 @@ private var passwordInputWindow_private: KMPasswordInputWindow?
                 } else { /// 密码错误
                     if passwordErrorLabel != nil {
                         passwordErrorLabel.isHidden = false
+                        passwordErrorLabel.stringValue = NSLocalizedString("Incorrect password. Please try again.", comment: "")
                     }
                     if secureTextFiled != nil {
                         secureTextFiled.backgroundView.layer?.borderColor = NSColor.km_init(hex: "#F3465B").cgColor
@@ -348,6 +346,7 @@ private var passwordInputWindow_private: KMPasswordInputWindow?
                 } else { /// 密码错误
                     if passwordErrorLabel != nil {
                         passwordErrorLabel.isHidden = false
+                        passwordErrorLabel.stringValue = NSLocalizedString("Incorrect password. Please try again.", comment: "")
                     }
                     if secureTextFiled != nil {
                         secureTextFiled.backgroundView.layer?.borderColor = NSColor.km_init(hex: "#F3465B").cgColor

+ 2 - 2
PDF Office/PDF Master/Class/PDFTools/Secure/Window/KMPasswordInputWindow.xib

@@ -1,8 +1,8 @@
 <?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">
+<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="22505"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>

+ 2 - 0
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/Split/KMSecondaryViewController.h

@@ -7,9 +7,11 @@
 
 #import <Cocoa/Cocoa.h>
 
+@class KMSecondaryViewController;
 @protocol KMSecondaryViewControllerDelegate <NSObject>
 @optional
 - (void)receivedFileUrl:(NSURL *)url;
+- (void)controllerDidClose:(KMSecondaryViewController *)controller;
 
 @end
 

+ 13 - 4
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/Split/KMSecondaryViewController.m

@@ -6,6 +6,7 @@
 //
 
 #import "KMSecondaryViewController.h"
+#import <PDF_Reader_Pro-Swift.h>
 
 #define FIXED_HEIGHT 195.0
 
@@ -85,19 +86,19 @@
     [super viewDidLoad];
     
     self.view.wantsLayer = YES;
-    self.view.layer.backgroundColor = NSColor.whiteColor.CGColor;
+    self.view.layer.backgroundColor = [KMAppearance KMColor_Layout_BG_Drak].CGColor;
         
     
     [_dragOrClickButtonLabel setStringValue:NSLocalizedString(@"Drag file here to open it", nil)];
-//    _dragOrClickButtonLabel.textColor = [KMAppearance KMColor_Layout_H1];
+    _dragOrClickButtonLabel.textColor = [KMAppearance KMColor_Layout_H1];
     
     _selectFileButton.wantsLayer = YES;
     _selectFileButton.layer.cornerRadius = 4;
     _selectFileButton.layer.masksToBounds = YES;
-//    _selectFileButton.layer.backgroundColor = [KMAppearance KMColor_Interactive_M0].CGColor;
+    _selectFileButton.layer.backgroundColor = [KMAppearance KMColor_Interactive_M0].CGColor;
     _selectFileButton.layer.cornerRadius = 1.0;
     _selectFileButton.title = NSLocalizedString(@"Select File", nil);
-//    [_selectFileButton setTitleColor:[KMAppearance KMColor_Layout_W0]];
+    [_selectFileButton setTitleColor:[KMAppearance KMColor_Layout_W0]];
     
     self.secondaryView.receivedFileUrlBlock = ^(NSURL *fileUrl) {
         if ([self.delegate respondsToSelector:@selector(receivedFileUrl:)]) {
@@ -106,6 +107,14 @@
     };
 }
 
+- (IBAction)closeSecondaryPdfView:(NSButton *)sender {
+    if ([self.delegate respondsToSelector:@selector(controllerDidClose:)]) {
+        [self.delegate controllerDidClose:self];
+    }
+    
+    [[NSNotificationCenter defaultCenter] postNotificationName:@"KMSplitSinglePageNotification" object:self];
+}
+
 //Adjust NSTextField width
 - (void)changeBenefitOfContrastLabelWidth:(CGFloat)widthFloat {
     _benefitOfContrastLabel_WidthLayout.constant = widthFloat;

+ 6 - 6
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/Split/KMSecondaryViewController.xib

@@ -32,7 +32,7 @@
                         <font key="font" metaFont="system"/>
                     </buttonCell>
                 </button>
-                <button hidden="YES" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="wmn-eL-Rge">
+                <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="wmn-eL-Rge">
                     <rect key="frame" x="534" y="657.5" width="20.5" height="24"/>
                     <constraints>
                         <constraint firstAttribute="width" constant="20" id="dGb-Vf-8wE"/>
@@ -43,7 +43,7 @@
                         <font key="font" metaFont="system"/>
                     </buttonCell>
                     <connections>
-                        <action selector="closeSecondaryPdfView:" target="-1" id="yr8-Se-sI3"/>
+                        <action selector="closeSecondaryPdfView:" target="-2" id="E5W-O6-BXq"/>
                     </connections>
                 </button>
                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="kTE-cG-rrO">
@@ -55,7 +55,7 @@
                                 <constraint firstAttribute="height" constant="140" id="Egz-J0-EPI"/>
                                 <constraint firstAttribute="width" constant="140" id="iaS-HP-zEF"/>
                             </constraints>
-                            <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" image="icon_empty_add_norm" id="JlM-1S-ZXY"/>
+                            <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" image="KMImageNameSplitEmpty" id="JlM-1S-ZXY"/>
                         </imageView>
                         <button verticalHuggingPriority="750" tag="10" translatesAutoresizingMaskIntoConstraints="NO" id="lHt-h3-ZMr">
                             <rect key="frame" x="50" y="112" width="200" height="40"/>
@@ -71,7 +71,7 @@
                                 <action selector="selectFileAction:" target="-2" id="Nzx-Jm-zi4"/>
                             </connections>
                         </button>
-                        <textField hidden="YES" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="0rM-Vt-X5j">
+                        <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="0rM-Vt-X5j">
                             <rect key="frame" x="44" y="84" width="212" height="20"/>
                             <constraints>
                                 <constraint firstAttribute="width" constant="208" id="ehi-uE-V6x"/>
@@ -82,7 +82,7 @@
                                 <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                             </textFieldCell>
                         </textField>
-                        <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="j6H-4w-adU">
+                        <button hidden="YES" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="j6H-4w-adU">
                             <rect key="frame" x="80" y="160" width="140" height="140"/>
                             <constraints>
                                 <constraint firstAttribute="height" constant="140" id="QdR-ZW-YA7"/>
@@ -123,6 +123,7 @@
         </customView>
     </objects>
     <resources>
+        <image name="KMImageNameSplitEmpty" width="200" height="200"/>
         <image name="NSStopProgressTemplate" width="14" height="13"/>
         <image name="buttonCell:iDk-4N-SVc:image" width="1" height="1">
             <mutableData key="keyedArchiveRepresentation">
@@ -389,6 +390,5 @@ HDwcPhxAHEIcSRxLHE0pwynIKdcp2ynmKe4p+yoIKh0qIiomKigqKiosKjUqOipAKkgqSipMKk4qUDvw
 O/U8AjwFPBI8FzwfPCI8JzwvAAAAAAAAAgEAAAAAAAAAaAAAAAAAAAAAAAAAAAAAPDI
 </mutableData>
         </image>
-        <image name="icon_empty_add_norm" width="128" height="128"/>
     </resources>
 </document>

+ 1 - 1
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController+Thumbnail.swift

@@ -450,7 +450,7 @@ extension KMLeftSideViewController {
                 let pdfDoc = CPDFDocument(url: fileURL)
                 if let data = pdfDoc?.isLocked, data {
                     DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
-                        KMBaseWindowController.checkPassword(url: fileURL) { [unowned self] success, resultPassword in
+                        KMBaseWindowController.checkPassword(url: fileURL, type: .owner) { [unowned self] success, resultPassword in
                             self.km_quick_endSheet()
                             if (resultPassword.isEmpty == false) {
                                 

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

@@ -1393,7 +1393,7 @@ extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
                             var insertIndexSet = IndexSet()
                             var pdf = CPDFDocument(url: URL(fileURLWithPath: path))
                             if let data = pdf?.isEncrypted, data {
-                                KMBaseWindowController.checkPassword(url: URL(fileURLWithPath: path)) { success, resultPassword in
+                                KMBaseWindowController.checkPassword(url: URL(fileURLWithPath: path), type: .owner) { success, resultPassword in
                                     if success && resultPassword.isEmpty == false {
                                         for i in 0 ..< (pdf?.pageCount ?? 0) {
                                             let page = pdf?.page(at: i).copy() as? CPDFPage
@@ -1482,7 +1482,7 @@ extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
                     let pdf = CPDFDocument(url: url!)
                     if let data = pdf?.isEncrypted, data {
 //                        KMDecryptWindowController *vc = [[KMDecryptWindowController alloc] init];
-                        KMBaseWindowController.checkPassword(url: url!) { success, resultPassword in
+                        KMBaseWindowController.checkPassword(url: url!, type: .owner) { success, resultPassword in
                             if success && resultPassword.isEmpty == false {
                                 pdf?.unlock(withPassword: resultPassword)
                                 for i in 0 ..< (pdf?.pageCount ?? 0) {

+ 19 - 19
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/KMPropertiesViewPopController.swift

@@ -22,31 +22,31 @@ import Cocoa
     static let defaultManager = KMPropertiesViewPopController()
 
     class func showChangeColorDetails() -> Bool {
-        let isOpenConvertDetails = UserDefaults.standard.bool(forKey: "KMPropertiesHaveChangeColorDetails")
-        if !isOpenConvertDetails {
+//        let isOpenConvertDetails = UserDefaults.standard.bool(forKey: "KMPropertiesHaveChangeColorDetails")
+//        if !isOpenConvertDetails {
             return true
-        }
-        return false
+//        }
+//        return false
     }
 
     func showChangeColorDetailsView(_ view: NSView) {
-        let popViewController = KMPropertiesViewPopController()
-        popViewController.block = { [weak self] in
-            self?.popOver?.close()
-        }
-        self.popOver = NSPopover()
-        self.popOver?.contentViewController = popViewController
-        self.popOver?.animates = false
-        self.popOver?.behavior = .transient
-//        self.popOver?.appearance = .minimal
-        self.popOver?.contentSize = popViewController.view.frame.size
         DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
-            if view.superview?.window == nil {
-                return
+            if KMGuideInfoWindowController.availableShow(.customColor) {
+                let guideWC = KMGuideInfoWindowController.currentWC()
+                guideWC.type = .customColor
+                guideWC.digitalBoxRect = view.superview?.convert(view.frame, to: view.window?.contentView) ?? .zero
+                var beh = view.window?.collectionBehavior ?? []
+                beh.insert(.canJoinAllSpaces)
+                guideWC.window?.collectionBehavior = beh
+                
+                var rect = view.window?.frame ?? .zero
+                rect.size.height -= 20
+                guideWC.window?.setFrame(rect, display: false)
+                guideWC.window?.minSize = rect.size
+                guideWC.window?.maxSize = rect.size
+                view.window?.addChildWindow(guideWC.window!, ordered: .above)
+                guideWC.show()
             }
-            UserDefaults.standard.set(true, forKey: "KMPropertiesHaveChangeColorDetails")
-            UserDefaults.standard.synchronize()
-            self.popOver?.show(relativeTo: view.bounds, of: view, preferredEdge: .maxY)
         }
     }
 

+ 1 - 1
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/StampList/KMAnnotationStampViewController.swift

@@ -1013,7 +1013,7 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
                     if filePath.pathExtension.lowercased() == "pdf" {
                         if let pdf = CPDFDocument(url: url), pdf.isEncrypted {
                             if #available(macOS 13.0, *) {
-                                KMBaseWindowController.checkPassword(url: URL(filePath: filePath)) { [unowned self] success, resultPassword in
+                                KMBaseWindowController.checkPassword(url: URL(filePath: filePath), type: .owner) { [unowned self] success, resultPassword in
                                     self!.addImageStamp(withSecurityPDFFilePath: filePath, password: resultPassword, removeBGColor: (accessoryCtr.selectedButton.state == .on))
                                 }
                             } else {

+ 1 - 1
PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMToolbarItemView.swift

@@ -652,7 +652,7 @@ extension KMToolbarItemView {
             self.imageViewBox.km_add_bottom_constraint(equalTo: self.nameBtn, attribute: .top, constant: 0)
         
             self.imageViewBox.contentView?.addSubview(self.imageViewBtn)
-            self.imageViewBtn.km_add_inset_constraint(inset: .init(top: 0, left: offset, bottom: 0, right: offset))
+            self.imageViewBtn.km_add_inset_constraint(inset: .init(top: 0.5, left: offset, bottom: 0, right: offset))
             self.itemHeight = 40
         }
             

+ 3 - 1
PDF Office/PDF Master/Class/PDFWindowController/Tools/FMTrackEventManager.swift

@@ -22,7 +22,9 @@ import AppCenterAnalytics
     func trackEvent(event: String, withProperties properties: [String: String]?) {
         if event.count < 1 { return }
 #if DEBUG
-        NSLog("###-FireBaseEvent-(event)-(properties?.first?.key)-(properties?.first?.value)")
+        let keyStr: String = properties?.keys.first ?? ""
+        let vStr: String = properties?.values.first ?? ""
+        NSLog("###-FireBaseEvent-(%@)-properties(%@):(%@)",event,keyStr,vStr)
 #endif
         // if RIAnalytics.isNewUserForCurrentVersion()
         if let props = properties {

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

@@ -3490,6 +3490,10 @@ extension KMMainViewController: KMSecondaryViewControllerDelegate {
             self.openSecondaryPdfView = nil
         }
     }
+    
+    func controllerDidClose(_ controller: KMSecondaryViewController!) {
+        self.singlePageScreen(isSinglePage: true, doublePagesScreen: false)
+    }
 }
 
 // MARK: -
@@ -4271,7 +4275,7 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
                         alert.beginSheetModal(for: NSWindow.currentWindow()) { returnCode in
                             if returnCode == .alertSecondButtonReturn {
                                 DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.25) { [unowned self] in
-                                    KMBaseWindowController.checkPassword(url: self.document!.documentURL!) { [unowned self] success, resultPassword in
+                                    KMBaseWindowController.checkPassword(url: self.document!.documentURL!, type: .owner) { [unowned self] success, resultPassword in
                                         if success {
                                             self.document?.unlock(withPassword: resultPassword)
                                             self.clickChildTool(type: .secure, index: 2)
@@ -4318,7 +4322,7 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
                             self.view.window?.endSheet((self.currentWindowController.window)!)
                             self.currentWindowController = nil
                             
-                            KMBaseWindowController.checkPassword(url: self.document!.documentURL!) { [unowned self] success, resultPassword in
+                            KMBaseWindowController.checkPassword(url: self.document!.documentURL!, type: .owner) { [unowned self] success, resultPassword in
                                 if success {
                                     /// 删除安全性设置
                                     if (!self.listView.document!.allowsCopying || !self.listView.document!.allowsPrinting) {
@@ -5034,19 +5038,13 @@ extension KMMainViewController {
         if (type == .Annatiton) {
             FMTrackEventManager.defaultManager.trackEvent(event: "Tbr", withProperties: ["Tbr_Btn" : "Btn_Tbr_Tools"])
         } else if (type == .editPDF) {
-//            KMAnalytics.trackEvent(eventName: "Btn_Tbr_EditPDF", parameters: [
-//                KMAnalytics.Parameter.categoryKey : KMAnalytics.Category.tbr,
-//                KMAnalytics.Parameter.labelKey : KMAnalytics.Label.tbr_Btn], platform: .AppCenter, appTarget: .all)
+
         } else if (type == .Page) {
             FMTrackEventManager.defaultManager.trackEvent(event: "Tbr", withProperties: ["Tbr_Btn" : "Btn_Tbr_PageEdit"])
         } else if (type == .Conversion) {
-//            KMAnalytics.trackEvent(eventName: "Btn_Tbr_Converter", parameters: [
-//                KMAnalytics.Parameter.categoryKey : KMAnalytics.Category.tbr,
-//                KMAnalytics.Parameter.labelKey : KMAnalytics.Label.tbr_Btn], platform: .AppCenter, appTarget: .all)
+
         } else if (type == .Tool) {
-//            KMAnalytics.trackEvent(eventName: "Btn_Tbr_Tools", parameters: [
-//                KMAnalytics.Parameter.categoryKey : KMAnalytics.Category.tbr,
-//                KMAnalytics.Parameter.labelKey : KMAnalytics.Label.tbr_Btn], platform: .AppCenter, appTarget: .all)
+
         }
     }
     

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

@@ -129,9 +129,11 @@ extension KMMainViewController: KMToolbarControllerDelegate {
     }
     
     func changeAnnotationModeAction(item: KMToolbarClickButton) {
-        if !IAPProductsManager.default().isAvailableAllFunction(){
-            KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
-            return
+        if self.listView.toolMode == .formToolMode {
+            if !IAPProductsManager.default().isAvailableAllFunction(){
+                KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
+                return
+            }
         }
         
         if (self.rightMouseEventing) {

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

@@ -310,7 +310,7 @@ let LOCKED_KEY  = "locked"
         
         DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.3) {
             if self.passwordWindow == nil {
-                self.passwordWindow = KMPasswordInputWindow.openWindow(window: NSWindow.currentWindow(), url: self.document!.documentURL) { [unowned self] result , password in
+                self.passwordWindow = KMPasswordInputWindow.openWindow(window: self.view.window!, url: self.document!.documentURL) { [unowned self] result , password in
                     self.passwordWindow = nil
                     if (result == .cancel) {
                         self.browserWindowController?.browser.closeTab()

+ 2 - 17
PDF Office/PDF Master/Class/Preference/Controller/KMDisplayPreferences.swift

@@ -40,10 +40,6 @@ import Cocoa
     
     var colorLabels: [NSTextField] = []
     var colorControls: [NSControl] = []
-    /*
-     - (NSUInteger)countOfSizes;
-     - (NSNumber *)objectInSizesAtIndex:(NSUInteger)anIndex;
-     */
     
     let SKDefaultFontSizes: [CGFloat] = [8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 16.0, 18.0, 20.0, 24.0, 28.0, 32.0, 48.0, 64.0]
     
@@ -171,8 +167,8 @@ import Cocoa
             slider1?.allowsTickMarkValuesOnly = true
             slider2?.allowsTickMarkValuesOnly = true
         } else {
-            slider1?.superview?.setNeedsDisplay(slider1!.frame)
-            slider2?.superview?.setNeedsDisplay(slider2!.frame)
+            slider1?.superview?.setNeedsDisplay(slider1?.frame ?? .zero)
+            slider2?.superview?.setNeedsDisplay(slider2?.frame ?? .zero)
             
             slider1?.numberOfTickMarks = 0
             slider2?.numberOfTickMarks = 0
@@ -202,17 +198,6 @@ import Cocoa
     @objc func invertBarAction(_ sender: NSButton) {
         KMPreference.shared.invertBar = sender.state == .on
     }
-    
-    /*
-     - (NSUInteger)countOfSizes {
-         return sizeof(SKDefaultFontSizes) / sizeof(CGFloat);
-     }
-
-     - (NSNumber *)objectInSizesAtIndex:(NSUInteger)anIndex {
-         return [NSNumber numberWithDouble:SKDefaultFontSizes[anIndex]];
-     }
-     */
-    
 }
 
 extension KMDisplayPreferences: KMPreferencePane {

+ 0 - 45
PDF Office/PDF Master/Class/Preference/Controller/KMGeneralPreferences.swift

@@ -61,30 +61,8 @@ class KMGeneralPreferences: NSViewController {
         }
     }
     
-    /*
-     static char KMGeneralPreferencesDefaultsObservationContext;
-     static char KMGeneralPreferencesUpdaterObservationContext;
-
-     @interface KMGeneralPreferences (Private)
-     - (void)synchronizeUpdateInterval;
-     - (void)updateRevertButtons;
-     @end
-     */
-    
     deinit {
         KMPrint("KMGeneralPreferences deinit.")
-        
-        /*
-         @try {
-             
-             [[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeys:[NSArray arrayWithObjects:SKStringConstants.defaultPDFDisplaySettingsKey, SKStringConstants.defaultFullScreenPDFDisplaySettingsKey, nil]];
-     #if VERSION_DMG
-             [[SUUpdater sharedUpdater] removeObserver:self forKeyPath:AUTOMATICALLYCHECKSFORUPDATES_KEY];
-             [[SUUpdater sharedUpdater] removeObserver:self forKeyPath:UPDATECHECKINTERVAL_KEY];
-     #endif
-         }
-         @catch(id e) {}
-         */
     }
     
     override var nibName: NSNib.Name? {
@@ -93,12 +71,6 @@ class KMGeneralPreferences: NSViewController {
     
     override func loadView() {
         super.loadView()
-    //    [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeys:[NSArray arrayWithObjects:SKStringConstants.defaultPDFDisplaySettingsKey, SKStringConstants.defaultFullScreenPDFDisplaySettingsKey, nil] context:&KMGeneralPreferencesDefaultsObservationContext];
-    //    [NSUserDefaultsController sharedUserDefaultsController]
-    #if VERSION_DMG
-//        [[SUUpdater sharedUpdater] addObserver:self forKeyPath:AUTOMATICALLYCHECKSFORUPDATES_KEY options:0 context:&KMGeneralPreferencesUpdaterObservationContext];
-//        [[SUUpdater sharedUpdater] addObserver:self forKeyPath:UPDATECHECKINTERVAL_KEY options:0 context:&KMGeneralPreferencesUpdaterObservationContext];
-    #endif
     }
     
     override func viewDidLoad() {
@@ -308,23 +280,6 @@ class KMGeneralPreferences: NSViewController {
          updateInterval = interval;
      }
 
-     #pragma mark Actions
-
-     
-
-     #pragma mark KVO
-
-     - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
-         if (context == &KMGeneralPreferencesDefaultsObservationContext)
-             [self updateRevertButtons];
-         else if (context == &KMGeneralPreferencesUpdaterObservationContext)
-             [self synchronizeUpdateInterval];
-         else
-             [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
-     }
-
-     @end
-
      */
     
     override var title: String? {

+ 14 - 9
PDF Office/PDF Master/Class/Preference/Controller/KMSyncPreferences.swift

@@ -41,8 +41,9 @@ class KMSyncPreferences: NSViewController {
     override func loadView() {
         super.loadView()
         
-        let initialUserDefaultsURL: URL = Bundle.main.url(forResource: INITIALUSERDEFAULTS_KEY, withExtension: "plist")!
-        TeXEditors = NSDictionary(contentsOf: initialUserDefaultsURL)?.object(forKey: TEXEDITORS_KEY) as! [[String : Any]]
+        if let initialUserDefaultsURL: URL = Bundle.main.url(forResource: INITIALUSERDEFAULTS_KEY, withExtension: "plist") {
+            TeXEditors = (NSDictionary(contentsOf: initialUserDefaultsURL)?.object(forKey: TEXEDITORS_KEY) as? [[String : Any]]) ?? [[:]]
+        }
         
         self.texEditorLabels = [self.presetLabel, self.commandLabel, self.argumentsLabel]
         self.texEditorControls = [self.presetButton, self.commandTextField, self.argumentsTextField]
@@ -57,21 +58,23 @@ class KMSyncPreferences: NSViewController {
         
         while i > 0 {
             i -= 1
-            let name = TeXEditors[i][NAME_KEY]
-            let path =  ws.fullPath(forApplication: name as! String)
+            let name = (TeXEditors[i][NAME_KEY] as? String) ?? ""
+            let path =  ws.fullPath(forApplication: name)
             
             let image = path != nil ? ws.icon(forFile: path!) : ws.icon(forFileType: NSFileTypeForHFSTypeCode(OSType(kGenericApplicationIcon)))
-            texEditorPopUpButton?.insertItem(withTitle: name as! String, at: 0)
+            texEditorPopUpButton?.insertItem(withTitle: name, at: 0)
             texEditorPopUpButton?.item(at: 0)?.setImageAndSize(image)
-            if (name as! String) == editorPreset {
-                idx = i;
+            if name == editorPreset {
+                idx = i
             }
         }
         
         self.customTeXEditor = idx == -1
         
         if (idx == -1) {
-            texEditorPopUpButton?.select(texEditorPopUpButton!.lastItem)
+            if let data = texEditorPopUpButton?.lastItem {
+                texEditorPopUpButton?.select(data)
+            }
         } else {
             texEditorPopUpButton?.selectItem(at: idx)
         }
@@ -141,7 +144,9 @@ extension KMSyncPreferences: KMPreferencePane {
         let editorPreset = UserDefaults.standard.string(forKey: SKTeXEditorPresetKey)
         let texEditorPopUpButton = self.presetButton
         if let data = editorPreset?.isEmpty, data {
-            texEditorPopUpButton?.select(texEditorPopUpButton!.lastItem)
+            if let value = texEditorPopUpButton?.lastItem {
+                texEditorPopUpButton?.select(value)
+            }
             self.customTeXEditor = true
         } else {
             texEditorPopUpButton?.selectItem(withTitle: editorPreset ?? "")

+ 120 - 130
PDF Office/PDF Master/Class/Preference/Tools/KMPreferenceManager.swift

@@ -240,10 +240,10 @@ typealias KMPreference = KMPreferenceManager
         if (UserDefaults.standard.value(forKey: KMPreferenceInfoKey) == nil) {
             info = self.getDefaultInfo()
         } else {
-            info = (UserDefaults.standard.value(forKey: KMPreferenceInfoKey) as! [String : Any])
+            info = (UserDefaults.standard.value(forKey: KMPreferenceInfoKey) as? [String : Any]) ?? [:]
         }
         
-        var groupInfo: [String : Any] = info![group.rawValue] as! [String : Any]
+        var groupInfo: [String : Any] = info?[group.rawValue] as? [String : Any] ?? [:]
         groupInfo.updateValue(data, forKey: key)
         
         info?.updateValue(groupInfo, forKey: group.rawValue)
@@ -265,10 +265,10 @@ typealias KMPreference = KMPreferenceManager
         if (UserDefaults.standard.value(forKey: KMPreferenceInfoKey) == nil) {
             info = self.getDefaultInfo()
         } else {
-            info = (UserDefaults.standard.value(forKey: KMPreferenceInfoKey) as! [String : Any])
+            info = (UserDefaults.standard.value(forKey: KMPreferenceInfoKey) as? [String : Any]) ?? [:]
         }
         
-        let groupInfo: [String : Any] = info![findGroup(forKey: key).rawValue] as! [String : Any]
+        let groupInfo: [String : Any] = info?[findGroup(forKey: key).rawValue] as? [String : Any] ?? [:]
         return groupInfo[key] as Any
     }
     
@@ -277,7 +277,7 @@ typealias KMPreference = KMPreferenceManager
         if (UserDefaults.standard.value(forKey: KMPreferenceInfoKey) == nil) {
             info = self.getDefaultInfo()
         } else {
-            info = (UserDefaults.standard.value(forKey: KMPreferenceInfoKey) as! [String : Any])
+            info = (UserDefaults.standard.value(forKey: KMPreferenceInfoKey) as? [String : Any]) ?? [:]
         }
         
         let groupInfo = self.getDefaultInfo()[group.rawValue]
@@ -779,7 +779,7 @@ extension KMPreferenceManager {
     
     var openLastUnlockedDocumentWhenAppStart: Bool {
         get {
-            return self.getData(forKey: KMOpenLastUnlockedDocumentWhenAppStartKey) as! Bool
+            return self.getData(forKey: KMOpenLastUnlockedDocumentWhenAppStartKey) as? Bool ?? true
         }
         set {
             let _ = self.setData(data: newValue, forKey: KMOpenLastUnlockedDocumentWhenAppStartKey)
@@ -788,7 +788,7 @@ extension KMPreferenceManager {
     
     var documentMaximunDisplayNumber: Int {
         get {
-            return self.getData(forKey: KMDocumentMaximunDisplayNumberKey) as! Int
+            return self.getData(forKey: KMDocumentMaximunDisplayNumberKey) as? Int ?? 10
         }
         set {
             let _ = self.setData(data: newValue, forKey: KMDocumentMaximunDisplayNumberKey)
@@ -797,7 +797,7 @@ extension KMPreferenceManager {
     
     var autoSave: Bool {
         get {
-            return self.getData(forKey: KMAutoSaveKey) as! Bool
+            return self.getData(forKey: KMAutoSaveKey) as? Bool ?? true
         }
         set {
             let _ = self.setData(data: newValue, forKey: KMAutoSaveKey)
@@ -806,7 +806,7 @@ extension KMPreferenceManager {
     
     var autoSavePerNumberMinute: Int {
         get {
-            return self.getData(forKey: KMAutoSavePerNumberMinuteKey) as! Int
+            return self.getData(forKey: KMAutoSavePerNumberMinuteKey) as? Int ?? 5
         }
         set {
             let _ = self.setData(data: newValue, forKey: KMAutoSavePerNumberMinuteKey)
@@ -815,9 +815,10 @@ extension KMPreferenceManager {
     
     var closeFilePromptType: KMPreferenceCloseFilePromptType {
         get {
-            let type: Int? = self.getData(forKey: KMCloseFilePromptTypeKey) as? Int
-            if (type != nil && type! == 1) { // 无提示,直接保存
-                return .noPromp
+            if let type = self.getData(forKey: KMCloseFilePromptTypeKey) as? Int {
+                if type == 1 { // 无提示,直接保存
+                    return .noPromp
+                }
             }
             
             return .promp
@@ -831,7 +832,7 @@ extension KMPreferenceManager {
     
     var openImageFileType: Int {
         get {
-            return self.getData(forKey: KMOpenImageFileTypeKey) as! Int
+            return self.getData(forKey: KMOpenImageFileTypeKey) as? Int ?? 0
         }
         set {
             let _ = self.setData(data: newValue, forKey: KMOpenImageFileTypeKey)
@@ -841,7 +842,6 @@ extension KMPreferenceManager {
     var author: String {
         get {
             return KMDataManager.ud_string(forKey: KMUserNameKey) ?? NSFullUserName()
-//            return self.getData(forKey: KMGeneralAuthorNameKey) as! String
         }
         set {
             self._syncDataToUserDefault(newValue, forKey: KMGeneralAuthorNameKey)
@@ -851,7 +851,7 @@ extension KMPreferenceManager {
     
     var setDefaultPDFReader: Bool {
         get {
-            return self.getData(forKey: KMSetDefaultPDFReaderKey) as! Bool
+            return self.getData(forKey: KMSetDefaultPDFReaderKey) as? Bool ?? true
         }
         set {
             let result = KMTools.setDefaultPDFReader(newValue)
@@ -863,18 +863,6 @@ extension KMPreferenceManager {
     
     var savePasswordType: KMPreferenceSavePasswordType {
         get {
-//            let type: Int? = self.getData(forKey: KMSavePasswordTypeKey) as? Int
-//            if (type == nil || type! == 2) {
-//                return .ask
-//            }
-//            if (type! == 0) {
-//                return .always
-//            } else if (type! == 1) {
-//                return .never
-//            }
-//
-//            return .ask
-            
             let type = KMDataManager.ud_integer(forKey: KMSavePasswordOptionKey)
             if type == -1 {
                 return .ask
@@ -1022,22 +1010,21 @@ extension KMPreferenceManager {
 extension KMPreferenceManager {
     var viewPageDisplayType: KMPDFDisplayType {
         get {
-            let type: Int? = self.getData(forKey: KMViewPageDisplayTypeKey) as? Int
-            if (type == nil || type == 1) {
-                return .singlePageContinuous
-            }
-            if (type! == 0) {
-                return .singlePage
-            } else if (type! == 2) {
-                return .twoUp
-            } else if (type! == 3) {
-                return .twoUpContinuous
-            } else if (type! == 4) {
-                return .bookMode
-            } else if (type! == 5) {
-                return .bookContinuous
+            if let type = self.getData(forKey: KMViewPageDisplayTypeKey) as? Int {
+                if (type == 0) {
+                    return .singlePage
+                } else if type == 1 {
+                    return .singlePageContinuous
+                } else if (type == 2) {
+                    return .twoUp
+                } else if (type == 3) {
+                    return .twoUpContinuous
+                } else if (type == 4) {
+                    return .bookMode
+                } else if (type == 5) {
+                    return .bookContinuous
+                }
             }
-            
             return .singlePageContinuous
         }
         set {
@@ -1050,13 +1037,14 @@ extension KMPreferenceManager {
     
     var viewZoomScaleType: KMPDFZoomType {
         get {
-            let type: Int? = self.getData(forKey: KMViewZoomScaleTypeKey) as? Int
-            if (type == nil || type! == 0) {
-                return .width
-            } else if (type! == 1) {
-                return .fit
-            } else if (type! == 2) {
-                return .actualSize
+            if let type = self.getData(forKey: KMViewZoomScaleTypeKey) as? Int {
+                if (type == 0) {
+                    return .width
+                } else if (type == 1) {
+                    return .fit
+                } else if (type == 2) {
+                    return .actualSize
+                }
             }
             return .width
         }
@@ -1069,13 +1057,14 @@ extension KMPreferenceManager {
     
     var leftSideDisplayType: KMPreferenceLeftSideDisplayType {
         get {
-            let type: Int? = self.getData(forKey: KMLeftSideDisplayTypeKey) as? Int
-            if (type == nil || type! == 0) {
-                return .closeWhenOpenFile
-            } else if (type! == 1) {
-                return .openAppSaveLastSelect
-            } else if (type! == 2) {
-                return .showOutlineIfHas
+            if let type = self.getData(forKey: KMLeftSideDisplayTypeKey) as? Int {
+                if type == 0 {
+                    return .closeWhenOpenFile
+                } else if (type == 1) {
+                    return .openAppSaveLastSelect
+                } else if (type == 2) {
+                    return .showOutlineIfHas
+                }
             }
             return .closeWhenOpenFile
         }
@@ -1086,31 +1075,14 @@ extension KMPreferenceManager {
         }
     }
     
-//    var showOutlineList: Bool {
-//        get {
-//            return self.getData(forKey: KMShowOutlineListKey) as! Bool
-//        }
-//        set {
-//            let _ = self.setData(data: newValue, forKey: KMShowOutlineListKey)
-//        }
-//    }
-    
-//    var leftSideExpandType: Int {
-//        get {
-//            return self.getData(forKey: KMLeftSideExpandTypeKey) as! Int
-//        }
-//        set {
-//            let _ = self.setData(data: newValue, forKey: KMLeftSideExpandTypeKey)
-//        }
-//    }
-    
     var propertyPanelExpandType: KMPreferencePropertyPanelExpandType {
         get {
-            let type: Int? = self.getData(forKey: KMPropertyPanelExpandTypeKey) as? Int
-            if (type == nil || type! == 0) {
-                return .auto
-            } else if (type! == 1) {
-                return .manual
+            if let type = self.getData(forKey: KMPropertyPanelExpandTypeKey) as? Int {
+                if (type == 0) {
+                    return .auto
+                } else if (type == 1) {
+                    return .manual
+                }
             }
             return .auto
         }
@@ -1123,7 +1095,7 @@ extension KMPreferenceManager {
     
     var highlightForms: Bool {
         get {
-            return self.getData(forKey: KMHighlightFormsKey) as! Bool
+            return self.getData(forKey: KMHighlightFormsKey) as? Bool ?? true
         }
         set {
             let _ = self.setData(data: newValue, forKey: KMHighlightFormsKey)
@@ -1132,13 +1104,14 @@ extension KMPreferenceManager {
 
     var pageIndicatorType: KMPreferencePageIndicatorDisplayType {
         get {
-            let type: Int? = self.getData(forKey: KMPageIndicatorTypeKey) as? Int
-            if (type == nil || type! == 2) {
-                return .never
-            } else if (type! == 0) {
-                return .automatic
-            } else if (type! == 1) {
-                return .always
+            if let type = self.getData(forKey: KMPageIndicatorTypeKey) as? Int {
+                if (type == 2) {
+                    return .never
+                } else if (type == 0) {
+                    return .automatic
+                } else if (type == 1) {
+                    return .always
+                }
             }
             return .never
         }
@@ -1151,7 +1124,7 @@ extension KMPreferenceManager {
     
     var highlightLinks: Bool {
         get {
-            return self.getData(forKey: KMHighlightLinksKey) as! Bool
+            return self.getData(forKey: KMHighlightLinksKey) as? Bool ?? true
         }
         set {
             let _ = self.setData(data: newValue, forKey: KMHighlightLinksKey)
@@ -1786,12 +1759,10 @@ extension KMPreferenceManager {
 extension KMPreferenceManager {
     var markupFontTextString: String {
         get {
-            let string: String? = UserDefaults.standard.object(forKey: CFreeTextNoteFontNameKey) as? String
-            if (string == nil) {
-                return KMDefaultFontName
-            }
-            if (KMPreferenceManager.supportFonts.contains(string!)) {
-                return string!
+            if let string = UserDefaults.standard.object(forKey: CFreeTextNoteFontNameKey) as? String {
+                if (KMPreferenceManager.supportFonts.contains(string)) {
+                    return string
+                }
             }
             return KMDefaultFontName
         }
@@ -1807,12 +1778,9 @@ extension KMPreferenceManager {
     
     var markupFontTextAligment: NSTextAlignment {
         get {
-            let type: Int? = UserDefaults.standard.integer(forKey: CFreeTextNoteAlignmentKey)
-            if (type == nil) {
-                return .left
-            }
-            if (type! == 0 || type! == 1 || type == 2) {
-                return NSTextAlignment(rawValue: type!)!
+            let type = UserDefaults.standard.integer(forKey: CFreeTextNoteAlignmentKey)
+            if (type == 0 || type == 1 || type == 2) {
+                return NSTextAlignment(rawValue: type) ?? .left
             }
             return .left
         }
@@ -1828,12 +1796,10 @@ extension KMPreferenceManager {
     
     var markupFontNoteString: String {
         get {
-            let fontName: String? = KMPreferenceManager.shared.getData(forKey: KMPreference.markupFontNoteStringKey) as? String
-            if (fontName == nil) {
-                return KMDefaultFontName
-            }
-            if (KMPreference.supportFonts.contains(fontName!)) {
-                return fontName!
+            if let fontName = KMPreferenceManager.shared.getData(forKey: KMPreference.markupFontNoteStringKey) as? String {
+                if (KMPreference.supportFonts.contains(fontName)) {
+                    return fontName
+                }
             }
             return KMDefaultFontName
         }
@@ -1867,29 +1833,53 @@ extension KMPreferenceManager {
     
     private func syncDataToPDFView(_ data: Any, forKey key: KMPreferenceKey) {
         if (key == KMMarkupColorHighlightKey) {
-            UserDefaults.standard.setPDFListViewColor((data as! NSColor), forKey: CHighlightNoteColorKey)
+            if let color = data as? NSColor {
+                UserDefaults.standard.setPDFListViewColor(color, forKey: CHighlightNoteColorKey)
+            }
         } else if (key == KMMarkupColorUnderlineKey) {
-            UserDefaults.standard.setPDFListViewColor((data as! NSColor), forKey: CUnderlineNoteColorKey)
+            if let color = data as? NSColor {
+                UserDefaults.standard.setPDFListViewColor(color, forKey: CUnderlineNoteColorKey)
+            }
         } else if (key == KMMarkupColorStrikthroughKey) {
-            UserDefaults.standard.setPDFListViewColor((data as! NSColor), forKey: CStrikeOutNoteColorKey)
+            if let color = data as? NSColor {
+                UserDefaults.standard.setPDFListViewColor(color, forKey: CStrikeOutNoteColorKey)
+            }
         } else if (key == KMMarkupColorPenKey) {
-            UserDefaults.standard.setPDFListViewColor((data as! NSColor), forKey: CInkNoteColorKey)
+            if let color = data as? NSColor {
+                UserDefaults.standard.setPDFListViewColor(color, forKey: CInkNoteColorKey)
+            }
         } else if (key == KMMarkupColorNoteKey) {
-            UserDefaults.standard.setPDFListViewColor((data as! NSColor), forKey: CAnchoredNoteColorKey)
+            if let color = data as? NSColor {
+                UserDefaults.standard.setPDFListViewColor(color, forKey: CAnchoredNoteColorKey)
+            }
         } else if (key == KMMarkupColorRectangleFillKey) {
-            UserDefaults.standard.setPDFListViewColor((data as! NSColor), forKey: CSquareNoteInteriorColorKey)
+            if let color = data as? NSColor {
+                UserDefaults.standard.setPDFListViewColor(color, forKey: CSquareNoteInteriorColorKey)
+            }
         } else if (key == KMMarkupColorRectangleBorderKey) {
-            UserDefaults.standard.setPDFListViewColor((data as! NSColor), forKey: CSquareNoteColorKey)
+            if let color = data as? NSColor {
+                UserDefaults.standard.setPDFListViewColor(color, forKey: CSquareNoteColorKey)
+            }
         } else if (key == KMMarkupColorCircleFillKey) {
-            UserDefaults.standard.setPDFListViewColor((data as! NSColor), forKey: CCircleNoteInteriorColorKey)
+            if let color = data as? NSColor {
+                UserDefaults.standard.setPDFListViewColor(color, forKey: CCircleNoteInteriorColorKey)
+            }
         } else if (key == KMMarkupColorCircleBorderKey) {
-            UserDefaults.standard.setPDFListViewColor((data as! NSColor), forKey: CCircleNoteColorKey)
+            if let color = data as? NSColor {
+                UserDefaults.standard.setPDFListViewColor(color, forKey: CCircleNoteColorKey)
+            }
         } else if (key == KMMarkupColorLineKey) {
-            UserDefaults.standard.setPDFListViewColor((data as! NSColor), forKey: CLineNoteColorKey)
+            if let color = data as? NSColor {
+                UserDefaults.standard.setPDFListViewColor(color, forKey: CLineNoteColorKey)
+            }
         } else if (key == KMMarkupColorArrowKey) {
-            UserDefaults.standard.setPDFListViewColor((data as! NSColor), forKey: CArrowNoteColorKey)
+            if let color = data as? NSColor {
+                UserDefaults.standard.setPDFListViewColor(color, forKey: CArrowNoteColorKey)
+            }
         } else if (key == KMMarkupColorTextKey) {
-            UserDefaults.standard.setPDFListViewColor((data as! NSColor), forKey: CFreeTextNoteColorKey)
+            if let color = data as? NSColor {
+                UserDefaults.standard.setPDFListViewColor(color, forKey: CFreeTextNoteColorKey)
+            }
         } else if (key == KMMarkupFontTextStringKey) {
             UserDefaults.standard.set(data, forKey: CFreeTextNoteFontNameKey)
             UserDefaults.standard.synchronize()
@@ -1925,22 +1915,22 @@ extension KMPreferenceManager {
     }
     
     private func getDefaultColors(forKey key: KMPreferenceKey) -> [Double] {
-        let markupGroupInfo: [KMPreferenceKey : Any] = self.getDefaultInfo()[KMPreferenceGroup.markup.rawValue]!
+        let markupGroupInfo: [KMPreferenceKey : Any] = self.getDefaultInfo()[KMPreferenceGroup.markup.rawValue] ?? [:]
         for key_i in [KMMarkupColorHighlightKey, KMMarkupColorUnderlineKey, KMMarkupColorStrikthroughKey,
                     KMMarkupColorPenKey, KMMarkupColorNoteKey, KMMarkupColorTextKey,
                     KMMarkupColorRectangleFillKey, KMMarkupColorRectangleBorderKey,
                     KMMarkupColorCircleFillKey, KMMarkupColorCircleBorderKey,
                     KMMarkupColorLineKey, KMMarkupColorArrowKey] {
             if (key == key_i) {
-                return markupGroupInfo[key] as! [Double]
+                return markupGroupInfo[key] as? [Double] ?? []
             }
         }
 
-        let displayGroupInfo: [KMPreferenceKey : Any] = self.getDefaultInfo()[KMPreferenceGroup.display.rawValue]!
+        let displayGroupInfo: [KMPreferenceKey : Any] = self.getDefaultInfo()[KMPreferenceGroup.display.rawValue] ?? [:]
         for key_i in [KMDisplayBackgroundNormalColorKey, KMDisplayBackgroundFullScreenColorKey,
                       KMDisplayFieldHighlightingColorKey, KMDisplayRequiredFieldHighlightingColorKey] {
             if (key == key_i) {
-                return displayGroupInfo[key] as! [Double]
+                return displayGroupInfo[key] as? [Double] ?? []
             }
         }
         
@@ -1952,14 +1942,16 @@ extension KMPreferenceManager {
     }
     
     private func resetDataToPDFView() {
-        let markupGroupInfo: [KMPreferenceKey : Any] = self.getDefaultInfo()[KMPreferenceGroup.markup.rawValue]!
+        let markupGroupInfo: [KMPreferenceKey : Any] = self.getDefaultInfo()[KMPreferenceGroup.markup.rawValue] ?? [:]
         // colors
         for key in [KMMarkupColorHighlightKey, KMMarkupColorUnderlineKey, KMMarkupColorStrikthroughKey,
                     KMMarkupColorPenKey, KMMarkupColorNoteKey, KMMarkupColorTextKey,
                     KMMarkupColorRectangleFillKey, KMMarkupColorRectangleBorderKey,
                     KMMarkupColorCircleFillKey, KMMarkupColorCircleBorderKey,
                     KMMarkupColorLineKey, KMMarkupColorArrowKey] {
-            self.syncDataToPDFView(self.dataToColor(colors: markupGroupInfo[key] as! [Double]), forKey: key)
+            if let data = markupGroupInfo[key] as? [Double] {
+                self.syncDataToPDFView(self.dataToColor(colors:data ), forKey: key)
+            }
         }
         // lines
         for key in [KMFreeTextNoteLineStyleKey, KMFreeTextNoteLineWidthKey, KMFreeTextNoteDashPatternKey,
@@ -2069,14 +2061,12 @@ extension KMPreferenceManager {
                 return
             }
             
-            let viewSetting: [String : Any]? = UserDefaults.standard.value(forKey: kKMViewSettingKey) as? [String : Any]
+            let viewSetting: [String : Any] = UserDefaults.standard.value(forKey: kKMViewSettingKey) as? [String : Any] ?? [:]
             var info: [String : Any] = [:]
-            if (viewSetting != nil) {
-                for (key, value) in viewSetting! {
-                    info.updateValue(value, forKey: key)
-                }
+            for (key, value) in viewSetting {
+                info.updateValue(value, forKey: key)
             }
-            for (key, value) in newValue! {
+            for (key, value) in newValue ?? [:] {
                 if (key == .pageNumber) { // 只处理 枚举
                     info.updateValue(value, forKey: key.rawValue)
                 }

+ 5 - 3
PDF Office/PDF Master/Class/Preference/View/KMFontWell.swift

@@ -208,8 +208,8 @@ class KMFontWell: NSButton {
         let oldCell = self.cell as? NSButtonCell
         if let data = oldCell?.isKind(of: Self.cellClass!), !data {
             let newCell = KMFontWellCell(textCell: "")
-            newCell.alignment = oldCell!.alignment
-            newCell.isEditable = oldCell!.isEditable
+            newCell.alignment = oldCell?.alignment ?? .center
+            newCell.isEditable = oldCell?.isEditable ?? true
             newCell.target = oldCell?.target
             newCell.action = oldCell?.action
             self.cell = newCell
@@ -222,7 +222,9 @@ class KMFontWell: NSButton {
     override func encode(with coder: NSCoder) {
         super.encode(with: coder)
         
-        coder.encode(NSStringFromSelector(action!), forKey: ACTION_KEY)
+        if let data = self.action {
+            coder.encode(NSStringFromSelector(data), forKey: ACTION_KEY)
+        }
         coder.encodeConditionalObject(target, forKey: TARGET_KEY)
     }
     

+ 0 - 36
PDF Office/PDF Master/Class/Preference/View/KMLineWell.swift

@@ -125,10 +125,6 @@ class KMLineWell: NSControl {
     
     private var __lwFlags = _lwFlags()
     
-    /*
-     - (void)lineInspectorLineAttributeChanged:(NSNotification *)notification;
-     */
-    
     var canActivate: Bool {
         get {
             return __lwFlags.canActivate
@@ -383,8 +379,6 @@ class KMLineWell: NSControl {
 //        [[info objectForKey:NSObservedObjectKey] setValue:[self valueForKey:key] forKeyPath:[info objectForKey:NSObservedKeyPathKey]];
 //    }
 
-    
-    
     /*
 
      + (void)initialize {
@@ -438,36 +432,6 @@ class KMLineWell: NSControl {
 
      #pragma mark Notification handlers
 
-     - (void)lineInspectorLineAttributeChanged:(NSNotification *)notification {
-     //    SKLineInspector *inspector = [notification object];
-     //    NSString *key = nil;
-     //    switch ([inspector currentLineChangeAction]) {
-     //        case SKLineChangeActionLineWidth:
-     //            key = SKLineWellLineWidthKey;
-     //            break;
-     //        case SKLineChangeActionStyle:
-     //            key = SKLineWellStyleKey;
-     //            break;
-     //        case SKLineChangeActionDashPattern:
-     //            key = SKLineWellDashPatternKey;
-     //            break;
-     //        case SKLineChangeActionStartLineStyle:
-     //            if ([self displayStyle] == SKLineWellDisplayStyleLine)
-     //                key = SKLineWellStartLineStyleKey;
-     //            break;
-     //        case SKLineChangeActionEndLineStyle:
-     //            if ([self displayStyle] == SKLineWellDisplayStyleLine)
-     //                key = SKLineWellEndLineStyleKey;
-     //            break;
-     //        case SKNoLineChangeAction:
-     //            break;
-     //    }
-     //    if (key) {
-     //        [self takeValueForKey:key from:inspector];
-     //        [self sendAction:[self action] to:[self target]];
-     //    }
-     }
-
      #pragma mark NSDraggingSource protocol
 
      - (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal {

+ 34 - 109
PDF Office/PDF Master/Class/Preference/Window/KMPreferenceController.swift

@@ -36,8 +36,6 @@ private let NIBNAME_KEY = "nibName"
     private let INITIALUSERDEFAULTS_KEY = "InitialUserDefaults"
     private let RESETTABLEKEYS_KEY = "ResettableKeys"
     /*
-     @protocol ;
-
      @interface SKPreferenceController : NSWindowController <NSWindowDelegate, NSTabViewDelegate, NSToolbarDelegate> {
          NSArray *resetButtons;
      }
@@ -62,19 +60,6 @@ private let NIBNAME_KEY = "nibName"
      - (void)selectPaneWithIdentifier:(NSString *)itemIdentifier;
 
      @end
-
- 
-
-     @interface SKIBArray : NSArray {
-         __strong id object[9];
-         unsigned long mutations;
-     }
-
-
-     //@property (nonatomic, retain) id object;
-     @property (nonatomic, retain) IBOutlet id object1, object2, object3, object4, object5, object6, object7, object8, object9;
-
-     @end
      */
     
     deinit {
@@ -119,13 +104,13 @@ private let NIBNAME_KEY = "nibName"
         var pane: NSViewController?
         var view: NSView?
         for pane in self.preferencePanes ?? [] {
-            let _pane = pane as! NSViewController
-            width = fmax(width, NSWidth(_pane.view.frame))
+            let _pane = pane as? NSViewController
+            width = fmax(width, NSWidth(_pane?.view.frame ?? .zero))
         }
         for pane in self.preferencePanes ?? [] {
-            let _pane = pane as! NSViewController
-            view = _pane.view
-            frame = view!.frame
+            let _pane = pane as? NSViewController
+            view = _pane?.view
+            frame = view?.frame ?? .zero
             if let data = view?.autoresizingMask.contains(.width), data {
                 frame.size.width = width
             } else {
@@ -135,7 +120,7 @@ private let NIBNAME_KEY = "nibName"
             view?.frame = frame
         }
         
-        self.currentPane = self._preferencePane(forItemIdentifier: UserDefaults.standard.string(forKey: SKLastSelectedPreferencePaneKey) ?? "") ?? self.preferencePanes![0]
+        self.currentPane = self._preferencePane(forItemIdentifier: UserDefaults.standard.string(forKey: SKLastSelectedPreferencePaneKey) ?? "") ?? self.preferencePanes?.first
         toolbar.selectedItemIdentifier = NSToolbarItem.Identifier((self.currentPane as? NSViewController)?.nibName ?? "")
         
         if  let _currentPane = self.currentPane as? NSViewController {
@@ -146,7 +131,7 @@ private let NIBNAME_KEY = "nibName"
         view = (self.currentPane as? NSViewController)?.view
         frame = window?.frame ?? .zero
         frame.size.width = width
-        frame = KMShrinkRect(rect: frame, amount: NSHeight(window?.contentView?.frame ?? .zero) - NSMaxY(view!.frame), edge: .minY)
+        frame = KMShrinkRect(rect: frame, amount: NSHeight(window?.contentView?.frame ?? .zero) - NSMaxY(view?.frame ?? .zero), edge: .minY)
         
         window?.setFrame(frame, display: false)
         
@@ -219,61 +204,6 @@ private let NIBNAME_KEY = "nibName"
      }
 
      #pragma mark Toolbar
-     @end
-
-     @implementation SKIBArray
-
-     static void setObjectAtIndex(id __strong *object, id obj, NSUInteger i, unsigned long *mutationsPtr) {
-         if (object[i] != obj) {
-     //        [object[i] release];
-             object[i] = obj;
-             (*mutationsPtr)++;
-         }
-     }
-
-     #define SYNTHESIZE_OBJECT_ACCESSORS(i) \
-     @dynamic object##i; \
-     - (id)object##i { return object[i-1]; } \
-     - (void)setObject##i:(id)obj { setObjectAtIndex(object, obj, i-1, &mutations); }
-
-     SYNTHESIZE_OBJECT_ACCESSORS(1)
-     SYNTHESIZE_OBJECT_ACCESSORS(2)
-     SYNTHESIZE_OBJECT_ACCESSORS(3)
-     SYNTHESIZE_OBJECT_ACCESSORS(4)
-     SYNTHESIZE_OBJECT_ACCESSORS(5)
-     SYNTHESIZE_OBJECT_ACCESSORS(6)
-     SYNTHESIZE_OBJECT_ACCESSORS(7)
-     SYNTHESIZE_OBJECT_ACCESSORS(8)
-     SYNTHESIZE_OBJECT_ACCESSORS(9)
-
-     - (void)dealloc {
-         NSUInteger i;
-         for (i = 0; i < 9; i++)
-             setObjectAtIndex(object, nil, i, &mutations);
-     //    [super dealloc];
-     }
-
-     - (NSUInteger)count {
-         NSUInteger i;
-         for (i = 0; i < 9; i++)
-             if (object[i] == nil) break;
-         return i;
-     }
-
-     - (id)objectAtIndex:(NSUInteger)anIndex {
-         return object[anIndex];
-     }
-
-     - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len {
-         if (state->state == 0) {
-             state->state = 1;
-     //        state->itemsPtr = object;
-             state->mutationsPtr = &mutations;
-             return [self count];
-         }
-         return 0;
-     }
-
      @end
      */
 
@@ -301,15 +231,11 @@ private let NIBNAME_KEY = "nibName"
         let response = alert.runModal()
         if (response == .alertFirstButtonReturn) {
             NSUserDefaultsController.shared.revertToInitialValues(forKeys: nil)
-            for pane in self.preferencePanes! {
+            for pane in self.preferencePanes ?? [] {
                 pane.defaultsDidRevert?()
             }
             
             KMPreference.shared.resetAllData()
-            
-            //重置OCR后,记录切换值
-//            [[NSUserDefaults standardUserDefaults] setInteger:0 forKey:@"KMStatusPlanPopUpBtnKey"];
-//            [[NSUserDefaults standardUserDefaults] synchronize];
         }
     }
     
@@ -325,8 +251,8 @@ extension KMPreferenceController {
         self._panelControlSelectColor(itemIdent)
 
         for pane in self.preferencePanes ?? [] {
-            let _pane = pane as! NSViewController
-            if _pane.nibName == itemIdent {
+            let _pane = pane as? NSViewController
+            if _pane?.nibName == itemIdent {
                 return pane
             }
         }
@@ -376,23 +302,23 @@ extension KMPreferenceController {
         var _pane = pane as? NSViewController
         let _currentPane = self.currentPane as? NSViewController
         if _pane != _currentPane {
-            if (_pane != nil) {
+            if let data = _pane {
                 self.historyIndex += 1
-                if self.history!.count > self.historyIndex {
-                    let range = self.historyIndex ..< self.history!.count-self.historyIndex
+                if let cnt = self.history?.count, cnt > self.historyIndex {
+                    let range = self.historyIndex ..< cnt-self.historyIndex
                     self.history?.removeSubrange(range)
                 }
-                self.history?.append(_pane!)
+                self.history?.append(data)
             } else {
                 _pane = self.history?[self.historyIndex]
             }
             
             let window = self.window
-            let contentView = window!.contentView
-            let oldView = _currentPane!.view
-            let view = _pane!.view
-            var frame = window!.frame
-            frame = KMShrinkRect(rect: frame,  amount: NSHeight(contentView!.frame) - NSMaxY(view.frame), edge: .minY)
+            let contentView = window?.contentView
+            let oldView = _currentPane?.view
+            let view = _pane?.view
+            var frame = window?.frame ?? .zero
+            frame = KMShrinkRect(rect: frame,  amount: NSHeight(contentView?.frame ?? .zero) - NSMaxY(view?.frame ?? .zero), edge: .minY)
             
             // make sure edits are committed
             _currentPane?.commitEditing()
@@ -407,14 +333,18 @@ extension KMPreferenceController {
             }
             
             if UserDefaults.standard.bool(forKey: SKDisableAnimationsKey) {
-                contentView?.replaceSubview(oldView, with: view)
+                if oldView != nil && view != nil {
+                    contentView?.replaceSubview(oldView!, with: view!)
+                }
                 window?.setFrame(frame, display: true)
             } else {
-                let duration = window?.animationResizeTime(frame)
+                let duration = window?.animationResizeTime(frame) ?? 0
                 contentView?.displayIfNeeded()
                 NSAnimationContext.runAnimationGroup { context in
-                    context.duration = duration!
-                    contentView?.animator().replaceSubview(oldView, with: view)
+                    context.duration = duration
+                    if oldView != nil && view != nil {
+                        contentView?.animator().replaceSubview(oldView!, with: view!)
+                    }
                     window?.animator().setFrame(frame, display: true)
                 }
             }
@@ -423,9 +353,9 @@ extension KMPreferenceController {
     
     @objc private func _resetCurrentSheetDidEnd(_ alert: NSAlert, _ returnCode: Int, _ contextInfo: Any) {
         if (returnCode == NSApplication.ModalResponse.alertFirstButtonReturn.rawValue) {
-            let initialUserDefaultsURL = Bundle.main.url(forResource: INITIALUSERDEFAULTS_KEY, withExtension: "plist")
-            if let _currentPane = self.currentPane as? NSViewController {
-                let resettableKeys = (NSDictionary(contentsOf: initialUserDefaultsURL!)?.object(forKey: RESETTABLEKEYS_KEY) as? NSDictionary)?.object(forKey: _currentPane.nibName!)
+            if let initialUserDefaultsURL = Bundle.main.url(forResource: INITIALUSERDEFAULTS_KEY, withExtension: "plist") {
+                if let _currentPane = self.currentPane as? NSViewController {
+                let resettableKeys = (NSDictionary(contentsOf: initialUserDefaultsURL)?.object(forKey: RESETTABLEKEYS_KEY) as? NSDictionary)?.object(forKey: _currentPane.nibName ?? "")
                 if let data = resettableKeys as? [String] {
                     NSUserDefaultsController.shared.revertToInitialValues(forKeys: data)
                 }
@@ -438,21 +368,15 @@ extension KMPreferenceController {
                 } else if _currentPane is KMNotesPreferences {
                     KMPreference.shared.resetData(.markup)
                 }
-                
-//                if ([[currentPane title] isEqualToString:@"OCR"]) { //重置OCR后,记录切换值
-//                    [[NSUserDefaults standardUserDefaults] setInteger:0 forKey:@"KMStatusPlanPopUpBtnKey"];
-//                    [[NSUserDefaults standardUserDefaults] synchronize];
-//                }
             }
         }
+        }
     }
 }
 
 extension KMPreferenceController: NSToolbarDelegate {
     func toolbar(_ toolbar: NSToolbar, itemForItemIdentifier itemIdentifier: NSToolbarItem.Identifier, willBeInsertedIntoToolbar flag: Bool) -> NSToolbarItem? {
-//        NSViewController<SKPreferencePane> * = [self preferencePaneForItemIdentifier:itemIdent];
         let pane = self._preferencePane(forItemIdentifier: itemIdentifier.rawValue) as? NSViewController
-//        NSToolbarItem * = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdent];
         let item = NSToolbarItem(itemIdentifier: itemIdentifier)
         item.label = pane?.title ?? ""
         var ima: NSImage?
@@ -476,8 +400,9 @@ extension KMPreferenceController: NSToolbarDelegate {
     func toolbarDefaultItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] {
         var items: [NSToolbarItem.Identifier] = []
         for item in self.preferencePanes ?? [] {
-            let name = (item as? NSViewController)?.nibName
-            items.append(NSToolbarItem.Identifier(rawValue: name!))
+            if let name = (item as? NSViewController)?.nibName {
+                items.append(NSToolbarItem.Identifier(rawValue: name))
+            }
         }
         return items
     }

+ 2 - 0
PDF Office/PDF Master/Strings/zh-Hans.lproj/Localizable.strings

@@ -1309,6 +1309,8 @@
 
 "This PDF is password protected. Please enter the password below to access this PDF." = "该文档受密码保护。请在下面输入密码开启文档。";
 
+"Permission Password" = "权限密码";
+
 "Share" = "分享";
 
 "Upgrade your PDF Reader Pro and enjoy all the benefits:" = "升级PDF Reader Pro,畅享进阶功能!";

+ 2 - 0
PDF Office/PDF Master/Strings/zh-Hant.lproj/Localizable.strings

@@ -1311,6 +1311,8 @@
 
 "This PDF is password protected. Please enter the password below to access this PDF." = "此文件受密碼保護,請輸入密碼方可開啟文件。";
 
+"Permission Password" = "許可權密碼";
+
 "Share" = "分享";
 
 "Upgrade your PDF Reader Pro and enjoy all the benefits:" = "升級PDF Reader Pro享受完整功能:";

+ 15 - 63
PDF Office/PDF Reader Pro.xcodeproj/xcuserdata/kdanmobile.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -231,98 +231,50 @@
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
-            uuid = "8B48DE07-E799-49FB-84C2-545601724021"
+            uuid = "2F51C06E-D7F5-4C1B-9CD1-DF3B0E4EEFAA"
             shouldBeEnabled = "Yes"
             ignoreCount = "0"
             continueAfterRunningActions = "No"
-            filePath = "PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift"
+            filePath = "PDF Master/Class/PDFTools/Crop/KMPDFCropWindowController.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "976"
-            endingLineNumber = "976"
-            landmarkName = "cropAllPageItem(sender:)"
+            startingLineNumber = "353"
+            endingLineNumber = "353"
+            landmarkName = "buttonClicked_Margin(_:)"
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
-            uuid = "D23D3256-568F-45C5-BB8D-43B89ED7018C"
+            uuid = "A00E08E0-6CC3-4B89-AFF8-4910748FBF92"
             shouldBeEnabled = "Yes"
             ignoreCount = "0"
             continueAfterRunningActions = "No"
-            filePath = "PDF Master/Class/ChromiumTabs/src/Browser Window/CTBrowser.m"
+            filePath = "PDF Master/Class/PDFTools/Crop/KMPDFCropWindowController.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "142"
-            endingLineNumber = "142"
-            landmarkName = "-windowDidBeginToClose"
+            startingLineNumber = "383"
+            endingLineNumber = "383"
+            landmarkName = "buttonClicked_Margin(_:)"
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
-            uuid = "250E8571-FF9A-4F21-A82D-9045D440563F"
+            uuid = "835506E2-BAB9-4B07-811B-120DC0EA9881"
             shouldBeEnabled = "Yes"
             ignoreCount = "0"
             continueAfterRunningActions = "No"
-            filePath = "PDF Master/Class/ChromiumTabs/KMBrowser.swift"
+            filePath = "PDF Master/Class/Home/ViewController/KMHomeViewController+Action.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "31"
-            endingLineNumber = "31"
-            landmarkName = "windowDidBeginToClose()"
+            startingLineNumber = "454"
+            endingLineNumber = "454"
+            landmarkName = "openFile(withFilePath:)"
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "44D0B49A-36B2-49D7-8950-6856068635F3"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "PDF Master/Class/Purchase/DMG/Verification/KMVerificationWindowController.m"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "487"
-            endingLineNumber = "487"
-            landmarkName = "-verificationActivateAIInfo:"
-            landmarkType = "7">
-            <Locations>
-               <Location
-                  uuid = "44D0B49A-36B2-49D7-8950-6856068635F3 - c98d300759d935a4"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "-[KMVerificationWindowController verificationActivateAIInfo:]"
-                  moduleName = "PDF Reader Pro"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Users/kdanmobile/Documents/Git/PDF_Office/PDF%20Office/PDF%20Master/Class/Purchase/DMG/Verification/KMVerificationWindowController.m"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "487"
-                  endingLineNumber = "487"
-                  offsetFromSymbolStart = "72">
-               </Location>
-               <Location
-                  uuid = "44D0B49A-36B2-49D7-8950-6856068635F3 - c98d300759d935a4"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "-[KMVerificationWindowController verificationActivateAIInfo:]"
-                  moduleName = "PDF Reader Pro"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Users/kdanmobile/Documents/Git/PDF_Office/PDF%20Office/PDF%20Master/Class/Purchase/DMG/Verification/KMVerificationWindowController.m"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "487"
-                  endingLineNumber = "487"
-                  offsetFromSymbolStart = "108">
-               </Location>
-            </Locations>
-         </BreakpointContent>
-      </BreakpointProxy>
    </Breakpoints>
 </Bucket>