|
@@ -15,6 +15,8 @@
|
|
|
#import "CPDFListView+Private.h"
|
|
|
#import "CPDFListMagnifierView.h"
|
|
|
|
|
|
+#import <MobileCoreServices/UTCoreTypes.h>
|
|
|
+
|
|
|
@implementation CPDFListView (Annotation)
|
|
|
|
|
|
#pragma mark - Private method
|
|
@@ -44,6 +46,16 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+- (BOOL)isPasteboardValid {
|
|
|
+ NSString *textType = (NSString *)kUTTypeText;
|
|
|
+ NSString *urlType = (NSString*)kUTTypeURL;
|
|
|
+ NSString *urlFileType = (NSString*)kUTTypeFileURL;
|
|
|
+ NSString *jpegImageType = (NSString *)kUTTypeJPEG;
|
|
|
+ NSString *pngImageType = (NSString *)kUTTypePNG;
|
|
|
+ NSString *rawImageType = @"com.apple.uikit.image";
|
|
|
+ return [[UIPasteboard generalPasteboard] containsPasteboardTypes:[NSArray arrayWithObjects:textType, urlType, urlFileType, jpegImageType, pngImageType, rawImageType, nil]];
|
|
|
+}
|
|
|
+
|
|
|
- (void)showMenuForAnnotation:(CPDFAnnotation *)annotation {
|
|
|
if (!annotation) {
|
|
|
[UIMenuController sharedMenuController].menuItems = nil;
|
|
@@ -51,71 +63,56 @@
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- NSMutableArray *menuItems = [NSMutableArray array];
|
|
|
- UIMenuItem *colorItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"Color", nil)
|
|
|
- action:@selector(colorItemAction:)];
|
|
|
- UIMenuItem *opacityItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"Opacity", nil)
|
|
|
- action:@selector(opacityItemAction:)];
|
|
|
- UIMenuItem *copyItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"Copy", nil)
|
|
|
- action:@selector(copyItemAction:)];
|
|
|
- UIMenuItem *noteItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"Note", nil)
|
|
|
- action:@selector(noteItemAction:)];
|
|
|
+ UIMenuItem *editNoteItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"Edit", nil)
|
|
|
+ action:@selector(menuItemClick_Edit:)];
|
|
|
+
|
|
|
UIMenuItem *deleteItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"Delete", nil)
|
|
|
- action:@selector(deleteItemAction:)];
|
|
|
- if ([annotation isKindOfClass:[CPDFMarkupAnnotation class]]) {
|
|
|
- UIMenuItem *shareItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"Share", nil)
|
|
|
- action:@selector(shareItemAction:)];
|
|
|
- [menuItems addObject:colorItem];
|
|
|
- [menuItems addObject:opacityItem];
|
|
|
- [menuItems addObject:copyItem];
|
|
|
- [menuItems addObject:shareItem];
|
|
|
- [menuItems addObject:noteItem];
|
|
|
- [menuItems addObject:deleteItem];
|
|
|
- } else if ([annotation isKindOfClass:[CPDFStampAnnotation class]]) {
|
|
|
- if (CPDFStampTypeImage == [(CPDFStampAnnotation *)annotation stampType]) {
|
|
|
- UIMenuItem *saveItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"Save", nil)
|
|
|
- action:@selector(saveItemAction:)];
|
|
|
- [menuItems addObject:saveItem];
|
|
|
- [menuItems addObject:copyItem];
|
|
|
- }
|
|
|
+ action:@selector(menuItemClick_Delete:)];
|
|
|
+
|
|
|
+ UIMenuItem *propertiesItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"Properties", nil)
|
|
|
+ action:@selector(menuItemClick_Properties:)];
|
|
|
+
|
|
|
+ UIMenuItem *noteItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"Note", nil)
|
|
|
+ action:@selector(menuItemClick_Note:)];
|
|
|
+
|
|
|
+ NSMutableArray *menuItems = [NSMutableArray array];
|
|
|
+ if([annotation isKindOfClass:[CPDFTextAnnotation class]]) {
|
|
|
+ [menuItems addObject:editNoteItem];
|
|
|
[menuItems addObject:deleteItem];
|
|
|
- } else if ([annotation isKindOfClass:[CPDFLinkAnnotation class]]) {
|
|
|
- UIMenuItem *editItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"Edit", nil)
|
|
|
- action:@selector(editItemAction:)];
|
|
|
- [menuItems addObject:editItem];
|
|
|
+ } else if([annotation isKindOfClass:[CPDFMarkupAnnotation class]] ||
|
|
|
+ [annotation isKindOfClass:[CPDFInkAnnotation class]] ||
|
|
|
+ [annotation isKindOfClass:[CPDFCircleAnnotation class]] ||
|
|
|
+ [annotation isKindOfClass:[CPDFSquareAnnotation class]] ||
|
|
|
+ [annotation isKindOfClass:[CPDFLineAnnotation class]]) {
|
|
|
+ [menuItems addObject:propertiesItem];
|
|
|
+ [menuItems addObject:noteItem];
|
|
|
[menuItems addObject:deleteItem];
|
|
|
} else if ([annotation isKindOfClass:[CPDFFreeTextAnnotation class]]) {
|
|
|
- UIMenuItem *editItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"Edit", nil)
|
|
|
- action:@selector(editItemAction:)];
|
|
|
- [menuItems addObject:editItem];
|
|
|
- [menuItems addObject:copyItem];
|
|
|
+ [menuItems addObject:propertiesItem];
|
|
|
+ [menuItems addObject:editNoteItem];
|
|
|
+ [menuItems addObject:deleteItem];
|
|
|
+ } else if ([annotation isKindOfClass:[CPDFStampAnnotation class]]) {
|
|
|
+ [menuItems addObject:noteItem];
|
|
|
[menuItems addObject:deleteItem];
|
|
|
} else if ([annotation isKindOfClass:[CPDFSoundAnnotation class]] ||
|
|
|
- [annotation isKindOfClass:[CPDFMovieAnnotation class]]) {
|
|
|
+ [annotation isKindOfClass:[CPDFMovieAnnotation class]]) {
|
|
|
+ if ([annotation isKindOfClass:[CPDFSoundAnnotation class]]) {
|
|
|
+ UIMenuItem *playItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"Play", nil)
|
|
|
+ action:@selector(menuItemClick_Play:)];
|
|
|
+ [menuItems addObject:playItem];
|
|
|
+ }
|
|
|
+ [menuItems addObject:deleteItem];
|
|
|
+ } else if ([annotation isKindOfClass:[CPDFLinkAnnotation class]]) {
|
|
|
+ [menuItems addObject:editNoteItem];
|
|
|
[menuItems addObject:deleteItem];
|
|
|
} else if ([annotation isKindOfClass:[CPDFSignatureAnnotation class]]) {
|
|
|
- UIMenuItem *cancelItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"Cancel", nil)
|
|
|
- action:@selector(deleteItemAction:)];
|
|
|
- UIMenuItem *addHereItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"Add here", nil)
|
|
|
- action:@selector(addHereItemAction:)];
|
|
|
- [menuItems addObject:cancelItem];
|
|
|
+ UIMenuItem *addHereItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"Signature", nil)
|
|
|
+ action:@selector(menuItemClick_Signature:)];
|
|
|
+
|
|
|
[menuItems addObject:addHereItem];
|
|
|
- } else if ([annotation isKindOfClass:[CPDFLineAnnotation class]] ||
|
|
|
- [annotation isKindOfClass:[CPDFSquareAnnotation class]] ||
|
|
|
- [annotation isKindOfClass:[CPDFCircleAnnotation class]] ||
|
|
|
- [annotation isKindOfClass:[CPDFInkAnnotation class]]) {
|
|
|
- UIMenuItem *thicknessItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"Thickness", nil)
|
|
|
- action:@selector(thicknessItemAction:)];
|
|
|
- [menuItems addObject:noteItem];
|
|
|
- [menuItems addObject:colorItem];
|
|
|
- [menuItems addObject:thicknessItem];
|
|
|
- [menuItems addObject:opacityItem];
|
|
|
- [menuItems addObject:deleteItem];
|
|
|
- } else if ([annotation isKindOfClass:[CPDFSignatureWidgetAnnotation class]]) {
|
|
|
- UIMenuItem *deleteItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"Delete", nil)
|
|
|
- action:@selector(signatureWidgetDeleteItemAction:)];
|
|
|
[menuItems addObject:deleteItem];
|
|
|
}
|
|
|
+
|
|
|
if (menuItems.count <= 0) {
|
|
|
return;
|
|
|
}
|
|
@@ -129,6 +126,192 @@
|
|
|
[[UIMenuController sharedMenuController] setMenuVisible:YES animated:YES];
|
|
|
}
|
|
|
|
|
|
+- (void)showMenuForMediaAtPoint:(CGPoint)point forPage:(CPDFPage *)page {
|
|
|
+ NSMutableArray *menuItems = [NSMutableArray array];
|
|
|
+ UIMenuItem *cancelItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"Delete", nil)
|
|
|
+ action:@selector(menuItemClick_MediaDelete:)];
|
|
|
+
|
|
|
+ UIMenuItem *mediaRecordItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"Record", nil)
|
|
|
+ action:@selector(menuItemClick_MediaRecord:)];
|
|
|
+ [menuItems addObject:cancelItem];
|
|
|
+ [menuItems addObject:mediaRecordItem];
|
|
|
+
|
|
|
+ CGRect bounds = CGRectMake(point.x-18, point.y-18, 37, 37);
|
|
|
+ CGRect rect = [self convertRect:bounds fromPage:page];
|
|
|
+ [self becomeFirstResponder];
|
|
|
+ [UIMenuController sharedMenuController].menuItems = menuItems;
|
|
|
+ [[UIMenuController sharedMenuController] setTargetRect:rect inView:self];
|
|
|
+ [[UIMenuController sharedMenuController] setMenuVisible:YES animated:YES];
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark - Action
|
|
|
+
|
|
|
+- (void)menuItemClick_Edit:(UIMenuItem *)menuItem {
|
|
|
+ if([self.activeAnnotation isKindOfClass:[CPDFTextAnnotation class]] || [self.activeAnnotation isKindOfClass:[CPDFLinkAnnotation class]]) {
|
|
|
+ if ([self.performDelegate respondsToSelector:@selector(PDFListViewEditNote:forAnnotation:)]) {
|
|
|
+ [self.performDelegate PDFListViewEditNote:self forAnnotation:self.activeAnnotation];
|
|
|
+ }
|
|
|
+ } else if([self.activeAnnotation isKindOfClass:[CPDFFreeTextAnnotation class]]) {
|
|
|
+ [self editAnnotationFreeText:(CPDFFreeTextAnnotation *)self.activeAnnotation];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)menuItemClick_Delete:(UIMenuItem *)menuItem {
|
|
|
+ [self updateActiveAnnotations:@[]];
|
|
|
+ [self.menuAnnotation.page removeAnnotation:self.activeAnnotation];
|
|
|
+ [self setNeedsDisplayForPage:self.activeAnnotation.page];
|
|
|
+ [self updateScrollEnabled];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)menuItemClick_Note:(UIMenuItem *)menuItem {
|
|
|
+ if ([self.performDelegate respondsToSelector:@selector(PDFListViewEditNote:forAnnotation:)]) {
|
|
|
+ [self.performDelegate PDFListViewEditNote:self forAnnotation:self.activeAnnotation];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)menuItemClick_Properties:(UIMenuItem *)menuItem {
|
|
|
+ if ([self.performDelegate respondsToSelector:@selector(PDFListViewEditProperties:forAnnotation:)]) {
|
|
|
+ [self.performDelegate PDFListViewEditProperties:self forAnnotation:self.activeAnnotation];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)menuItemClick_Signature:(UIMenuItem *)menuItem {
|
|
|
+ if ([self.activeAnnotation isKindOfClass:[CPDFSignatureAnnotation class]]) {
|
|
|
+ [(CPDFSignatureAnnotation *)self.activeAnnotation signature];
|
|
|
+
|
|
|
+ [self updateActiveAnnotations:@[]];
|
|
|
+ [self setNeedsDisplayForPage:self.activeAnnotation.page];
|
|
|
+ [self updateScrollEnabled];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)menuItemClick_Paste:(UIMenuItem *)menuItem {
|
|
|
+ NSString *textType = (NSString *)kUTTypeText;
|
|
|
+ NSString *utf8TextType = (NSString *)kUTTypeUTF8PlainText;
|
|
|
+ NSString *urlType = (NSString*)kUTTypeURL;
|
|
|
+ NSString *urlFileType = (NSString*)kUTTypeFileURL;
|
|
|
+ NSString *jpegImageType = (NSString *)kUTTypeJPEG;
|
|
|
+ NSString *pngImageType = (NSString *)kUTTypePNG;
|
|
|
+ NSString *rawImageType = @"com.apple.uikit.image";
|
|
|
+
|
|
|
+ NSArray *pasteArray = [UIPasteboard generalPasteboard].items;
|
|
|
+ for (NSDictionary* dic in pasteArray) {
|
|
|
+ if ([dic objectForKey:textType] ||
|
|
|
+ [dic objectForKey:utf8TextType] ||
|
|
|
+ [dic objectForKey:urlType] ||
|
|
|
+ [dic objectForKey:urlFileType]) {
|
|
|
+ NSString *contents = nil;
|
|
|
+ if ([dic objectForKey:textType] ||
|
|
|
+ [dic objectForKey:utf8TextType]) {
|
|
|
+ contents = [UIPasteboard generalPasteboard].string;
|
|
|
+ } else {
|
|
|
+ contents = [[UIPasteboard generalPasteboard].URL absoluteString];
|
|
|
+ }
|
|
|
+ UIFont *font = [UIFont systemFontOfSize:12.0];
|
|
|
+ NSDictionary *attributes = @{NSFontAttributeName : font};
|
|
|
+ CGRect bounds = [contents boundingRectWithSize:CGSizeMake(280, MAXFLOAT)
|
|
|
+ options:(NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading)
|
|
|
+ attributes:attributes
|
|
|
+ context:nil];
|
|
|
+
|
|
|
+ CPDFFreeTextAnnotation *annotation = [[CPDFFreeTextAnnotation alloc] initWithDocument:self.document];
|
|
|
+ [annotation setContents:contents];
|
|
|
+ [annotation setModificationDate:[NSDate date]];
|
|
|
+ [annotation setUserName:[self annotationUserName]];
|
|
|
+ annotation.bounds = CGRectMake(self.menuPoint.x-bounds.size.width/2.0,
|
|
|
+ self.menuPoint.y-bounds.size.height/2.0,
|
|
|
+ bounds.size.width, bounds.size.height);
|
|
|
+ [self.menuPage addAnnotation:annotation];
|
|
|
+ [self setNeedsDisplayForPage:self.menuPage];
|
|
|
+ } else if ([dic objectForKey:jpegImageType] ||
|
|
|
+ [dic objectForKey:pngImageType] ||
|
|
|
+ [dic objectForKey:rawImageType]) {
|
|
|
+ UIImage *image = [UIPasteboard generalPasteboard].image;
|
|
|
+ UIImage *compressImage = [self compressImage:image size:CGSizeMake(240.0, 240.0)];
|
|
|
+
|
|
|
+ CPDFStampAnnotation *annotation = [[CPDFStampAnnotation alloc] initWithDocument:self.document image:compressImage];
|
|
|
+ [annotation setModificationDate:[NSDate date]];
|
|
|
+ [annotation setUserName:[self annotationUserName]];
|
|
|
+ annotation.bounds = CGRectMake(self.menuPoint.x-compressImage.size.width/2.0,
|
|
|
+ self.menuPoint.y-compressImage.size.height/2.0,
|
|
|
+ compressImage.size.width, compressImage.size.height);
|
|
|
+ [self.menuPage addAnnotation:annotation];
|
|
|
+ [self setNeedsDisplayForPage:self.menuPage];
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)menuItemClick_TextNote:(UIMenuItem *)menuItem {
|
|
|
+ if (self.currentSelection) {
|
|
|
+ NSMutableArray *quadrilateralPoints = [NSMutableArray array];
|
|
|
+ CPDFMarkupAnnotation *annotation = [[CPDFMarkupAnnotation alloc] initWithDocument:self.document markupType:CPDFMarkupTypeHighlight];
|
|
|
+ for (CPDFSelection *selection in self.currentSelection.selectionsByLine) {
|
|
|
+ CGRect bounds = selection.bounds;
|
|
|
+ [quadrilateralPoints addObject:[NSValue valueWithCGPoint:CGPointMake(CGRectGetMinX(bounds), CGRectGetMaxY(bounds))]];
|
|
|
+ [quadrilateralPoints addObject:[NSValue valueWithCGPoint:CGPointMake(CGRectGetMaxX(bounds), CGRectGetMaxY(bounds))]];
|
|
|
+ [quadrilateralPoints addObject:[NSValue valueWithCGPoint:CGPointMake(CGRectGetMinX(bounds), CGRectGetMinY(bounds))]];
|
|
|
+ [quadrilateralPoints addObject:[NSValue valueWithCGPoint:CGPointMake(CGRectGetMaxX(bounds), CGRectGetMinY(bounds))]];
|
|
|
+ }
|
|
|
+ [annotation setQuadrilateralPoints:quadrilateralPoints];
|
|
|
+ [annotation setMarkupText:self.currentSelection.string];
|
|
|
+ [annotation setModificationDate:[NSDate date]];
|
|
|
+ [annotation setUserName:[self annotationUserName]];
|
|
|
+ [self.currentSelection.page addAnnotation:annotation];
|
|
|
+ [annotation createPopup];
|
|
|
+
|
|
|
+ [self clearSelection];
|
|
|
+ [self setNeedsDisplayForPage:annotation.page];
|
|
|
+ } else {
|
|
|
+ [self addAnnotation:CPDFViewAnnotationModeNote atPoint:self.menuPoint forPage:self.menuPage];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)menuItemClick_FreeText:(UIMenuItem *)menuItem {
|
|
|
+ [self addAnnotationFreeTextAtPoint:self.menuPoint forPage:self.menuPage];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)menuItemClick_Stamp:(UIMenuItem *)menuItem {
|
|
|
+ if ([self.performDelegate respondsToSelector:@selector(PDFListViewPerformAddStamp:atPoint:forPage:)]) {
|
|
|
+ [self.performDelegate PDFListViewPerformAddStamp:self atPoint:self.menuPoint forPage:self.menuPage];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)menuItemClick_Image:(UIMenuItem *)menuItem {
|
|
|
+ if ([self.performDelegate respondsToSelector:@selector(PDFListViewPerformAddImage:atPoint:forPage:)]) {
|
|
|
+ [self.performDelegate PDFListViewPerformAddImage:self atPoint:self.menuPoint forPage:self.menuPage];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)menuItemClick_Play:(UIMenuItem *)menuItem {
|
|
|
+ if ([self.activeAnnotation isKindOfClass:[CPDFSoundAnnotation class]]) {
|
|
|
+ [self updateActiveAnnotations:@[]];
|
|
|
+ [self setNeedsDisplayForPage:self.menuAnnotation.page];
|
|
|
+ if ([self.performDelegate respondsToSelector:@selector(PDFListViewPerformPlay:forAnnotation:)]) {
|
|
|
+ [self.performDelegate PDFListViewPerformPlay:self forAnnotation:(CPDFSoundAnnotation *)self.activeAnnotation];
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)menuItemClick_MediaDelete:(UIMenuItem *)menuItem {
|
|
|
+ CGPoint point = CGPointMake(CGRectGetMidX(self.mediaSelectionRect), CGRectGetMidY(self.mediaSelectionRect));
|
|
|
+ CPDFPage *page = self.mediaSelectionPage;
|
|
|
+ if ([self.performDelegate respondsToSelector:@selector(PDFListViewPerformCancelMedia:atPoint:forPage:)]) {
|
|
|
+ [self.performDelegate PDFListViewPerformCancelMedia:self atPoint:point forPage:page];
|
|
|
+ }
|
|
|
+
|
|
|
+ self.mediaSelectionPage = nil;
|
|
|
+ [self setNeedsDisplayForPage:page];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)menuItemClick_MediaRecord:(UIMenuItem *)menuItem {
|
|
|
+ CGPoint point = CGPointMake(CGRectGetMidX(self.mediaSelectionRect), CGRectGetMidY(self.mediaSelectionRect));
|
|
|
+ CPDFPage *page = self.mediaSelectionPage;
|
|
|
+ if ([self.performDelegate respondsToSelector:@selector(PDFListViewPerformRecordMedia:atPoint:forPage:)]) {
|
|
|
+ [self.performDelegate PDFListViewPerformRecordMedia:self atPoint:point forPage:page];
|
|
|
+ }
|
|
|
+ self.mediaSelectionPage = nil;
|
|
|
+}
|
|
|
+
|
|
|
#pragma mark - Magnifier
|
|
|
|
|
|
- (void)addMagnifierAtPoint:(CGPoint)point forPage:(CPDFPage *)page {
|
|
@@ -154,6 +337,41 @@
|
|
|
self.magnifierView = nil;
|
|
|
}
|
|
|
|
|
|
+#pragma mark - Menu
|
|
|
+
|
|
|
+- (NSArray<UIMenuItem *> *)annotationMenuItemsAtPoint:(CGPoint)point forPage:(CPDFPage *)page {
|
|
|
+ self.menuPoint = point;
|
|
|
+ self.menuPage = page;
|
|
|
+
|
|
|
+ if(self.currentSelection) {
|
|
|
+ return [super menuItemsAtPoint:point forPage:page];
|
|
|
+ } else {
|
|
|
+ NSMutableArray *menuItems = [NSMutableArray array];
|
|
|
+
|
|
|
+ UIMenuItem *pasteItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"Paste", nil)
|
|
|
+ action:@selector(menuItemClick_Paste:)];
|
|
|
+ if ([self isPasteboardValid]) {
|
|
|
+ [menuItems addObject:pasteItem];
|
|
|
+ }
|
|
|
+ UIMenuItem *textNoteItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"Note", nil)
|
|
|
+ action:@selector(menuItemClick_TextNote:)];
|
|
|
+ UIMenuItem *textItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"Text", nil)
|
|
|
+ action:@selector(menuItemClick_FreeText:)];
|
|
|
+ UIMenuItem *stampItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"Stamp", nil)
|
|
|
+ action:@selector(menuItemClick_Stamp:)];
|
|
|
+ UIMenuItem *imageItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"Image", nil)
|
|
|
+ action:@selector(menuItemClick_Image:)];
|
|
|
+ [menuItems addObject:textNoteItem];
|
|
|
+ [menuItems addObject:textItem];
|
|
|
+ [menuItems addObject:stampItem];
|
|
|
+ [menuItems addObject:imageItem];
|
|
|
+
|
|
|
+ return menuItems;
|
|
|
+ }
|
|
|
+ return nil;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
#pragma mark - Touch
|
|
|
|
|
|
- (void)annotationTouchBeganAtPoint:(CGPoint)point forPage:(CPDFPage *)page {
|
|
@@ -299,6 +517,15 @@
|
|
|
} else {
|
|
|
[self addAnnotationLinkAtPoint:point forPage:page];
|
|
|
}
|
|
|
+ } else if (CPDFViewAnnotationModeSound == self.annotationMode) {
|
|
|
+ BOOL isAudioRecord = NO;
|
|
|
+ if ([self.performDelegate respondsToSelector:@selector(PDFListViewerTouchEndedIsAudioRecordMedia:)]) {
|
|
|
+ isAudioRecord = [self.performDelegate PDFListViewerTouchEndedIsAudioRecordMedia:self];
|
|
|
+ }
|
|
|
+ if (isAudioRecord) {
|
|
|
+ } else {
|
|
|
+ [self addAnnotationMediaAtPoint:point forPage:page];
|
|
|
+ }
|
|
|
} else if (CPDFViewAnnotationModeFreeText == self.annotationMode) {
|
|
|
[self addAnnotationFreeTextAtPoint:point forPage:page];
|
|
|
} else if (CPDFViewAnnotationModeStamp == self.annotationMode) {
|
|
@@ -842,6 +1069,20 @@
|
|
|
[self updateActiveAnnotations:@[]];
|
|
|
}
|
|
|
|
|
|
+- (void)addAnnotationMediaAtPoint:(CGPoint)point forPage:(CPDFPage *)page {
|
|
|
+ if (self.mediaSelectionPage) {
|
|
|
+ CPDFPage *selectionPage = self.mediaSelectionPage;
|
|
|
+ self.mediaSelectionPage = nil;
|
|
|
+ [self setNeedsDisplayForPage:selectionPage];
|
|
|
+ }
|
|
|
+
|
|
|
+ self.mediaSelectionPage = page;
|
|
|
+ self.mediaSelectionRect = CGRectMake(point.x-20, point.y-20, 40, 40);
|
|
|
+ [self setNeedsDisplayForPage:page];
|
|
|
+
|
|
|
+ [self showMenuForMediaAtPoint:point forPage:page];
|
|
|
+}
|
|
|
+
|
|
|
- (void)addAnnotationLinkAtPoint:(CGPoint)point forPage:(CPDFPage *)page {
|
|
|
CPDFLinkAnnotation *annotation = [[CPDFLinkAnnotation alloc] initWithDocument:self.document] ;
|
|
|
annotation.bounds = self.addLinkRect;
|
|
@@ -854,7 +1095,7 @@
|
|
|
[self setNeedsDisplayForPage:page];
|
|
|
|
|
|
if(annotation)
|
|
|
- [self updateActiveAnnotations:annotation];
|
|
|
+ [self updateActiveAnnotations:@[annotation]];
|
|
|
|
|
|
if ([self.performDelegate respondsToSelector:@selector(PDFListViewEditNote:forAnnotation:)]) {
|
|
|
[self.performDelegate PDFListViewEditNote:self forAnnotation:annotation];
|