Revision: 4860
          http://skim-app.svn.sourceforge.net/skim-app/?rev=4860&view=rev
Author:   hofman
Date:     2008-10-24 14:41:42 +0000 (Fri, 24 Oct 2008)

Log Message:
-----------
Build textstorage for scriptable text of document from pages instead of 
selection. Always return a rich text object.

Modified Paths:
--------------
    trunk/PDFAnnotationFreeText_SKExtensions.m
    trunk/PDFAnnotation_SKExtensions.m
    trunk/PDFPage_SKExtensions.h
    trunk/PDFPage_SKExtensions.m
    trunk/SKPDFDocument.h
    trunk/SKPDFDocument.m

Modified: trunk/PDFAnnotationFreeText_SKExtensions.m
===================================================================
--- trunk/PDFAnnotationFreeText_SKExtensions.m  2008-10-24 13:15:07 UTC (rev 
4859)
+++ trunk/PDFAnnotationFreeText_SKExtensions.m  2008-10-24 14:41:42 UTC (rev 
4860)
@@ -128,10 +128,10 @@
 }
 
 - (id)textContents {
-    NSTextStorage *textContents = [[[NSTextStorage alloc] initWithString:[self 
string]] autorelease];
+    NSTextStorage *textContents = [super textContents];
     if ([self font])
         [textContents addAttribute:NSFontAttributeName value:[self font] 
range:NSMakeRange(0, [textContents length])];
-    return [self string] ? textContents : (id)[NSNull null];
+    return textContents;
 }
 
 - (NSString *)fontName {

Modified: trunk/PDFAnnotation_SKExtensions.m
===================================================================
--- trunk/PDFAnnotation_SKExtensions.m  2008-10-24 13:15:07 UTC (rev 4859)
+++ trunk/PDFAnnotation_SKExtensions.m  2008-10-24 14:41:42 UTC (rev 4860)
@@ -388,7 +388,7 @@
 
 - (id)textContents;
 {
-    return [self string] ? [[[NSTextStorage alloc] initWithString:[self 
string]] autorelease] : [NSNull null];
+    return [[[NSTextStorage alloc] initWithString:[self string] ?: @""] 
autorelease];
 }
 
 - (void)setTextContents:(id)text;

Modified: trunk/PDFPage_SKExtensions.h
===================================================================
--- trunk/PDFPage_SKExtensions.h        2008-10-24 13:15:07 UTC (rev 4859)
+++ trunk/PDFPage_SKExtensions.h        2008-10-24 14:41:42 UTC (rev 4860)
@@ -85,7 +85,7 @@
 - (NSData *)mediaBoundsAsQDRect;
 - (void)setMediaBoundsAsQDRect:(NSData *)inQDBoundsAsData;
 - (NSData *)contentBoundsAsQDRect;
-- (id)richText;
+- (NSTextStorage *)richText;
 - (NSArray *)notes;
 - (void)insertInNotes:(id)newNote;
 - (void)insertInNotes:(id)newNote atIndex:(unsigned int)index;

Modified: trunk/PDFPage_SKExtensions.m
===================================================================
--- trunk/PDFPage_SKExtensions.m        2008-10-24 13:15:07 UTC (rev 4859)
+++ trunk/PDFPage_SKExtensions.m        2008-10-24 14:41:42 UTC (rev 4860)
@@ -448,9 +448,9 @@
     return [NSData dataWithRectAsQDRect:[self foregroundBox]];
 }
 
-- (id)richText {
+- (NSTextStorage *)richText {
     NSAttributedString *attrString = [self attributedString];
-    return attrString ? [[[NSTextStorage alloc] 
initWithAttributedString:attrString] autorelease] : [NSNull null];
+    return attrString ? [[[NSTextStorage alloc] 
initWithAttributedString:attrString] autorelease] : [[[NSTextStorage alloc] 
init] autorelease];
 }
 
 - (NSArray *)notes {

Modified: trunk/SKPDFDocument.h
===================================================================
--- trunk/SKPDFDocument.h       2008-10-24 13:15:07 UTC (rev 4859)
+++ trunk/SKPDFDocument.h       2008-10-24 14:41:42 UTC (rev 4860)
@@ -140,7 +140,7 @@
 - (void)setCurrentPage:(PDFPage *)page;
 - (id)activeNote;
 - (void)setActiveNote:(id)note;
-- (id)richText;
+- (NSTextStorage *)richText;
 - (id)selectionSpecifier;
 - (void)setSelectionSpecifier:(id)specifier;
 - (NSData *)selectionQDRect;

Modified: trunk/SKPDFDocument.m
===================================================================
--- trunk/SKPDFDocument.m       2008-10-24 13:15:07 UTC (rev 4859)
+++ trunk/SKPDFDocument.m       2008-10-24 14:41:42 UTC (rev 4860)
@@ -1839,9 +1839,18 @@
         [[self pdfView] setActiveAnnotation:note];
 }
 
-- (id)richText {
-    NSAttributedString *attrString = [[[self pdfDocument] 
selectionForEntireDocument] attributedString];
-    return attrString ? [[[NSTextStorage alloc] 
initWithAttributedString:attrString] autorelease] : [NSNull null];
+- (NSTextStorage *)richText {
+    PDFDocument *doc = [self pdfDocument];
+    unsigned int i, count = [doc pageCount];
+    NSTextStorage *textStorage = [[[NSTextStorage alloc] init] autorelease];
+    NSAttributedString *attrString;
+    [textStorage beginEditing];
+    for (i = 0; i < count; i++) {
+        if (attrString = [[doc pageAtIndex:i] attributedString])
+            [textStorage appendAttributedString:attrString];
+    }
+    [textStorage endEditing];
+    return textStorage;
 }
 
 - (id)selectionSpecifier {


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to