|
@@ -794,11 +794,9 @@ extension KMEditPDfHanddler {
|
|
|
guard let theColor = color else {
|
|
|
return
|
|
|
}
|
|
|
- let editingAreas = self.editingAreas
|
|
|
- for area in editingAreas {
|
|
|
- if let data = area as? CPDFEditTextArea {
|
|
|
- self.listView?.setEditingSelectionFontColor(theColor, with: data)
|
|
|
- }
|
|
|
+ let areas = self.editingTextAreas
|
|
|
+ for area in areas {
|
|
|
+ self.listView?.setEditingSelectionFontColor(theColor, with: area)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -806,157 +804,91 @@ extension KMEditPDfHanddler {
|
|
|
guard let font = CPDFFont.mappingFont(withFontString: fontName) else {
|
|
|
return
|
|
|
}
|
|
|
- let editingAreas = self.editingAreas
|
|
|
- for area in editingAreas {
|
|
|
- if let data = area as? CPDFEditTextArea {
|
|
|
- self.listView?.setEditSelectionCFont(font, with: data)
|
|
|
- }
|
|
|
+ let areas = self.editingTextAreas
|
|
|
+ for area in areas {
|
|
|
+ self.listView?.setEditSelectionCFont(font, with: area)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func fontAddAction() {
|
|
|
- let editingAreas = self.editingAreas
|
|
|
- if editingAreas.isEmpty {
|
|
|
- return
|
|
|
- }
|
|
|
- guard let area = editingAreas.last else {
|
|
|
- return
|
|
|
- }
|
|
|
- if area.isTextArea() == false {
|
|
|
- return
|
|
|
- }
|
|
|
- if let fontSize = self.listView?.editingSelectionFontSize(with: area as! CPDFEditTextArea) {
|
|
|
- self.listView?.setEditingSelectionFontSize(fontSize+1, with: area as! CPDFEditTextArea, isAutoSize: false)
|
|
|
+ let areas = self.editingTextAreas
|
|
|
+ for area in areas {
|
|
|
+ if let fontSize = self.listView?.editingSelectionFontSize(byRangeEdit: area) {
|
|
|
+ self.listView?.setEditingSelectionFontSize(fontSize+1, with: area, isAutoSize: false)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func fontReduceAction() {
|
|
|
- let editingAreas = self.editingAreas
|
|
|
- if editingAreas.isEmpty {
|
|
|
- return
|
|
|
- }
|
|
|
- guard let area = editingAreas.last else {
|
|
|
- return
|
|
|
- }
|
|
|
- if area.isTextArea() == false {
|
|
|
- return
|
|
|
- }
|
|
|
- if let fontSize = self.listView?.editingSelectionFontSize(with: area as! CPDFEditTextArea) {
|
|
|
- self.listView?.setEditingSelectionFontSize(fontSize-1, with: area as! CPDFEditTextArea, isAutoSize: false)
|
|
|
+ let areas = self.editingTextAreas
|
|
|
+ for area in areas {
|
|
|
+ if let fontSize = self.listView?.editingSelectionFontSize(byRangeEdit: area) {
|
|
|
+ self.listView?.setEditingSelectionFontSize(fontSize-1, with: area, isAutoSize: false)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func fontBoldAction() {
|
|
|
- let editingAreas = self.editingAreas
|
|
|
- if editingAreas.isEmpty {
|
|
|
- return
|
|
|
- }
|
|
|
- guard let area = editingAreas.last else {
|
|
|
- return
|
|
|
- }
|
|
|
- if area.isTextArea() == false {
|
|
|
- return
|
|
|
+ let areas = self.editingTextAreas
|
|
|
+ for area in areas {
|
|
|
+ if let data = self.listView?.isBoldCurrentSelection(byRangeEdit: area) {
|
|
|
+ self.listView?.setCurrentSelectionIsBold(!data, with: area)
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- self.listView?.setCurrentSelectionIsBold(true, with: area as! CPDFEditTextArea)
|
|
|
}
|
|
|
|
|
|
func fontItalicAction() {
|
|
|
- let editingAreas = self.editingAreas
|
|
|
- if editingAreas.isEmpty {
|
|
|
- return
|
|
|
- }
|
|
|
- guard let area = editingAreas.last else {
|
|
|
- return
|
|
|
- }
|
|
|
- if area.isTextArea() == false {
|
|
|
- return
|
|
|
+ let areas = self.editingTextAreas
|
|
|
+ for area in areas {
|
|
|
+ if let data = self.listView?.isItalicCurrentSelection(byRangeEdit: area) {
|
|
|
+ self.listView?.setCurrentSelectionIsItalic(!data, with: area)
|
|
|
+ }
|
|
|
}
|
|
|
- self.listView?.setCurrentSelectionIsItalic(true, with: area as! CPDFEditTextArea)
|
|
|
}
|
|
|
|
|
|
func textAlignmentAction(align: NSTextAlignment) {
|
|
|
- let editingAreas = self.editingAreas
|
|
|
- for area in editingAreas {
|
|
|
- if let data = area as? CPDFEditTextArea {
|
|
|
- self.listView?.setCurrentSelectionAlignment(align, with: data)
|
|
|
- }
|
|
|
+ let areas = self.editingTextAreas
|
|
|
+ for area in areas {
|
|
|
+ self.listView?.setCurrentSelectionAlignment(align, with: area)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func leftRotateAction() {
|
|
|
- let editingAreas = self.editingAreas
|
|
|
- if editingAreas.isEmpty {
|
|
|
- return
|
|
|
- }
|
|
|
- guard let area = editingAreas.last as? CPDFEditImageArea else {
|
|
|
- return
|
|
|
+ let areas = self.editingImageAreas
|
|
|
+ for area in areas {
|
|
|
+ self.listView?.rotate(with: area, rotate: -90)
|
|
|
}
|
|
|
-// if let ang = self.listView?.getRotateWith(area) {
|
|
|
-// self.listView?.rotate(with: area, rotate: ang-90)
|
|
|
-// }
|
|
|
-
|
|
|
-// FMTrackEventManager.defaultManager.trackEvent(event: "SubTbr_PageEdit", withProperties: ["SubTbr_Btn": "Btn_SubTbr_PageEdit_Rotate"])
|
|
|
- self.listView?.rotate(with: area, rotate: -90)
|
|
|
-
|
|
|
-// var frame = area.bounds
|
|
|
-// frame.size.width += 100
|
|
|
-// self.listView?.setBoundsEditArea(area, withBounds: frame)
|
|
|
- // 文档拖拽、tooltip、多选场景、暗黑场景
|
|
|
-
|
|
|
-// if self.listView.editingAreas()!.count == 1 && (self.listView.editingAreas()!.first is CPDFEditImageArea) {
|
|
|
-// self.listView.selectImageAreas = self.listView.editingAreas()!.first as? CPDFEditImageArea
|
|
|
-// }
|
|
|
-// self.editImageView.image = self.listView.selectImageAreas.thumbnailImage
|
|
|
-// self.delegate?.editImagePropertyViewControllerDidChanged(controller: self, type: .rotate)
|
|
|
}
|
|
|
|
|
|
func rightRotateAction() {
|
|
|
- let editingAreas = self.editingAreas
|
|
|
- if editingAreas.isEmpty {
|
|
|
- return
|
|
|
- }
|
|
|
- guard let area = editingAreas.last as? CPDFEditImageArea else {
|
|
|
- return
|
|
|
+ let areas = self.editingImageAreas
|
|
|
+ for area in areas {
|
|
|
+ self.listView?.rotate(with: area, rotate: 90)
|
|
|
}
|
|
|
- self.listView?.rotate(with: area, rotate: 90)
|
|
|
}
|
|
|
|
|
|
func reverseXAction() {
|
|
|
- let editingAreas = self.editingAreas
|
|
|
- if editingAreas.isEmpty {
|
|
|
- return
|
|
|
- }
|
|
|
- for area in editingAreas {
|
|
|
- if let data = area as? CPDFEditImageArea {
|
|
|
- self.listView?.horizontalMirror(with: data)
|
|
|
- }
|
|
|
+ let areas = self.editingImageAreas
|
|
|
+ for area in areas {
|
|
|
+ self.listView?.horizontalMirror(with: area)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func reverseYAction() {
|
|
|
- let editingAreas = self.editingAreas
|
|
|
- if editingAreas.isEmpty {
|
|
|
- return
|
|
|
- }
|
|
|
- for area in editingAreas {
|
|
|
- if let data = area as? CPDFEditImageArea {
|
|
|
- self.listView?.verticalMirror(with: data)
|
|
|
- }
|
|
|
+ let areas = self.editingImageAreas
|
|
|
+ for area in areas {
|
|
|
+ self.listView?.verticalMirror(with: area)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func cropAction() {
|
|
|
- let editingAreas = self.editingAreas
|
|
|
- if editingAreas.isEmpty {
|
|
|
+ let areas = self.editingImageAreas
|
|
|
+ if areas.isEmpty {
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
self.listView?.isEditImage = true
|
|
|
- for area in editingAreas {
|
|
|
- if let data = area as? CPDFEditImageArea {
|
|
|
- self.listView?.enterCrop(with: data)
|
|
|
- }
|
|
|
+ for area in areas {
|
|
|
+ self.listView?.enterCrop(with: area)
|
|
|
}
|
|
|
|
|
|
self.hiddenPopWindow()
|
|
@@ -970,14 +902,13 @@ extension KMEditPDfHanddler {
|
|
|
func cropCancelAction() {
|
|
|
self.hiddenCropComfirmWindow()
|
|
|
|
|
|
- let areas = self.editingAreas
|
|
|
+ let areas = self.editingImageAreas
|
|
|
if areas.isEmpty {
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
for area in areas {
|
|
|
- if let data = area as? CPDFEditImageArea {
|
|
|
- self.listView?.exitCrop(with: data)
|
|
|
- }
|
|
|
+ self.listView?.exitCrop(with: area)
|
|
|
}
|
|
|
|
|
|
self.listView?.cropAreas = nil
|
|
@@ -1002,8 +933,8 @@ extension KMEditPDfHanddler {
|
|
|
}
|
|
|
|
|
|
func replaceAction() {
|
|
|
- let editingAreas = self.editingAreas
|
|
|
- if editingAreas.isEmpty {
|
|
|
+ let areas = self.editingImageAreas
|
|
|
+ if areas.isEmpty {
|
|
|
return
|
|
|
}
|
|
|
let panel = NSOpenPanel()
|
|
@@ -1012,28 +943,20 @@ extension KMEditPDfHanddler {
|
|
|
panel.beginSheetModal(for: NSApp.mainWindow!) { response in
|
|
|
if response == .OK {
|
|
|
let openPath = panel.url?.path
|
|
|
- for area in editingAreas {
|
|
|
- if let data = area as? CPDFEditImageArea {
|
|
|
+ for area in areas {
|
|
|
// , rect: data.bounds
|
|
|
- self.listView?.replace(data, imagePath: openPath!)
|
|
|
- }
|
|
|
+ self.listView?.replace(area, imagePath: openPath!)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func exportAction() {
|
|
|
- let editingAreas = self.editingAreas
|
|
|
- if editingAreas.isEmpty {
|
|
|
+ let areas = self.editingImageAreas
|
|
|
+ if areas.isEmpty {
|
|
|
return
|
|
|
}
|
|
|
- var imagesAreas: [CPDFEditImageArea] = []
|
|
|
- for area in editingAreas {
|
|
|
- if let data = area as? CPDFEditImageArea {
|
|
|
- imagesAreas.append(data)
|
|
|
- }
|
|
|
- }
|
|
|
- if imagesAreas.count == 1 {
|
|
|
+ if areas.count == 1 {
|
|
|
let panel = NSSavePanel()
|
|
|
panel.nameFieldStringValue = "\(NSLocalizedString("Untitled", comment: "")).jpg"
|
|
|
panel.isExtensionHidden = true
|
|
@@ -1043,12 +966,12 @@ extension KMEditPDfHanddler {
|
|
|
if FileManager.default.fileExists(atPath: url!.path) {
|
|
|
try?FileManager.default.removeItem(atPath: url!.path)
|
|
|
}
|
|
|
- let result = self.listView?.extractImage(with: imagesAreas.first, toImagePath: url!.path) ?? false
|
|
|
+ let result = self.listView?.extractImage(with: areas.first, toImagePath: url!.path) ?? false
|
|
|
if result {
|
|
|
NSWorkspace.shared.activateFileViewerSelecting([url!])
|
|
|
}
|
|
|
}
|
|
|
- } else if imagesAreas.count > 1 {
|
|
|
+ } else if areas.count > 1 {
|
|
|
let panel = NSOpenPanel()
|
|
|
panel.canChooseFiles = false
|
|
|
panel.canChooseDirectories = true
|
|
@@ -1069,13 +992,13 @@ extension KMEditPDfHanddler {
|
|
|
}
|
|
|
try? FileManager.default.createDirectory(atPath: filePath!, withIntermediateDirectories: false, attributes: nil)
|
|
|
var saveURLs : [URL] = []
|
|
|
- for j in 0 ... imagesAreas.count-1 {
|
|
|
+ for j in 0 ..< areas.count {
|
|
|
let documentFileName = self.listView?.document?.documentURL.deletingPathExtension().lastPathComponent ?? ""
|
|
|
var outPath = filePath!
|
|
|
outPath = outPath.stringByAppendingPathComponent(documentFileName)
|
|
|
outPath = outPath + "page \(j+1)"
|
|
|
outPath = outPath.stringByAppendingPathExtension("jpg")
|
|
|
- let result = self.listView?.extractImage(with: imagesAreas[j], toImagePath: outPath) ?? false
|
|
|
+ let result = self.listView?.extractImage(with: areas[j], toImagePath: outPath) ?? false
|
|
|
if result {
|
|
|
saveURLs.append(URL(fileURLWithPath: outPath))
|
|
|
}
|
|
@@ -1537,6 +1460,8 @@ extension KMEditPDfHanddler: CPDFViewDelegate {
|
|
|
if self.subViewType == .EditPDFAddText {
|
|
|
self.rightViewC?.eidtPDFTextProperty.reloadData()
|
|
|
self.rightViewC?.eidtPDFTextProperty.updateTextTextPresuppositionState()
|
|
|
+
|
|
|
+ self.showPopWindow(positionRect: .zero)
|
|
|
}
|
|
|
}
|
|
|
|