CPDFListView.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. //
  2. // CPDFListView.h
  3. // ComPDFKit
  4. //
  5. // Copyright © 2014-2022 PDF Technologies, Inc. All Rights Reserved.
  6. //
  7. // THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
  8. // AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
  9. // UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
  10. // This notice may not be removed from this file.
  11. //
  12. #import <ComPDFKit/ComPDFKit.h>
  13. #import <Foundation/Foundation.h>
  14. #import <QuartzCore/QuartzCore.h>
  15. #import <KMDrawViewSDK_Mac/KMDrawViewSDK_Mac.h>
  16. #define SKAnnotationKey @"SKAnnotation"
  17. extern NSString *SKPasteboardTypeLineStyle;
  18. extern NSNotificationName const CPDFListViewSelectionChangedNotification;
  19. extern NSNotificationName const CPDFListViewToolModeChangeNotification;
  20. extern NSNotificationName const CPDFListViewAnnotationTypeChangeNotification;
  21. extern NSNotificationName const CPDFListViewMagnificationChangedNotification;
  22. extern NSNotificationName const CPDFListViewDidAddAnnotationNotification;
  23. extern NSNotificationName const CPDFListViewDidRemoveAnnotationNotification;
  24. extern NSNotificationName const CPDFListViewActiveAnnotationsChangeNotification;
  25. extern NSNotificationName const CPDFListViewAnnotationsAttributeHasChangeNotification;
  26. extern NSNotificationName const KMPDFViewTableAnnotationDidChangeNotification;
  27. extern NSNotificationName const CPDFListViewDisplayModeChangeNotification;
  28. typedef NS_ENUM(NSInteger, CPDFViewSidebarSpeedMode) {
  29. CPDFViewSidebarSpeedModeLeft = 0,
  30. CPDFViewSidebarSpeedModeRight
  31. };
  32. typedef NS_ENUM(NSInteger, CAnnotationType) {
  33. CAnnotationTypeUnkown = 0,
  34. CAnnotationTypeAnchored, //Note
  35. CAnnotationTypeLink,
  36. CAnnotationTypeFreeText,
  37. CAnnotationTypeLine,
  38. CAnnotationTypeArrow,
  39. CAnnotationTypeSquare,
  40. CAnnotationTypeCircle,
  41. CAnnotationTypeHighlight,
  42. CAnnotationTypeUnderline,
  43. CAnnotationTypeSquiggly,
  44. CAnnotationTypeStrikeOut,
  45. CAnnotationTypeStamp,
  46. CAnnotationTypeSignSignature,
  47. /*CAnnotationTypeCaret,*/
  48. CAnnotationTypeInk,
  49. /*CAnnotationTypePopUp,*/
  50. /*CAnnotationTypeFileattachment,*/
  51. /*CAnnotationTypeSound,*/
  52. /*CAnnotationTypeMovie,*/
  53. CAnnotationTypeRedact,
  54. CAnnotationTypeEraser,
  55. CAnnotationTypeMeasureSquare,
  56. CAnnotationTypeMeasureLine,
  57. CAnnotationTypeMeasurePolyGon,
  58. CAnnotationTypeMeasurePolyLine,
  59. CAnnotationTypeRadioButton = 100,
  60. CAnnotationTypeCheckBox,
  61. CAnnotationTypeTextField,
  62. CAnnotationTypeComboBox,
  63. CAnnotationTypeListMenu,
  64. CAnnotationTypeActionButton,
  65. CAnnotationTypeSignature,
  66. CAnnotationTypeSignText = 200,
  67. CAnnotationTypeSignFalse,
  68. CAnnotationTypeSignTure,
  69. CAnnotationTypeSignCircle,
  70. CAnnotationTypeSignLine,
  71. CAnnotationTypeSignDot,
  72. CAnnotationTypeSignConfig,
  73. CAnnotationTypeSignDate,
  74. CAnnotationTypeTable,
  75. CAnnotationTypeDigitalSign,
  76. };
  77. typedef NS_ENUM(NSInteger, CToolMode) {
  78. CTextToolMode = 0, //常规模式
  79. CMoveToolMode, //滚动模式
  80. CMagnifyToolMode, //放大镜模式
  81. CSelectToolMode, //内容选择模式
  82. CNoteToolMode, //注释创建模式
  83. CSelectZoomToolMode, //区域放大模式
  84. CFormToolMode, //Form模式
  85. CEditPDFToolMode, //内容编辑模式
  86. CEditLinkToolMode, //添加Link注释模式
  87. CRedactToolMode, //密文模式
  88. CRedactErasureToolMode, //密文擦除
  89. CDigitalSignToolMode, //数字签名
  90. COCRToolMode, //OCR模式
  91. CCropToolMode, //裁剪模式
  92. }; //移除填写模式+测量模式(CNoteToolMode),isMeasureAnnotationType&isSelfSignAnnotationType来区分
  93. typedef NS_ENUM(NSUInteger, KMPDFActiveFormsAlignType) {
  94. KMPDFActiveFormsAlignType_Left = 0,
  95. KMPDFActiveFormsAlignType_Vertical,
  96. KMPDFActiveFormsAlignType_Right,
  97. KMPDFActiveFormsAlignType_Top,
  98. KMPDFActiveFormsAlignType_Horizontally,
  99. KMPDFActiveFormsAlignType_Bottom,
  100. KMPDFActiveFormsAlignType_DisHorizontally,
  101. KMPDFActiveFormsAlignType_DisVertical
  102. };
  103. typedef NS_ENUM(NSUInteger, KMPDFViewMode) {
  104. KMPDFViewModeNormal = 0,
  105. KMPDFViewModeSoft,
  106. KMPDFViewModeNight,
  107. KMPDFViewModeGreen,
  108. KMPDFViewModeThemes1,
  109. KMPDFViewModeThemes2,
  110. KMPDFViewModeThemes3,
  111. KMPDFViewModeThemes4,
  112. KMPDFViewModeOther
  113. };
  114. typedef NS_ENUM(NSInteger, KMPDFViewSplitMode) {
  115. KMPDFViewSplitModeDisable = 0,
  116. KMPDFViewSplitModeHorizontal,
  117. KMPDFViewSplitModeVertical
  118. };
  119. enum {
  120. SKDragArea = 1 << 16,
  121. SKResizeUpDownArea = 1 << 17,
  122. SKResizeLeftRightArea = 1 << 18,
  123. SKResizeDiagonal45Area = 1 << 19,
  124. SKResizeDiagonal135Area = 1 << 20,
  125. SKReadingBarArea = 1 << 21,
  126. SKSpecialToolArea = 1 << 22
  127. };
  128. @protocol CPDFListViewDelegate;
  129. @class CStampSignatureObject,CPDFListStampAnnotation,CPDFListSignatureAnnotation, KMTableCellData;
  130. @interface CPDFListView : CPDFView
  131. @property (nonatomic, weak) id<CPDFListViewDelegate>pdfListViewDelegate;
  132. // Methods for The currently selected Annotation.
  133. @property (nonatomic, readonly) NSMutableArray <CPDFAnnotation *>*activeAnnotations;
  134. // Methods for The currently selected Annotation.
  135. @property (nonatomic, readonly) CPDFAnnotation * activeAnnotation;
  136. @property (nonatomic, readonly) CPDFAnnotation * editAnnotation;
  137. // Methods for The annotation type currently selected.
  138. @property (nonatomic, assign) CAnnotationType annotationType;
  139. // Method of the currently selected annotation mode.
  140. @property (nonatomic, assign) CToolMode toolMode;
  141. // The magnification times when the current magnifying glass is in mode
  142. @property (nonatomic, readonly) CGFloat magnification;
  143. @property (nonatomic, assign) BOOL isSetLinkDestinationArea;
  144. // Show Annotation or not
  145. @property (nonatomic, assign) BOOL hideNotes;
  146. // Whether to display a Form comment hop number
  147. @property (nonatomic, assign) BOOL showHopnumber;
  148. // Whether to display the Form name
  149. @property (nonatomic, assign) BOOL showFormFieldName;
  150. // Auxiliary reference line
  151. @property (nonatomic, strong) CAShapeLayer *shapeLayerLeftV;
  152. @property (nonatomic, strong) CAShapeLayer *shapeLayerRightV;
  153. @property (nonatomic, strong) CAShapeLayer *shapeLayerTopH;
  154. @property (nonatomic, strong) CAShapeLayer *shapeLayerBottomH;
  155. @property (nonatomic, assign) NSPoint lastAddAnnotationPoint;
  156. @property (nonatomic, assign) BOOL isCreatAnnotation;
  157. @property (nonatomic, assign) NSInteger toolBarCreateAnnotationMenuItem;
  158. @property (nonatomic, assign) BOOL isTakeSnapeSelectConetent;
  159. @property (nonatomic, assign) KMPDFViewMode viewMode;
  160. @property (nonatomic, assign) KMPDFViewSplitMode viewSplitMode;
  161. @property (nonatomic, strong) NSTrackingArea *trackingArea;
  162. @property (nonatomic, strong) NSImage *originImage;
  163. @property (nonatomic,retain) KMTableCellData *cellCopyData;
  164. @property (nonatomic,retain) NSTextField *tableTextField;
  165. @property (nonatomic, assign) NSPoint dragTablePoint;
  166. @property (nonatomic, assign) BOOL editAreaBoundUpdating;
  167. // Measurement attribute setting
  168. @property (nonatomic, retain) CPDFDistanceMeasureInfo *distanceMeasureInfo;
  169. @property (nonatomic, retain) CPDFPerimeterMeasureInfo *perimeterMeasureInfo;
  170. @property (nonatomic, retain) CPDFAreaMeasureInfo *polygonAreaMeasureInfo;
  171. @property (nonatomic, retain) CPDFAreaMeasureInfo *squareAreaMeasureInfo;
  172. @property (nonatomic, retain) NSArray *signatures;
  173. @property (nonatomic, assign) BOOL isPresentationMode;
  174. @property (nonatomic, readonly) BOOL isShowSplitBar;
  175. @property (nonatomic, strong) KMDrawView *presentationDrawView;
  176. - (CPDFAnnotation *)addAnnotationWithType:(CAnnotationType)annotationType selection:(CPDFSelection *)selection page:(CPDFPage *)page bounds:(NSRect)bounds;
  177. - (void)addAnnotationWithAnnotation:(CPDFAnnotation *)annotation toPage:(CPDFPage *)page;
  178. // Add stamp Annotation, add directly after mouse click
  179. // a new parameter.
  180. // stampObject - stamp Object.
  181. // isToolModel - Whether it is a pattern
  182. - (void)setAddStampObject:(CStampSignatureObject *)stampObject keepToolModel:(BOOL)isToolModel;
  183. // Add an image Stamp note
  184. - (void)addAnnotationWithImage:(NSImage *)image page:(CPDFPage *)page point:(NSPoint)point;
  185. // Refresh the currently selected Annotation
  186. - (void)updateActiveAnnotations:(NSArray<CPDFAnnotation *> *)activeAnnotation;
  187. // Edit Annotation
  188. - (void)editAnnotation:(CPDFAnnotation *)annotation;
  189. // Rotate Stamp notes, angle 0-360 degrees,Rotation is supported only by the current addition
  190. - (void)rotateStampAnnotation:(CPDFListStampAnnotation *)annotation rotateAngle:(NSInteger)angle;
  191. // Rotate Signature notes, angle 0-360 degrees,Rotation is supported only by the current addition
  192. - (void)rotateSignatureAnnotation:(CPDFListSignatureAnnotation *)annotation rotateAngle:(NSInteger)angle;
  193. // When selecting a region mode, the selected region is obtained
  194. - (NSRect)currentSelectionRect;
  195. - (CPDFPage *)currentSelectionPage;
  196. // Scale the page to the specified range
  197. - (void)zoomToRect:(NSRect)rect onPage:(CPDFPage *)page;
  198. // Remove Auxiliary reference line
  199. - (void)removeShapeLayer;
  200. // Determines whether the current annotation is consistent with the selected annotation mode
  201. - (BOOL)consistentTypeWithAnnotation:(CPDFAnnotation *)annotation;
  202. //修改对齐方式
  203. - (void)changeAnnotations:(NSArray<CPDFAnnotation *> *)annotations alignmentType:(KMPDFActiveFormsAlignType)type;
  204. - (void)addImageAnnotation:(NSImage *)image center:(NSPoint)center isRemoveBGColor:(BOOL)isRemoveBGColor;
  205. - (void)setPageBackgroundColorWithColor:(NSColor *)color viewMode:(KMPDFViewMode)viewMode;
  206. - (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard types:(NSArray *)types;
  207. - (void)enterPresentationDrawMode;
  208. - (BOOL)isEnterPresentationDrawMode;
  209. - (void)changePresentationDrawModelColor:(NSColor *)color;
  210. - (void)resetPresentationDrawMode;
  211. - (void)exitPresentationDrawMode;
  212. - (KMDrawView *)CreatePresentationDrawView;
  213. - (CGRect)selectionMultipleBoundsWithAnnotations:(NSArray<CPDFAnnotation *> *)annotations;
  214. - (CGRect)selectionMultipleBoundsWithEditArea:(NSArray<CPDFEditArea *> *)editAreas;
  215. - (void)removeAnnotation:(CPDFAnnotation *)annotation;
  216. - (IBAction)menuItemClick_TwoPagesContinuous:(id)sender;
  217. - (IBAction)menuItemClick_TwoPages:(id)sender;
  218. - (IBAction)menuItemClick_SinglePagesContinuous:(id)sender;
  219. - (IBAction)menuItemClick_SinglePage:(id)sender;
  220. - (IBAction)menuItemClick_BookMode:(id)sender;
  221. - (IBAction)menuItemClick_BringForward:(NSMenuItem *)sender;
  222. - (IBAction)menuItemClick_SendBackward:(NSMenuItem *)sender;
  223. - (IBAction)menuItemClick_BringFront:(NSMenuItem *)sender;
  224. - (IBAction)menuItemClick_SendBack:(NSMenuItem *)sender;
  225. - (void)editAnnotation:(CPDFAnnotation *)annotation;
  226. - (void)redactAddAnnotationPages:(NSMutableArray *)pages redactAnnotation:(CPDFRedactAnnotation *)redactAnnotation;
  227. - (void)exprotSelection:(CPDFSelection *)selection type:(NSInteger)type; //0 png //1 jpg, 2 pdf
  228. @end
  229. @protocol CPDFListViewDelegate <NSObject>
  230. @optional
  231. - (void)PDFListViewChangedSelectionOrMagnification:(CPDFListView *)pdfListView;
  232. - (void)PDFListViewDidSelectionEnd:(CPDFListView *)pdfListView;
  233. - (void)PDFListViewChangedMagnification:(CPDFListView *)pdfListView;
  234. - (void)PDFListViewChangedToolMode:(CPDFListView *)pdfListView forToolMode:(CToolMode)toolMode;
  235. - (void)PDFListViewChangedAnnotationType:(CPDFListView *)pdfListView forAnnotationType:(CAnnotationType)annotationType;
  236. - (NSColor *)PDFListViewBackgroundColor;
  237. - (void)PDFListViewAddAnnotations:(CPDFListView *)pdfListView forAddAnnotations:(NSArray<CPDFAnnotation *> *)annotations inPage:(CPDFPage *)pdfPage;
  238. - (void)PDFListViewRemoveAnnotations:(CPDFListView *)pdfListView forRemoveAnnotations:(NSArray<CPDFAnnotation *> *)annotations inPage:(CPDFPage *)pdfPage;
  239. - (void)PDFListViewChangeatioActiveAnnotations:(CPDFListView *)pdfListView forActiveAnnotations:(NSArray<CPDFAnnotation *> *)annotations isRightMenu:(BOOL)isRightMenu;
  240. - (void)PDFListViewMenuForEvent:(CPDFListView *)pdfListView forEvent:(NSEvent *)theEvent clickMenu:(NSMenu **)menu isMoveSelectAnno:(BOOL)isMoveSelectAnno;
  241. - (BOOL)PDFListViewMenuValidate:(CPDFListView *)pdfListView menuItem:(NSMenuItem *)menuItem isTakesEffect:(BOOL *)isTakesEffect;
  242. - (void)PDFListViewEditAnnotation:(CPDFListView *)pdfListView forAnnotation:(CPDFAnnotation *)anotation;
  243. - (BOOL)PDFListViewKeyDownIsContinue:(CPDFListView *)pdfListView theEvent:(NSEvent *)theEvent;
  244. - (NSArray<NSMenuItem *> *)PDFListViewMenuItemsEditingAtPoint:(CGPoint)point forPage:(CPDFPage *)page menuItems:(NSArray <NSMenuItem *>*)menuItems;
  245. - (void)PDFListViewDidTextFontChanged:(CPDFListView *)pdfListView;
  246. - (void)PDFListViewDidTextColorChanged:(CPDFListView *)pdfListView withColor:(NSColor *)color;
  247. - (void)PDFListViewRedactErasure:(CPDFListView *)pdfListView;
  248. - (void)PDFListViewLinkDestinationStart:(CPDFListView *)pdfListView withActiveAnnotation:(CPDFAnnotation *)annotation;
  249. - (void)PDFListViewLinkDestinationEnd:(CPDFListView *)pdfListView withActiveAnnotation:(CPDFAnnotation *)annotation;
  250. - (void)PDFListViewKeyDowClosePanel:(CPDFViewSidebarSpeedMode)speedy event:(NSEvent *)theEvent;
  251. - (NSArray<NSColor *> *)PDFListViewEventMarkupColorWithAnnotation:(CPDFAnnotation *)annotation;
  252. - (BOOL)PDFListViewHaveDocumentAttribute;
  253. // 是否需要绘制注释 【文字、背景】
  254. - (BOOL)PDFListView:(CPDFListView *)pdfListView needDrawAnnotation:(CPDFAnnotation *)annotation;
  255. - (void)PDFListViewAnnotationAttributeHasChange:(CPDFListView *)pdfListView withAnnotation:(CPDFAnnotation *)annotation;
  256. - (void)PDFListView:(CPDFListView *)sender showSnapshotAtPageNumber:(NSInteger)pageNum forRect:(NSRect)rect scaleFactor:(CGFloat)scaleFactor autoFits:(BOOL)autoFits;
  257. - (void)PDFListView:(CPDFListView *)pdfView documentDataDidChanged:(id)docData withInfo:(NSDictionary *)info;
  258. - (void)PDFListViewAnnotationMeasureInfoChange:(CPDFListView *)pdfListView withAnnotation:(CPDFAnnotation *)annotation;
  259. - (void)PDFListViewMeasureCancel:(CPDFListView *)pdfListView;
  260. - (void)PDFListViewMobileAnnotationBegan:(CGPoint)point forPDFListView:(CPDFListView *)pdfListView forActiveAnnotations:(NSArray<CPDFAnnotation *> *)annotations;
  261. - (void)PDFListViewMobileAnnotationMove:(CGPoint)point forPDFListView:(CPDFListView *)pdfListView forActiveAnnotations:(NSArray<CPDFAnnotation *> *)annotations;
  262. - (void)PDFListViewMobileAnnotationEnd:(CGPoint)point forPDFListView:(CPDFListView *)pdfListView forActiveAnnotations:(NSArray<CPDFAnnotation *> *)annotations;
  263. - (BOOL)PDFListViewSplitModeShowBar;
  264. - (BOOL)PDFListViewShowTipView;
  265. - (void)PDFListViewAnnotationEditModeChange:(CPDFListView *)pdfListView forAnnotation:(CPDFAnnotation *)anotation;
  266. - (void)PDFListViewEndEditMode:(CPDFListView *)pdfListView;
  267. @end