|
@@ -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 {
|