Explorar o código

【OCToSwift】SKInfoWindowController

tangchao hai 1 ano
pai
achega
a8c316f104

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

@@ -2779,9 +2779,6 @@
 		BB8F4586295B19AC0037EA22 /* KMHeaderFooterDateInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB8F4585295B19AC0037EA22 /* KMHeaderFooterDateInfoView.swift */; };
 		BB8F4587295B19AC0037EA22 /* KMHeaderFooterDateInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB8F4585295B19AC0037EA22 /* KMHeaderFooterDateInfoView.swift */; };
 		BB8F4588295B19AC0037EA22 /* KMHeaderFooterDateInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB8F4585295B19AC0037EA22 /* KMHeaderFooterDateInfoView.swift */; };
-		BB9695A829BDA3A800FD68D3 /* SKInfoWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = BB9695A729BDA3A800FD68D3 /* SKInfoWindowController.m */; };
-		BB9695A929BDA3A800FD68D3 /* SKInfoWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = BB9695A729BDA3A800FD68D3 /* SKInfoWindowController.m */; };
-		BB9695AA29BDA3A800FD68D3 /* SKInfoWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = BB9695A729BDA3A800FD68D3 /* SKInfoWindowController.m */; };
 		BB9695B229BDA46500FD68D3 /* SKLocalization.m in Sources */ = {isa = PBXBuildFile; fileRef = BB9695B129BDA46500FD68D3 /* SKLocalization.m */; };
 		BB9695B329BDA46500FD68D3 /* SKLocalization.m in Sources */ = {isa = PBXBuildFile; fileRef = BB9695B129BDA46500FD68D3 /* SKLocalization.m */; };
 		BB9695B429BDA46500FD68D3 /* SKLocalization.m in Sources */ = {isa = PBXBuildFile; fileRef = BB9695B129BDA46500FD68D3 /* SKLocalization.m */; };
@@ -2800,6 +2797,9 @@
 		BB986AE72AD5376100ADF172 /* WelcomeWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BB986AE62AD5376100ADF172 /* WelcomeWindowController.xib */; };
 		BB986AE82AD5376100ADF172 /* WelcomeWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BB986AE62AD5376100ADF172 /* WelcomeWindowController.xib */; };
 		BB986AE92AD5376100ADF172 /* WelcomeWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BB986AE62AD5376100ADF172 /* WelcomeWindowController.xib */; };
+		BB986AEB2AD53AE800ADF172 /* KMInfoWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB986AEA2AD53AE800ADF172 /* KMInfoWindowController.swift */; };
+		BB986AEC2AD53AE800ADF172 /* KMInfoWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB986AEA2AD53AE800ADF172 /* KMInfoWindowController.swift */; };
+		BB986AED2AD53AE800ADF172 /* KMInfoWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB986AEA2AD53AE800ADF172 /* KMInfoWindowController.swift */; };
 		BB99ACC2292DE22E0048AFD9 /* KMMergeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB99ACC0292DE22E0048AFD9 /* KMMergeViewController.swift */; };
 		BB99ACC3292DE22E0048AFD9 /* KMMergeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB99ACC0292DE22E0048AFD9 /* KMMergeViewController.swift */; };
 		BB99ACC4292DE22E0048AFD9 /* KMMergeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB99ACC0292DE22E0048AFD9 /* KMMergeViewController.swift */; };
@@ -4575,8 +4575,6 @@
 		BB8F457D295B00130037EA22 /* KMWatermarkAdjectiveTools.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMWatermarkAdjectiveTools.swift; sourceTree = "<group>"; };
 		BB8F4581295B0F900037EA22 /* KMHeaderFooterMarginInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMHeaderFooterMarginInfoView.swift; sourceTree = "<group>"; };
 		BB8F4585295B19AC0037EA22 /* KMHeaderFooterDateInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMHeaderFooterDateInfoView.swift; sourceTree = "<group>"; };
-		BB9695A629BDA3A800FD68D3 /* SKInfoWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKInfoWindowController.h; sourceTree = "<group>"; };
-		BB9695A729BDA3A800FD68D3 /* SKInfoWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKInfoWindowController.m; sourceTree = "<group>"; };
 		BB9695B029BDA46500FD68D3 /* SKLocalization.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKLocalization.h; sourceTree = "<group>"; };
 		BB9695B129BDA46500FD68D3 /* SKLocalization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKLocalization.m; sourceTree = "<group>"; };
 		BB9695B529BDB03E00FD68D3 /* InfoWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = InfoWindow.xib; sourceTree = "<group>"; };
@@ -4584,6 +4582,7 @@
 		BB981E512AD4F638001988CA /* KMPageIndicator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KMPageIndicator.swift; sourceTree = "<group>"; };
 		BB981E582AD4F70D001988CA /* KMWelcomeWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMWelcomeWindowController.swift; sourceTree = "<group>"; };
 		BB986AE62AD5376100ADF172 /* WelcomeWindowController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = WelcomeWindowController.xib; sourceTree = "<group>"; };
+		BB986AEA2AD53AE800ADF172 /* KMInfoWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMInfoWindowController.swift; sourceTree = "<group>"; };
 		BB99ACC0292DE22E0048AFD9 /* KMMergeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMMergeViewController.swift; sourceTree = "<group>"; };
 		BB99ACC1292DE22E0048AFD9 /* KMMergeViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KMMergeViewController.xib; sourceTree = "<group>"; };
 		BB99ACC9292DEE6E0048AFD9 /* KMMergeTitleBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMMergeTitleBar.swift; sourceTree = "<group>"; };
@@ -8460,8 +8459,7 @@
 				BB9695B529BDB03E00FD68D3 /* InfoWindow.xib */,
 				BB9695B029BDA46500FD68D3 /* SKLocalization.h */,
 				BB9695B129BDA46500FD68D3 /* SKLocalization.m */,
-				BB9695A629BDA3A800FD68D3 /* SKInfoWindowController.h */,
-				BB9695A729BDA3A800FD68D3 /* SKInfoWindowController.m */,
+				BB986AEA2AD53AE800ADF172 /* KMInfoWindowController.swift */,
 			);
 			path = Property;
 			sourceTree = "<group>";
@@ -10410,6 +10408,7 @@
 				BB162E9B295073B40088E9D1 /* KMWatermarkManager.swift in Sources */,
 				BB4BD9CC2909026500A66A65 /* KMRightSideViewController.swift in Sources */,
 				AD2D74B529F0D39500EDC5E4 /* KMCancellationSuccessView.swift in Sources */,
+				BB986AEB2AD53AE800ADF172 /* KMInfoWindowController.swift in Sources */,
 				9F080B23298FCB0D00FC27DA /* KMDesignToken+Action.swift in Sources */,
 				ADC075C029866AE6006C752F /* KMBatchTextRecognitionView.swift in Sources */,
 				9F1FE4B429406E4700E952CA /* CTBrowser.m in Sources */,
@@ -10429,7 +10428,6 @@
 				F359916929261F0D000D25DE /* CPDFListView+Tool.m in Sources */,
 				9F3D819329A33A290087B5AD /* KMDesignDropdown.swift in Sources */,
 				9F0CB47F2967F64D00007028 /* KMPropertiesPanelReadOnlySubVC.swift in Sources */,
-				BB9695A829BDA3A800FD68D3 /* SKInfoWindowController.m in Sources */,
 				BB2EDF76296ECE17003BCF58 /* KMPageEditInsertPageSizeItemView.swift in Sources */,
 				ADBC2D3F299F70A8006280C8 /* KMBatchManager.swift in Sources */,
 				9F1FE49F29406E4700E952CA /* HoverButton.m in Sources */,
@@ -11227,7 +11225,6 @@
 				BB89DD7F2953F863007C3FFA /* KMWatermarkFileOutsideView.swift in Sources */,
 				9F3D819429A33A290087B5AD /* KMDesignDropdown.swift in Sources */,
 				9F0CB4802967F64D00007028 /* KMPropertiesPanelReadOnlySubVC.swift in Sources */,
-				BB9695A929BDA3A800FD68D3 /* SKInfoWindowController.m in Sources */,
 				BB2EDF77296ECE17003BCF58 /* KMPageEditInsertPageSizeItemView.swift in Sources */,
 				ADBC2D40299F70A8006280C8 /* KMBatchManager.swift in Sources */,
 				9F1F82DB292F84D60092C4B4 /* KMHomeInsertActionViewController.swift in Sources */,
@@ -11797,6 +11794,7 @@
 				BB9695B329BDA46500FD68D3 /* SKLocalization.m in Sources */,
 				9F0CB4EE298655A800007028 /* KMDesignToken+PaddingLeft.swift in Sources */,
 				BB00302F298D315E002DD1A0 /* KMPreferenceMarkupController.swift in Sources */,
+				BB986AEC2AD53AE800ADF172 /* KMInfoWindowController.swift in Sources */,
 				9F1FE49D29406E4700E952CA /* HoverCloseButton.m in Sources */,
 				9F1F82C4292F113A0092C4B4 /* KMHomeDragView.swift in Sources */,
 				BB3A81B12AC2B82A006FC66C /* KMPageSizeTool.swift in Sources */,
@@ -12433,7 +12431,6 @@
 				BB8F456B295ABDC10037EA22 /* KMWatermarkAdjectiveBaseModel.swift in Sources */,
 				9F0CB4FB298655E500007028 /* KMDesignToken+Border.swift in Sources */,
 				BBBF68822A3BF17F0058E14E /* KMFilePromiseProvider.swift in Sources */,
-				BB9695AA29BDA3A800FD68D3 /* SKInfoWindowController.m in Sources */,
 				9F0CB4D32986550B00007028 /* KMDesignToken+Width.swift in Sources */,
 				BB4EEF4629764FEF003A3537 /* KMWatermarkAligementView.swift in Sources */,
 				9F0CB533298656EA00007028 /* KMDesignToken+BorderWidthBottom.swift in Sources */,
@@ -12670,6 +12667,7 @@
 				BBA93D3529BF0ECE0044E0DD /* SKKeychain.m in Sources */,
 				89E4E71F2963F77C002DBA6F /* KMSelfSignAnnotationFreeText.m in Sources */,
 				9F1F82C5292F113A0092C4B4 /* KMHomeDragView.swift in Sources */,
+				BB986AED2AD53AE800ADF172 /* KMInfoWindowController.swift in Sources */,
 				BB0A55122A302DB700B6E84B /* KMTextField.swift in Sources */,
 				AD4B45732940B0000076FA14 /* KMOCRModel.swift in Sources */,
 				ADCB98E32924776F00B51A03 /* KMBatchProcessingSizeTableCell.swift in Sources */,

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

@@ -318,8 +318,8 @@
             filePath = "PDF Master/Class/PDFWindowController/PDFListView/AppKitCategories/PDFListView+KMExtensions.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "238"
-            endingLineNumber = "238"
+            startingLineNumber = "239"
+            endingLineNumber = "239"
             landmarkName = "PDFListViewColor(forKey:)"
             landmarkType = "7">
          </BreakpointContent>

+ 6 - 6
PDF Office/PDF Master/Class/Common/OC/Property/InfoWindow.xib

@@ -6,7 +6,7 @@
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
-        <customObject id="-2" userLabel="File's Owner" customClass="SKInfoWindowController">
+        <customObject id="-2" userLabel="File's Owner" customClass="KMInfoWindowController" customModule="PDF_Master" customModuleProvider="target">
             <connections>
                 <outlet property="attributesTableView" destination="235" id="244"/>
                 <outlet property="summaryTableView" destination="225" id="231"/>
@@ -32,18 +32,18 @@
                         <tabViewItems>
                             <tabViewItem label="Summary" identifier="1" id="94">
                                 <view key="view" id="95">
-                                    <rect key="frame" x="10" y="25" width="414" height="310"/>
+                                    <rect key="frame" x="10" y="29" width="414" height="306"/>
                                     <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                     <subviews>
                                         <scrollView focusRingType="none" fixedFrame="YES" borderType="none" autohidesScrollers="YES" horizontalLineScroll="22" horizontalPageScroll="10" verticalLineScroll="22" verticalPageScroll="10" hasHorizontalScroller="NO" hasVerticalScroller="NO" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="222">
-                                            <rect key="frame" x="17" y="17" width="380" height="287"/>
+                                            <rect key="frame" x="17" y="17" width="380" height="283"/>
                                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                             <clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="tba-ii-VJE">
-                                                <rect key="frame" x="0.0" y="0.0" width="380" height="287"/>
+                                                <rect key="frame" x="0.0" y="0.0" width="380" height="283"/>
                                                 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                                 <subviews>
                                                     <tableView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" tableStyle="fullWidth" columnReordering="NO" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" typeSelect="NO" rowHeight="20" rowSizeStyle="automatic" viewBased="YES" id="225">
-                                                        <rect key="frame" x="0.0" y="0.0" width="389" height="287"/>
+                                                        <rect key="frame" x="0.0" y="0.0" width="389" height="283"/>
                                                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                                         <size key="intercellSpacing" width="3" height="2"/>
                                                         <color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="calibratedRGB"/>
@@ -141,7 +141,7 @@
                                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                             <clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="RKB-CK-2VI">
                                                 <rect key="frame" x="0.0" y="0.0" width="380" height="287"/>
-                                                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                                                <autoresizingMask key="autoresizingMask"/>
                                                 <subviews>
                                                     <tableView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" tableStyle="fullWidth" columnReordering="NO" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" typeSelect="NO" rowHeight="20" rowSizeStyle="automatic" viewBased="YES" id="235">
                                                         <rect key="frame" x="0.0" y="0.0" width="389" height="287"/>

+ 584 - 0
PDF Office/PDF Master/Class/Common/OC/Property/KMInfoWindowController.swift

@@ -0,0 +1,584 @@
+//
+//  KMInfoWindowController.swift
+//  PDF Master
+//
+//  Created by tangchao on 2023/10/10.
+//
+
+import Cocoa
+
+/*
+ #define SKInfoWindowFrameAutosaveName @"SKInfoWindow"
+
+ #define LABEL_COLUMN_ID @"label"
+ #define VALUE_COLUMN_ID @"value"
+ */
+  
+private let LABEL_COLUMN_ID = "label"
+private let VALUE_COLUMN_ID = "value"
+
+private let KMInfoVersionKey = "Version"
+private let KMInfoPageCountKey = "PageCount"
+private let KMInfoPageSizeKey = "PageSize"
+private let KMInfoPageWidthKey = "PageWidth"
+private let KMInfoPageHeightKey = "PageHeight"
+private let KMInfoKeywordsStringKey = "KeywordsString"
+private let KMInfoEncryptedKey = "Encrypted"
+private let KMInfoAllowsPrintingKey = "AllowsPrinting"
+private let KMInfoAllowsCopyingKey = "AllowsCopying"
+private let KMInfoAllowsDocumentAssemblyKey = "AllowsDocumentAssembly"
+private let KMInfoAllowsContentAccessibilityKey = "AllowsContentAccessibility"
+private let KMInfoAllowsCommentingKey = "AllowsCommenting"
+private let KMInfoAllowsFormFieldEntryKey = "AllowsFormFieldEntry"
+private let KMInfoFileNameKey = "FileName"
+private let KMInfoFileSizeKey = "FileSize"
+private let KMInfoPhysicalSizeKey = "PhysicalSize"
+private let KMInfoLogicalSizeKey = "LogicalSize"
+private let KMInfoTagsKey = "Tags"
+private let KMInfoRatingKey = "Rating"
+
+private let kKMWindowDidBecomeMainNotificationName = Notification.Name(rawValue: "KMWindowDidBecomeMainNotificationName")
+
+typealias KMInfoWindowC = KMInfoWindowController
+
+class KMInfoWindowController: NSWindowController {
+    public static let windowDidBecomeMainNotification = kKMWindowDidBecomeMainNotificationName
+    
+    @IBOutlet weak var summaryTableView: NSTableView!
+    @IBOutlet weak var attributesTableView: NSTableView!
+    @IBOutlet weak var tabView: NSTabView!
+    var info: NSDictionary?
+    
+    var editDictionary: NSMutableDictionary = NSMutableDictionary()
+    
+    private var _summaryKeys: [String] = []
+    var summaryKeys: [String] {
+        get {
+            return self._summaryKeys
+        }
+    }
+    private var _attributesKeys: [String] = []
+    var attributesKeys: [String] {
+        get {
+            return self._attributesKeys
+        }
+    }
+    
+    private var _labels: [String : String] = [:]
+    var labels: [String : String] {
+        get {
+            return self._labels
+        }
+    }
+    
+    private weak var _currentDocument: NSDocument?
+    
+    deinit {
+        NotificationCenter.default.removeObserver(self)
+        
+        Swift.debugPrint("KMInfoWindowController 已释放")
+    }
+    
+    static let shared = KMInfoWindowController()
+    
+    convenience init() {
+        self.init(windowNibName: "InfoWindow")
+        
+        self.info = nil;
+        self._summaryKeys = [KMInfoFileNameKey,
+                             KMInfoFileSizeKey,
+                             KMInfoPageSizeKey,
+                             KMInfoPageCountKey,
+                             KMInfoVersionKey,
+                             "",
+                             KMInfoEncryptedKey,
+                             KMInfoAllowsPrintingKey,
+                             KMInfoAllowsCopyingKey,
+                             KMInfoAllowsDocumentAssemblyKey,
+                             KMInfoAllowsContentAccessibilityKey,
+                             KMInfoAllowsCommentingKey,
+                             KMInfoAllowsFormFieldEntryKey]
+        
+        self._attributesKeys = [PDFDocumentAttribute.titleAttribute.rawValue,
+                                PDFDocumentAttribute.authorAttribute.rawValue,
+                                PDFDocumentAttribute.subjectAttribute.rawValue,
+                                PDFDocumentAttribute.creatorAttribute.rawValue,
+                                PDFDocumentAttribute.producerAttribute.rawValue,
+                                PDFDocumentAttribute.creationDateAttribute.rawValue,
+                                PDFDocumentAttribute.modificationDateAttribute.rawValue,
+                                KMInfoKeywordsStringKey]
+        self._labels = [KMLocalizedString("File name:", "Info label") : KMInfoFileNameKey,
+                        KMLocalizedString("File size:", "Info label") : KMInfoFileSizeKey,
+                        KMLocalizedString("Page size:", "Info label") : KMInfoPageSizeKey,
+                        KMLocalizedString("Page count:", "Info label") : KMInfoPageCountKey,
+                        KMLocalizedString("PDF Version:", "Info label") : KMInfoVersionKey,
+                        KMLocalizedString("Encrypted:", "Info label") : KMInfoEncryptedKey,
+                        KMLocalizedString("Printing:", "Info label") : KMInfoAllowsPrintingKey,
+                        KMLocalizedString("Content Copying:", "Info label") : KMInfoAllowsCopyingKey,
+                        KMLocalizedString("Document Assembly:", "Info label") : KMInfoAllowsDocumentAssemblyKey,
+                        KMLocalizedString("Content Copying for Accessibility:", "Info label") : KMInfoAllowsContentAccessibilityKey,
+                        KMLocalizedString("Commenting:", "Info label") : KMInfoAllowsCommentingKey,
+                        KMLocalizedString("Filling of form fields:", "Info label") : KMInfoAllowsFormFieldEntryKey,
+                        KMLocalizedString("Title:", "Info label") : PDFDocumentAttribute.titleAttribute.rawValue,
+                        KMLocalizedString("Author:", "Info label") : PDFDocumentAttribute.authorAttribute.rawValue,
+                        KMLocalizedString("Subject:", "Info label") : PDFDocumentAttribute.subjectAttribute.rawValue,
+                        KMLocalizedString("Content Creator:", "Info label") : PDFDocumentAttribute.creatorAttribute.rawValue,
+                        KMLocalizedString("PDF Producer:", "Info label") : PDFDocumentAttribute.producerAttribute.rawValue,
+                        KMLocalizedString("Creation date:", "Info label") : PDFDocumentAttribute.creationDateAttribute.rawValue,
+                        KMLocalizedString("Modification date:", "Info label") : PDFDocumentAttribute.modificationDateAttribute.rawValue,
+                        KMLocalizedString("Keywords:", "Info label") : KMInfoKeywordsStringKey]
+    }
+    
+    override func loadWindow() {
+        super.loadWindow()
+        
+        self.window?.localizeStrings(fromTable: self.windowNibName)
+    }
+
+    override func windowDidLoad() {
+        super.windowDidLoad()
+    
+        self.updateForDocument(NSApp.mainWindow?.windowController?.document as? NSDocument)
+        
+        self.summaryTableView.selectionHighlightStyle = .none
+        self.attributesTableView.selectionHighlightStyle = .none
+
+        self.tabView.selectTabViewItem(at: 1)
+
+        NotificationCenter.default.addObserver(self, selector: #selector(_handleViewFrameDidChangeNotification), name: NSView.frameDidChangeNotification, object: self.attributesTableView.enclosingScrollView)
+        NotificationCenter.default.addObserver(self, selector: #selector(_handleWindowDidBecomeMainNotification), name: NSWindow.didBecomeMainNotification, object: nil)
+        NotificationCenter.default.addObserver(self, selector: #selector(_handleWindowDidResignMainNotification), name: NSWindow.didResignMainNotification, object: nil)
+//    //    [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(handlePDFDocumentInfoDidChangeNotification:)
+//    //                                                 name: SKPDFPageBoundsDidChangeNotification object: nil];
+//    //    [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(handleDocumentFileURLDidChangeNotification:)
+//    //                                                 name: SKDocumentFileURLDidChangeNotification object: nil];
+        NotificationCenter.default.addObserver(self, selector: #selector(_handlePDFDocumentInfoDidChangeNotification), name: NSNotification.Name.PDFDocumentDidUnlock, object: nil)
+        NotificationCenter.default.addObserver(self, selector: #selector(_handleWindowWillCloseNotification), name: NSWindow.willCloseNotification, object: nil)
+        NotificationCenter.default.addObserver(self, selector: #selector(_km_handleWindowDidBecomeMainNotification), name: KMInfoWindowC.windowDidBecomeMainNotification, object: nil)
+    }
+    
+    func updateForDocument(_ doc: NSDocument?) {
+        self._currentDocument = doc
+
+        let info = self._infoForDocument(doc)
+        var dic = NSMutableDictionary(dictionary: info)
+        for key in self.editDictionary.allKeys {
+            dic.setObject(self.editDictionary[key], forKey: key as! NSCopying)
+        }
+        self.info = dic
+        self.summaryTableView.reloadData()
+        self.attributesTableView.reloadData()
+    }
+    
+    // MARK: - Private Methods
+     
+    private func _infoForDocument(_ doc: NSDocument?) -> NSDictionary {
+        var dictionary: NSMutableDictionary = NSMutableDictionary()
+        var logicalSize: Int64 = 0
+        var physicalSize: Int64 = 0
+        
+        if let data = doc, data.isKind(of: KMMainDocument.self) {
+            if let pdfDoc = (data as! KMMainDocument).mainViewController?.document {
+                dictionary.addEntries(from: pdfDoc.documentAttributes())
+                dictionary.setValue(String(format: "%ld.%ld", pdfDoc.majorVersion, pdfDoc.minorVersion), forKey: KMInfoVersionKey)
+                dictionary.setValue(NSNumber(value: pdfDoc.pageCount), forKey: KMInfoPageCountKey)
+                if (pdfDoc.pageCount > 0) {
+                    let page: CPDFPage = pdfDoc.page(at:0)!
+                    let cropSize = page.bounds(for: .cropBox).size
+                    let mediaSize = page.bounds(for: .mediaBox).size
+                    dictionary.setValue(KMSizeString(cropSize, mediaSize), forKey: KMInfoPageSizeKey)
+                    dictionary.setValue(NSNumber(value: cropSize.width), forKey: KMInfoPageWidthKey)
+                    dictionary.setValue(NSNumber(value: cropSize.height), forKey: KMInfoPageHeightKey)
+                }
+                if let keyworks = dictionary.value(forKey: CPDFDocumentAttribute.keywordsAttribute.rawValue) {
+                    if (keyworks as AnyObject).isKind(of: NSArray.self) {
+                        dictionary.setValue(keyworks, forKey: KMInfoKeywordsStringKey)
+                    }
+                }
+                dictionary.setValue(NSNumber(booleanLiteral: pdfDoc.isEncrypted), forKey: KMInfoEncryptedKey)
+                dictionary.setValue(NSNumber(booleanLiteral: pdfDoc.allowsPrinting), forKey: KMInfoAllowsPrintingKey)
+                dictionary.setValue(NSNumber(booleanLiteral: pdfDoc.allowsCopying), forKey: KMInfoAllowsCopyingKey)
+                
+//                dictionary.setValue(NSNumber(booleanLiteral: pdfDoc.allowsContentAccessibility), forKey: KMInfoAllowsContentAccessibilityKey)
+                dictionary.setValue(NSNumber(booleanLiteral: pdfDoc.allowsCommenting), forKey: KMInfoAllowsCommentingKey)
+                dictionary.setValue(NSNumber(booleanLiteral: pdfDoc.allowsFormFieldEntry), forKey: KMInfoAllowsDocumentAssemblyKey)
+                dictionary.setValue(NSNumber(booleanLiteral: pdfDoc.allowsFormFieldEntry), forKey: KMInfoAllowsFormFieldEntryKey)
+            }
+        }
+        
+        dictionary.setValue(doc?.fileURL?.path.lastPathComponent, forKey: KMInfoFileNameKey)
+//        [dictionary setValue:SKFileSizeStringForFileURL([doc fileURL], &physicalSize, &logicalSize) forKey:SKInfoFileSizeKey];
+        dictionary.setValue(NSNumber(value: physicalSize), forKey: KMInfoPhysicalSizeKey)
+        dictionary.setValue(NSNumber(value: logicalSize), forKey: KMInfoLogicalSizeKey)
+        return dictionary
+    }
+    
+    @objc private func _handleViewFrameDidChangeNotification(_ sender: Notification) {
+        self.attributesTableView.noteHeightOfRows(withIndexesChanged: IndexSet(integer: self.attributesKeys.count-1))
+    }
+    
+    @objc private func _handleWindowDidBecomeMainNotification(_ sender: Notification) {
+        self.editDictionary.removeAllObjects()
+        self.updateForDocument((sender.object as? NSWindow)?.windowController?.document as? NSDocument)
+    }
+    
+    @objc private func _handleWindowDidResignMainNotification(_ sender: Notification) {
+        self.editDictionary.removeAllObjects()
+        self.updateForDocument(nil)
+    }
+    
+    @objc private func _handlePDFDocumentInfoDidChangeNotification(_ sender: Notification) {
+        guard let doc = NSApp.mainWindow?.windowController?.document else {
+            return
+        }
+        
+        if (doc.isKind(of: KMMainDocument.self)) {
+            guard let pdfDocument = (doc as! KMMainDocument).mainViewController?.document else {
+                return
+            }
+            if (pdfDocument.isEqual(to: sender.object)) {
+                self.editDictionary.removeAllObjects()
+                self.updateForDocument((doc as! NSDocument))
+            }
+        }
+    }
+    
+    @objc private func _handleWindowWillCloseNotification(_ sender: Notification) {
+        if let object = sender.object as? AnyObject, object.isEqual(self.window) {
+            if (self.editDictionary.count > 0) {
+                if let windowController = NSApp.mainWindow?.windowController, windowController.isKind(of: KMBrowserWindowController.self) {
+                    let document = (windowController as! KMBrowserWindowController).document as? KMMainDocument
+                    var dic: NSMutableDictionary = NSMutableDictionary(dictionary: document?.mainViewController?.document?.documentAttributes() ?? [:])
+                    var isSave = false
+                    for key in self.editDictionary.allKeys {
+                        if let data = key as? NSString, data.isEqual(to: KMInfoKeywordsStringKey) {
+                            let string = self.editDictionary[key]
+                            if let data = string as? NSString, data.isEqual(to: dic[PDFDocumentAttribute.keywordsAttribute.rawValue]) {
+                                isSave = true
+                                dic.setObject(string as Any, forKey: CPDFDocumentAttribute.keywordsAttribute.rawValue as NSCopying)
+                            }
+                        } else {
+                            if let data = dic[key] as? NSString, data.isEqual(to: self.editDictionary[key]) == false {
+                                isSave = true
+                                dic.setObject(self.editDictionary[key] as Any, forKey: key as! NSCopying)
+                            }
+                        }
+                    }
+                    if (isSave) {
+                        document?.mainViewController?.document?.setDocumentAttributes(dic as? [CPDFDocumentAttribute : Any])
+                        document?.save(nil)
+                    }
+                }
+            }
+            self.editDictionary.removeAllObjects()
+        }
+    }
+    
+    @objc private func _km_handleWindowDidBecomeMainNotification(_ sender: Notification) {
+        self.editDictionary.removeAllObjects()
+        self.updateForDocument(sender.object as? NSDocument)
+    }
+    
+    /*
+     - (void)handlePDFDocumentInfoDidChangeNotification:(NSNotification *)notification {
+         [self.editDictionary removeAllObjects];
+         NSDocument *doc = [[[NSApp mainWindow] windowController] document];
+         if ([doc isKindOfClass:[KMMainDocument class]]) {
+             CPDFDocument *pdfDocument = ((KMMainDocument *)doc).mainViewController.document;
+             if ([pdfDocument isEqual:notification.object]) {
+                 [self updateForDocument:doc];
+             }
+         }
+     }
+
+     - (void)handleDocumentFileURLDidChangeNotification:(NSNotification *)notification {
+         [self.editDictionary removeAllObjects];
+         NSDocument *doc = [[[NSApp mainWindow] windowController] document];
+         if ([doc isEqual:[notification object]])
+             [self updateForDocument:doc];
+     }
+     */
+
+    override func showWindow(_ sender: Any?) {
+        super.showWindow(sender)
+        
+        self.editDictionary.removeAllObjects()
+        self.attributesTableView.reloadData()
+    }
+    /*
+
+     #define BYTE_FACTOR 1024
+     #define BYTE_FACTOR_F 1024.0f
+     #define BYTE_SHIFT 10
+
+     static NSString *SKFileSizeStringForFileURL(NSURL *fileURL, unsigned long long *physicalSizePtr, unsigned long long *logicalSizePtr) {
+         if (fileURL == nil)
+             return @"";
+         
+         FSRef fileRef;
+         FSCatalogInfo catalogInfo;
+         unsigned long long size, logicalSize = 0;
+         BOOL gotSize = NO, isDir = NO;
+         NSMutableString *string = [NSMutableString string];
+         
+         Boolean gotRef = CFURLGetFSRef((CFURLRef)fileURL, &fileRef);
+         if (gotRef && noErr == FSGetCatalogInfo(&fileRef, kFSCatInfoDataSizes | kFSCatInfoRsrcSizes | kFSCatInfoNodeFlags, &catalogInfo, NULL, NULL, NULL)) {
+             size = catalogInfo.dataPhysicalSize + catalogInfo.rsrcPhysicalSize;
+             logicalSize = catalogInfo.dataLogicalSize + catalogInfo.rsrcLogicalSize;
+             isDir = (catalogInfo.nodeFlags & kFSNodeIsDirectoryMask) != 0;
+             gotSize = YES;
+         }
+         
+         if (gotSize == NO) {
+             // this seems to give the logical size
+             NSDictionary *fileAttrs = [[NSFileManager defaultManager] attributesOfItemAtPath:[fileURL path] error:NULL];
+             logicalSize = size = [[fileAttrs objectForKey:NSFileSize] unsignedLongLongValue];
+             isDir = [[fileAttrs fileType] isEqualToString:NSFileTypeDirectory];
+         }
+         
+         if (isDir) {
+             NSString *path = [fileURL path];
+             unsigned long long componentSize;
+             unsigned long long logicalComponentSize;
+             for (NSString *file in [[NSFileManager defaultManager] subpathsOfDirectoryAtPath:path error:NULL]) {
+                 SKFileSizeStringForFileURL([NSURL fileURLWithPath:[path stringByAppendingPathComponent:file]], &componentSize, &logicalComponentSize);
+                 size += componentSize;
+                 logicalSize += logicalComponentSize;
+             }
+         }
+         
+         if (physicalSizePtr)
+             *physicalSizePtr = size;
+         if (logicalSizePtr)
+             *logicalSizePtr = logicalSize;
+         
+         if (size < BYTE_FACTOR) {
+             [string appendFormat:@"%qu %@", size, NSLocalizedString(@"bytes", @"size unit")];
+         } else {
+             #define numUnits 6
+             NSString *units[numUnits] = {NSLocalizedString(@"kB", @"size unit"), NSLocalizedString(@"MB", @"size unit"), NSLocalizedString(@"GB", @"size unit"), NSLocalizedString(@"TB", @"size unit"), NSLocalizedString(@"PB", @"size unit"), NSLocalizedString(@"EB", @"size unit")};
+             NSUInteger i;
+             for (i = 0; i < numUnits; i++, size >>= BYTE_SHIFT) {
+                 if ((size >> BYTE_SHIFT) < BYTE_FACTOR || i == numUnits - 1) {
+                     [string appendFormat:@"%.1f %@", size / BYTE_FACTOR_F, units[i]];
+                     break;
+                 }
+             }
+         }
+         
+         NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
+         
+         [formatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
+         [formatter setNumberStyle:NSNumberFormatterDecimalStyle];
+         [string appendFormat:@" (%@ %@)", [formatter stringFromNumber:[NSNumber numberWithUnsignedLongLong:logicalSize]], NSLocalizedString(@"bytes", @"size unit")];
+         
+         return string;
+     }
+
+     - (NSArray *)keys {
+         return [attributesKeys arrayByAddingObjectsFromArray:summaryKeys];
+     }
+     */
+}
+
+extension KMInfoWindowController: NSTableViewDelegate, NSTableViewDataSource {
+    func numberOfRows(in tableView: NSTableView) -> Int {
+        if (tableView.isEqual(to: self.summaryTableView)) {
+            return self.summaryKeys.count
+        } else if (tableView.isEqual(to: self.attributesTableView)) {
+            return self.attributesKeys.count
+        }
+        return 0
+    }
+    
+    func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
+        var shortDateFormatter = DateFormatter()
+        shortDateFormatter.dateStyle = .short
+        shortDateFormatter.timeStyle = .none
+        
+        var keys: [String]?
+        if (tableView.isEqual(to: self.summaryTableView)) {
+            keys = self.summaryKeys
+        } else if (tableView.isEqual(to: self.attributesTableView)) {
+            keys = self.attributesKeys
+        }
+        
+        let key = keys![row]
+        let tcID = tableColumn?.identifier.rawValue
+        var value: Any?
+        if (key.isEmpty) {
+            value = ""
+        } else {
+            if let data = tcID, data == LABEL_COLUMN_ID {
+                value = self.labels[key] != nil ? self.labels[key] : key.appending(":")
+            } else if let data = tcID, data == VALUE_COLUMN_ID {
+                value = self.info?.object(forKey: key)
+                if (value == nil) {
+                    value = "-"
+                } else if let data = value as? NSDate {
+                    value = shortDateFormatter.string(from: data as Date)
+                } else if let data = value as? NSNumber {
+                    if (key == KMInfoEncryptedKey) {
+                        value = data.boolValue ? KMLocalizedString("Yes", "") : KMLocalizedString("No", "")
+                    } else {
+                        value = key == KMInfoPageCountKey ? data.stringValue : (data.boolValue ? KMLocalizedString("Allowed", "") : KMLocalizedString("Not Allowed", ""))
+                    }
+                }
+            }
+        }
+        
+        var cellView = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: tcID ?? ""), owner: self) as? NSTableCellView
+        cellView?.textField?.stringValue = (value as? String) ?? ""
+        if (tableView.isEqual(to: self.attributesTableView) && tableColumn?.identifier.rawValue == VALUE_COLUMN_ID) {
+            if (row == 0 || row == 1 || row == 2 || row == 3 || row == 7) {
+                cellView?.textField?.bezelStyle = .squareBezel
+                cellView?.textField?.isEditable = true
+                cellView?.textField?.isSelectable = true
+                cellView?.textField?.isBordered = true
+                cellView?.textField?.isBezeled = true
+                cellView?.textField?.drawsBackground = true
+                cellView?.textField?.delegate = self
+                
+                if (row == 1) {
+                    let cell = tableView.view(atColumn: 1, row: 0, makeIfNecessary: true) as? NSTableCellView
+                    cell?.textField?.nextKeyView = cellView!.textField
+                } else if (row == 2) {
+                    let cell = tableView.view(atColumn: 1, row: 1, makeIfNecessary: true) as? NSTableCellView
+                    cell?.textField?.nextKeyView = cellView!.textField
+                } else if (row == 3) {
+                    let cell = tableView.view(atColumn: 1, row: 2, makeIfNecessary: true) as? NSTableCellView
+                    cell?.textField?.nextKeyView = cellView!.textField
+                } else if (row == 7) {
+                    let cell = tableView.view(atColumn: 1, row: 3, makeIfNecessary: true) as? NSTableCellView
+                    cell?.textField?.nextKeyView = cellView!.textField
+                }
+            } else {
+                cellView?.textField?.isEditable = false
+                cellView?.textField?.isSelectable = false
+                cellView?.textField?.isBordered = false
+                cellView?.textField?.isBezeled = false
+                cellView?.textField?.drawsBackground = false
+                cellView?.textField?.delegate = nil;
+            }
+            cellView?.textField?.tag = row
+        }
+    
+        return cellView
+    }
+    
+    func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat {
+        var rowHeight = tableView.rowHeight
+        if (tableView.isEqual(to: self.attributesTableView) && row == tableView.numberOfRows-1) {
+            
+            //        }
+            //        if ([tv isEqual:attributesTableView] && row == [tv numberOfRows] - 1)
+            rowHeight = fmax(rowHeight, NSHeight(tableView.enclosingScrollView?.bounds ?? NSZeroRect) - tableView.numberOfRows.cgFloat * (rowHeight + tableView.intercellSpacing.height) + rowHeight)
+        }
+        return rowHeight
+    }
+    /*
+     - (id)tableView:(NSTableView *)tv objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
+         static NSDateFormatter *shortDateFormatter = nil;
+         if(shortDateFormatter == nil) {
+             shortDateFormatter = [[NSDateFormatter alloc] init];
+             [shortDateFormatter setDateStyle:NSDateFormatterShortStyle];
+             [shortDateFormatter setTimeStyle:NSDateFormatterNoStyle];
+         }
+         NSArray *keys = nil;
+         if ([tv isEqual:summaryTableView])
+             keys = summaryKeys;
+         else if ([tv isEqual:attributesTableView])
+             keys = attributesKeys;
+         NSString *key = [keys objectAtIndex:row];
+         NSString *tcID = [tableColumn identifier];
+         id value = nil;
+         if ([key length]) {
+             if ([tcID isEqualToString:LABEL_COLUMN_ID]) {
+                 value = [labels objectForKey:key] ?: [key stringByAppendingString:@":"];
+             } else if ([tcID isEqualToString:VALUE_COLUMN_ID]) {
+                 value = [info objectForKey:key];
+                 if (value == nil)
+                     value = @"-";
+                 else if ([value isKindOfClass:[NSDate class]])
+                     value = [shortDateFormatter stringFromDate:value];
+                 else if ([value isKindOfClass:[NSNumber class]]){
+                     if ([key isEqualToString:SKInfoEncryptedKey]) {
+                         value = [value boolValue] ? NSLocalizedString(@"Yes", @"") : NSLocalizedString(@"No", @"");
+                     } else {
+                         value = ([key isEqualToString:SKInfoPageCountKey] ? [value stringValue] : ([value boolValue] ? NSLocalizedString(@"Allowed", @"") : NSLocalizedString(@"Not Allowed", @"")));
+                     }
+                 }
+             }
+         }
+         return value;
+     }
+
+     - (void)tableView:(NSTableView *)tv willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
+         if ([tv isEqual:attributesTableView] && [[tableColumn identifier] isEqualToString:LABEL_COLUMN_ID])
+             [cell setLineBreakMode:row == [tv numberOfRows] - 1 ? NSLineBreakByWordWrapping : NSLineBreakByTruncatingTail];
+     }
+
+     - (CGFloat)tableView:(NSTableView *)tv heightOfRow:(NSInteger)row {
+         CGFloat rowHeight = [tv rowHeight];
+         if ([tv isEqual:attributesTableView] && row == [tv numberOfRows] - 1)
+             rowHeight = fmax(rowHeight, NSHeight([[tv enclosingScrollView] bounds]) - [tv numberOfRows] * (rowHeight + [tv intercellSpacing].height) + rowHeight);
+         return rowHeight;
+     }
+
+     - (BOOL)tableView:(NSTableView *)tv shouldSelectRow:(NSInteger)row {
+         return YES;
+     }
+
+     - (void)tabView:(NSTabView *)tabView willSelectTabViewItem:(nullable NSTabViewItem *)tabViewItem
+     {
+         if ([tabView indexOfTabViewItem:tabViewItem] == 1) {
+             if (self.currentDocument) {
+                 NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:[self infoForDocument:self.currentDocument]];
+                 for (NSString *key in self.editDictionary.allKeys) {
+                     [dic setObject:self.editDictionary[key] forKey:key];
+                 }
+                 [self setInfo:dic];
+             }
+             
+             [self.attributesTableView reloadData];
+         } else {
+             [self.summaryTableView reloadData];
+         }
+     }
+     */
+}
+
+extension KMInfoWindowController: NSTextFieldDelegate {
+    func controlTextDidChange(_ obj: Notification) {
+        if let textField = obj.object as? NSTextField {
+            if (textField.tag == 0) {
+                self.editDictionary.setObject(textField.stringValue, forKey: PDFDocumentAttribute.titleAttribute.rawValue as NSCopying)
+            } else if (textField.tag == 1) {
+                self.editDictionary.setObject(textField.stringValue, forKey: PDFDocumentAttribute.authorAttribute.rawValue as NSCopying)
+            } else if (textField.tag == 2) {
+                self.editDictionary.setObject(textField.stringValue, forKey: PDFDocumentAttribute.subjectAttribute.rawValue as NSCopying)
+            } else if (textField.tag == 3) {
+                self.editDictionary.setObject(textField.stringValue, forKey: PDFDocumentAttribute.creatorAttribute.rawValue as NSCopying)
+            } else if (textField.tag == 7) {
+                self.editDictionary.setObject(textField.stringValue, forKey: KMInfoKeywordsStringKey as NSCopying)
+            }
+        }
+    }
+}
+
+private let CM_PER_POINT = 0.035277778
+private let INCH_PER_POINT = 0.013888889
+private func KMSizeString(_ size: NSSize, _ altSize: NSSize) -> String {
+    var useMetric = false
+    if let data = ((NSLocale.current as NSLocale).object(forKey: .usesMetricSystem) as? NSNumber) {
+        useMetric = data.boolValue
+    }
+    
+    let factor = useMetric ? CM_PER_POINT : INCH_PER_POINT
+    let units = useMetric ? KMLocalizedString("cm", "size unit") : KMLocalizedString("in", "size unit")
+    if (NSEqualSizes(size, altSize)) {
+        return String(format: "%.2f x %.2f %@", size.width * factor, size.height * factor, units)
+    } else {
+        return String(format: "%.2f x %.2f %@  (%.2f x %.2f %@)", size.width * factor, size.height * factor, units, altSize.width * factor, altSize.height * factor, units)
+    }
+}

+ 0 - 63
PDF Office/PDF Master/Class/Common/OC/Property/SKInfoWindowController.h

@@ -1,63 +0,0 @@
-//
-//  SKInfoWindowController.h
-//  Skim
-//
-//  Created by Christiaan Hofman on 12/17/06.
-/*
- This software is Copyright (c) 2006-2018
- Christiaan Hofman. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- - Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
-    notice, this list of conditions and the following disclaimer in
-    the documentation and/or other materials provided with the
-    distribution.
-
- - Neither the name of Christiaan Hofman nor the names of any
-    contributors may be used to endorse or promote products derived
-    from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Cocoa/Cocoa.h>
-
-extern NSString * const kKMWindowDidBecomeMainNotificationName;
-
-@interface SKInfoWindowController : NSWindowController {
-    NSTableView *summaryTableView;
-    NSTableView *attributesTableView;
-    NSTabView *tabView;
-    NSDictionary *info;
-    NSArray *summaryKeys;
-    NSArray *attributesKeys;
-    NSDictionary *labels;
-}
-
-@property (nonatomic, retain) IBOutlet NSTableView *summaryTableView, *attributesTableView;
-@property (nonatomic, retain) IBOutlet NSTabView *tabView;
-@property (nonatomic, copy) NSDictionary *info;
-@property (nonatomic, readonly) NSArray *keys;
-@property (nonatomic, retain) NSMutableDictionary *editDictionary;
-
-+ (id)sharedInstance;
-
-- (NSDictionary *)infoForDocument:(NSDocument *)doc;
-
-@end

+ 0 - 610
PDF Office/PDF Master/Class/Common/OC/Property/SKInfoWindowController.m

@@ -1,610 +0,0 @@
-//
-//  SKInfoWindowController.m
-//  Skim
-//
-//  Created by Christiaan Hofman on 12/17/06.
-/*
- This software is Copyright (c) 2006-2018
- Christiaan Hofman. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- - Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
-    notice, this list of conditions and the following disclaimer in
-    the documentation and/or other materials provided with the
-    distribution.
-
- - Neither the name of Christiaan Hofman nor the names of any
-    contributors may be used to endorse or promote products derived
-    from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "SKInfoWindowController.h"
-#import <Quartz/Quartz.h>
-#import "SKLocalization.h"
-#import <PDF_Master-Swift.h>
-
-#define SKInfoWindowFrameAutosaveName @"SKInfoWindow"
-
-#define SKInfoVersionKey @"Version"
-#define SKInfoPageCountKey @"PageCount"
-#define SKInfoPageSizeKey @"PageSize"
-#define SKInfoPageWidthKey @"PageWidth"
-#define SKInfoPageHeightKey @"PageHeight"
-#define SKInfoKeywordsStringKey @"KeywordsString"
-#define SKInfoEncryptedKey @"Encrypted"
-#define SKInfoAllowsPrintingKey @"AllowsPrinting"
-#define SKInfoAllowsCopyingKey @"AllowsCopying"
-#define SKInfoAllowsDocumentAssemblyKey @"AllowsDocumentAssembly"
-#define SKInfoAllowsContentAccessibilityKey @"AllowsContentAccessibility"
-#define SKInfoAllowsCommentingKey @"AllowsCommenting"
-#define SKInfoAllowsFormFieldEntryKey @"AllowsFormFieldEntry"
-#define SKInfoFileNameKey @"FileName"
-#define SKInfoFileSizeKey @"FileSize"
-#define SKInfoPhysicalSizeKey @"PhysicalSize"
-#define SKInfoLogicalSizeKey @"LogicalSize"
-#define SKInfoTagsKey @"Tags"
-#define SKInfoRatingKey @"Rating"
-
-#define LABEL_COLUMN_ID @"label"
-#define VALUE_COLUMN_ID @"value"
-
-NSString * const kKMWindowDidBecomeMainNotificationName = @"KMWindowDidBecomeMainNotificationName";
-
-@interface SKInfoWindowController (SKPrivate) <NSTextFieldDelegate>
-- (void)handleViewFrameDidChangeNotification:(NSNotification *)notification;
-- (void)handleWindowDidBecomeMainNotification:(NSNotification *)notification;
-- (void)handleWindowDidResignMainNotification:(NSNotification *)notification;
-- (void)handlePDFDocumentInfoDidChangeNotification:(NSNotification *)notification;
-- (void)handleDocumentFileURLDidChangeNotification:(NSNotification *)notification;
-
-@end
-
-@interface SKInfoWindowController ()
-
-@property (nonatomic, weak) NSDocument *currentDocument;
-
-@end
-
-@implementation SKInfoWindowController
-
-@synthesize summaryTableView, attributesTableView, tabView, info, editDictionary;
-@dynamic keys;
-
-static SKInfoWindowController *sharedInstance = nil;
-    
-+ (id)sharedInstance {
-    @synchronized (self) {
-        if (sharedInstance == nil) {
-            sharedInstance = [[super allocWithZone:NULL] init];
-        }
-    }
-    return sharedInstance;
-}
-
-+ (instancetype)allocWithZone:(struct _NSZone *)zone {
-    return  [self sharedInstance];
-}
-
-- (id)init {
-    if (sharedInstance) NSLog(@"Attempt to allocate second instance of %@", [self class]);
-    self = [super initWithWindowNibName:@"InfoWindow"];
-    if (self){
-        info = nil;
-        if (@available(macOS 10.13, *)) {
-            summaryKeys = [[NSArray alloc] initWithObjects:
-                           SKInfoFileNameKey,
-                           SKInfoFileSizeKey,
-                           SKInfoPageSizeKey,
-                           SKInfoPageCountKey,
-                           SKInfoVersionKey,
-                           @"",
-                           SKInfoEncryptedKey,
-                           SKInfoAllowsPrintingKey,
-                           SKInfoAllowsCopyingKey,
-                           SKInfoAllowsDocumentAssemblyKey,
-                           SKInfoAllowsContentAccessibilityKey,
-                           SKInfoAllowsCommentingKey,
-                           SKInfoAllowsFormFieldEntryKey,nil];
-        } else {
-            summaryKeys = [[NSArray alloc] initWithObjects:
-                           SKInfoFileNameKey,
-                           SKInfoFileSizeKey,
-                           SKInfoPageSizeKey,
-                           SKInfoPageCountKey,
-                           SKInfoVersionKey,
-                           @"",
-                           SKInfoEncryptedKey,
-                           SKInfoAllowsPrintingKey,
-                           SKInfoAllowsCopyingKey, nil];
-            
-        }
-        attributesKeys = [[NSArray alloc] initWithObjects:
-                            PDFDocumentTitleAttribute,
-                            PDFDocumentAuthorAttribute,
-                            PDFDocumentSubjectAttribute,
-                            PDFDocumentCreatorAttribute,
-                            PDFDocumentProducerAttribute,
-                            PDFDocumentCreationDateAttribute,
-                            PDFDocumentModificationDateAttribute,
-                            SKInfoKeywordsStringKey, nil];
-        labels = [[NSDictionary alloc] initWithObjectsAndKeys:
-                            NSLocalizedString(@"File name:", @"Info label"), SKInfoFileNameKey, 
-                            NSLocalizedString(@"File size:", @"Info label"), SKInfoFileSizeKey, 
-                            NSLocalizedString(@"Page size:", @"Info label"), SKInfoPageSizeKey, 
-                            NSLocalizedString(@"Page count:", @"Info label"), SKInfoPageCountKey, 
-                            NSLocalizedString(@"PDF Version:", @"Info label"), SKInfoVersionKey, 
-                            NSLocalizedString(@"Encrypted:", @"Info label"), SKInfoEncryptedKey, 
-                            NSLocalizedString(@"Printing:", @"Info label"), SKInfoAllowsPrintingKey,
-                            NSLocalizedString(@"Content Copying:", @"Info label"), SKInfoAllowsCopyingKey,
-                            NSLocalizedString(@"Document Assembly:", @"Info label"), SKInfoAllowsDocumentAssemblyKey,
-                            NSLocalizedString(@"Content Copying for Accessibility:", @"Info label"), SKInfoAllowsContentAccessibilityKey,
-                            NSLocalizedString(@"Commenting:", @"Info label"), SKInfoAllowsCommentingKey,
-                            NSLocalizedString(@"Filling of form fields:", @"Info label"), SKInfoAllowsFormFieldEntryKey,
-                            NSLocalizedString(@"Title:", @"Info label"), PDFDocumentTitleAttribute,
-                            NSLocalizedString(@"Author:", @"Info label"), PDFDocumentAuthorAttribute, 
-                            NSLocalizedString(@"Subject:", @"Info label"), PDFDocumentSubjectAttribute, 
-                            NSLocalizedString(@"Content Creator:", @"Info label"), PDFDocumentCreatorAttribute, 
-                            NSLocalizedString(@"PDF Producer:", @"Info label"), PDFDocumentProducerAttribute, 
-                            NSLocalizedString(@"Creation date:", @"Info label"), PDFDocumentCreationDateAttribute, 
-                            NSLocalizedString(@"Modification date:", @"Info label"), PDFDocumentModificationDateAttribute, 
-                            NSLocalizedString(@"Keywords:", @"Info label"), SKInfoKeywordsStringKey, nil];
-    }
-    return self;
-}
-
-- (void)dealloc {
-    [[NSNotificationCenter defaultCenter] removeObserver:self];
-}
-
-- (void)loadWindow {
-    [super loadWindow];
-    [[self window] localizeStringsFromTable:[self windowNibName]];
-}
-
-- (void)updateForDocument:(NSDocument *)doc {
-    self.currentDocument = doc;
-    
-    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:[self infoForDocument:doc]];
-    for (NSString *key in self.editDictionary.allKeys) {
-        [dic setObject:self.editDictionary[key] forKey:key];
-    }
-    [self setInfo:dic];
-    [summaryTableView reloadData];
-    [attributesTableView reloadData];
-}
-
-- (void)windowDidLoad {
-    [self updateForDocument:[[[NSApp mainWindow] windowController] document]];
-    
-    if (@available(macOS 10.13, *)) {
-    } else {
-        [self.window setFrame:CGRectMake(self.window.frame.origin.x, self.window.frame.origin.y, 460, 310) display:YES animate:YES];
-    }
-
-    [summaryTableView setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleNone];
-    [attributesTableView setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleNone];
-    
-    self.editDictionary = [NSMutableDictionary dictionary];
-    
-    [self.tabView selectTabViewItemAtIndex:1];
-
-    [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(handleViewFrameDidChangeNotification:)
-                                                 name: NSViewFrameDidChangeNotification object: [attributesTableView enclosingScrollView]];
-    [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(handleWindowDidBecomeMainNotification:) 
-                                                 name: NSWindowDidBecomeMainNotification object: nil];
-    [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(handleWindowDidResignMainNotification:) 
-                                                 name: NSWindowDidResignMainNotification object: nil];
-    [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(handlePDFDocumentInfoDidChangeNotification:) 
-                                                 name: PDFDocumentDidUnlockNotification object: nil];
-//    [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(handlePDFDocumentInfoDidChangeNotification:)
-//                                                 name: SKPDFPageBoundsDidChangeNotification object: nil];
-//    [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(handleDocumentFileURLDidChangeNotification:)
-//                                                 name: SKDocumentFileURLDidChangeNotification object: nil];
-    [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(handleWindowWillCloseNotification:)
-                                                 name: NSWindowWillCloseNotification object: nil];
-    
-    [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(km_handleWindowDidBecomeMainNotification:)
-                                                 name: kKMWindowDidBecomeMainNotificationName object: nil];
-}
-
-- (void)showWindow:(id)sender {
-    [super showWindow:nil];
-    [self.editDictionary removeAllObjects];
-    [self.attributesTableView reloadData];
-}
-
-#define BYTE_FACTOR 1024
-#define BYTE_FACTOR_F 1024.0f
-#define BYTE_SHIFT 10
-
-static NSString *SKFileSizeStringForFileURL(NSURL *fileURL, unsigned long long *physicalSizePtr, unsigned long long *logicalSizePtr) {
-    if (fileURL == nil)
-        return @"";
-    
-    FSRef fileRef;
-    FSCatalogInfo catalogInfo;
-    unsigned long long size, logicalSize = 0;
-    BOOL gotSize = NO, isDir = NO;
-    NSMutableString *string = [NSMutableString string];
-    
-    Boolean gotRef = CFURLGetFSRef((CFURLRef)fileURL, &fileRef);
-    if (gotRef && noErr == FSGetCatalogInfo(&fileRef, kFSCatInfoDataSizes | kFSCatInfoRsrcSizes | kFSCatInfoNodeFlags, &catalogInfo, NULL, NULL, NULL)) {
-        size = catalogInfo.dataPhysicalSize + catalogInfo.rsrcPhysicalSize;
-        logicalSize = catalogInfo.dataLogicalSize + catalogInfo.rsrcLogicalSize;
-        isDir = (catalogInfo.nodeFlags & kFSNodeIsDirectoryMask) != 0;
-        gotSize = YES;
-    }
-    
-    if (gotSize == NO) {
-        // this seems to give the logical size
-        NSDictionary *fileAttrs = [[NSFileManager defaultManager] attributesOfItemAtPath:[fileURL path] error:NULL];
-        logicalSize = size = [[fileAttrs objectForKey:NSFileSize] unsignedLongLongValue];
-        isDir = [[fileAttrs fileType] isEqualToString:NSFileTypeDirectory];
-    }
-    
-    if (isDir) {
-        NSString *path = [fileURL path];
-        unsigned long long componentSize;
-        unsigned long long logicalComponentSize;
-        for (NSString *file in [[NSFileManager defaultManager] subpathsOfDirectoryAtPath:path error:NULL]) {
-            SKFileSizeStringForFileURL([NSURL fileURLWithPath:[path stringByAppendingPathComponent:file]], &componentSize, &logicalComponentSize);
-            size += componentSize;
-            logicalSize += logicalComponentSize;
-        }
-    }
-    
-    if (physicalSizePtr)
-        *physicalSizePtr = size;
-    if (logicalSizePtr)
-        *logicalSizePtr = logicalSize;
-    
-    if (size < BYTE_FACTOR) {
-        [string appendFormat:@"%qu %@", size, NSLocalizedString(@"bytes", @"size unit")];
-    } else {
-        #define numUnits 6
-        NSString *units[numUnits] = {NSLocalizedString(@"kB", @"size unit"), NSLocalizedString(@"MB", @"size unit"), NSLocalizedString(@"GB", @"size unit"), NSLocalizedString(@"TB", @"size unit"), NSLocalizedString(@"PB", @"size unit"), NSLocalizedString(@"EB", @"size unit")};
-        NSUInteger i;
-        for (i = 0; i < numUnits; i++, size >>= BYTE_SHIFT) {
-            if ((size >> BYTE_SHIFT) < BYTE_FACTOR || i == numUnits - 1) {
-                [string appendFormat:@"%.1f %@", size / BYTE_FACTOR_F, units[i]];
-                break;
-            }
-        }
-    }
-    
-    NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
-    
-    [formatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
-    [formatter setNumberStyle:NSNumberFormatterDecimalStyle];
-    [string appendFormat:@" (%@ %@)", [formatter stringFromNumber:[NSNumber numberWithUnsignedLongLong:logicalSize]], NSLocalizedString(@"bytes", @"size unit")];
-    
-    return string;
-}
-
-#define CM_PER_POINT 0.035277778
-#define INCH_PER_POINT 0.013888889
-
-static inline 
-NSString *SKSizeString(NSSize size, NSSize altSize) {
-    BOOL useMetric = [[[NSLocale currentLocale] objectForKey:NSLocaleUsesMetricSystem] boolValue];
-    NSString *units = useMetric ? NSLocalizedString(@"cm", @"size unit") : NSLocalizedString(@"in", @"size unit");
-    CGFloat factor = useMetric ? CM_PER_POINT : INCH_PER_POINT;
-    if (NSEqualSizes(size, altSize))
-        return [NSString stringWithFormat:@"%.2f x %.2f %@", size.width * factor, size.height * factor, units];
-    else
-        return [NSString stringWithFormat:@"%.2f x %.2f %@  (%.2f x %.2f %@)", size.width * factor, size.height * factor, units, altSize.width * factor, altSize.height * factor, units];
-}
-
-- (NSDictionary *)infoForDocument:(NSDocument *)doc {
-    NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
-    unsigned long long logicalSize = 0, physicalSize = 0;
-    
-    if ([doc isKindOfClass:KMMainDocument.class]) {
-        CPDFDocument *pdfDoc = ((KMMainDocument *)doc).mainViewController.document;
-        if (pdfDoc != nil) {
-            [dictionary addEntriesFromDictionary:[pdfDoc documentAttributes]];
-            [dictionary setValue:[NSString stringWithFormat: @"%ld.%ld", (long)[pdfDoc majorVersion], (long)[pdfDoc minorVersion]] forKey:SKInfoVersionKey];
-            [dictionary setValue:[NSNumber numberWithInteger:[pdfDoc pageCount]] forKey:SKInfoPageCountKey];
-            if ([pdfDoc pageCount]) {
-                NSSize cropSize = [[pdfDoc pageAtIndex:0] boundsForBox:CPDFDisplayCropBox].size;
-                NSSize mediaSize = [[pdfDoc pageAtIndex:0] boundsForBox:CPDFDisplayMediaBox].size;
-                [dictionary setValue:SKSizeString(cropSize, mediaSize) forKey:SKInfoPageSizeKey];
-                [dictionary setValue:[NSNumber numberWithDouble:cropSize.width] forKey:SKInfoPageWidthKey];
-                [dictionary setValue:[NSNumber numberWithDouble:cropSize.height] forKey:SKInfoPageHeightKey];
-            }
-            NSArray *keyworks = [dictionary valueForKey:CPDFDocumentKeywordsAttribute];
-            if ([keyworks isKindOfClass:[NSArray class]]) {
-                [dictionary setValue:[[dictionary valueForKey:CPDFDocumentKeywordsAttribute] componentsJoinedByString:@"\n"] forKey:SKInfoKeywordsStringKey];
-            }
-            
-            [dictionary setValue:[NSNumber numberWithBool:[pdfDoc isEncrypted]] forKey:SKInfoEncryptedKey];
-            [dictionary setValue:[NSNumber numberWithBool:[pdfDoc allowsPrinting]] forKey:SKInfoAllowsPrintingKey];
-            [dictionary setValue:[NSNumber numberWithBool:[pdfDoc allowsCopying]] forKey:SKInfoAllowsCopyingKey];
-            
-            if (@available(macOS 10.13, *)) {
-//                [dictionary setValue:[NSNumber numberWithBool:[pdfDoc allowsContentAccessibility]] forKey:SKInfoAllowsContentAccessibilityKey];
-                [dictionary setValue:[NSNumber numberWithBool:[pdfDoc allowsCommenting]] forKey:SKInfoAllowsCommentingKey];
-                [dictionary setValue:[NSNumber numberWithBool:[pdfDoc allowsDocumentAssembly]] forKey:SKInfoAllowsDocumentAssemblyKey];
-                [dictionary setValue:[NSNumber numberWithBool:[pdfDoc allowsFormFieldEntry]] forKey:SKInfoAllowsFormFieldEntryKey];
-            }
-        }
-    }
-    [dictionary setValue:[[[doc fileURL] path] lastPathComponent] forKey:SKInfoFileNameKey];
-    [dictionary setValue:SKFileSizeStringForFileURL([doc fileURL], &physicalSize, &logicalSize) forKey:SKInfoFileSizeKey];
-    [dictionary setValue:[NSNumber numberWithUnsignedLongLong:physicalSize] forKey:SKInfoPhysicalSizeKey];
-    [dictionary setValue:[NSNumber numberWithUnsignedLongLong:logicalSize] forKey:SKInfoLogicalSizeKey];
-//    if ([doc respondsToSelector:@selector(tags)])
-//        [dictionary setValue:[(KMMainDocument *)doc tags] ?: [NSArray array] forKey:SKInfoTagsKey];
-//    if ([doc respondsToSelector:@selector(rating)])
-//        [dictionary setValue:[NSNumber numberWithDouble:[(KMMainDocument *)doc rating]] forKey:SKInfoRatingKey];
-    
-    return dictionary;
-}
-
-- (NSArray *)keys {
-    return [attributesKeys arrayByAddingObjectsFromArray:summaryKeys];
-}
-
-- (void)handleWindowWillCloseNotification:(NSNotification *)notification {
-    id object = [notification object];
-    if ([object isEqual:self.window]) {
-        if (self.editDictionary.count > 0) {
-            NSWindowController *windowController = [[NSApp mainWindow] windowController];
-            if ([windowController isKindOfClass:[KMBrowserWindowController class]]) {
-                KMMainDocument *document = (KMMainDocument *)[(KMBrowserWindowController *)windowController document];
-                NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:[document.mainViewController.document documentAttributes]];
-                BOOL isSave = NO;
-                for (NSString *key in self.editDictionary) {
-                    if ([key isEqualToString:SKInfoKeywordsStringKey]) {
-                        NSString *string = self.editDictionary[key];
-//                        NSArray *array = [string componentsSeparatedByString:@"\n"];
-//                        if (array && ![dic[PDFDocumentKeywordsAttribute] isEqual:array]) {
-//                            isSave = YES;
-//                            [dic setObject:array forKey:PDFDocumentKeywordsAttribute];
-//                        }
-                        if (string && string.length > 0 && ![string isEqualToString:dic[PDFDocumentKeywordsAttribute]]) {
-                            isSave = YES;
-                            [dic setObject:string forKey:CPDFDocumentKeywordsAttribute];
-                        }
-                    } else {
-                        if (![dic[key] isEqualToString:self.editDictionary[key]]) {
-                            isSave = YES;
-                            [dic setObject:self.editDictionary[key] forKey:key];
-                        }
-                    }
-                }
-                if (isSave) {
-                    [document.mainViewController.document setDocumentAttributes:dic];
-                    [document saveDocument:nil];
-                }
-            }
-        }
-        [self.editDictionary removeAllObjects];
-    }
-}
-
-- (void)handleViewFrameDidChangeNotification:(NSNotification *)notification {
-    [attributesTableView noteHeightOfRowsWithIndexesChanged:[NSIndexSet indexSetWithIndex:[attributesKeys count] - 1]];
-}
-
-- (void)handleWindowDidBecomeMainNotification:(NSNotification *)notification {
-    [self.editDictionary removeAllObjects];
-    [self updateForDocument:[[[notification object] windowController] document]];
-}
-
-- (void)km_handleWindowDidBecomeMainNotification:(NSNotification *)notification {
-    [self.editDictionary removeAllObjects];
-    [self updateForDocument:notification.object];
-}
-
-- (void)handleWindowDidResignMainNotification:(NSNotification *)notification {
-    [self.editDictionary removeAllObjects];
-    [self updateForDocument:nil];
-}
-
-- (void)handlePDFDocumentInfoDidChangeNotification:(NSNotification *)notification {
-    [self.editDictionary removeAllObjects];
-    NSDocument *doc = [[[NSApp mainWindow] windowController] document];
-    if ([doc isKindOfClass:[KMMainDocument class]]) {
-        CPDFDocument *pdfDocument = ((KMMainDocument *)doc).mainViewController.document;
-        if ([pdfDocument isEqual:notification.object]) {
-            [self updateForDocument:doc];
-        }
-    }
-}
-
-- (void)handleDocumentFileURLDidChangeNotification:(NSNotification *)notification {
-    [self.editDictionary removeAllObjects];
-    NSDocument *doc = [[[NSApp mainWindow] windowController] document];
-    if ([doc isEqual:[notification object]])
-        [self updateForDocument:doc];
-}
-
-- (NSInteger)numberOfRowsInTableView:(NSTableView *)tv {
-    NSArray *keys = nil;
-    if ([tv isEqual:summaryTableView])
-        keys = summaryKeys;
-    else if ([tv isEqual:attributesTableView])
-        keys = attributesKeys;
-    return [keys count];
-}
-
-- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
-    static NSDateFormatter *shortDateFormatter = nil;
-    if(shortDateFormatter == nil) {
-        shortDateFormatter = [[NSDateFormatter alloc] init];
-        [shortDateFormatter setDateStyle:NSDateFormatterShortStyle];
-        [shortDateFormatter setTimeStyle:NSDateFormatterNoStyle];
-    }
-    NSArray *keys = nil;
-    if ([tableView isEqual:summaryTableView]) {
-        keys = summaryKeys;
-    } else if ([tableView isEqual:attributesTableView]) {
-        keys = attributesKeys;
-    }
-    NSString *key = [keys objectAtIndex:row];
-    NSString *tcID = [tableColumn identifier];
-    id value = nil;
-    if ([key length]) {
-        if ([tcID isEqualToString:LABEL_COLUMN_ID]) {
-            value = [labels objectForKey:key] ?: [key stringByAppendingString:@":"];
-        } else if ([tcID isEqualToString:VALUE_COLUMN_ID]) {
-            value = [info objectForKey:key];
-            if (value == nil)
-                value = @"-";
-            else if ([value isKindOfClass:[NSDate class]])
-                value = [shortDateFormatter stringFromDate:value];
-            else if ([value isKindOfClass:[NSNumber class]]){
-                if ([key isEqualToString:SKInfoEncryptedKey]) {
-                    value = [value boolValue] ? NSLocalizedString(@"Yes", @"") : NSLocalizedString(@"No", @"");
-                } else {
-                    value = ([key isEqualToString:SKInfoPageCountKey] ? [value stringValue] : ([value boolValue] ? NSLocalizedString(@"Allowed", @"") : NSLocalizedString(@"Not Allowed", @"")));
-                }
-            }
-        }
-    } else {
-        value = @"";
-    }
-    NSTableCellView *cellView = [tableView makeViewWithIdentifier:tcID owner:self];
-    cellView.textField.stringValue = value;
-    if ([tableView isEqual:attributesTableView] && [[tableColumn identifier] isEqualToString:VALUE_COLUMN_ID]) {
-        if (row == 0 || row == 1 || row == 2 || row == 3 || row == 7) {
-            cellView.textField.bezelStyle = NSTextFieldSquareBezel;
-            cellView.textField.editable = YES;
-            cellView.textField.selectable = YES;
-            cellView.textField.bordered = YES;
-            cellView.textField.bezeled = YES;
-            cellView.textField.drawsBackground = YES;
-            cellView.textField.delegate = self;
-            
-            if (row == 1) {
-                NSTableCellView *cell = [tableView viewAtColumn:1 row:0 makeIfNecessary:YES];
-                cell.textField.nextKeyView = cellView.textField;
-            } else if (row == 2) {
-                NSTableCellView *cell = [tableView viewAtColumn:1 row:1 makeIfNecessary:NO];
-                cell.textField.nextKeyView = cellView.textField;
-            } else if (row == 3) {
-                NSTableCellView *cell = [tableView viewAtColumn:1 row:2 makeIfNecessary:NO];
-                cell.textField.nextKeyView = cellView.textField;
-            } else if (row == 7) {
-                NSTableCellView *cell = [tableView viewAtColumn:1 row:3 makeIfNecessary:NO];
-                cell.textField.nextKeyView = cellView.textField;
-            }
-        } else {
-            cellView.textField.editable = NO;
-            cellView.textField.selectable = NO;
-            cellView.textField.bordered = NO;
-            cellView.textField.bezeled = NO;
-            cellView.textField.drawsBackground = NO;
-            cellView.textField.delegate = nil;
-        }
-        cellView.textField.tag = row;
-    }
-    
-    return cellView;
-}
-
-- (id)tableView:(NSTableView *)tv objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
-    static NSDateFormatter *shortDateFormatter = nil;
-    if(shortDateFormatter == nil) {
-        shortDateFormatter = [[NSDateFormatter alloc] init];
-        [shortDateFormatter setDateStyle:NSDateFormatterShortStyle];
-        [shortDateFormatter setTimeStyle:NSDateFormatterNoStyle];
-    }
-    NSArray *keys = nil;
-    if ([tv isEqual:summaryTableView])
-        keys = summaryKeys;
-    else if ([tv isEqual:attributesTableView])
-        keys = attributesKeys;
-    NSString *key = [keys objectAtIndex:row];
-    NSString *tcID = [tableColumn identifier];
-    id value = nil;
-    if ([key length]) {
-        if ([tcID isEqualToString:LABEL_COLUMN_ID]) {
-            value = [labels objectForKey:key] ?: [key stringByAppendingString:@":"];
-        } else if ([tcID isEqualToString:VALUE_COLUMN_ID]) {
-            value = [info objectForKey:key];
-            if (value == nil)
-                value = @"-";
-            else if ([value isKindOfClass:[NSDate class]])
-                value = [shortDateFormatter stringFromDate:value];
-            else if ([value isKindOfClass:[NSNumber class]]){
-                if ([key isEqualToString:SKInfoEncryptedKey]) {
-                    value = [value boolValue] ? NSLocalizedString(@"Yes", @"") : NSLocalizedString(@"No", @"");
-                } else {
-                    value = ([key isEqualToString:SKInfoPageCountKey] ? [value stringValue] : ([value boolValue] ? NSLocalizedString(@"Allowed", @"") : NSLocalizedString(@"Not Allowed", @"")));
-                }
-            }
-        }
-    }
-    return value;
-}
-
-- (void)tableView:(NSTableView *)tv willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
-    if ([tv isEqual:attributesTableView] && [[tableColumn identifier] isEqualToString:LABEL_COLUMN_ID])
-        [cell setLineBreakMode:row == [tv numberOfRows] - 1 ? NSLineBreakByWordWrapping : NSLineBreakByTruncatingTail];
-}
-
-- (CGFloat)tableView:(NSTableView *)tv heightOfRow:(NSInteger)row {
-    CGFloat rowHeight = [tv rowHeight];
-    if ([tv isEqual:attributesTableView] && row == [tv numberOfRows] - 1)
-        rowHeight = fmax(rowHeight, NSHeight([[tv enclosingScrollView] bounds]) - [tv numberOfRows] * (rowHeight + [tv intercellSpacing].height) + rowHeight);
-    return rowHeight;
-}
-
-- (BOOL)tableView:(NSTableView *)tv shouldSelectRow:(NSInteger)row {
-    return YES;
-}
-
-- (void)tabView:(NSTabView *)tabView willSelectTabViewItem:(nullable NSTabViewItem *)tabViewItem
-{
-    if ([tabView indexOfTabViewItem:tabViewItem] == 1) {
-        if (self.currentDocument) {
-            NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:[self infoForDocument:self.currentDocument]];
-            for (NSString *key in self.editDictionary.allKeys) {
-                [dic setObject:self.editDictionary[key] forKey:key];
-            }
-            [self setInfo:dic];
-        }
-        
-        [self.attributesTableView reloadData];
-    } else {
-        [self.summaryTableView reloadData];
-    }
-}
-
-#pragma mark - NSTextFieldDelegate
-- (void)controlTextDidChange:(NSNotification *)obj {
-    NSTextField *textField = (NSTextField*)[obj object];
-    if (textField.tag == 0) {
-        [self.editDictionary setObject:textField.stringValue forKey:PDFDocumentTitleAttribute];
-    } else if (textField.tag == 1) {
-        [self.editDictionary setObject:textField.stringValue forKey:PDFDocumentAuthorAttribute];
-    } else if (textField.tag == 2) {
-        [self.editDictionary setObject:textField.stringValue forKey:PDFDocumentSubjectAttribute];
-    } else if (textField.tag == 3) {
-        [self.editDictionary setObject:textField.stringValue forKey:PDFDocumentCreatorAttribute];
-    } else if (textField.tag == 7) {
-        [self.editDictionary setObject:textField.stringValue forKey:SKInfoKeywordsStringKey];
-    }
-}
-
-@end

+ 4 - 3
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/AppKitCategories/PDFListView+KMExtensions.swift

@@ -89,11 +89,12 @@ import Foundation
     }
     
     func PDFListViewFirstCharacter() -> u_char {
-        if let characters = self.charactersIgnoringModifiers as? NSString {
-            if (characters.length == 0) {
+        if let characters = self.charactersIgnoringModifiers?.utf16 {
+            if (characters.count == 0) {
                 return 0
             }
-            characters.character(at: 0)
+//            characters.character(at: 0)
+            return u_char(characters.first!)
         }
         return 0
     }

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

@@ -80,7 +80,7 @@ extension KMMainViewController {
     }
     
     @IBAction func menuItemAction_property(_ sender: Any) {
-        SKInfoWindowController().showWindow(nil)
+        KMInfoWindowController.shared.showWindow(sender)
     }
     
     @IBAction func menuItemAction_print(_ sender: Any) {

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

@@ -213,7 +213,7 @@ import Cocoa
         
         self.view.window?.makeFirstResponder(self.listView)
         // 更新属性页面的信息
-        NotificationCenter.default.post(name: NSNotification.Name(rawValue: kKMWindowDidBecomeMainNotificationName), object: self.myDocument)
+        NotificationCenter.default.post(name: KMInfoWindowC.windowDidBecomeMainNotification, object: self.myDocument)
         
         if (self.document == nil) {
             return

+ 1 - 0
PDF Office/PDF Master/PDF_Master DMG-Bridging-Header.h

@@ -61,3 +61,4 @@
 #import "KMRecommondManager.h"
 #import "CPDFListView+Extension.h"
 #import <Sparkle/Sparkle.h>
+#import "SKLocalization.h"

+ 1 - 1
PDF Office/PDF Master/PDF_Master-Bridging-Header.h

@@ -51,7 +51,6 @@
 #import "KMConvertPDFManagerOC.h"
 #import "GBDeviceInfo.h"
 #import "KMEmailSubWindowController.h"
-#import "SKInfoWindowController.h"
 #import "SKKeychain.h"
 #import "CSelfSignAnnotationFreeText.h"
 #import "CSelfSignAnnotation.h"
@@ -61,3 +60,4 @@
 
 #import "NSGeometry+PDFListView.h"
 #import "CPDFAnnotationHeader.h"
+#import "SKLocalization.h"