|
@@ -78,11 +78,11 @@ import KMComponentLibrary
|
|
|
|
|
|
//右边
|
|
//右边
|
|
var rightSideController: KMRightSideController?
|
|
var rightSideController: KMRightSideController?
|
|
-
|
|
|
|
|
|
+
|
|
//MARK: - 旧代码,有需要用到的拿出来,写好备注
|
|
//MARK: - 旧代码,有需要用到的拿出来,写好备注
|
|
|
|
|
|
@IBOutlet weak var leftView: NSView!
|
|
@IBOutlet weak var leftView: NSView!
|
|
-
|
|
|
|
|
|
+
|
|
var model = KMMainModel()
|
|
var model = KMMainModel()
|
|
|
|
|
|
//自动滚动
|
|
//自动滚动
|
|
@@ -99,11 +99,11 @@ import KMComponentLibrary
|
|
//对比
|
|
//对比
|
|
var isCompareModel: Bool = false {
|
|
var isCompareModel: Bool = false {
|
|
didSet {
|
|
didSet {
|
|
- }
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
//合并
|
|
//合并
|
|
var mergeWindowController: KMMergeWindowController?
|
|
var mergeWindowController: KMMergeWindowController?
|
|
-
|
|
|
|
|
|
+
|
|
//密码弹窗
|
|
//密码弹窗
|
|
var passwordWindow: KMPasswordInputWindow?
|
|
var passwordWindow: KMPasswordInputWindow?
|
|
//对比
|
|
//对比
|
|
@@ -173,7 +173,7 @@ import KMComponentLibrary
|
|
|
|
|
|
var pageNumber: UInt?
|
|
var pageNumber: UInt?
|
|
|
|
|
|
- var pdfEditController: KMPDFEditViewController? {
|
|
|
|
|
|
+ var pdfEditController: KMPDFEditViewController? {
|
|
get {
|
|
get {
|
|
return self.getPDFEditController()
|
|
return self.getPDFEditController()
|
|
}
|
|
}
|
|
@@ -190,7 +190,7 @@ import KMComponentLibrary
|
|
let vc = KMNHomeViewController()
|
|
let vc = KMNHomeViewController()
|
|
return vc
|
|
return vc
|
|
}()
|
|
}()
|
|
-
|
|
|
|
|
|
+
|
|
fileprivate var _secureOptions: [CPDFDocumentWriteOption : Any]?
|
|
fileprivate var _secureOptions: [CPDFDocumentWriteOption : Any]?
|
|
var secureOptions: [CPDFDocumentWriteOption : Any]? {
|
|
var secureOptions: [CPDFDocumentWriteOption : Any]? {
|
|
get {
|
|
get {
|
|
@@ -378,7 +378,7 @@ import KMComponentLibrary
|
|
listView.annotationType = .addText
|
|
listView.annotationType = .addText
|
|
listView.setShouAddEdit([.text])
|
|
listView.setShouAddEdit([.text])
|
|
listView.change(.text)
|
|
listView.change(.text)
|
|
-
|
|
|
|
|
|
+
|
|
} else if subToolMode == .Edit_Image {
|
|
} else if subToolMode == .Edit_Image {
|
|
if listView.toolMode != .editPDFToolMode {
|
|
if listView.toolMode != .editPDFToolMode {
|
|
listView.toolMode = .editPDFToolMode
|
|
listView.toolMode = .editPDFToolMode
|
|
@@ -387,18 +387,18 @@ import KMComponentLibrary
|
|
listView.annotationType = .addImage
|
|
listView.annotationType = .addImage
|
|
listView.setShouAddEdit([.image])
|
|
listView.setShouAddEdit([.image])
|
|
listView.change(.image)
|
|
listView.change(.image)
|
|
-
|
|
|
|
|
|
+
|
|
} else if subToolMode == .Edit_Link {
|
|
} else if subToolMode == .Edit_Link {
|
|
listView.toolMode = .noteToolMode
|
|
listView.toolMode = .noteToolMode
|
|
|
|
|
|
listView.annotationType = .link
|
|
listView.annotationType = .link
|
|
|
|
|
|
} else if subToolMode == .Edit_Crop {
|
|
} else if subToolMode == .Edit_Crop {
|
|
-// listView.toolMode = .selectToolMode
|
|
|
|
|
|
+ // listView.toolMode = .selectToolMode
|
|
|
|
|
|
showCropController()
|
|
showCropController()
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
} else if toolbarMode == .Form {
|
|
} else if toolbarMode == .Form {
|
|
|
|
|
|
@@ -480,7 +480,7 @@ import KMComponentLibrary
|
|
updatePDFViewAnnotationMode()
|
|
updatePDFViewAnnotationMode()
|
|
|
|
|
|
if viewManager.showRightSide == true {
|
|
if viewManager.showRightSide == true {
|
|
- openRightPane()
|
|
|
|
|
|
+ openRightPane()
|
|
|
|
|
|
} else {
|
|
} else {
|
|
closeRightPane()
|
|
closeRightPane()
|
|
@@ -593,7 +593,7 @@ import KMComponentLibrary
|
|
pageEditViewController?.currentUndoManager = listView.undoManager
|
|
pageEditViewController?.currentUndoManager = listView.undoManager
|
|
toolbarManager.page_pageInfo_Property.text = String(listView.currentPageIndex + 1)
|
|
toolbarManager.page_pageInfo_Property.text = String(listView.currentPageIndex + 1)
|
|
pdfToolbarController?.refreshSecondToolbarItemsState()
|
|
pdfToolbarController?.refreshSecondToolbarItemsState()
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -885,17 +885,17 @@ import KMComponentLibrary
|
|
//MARK: - Crop裁剪
|
|
//MARK: - Crop裁剪
|
|
func showCropController() {
|
|
func showCropController() {
|
|
listView.isHidden = true
|
|
listView.isHidden = true
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
if cropController == nil {
|
|
if cropController == nil {
|
|
cropController = KMCropController.init()
|
|
cropController = KMCropController.init()
|
|
}
|
|
}
|
|
cropController?.view.frame = CGRectMake(44, 0, CGRectGetWidth(bottomContendBox.frame)-44, CGRectGetHeight(bottomContendBox.frame))
|
|
cropController?.view.frame = CGRectMake(44, 0, CGRectGetWidth(bottomContendBox.frame)-44, CGRectGetHeight(bottomContendBox.frame))
|
|
cropController?.view.autoresizingMask = [.maxXMargin, .width, .height]
|
|
cropController?.view.autoresizingMask = [.maxXMargin, .width, .height]
|
|
-// cropController?.delegate = self
|
|
|
|
|
|
+ cropController?.delegate = self
|
|
bottomContendBox.addSubview(cropController!.view)
|
|
bottomContendBox.addSubview(cropController!.view)
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
updateCropDocument()
|
|
updateCropDocument()
|
|
}
|
|
}
|
|
|
|
|
|
@@ -917,11 +917,15 @@ import KMComponentLibrary
|
|
|
|
|
|
func removeCropController() {
|
|
func removeCropController() {
|
|
listView.isHidden = false
|
|
listView.isHidden = false
|
|
-
|
|
|
|
|
|
+
|
|
if cropController != nil {
|
|
if cropController != nil {
|
|
cropController?.view.removeFromSuperview()
|
|
cropController?.view.removeFromSuperview()
|
|
cropController = nil
|
|
cropController = nil
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ toolbarManager.edit_crop_Property.state = .normal
|
|
|
|
+ pdfToolbarController?.refreshSecondToolbarItemsState()
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
//MARK: - Watermark水印
|
|
//MARK: - Watermark水印
|
|
@@ -1178,6 +1182,99 @@ import KMComponentLibrary
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //MARK: - Crop
|
|
|
|
+
|
|
|
|
+ // 白边距
|
|
|
|
+ @objc func smart_cropAllPage() {
|
|
|
|
+
|
|
|
|
+ var rectArray: Array<NSRect> = []
|
|
|
|
+ for i in 0 ..< self.listView.document.pageCount {
|
|
|
|
+ progressC?.increment(by: Double(i))
|
|
|
|
+ progressC?.doubleValue = Double(i)
|
|
|
|
+ let page = self.listView.document.page(at: i)
|
|
|
|
+ let rect = KMCropTools.getPageForegroundBox(page!)
|
|
|
|
+ rectArray.append(rect)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 自动
|
|
|
|
+ @objc func auto_cropAllPage() {
|
|
|
|
+ var size = NSZeroSize
|
|
|
|
+ for i in 0 ..< self.listView.document.pageCount {
|
|
|
|
+ let page = self.listView.document.page(at: i)
|
|
|
|
+ let rect = KMCropTools.getPageForegroundBox(page!)
|
|
|
|
+ size.width = fmax(size.width, NSWidth(rect))
|
|
|
|
+ size.height = fmax(size.height, NSHeight(rect))
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var rectArray: Array<NSRect> = []
|
|
|
|
+ for i in 0 ..< self.listView.document.pageCount {
|
|
|
|
+ progressC?.increment(by: Double(i))
|
|
|
|
+ progressC?.doubleValue = Double(i)
|
|
|
|
+ let page = self.listView.document.page(at: i)
|
|
|
|
+ var rect = KMCropTools.getPageForegroundBox(page!)
|
|
|
|
+ let bounds: NSRect = (page?.bounds(for: .mediaBox))!
|
|
|
|
+ if (rect.minX - bounds.minX > bounds.maxX-rect.maxX) {
|
|
|
|
+ rect.origin.x = rect.maxX-size.width
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ rect.origin.y = rect.maxY-size.height
|
|
|
|
+ rect.size = size
|
|
|
|
+
|
|
|
|
+ if (NSWidth(rect) > NSWidth(bounds)) {
|
|
|
|
+ rect.size.width = NSWidth(bounds)
|
|
|
|
+ }
|
|
|
|
+ if (NSHeight(rect) > NSHeight(bounds)) {
|
|
|
|
+ rect.size.height = NSHeight(bounds)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (NSMinX(rect) < NSMinX(bounds)) {
|
|
|
|
+ rect.origin.x = NSMinX(bounds)
|
|
|
|
+ } else if (NSMaxX(rect) > NSMaxX(bounds)) {
|
|
|
|
+ rect.origin.x = NSMaxX(bounds) - NSWidth(rect)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (NSMinY(rect) < NSMinY(bounds)) {
|
|
|
|
+ rect.origin.y = NSMinY(bounds)
|
|
|
|
+ } else if (NSMaxY(rect) > NSMaxY(bounds)) {
|
|
|
|
+ rect.origin.y = NSMaxY(bounds) - NSHeight(rect)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ rectArray.append(rect)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ func cropPages(atIndexs pageIndexs: [UInt], to rects: Array<NSRect>) {
|
|
|
|
+ let currentPage = self.listView.currentPage()
|
|
|
|
+ let visibleRect: NSRect = self.listView.convert(self.listView.convert(self.listView.documentView().visibleRect, from: self.listView.documentView()), to: self.listView.currentPage())
|
|
|
|
+
|
|
|
|
+ var oldRectArray: Array<NSRect> = []
|
|
|
|
+ let rectCount = rects.count
|
|
|
|
+ for i in pageIndexs {
|
|
|
|
+ if let page = self.listView.document.page(at: i) {
|
|
|
|
+ let rect = NSIntersectionRect(rects[Int(i) % rectCount], (page.bounds(for: .mediaBox)))
|
|
|
|
+ let oldRect = page.bounds(for: .cropBox)
|
|
|
|
+ oldRectArray.append(oldRect)
|
|
|
|
+
|
|
|
|
+ page.setBounds(rect, for: .cropBox)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ let undoManager = self.listView.undoManager
|
|
|
|
+ (undoManager?.prepare(withInvocationTarget: self) as AnyObject).cropPages(atIndexs: pageIndexs, to: oldRectArray)
|
|
|
|
+
|
|
|
|
+ /// 刷新预览视图
|
|
|
|
+ self.listView.layoutDocumentView()
|
|
|
|
+
|
|
|
|
+ self.listView.displayBox = .cropBox
|
|
|
|
+
|
|
|
|
+ self.listView.go(to: currentPage)
|
|
|
|
+ self.listView.go(to: visibleRect, on: currentPage)
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
//MARK: - Share
|
|
//MARK: - Share
|
|
@objc private func shareDocument(sender: NSView) {
|
|
@objc private func shareDocument(sender: NSView) {
|
|
let document = self.listView.document ?? CPDFDocument()
|
|
let document = self.listView.document ?? CPDFDocument()
|
|
@@ -1320,7 +1417,7 @@ import KMComponentLibrary
|
|
represent.perform(withItems: [string])
|
|
represent.perform(withItems: [string])
|
|
return
|
|
return
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
let represent = sender.representedObject as? NSSharingService
|
|
let represent = sender.representedObject as? NSSharingService
|
|
represent?.perform(withItems: [string])
|
|
represent?.perform(withItems: [string])
|
|
}
|
|
}
|
|
@@ -1434,7 +1531,7 @@ extension KMMainViewController: KMPDFToolbarControllerDelegate {
|
|
} else if itemIdentifier == KMPDFToolbar_Protect_Identifier {
|
|
} else if itemIdentifier == KMPDFToolbar_Protect_Identifier {
|
|
|
|
|
|
} else if itemIdentifier == KMPDFToolbar_Tools_Identifier {
|
|
} else if itemIdentifier == KMPDFToolbar_Tools_Identifier {
|
|
-
|
|
|
|
|
|
+
|
|
} else if itemIdentifier == KMPDFToolbar_convert_word_Identifier {
|
|
} else if itemIdentifier == KMPDFToolbar_convert_word_Identifier {
|
|
let winC = KMConvertWordWindowController()
|
|
let winC = KMConvertWordWindowController()
|
|
let model = KMDocumentModel(url: listView.document.documentURL)
|
|
let model = KMDocumentModel(url: listView.document.documentURL)
|
|
@@ -1648,7 +1745,7 @@ extension KMMainViewController: KMPDFToolbarControllerDelegate {
|
|
fileAttribute.bAllPage = false
|
|
fileAttribute.bAllPage = false
|
|
fileAttribute.pagesType = .PagesString
|
|
fileAttribute.pagesType = .PagesString
|
|
fileAttribute.pagesString = view.properties.text ?? ""
|
|
fileAttribute.pagesString = view.properties.text ?? ""
|
|
-
|
|
|
|
|
|
+
|
|
let fetchSelectPages = fileAttribute.fetchSelectPages()
|
|
let fetchSelectPages = fileAttribute.fetchSelectPages()
|
|
if (fetchSelectPages.isEmpty) {
|
|
if (fetchSelectPages.isEmpty) {
|
|
let alert = NSAlert()
|
|
let alert = NSAlert()
|
|
@@ -1663,9 +1760,9 @@ extension KMMainViewController: KMPDFToolbarControllerDelegate {
|
|
tIndexPaths.insert(IndexPath(item: (fetchSelectPages[i] - 1), section: 0))
|
|
tIndexPaths.insert(IndexPath(item: (fetchSelectPages[i] - 1), section: 0))
|
|
}
|
|
}
|
|
pageEditViewController?.selectionIndexPaths = tIndexPaths
|
|
pageEditViewController?.selectionIndexPaths = tIndexPaths
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1869,7 +1966,7 @@ extension KMMainViewController: KMSplitPDFViewControllerDelegate {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-//MARK: - Edit相关代理
|
|
|
|
|
|
+//MARK: - Edit编辑相关代理
|
|
extension KMMainViewController: KMEditToolbarViewDelegate {
|
|
extension KMMainViewController: KMEditToolbarViewDelegate {
|
|
func kmEditToolbarViewDidUpdateMode(_ view: KMEditToolbarView) {
|
|
func kmEditToolbarViewDidUpdateMode(_ view: KMEditToolbarView) {
|
|
if view.editType == .watermark {
|
|
if view.editType == .watermark {
|
|
@@ -1964,6 +2061,21 @@ extension KMMainViewController: KMEditToolbarViewDelegate {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+//MARK: - KMCropControllerDelegate 裁剪相关代理
|
|
|
|
+extension KMMainViewController: KMCropControllerDelegate {
|
|
|
|
+ func kmCropControllerDidCrop(_ controller: KMCropController, _ cropRect: CGRect, _ view: KMPageRangeSelectView) {
|
|
|
|
+ let indexs = view.getSelectedPageIndex(listView.document)
|
|
|
|
+ var uIndexs: [UInt] = []
|
|
|
|
+ for index in indexs {
|
|
|
|
+ if index > 0 {
|
|
|
|
+ uIndexs.append(UInt(index-1))
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ cropPages(atIndexs: uIndexs, to: [cropRect])
|
|
|
|
+ removeCropController()
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
//MARK: - KMWatermarkControllerDelegate 水印相关代理
|
|
//MARK: - KMWatermarkControllerDelegate 水印相关代理
|
|
extension KMMainViewController: KMWatermarkControllerDelegate {
|
|
extension KMMainViewController: KMWatermarkControllerDelegate {
|
|
func kmWatermarkControllerDidUpdateMode(_ view: KMWatermarkController) {
|
|
func kmWatermarkControllerDidUpdateMode(_ view: KMWatermarkController) {
|
|
@@ -2022,7 +2134,7 @@ extension KMMainViewController: KMBackgroundControllerDelegate {
|
|
extension KMMainViewController: KMHeaderFooterControllerDelegate {
|
|
extension KMMainViewController: KMHeaderFooterControllerDelegate {
|
|
func kmHeaderFooterControllerDidUpdateMode(_ view: KMHeaderFooterController) {
|
|
func kmHeaderFooterControllerDidUpdateMode(_ view: KMHeaderFooterController) {
|
|
editToolbarView?.editSubType = view.editSubType
|
|
editToolbarView?.editSubType = view.editSubType
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
func kmHeaderFooterControllerDidModelDataUpdated(_ view: KMHeaderFooterController) {
|
|
func kmHeaderFooterControllerDidModelDataUpdated(_ view: KMHeaderFooterController) {
|
|
@@ -2146,7 +2258,7 @@ extension KMMainViewController: CPDFViewDelegate,CPDFListViewDelegate {
|
|
func pdfViewDidClick(onLink pdfView: CPDFView!, withURL url: String!) {
|
|
func pdfViewDidClick(onLink pdfView: CPDFView!, withURL url: String!) {
|
|
if let urlString = url, urlString == kKMPurchaseProductURLString {
|
|
if let urlString = url, urlString == kKMPurchaseProductURLString {
|
|
//跳转订阅比较表
|
|
//跳转订阅比较表
|
|
- return
|
|
|
|
|
|
+ return
|
|
}
|
|
}
|
|
|
|
|
|
if url.hasPrefix("smb://") {
|
|
if url.hasPrefix("smb://") {
|
|
@@ -2200,13 +2312,13 @@ extension KMMainViewController: CPDFViewDelegate,CPDFListViewDelegate {
|
|
//MARK: -编辑模块
|
|
//MARK: -编辑模块
|
|
func pdfViewEditingSelectionDidChanged(_ pdfView: CPDFView!) {
|
|
func pdfViewEditingSelectionDidChanged(_ pdfView: CPDFView!) {
|
|
// 文本区块 选中文本已经变化
|
|
// 文本区块 选中文本已经变化
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
func pdfViewEditingAreaDidChanged(_ pdfView: CPDFView!) {
|
|
func pdfViewEditingAreaDidChanged(_ pdfView: CPDFView!) {
|
|
//编辑模块变化
|
|
//编辑模块变化
|
|
rightSideController?.reloadDataWithPDFView(pdfView: (pdfView as! CPDFListView))
|
|
rightSideController?.reloadDataWithPDFView(pdfView: (pdfView as! CPDFListView))
|
|
-
|
|
|
|
|
|
+
|
|
if pdfView is CPDFListView {
|
|
if pdfView is CPDFListView {
|
|
(pdfView as! CPDFListView).isEditImage = false
|
|
(pdfView as! CPDFListView).isEditImage = false
|
|
}
|
|
}
|
|
@@ -2356,7 +2468,7 @@ extension KMMainViewController: CPDFViewDelegate,CPDFListViewDelegate {
|
|
attri.isItalic = model.italic
|
|
attri.isItalic = model.italic
|
|
|
|
|
|
self.listView.createStringBounds(newRect, with: attri, page: page)
|
|
self.listView.createStringBounds(newRect, with: attri, page: page)
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
func pdfViewMobileEditingBegan(_ point: CGPoint, for pdfView: CPDFView!, forEditing editingAreas: [CPDFEditArea]!) {
|
|
func pdfViewMobileEditingBegan(_ point: CGPoint, for pdfView: CPDFView!, forEditing editingAreas: [CPDFEditArea]!) {
|
|
@@ -2394,7 +2506,7 @@ extension KMMainViewController: CPDFViewDelegate,CPDFListViewDelegate {
|
|
}
|
|
}
|
|
|
|
|
|
func pdfViewEditingDoubleClick(_ pdfView: CPDFView!, imageArea editArea: CPDFEditArea!) {
|
|
func pdfViewEditingDoubleClick(_ pdfView: CPDFView!, imageArea editArea: CPDFEditArea!) {
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
func pdfListViewKeyDownIsContinue(_ pdfListView: CPDFListView!, theEvent: NSEvent!) -> Bool {
|
|
func pdfListViewKeyDownIsContinue(_ pdfListView: CPDFListView!, theEvent: NSEvent!) -> Bool {
|
|
@@ -2557,7 +2669,7 @@ extension KMMainViewController: CPDFViewDelegate,CPDFListViewDelegate {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if isSameAnnotation == false {
|
|
if isSameAnnotation == false {
|
|
-
|
|
|
|
|
|
+
|
|
} else {
|
|
} else {
|
|
self.openRightPane()
|
|
self.openRightPane()
|
|
}
|
|
}
|
|
@@ -2567,7 +2679,7 @@ extension KMMainViewController: CPDFViewDelegate,CPDFListViewDelegate {
|
|
let fristAnnotation = annotations.first
|
|
let fristAnnotation = annotations.first
|
|
let className = NSStringFromClass(fristAnnotation!.classForCoder)
|
|
let className = NSStringFromClass(fristAnnotation!.classForCoder)
|
|
if self.viewManager.isPDFReadMode {
|
|
if self.viewManager.isPDFReadMode {
|
|
-
|
|
|
|
|
|
+
|
|
self.closeRightPane()
|
|
self.closeRightPane()
|
|
} else {
|
|
} else {
|
|
if className != "CPDFStampAnnotation" &&
|
|
if className != "CPDFStampAnnotation" &&
|
|
@@ -2609,12 +2721,12 @@ extension KMMainViewController: CPDFViewDelegate,CPDFListViewDelegate {
|
|
}
|
|
}
|
|
} else if (annotations.count == 0){
|
|
} else if (annotations.count == 0){
|
|
if pdfListView.annotationType == .unkown {
|
|
if pdfListView.annotationType == .unkown {
|
|
- self.closeRightPane()
|
|
|
|
|
|
+ self.closeRightPane()
|
|
} else {
|
|
} else {
|
|
if self.viewManager.isPDFReadMode {
|
|
if self.viewManager.isPDFReadMode {
|
|
- self.closeRightPane()
|
|
|
|
|
|
+ self.closeRightPane()
|
|
} else {
|
|
} else {
|
|
- self.openRightPane()
|
|
|
|
|
|
+ self.openRightPane()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -2622,7 +2734,7 @@ extension KMMainViewController: CPDFViewDelegate,CPDFListViewDelegate {
|
|
|
|
|
|
func pdfListViewChangedAnnotationType(_ pdfListView: CPDFListView!, for annotationType: CAnnotationType) {
|
|
func pdfListViewChangedAnnotationType(_ pdfListView: CPDFListView!, for annotationType: CAnnotationType) {
|
|
if(annotationType == .unkown) {
|
|
if(annotationType == .unkown) {
|
|
- self.closeRightPane()
|
|
|
|
|
|
+ self.closeRightPane()
|
|
}
|
|
}
|
|
let aType = annotationType
|
|
let aType = annotationType
|
|
if aType.isMarkup() || aType == .anchored || aType == .freeText || aType.isSquare() || aType == .link {
|
|
if aType.isMarkup() || aType == .anchored || aType == .freeText || aType.isSquare() || aType == .link {
|
|
@@ -2904,12 +3016,12 @@ extension KMMainViewController: CPDFViewDelegate,CPDFListViewDelegate {
|
|
if self.listView.toolMode == .moveToolMode {
|
|
if self.listView.toolMode == .moveToolMode {
|
|
self.listView.toolMode = .textToolMode
|
|
self.listView.toolMode = .textToolMode
|
|
self.listView.annotationType = .unkown
|
|
self.listView.annotationType = .unkown
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
if (self.model.rightMouseEventing) {
|
|
if (self.model.rightMouseEventing) {
|
|
self.model.rightMouseEventing = false
|
|
self.model.rightMouseEventing = false
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|
|
self.leftSideViewController.refreshUIForAddAnnotation(annos: annotations, page: pdfPage)
|
|
self.leftSideViewController.refreshUIForAddAnnotation(annos: annotations, page: pdfPage)
|
|
@@ -2994,11 +3106,11 @@ extension KMMainViewController: CPDFViewDelegate,CPDFListViewDelegate {
|
|
|
|
|
|
//TextEdit
|
|
//TextEdit
|
|
func pdfListViewDidTextFontChanged(_ pdfListView: CPDFListView!) {
|
|
func pdfListViewDidTextFontChanged(_ pdfListView: CPDFListView!) {
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
func pdfListViewDidTextColorChanged(_ pdfListView: CPDFListView!, with color: NSColor!) {
|
|
func pdfListViewDidTextColorChanged(_ pdfListView: CPDFListView!, with color: NSColor!) {
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
func pdfListViewAnnotationMeasureInfoChange(_ pdfListView: CPDFListView!, with annotation: CPDFAnnotation!) {
|
|
func pdfListViewAnnotationMeasureInfoChange(_ pdfListView: CPDFListView!, with annotation: CPDFAnnotation!) {
|
|
@@ -3242,7 +3354,7 @@ extension KMMainViewController {
|
|
self.initPDFLeftViewVC()
|
|
self.initPDFLeftViewVC()
|
|
self.leftSideViewController.mainViewController = self
|
|
self.leftSideViewController.mainViewController = self
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
func viewDidAppearFunction() {
|
|
func viewDidAppearFunction() {
|
|
//春季活动
|
|
//春季活动
|
|
@@ -3333,7 +3445,7 @@ extension KMMainViewController {
|
|
|
|
|
|
func viewDidLoadOld() {
|
|
func viewDidLoadOld() {
|
|
mwcFlags.settingUpWindow = 1
|
|
mwcFlags.settingUpWindow = 1
|
|
-
|
|
|
|
|
|
+
|
|
self.srHanddler.pdfView = self.listView
|
|
self.srHanddler.pdfView = self.listView
|
|
|
|
|
|
self.initToolbar()
|
|
self.initToolbar()
|
|
@@ -3366,8 +3478,8 @@ extension KMMainViewController {
|
|
self._goToFirstPageForFristAppear()
|
|
self._goToFirstPageForFristAppear()
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(rename(_:)), name: NSNotification.Name.init(rawValue: "KMTabControllerRename"), object: nil)
|
|
NotificationCenter.default.addObserver(self, selector: #selector(rename(_:)), name: NSNotification.Name.init(rawValue: "KMTabControllerRename"), object: nil)
|
|
NotificationCenter.default.addObserver(self, selector: #selector(closeTab(_:)), name: NSNotification.Name.init(rawValue: "KMTabControllerCloseTabs"), object: nil)
|
|
NotificationCenter.default.addObserver(self, selector: #selector(closeTab(_:)), name: NSNotification.Name.init(rawValue: "KMTabControllerCloseTabs"), object: nil)
|
|
@@ -3446,7 +3558,7 @@ extension KMMainViewController {
|
|
leftSideViewController.delegate = self
|
|
leftSideViewController.delegate = self
|
|
self.leftView.addSubview(leftSideViewController.view)
|
|
self.leftView.addSubview(leftSideViewController.view)
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
func addAdsBannerView() {
|
|
func addAdsBannerView() {
|
|
#if VERSION_FREE
|
|
#if VERSION_FREE
|
|
if !IAPProductsManager.default().isAvailableAllFunction(){
|
|
if !IAPProductsManager.default().isAvailableAllFunction(){
|
|
@@ -3454,7 +3566,7 @@ extension KMMainViewController {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
if !document.isLocked {
|
|
if !document.isLocked {
|
|
- }
|
|
|
|
|
|
+ }
|
|
NotificationCenter.default.addObserver(self, selector: #selector(purchaseStateUpdateNoti), name: NSNotification.Name(rawValue: "KMIAPProductPurchasedNotification"), object: nil)
|
|
NotificationCenter.default.addObserver(self, selector: #selector(purchaseStateUpdateNoti), name: NSNotification.Name(rawValue: "KMIAPProductPurchasedNotification"), object: nil)
|
|
NotificationCenter.default.addObserver(self, selector: #selector(purchaseStateUpdateNoti), name: NSNotification.Name(rawValue: "kDeviceActivateNotification"), object: nil)
|
|
NotificationCenter.default.addObserver(self, selector: #selector(purchaseStateUpdateNoti), name: NSNotification.Name(rawValue: "kDeviceActivateNotification"), object: nil)
|
|
|
|
|
|
@@ -3728,15 +3840,15 @@ extension KMMainViewController {
|
|
|
|
|
|
func loadOpenFileFunctionGuide(_ showType: KMGuideInfoType) -> Void {
|
|
func loadOpenFileFunctionGuide(_ showType: KMGuideInfoType) -> Void {
|
|
if showType == .openFileNormal && KMGuideInfoWindowController.availableShow(.openFileNormal) {
|
|
if showType == .openFileNormal && KMGuideInfoWindowController.availableShow(.openFileNormal) {
|
|
-
|
|
|
|
|
|
+
|
|
self.guideInfoWindowController = KMGuideInfoWindowController.currentWC()
|
|
self.guideInfoWindowController = KMGuideInfoWindowController.currentWC()
|
|
guard let guideWC = self.guideInfoWindowController else { return }
|
|
guard let guideWC = self.guideInfoWindowController else { return }
|
|
|
|
|
|
guideWC.type = .openFileNormal
|
|
guideWC.type = .openFileNormal
|
|
-// guideWC.openPanelRect = (self.view.window?.contentView?.convert(leftPanelItem.frame, from: leftPanelItem.superview)) ?? .zero
|
|
|
|
|
|
+ // guideWC.openPanelRect = (self.view.window?.contentView?.convert(leftPanelItem.frame, from: leftPanelItem.superview)) ?? .zero
|
|
guideWC.window?.collectionBehavior = [.canJoinAllSpaces]
|
|
guideWC.window?.collectionBehavior = [.canJoinAllSpaces]
|
|
guideWC.normalGuideFinishHandle = { [weak self] windowVC in
|
|
guideWC.normalGuideFinishHandle = { [weak self] windowVC in
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|
|
guideWC.finishHandle = { [weak self] windowVC, type in
|
|
guideWC.finishHandle = { [weak self] windowVC, type in
|
|
@@ -3761,7 +3873,7 @@ extension KMMainViewController {
|
|
|
|
|
|
guideWC.type = .digitalSignGuide
|
|
guideWC.type = .digitalSignGuide
|
|
|
|
|
|
- guideWC.window?.collectionBehavior = [.canJoinAllSpaces]
|
|
|
|
|
|
+ guideWC.window?.collectionBehavior = [.canJoinAllSpaces]
|
|
guideWC.finishHandle = { [weak self] windowVC, type in
|
|
guideWC.finishHandle = { [weak self] windowVC, type in
|
|
self?.checkFirstTrialController()
|
|
self?.checkFirstTrialController()
|
|
}
|
|
}
|
|
@@ -3780,11 +3892,11 @@ extension KMMainViewController {
|
|
|
|
|
|
guideWC.type = .pdfCompareGuide
|
|
guideWC.type = .pdfCompareGuide
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
guard let win = self.view.window else {
|
|
guard let win = self.view.window else {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
guideWC.finishHandle = { [weak self] winC, type in
|
|
guideWC.finishHandle = { [weak self] winC, type in
|
|
if type == .windowNewFinish {
|
|
if type == .windowNewFinish {
|
|
DispatchQueue.main.async {
|
|
DispatchQueue.main.async {
|
|
@@ -3828,10 +3940,10 @@ extension KMMainViewController {
|
|
guard let guideWC = self.guideInfoWindowController else { return }
|
|
guard let guideWC = self.guideInfoWindowController else { return }
|
|
|
|
|
|
guideWC.type = .convertGuide
|
|
guideWC.type = .convertGuide
|
|
- guard let win = self.view.window else {
|
|
|
|
|
|
+ guard let win = self.view.window else {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- guideWC.purchaseHandle = { [weak self] windowVC in
|
|
|
|
|
|
+ guideWC.purchaseHandle = { [weak self] windowVC in
|
|
#if VERSION_DMG
|
|
#if VERSION_DMG
|
|
if IAPProductsManager.default().isAvailableAllFunction() {
|
|
if IAPProductsManager.default().isAvailableAllFunction() {
|
|
if IAPProductsManager.default().isAvailableAdvancedPDFToOffice() {
|
|
if IAPProductsManager.default().isAvailableAdvancedPDFToOffice() {
|
|
@@ -3931,7 +4043,7 @@ extension KMMainViewController {
|
|
controller.selectedPages = tPages
|
|
controller.selectedPages = tPages
|
|
controller.listView = self.listView
|
|
controller.listView = self.listView
|
|
self.addChild(controller)
|
|
self.addChild(controller)
|
|
-
|
|
|
|
|
|
+
|
|
controller.view.autoresizingMask = [.width,.height]
|
|
controller.view.autoresizingMask = [.width,.height]
|
|
self.listView.isHidden = true
|
|
self.listView.isHidden = true
|
|
|
|
|
|
@@ -3994,7 +4106,7 @@ extension KMMainViewController {
|
|
open func hasEnterPageEdit() -> Bool {
|
|
open func hasEnterPageEdit() -> Bool {
|
|
return self.getPDFEditController() != nil
|
|
return self.getPDFEditController() != nil
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
// MARK: - 数字签名
|
|
// MARK: - 数字签名
|
|
|
|
|
|
@@ -4049,7 +4161,7 @@ extension KMMainViewController {
|
|
var currentPageIndex = listView.document?.index(for: listView.currentPage()) ?? 0
|
|
var currentPageIndex = listView.document?.index(for: listView.currentPage()) ?? 0
|
|
var password: String = ""
|
|
var password: String = ""
|
|
|
|
|
|
- password = listView.document?.password ?? ""
|
|
|
|
|
|
+ password = listView.document?.password ?? ""
|
|
|
|
|
|
digitalSignController = KMPDFDigitalSignViewController()
|
|
digitalSignController = KMPDFDigitalSignViewController()
|
|
|
|
|
|
@@ -4070,7 +4182,7 @@ extension KMMainViewController {
|
|
self?.exitDigitalSign()
|
|
self?.exitDigitalSign()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
// MARK: - Toolbar
|
|
// MARK: - Toolbar
|
|
@@ -4092,7 +4204,7 @@ extension KMMainViewController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if toolbarItem.itemIdentifier != KMDocumentEditToolbarItemIdentifier && toolbarItem.itemIdentifier != KMRightControlToolbarItemIdentifier && toolbarItem.itemIdentifier != KMLeftControlToolbarItemIdentifier {
|
|
if toolbarItem.itemIdentifier != KMDocumentEditToolbarItemIdentifier && toolbarItem.itemIdentifier != KMRightControlToolbarItemIdentifier && toolbarItem.itemIdentifier != KMLeftControlToolbarItemIdentifier {
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -4127,7 +4239,7 @@ extension KMMainViewController {
|
|
}
|
|
}
|
|
|
|
|
|
private func removeBackgroundMaskView() {
|
|
private func removeBackgroundMaskView() {
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
private func _goToFirstPageForFristAppear() {
|
|
private func _goToFirstPageForFristAppear() {
|
|
@@ -4321,7 +4433,7 @@ extension KMMainViewController {
|
|
self.mergeWindowController!.mergeAction = { [unowned self] controller, filePath in
|
|
self.mergeWindowController!.mergeAction = { [unowned self] controller, filePath in
|
|
self.view.window?.endSheet(mergeWindowController!.window!)
|
|
self.view.window?.endSheet(mergeWindowController!.window!)
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
self.view.window?.beginSheet(self.mergeWindowController!.window!)
|
|
self.view.window?.beginSheet(self.mergeWindowController!.window!)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -4336,7 +4448,7 @@ extension KMMainViewController {
|
|
securityWindowController.batchAction = { [unowned self] controller, files in
|
|
securityWindowController.batchAction = { [unowned self] controller, files in
|
|
self.view.window?.endSheet((securityWindowController.window)!)
|
|
self.view.window?.endSheet((securityWindowController.window)!)
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
let batchWindowController = KMBatchOperateWindowController.sharedWindowController
|
|
let batchWindowController = KMBatchOperateWindowController.sharedWindowController
|
|
let batchOperateFile = KMBatchOperateFile(filePath: self.document?.documentURL.path ?? "", type: .AddPassword)
|
|
let batchOperateFile = KMBatchOperateFile(filePath: self.document?.documentURL.path ?? "", type: .AddPassword)
|
|
batchWindowController.switchToOperateType(.AddPassword, files: [batchOperateFile])
|
|
batchWindowController.switchToOperateType(.AddPassword, files: [batchOperateFile])
|
|
@@ -4678,8 +4790,8 @@ extension KMMainViewController {
|
|
} else if self!.listView.editingAreas().count > 0 {
|
|
} else if self!.listView.editingAreas().count > 0 {
|
|
if self?.listView.annotationType == .addImage ||
|
|
if self?.listView.annotationType == .addImage ||
|
|
self?.listView.annotationType == .addText {
|
|
self?.listView.annotationType == .addText {
|
|
- }
|
|
|
|
- self?.listView.endEditIsRemoveBlock(with: self!.listView.editingAreas().first as? CPDFEditArea)
|
|
|
|
|
|
+ }
|
|
|
|
+ self?.listView.endEditIsRemoveBlock(with: self!.listView.editingAreas().first as? CPDFEditArea)
|
|
self?.listView.updateEditing([])
|
|
self?.listView.updateEditing([])
|
|
self?.listView.isEditImage = false
|
|
self?.listView.isEditImage = false
|
|
self?.listView.setNeedsDisplayPageViewFor(self!.listView.currentPage())
|
|
self?.listView.setNeedsDisplayPageViewFor(self!.listView.currentPage())
|
|
@@ -4691,8 +4803,8 @@ extension KMMainViewController {
|
|
} else if(self?.listView.annotationType == .addImage || self!.listView.annotationType == .addText) {
|
|
} else if(self?.listView.annotationType == .addImage || self!.listView.annotationType == .addText) {
|
|
if self?.listView.annotationType == .addImage ||
|
|
if self?.listView.annotationType == .addImage ||
|
|
self?.listView.annotationType == .addText {
|
|
self?.listView.annotationType == .addText {
|
|
- }
|
|
|
|
- self?.listView.setShouAddEdit([])
|
|
|
|
|
|
+ }
|
|
|
|
+ self?.listView.setShouAddEdit([])
|
|
self?.listView.change([.text, .image])
|
|
self?.listView.change([.text, .image])
|
|
self?.listView.annotationType = .editTextImage
|
|
self?.listView.annotationType = .editTextImage
|
|
self?.closeRightPane()
|
|
self?.closeRightPane()
|
|
@@ -4701,7 +4813,7 @@ extension KMMainViewController {
|
|
} else {
|
|
} else {
|
|
if self?.listView.annotationType == .addImage ||
|
|
if self?.listView.annotationType == .addImage ||
|
|
self?.listView.annotationType == .addText {
|
|
self?.listView.annotationType == .addText {
|
|
- }
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -4962,7 +5074,7 @@ extension KMMainViewController {
|
|
}
|
|
}
|
|
if self.listView.toolMode == .editPDFToolMode {
|
|
if self.listView.toolMode == .editPDFToolMode {
|
|
if editSelectd {
|
|
if editSelectd {
|
|
- }
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|