|
@@ -430,7 +430,9 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
}
|
|
|
|
|
|
func displayThumbnailViewAnimating(_ animate: Bool) {
|
|
|
- self.replaceSideView(self.thumbnailTableView.enclosingScrollView!, animate: animate)
|
|
|
+ if let enclosingScrollView = self.thumbnailTableView.enclosingScrollView {
|
|
|
+ self.replaceSideView(enclosingScrollView, animate: animate)
|
|
|
+ }
|
|
|
|
|
|
var frame = self.thumbnailTableView.enclosingScrollView?.frame ?? .zero
|
|
|
frame.origin.y = 0
|
|
@@ -537,7 +539,9 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
self.annotationSort(sortArray: [])
|
|
|
|
|
|
self.searchViewController.contentView = nil
|
|
|
- self.replaceSideView(self.noteOutlineView.enclosingScrollView!, animate: animate)
|
|
|
+ if let data = self.noteOutlineView.enclosingScrollView {
|
|
|
+ self.replaceSideView(data, animate: animate)
|
|
|
+ }
|
|
|
if (self.findState != .note) {
|
|
|
self.findState = .note
|
|
|
} else {
|
|
@@ -559,9 +563,10 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
frame.size.height = self.snapshotTableView.enclosingScrollView?.superview?.frame.size.height ?? 0
|
|
|
self.snapshotTableView.enclosingScrollView?.frame = frame
|
|
|
|
|
|
- let view = self.noteOutlineView.enclosingScrollView!
|
|
|
+ let view = self.noteOutlineView.enclosingScrollView
|
|
|
+ let viewFrame = view?.frame ?? .zero
|
|
|
let emptyVcSize = self.leftSideEmptyVC.emptyAnnotationView.frame.size
|
|
|
- self.leftSideEmptyVC.emptyAnnotationView.frame = NSMakeRect((view.frame.size.width-emptyVcSize.width)/2.0,(view.frame.size.height-emptyVcSize.height)/2.0, emptyVcSize.width, emptyVcSize.height)
|
|
|
+ self.leftSideEmptyVC.emptyAnnotationView.frame = NSMakeRect((viewFrame.size.width-emptyVcSize.width)/2.0,(viewFrame.size.height-emptyVcSize.height)/2.0, emptyVcSize.width, emptyVcSize.height)
|
|
|
|
|
|
DispatchQueue.main.async {
|
|
|
self.noteOutlineView.reloadData()
|
|
@@ -570,7 +575,9 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
|
|
|
func displaySnapshotViewAnimating(_ animate: Bool) {
|
|
|
self.searchViewController.contentView = nil
|
|
|
- self.replaceSideView(self.snapshotTableView.enclosingScrollView!, animate: animate)
|
|
|
+ if let data = self.snapshotTableView.enclosingScrollView {
|
|
|
+ self.replaceSideView(data, animate: animate)
|
|
|
+ }
|
|
|
if (self.findState != .snapshot) {
|
|
|
self.findState = .snapshot
|
|
|
} else {
|
|
@@ -627,7 +634,9 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
}
|
|
|
|
|
|
func displayTocViewAnimating(_ animate: Bool) {
|
|
|
- self.replaceSideView(self.tocOutlineView.enclosingScrollView!, animate: animate)
|
|
|
+ if let data = self.tocOutlineView.enclosingScrollView {
|
|
|
+ self.replaceSideView(data, animate: animate)
|
|
|
+ }
|
|
|
|
|
|
var frame = self.tocOutlineView.enclosingScrollView?.frame ?? .zero
|
|
|
frame.origin.y = 0
|
|
@@ -644,10 +653,11 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
frame.size.height = self.snapshotTableView.enclosingScrollView?.superview?.frame.size.height ?? 0
|
|
|
self.snapshotTableView.enclosingScrollView?.frame = frame
|
|
|
|
|
|
- let view = self.tocOutlineView.enclosingScrollView!
|
|
|
+ let view = self.tocOutlineView.enclosingScrollView
|
|
|
+ let viewFrame = view?.frame ?? .zero
|
|
|
let emptyVcSize = self.leftSideEmptyVC.emptyOutlineView.frame.size
|
|
|
|
|
|
- self.leftSideEmptyVC.emptyOutlineView.frame = NSMakeRect((view.frame.size.width-emptyVcSize.width)/2.0,(view.frame.size.height-emptyVcSize.height)/2.0, emptyVcSize.width, emptyVcSize.height);
|
|
|
+ self.leftSideEmptyVC.emptyOutlineView.frame = NSMakeRect((viewFrame.size.width-emptyVcSize.width)/2.0,(viewFrame.size.height-emptyVcSize.height)/2.0, emptyVcSize.width, emptyVcSize.height);
|
|
|
|
|
|
DispatchQueue.main.async {
|
|
|
self.tocOutlineView.reloadData()
|
|
@@ -697,7 +707,7 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
emptyPage.setBounds(firstFrame2, for: .mediaBox)
|
|
|
emptyPage.rotation = firstPage?.rotation ?? 0
|
|
|
|
|
|
- let pageImage = firstPage!.thumbnail(of: NSMakeSize(self.thumbnailCacheSize, self.thumbnailCacheSize))
|
|
|
+ let pageImage = firstPage?.thumbnail(of: NSMakeSize(self.thumbnailCacheSize, self.thumbnailCacheSize))
|
|
|
// NSImage * = [emptyPage thumbnailWithSize:thumbnailCacheSize forBox:[pdfView displayBox]];
|
|
|
var rect: NSRect = .zero
|
|
|
rect.size = pageImage?.size ?? .zero
|
|
@@ -1376,10 +1386,14 @@ extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
|
|
|
let pasteboard = info.draggingPasteboard
|
|
|
if (pasteboard.availableType(from: [.localDraggedTypes]) != nil) {
|
|
|
result = true
|
|
|
- let rowData = pasteboard.data(forType: .localDraggedTypes)
|
|
|
- let rowIndexes = NSKeyedUnarchiver.unarchiveObject(with: rowData!) as? IndexSet ?? IndexSet()
|
|
|
- let urlData = pasteboard.data(forType: KPDFThumbnailDoucumentURLForDraggedTypes)
|
|
|
- let url = NSKeyedUnarchiver.unarchiveObject(with: urlData!) as? String
|
|
|
+ guard let rowData = pasteboard.data(forType: .localDraggedTypes) else {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ let rowIndexes = NSKeyedUnarchiver.unarchiveObject(with: rowData) as? IndexSet ?? IndexSet()
|
|
|
+ guard let urlData = pasteboard.data(forType: KPDFThumbnailDoucumentURLForDraggedTypes) else {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ let url = NSKeyedUnarchiver.unarchiveObject(with: urlData) as? String
|
|
|
if url != nil && url != self.listView.document.documentURL.absoluteString {
|
|
|
if (pasteboard.availableType(from: [.fileURL]) != nil) {
|
|
|
// if ([pasteboard availableTypeFromArray:[NSArray arrayWithObject:NSFilenamesPboardType]]){
|
|
@@ -1396,10 +1410,11 @@ extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
|
|
|
KMBaseWindowController.checkPassword(url: URL(fileURLWithPath: path), type: .owner) { success, resultPassword in
|
|
|
if success && resultPassword.isEmpty == false {
|
|
|
for i in 0 ..< (pdf?.pageCount ?? 0) {
|
|
|
- let page = pdf?.page(at: i).copy() as? CPDFPage
|
|
|
- self.listView.document.insertPageObject(page!, at: UInt(index))
|
|
|
- insertIndexSet.insert(index)
|
|
|
- index += 1
|
|
|
+ if let page = pdf?.page(at: i).copy() as? CPDFPage {
|
|
|
+ self.listView.document.insertPageObject(page, at: UInt(index))
|
|
|
+ insertIndexSet.insert(index)
|
|
|
+ index += 1
|
|
|
+ }
|
|
|
}
|
|
|
self.insertPages(insertIndexSet, pageAt: index-1)
|
|
|
}
|
|
@@ -1422,8 +1437,9 @@ extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
|
|
|
var pageIndex = 0
|
|
|
var pages: [CPDFPage] = []
|
|
|
for idx in rowIndexes {
|
|
|
- let page = self.listView.document.page(at: UInt(idx))?.copy() as? CPDFPage
|
|
|
- pages.append(page!)
|
|
|
+ if let page = self.listView.document.page(at: UInt(idx))?.copy() as? CPDFPage {
|
|
|
+ pages.append(page)
|
|
|
+ }
|
|
|
}
|
|
|
var toPage: CPDFPage?
|
|
|
if row < self.listView.document.pageCount {
|
|
@@ -1446,14 +1462,16 @@ extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
|
|
|
for idx in rowIndexes {
|
|
|
if idx < toPageIndex {
|
|
|
if((idx+pageIndex) < self.listView.document.pageCount) {
|
|
|
- var page = self.listView.document.page(at: UInt(idx))
|
|
|
- deletepages.append(page!)
|
|
|
+ if let page = self.listView.document.page(at: UInt(idx)) {
|
|
|
+ deletepages.append(page)
|
|
|
+ }
|
|
|
self.listView.document.removePage(at: IndexSet(integer: idx))
|
|
|
}
|
|
|
} else {
|
|
|
if((idx+pageIndex) < self.listView.document.pageCount) {
|
|
|
- let page = self.listView.document.page(at: UInt(idx+pageIndex))
|
|
|
- deletepages.append(page!)
|
|
|
+ if let page = self.listView.document.page(at: UInt(idx+pageIndex)) {
|
|
|
+ deletepages.append(page)
|
|
|
+ }
|
|
|
self.listView.document.removePage(at: IndexSet(integer: idx+pageIndex))
|
|
|
}
|
|
|
}
|
|
@@ -1481,16 +1499,16 @@ extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
|
|
|
if pathExtension == "pdf" {
|
|
|
let pdf = CPDFDocument(url: url!)
|
|
|
if let data = pdf?.isEncrypted, data {
|
|
|
-// KMDecryptWindowController *vc = [[KMDecryptWindowController alloc] init];
|
|
|
KMBaseWindowController.checkPassword(url: url!, type: .owner) { success, resultPassword in
|
|
|
if success && resultPassword.isEmpty == false {
|
|
|
pdf?.unlock(withPassword: resultPassword)
|
|
|
for i in 0 ..< (pdf?.pageCount ?? 0) {
|
|
|
-// let page = pdf?.page(at: i).copy() as? CPDFPage
|
|
|
- let page = pdf?.page(at: i)
|
|
|
- self.listView.document.insertPageObject(page!, at: UInt(index))
|
|
|
- insertIndexSet.insert(index)
|
|
|
- index += 1
|
|
|
+ // let page = pdf?.page(at: i).copy() as? CPDFPage
|
|
|
+ if let page = pdf?.page(at: i) {
|
|
|
+ self.listView.document.insertPageObject(page, at: UInt(index))
|
|
|
+ insertIndexSet.insert(index)
|
|
|
+ index += 1
|
|
|
+ }
|
|
|
}
|
|
|
self.insertPages(insertIndexSet, pageAt: index-1)
|
|
|
}
|
|
@@ -1498,20 +1516,22 @@ extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
|
|
|
} else {
|
|
|
for i in 0 ..< (pdf?.pageCount ?? 0) {
|
|
|
// let page = pdf?.page(at: i).copy() as? CPDFPage
|
|
|
- let page = pdf?.page(at: i)
|
|
|
- self.listView.document.insertPageObject(page!, at: UInt(index))
|
|
|
- insertIndexSet.insert(index)
|
|
|
- index += 1
|
|
|
+ if let page = pdf?.page(at: i) {
|
|
|
+ self.listView.document.insertPageObject(page, at: UInt(index))
|
|
|
+ insertIndexSet.insert(index)
|
|
|
+ index += 1
|
|
|
+ }
|
|
|
}
|
|
|
self.insertPages(insertIndexSet, pageAt: index-1)
|
|
|
}
|
|
|
} else if KMImageToPDFMethod.supportedImageTypes().contains(pathExtension) {
|
|
|
- let image = NSImage(contentsOfFile: url?.path ?? "")
|
|
|
-// PDFPage * page = [[[PDFPage alloc] initWithImage:image] autorelease];
|
|
|
-// [pdfView.document insertPage:page atIndex:index];
|
|
|
- _ = self.listView.document.km_insert(image: image!, at: UInt(index))
|
|
|
- insertIndexSet.insert(index)
|
|
|
- self.insertPages(insertIndexSet, pageAt: index-1)
|
|
|
+ if let image = NSImage(contentsOfFile: url?.path ?? "") {
|
|
|
+ // PDFPage * page = [[[PDFPage alloc] initWithImage:image] autorelease];
|
|
|
+ // [pdfView.document insertPage:page atIndex:index];
|
|
|
+ _ = self.listView.document.km_insert(image: image, at: UInt(index))
|
|
|
+ insertIndexSet.insert(index)
|
|
|
+ self.insertPages(insertIndexSet, pageAt: index-1)
|
|
|
+ }
|
|
|
}
|
|
|
result = true
|
|
|
} else {
|
|
@@ -1808,8 +1828,8 @@ extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
|
|
|
}
|
|
|
|
|
|
fileURL = fileURL.appendingPathExtension(pathExt).uniqueFileURL()
|
|
|
- let success = try?fileData?.write(to: fileURL)
|
|
|
- if success != nil {
|
|
|
+ let success = (try?fileData?.write(to: fileURL)) != nil
|
|
|
+ if success {
|
|
|
fileURLArray.append(fileURL.lastPathComponent)
|
|
|
}
|
|
|
}
|
|
@@ -1951,7 +1971,7 @@ extension KMLeftSideViewController: NSFilePromiseProviderDelegate {
|
|
|
extension KMLeftSideViewController {
|
|
|
var dragTempFloderPath: String? {
|
|
|
get {
|
|
|
- return NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.applicationSupportDirectory, FileManager.SearchPathDomainMask.userDomainMask, true).last?.stringByAppendingPathComponent(Bundle.main.bundleIdentifier!).stringByAppendingPathComponent("KMPDFThumbnailView_Drag_Temp")
|
|
|
+ return NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.applicationSupportDirectory, FileManager.SearchPathDomainMask.userDomainMask, true).last?.stringByAppendingPathComponent(Bundle.main.bundleIdentifier ?? "").stringByAppendingPathComponent("KMPDFThumbnailView_Drag_Temp")
|
|
|
}
|
|
|
}
|
|
|
var dragTempFilePath: String? {
|
|
@@ -1963,144 +1983,6 @@ extension KMLeftSideViewController {
|
|
|
|
|
|
// MARK: - NSOutlineViewDelegate, NSOutlineViewDataSource
|
|
|
|
|
|
-/*
|
|
|
-
|
|
|
- func outlineView(_ outlineView: NSOutlineView, child index: Int, ofItem item: Any?) -> Any {
|
|
|
- if item is KMBOTAAnnotationSection {
|
|
|
- let section = item as? KMBOTAAnnotationSection
|
|
|
- return section!.annotations?[index] as Any
|
|
|
- } else if item is KMBOTAAnnotationItem {
|
|
|
- return item as Any
|
|
|
- } else {
|
|
|
- var tempArray: [KMBOTAAnnotationSection] = []
|
|
|
- for temp in self.data {
|
|
|
- if temp.annotations?.count != 0 {
|
|
|
- tempArray.append(temp)
|
|
|
- }
|
|
|
- }
|
|
|
- let section = tempArray[index]
|
|
|
- return section as Any
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- func outlineView(_ outlineView: NSOutlineView, viewFor tableColumn: NSTableColumn?, item: Any) -> NSView? {
|
|
|
- if item is KMBOTAAnnotationItem {
|
|
|
- let cell : KMAnnotationOutlineCellView = KMAnnotationOutlineCellView.init()
|
|
|
- cell.delegate = self
|
|
|
- cell.model = item as? KMBOTAAnnotationItem
|
|
|
- return cell
|
|
|
- } else if item is KMBOTAAnnotationSection {
|
|
|
- let section = item as? KMBOTAAnnotationSection
|
|
|
-
|
|
|
- let cell : KMAnnotationOutlineSectionView = KMAnnotationOutlineSectionView.init()
|
|
|
- cell.model = section
|
|
|
- return cell
|
|
|
- }
|
|
|
- return NSTableCellView()
|
|
|
- }
|
|
|
-
|
|
|
- func outlineView(_ outlineView: NSOutlineView, rowViewForItem item: Any) -> NSTableRowView? {
|
|
|
- let rowView = KMAnnotationOutlineRowView()
|
|
|
- if item is KMBOTAAnnotationItem {
|
|
|
- rowView.model = (item as? KMBOTAAnnotationItem)
|
|
|
- } else if item is KMBOTAAnnotationSection {
|
|
|
- rowView.section = (item as? KMBOTAAnnotationSection)
|
|
|
- }
|
|
|
- rowView.mouseDownAction = { [unowned self] view, event in
|
|
|
- if rowView.section != nil {
|
|
|
- let expanded = outlineView.isItemExpanded(outlineView.item(atRow: outlineView.selectedRow))
|
|
|
- if expanded {
|
|
|
- outlineView.collapseItem(outlineView.item(atRow: outlineView.selectedRow), collapseChildren: true)
|
|
|
- outlineView.reloadItem(outlineView.item(atRow: outlineView.selectedRow))
|
|
|
- } else {
|
|
|
- outlineView.expandItem(outlineView.item(atRow: outlineView.selectedRow), expandChildren: true)
|
|
|
- outlineView.reloadItem(outlineView.item(atRow: outlineView.selectedRow))
|
|
|
- }
|
|
|
- } else if rowView.model != nil {
|
|
|
- self.didSelectItem(view: rowView, event: event)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- rowView.rightMouseDownAction = { [unowned self] view, event in
|
|
|
- if rowView.section != nil {
|
|
|
-
|
|
|
- } else if rowView.model != nil {
|
|
|
- if !KMOCToolClass.arrayContains(array: self.selectItems, annotation: item) ||
|
|
|
- self.selectItems.count == 1 {
|
|
|
- self.selectItem(item: item as! KMBOTAAnnotationItem)
|
|
|
- }
|
|
|
-
|
|
|
- DispatchQueue.main.async {
|
|
|
- self.delegate?.annotationOutlineView(self, rightMouseDownDidSelectView: view, evnet: event)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- rowView.hoverCallback = { [unowned self] (mouseEntered, mouseBox) in
|
|
|
- self.outlineView.enumerateAvailableRowViews { view, row in
|
|
|
- if view is KMAnnotationOutlineRowView {
|
|
|
- (view as? KMAnnotationOutlineRowView)?.model?.hover = false
|
|
|
- (view as? KMAnnotationOutlineRowView)?.reloadData()
|
|
|
- }
|
|
|
- }
|
|
|
- if mouseEntered {
|
|
|
- rowView.model?.hover = true
|
|
|
- } else {
|
|
|
- rowView.model?.hover = false
|
|
|
- }
|
|
|
- }
|
|
|
- return rowView
|
|
|
- }
|
|
|
-
|
|
|
- func outlineView(_ outlineView: NSOutlineView, heightOfRowByItem item: Any) -> CGFloat {
|
|
|
- if item is KMBOTAAnnotationItem {
|
|
|
- return KMBOTAAnnotationTool.fetchCellHeight(annotation: (item as? KMBOTAAnnotationItem)!.annotation!, maxSize: CGSize(width: self.maxWidth - 16, height: 1000))
|
|
|
- } else if item is KMBOTAAnnotationSection {
|
|
|
- return 40
|
|
|
- } else {
|
|
|
- return 30
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- func outlineViewSelectionDidChange(_ notification: Notification) {
|
|
|
- if self.outlineView.selectedRow == -1 {
|
|
|
- self.cancelSelect()
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- func outlineView(_ outlineView: NSOutlineView, isItemExpandable item: Any) -> Bool {
|
|
|
- if item is KMBOTAAnnotationItem {
|
|
|
- return false
|
|
|
- } else if item is KMBOTAAnnotationSection {
|
|
|
- let section = item as? KMBOTAAnnotationSection
|
|
|
- return section!.annotations?.count ?? 0 > 0
|
|
|
- }
|
|
|
- return false
|
|
|
- }
|
|
|
-
|
|
|
- func outlineView(_ outlineView: NSOutlineView, shouldExpandItem item: Any) -> Bool {
|
|
|
- if let item = item as? KMBOTAAnnotationSection {
|
|
|
- if !item.isItemExpanded {
|
|
|
- item.isItemExpanded = true
|
|
|
- outlineView.animator().expandItem(item, expandChildren: true)
|
|
|
- return false
|
|
|
- }
|
|
|
- }
|
|
|
- return true
|
|
|
- }
|
|
|
-
|
|
|
- func outlineView(_ outlineView: NSOutlineView, shouldCollapseItem item: Any) -> Bool {
|
|
|
- if let item = item as? KMBOTAAnnotationSection {
|
|
|
- if item.isItemExpanded {
|
|
|
- item.isItemExpanded = false
|
|
|
- outlineView.animator().collapseItem(item, collapseChildren: true)
|
|
|
- return false
|
|
|
- }
|
|
|
- }
|
|
|
- return true
|
|
|
- }
|
|
|
- */
|
|
|
-
|
|
|
extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSource {
|
|
|
func outlineView(_ outlineView: NSOutlineView, numberOfChildrenOfItem item: Any?) -> Int {
|
|
|
if outlineView.isEqual(to: self.tocOutlineView) {
|
|
@@ -2111,10 +1993,11 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
|
|
|
if item == nil { // 第一层
|
|
|
// 获取根
|
|
|
guard let outline = self.listView.document.outlineRoot() else {
|
|
|
- let view = self.tocOutlineView.enclosingScrollView!
|
|
|
+ let view = self.tocOutlineView.enclosingScrollView
|
|
|
+ let viewFrame = view?.frame ?? .zero
|
|
|
let emptyVcSize = self.leftSideEmptyVC.emptyOutlineView.frame.size
|
|
|
//
|
|
|
- self.leftSideEmptyVC.emptyOutlineView.frame = NSMakeRect((view.frame.size.width-emptyVcSize.width)/2.0,(view.frame.size.height-emptyVcSize.height)/2.0, emptyVcSize.width, emptyVcSize.height)
|
|
|
+ self.leftSideEmptyVC.emptyOutlineView.frame = NSMakeRect((viewFrame.size.width-emptyVcSize.width)/2.0,(viewFrame.size.height-emptyVcSize.height)/2.0, emptyVcSize.width, emptyVcSize.height)
|
|
|
self.leftSideEmptyVC.emptyOutlineView.autoresizingMask = [.minXMargin, .maxXMargin, .minYMargin, .maxYMargin]
|
|
|
self.tocOutlineView.enclosingScrollView?.documentView?.addSubview(self.leftSideEmptyVC.emptyOutlineView)
|
|
|
self.leftSideEmptyVC.deleteOutlineBtn.isEnabled = false
|
|
@@ -2136,10 +2019,11 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
|
|
|
self.leftSideEmptyVC.emptyOutlineView.removeFromSuperview()
|
|
|
self.leftSideEmptyVC.deleteOutlineBtn.isEnabled = true
|
|
|
} else { // 没有数据
|
|
|
- let view = self.tocOutlineView.enclosingScrollView!
|
|
|
+ let view = self.tocOutlineView.enclosingScrollView
|
|
|
+ let viewFrame = view?.frame ?? .zero
|
|
|
let emptyVcSize = self.leftSideEmptyVC.emptyOutlineView.frame.size
|
|
|
//
|
|
|
- self.leftSideEmptyVC.emptyOutlineView.frame = NSMakeRect((view.frame.size.width-emptyVcSize.width)/2.0,(view.frame.size.height-emptyVcSize.height)/2.0, emptyVcSize.width, emptyVcSize.height)
|
|
|
+ self.leftSideEmptyVC.emptyOutlineView.frame = NSMakeRect((viewFrame.size.width-emptyVcSize.width)/2.0,(viewFrame.size.height-emptyVcSize.height)/2.0, emptyVcSize.width, emptyVcSize.height)
|
|
|
self.leftSideEmptyVC.emptyOutlineView.autoresizingMask = [.minXMargin, .maxXMargin, .minYMargin, .maxYMargin]
|
|
|
self.tocOutlineView.enclosingScrollView?.documentView?.addSubview(self.leftSideEmptyVC.emptyOutlineView)
|
|
|
self.leftSideEmptyVC.deleteOutlineBtn.isEnabled = false
|
|
@@ -2176,8 +2060,7 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
|
|
|
if self.isSearchOutlineMode {
|
|
|
if let data = item as? String, data == "Bookmarks" { // 书签group
|
|
|
return 0
|
|
|
- } else if item is CPDFOutline { // 大纲
|
|
|
- let child = item as! CPDFOutline
|
|
|
+ } else if let child = item as? CPDFOutline { // 大纲
|
|
|
if child.numberOfChildren == 0 {
|
|
|
return 0
|
|
|
}
|
|
@@ -2222,9 +2105,10 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
|
|
|
self.noteFilterButton.isEnabled = false
|
|
|
// }
|
|
|
self.noteOutlineView.usesAlternatingRowBackgroundColors = false
|
|
|
- let view = self.noteOutlineView.enclosingScrollView!
|
|
|
+ let view = self.noteOutlineView.enclosingScrollView
|
|
|
+ let viewFrame = view?.frame ?? .zero
|
|
|
var emptyVcSize = self.leftSideEmptyVC.emptyAnnotationView.frame.size
|
|
|
- self.leftSideEmptyVC.emptyAnnotationView.frame = NSMakeRect((view.frame.size.width-emptyVcSize.width)/2.0,(view.frame.size.height-emptyVcSize.height)/2.0, emptyVcSize.width, emptyVcSize.height)
|
|
|
+ self.leftSideEmptyVC.emptyAnnotationView.frame = NSMakeRect((viewFrame.size.width-emptyVcSize.width)/2.0,(viewFrame.size.height-emptyVcSize.height)/2.0, emptyVcSize.width, emptyVcSize.height)
|
|
|
|
|
|
self.leftSideEmptyVC.emptyAnnotationView.autoresizingMask = [.minXMargin, .maxXMargin, .minYMargin, .maxYMargin]
|
|
|
self.noteOutlineView.enclosingScrollView?.documentView?.addSubview(self.leftSideEmptyVC.emptyAnnotationView)
|
|
@@ -2304,17 +2188,13 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
|
|
|
} else {
|
|
|
if let data = item as? String, data == "Bookmarks" {
|
|
|
return array[index]
|
|
|
- } else if item is CPDFOutline {
|
|
|
+ } else if let ol = item as? CPDFOutline {
|
|
|
if self.isSearchOutlineMode == false {
|
|
|
- return (item as! CPDFOutline).child(at: UInt(index))
|
|
|
+ return ol.child(at: UInt(index)) as Any
|
|
|
}
|
|
|
- let child = item as! CPDFOutline
|
|
|
-// if child.numberOfChildren == 0 {
|
|
|
-// return 0
|
|
|
-// }
|
|
|
var array: [CPDFOutline] = []
|
|
|
- for i in 0 ..< child.numberOfChildren {
|
|
|
- if let _child = child.child(at: i) {
|
|
|
+ for i in 0 ..< ol.numberOfChildren {
|
|
|
+ if let _child = ol.child(at: i) {
|
|
|
if self._hasContainString(self.outlineSearchField.stringValue, rootOutline: _child) {
|
|
|
array.append(_child)
|
|
|
}
|
|
@@ -2480,33 +2360,33 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
|
|
|
return cell
|
|
|
} else if outlineView.isEqual(to: self.noteOutlineView) {
|
|
|
let model = item as? KMBOTAAnnotationItem
|
|
|
- var note: CPDFAnnotation!
|
|
|
+ var note: CPDFAnnotation?
|
|
|
if self.noteSearchMode {
|
|
|
- note = item as! CPDFAnnotation
|
|
|
+ note = item as? CPDFAnnotation
|
|
|
} else {
|
|
|
- note = (item as! KMBOTAAnnotationItem).annotation!
|
|
|
+ note = (item as? KMBOTAAnnotationItem)?.annotation
|
|
|
}
|
|
|
|
|
|
let cell = outlineView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "KMNoteTableViewCell"), owner: self) as! KMNoteTableViewCell
|
|
|
cell.cellNote = note
|
|
|
|
|
|
- let noteColor = note.color
|
|
|
- var noteType = note.type ?? ""
|
|
|
- var noteString = KMBOTAAnnotationTool.fetchContentLabelString(annotation: note)
|
|
|
-// NSString *pageString = [[note page] displayLabel] ? : @"";
|
|
|
- var pageString = "\((note.page?.pageIndex() ?? 0) + 1)"
|
|
|
+ let noteColor = note?.color
|
|
|
+ var noteType = note?.type ?? ""
|
|
|
+ var noteString = ""
|
|
|
+ if let data = note {
|
|
|
+ noteString = KMBOTAAnnotationTool.fetchContentLabelString(annotation: data)
|
|
|
+ }
|
|
|
+
|
|
|
+ var pageString = "\((note?.page?.pageIndex() ?? 0) + 1)"
|
|
|
let formatter = DateFormatter()
|
|
|
formatter.dateFormat = "hh:mm"
|
|
|
var dateString = ""
|
|
|
- if let date = note.modificationDate() {
|
|
|
+ if let date = note?.modificationDate() {
|
|
|
dateString = formatter.string(from: date)
|
|
|
}
|
|
|
- var authorString = note.userName() ?? ""
|
|
|
-// NSString *noteTextString = [note noteText].string ? : @"";
|
|
|
- var noteTextString = note.string() ?? ""
|
|
|
-//
|
|
|
+ var authorString = note?.userName() ?? ""
|
|
|
+ var noteTextString = note?.string() ?? ""
|
|
|
// if([noteType isEqualToString:@"Redact"]) {
|
|
|
-
|
|
|
// noteString = @"Redact";
|
|
|
// }
|
|
|
//
|
|
@@ -2542,82 +2422,84 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
|
|
|
}
|
|
|
|
|
|
let imageView = KMNoteTypeImageView()
|
|
|
- if note.isKind(of: CPDFStampAnnotation.self) {
|
|
|
- let annotation_stamp = note as! CPDFStampAnnotation
|
|
|
- if (annotation_stamp.stampImage() != nil) {
|
|
|
- noteType = SKNStampString
|
|
|
- }
|
|
|
- } else if note.isKind(of: CPDFLineAnnotation.self) {
|
|
|
- let annotation_line = note as! CPDFLineAnnotation
|
|
|
- if annotation_line.startLineStyle == .none && annotation_line.endLineStyle == .none {
|
|
|
- noteType = SKNLine_NoneString
|
|
|
- } else if annotation_line.startLineStyle == .none && annotation_line.endLineStyle == .openArrow {
|
|
|
- noteType = SKNLine_OpenArrowString
|
|
|
- } else {
|
|
|
- noteType = SKNLine_NoneString
|
|
|
- }
|
|
|
- } else if note.isKind(of: CPDFButtonWidgetAnnotation.self) {
|
|
|
- let buttonWidget = note as! CPDFButtonWidgetAnnotation
|
|
|
- if buttonWidget.controlType() == .radioButtonControl {
|
|
|
- noteType = KMAnnotationFormRadioButtonKey
|
|
|
- } else if buttonWidget.controlType() == .checkBoxControl {
|
|
|
- noteType = KMAnnotationFormCheckBoxKey
|
|
|
- } else if buttonWidget.controlType() == .pushButtonControl {
|
|
|
- noteType = KMAnnotationFormActionButtonKey
|
|
|
- }
|
|
|
- } else if note.isKind(of: CPDFTextWidgetAnnotation.self) {
|
|
|
- noteType = KMAnnotationFormTextFieldKey
|
|
|
- } else if note.isKind(of: CPDFChoiceWidgetAnnotation.self) {
|
|
|
- let choiceWidget = note as! CPDFChoiceWidgetAnnotation
|
|
|
- if choiceWidget.isListChoice {
|
|
|
- noteType = KMAnnotationFormListMenuKey
|
|
|
- } else {
|
|
|
- noteType = KMAnnotationFormComboBoxKey
|
|
|
- }
|
|
|
- } else if note.isKind(of: KMTableAnnotation.self) {
|
|
|
- noteType = "Ink_Table"
|
|
|
- } else if note.isKind(of: KMSelfSignAnnotation.self) {
|
|
|
- let selfSignNote = note as! KMSelfSignAnnotation
|
|
|
- if selfSignNote.annotationType == .signFalse {
|
|
|
- noteType = "KMSelfSignTypeFalseActionButtonKey"
|
|
|
- } else if (selfSignNote.annotationType == .signature) {
|
|
|
- noteType = "KMSelfSignTypeTureActionButtonKey"
|
|
|
- } else if (selfSignNote.annotationType == .signCircle) {
|
|
|
- noteType = "KMSelfSignTypeCircleActionButtonKey"
|
|
|
- } else if (selfSignNote.annotationType == .signLine) {
|
|
|
- noteType = "KMSelfSignTypeLineActionButtonKey"
|
|
|
- } else if (selfSignNote.annotationType == .signDot) {
|
|
|
- noteType = "KMSelfSignTypeDotActionButtonKey"
|
|
|
- } else if (selfSignNote.annotationType == .signText) {
|
|
|
- noteType = "KMSelfSignTypeTextActionButtonKey"
|
|
|
- }
|
|
|
- } else if note.isKind(of: CPDFSquareAnnotation.self) {
|
|
|
- noteType = SKNSquareString
|
|
|
- } else if note.isKind(of: CPDFTextAnnotation.self) {
|
|
|
- noteType = SKNNoteString
|
|
|
- } else if note.isKind(of: CPDFFreeTextAnnotation.self) {
|
|
|
- noteType = SKNFreeTextString
|
|
|
- } else if note.isKind(of: CPDFCircleAnnotation.self) {
|
|
|
- noteType = SKNCircleString
|
|
|
- } else if note.isKind(of: CPDFSignatureAnnotation.self) {
|
|
|
- noteType = SKNSignatureString
|
|
|
- } else if note.isKind(of: CPDFInkAnnotation.self) {
|
|
|
- noteType = SKNInkString
|
|
|
- } else if note.isKind(of: CPDFMarkupAnnotation.self) {
|
|
|
- let anno = note as! CPDFMarkupAnnotation
|
|
|
- if anno.markupType() == .highlight {
|
|
|
- noteType = SKNHighlightString
|
|
|
- } else if anno.markupType() == .underline {
|
|
|
- noteType = SKNUnderlineString
|
|
|
- } else if anno.markupType() == .strikeOut {
|
|
|
- noteType = SKNStrikeOutString
|
|
|
+ if let data = note {
|
|
|
+ if data.isKind(of: CPDFStampAnnotation.self) {
|
|
|
+ let annotation_stamp = data as! CPDFStampAnnotation
|
|
|
+ if (annotation_stamp.stampImage() != nil) {
|
|
|
+ noteType = SKNStampString
|
|
|
+ }
|
|
|
+ } else if data.isKind(of: CPDFLineAnnotation.self) {
|
|
|
+ let annotation_line = data as! CPDFLineAnnotation
|
|
|
+ if annotation_line.startLineStyle == .none && annotation_line.endLineStyle == .none {
|
|
|
+ noteType = SKNLine_NoneString
|
|
|
+ } else if annotation_line.startLineStyle == .none && annotation_line.endLineStyle == .openArrow {
|
|
|
+ noteType = SKNLine_OpenArrowString
|
|
|
+ } else {
|
|
|
+ noteType = SKNLine_NoneString
|
|
|
+ }
|
|
|
+ } else if data.isKind(of: CPDFButtonWidgetAnnotation.self) {
|
|
|
+ let buttonWidget = data as! CPDFButtonWidgetAnnotation
|
|
|
+ if buttonWidget.controlType() == .radioButtonControl {
|
|
|
+ noteType = KMAnnotationFormRadioButtonKey
|
|
|
+ } else if buttonWidget.controlType() == .checkBoxControl {
|
|
|
+ noteType = KMAnnotationFormCheckBoxKey
|
|
|
+ } else if buttonWidget.controlType() == .pushButtonControl {
|
|
|
+ noteType = KMAnnotationFormActionButtonKey
|
|
|
+ }
|
|
|
+ } else if data.isKind(of: CPDFTextWidgetAnnotation.self) {
|
|
|
+ noteType = KMAnnotationFormTextFieldKey
|
|
|
+ } else if data.isKind(of: CPDFChoiceWidgetAnnotation.self) {
|
|
|
+ let choiceWidget = data as! CPDFChoiceWidgetAnnotation
|
|
|
+ if choiceWidget.isListChoice {
|
|
|
+ noteType = KMAnnotationFormListMenuKey
|
|
|
+ } else {
|
|
|
+ noteType = KMAnnotationFormComboBoxKey
|
|
|
+ }
|
|
|
+ } else if data.isKind(of: KMTableAnnotation.self) {
|
|
|
+ noteType = "Ink_Table"
|
|
|
+ } else if data.isKind(of: KMSelfSignAnnotation.self) {
|
|
|
+ let selfSignNote = data as! KMSelfSignAnnotation
|
|
|
+ if selfSignNote.annotationType == .signFalse {
|
|
|
+ noteType = "KMSelfSignTypeFalseActionButtonKey"
|
|
|
+ } else if (selfSignNote.annotationType == .signature) {
|
|
|
+ noteType = "KMSelfSignTypeTureActionButtonKey"
|
|
|
+ } else if (selfSignNote.annotationType == .signCircle) {
|
|
|
+ noteType = "KMSelfSignTypeCircleActionButtonKey"
|
|
|
+ } else if (selfSignNote.annotationType == .signLine) {
|
|
|
+ noteType = "KMSelfSignTypeLineActionButtonKey"
|
|
|
+ } else if (selfSignNote.annotationType == .signDot) {
|
|
|
+ noteType = "KMSelfSignTypeDotActionButtonKey"
|
|
|
+ } else if (selfSignNote.annotationType == .signText) {
|
|
|
+ noteType = "KMSelfSignTypeTextActionButtonKey"
|
|
|
+ }
|
|
|
+ } else if data.isKind(of: CPDFSquareAnnotation.self) {
|
|
|
+ noteType = SKNSquareString
|
|
|
+ } else if data.isKind(of: CPDFTextAnnotation.self) {
|
|
|
+ noteType = SKNNoteString
|
|
|
+ } else if data.isKind(of: CPDFFreeTextAnnotation.self) {
|
|
|
+ noteType = SKNFreeTextString
|
|
|
+ } else if data.isKind(of: CPDFCircleAnnotation.self) {
|
|
|
+ noteType = SKNCircleString
|
|
|
+ } else if data.isKind(of: CPDFSignatureAnnotation.self) {
|
|
|
+ noteType = SKNSignatureString
|
|
|
+ } else if data.isKind(of: CPDFInkAnnotation.self) {
|
|
|
+ noteType = SKNInkString
|
|
|
+ } else if data.isKind(of: CPDFMarkupAnnotation.self) {
|
|
|
+ let anno = data as! CPDFMarkupAnnotation
|
|
|
+ if anno.markupType() == .highlight {
|
|
|
+ noteType = SKNHighlightString
|
|
|
+ } else if anno.markupType() == .underline {
|
|
|
+ noteType = SKNUnderlineString
|
|
|
+ } else if anno.markupType() == .strikeOut {
|
|
|
+ noteType = SKNStrikeOutString
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
cell.typeImageView.image = imageView.noteTypeImage(withType: noteType, color: noteColor ?? .red)
|
|
|
cell.typeImageView.isHidden = false
|
|
|
|
|
|
- if note.isKind(of: CPDFMarkupAnnotation.self) {
|
|
|
+ if note is CPDFMarkupAnnotation {
|
|
|
cell.isFold = true
|
|
|
}
|
|
|
|
|
@@ -2630,136 +2512,140 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
|
|
|
|
|
|
cell.contentView.isHidden = false
|
|
|
cell.contentViewHidden(false)
|
|
|
- if note.isKind(of: CPDFMarkupAnnotation.self) {
|
|
|
- let markup = note as! CPDFMarkupAnnotation
|
|
|
- var contentString = KMBOTAAnnotationTool.fetchText(text: markup.markupContent() ?? "")
|
|
|
- contentString = contentString.replacingOccurrences(of: "\r", with: "")
|
|
|
- contentString = contentString.replacingOccurrences(of: "\n", with: "")
|
|
|
- cell.noteContentLabel.stringValue = contentString
|
|
|
- if(contentString.isEmpty == false) {
|
|
|
- cell.foldButton.isHidden = false
|
|
|
- }
|
|
|
- var attributeStr = NSMutableAttributedString(string: contentString)
|
|
|
- if (markup.markupType() == .highlight) {
|
|
|
- attributeStr.addAttribute(.backgroundColor, value: noteColor as Any, range: NSMakeRange(0, contentString.count))
|
|
|
- } else if (markup.markupType() == .strikeOut) {
|
|
|
- attributeStr.addAttribute(.strikethroughStyle, value: NSUnderlineStyle.single.rawValue, range: NSMakeRange(0, contentString.count))
|
|
|
- attributeStr.addAttribute(.strikethroughColor, value: noteColor as Any, range: NSMakeRange(0, contentString.count))
|
|
|
- } else if (markup.markupType() == .underline) {
|
|
|
- attributeStr.addAttribute(.underlineStyle, value: NSUnderlineStyle.single.rawValue, range: NSMakeRange(0, contentString.count))
|
|
|
- attributeStr.addAttribute(.underlineColor, value: noteColor as Any, range: NSMakeRange(0, contentString.count))
|
|
|
- }
|
|
|
- cell.annotationContentLabel.attributedStringValue = attributeStr
|
|
|
-
|
|
|
- if self.foldType == .unfold {
|
|
|
-// if let data = model?.foldType, data == .unfold { // 全部展开
|
|
|
- cell.isFold = false
|
|
|
- } else if self.foldType == .fold {
|
|
|
-// else if let data = model?.foldType, data == .fold { // 全部折叠
|
|
|
- cell.isFold = true
|
|
|
- } else { // 混合
|
|
|
- if self.allFoldNotes.isEmpty == false && self.allFoldNotes.contains(note) {
|
|
|
+ if let data = note {
|
|
|
+ if data.isKind(of: CPDFMarkupAnnotation.self) {
|
|
|
+ let markup = data as! CPDFMarkupAnnotation
|
|
|
+ var contentString = KMBOTAAnnotationTool.fetchText(text: markup.markupContent() ?? "")
|
|
|
+ contentString = contentString.replacingOccurrences(of: "\r", with: "")
|
|
|
+ contentString = contentString.replacingOccurrences(of: "\n", with: "")
|
|
|
+ cell.noteContentLabel.stringValue = contentString
|
|
|
+ if(contentString.isEmpty == false) {
|
|
|
+ cell.foldButton.isHidden = false
|
|
|
+ }
|
|
|
+ var attributeStr = NSMutableAttributedString(string: contentString)
|
|
|
+ if (markup.markupType() == .highlight) {
|
|
|
+ attributeStr.addAttribute(.backgroundColor, value: noteColor as Any, range: NSMakeRange(0, contentString.count))
|
|
|
+ } else if (markup.markupType() == .strikeOut) {
|
|
|
+ attributeStr.addAttribute(.strikethroughStyle, value: NSUnderlineStyle.single.rawValue, range: NSMakeRange(0, contentString.count))
|
|
|
+ attributeStr.addAttribute(.strikethroughColor, value: noteColor as Any, range: NSMakeRange(0, contentString.count))
|
|
|
+ } else if (markup.markupType() == .underline) {
|
|
|
+ attributeStr.addAttribute(.underlineStyle, value: NSUnderlineStyle.single.rawValue, range: NSMakeRange(0, contentString.count))
|
|
|
+ attributeStr.addAttribute(.underlineColor, value: noteColor as Any, range: NSMakeRange(0, contentString.count))
|
|
|
+ }
|
|
|
+ cell.annotationContentLabel.attributedStringValue = attributeStr
|
|
|
+
|
|
|
+ if self.foldType == .unfold {
|
|
|
+ // if let data = model?.foldType, data == .unfold { // 全部展开
|
|
|
cell.isFold = false
|
|
|
- } else {
|
|
|
+ } else if self.foldType == .fold {
|
|
|
+ // else if let data = model?.foldType, data == .fold { // 全部折叠
|
|
|
cell.isFold = true
|
|
|
+ } else { // 混合
|
|
|
+ if self.allFoldNotes.isEmpty == false && self.allFoldNotes.contains(data) {
|
|
|
+ cell.isFold = false
|
|
|
+ } else {
|
|
|
+ cell.isFold = true
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- // noteString.isEmpty == false &&
|
|
|
- if (contentString.isEmpty == false) {
|
|
|
- cell.contentViewHidden(false)
|
|
|
- } else {
|
|
|
- cell.contentViewHidden(true)
|
|
|
- }
|
|
|
- } else if note.isKind(of: CPDFLineAnnotation.self) || noteType == SKNSquareString || noteType == SKNCircleString || noteType == SKNInkString {
|
|
|
- cell.annotationContentLabel.stringValue = noteString
|
|
|
- if (noteString.isEmpty == false) {
|
|
|
- cell.contentViewHidden(false)
|
|
|
- } else {
|
|
|
- cell.contentViewHidden(true)
|
|
|
- }
|
|
|
- } else if note.isKind(of: CPDFStampAnnotation.self) {
|
|
|
- if note.isKind(of: KMSelfSignAnnotation.self) {
|
|
|
- let newAnnotation = note as! KMSelfSignAnnotation
|
|
|
- let type = newAnnotation.annotationType
|
|
|
- var returnString = ""
|
|
|
- if (type == .signFalse) {
|
|
|
- returnString = KMLocalizedString("X", nil)
|
|
|
- } else if (type == .signature) {
|
|
|
- returnString = KMLocalizedString("Check mark", nil)
|
|
|
- } else if (type == .signCircle) {
|
|
|
- returnString = KMLocalizedString("Circle", nil)
|
|
|
- } else if (type == .signLine) {
|
|
|
- returnString = KMLocalizedString("Line", nil)
|
|
|
- } else if (type == .signDot) {
|
|
|
- returnString = KMLocalizedString("Dot", nil)
|
|
|
- } else if (type == .signText) {
|
|
|
- returnString = KMLocalizedString("Text", nil)
|
|
|
- }
|
|
|
- cell.annotationContentLabel.stringValue = returnString
|
|
|
- } else {
|
|
|
- cell.annotationContentLabel.isHidden = true
|
|
|
-
|
|
|
- cell.noteImageView.isHidden = false
|
|
|
- let anno = note as! CPDFStampAnnotation
|
|
|
- cell.noteImageView.image = anno.stampImage()
|
|
|
- }
|
|
|
- } else if note.isKind(of: CPDFTextAnnotation.self) {
|
|
|
- cell.foldButton.isHidden = false
|
|
|
- if noteString.isEmpty {
|
|
|
- cell.annotationContentLabel.stringValue = noteTextString
|
|
|
- }else{
|
|
|
+ // noteString.isEmpty == false &&
|
|
|
+ if (contentString.isEmpty == false) {
|
|
|
+ cell.contentViewHidden(false)
|
|
|
+ } else {
|
|
|
+ cell.contentViewHidden(true)
|
|
|
+ }
|
|
|
+ } else if data.isKind(of: CPDFLineAnnotation.self) || noteType == SKNSquareString || noteType == SKNCircleString || noteType == SKNInkString {
|
|
|
cell.annotationContentLabel.stringValue = noteString
|
|
|
- cell.noteContentLabel.stringValue = noteTextString
|
|
|
- }
|
|
|
-
|
|
|
- if (self.foldType == .unfold) {
|
|
|
- cell.isFold = false
|
|
|
- } else if (self.foldType == .fold) {
|
|
|
- cell.isFold = true
|
|
|
- } else {
|
|
|
- if self.allFoldNotes.isEmpty == false && self.allFoldNotes.contains(note) {
|
|
|
- cell.isFold = false
|
|
|
+ if (noteString.isEmpty == false) {
|
|
|
+ cell.contentViewHidden(false)
|
|
|
} else {
|
|
|
- cell.isFold = true
|
|
|
+ cell.contentViewHidden(true)
|
|
|
}
|
|
|
- }
|
|
|
- if (noteString.isEmpty == false || noteTextString.isEmpty == false) {
|
|
|
- cell.contentView.isHidden = false
|
|
|
- } else {
|
|
|
- cell.contentView.isHidden = true
|
|
|
- cell.contentViewHidden(true)
|
|
|
- }
|
|
|
- // noteString.isEmpty == false &&
|
|
|
- if (noteTextString.isEmpty == false) {
|
|
|
+ } else if data.isKind(of: CPDFStampAnnotation.self) {
|
|
|
+ if data.isKind(of: KMSelfSignAnnotation.self) {
|
|
|
+ let newAnnotation = note as! KMSelfSignAnnotation
|
|
|
+ let type = newAnnotation.annotationType
|
|
|
+ var returnString = ""
|
|
|
+ if (type == .signFalse) {
|
|
|
+ returnString = KMLocalizedString("X", nil)
|
|
|
+ } else if (type == .signature) {
|
|
|
+ returnString = KMLocalizedString("Check mark", nil)
|
|
|
+ } else if (type == .signCircle) {
|
|
|
+ returnString = KMLocalizedString("Circle", nil)
|
|
|
+ } else if (type == .signLine) {
|
|
|
+ returnString = KMLocalizedString("Line", nil)
|
|
|
+ } else if (type == .signDot) {
|
|
|
+ returnString = KMLocalizedString("Dot", nil)
|
|
|
+ } else if (type == .signText) {
|
|
|
+ returnString = KMLocalizedString("Text", nil)
|
|
|
+ }
|
|
|
+ cell.annotationContentLabel.stringValue = returnString
|
|
|
+ } else {
|
|
|
+ cell.annotationContentLabel.isHidden = true
|
|
|
+
|
|
|
+ cell.noteImageView.isHidden = false
|
|
|
+ let anno = note as! CPDFStampAnnotation
|
|
|
+ cell.noteImageView.image = anno.stampImage()
|
|
|
+ }
|
|
|
+ } else if data.isKind(of: CPDFTextAnnotation.self) {
|
|
|
cell.foldButton.isHidden = false
|
|
|
- }else{
|
|
|
- cell.foldButton.isHidden = true
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- cell.annotationContentLabel.stringValue = noteString
|
|
|
- cell.imageViewHeightConstraint.constant = cell.contentView.frame.size.height
|
|
|
- if (noteString.isEmpty == false) {
|
|
|
- cell.contentViewHidden(false)
|
|
|
+ if noteString.isEmpty {
|
|
|
+ cell.annotationContentLabel.stringValue = noteTextString
|
|
|
+ }else{
|
|
|
+ cell.annotationContentLabel.stringValue = noteString
|
|
|
+ cell.noteContentLabel.stringValue = noteTextString
|
|
|
+ }
|
|
|
+
|
|
|
+ if (self.foldType == .unfold) {
|
|
|
+ cell.isFold = false
|
|
|
+ } else if (self.foldType == .fold) {
|
|
|
+ cell.isFold = true
|
|
|
+ } else {
|
|
|
+ if self.allFoldNotes.isEmpty == false && self.allFoldNotes.contains(data) {
|
|
|
+ cell.isFold = false
|
|
|
+ } else {
|
|
|
+ cell.isFold = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (noteString.isEmpty == false || noteTextString.isEmpty == false) {
|
|
|
+ cell.contentView.isHidden = false
|
|
|
+ } else {
|
|
|
+ cell.contentView.isHidden = true
|
|
|
+ cell.contentViewHidden(true)
|
|
|
+ }
|
|
|
+ // noteString.isEmpty == false &&
|
|
|
+ if (noteTextString.isEmpty == false) {
|
|
|
+ cell.foldButton.isHidden = false
|
|
|
+ }else{
|
|
|
+ cell.foldButton.isHidden = true
|
|
|
+ }
|
|
|
+
|
|
|
} else {
|
|
|
- cell.contentViewHidden(true)
|
|
|
+ cell.annotationContentLabel.stringValue = noteString
|
|
|
+ cell.imageViewHeightConstraint.constant = cell.contentView.frame.size.height
|
|
|
+ if (noteString.isEmpty == false) {
|
|
|
+ cell.contentViewHidden(false)
|
|
|
+ } else {
|
|
|
+ cell.contentViewHidden(true)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
cell.autherLayoutConstraint.constant = cell.autherLabel.isHidden ? -(cell.autherLabel.bounds.size.width) + 10.0 : 10.0
|
|
|
cell.typeImageViewLayoutConstraint.constant = cell.typeImageView.isHidden ? -(cell.typeImageView.bounds.size.width) : 0.0
|
|
|
cell.contentBoxLayoutConstraint.constant = cell.noteContentBox.isHidden ? -(cell.noteContentBox.bounds.size.height+8.0) : 8.0
|
|
|
- if note.isKind(of: CPDFStampAnnotation.self) && note.isKind(of: KMSelfSignAnnotation.self) == false {
|
|
|
-
|
|
|
- } else {
|
|
|
- if note.isKind(of: CPDFMarkupAnnotation.self) {
|
|
|
- if (!cell.isFold) {
|
|
|
- self.allFoldNotes.append(note)
|
|
|
+ if let data = note {
|
|
|
+ if data.isKind(of: CPDFStampAnnotation.self) && data.isKind(of: KMSelfSignAnnotation.self) == false {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ if data.isKind(of: CPDFMarkupAnnotation.self) {
|
|
|
+ if (!cell.isFold) {
|
|
|
+ self.allFoldNotes.append(data)
|
|
|
+ } else {
|
|
|
+ cell.imageViewHeightConstraint.constant = 18.0 + 8
|
|
|
+ }
|
|
|
} else {
|
|
|
cell.imageViewHeightConstraint.constant = 18.0 + 8
|
|
|
}
|
|
|
- } else {
|
|
|
- cell.imageViewHeightConstraint.constant = 18.0 + 8
|
|
|
}
|
|
|
}
|
|
|
cell.isUnFoldNote = { [unowned self] cellNote, isUnfold in
|
|
@@ -2781,8 +2667,10 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
|
|
|
model?.foldH = isUnfold ? 30 : (cell.noteContentHeightConstraint.constant + cell.maltlineLabelLayoutConstraint.constant + 85)
|
|
|
}
|
|
|
if (isUnfold) {
|
|
|
- if (self.allFoldNotes.contains(note)) {
|
|
|
- self.allFoldNotes.removeObject(note)
|
|
|
+ if let data = note {
|
|
|
+ if (self.allFoldNotes.contains(data)) {
|
|
|
+ self.allFoldNotes.removeObject(data)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (self.allFoldNotes.count == 0) {
|
|
@@ -2791,8 +2679,10 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
|
|
|
self.foldType = .none
|
|
|
}
|
|
|
} else {
|
|
|
- if self.allFoldNotes.contains(note) == false {
|
|
|
- self.allFoldNotes.append(note)
|
|
|
+ if let data = note {
|
|
|
+ if self.allFoldNotes.contains(data) == false {
|
|
|
+ self.allFoldNotes.append(data)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// if (rightSideController.allFoldNotes.count == rightSideController.canFoldNotes.count) {
|
|
@@ -2809,17 +2699,17 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
|
|
|
|
|
|
func outlineView(_ outlineView: NSOutlineView, heightOfRowByItem item: Any) -> CGFloat {
|
|
|
if outlineView.isEqual(self.noteOutlineView) {
|
|
|
- if item is KMBOTAAnnotationItem {
|
|
|
- let model = item as! KMBOTAAnnotationItem
|
|
|
+ if let model = item as? KMBOTAAnnotationItem {
|
|
|
if model.foldType == .fold {
|
|
|
return model.foldH
|
|
|
}
|
|
|
- return KMBOTAAnnotationTool.fetchCellHeight(annotation: (item as? KMBOTAAnnotationItem)!.annotation!, maxSize: CGSize(width: 260+40 - 16, height: 1000))
|
|
|
+ if let anno = model.annotation {
|
|
|
+ return KMBOTAAnnotationTool.fetchCellHeight(annotation: anno, maxSize: CGSize(width: 260+40 - 16, height: 1000))
|
|
|
+ }
|
|
|
}
|
|
|
return 30
|
|
|
} else if outlineView.isEqual(self.tocOutlineView) {
|
|
|
- if item is CPDFOutline {
|
|
|
- let tempItem = item as! CPDFOutline
|
|
|
+ if let tempItem = item as? CPDFOutline {
|
|
|
let string: NSString = tempItem.label as NSString
|
|
|
let paragraphStyle = NSMutableParagraphStyle()
|
|
|
paragraphStyle.lineHeightMultiple = 1.32
|
|
@@ -2843,7 +2733,7 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
|
|
|
if let data = item as? String, data == "Bookmarks" {
|
|
|
return true
|
|
|
} else if item is CPDFOutline {
|
|
|
- return ((item as! CPDFOutline).numberOfChildren ?? 0) != 0
|
|
|
+ return ((item as? CPDFOutline)?.numberOfChildren ?? 0) != 0
|
|
|
} else if item is CPDFBookmark {
|
|
|
return false
|
|
|
}
|