|
@@ -53,45 +53,7 @@ extension KMLeftSideViewController {
|
|
|
NSMenu.popUpContextMenu(menu, with: data, for: button)
|
|
|
}
|
|
|
} else if (tag == 302) {
|
|
|
- let menu = NSMenu()
|
|
|
- let expandAllCommentsItem = menu.addItem(title: KMLocalizedString("Expand All", nil), action: #selector(toc_expandAllComments), target: self)
|
|
|
- expandAllCommentsItem?.representedObject = self.tocOutlineView
|
|
|
-
|
|
|
- let foldAllCommentsItem = menu.addItem(title: KMLocalizedString("Collapse All", nil), action: #selector(toc_foldAllComments), target: self)
|
|
|
- expandAllCommentsItem?.representedObject = self.tocOutlineView
|
|
|
- let item = self.outlineRoot()
|
|
|
-
|
|
|
- var num = 0
|
|
|
- for i in 0 ..< Int(item?.numberOfChildren ?? 0) {
|
|
|
- let outline = item?.child(at: UInt(i))
|
|
|
- if self.tocOutlineView.isItemExpanded(outline) {
|
|
|
- num += 1
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if let cnt = item?.numberOfChildren, cnt > 0 && num == 0 {
|
|
|
- self.tocType = .fold
|
|
|
- } else if let cnt = item?.numberOfChildren, cnt > 0 && num == cnt {
|
|
|
- self.tocType = .unfold
|
|
|
- } else {
|
|
|
- self.tocType = .none
|
|
|
- }
|
|
|
-
|
|
|
- if (self.tocType == .unfold) {
|
|
|
- expandAllCommentsItem?.state = .on
|
|
|
- foldAllCommentsItem?.state = .off
|
|
|
- } else if (self.tocType == .fold) {
|
|
|
- expandAllCommentsItem?.state = .off
|
|
|
- foldAllCommentsItem?.state = .on
|
|
|
- } else {
|
|
|
- expandAllCommentsItem?.state = .off
|
|
|
- foldAllCommentsItem?.state = .off
|
|
|
- }
|
|
|
- let removeEntryItem = menu.addItem(title: KMLocalizedString("Remove All Outlines", nil), action: #selector(leftSideEmptyAnnotationClick_DeleteOutline), target: self)
|
|
|
- removeEntryItem?.representedObject = self.tocOutlineView
|
|
|
- if let data = NSApp.currentEvent {
|
|
|
- NSMenu.popUpContextMenu(menu, with: data, for: button)
|
|
|
- }
|
|
|
+ self.outlineMoreMenu(button)
|
|
|
} else if (tag == 304) {
|
|
|
let menu = NSMenu()
|
|
|
let object = KMPopupMenuObject()
|
|
@@ -463,113 +425,7 @@ extension KMLeftSideViewController: NSMenuDelegate {
|
|
|
item?.representedObject = controller
|
|
|
}
|
|
|
} else if menu.isEqual(to: self.noteOutlineView.menu) {
|
|
|
- var items: NSArray?
|
|
|
- var rowIndexes = self.noteOutlineView.selectedRowIndexes
|
|
|
- let row = self.noteOutlineView.clickedRow
|
|
|
- if (row != -1) {
|
|
|
- if rowIndexes.contains(row) == false {
|
|
|
- rowIndexes = IndexSet(integer: row)
|
|
|
- }
|
|
|
- items = self.noteOutlineView.itemsAtRowIndexes(rowIndexes) as NSArray
|
|
|
-
|
|
|
- // PDFAnnotation *foldNote = (PDFAnnotation *)notes[row];
|
|
|
-// let foldNote = self.allAnnotations[row]
|
|
|
- guard let foldNote = self.fetchNote(for: row) else {
|
|
|
- return
|
|
|
- }
|
|
|
- var isFold = true
|
|
|
- if self.allFoldNotes.contains(foldNote) {
|
|
|
- isFold = false
|
|
|
- }
|
|
|
- item = menu.addItem(title: KMLocalizedString("Expand", nil), action: #selector(unfoldNoteAction), target: self)
|
|
|
- if (isFold) {
|
|
|
- item?.state = .off
|
|
|
- } else {
|
|
|
- item?.state = .on
|
|
|
- }
|
|
|
- item?.representedObject = items
|
|
|
- item = menu.addItem(title: KMLocalizedString("Collapse", nil), action: #selector(foldNoteAction), target: self)
|
|
|
- if (isFold) {
|
|
|
- item?.state = .on
|
|
|
- } else {
|
|
|
- item?.state = .off
|
|
|
- }
|
|
|
- item?.representedObject = items
|
|
|
-
|
|
|
- menu.addItem(.separator())
|
|
|
- let hideNotes = self.hideNotes()
|
|
|
- if hideNotes == false && (items?.count ?? 0) == 1 {
|
|
|
- let annotation = self.noteItems(items!).lastObject as? CPDFAnnotation
|
|
|
- if let data = annotation?.isEditable(), data {
|
|
|
- if annotation?.type == nil {
|
|
|
- let isNote = annotation?.isNote() ?? false
|
|
|
- if isNote {
|
|
|
- // [NSLocalizedString(@"Edit", @"Menu item title") stringByAppendingEllipsis]
|
|
|
- item = menu.addItem(title: KMLocalizedString("Edit", "Menu item title"), action: #selector(editNoteTextFromTable), target: self)
|
|
|
- item?.representedObject = annotation
|
|
|
- }
|
|
|
- } else if let data = self.noteOutlineView.tableColumn(withIdentifier: NSUserInterfaceItemIdentifier("note"))?.isHidden, data {
|
|
|
-// [NSLocalizedString(@"Edit", @"Menu item title") stringByAppendingEllipsis]
|
|
|
- item = menu.addItem(title: KMLocalizedString("Edit", "Menu item title"), action: #selector(editThisAnnotation), target: self)
|
|
|
- item?.representedObject = annotation
|
|
|
- } else {
|
|
|
- item = menu.addItem(title: KMLocalizedString("Edit", "Menu item title"), action: #selector(editNoteFromTable), target: self)
|
|
|
- item?.representedObject = annotation
|
|
|
- item = menu.addItem(title: KMLocalizedString("Edit", "Menu item title"), action: #selector(editThisAnnotation), target: self)
|
|
|
- item?.representedObject = annotation
|
|
|
- item?.keyEquivalentModifierMask = [.option]
|
|
|
- item?.isAlternate = true
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if menu.numberOfItems > 0 {
|
|
|
- item = menu.addItem(title: NSLocalizedString("Export Annotations…", tableName: "MainMenu", comment: "Menu item title"), action: #selector(exportAnnotationNotes), target: self)
|
|
|
-
|
|
|
- let subMenu = NSMenu()
|
|
|
- item?.submenu = subMenu
|
|
|
- item = subMenu.addItem(title: NSLocalizedString("PDF", tableName: "MainMenu", comment: "Menu item title"), action: #selector(exportAnnotationNotes), target: self)
|
|
|
- item?.tag = 0
|
|
|
- item = subMenu.addItem(title: NSLocalizedString("PDF Bundle", tableName: "MainMenu", comment: "Menu item title"), action: #selector(exportAnnotationNotes), target: self)
|
|
|
- item?.tag = 1
|
|
|
- item = subMenu.addItem(title: NSLocalizedString("PDF Reader Pro Edition Notes", tableName: "MainMenu", comment: "Menu item title"), action: #selector(exportAnnotationNotes), target: self)
|
|
|
- item?.tag = 2
|
|
|
- item = subMenu.addItem(title: NSLocalizedString("Notes as Texts", tableName: "MainMenu", comment: "Menu item title"), action: #selector(exportAnnotationNotes), target: self)
|
|
|
- item?.tag = 3
|
|
|
- item = subMenu.addItem(title: NSLocalizedString("Notes as RTF", tableName: "MainMenu", comment: "Menu item title"), action: #selector(exportAnnotationNotes), target: self)
|
|
|
- item?.tag = 4
|
|
|
- item = subMenu.addItem(title: NSLocalizedString("Notes as RTFD", tableName: "MainMenu", comment: "Menu item title"), action: #selector(exportAnnotationNotes), target: self)
|
|
|
- item?.tag = 5
|
|
|
- item = subMenu.addItem(title: NSLocalizedString("Notes as FDF", tableName: "MainMenu", comment: "Menu item title"), action: #selector(exportAnnotationNotes), target: self)
|
|
|
- item?.tag = 6
|
|
|
-
|
|
|
- menu.addItem(.separator())
|
|
|
- if self.outlineView(self.noteOutlineView, canDeleteItems: items as? [Any] ?? []) {
|
|
|
- item = menu.addItem(title: KMLocalizedString("Delete", "Menu item title"), action: #selector(deleteNotes), target: self)
|
|
|
- item?.representedObject = items
|
|
|
- }
|
|
|
- item = menu.addItem(title: NSLocalizedString("Remove All Annotations", tableName: "MainMenu", comment: "Menu item title"), action: #selector(removeAllAnnotations), target: self)
|
|
|
- }
|
|
|
- } else {
|
|
|
- let subMenu = NSMenu()
|
|
|
- item?.submenu = subMenu
|
|
|
- item = subMenu.addItem(title: NSLocalizedString("PDF", tableName: "MainMenu", comment: "Menu item title"), action: #selector(exportAnnotationNotes), target: self)
|
|
|
- item?.tag = 0
|
|
|
- item = subMenu.addItem(title: NSLocalizedString("PDF Bundle", tableName: "MainMenu", comment: "Menu item title"), action: #selector(exportAnnotationNotes), target: self)
|
|
|
- item?.tag = 1
|
|
|
- item = subMenu.addItem(title: NSLocalizedString("PDF Reader Pro Edition Notes", tableName: "MainMenu", comment: "Menu item title"), action: #selector(exportAnnotationNotes), target: self)
|
|
|
- item?.tag = 2
|
|
|
- item = subMenu.addItem(title: NSLocalizedString("Notes as Texts", tableName: "MainMenu", comment: "Menu item title"), action: #selector(exportAnnotationNotes), target: self)
|
|
|
- item?.tag = 3
|
|
|
- item = subMenu.addItem(title: NSLocalizedString("Notes as RTF", tableName: "MainMenu", comment: "Menu item title"), action: #selector(exportAnnotationNotes), target: self)
|
|
|
- item?.tag = 4
|
|
|
- item = subMenu.addItem(title: NSLocalizedString("Notes as RTFD", tableName: "MainMenu", comment: "Menu item title"), action: #selector(exportAnnotationNotes), target: self)
|
|
|
- item?.tag = 5
|
|
|
- item = subMenu.addItem(title: NSLocalizedString("Notes as FDF", tableName: "MainMenu", comment: "Menu item title"), action: #selector(exportAnnotationNotes), target: self)
|
|
|
- item?.tag = 6
|
|
|
-
|
|
|
- item = menu.addItem(title: NSLocalizedString("Remove All Annotations", tableName: "MainMenu", comment: "Menu item title"), action: #selector(removeAllAnnotations), target: self)
|
|
|
- }
|
|
|
+ self.annoListMenu(menu)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -602,31 +458,19 @@ extension KMLeftSideViewController: NSMenuItemValidation {
|
|
|
action == #selector(outlineContextMenuItemClicked_SetDestination) ||
|
|
|
action == #selector(outlineContextMenuItemClicked_Rename) ||
|
|
|
action == #selector(outlineContextMenuItemClicked_Promote) ||
|
|
|
- action == #selector(outlineContextMenuItemClicked_Demote)) {
|
|
|
+ action == #selector(outlineContextMenuItemClicked_Demote) ||
|
|
|
+ action == #selector(leftSideEmptyAnnotationClick_DeleteOutline)) {
|
|
|
return self.outlineListValidateMenuItem(menuItem)
|
|
|
} else if action == #selector(toggleOutlineCaseInsensitiveSearch) {
|
|
|
menuItem.state = self.outlineIgnoreCaseFlag ? .on : .off
|
|
|
return true
|
|
|
- }
|
|
|
-// } else if (action == @selector(note_expandAllComments:) ||
|
|
|
-// action == @selector(note_foldAllComments:) ||
|
|
|
-// action == @selector(exportAnnotationNotes:) ||
|
|
|
-// action == @selector(leftSideEmptyAnnotationClick_DeleteAnnotation:) ||
|
|
|
-// action == @selector(removeAllAnnotations:)) {
|
|
|
-// if (@available(macOS 10.13, *)) {
|
|
|
-// if (notes.count == 0) {
|
|
|
-// return NO;
|
|
|
-// } else {
|
|
|
-// return YES;
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// if (action == @selector(note_expandAllComments:) ||
|
|
|
-// action == @selector(note_foldAllComments:)) {
|
|
|
-// return NO;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// } else
|
|
|
- if (action == #selector(unfoldNoteAction) ||
|
|
|
+ } else if (action == #selector(note_expandAllComments) ||
|
|
|
+ action == #selector(note_foldAllComments) ||
|
|
|
+ action == #selector(exportAnnotationNotes) ||
|
|
|
+ action == #selector(leftSideEmptyAnnotationClick_DeleteAnnotation) ||
|
|
|
+ action == #selector(removeAllAnnotations)) {
|
|
|
+ return self.annotations.count > 0
|
|
|
+ } else if (action == #selector(unfoldNoteAction) ||
|
|
|
action == #selector(foldNoteAction)) {
|
|
|
let row = self.noteOutlineView.clickedRow
|
|
|
// NSArray *noteArr = [rightSideController.noteArrayController arrangedObjects];
|
|
@@ -647,48 +491,23 @@ extension KMLeftSideViewController: NSMenuItemValidation {
|
|
|
} else {
|
|
|
return true
|
|
|
}
|
|
|
- }
|
|
|
-// else if (action == @selector(editNoteFromTable:)) {
|
|
|
-// NSInteger row = [rightSideController.noteOutlineView clickedRow];
|
|
|
-// NSArray * noteArr = [rightSideController.noteArrayController arrangedObjects];
|
|
|
-// PDFAnnotation *foldNote = (PDFAnnotation *)noteArr[row];
|
|
|
+ } else if (action == #selector(editNoteFromTable)) {
|
|
|
+ let row = self.noteOutlineView.clickedRow
|
|
|
+ let foldNote = self.fetchNote(for: row)
|
|
|
// if (@available(macOS 10.13, *)) {
|
|
|
// if ([foldNote.widgetFieldType isEqualToString:PDFAnnotationWidgetSubtypeSignature]) {
|
|
|
// return NO;
|
|
|
// }
|
|
|
// }
|
|
|
-// if ([foldNote isKindOfClass:[PDFAnnotationStamp class]] ||
|
|
|
-// [foldNote isKindOfClass:[KMAnnotationStamp class]]) {
|
|
|
-// return NO;
|
|
|
-// } else {
|
|
|
-// return YES;
|
|
|
-// }
|
|
|
-// }
|
|
|
- else if (action == #selector(menuItemClick_SelectAll)) {
|
|
|
+ if foldNote is CPDFStampAnnotation || foldNote is KMAnnotationStamp || foldNote is CPDFListStampAnnotation {
|
|
|
+ return false
|
|
|
+ } else {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ } else if (action == #selector(menuItemClick_SelectAll)) {
|
|
|
menuItem.state = self.snapshotListIsAllSelected() ? .on : .off
|
|
|
return true
|
|
|
}
|
|
|
-// else if (action == @selector(leftSideEmptyAnnotationClick_DeleteOutline:)) {
|
|
|
-// PDFOutline * item = [[pdfView document] outlineRoot];
|
|
|
-// if (self.isSearchOutlineMode) {
|
|
|
-// NSInteger num = 0;
|
|
|
-// for (NSUInteger i = 0; i < [item numberOfChildren]; i++) {
|
|
|
-// PDFOutline *outline = [item childAtIndex:i];
|
|
|
-// if ([self hasContainString:self.leftSideController.outlineSearchField.stringValue rootOutline:outline]) {
|
|
|
-// num ++;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// if (num > 0)
|
|
|
-// return YES;
|
|
|
-// else
|
|
|
-// return NO;
|
|
|
-// } else {
|
|
|
-// if ([item numberOfChildren] > 0)
|
|
|
-// return YES;
|
|
|
-// else
|
|
|
-// return NO;
|
|
|
-// }
|
|
|
-// }
|
|
|
return true
|
|
|
}
|
|
|
}
|