1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- //
- // KMNoteReplyHanddler.swift
- // PDF Reader Pro
- //
- // Created by User-Tangchao on 2024/9/19.
- //
- import Cocoa
- // 注释回复处理类
- class KMNoteReplyHanddler: NSObject {
- func markAnnotation(_ anno: CPDFAnnotation?) {
- guard let replyA = self.fetchMarkAnnotation(anno) else {
- anno?.createReplyStateAnnotation(.marked)
- return
- }
- if replyA.getAnnotState() == .unMarked {
- replyA.setAnnotState(.marked)
- }
- }
-
- func unMarkAnnotation(_ anno: CPDFAnnotation?) {
- guard let replyA = self.fetchMarkAnnotation(anno) else {
- return
- }
- if replyA.getAnnotState() == .marked {
- replyA.setAnnotState(.unMarked)
- }
- }
-
- func fetchAnnoState(_ anno: CPDFAnnotation?) -> CPDFAnnotationState? {
- guard let replyA = self.fetchMarkAnnotation(anno) else {
- return nil
- }
- return replyA.getAnnotState()
- }
-
- func fetchReplyAnnotations(_ anno: CPDFAnnotation?) -> [CPDFAnnotation]? {
- guard let theAnno = anno else {
- return nil
- }
-
- var annos: [CPDFAnnotation] = []
- for a in theAnno.replyAnnotations ?? [] {
- if a.replyAnnotationType == .reply {
- annos.append(a)
- }
- }
- return annos
- }
-
- func fetchMarkAnnotation(_ anno: CPDFAnnotation?) -> CPDFAnnotation? {
- guard let theAnno = anno else {
- return nil
- }
-
- for replyA in theAnno.replyAnnotations ?? [] {
- if replyA.replyAnnotationType == .mark {
- return replyA
- }
- }
- return nil
- }
- }
|