CPDFListView.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  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. #define SKAnnotationKey @"SKAnnotation"
  16. extern NSString *SKPasteboardTypeLineStyle;
  17. extern NSNotificationName const CPDFListViewSelectionChangedNotification;
  18. extern NSNotificationName const CPDFListViewToolModeChangeNotification;
  19. extern NSNotificationName const CPDFListViewAnnotationTypeChangeNotification;
  20. extern NSNotificationName const CPDFListViewMagnificationChangedNotification;
  21. extern NSNotificationName const CPDFListViewDidAddAnnotationNotification;
  22. extern NSNotificationName const CPDFListViewDidRemoveAnnotationNotification;
  23. extern NSNotificationName const CPDFListViewActiveAnnotationsChangeNotification;
  24. extern NSNotificationName const CPDFListViewAnnotationsAttributeHasChangeNotification;
  25. extern NSNotificationName const KMPDFViewTableAnnotationDidChangeNotification;
  26. extern NSNotificationName const CPDFListViewDisplayModeChangeNotification;
  27. typedef NS_ENUM(NSInteger, CPDFViewSidebarSpeedMode) {
  28. CPDFViewSidebarSpeedModeLeft = 0,
  29. CPDFViewSidebarSpeedModeRight
  30. };
  31. typedef NS_ENUM(NSInteger, CAnnotationType) {
  32. CAnnotationTypeUnkown = 0,
  33. CAnnotationTypeAnchored,
  34. CAnnotationTypeLink,
  35. CAnnotationTypeFreeText,
  36. CAnnotationTypeLine,
  37. CAnnotationTypeArrow,
  38. CAnnotationTypeSquare,
  39. CAnnotationTypeCircle,
  40. /*CAnnotationTypePolyGon,*/
  41. /*CAnnotationTypePolyLine,*/
  42. CAnnotationTypeHighlight,
  43. CAnnotationTypeUnderline,
  44. // CAnnotationTypeSquiggly,
  45. CAnnotationTypeStrikeOut,
  46. CAnnotationTypeStamp,
  47. CAnnotationTypeSignSignature,
  48. /*CAnnotationTypeCaret,*/
  49. CAnnotationTypeInk,
  50. /*CAnnotationTypePopUp,*/
  51. /*CAnnotationTypeFileattachment,*/
  52. /*CAnnotationTypeSound,*/
  53. /*CAnnotationTypeMovie,*/
  54. CAnnotationTypeRedact,
  55. CAnnotationTypeEraser,
  56. CAnnotationTypeEditTextImage,
  57. CAnnotationTypeAddText,
  58. CAnnotationTypeAddImage,
  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. };
  76. typedef NS_ENUM(NSInteger, CToolMode) {
  77. CTextToolMode = 0,
  78. CMoveToolMode,
  79. CMagnifyToolMode,
  80. CSelectToolMode,
  81. CNoteToolMode,
  82. CSelectZoomToolMode,
  83. CFormToolMode,
  84. CSelfSignMode,
  85. CRedactToolMode,
  86. CRedactErasureToolMode,
  87. CEditPDFToolMode,
  88. };
  89. typedef NS_ENUM(NSUInteger, KMPDFActiveFormsAlignType) {
  90. KMPDFActiveFormsAlignType_Left = 0,
  91. KMPDFActiveFormsAlignType_Vertical,
  92. KMPDFActiveFormsAlignType_Right,
  93. KMPDFActiveFormsAlignType_Top,
  94. KMPDFActiveFormsAlignType_Horizontally,
  95. KMPDFActiveFormsAlignType_Bottom,
  96. KMPDFActiveFormsAlignType_DisHorizontally,
  97. KMPDFActiveFormsAlignType_DisVertical
  98. };
  99. typedef NS_ENUM(NSUInteger, KMPDFViewActiveFormsType) {
  100. KMPDFViewActiveFormsType_NotAllform = -1,//注释类型不全为form类型
  101. KMPDFViewActiveFormsType_Mix = 0,//包含多种类型的form(全为form)
  102. KMPDFViewActiveFormsType_Pure,//单纯只有一种form(全为form)
  103. KMPDFViewActiveFormsType_PureSingle,//单纯只有一种form(全为form),个数为1
  104. KMPDFViewActiveFormsType_Text,//单纯只有一种form,并且是text(全为form)
  105. KMPDFViewActiveFormsType_TextSingle,//单纯只有一种form,并且是text(全为form),个数为1
  106. KMPDFViewActiveFormsType_None
  107. };
  108. typedef NS_ENUM(NSUInteger, KMPDFViewMode) {
  109. KMPDFViewModeNormal = 0,
  110. KMPDFViewModeSoft,
  111. KMPDFViewModeNight,
  112. KMPDFViewModeGreen,
  113. KMPDFViewModeThemes1,
  114. KMPDFViewModeThemes2,
  115. KMPDFViewModeThemes3,
  116. KMPDFViewModeThemes4,
  117. KMPDFViewModeOther
  118. };
  119. typedef NS_ENUM(NSInteger, KMPDFViewSplitMode) {
  120. KMPDFViewSplitModeDisable = 0,
  121. KMPDFViewSplitModeHorizontal,
  122. KMPDFViewSplitModeVertical
  123. };
  124. enum {
  125. SKDragArea = 1 << 16,
  126. SKResizeUpDownArea = 1 << 17,
  127. SKResizeLeftRightArea = 1 << 18,
  128. SKResizeDiagonal45Area = 1 << 19,
  129. SKResizeDiagonal135Area = 1 << 20,
  130. SKReadingBarArea = 1 << 21,
  131. SKSpecialToolArea = 1 << 22
  132. };
  133. @protocol CPDFListViewDelegate;
  134. @class CStampSignatureObject,CPDFListStampAnnotation,CPDFListSignatureAnnotation, KMFormListMenuPopWindowController, KMTableCellData;
  135. @interface CPDFListView : CPDFView
  136. @property (nonatomic, weak) id<CPDFListViewDelegate>pdfListViewDelegate;
  137. // Methods for The currently selected Annotation.
  138. @property (nonatomic, readonly) NSMutableArray <CPDFAnnotation *>*activeAnnotations;
  139. // Methods for The currently selected Annotation.
  140. @property (nonatomic, readonly) CPDFAnnotation * activeAnnotation;
  141. // Methods for The annotation type currently selected.
  142. @property (nonatomic, assign) CAnnotationType annotationType;
  143. // Method of the currently selected annotation mode.
  144. @property (nonatomic, assign) CToolMode toolMode;
  145. // The magnification times when the current magnifying glass is in mode
  146. @property (nonatomic, readonly) CGFloat magnification;
  147. @property (nonatomic, assign) BOOL isSetLinkDestinationArea;
  148. // Show Annotation or not
  149. @property (nonatomic, assign) BOOL hideNotes;
  150. // Whether to display a Form comment hop number
  151. @property (nonatomic, assign) BOOL showHopnumber;
  152. // Whether to display the Form name
  153. @property (nonatomic, assign) BOOL showFormFieldName;
  154. // Auxiliary reference line
  155. @property (nonatomic, strong) CAShapeLayer *shapeLayerLeftV;
  156. @property (nonatomic, strong) CAShapeLayer *shapeLayerRightV;
  157. @property (nonatomic, strong) CAShapeLayer *shapeLayerTopH;
  158. @property (nonatomic, strong) CAShapeLayer *shapeLayerBottomH;
  159. @property (nonatomic, assign) NSPoint lastAddAnnotationPoint;
  160. @property (nonatomic, assign) BOOL isCreatAnnotation;
  161. @property (nonatomic, assign) NSInteger toolBarCreateAnnotationMenuItem;
  162. @property (nonatomic, assign) BOOL isTakeSnapeSelectConetent;
  163. @property (nonatomic, assign) KMPDFViewMode viewMode;
  164. @property (nonatomic, assign) KMPDFViewSplitMode viewSplitMode;
  165. @property (nonatomic, strong) KMFormListMenuPopWindowController *listWindowController;
  166. @property (nonatomic, strong) NSTrackingArea *trackingArea;
  167. @property (nonatomic, strong) NSImage *originImage;
  168. @property (nonatomic,retain) KMTableCellData *cellCopyData;
  169. @property (nonatomic,retain) NSTextField *tableTextField;
  170. @property (nonatomic, assign) NSPoint dragTablePoint;
  171. - (CPDFAnnotation *)addAnnotationWithType:(CAnnotationType)annotationType selection:(CPDFSelection *)selection page:(CPDFPage *)page bounds:(NSRect)bounds;
  172. - (void)addAnnotationWithAnnotation:(CPDFAnnotation *)annotation toPage:(CPDFPage *)page;
  173. // Add stamp Annotation, add directly after mouse click
  174. // a new parameter.
  175. // stampObject - stamp Object.
  176. // isToolModel - Whether it is a pattern
  177. - (void)setAddStampObject:(CStampSignatureObject *)stampObject keepToolModel:(BOOL)isToolModel;
  178. // Add an image Stamp note
  179. - (void)addAnnotationWithImage:(NSImage *)image page:(CPDFPage *)page point:(NSPoint)point;
  180. // Refresh the currently selected Annotation
  181. - (void)updateActiveAnnotations:(NSArray<CPDFAnnotation *> *)activeAnnotation;
  182. // Edit Annotation
  183. - (void)editAnnotation:(CPDFAnnotation *)annotation;
  184. // Rotate Stamp notes, angle 0-360 degrees,Rotation is supported only by the current addition
  185. - (void)rotateStampAnnotation:(CPDFListStampAnnotation *)annotation rotateAngle:(NSInteger)angle;
  186. // Rotate Signature notes, angle 0-360 degrees,Rotation is supported only by the current addition
  187. - (void)rotateSignatureAnnotation:(CPDFListSignatureAnnotation *)annotation rotateAngle:(NSInteger)angle;
  188. // When selecting a region mode, the selected region is obtained
  189. - (NSRect)currentSelectionRect;
  190. // Scale the page to the specified range
  191. - (void)zoomToRect:(NSRect)rect onPage:(CPDFPage *)page;
  192. // Remove Auxiliary reference line
  193. - (void)removeShapeLayer;
  194. // Determines whether the current annotation is consistent with the selected annotation mode
  195. - (BOOL)consistentTypeWithAnnotation:(CPDFAnnotation *)annotation;
  196. - (void)formsAnnotationAlign:(KMPDFActiveFormsAlignType)type;
  197. - (void)addImageAnnotation:(NSImage *)image center:(NSPoint)center isRemoveBGColor:(BOOL)isRemoveBGColor;
  198. - (void)setPageBackgroundColorWithColor:(NSColor *)color viewMode:(KMPDFViewMode)viewMode;
  199. - (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard types:(NSArray *)types;
  200. - (void)changeAnnotationTypeWithoutAction:(CAnnotationType)annotationType;
  201. - (void)clearStampCursor;
  202. @end
  203. @protocol CPDFListViewDelegate <NSObject>
  204. @optional
  205. - (void)PDFListViewChangedSelectionOrMagnification:(CPDFListView *)pdfListView;
  206. - (void)PDFListViewDidSelectionEnd:(CPDFListView *)pdfListView;
  207. - (void)PDFListViewChangedMagnification:(CPDFListView *)pdfListView;
  208. - (void)PDFListViewChangedToolMode:(CPDFListView *)pdfListView forToolMode:(CToolMode)toolMode;
  209. - (void)PDFListViewChangedAnnotationType:(CPDFListView *)pdfListView forAnnotationType:(CAnnotationType)annotationType;
  210. - (NSColor *)PDFListViewBackgroundColor;
  211. - (void)PDFListViewAddAnnotations:(CPDFListView *)pdfListView forAddAnnotations:(NSArray<CPDFAnnotation *> *)annotations inPage:(CPDFPage *)pdfPage;
  212. - (void)PDFListViewRemoveAnnotations:(CPDFListView *)pdfListView forRemoveAnnotations:(NSArray<CPDFAnnotation *> *)annotations inPage:(CPDFPage *)pdfPage;
  213. - (void)PDFListViewDeleteAnnotations:(CPDFListView *)pdfListView forDeleteAnnotations:(NSArray<CPDFAnnotation *> *)annotations inPage:(CPDFPage *)pdfPage;
  214. - (void)PDFListViewChangeatioActiveAnnotations:(CPDFListView *)pdfListView forActiveAnnotations:(NSArray<CPDFAnnotation *> *)annotations isRightMenu:(BOOL)isRightMenu;
  215. - (void)PDFListViewMenuForEvent:(CPDFListView *)pdfListView forEvent:(NSEvent *)theEvent clickMenu:(NSMenu **)menu isMoveSelectAnno:(BOOL)isMoveSelectAnno;
  216. - (BOOL)PDFListViewMenuValidate:(CPDFListView *)pdfListView menuItem:(NSMenuItem *)menuItem isTakesEffect:(BOOL *)isTakesEffect;
  217. - (void)PDFListViewEditAnnotation:(CPDFListView *)pdfListView forAnnotation:(CPDFAnnotation *)anotation;
  218. - (BOOL)PDFListViewKeyDownIsContinue:(CPDFListView *)pdfListView theEvent:(NSEvent *)theEvent;
  219. - (NSArray<NSMenuItem *> *)PDFListViewMenuItemsEditingAtPoint:(CGPoint)point forPage:(CPDFPage *)page menuItems:(NSArray <NSMenuItem *>*)menuItems;
  220. - (void)PDFListViewDidTextFontChanged:(CPDFListView *)pdfListView;
  221. - (void)PDFListViewDidTextColorChanged:(CPDFListView *)pdfListView withColor:(NSColor *)color;
  222. - (void)PDFListViewRedactErasure:(CPDFListView *)pdfListView;
  223. - (void)PDFListViewLinkDestinationStart:(CPDFListView *)pdfListView withActiveAnnotation:(CPDFAnnotation *)annotation;
  224. - (void)PDFListViewLinkDestinationEnd:(CPDFListView *)pdfListView withActiveAnnotation:(CPDFAnnotation *)annotation;
  225. - (void)PDFListViewKeyDowClosePanel:(CPDFViewSidebarSpeedMode)speedy event:(NSEvent *)theEvent;
  226. - (NSArray<NSColor *> *)PDFListViewEventMarkupColorWithAnnotation:(CPDFAnnotation *)annotation;
  227. - (BOOL)PDFListViewHaveDocumentAttribute;
  228. // 是否需要绘制注释 【文字、背景】
  229. - (BOOL)PDFListView:(CPDFListView *)pdfListView needDrawAnnotation:(CPDFAnnotation *)annotation;
  230. - (void)PDFListViewAnnotationAttributeHasChange:(CPDFListView *)pdfListView withAnnotation:(CPDFAnnotation *)annotation;
  231. - (void)PDFListView:(CPDFListView *)sender showSnapshotAtPageNumber:(NSInteger)pageNum forRect:(NSRect)rect scaleFactor:(CGFloat)scaleFactor autoFits:(BOOL)autoFits;
  232. - (void)PDFListView:(CPDFListView *)pdfView documentDataDidChanged:(id)docData withInfo:(NSDictionary *)info;
  233. - (void)pdfListViewDidApplyStampToAllPages:(CPDFListView *)pdfView ;
  234. - (void)pdfListViewDidAddLinkToSelectedImage:(CPDFListView *)pdfView ;
  235. - (BOOL)pdfListViewIsPDFReadMode;//当前是否是阅读模式
  236. @end