Kaynağa Gözat

【2025】【综合】
1、菜单栏完善
2、文件信息界面补充文件大小

niehaoyu 4 hafta önce
ebeveyn
işleme
13ea84075c

+ 4 - 1
PDF Office/PDF Master/AppDelegate+MenuAction.swift

@@ -271,7 +271,8 @@ extension AppDelegate {
                          NSSelectorFromString("menuItemAction_showInFinder:"),
                          NSSelectorFromString("menuItemAction_showInFinder:"),
                          NSSelectorFromString("menuItemAction_property:"),
                          NSSelectorFromString("menuItemAction_property:"),
                          NSSelectorFromString("menuItemAction_print:"),
                          NSSelectorFromString("menuItemAction_print:"),
-                         NSSelectorFromString("menuItemAction_customPrint:")]
+                         NSSelectorFromString("menuItemAction_customPrint:"),
+                         NSSelectorFromString("sharePageItemActionWithSender:")]
         if selectors.contains(selector) {
         if selectors.contains(selector) {
             return true
             return true
         }
         }
@@ -335,6 +336,8 @@ extension AppDelegate {
                 
                 
             } else if action == NSSelectorFromString("menuItemAction_customPrint:") {
             } else if action == NSSelectorFromString("menuItemAction_customPrint:") {
                 
                 
+            } else if action == NSSelectorFromString("sharePageItemActionWithSender:") {
+                return true
             }
             }
             return true
             return true
         }
         }

+ 0 - 12
PDF Office/PDF Master/Base.lproj/Main.storyboard

@@ -180,18 +180,6 @@
                                                 <action selector="menuItemAction_closeDocument:" target="Voe-Tx-rLC" id="Mwq-O0-OFF"/>
                                                 <action selector="menuItemAction_closeDocument:" target="Voe-Tx-rLC" id="Mwq-O0-OFF"/>
                                             </connections>
                                             </connections>
                                         </menuItem>
                                         </menuItem>
-                                        <menuItem title="Close Window" keyEquivalent="W" id="YcQ-xa-K0Q">
-                                            <modifierMask key="keyEquivalentModifierMask" shift="YES" command="YES"/>
-                                            <connections>
-                                                <action selector="menuItemAction_closeWindow:" target="Voe-Tx-rLC" id="9uA-Bf-wRB"/>
-                                            </connections>
-                                        </menuItem>
-                                        <menuItem title="Close All Windows" keyEquivalent="W" id="8vV-8n-kpX">
-                                            <modifierMask key="keyEquivalentModifierMask" shift="YES" option="YES" command="YES"/>
-                                            <connections>
-                                                <action selector="menuItemAction_closeAllWindows:" target="Voe-Tx-rLC" id="Ngl-jU-OnW"/>
-                                            </connections>
-                                        </menuItem>
                                         <menuItem isSeparatorItem="YES" id="GNk-He-mAO"/>
                                         <menuItem isSeparatorItem="YES" id="GNk-He-mAO"/>
                                         <menuItem title="Save" keyEquivalent="s" id="pxx-59-PXV">
                                         <menuItem title="Save" keyEquivalent="s" id="pxx-59-PXV">
                                             <connections>
                                             <connections>

+ 5 - 5
PDF Office/PDF Master/KMClass/Property/InfoWindow.xib

@@ -31,18 +31,18 @@
                         <tabViewItems>
                         <tabViewItems>
                             <tabViewItem label="Summary" identifier="1" id="94">
                             <tabViewItem label="Summary" identifier="1" id="94">
                                 <view key="view" id="95">
                                 <view key="view" id="95">
-                                    <rect key="frame" x="10" y="29" width="414" height="306"/>
+                                    <rect key="frame" x="10" y="25" width="414" height="310"/>
                                     <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                     <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                     <subviews>
                                     <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">
                                         <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="283"/>
+                                            <rect key="frame" x="17" y="17" width="380" height="287"/>
                                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                             <clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="tba-ii-VJE">
                                             <clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="tba-ii-VJE">
-                                                <rect key="frame" x="0.0" y="0.0" width="380" height="283"/>
+                                                <rect key="frame" x="0.0" y="0.0" width="380" height="287"/>
                                                 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                                 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                                 <subviews>
                                                 <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">
                                                     <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="283"/>
+                                                        <rect key="frame" x="0.0" y="0.0" width="389" height="287"/>
                                                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                                         <size key="intercellSpacing" width="3" height="2"/>
                                                         <size key="intercellSpacing" width="3" height="2"/>
                                                         <color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="calibratedRGB"/>
                                                         <color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="calibratedRGB"/>
@@ -140,7 +140,7 @@
                                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                             <clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="RKB-CK-2VI">
                                             <clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="RKB-CK-2VI">
                                                 <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="287"/>
-                                                <autoresizingMask key="autoresizingMask"/>
+                                                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                                 <subviews>
                                                 <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">
                                                     <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"/>
                                                         <rect key="frame" x="0.0" y="0.0" width="389" height="287"/>

+ 27 - 187
PDF Office/PDF Master/KMClass/Property/KMInfoWindowController.swift

@@ -9,11 +9,8 @@ import Cocoa
 
 
 /*
 /*
  #define SKInfoWindowFrameAutosaveName @"SKInfoWindow"
  #define SKInfoWindowFrameAutosaveName @"SKInfoWindow"
-
- #define LABEL_COLUMN_ID @"label"
- #define VALUE_COLUMN_ID @"value"
  */
  */
-  
+
 private let LABEL_COLUMN_ID = "label"
 private let LABEL_COLUMN_ID = "label"
 private let VALUE_COLUMN_ID = "value"
 private let VALUE_COLUMN_ID = "value"
 
 
@@ -110,15 +107,15 @@ class KMInfoWindowController: NSWindowController {
         self._labels = [KMInfoFileNameKey : KMLocalizedString("File name:"),
         self._labels = [KMInfoFileNameKey : KMLocalizedString("File name:"),
                         KMInfoFileSizeKey : KMLocalizedString("File size:"),
                         KMInfoFileSizeKey : KMLocalizedString("File size:"),
                         KMInfoPageSizeKey : KMLocalizedString("Page size:"),
                         KMInfoPageSizeKey : KMLocalizedString("Page size:"),
-                        KMInfoPageCountKey : KMLocalizedString("Page count:"),
-                        KMInfoVersionKey : KMLocalizedString("PDF Version:"),
+                       KMInfoPageCountKey : KMLocalizedString("Page count:"),
+                         KMInfoVersionKey : KMLocalizedString("PDF Version:"),
                        KMInfoEncryptedKey : KMLocalizedString("Encrypted:"),
                        KMInfoEncryptedKey : KMLocalizedString("Encrypted:"),
                   KMInfoAllowsPrintingKey : KMLocalizedString("Printing:"),
                   KMInfoAllowsPrintingKey : KMLocalizedString("Printing:"),
-                    KMInfoAllowsCopyingKey : KMLocalizedString("Content Copying:"),
-           KMInfoAllowsDocumentAssemblyKey : KMLocalizedString("Document Assembly:"),
-       KMInfoAllowsContentAccessibilityKey : KMLocalizedString("Content Copying for Accessibility:"),
-                 KMInfoAllowsCommentingKey : KMLocalizedString("Commenting:"),
-             KMInfoAllowsFormFieldEntryKey : KMLocalizedString("Filling of form fields:"),
+                   KMInfoAllowsCopyingKey : KMLocalizedString("Content Copying:"),
+          KMInfoAllowsDocumentAssemblyKey : KMLocalizedString("Document Assembly:"),
+      KMInfoAllowsContentAccessibilityKey : KMLocalizedString("Content Copying for Accessibility:"),
+                KMInfoAllowsCommentingKey : KMLocalizedString("Commenting:"),
+            KMInfoAllowsFormFieldEntryKey : KMLocalizedString("Filling of form fields:"),
                         PDFDocumentAttribute.titleAttribute.rawValue : KMLocalizedString("Title:"),
                         PDFDocumentAttribute.titleAttribute.rawValue : KMLocalizedString("Title:"),
                         PDFDocumentAttribute.authorAttribute.rawValue : KMLocalizedString("Author:"),
                         PDFDocumentAttribute.authorAttribute.rawValue : KMLocalizedString("Author:"),
                         PDFDocumentAttribute.subjectAttribute.rawValue : KMLocalizedString("Subject:"),
                         PDFDocumentAttribute.subjectAttribute.rawValue : KMLocalizedString("Subject:"),
@@ -126,25 +123,24 @@ class KMInfoWindowController: NSWindowController {
                         PDFDocumentAttribute.producerAttribute.rawValue : KMLocalizedString("PDF Producer:"),
                         PDFDocumentAttribute.producerAttribute.rawValue : KMLocalizedString("PDF Producer:"),
                         PDFDocumentAttribute.creationDateAttribute.rawValue : KMLocalizedString("Creation date:"),
                         PDFDocumentAttribute.creationDateAttribute.rawValue : KMLocalizedString("Creation date:"),
                         PDFDocumentAttribute.modificationDateAttribute.rawValue : KMLocalizedString("Modification date:"),
                         PDFDocumentAttribute.modificationDateAttribute.rawValue : KMLocalizedString("Modification date:"),
-                   KMInfoKeywordsStringKey : KMLocalizedString("Keywords:")]
+                  KMInfoKeywordsStringKey : KMLocalizedString("Keywords:")]
     }
     }
     
     
     override func loadWindow() {
     override func loadWindow() {
         super.loadWindow()
         super.loadWindow()
         
         
-//        self.window?.localizeStrings(fromTable: self.windowNibName)
     }
     }
-
+    
     override func windowDidLoad() {
     override func windowDidLoad() {
         super.windowDidLoad()
         super.windowDidLoad()
         
         
         self.window?.title = NSLocalizedString("Document Info", comment: "")
         self.window?.title = NSLocalizedString("Document Info", comment: "")
-    
+        
         self.updateForDocument(NSApp.mainWindow?.windowController?.document as? NSDocument)
         self.updateForDocument(NSApp.mainWindow?.windowController?.document as? NSDocument)
         
         
         self.summaryTableView.selectionHighlightStyle = .none
         self.summaryTableView.selectionHighlightStyle = .none
         self.attributesTableView.selectionHighlightStyle = .none
         self.attributesTableView.selectionHighlightStyle = .none
-
+        
         for item in self.tabView.tabViewItems {
         for item in self.tabView.tabViewItems {
             if item.isEqual(to: self.tabView.tabViewItems.first) {
             if item.isEqual(to: self.tabView.tabViewItems.first) {
                 item.label = NSLocalizedString("Summary", comment: "")
                 item.label = NSLocalizedString("Summary", comment: "")
@@ -153,7 +149,7 @@ class KMInfoWindowController: NSWindowController {
             }
             }
         }
         }
         self.tabView.selectTabViewItem(at: 1)
         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(_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(_handleWindowDidBecomeMainNotification), name: NSWindow.didBecomeMainNotification, object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(_handleWindowDidResignMainNotification), name: NSWindow.didResignMainNotification, object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(_handleWindowDidResignMainNotification), name: NSWindow.didResignMainNotification, object: nil)
@@ -164,7 +160,7 @@ class KMInfoWindowController: NSWindowController {
     
     
     func updateForDocument(_ doc: NSDocument?) {
     func updateForDocument(_ doc: NSDocument?) {
         self._currentDocument = doc
         self._currentDocument = doc
-
+        
         let info = self._infoForDocument(doc)
         let info = self._infoForDocument(doc)
         var dic = NSMutableDictionary(dictionary: info)
         var dic = NSMutableDictionary(dictionary: info)
         for key in self.editDictionary.allKeys {
         for key in self.editDictionary.allKeys {
@@ -180,7 +176,7 @@ class KMInfoWindowController: NSWindowController {
     }
     }
     
     
     // MARK: - Private Methods
     // MARK: - Private Methods
-     
+    
     private func _infoForDocument(_ doc: NSDocument?) -> NSDictionary {
     private func _infoForDocument(_ doc: NSDocument?) -> NSDictionary {
         var dictionary: NSMutableDictionary = NSMutableDictionary()
         var dictionary: NSMutableDictionary = NSMutableDictionary()
         var logicalSize: Int64 = 0
         var logicalSize: Int64 = 0
@@ -199,6 +195,10 @@ class KMInfoWindowController: NSWindowController {
                     dictionary.setValue(NSNumber(value: cropSize.width), forKey: KMInfoPageWidthKey)
                     dictionary.setValue(NSNumber(value: cropSize.width), forKey: KMInfoPageWidthKey)
                     dictionary.setValue(NSNumber(value: cropSize.height), forKey: KMInfoPageHeightKey)
                     dictionary.setValue(NSNumber(value: cropSize.height), forKey: KMInfoPageHeightKey)
                 }
                 }
+                let fileSize = pdfDoc.documentURL.path.getFileSize()
+                if fileSize > 0 {
+                    dictionary.setValue(NSNumber(value: fileSize), forKey: KMInfoFileSizeKey)
+                }
                 if let keyworks = dictionary.value(forKey: CPDFDocumentAttribute.keywordsAttribute.rawValue) {
                 if let keyworks = dictionary.value(forKey: CPDFDocumentAttribute.keywordsAttribute.rawValue) {
                     if (keyworks as AnyObject).isKind(of: NSArray.self) {
                     if (keyworks as AnyObject).isKind(of: NSArray.self) {
                         dictionary.setValue(keyworks, forKey: KMInfoKeywordsStringKey)
                         dictionary.setValue(keyworks, forKey: KMInfoKeywordsStringKey)
@@ -208,14 +208,14 @@ class KMInfoWindowController: NSWindowController {
                 dictionary.setValue(NSNumber(booleanLiteral: pdfDoc.allowsPrinting), forKey: KMInfoAllowsPrintingKey)
                 dictionary.setValue(NSNumber(booleanLiteral: pdfDoc.allowsPrinting), forKey: KMInfoAllowsPrintingKey)
                 dictionary.setValue(NSNumber(booleanLiteral: pdfDoc.allowsCopying), forKey: KMInfoAllowsCopyingKey)
                 dictionary.setValue(NSNumber(booleanLiteral: pdfDoc.allowsCopying), forKey: KMInfoAllowsCopyingKey)
                 
                 
-                 dictionary.setValue(NSNumber(booleanLiteral: pdfDoc.allowsCommenting), forKey: KMInfoAllowsCommentingKey)
+                dictionary.setValue(NSNumber(booleanLiteral: pdfDoc.allowsCommenting), forKey: KMInfoAllowsCommentingKey)
                 dictionary.setValue(NSNumber(booleanLiteral: pdfDoc.allowsFormFieldEntry), forKey: KMInfoAllowsDocumentAssemblyKey)
                 dictionary.setValue(NSNumber(booleanLiteral: pdfDoc.allowsFormFieldEntry), forKey: KMInfoAllowsDocumentAssemblyKey)
                 dictionary.setValue(NSNumber(booleanLiteral: pdfDoc.allowsFormFieldEntry), forKey: KMInfoAllowsFormFieldEntryKey)
                 dictionary.setValue(NSNumber(booleanLiteral: pdfDoc.allowsFormFieldEntry), forKey: KMInfoAllowsFormFieldEntryKey)
             }
             }
         }
         }
         
         
         dictionary.setValue(doc?.fileURL?.path.lastPathComponent, forKey: KMInfoFileNameKey)
         dictionary.setValue(doc?.fileURL?.path.lastPathComponent, forKey: KMInfoFileNameKey)
-         dictionary.setValue(NSNumber(value: physicalSize), forKey: KMInfoPhysicalSizeKey)
+        dictionary.setValue(NSNumber(value: physicalSize), forKey: KMInfoPhysicalSizeKey)
         dictionary.setValue(NSNumber(value: logicalSize), forKey: KMInfoLogicalSizeKey)
         dictionary.setValue(NSNumber(value: logicalSize), forKey: KMInfoLogicalSizeKey)
         return dictionary
         return dictionary
     }
     }
@@ -286,106 +286,13 @@ class KMInfoWindowController: NSWindowController {
         self.updateForDocument(sender.object as? NSDocument)
         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?) {
     override func showWindow(_ sender: Any?) {
         super.showWindow(sender)
         super.showWindow(sender)
         
         
         self.editDictionary.removeAllObjects()
         self.editDictionary.removeAllObjects()
         self.attributesTableView.reloadData()
         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 {
 extension KMInfoWindowController: NSTableViewDelegate, NSTableViewDataSource {
@@ -427,6 +334,8 @@ extension KMInfoWindowController: NSTableViewDelegate, NSTableViewDataSource {
                 } else if let data = value as? NSNumber {
                 } else if let data = value as? NSNumber {
                     if (key == KMInfoEncryptedKey) {
                     if (key == KMInfoEncryptedKey) {
                         value = data.boolValue ? KMLocalizedString("Yes") : KMLocalizedString("No")
                         value = data.boolValue ? KMLocalizedString("Yes") : KMLocalizedString("No")
+                    } else if (key == KMInfoFileSizeKey) {
+                        value = String.formatFileSize(data.int64Value)
                     } else {
                     } else {
                         value = key == KMInfoPageCountKey ? data.stringValue : (data.boolValue ? KMLocalizedString("Allowed") : KMLocalizedString("Not Allowed"))
                         value = key == KMInfoPageCountKey ? data.stringValue : (data.boolValue ? KMLocalizedString("Allowed") : KMLocalizedString("Not Allowed"))
                     }
                     }
@@ -469,87 +378,18 @@ extension KMInfoWindowController: NSTableViewDelegate, NSTableViewDataSource {
             }
             }
             cellView?.textField?.tag = row
             cellView?.textField?.tag = row
         }
         }
-    
+        
         return cellView
         return cellView
     }
     }
     
     
     func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat {
     func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat {
         var rowHeight = tableView.rowHeight
         var rowHeight = tableView.rowHeight
         if (tableView.isEqual(to: self.attributesTableView) && row == tableView.numberOfRows-1) {
         if (tableView.isEqual(to: self.attributesTableView) && row == tableView.numberOfRows-1) {
-             rowHeight = fmax(rowHeight, NSHeight(tableView.enclosingScrollView?.bounds ?? NSZeroRect) - tableView.numberOfRows.cgFloat * (rowHeight + tableView.intercellSpacing.height) + rowHeight)
+            rowHeight = fmax(rowHeight, NSHeight(tableView.enclosingScrollView?.bounds ?? NSZeroRect) - tableView.numberOfRows.cgFloat * (rowHeight + tableView.intercellSpacing.height) + rowHeight)
         }
         }
         return 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 {
 extension KMInfoWindowController: NSTextFieldDelegate {

+ 23 - 0
PDF Office/PDF Master/KMClass/Tools/Category/Foundation/String+KMExtensions.swift

@@ -133,6 +133,29 @@ extension String {
         return NSString(string: string).deletingPathExtension
         return NSString(string: string).deletingPathExtension
     }
     }
     
     
+    //获取文件大小
+    func getFileSize() -> CGFloat {
+        guard let dict = try? FileManager.default.attributesOfItem(atPath: self) as NSDictionary else {
+            return 0
+        }
+        return CGFloat(dict.fileSize())
+    }
+    
+    //转换文件大小
+    static func formatFileSize(_ bytes: Int64) -> String {
+        let units = ["byte", "KB", "MB", "GB", "TB"]
+        var size = Double(bytes)
+        var unitIndex = 0
+
+        while size >= 1024 && unitIndex < units.count - 1 {
+            size /= 1024
+            unitIndex += 1
+        }
+
+        return String(format: "%.2f %@", size, units[unitIndex])
+    }
+    
+    
 }
 }
 
 
 extension String {
 extension String {