+2004-12-18 Chris Blumenberg <cblu@apple.com>
+
+ Fixed: <rdar://problem/3766915> PDF content needs search to work
+
+ Reviewed by kevin, john.
+
+ * WebView.subproj/WebPDFView.m:
+ (-[WebPDFView searchFor:direction:caseSensitive:wrap:]): implemented
+ (-[WebPDFView takeFindStringFromSelection:]): new
+ (-[WebPDFView jumpToSelection:]): new
+ (-[WebPDFView validateUserInterfaceItem:]): new
+
2004-12-17 Richard Williamson <rjw@apple.com>
Make image decoding as lazy as possible for non threaded case; in some cases
#import <WebKit/WebAssertions.h>
#import <WebKit/WebDataSource.h>
#import <WebKit/WebLocalizableStrings.h>
+#import <WebKit/WebNSPasteboardExtras.h>
#import <WebKit/WebPDFView.h>
#import <Quartz/Quartz.h>
}
}
-- (BOOL)searchFor: (NSString *)string direction: (BOOL)forward caseSensitive: (BOOL)caseFlag wrap: (BOOL)wrapFlag;
+- (BOOL)searchFor:(NSString *)string direction:(BOOL)forward caseSensitive:(BOOL)caseFlag wrap:(BOOL)wrapFlag;
{
- BOOL lastFindWasSuccessful = NO;
-
- // FIXME: Insert find code here when ready.
-
- return lastFindWasSuccessful;
+ int options = 0;
+ if (!forward) {
+ options |= NSBackwardsSearch;
+ }
+ if (!caseFlag) {
+ options |= NSCaseInsensitiveSearch;
+ }
+ PDFDocument *document = [PDFSubview document];
+ PDFSelection *selection = [document findString:string fromSelection:[PDFSubview currentSelection] withOptions:options];
+ if (selection == nil && wrapFlag) {
+ selection = [document findString:string fromSelection:nil withOptions:options];
+ }
+ if (selection != nil) {
+ [PDFSubview setCurrentSelection:selection];
+ [PDFSubview scrollSelectionToVisible:nil];
+ return YES;
+ }
+ return NO;
}
+- (void)takeFindStringFromSelection:(id)sender
+{
+ [NSPasteboard _web_setFindPasteboardString:[[PDFSubview currentSelection] string] withOwner:self];
+}
+
+- (void)jumpToSelection:(id)sender
+{
+ [PDFSubview scrollSelectionToVisible:nil];
+}
+
+- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item
+{
+ SEL action = [item action];
+ if (action == @selector(takeFindStringFromSelection:) || action == @selector(jumpToSelection:)) {
+ return [PDFSubview currentSelection] != nil;
+ }
+ return YES;
+}
@end