|
@@ -1299,6 +1299,7 @@ extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
|
|
|
if let data = pdf?.isEncrypted, data {
|
|
|
KMBaseWindowController.checkPassword(url: URL(fileURLWithPath: path), type: .owner) { success, resultPassword in
|
|
|
if success && resultPassword.isEmpty == false {
|
|
|
+ self.model.insertedDocumentSet.insert(pdf!)
|
|
|
for i in 0 ..< (pdf?.pageCount ?? 0) {
|
|
|
if let page = pdf?.page(at: i).copy() as? CPDFPage {
|
|
|
self.pdfDocument()?.insertPageObject(page, at: UInt(index))
|
|
@@ -1310,6 +1311,9 @@ extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
+ if let data = pdf {
|
|
|
+ self.model.insertedDocumentSet.insert(data)
|
|
|
+ }
|
|
|
for i in 0 ..< (pdf?.pageCount ?? 0) {
|
|
|
let page = pdf?.page(at: i)
|
|
|
self.pdfDocument()?.insertPageObject(page, at: UInt(index))
|
|
@@ -1382,32 +1386,32 @@ extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
|
|
|
var insertIndexSet = IndexSet()
|
|
|
var index = row
|
|
|
|
|
|
-// if (fileNames.count == 1) {
|
|
|
if fileNames != nil {
|
|
|
-// var path = fileNames.first as? String ?? ""
|
|
|
let path = fileNames as? String ?? ""
|
|
|
let url = URL(string: path)
|
|
|
let pathExtension = url?.pathExtension.lowercased() ?? ""
|
|
|
if pathExtension == "pdf" {
|
|
|
let pdf = CPDFDocument(url: url!)
|
|
|
if let data = pdf?.isEncrypted, data {
|
|
|
- KMBaseWindowController.checkPassword(url: url!, type: .owner) { success, resultPassword in
|
|
|
+ self.view.window?.windowController?.kCheckPassword(url: url!, type: .owner, completion: { [weak self] success, resultPassword in
|
|
|
if success && resultPassword.isEmpty == false {
|
|
|
pdf?.unlock(withPassword: resultPassword)
|
|
|
+ self?.model.insertedDocumentSet.insert(pdf!)
|
|
|
for i in 0 ..< (pdf?.pageCount ?? 0) {
|
|
|
- // let page = pdf?.page(at: i).copy() as? CPDFPage
|
|
|
if let page = pdf?.page(at: i) {
|
|
|
- self.pdfDocument()?.insertPageObject(page, at: UInt(index))
|
|
|
+ self?.pdfDocument()?.insertPageObject(page, at: UInt(index))
|
|
|
insertIndexSet.insert(index)
|
|
|
index += 1
|
|
|
}
|
|
|
}
|
|
|
- self.insertPages(insertIndexSet, pageAt: index-1)
|
|
|
+ self?.insertPages(insertIndexSet, pageAt: index-1)
|
|
|
}
|
|
|
- }
|
|
|
+ })
|
|
|
} else {
|
|
|
+ if let data = pdf {
|
|
|
+ self.model.insertedDocumentSet.insert(data)
|
|
|
+ }
|
|
|
for i in 0 ..< (pdf?.pageCount ?? 0) {
|
|
|
-// let page = pdf?.page(at: i).copy() as? CPDFPage
|
|
|
if let page = pdf?.page(at: i) {
|
|
|
self.pdfDocument()?.insertPageObject(page, at: UInt(index))
|
|
|
insertIndexSet.insert(index)
|
|
@@ -1445,11 +1449,6 @@ extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
|
|
|
fileExt = "pdf"
|
|
|
// filenames
|
|
|
pboard.declareTypes([.pdf, .tiff, .fileURL, .filePromise, .localDraggedTypes, KPDFThumbnailDoucumentURLForDraggedTypes], owner: self)
|
|
|
-// let newDoc = CPDFDocument()
|
|
|
-// newDoc?.insertPageObject(page, at: 0)
|
|
|
-// let data = newDoc?.dataRepresentation()
|
|
|
-
|
|
|
-// [pboard setData:pdfData forType:NSPasteboardTypePDF];
|
|
|
pboard.setData(tiffData, forType: .pdf)
|
|
|
|
|
|
// NSData *zNSIndexSetData = [NSKeyedArchiver archivedDataWithRootObject:rowIndexes];
|
|
@@ -1622,7 +1621,6 @@ extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
|
|
|
let pdf = CPDFDocument()
|
|
|
for idx in indexSet {
|
|
|
if idx != NSNotFound && self.isLocked() == false {
|
|
|
-// let copyPage = self.listView.document.page(at: UInt(idx)).copy() as? CPDFPage
|
|
|
let copyPage = self.pdfDocument()?.page(at: UInt(idx))
|
|
|
pdf?.insertPageObject(copyPage, at: pdf?.pageCount ?? 0)
|
|
|
}
|