|
@@ -714,60 +714,31 @@ extension KMLeftSideViewController: NSMenuItemValidation {
|
|
|
}
|
|
|
} else {
|
|
|
let clickedOutline = self.tocOutlineView.item(atRow: self.tocOutlineView.clickedRow) as? CPDFOutline
|
|
|
- if let data = clickedOutline?.index, data > 0 {
|
|
|
- if (action == #selector(outlineContextMenuItemClicked_Demote)) {
|
|
|
- return true
|
|
|
+ if (action == #selector(outlineContextMenuItemClicked_Demote)) {
|
|
|
+ if let data = clickedOutline {
|
|
|
+ return self.pdfDocument()?.canDemote(outline: data) ?? false
|
|
|
}
|
|
|
- } else {
|
|
|
- if (action == #selector(outlineContextMenuItemClicked_Demote)) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (action == #selector(outlineContextMenuItemClicked_Promote)) {
|
|
|
+ if let data = clickedOutline {
|
|
|
+ return self.pdfDocument()?.canPromote(outline: data) ?? false
|
|
|
+ } else {
|
|
|
return false
|
|
|
}
|
|
|
}
|
|
|
- let parentOutLine = clickedOutline?.parent
|
|
|
- let grandparentOutLine = parentOutLine?.parent
|
|
|
- //if clicked PDFOutline 's parent exist
|
|
|
- if (grandparentOutLine != nil) {
|
|
|
- //and title is equla "add_AuntOutlineKey"
|
|
|
- if (action == #selector(outlineContextMenuItemClicked_AddAuntEntry)) {
|
|
|
+ if (action == #selector(outlineContextMenuItemClicked_AddAuntEntry)) {
|
|
|
+ let parentOutLine = clickedOutline?.parent
|
|
|
+ let grandparentOutLine = parentOutLine?.parent
|
|
|
+ if (grandparentOutLine != nil) {
|
|
|
return true
|
|
|
- } else if (action == #selector(outlineContextMenuItemClicked_Promote)){
|
|
|
- return true
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (action == #selector(outlineContextMenuItemClicked_AddAuntEntry)) {
|
|
|
- return false
|
|
|
- }else if (action == #selector(outlineContextMenuItemClicked_Promote)){
|
|
|
+ } else {
|
|
|
return false
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return true
|
|
|
- }
|
|
|
-// else
|
|
|
-// if ([menuItem action] == @selector(toggleEncryptFilePanel:)) {
|
|
|
-// [menuItem setTitle:NSLocalizedString(@"Set Passwords", @"Menu item title")];
|
|
|
-// NSURL *fileURL = [self.pdfView.document documentURL];
|
|
|
-// if (!fileURL) {
|
|
|
-// return YES;
|
|
|
-// }
|
|
|
-// PDFDocument *pdfDoc = [[[PDFDocument alloc] initWithURL:fileURL] autorelease];
|
|
|
-//
|
|
|
-// if ([pdfDoc isLocked]) {
|
|
|
-// [menuItem setTitle:NSLocalizedString(@"Remove Security", @"Menu item title")];
|
|
|
-// }
|
|
|
-// } else if (action == @selector(toggleToolbarShow:)) {
|
|
|
-// NSToolbar *toolbar = [self.window toolbar];
|
|
|
-// if ([toolbar isVisible])
|
|
|
-// [menuItem setTitle:NSLocalizedString(@"Hide Toolbar", @"Menu item title")];
|
|
|
-// else
|
|
|
-// [menuItem setTitle:NSLocalizedString(@"Show Toolbar", @"Menu item title")];
|
|
|
-// return YES;
|
|
|
-// } else if (action == @selector(readMode:)) {
|
|
|
-// menuItem.state = self.isReadMode ? NSControlStateValueOn : NSControlStateValueOff;
|
|
|
-// return YES;
|
|
|
-// } else if (action == @selector(addForm:)) {
|
|
|
-// return YES;
|
|
|
- else if action == #selector(toggleOutlineCaseInsensitiveSearch) {
|
|
|
+ } else if action == #selector(toggleOutlineCaseInsensitiveSearch) {
|
|
|
menuItem.state = self.outlineIgnoreCaseFlag ? .on : .off
|
|
|
return true
|
|
|
}
|