CPDFListView.h 11 KB

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