[sword-svn] r2626 - trunk/bindings/objc/src

mdbergmann at crosswire.org mdbergmann at crosswire.org
Fri Jun 10 01:02:20 MST 2011


Author: mdbergmann
Date: 2011-06-10 01:02:20 -0700 (Fri, 10 Jun 2011)
New Revision: 2626

Modified:
   trunk/bindings/objc/src/SwordBible.h
   trunk/bindings/objc/src/SwordBible.mm
   trunk/bindings/objc/src/SwordModule.h
   trunk/bindings/objc/src/SwordModule.mm
Log:
added option to retrieve texts for link data as rendered or stripped.

Modified: trunk/bindings/objc/src/SwordBible.h
===================================================================
--- trunk/bindings/objc/src/SwordBible.h	2011-05-07 22:26:51 UTC (rev 2625)
+++ trunk/bindings/objc/src/SwordBible.h	2011-06-10 08:02:20 UTC (rev 2626)
@@ -60,5 +60,10 @@
 - (SwordBibleTextEntry *)textEntryForKey:(SwordKey *)aKey textType:(TextPullType)aType;
 - (NSArray *)strippedTextEntriesForRef:(NSString *)reference context:(int)context;
 - (NSArray *)renderedTextEntriesForRef:(NSString *)reference context:(int)context;
+/**
+ Override from super class
+ @return Array of SwordBibleTextEntry
+ */
+- (NSArray *)textEntriesForReference:(NSString *)aReference textType:(TextPullType)textType;
 
 @end
\ No newline at end of file

Modified: trunk/bindings/objc/src/SwordBible.mm
===================================================================
--- trunk/bindings/objc/src/SwordBible.mm	2011-05-07 22:26:51 UTC (rev 2625)
+++ trunk/bindings/objc/src/SwordBible.mm	2011-06-10 08:02:20 UTC (rev 2626)
@@ -434,6 +434,10 @@
     return [self textEntriesForReference:reference context:context textType:TextTypeRendered];
 }
 
+- (NSArray *)textEntriesForReference:(NSString *)aReference textType:(TextPullType)textType {
+    return [self textEntriesForReference:aReference context:0 textType:textType];
+}
+
 - (NSArray *)textEntriesForReference:(NSString *)aReference context:(int)context textType:(TextPullType)textType {
     NSMutableArray *ret = [NSMutableArray array];
     

Modified: trunk/bindings/objc/src/SwordModule.h
===================================================================
--- trunk/bindings/objc/src/SwordModule.h	2011-05-07 22:26:51 UTC (rev 2625)
+++ trunk/bindings/objc/src/SwordModule.h	2011-06-10 08:02:20 UTC (rev 2626)
@@ -287,6 +287,7 @@
  @return NSString for text data
  */
 - (id)attributeValueForParsedLinkData:(NSDictionary *)data;
+- (id)attributeValueForParsedLinkData:(NSDictionary *)data withTextRenderType:(TextPullType)textType;
 
 /** returns the pre-verse entry value */
 - (NSString *)entryAttributeValuePreverse;
@@ -308,6 +309,11 @@
  Convenience method with a key-string
  */
 - (SwordModuleTextEntry *)textEntryForKeyString:(NSString *)aKeyString textType:(TextPullType)aType;
+/**
+ Pulls all text entries for the given reference
+ @return Array of SwordModuleTextEntry
+ */
+- (NSArray *)textEntriesForReference:(NSString *)aReference textType:(TextPullType)textType;
 
 /**
  Returns a rendered text for the text at the current module position

Modified: trunk/bindings/objc/src/SwordModule.mm
===================================================================
--- trunk/bindings/objc/src/SwordModule.mm	2011-05-07 22:26:51 UTC (rev 2625)
+++ trunk/bindings/objc/src/SwordModule.mm	2011-06-10 08:02:20 UTC (rev 2626)
@@ -492,6 +492,10 @@
 #pragma mark - Module metadata processing
 
 - (id)attributeValueForParsedLinkData:(NSDictionary *)data {
+    return [self attributeValueForParsedLinkData:data withTextRenderType:TextTypeStripped];
+}
+
+- (id)attributeValueForParsedLinkData:(NSDictionary *)data withTextRenderType:(TextPullType)textType {
     id ret = nil;
     
     NSString *passage = [data objectForKey:ATTRTYPE_PASSAGE];
@@ -503,16 +507,28 @@
         NSString *footnoteText = [self entryAttributeValueFootnoteOfType:attrType 
                                                               indexValue:[data objectForKey:ATTRTYPE_VALUE] 
                                                                   forKey:[SwordKey swordKeyWithRef:passage]];
-        ret = [self strippedTextFromString:footnoteText];
+        if(textType == TextTypeRendered) {
+            ret = [self renderedTextEntriesForRef:footnoteText];
+        } else {
+            ret = [self strippedTextEntriesForRef:footnoteText];            
+        }
     } else if([attrType isEqualToString:@"x"]) {
         NSString *refListString = [self entryAttributeValueFootnoteOfType:attrType
                                                                indexValue:[data objectForKey:ATTRTYPE_VALUE] 
                                                                    forKey:[SwordKey swordKeyWithRef:passage]];
-        ret = [self strippedTextEntriesForRef:refListString];
+        if(textType == TextTypeRendered) {
+            ret = [self renderedTextEntriesForRef:refListString];
+        } else {
+            ret = [self strippedTextEntriesForRef:refListString];
+        }
     } else if([attrType isEqualToString:@"scriptRef"] || [attrType isEqualToString:@"scripRef"]) {
         NSString *key = [[[data objectForKey:ATTRTYPE_VALUE] stringByReplacingOccurrencesOfString:@"+" 
                                                                                        withString:@" "] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
-        ret = [self strippedTextEntriesForRef:key];
+        if(textType == TextTypeRendered) {
+            ret = [self renderedTextEntriesForRef:key];
+        } else {
+            ret = [self strippedTextEntriesForRef:key];
+        }
     }
     
     return ret;
@@ -633,27 +649,11 @@
 }
 
 - (NSArray *)strippedTextEntriesForRef:(NSString *)reference {
-    NSArray *ret = nil;
-    
-    SwordModuleTextEntry *entry = [self textEntryForKey:[SwordKey swordKeyWithRef:reference] 
-                                               textType:TextTypeStripped];
-    if(entry) {
-        ret = [NSArray arrayWithObject:entry];
-    }
-    
-    return ret;    
+    return [self textEntriesForReference:reference textType:TextTypeStripped];
 }
 
 - (NSArray *)renderedTextEntriesForRef:(NSString *)reference {
-    NSArray *ret = nil;
-    
-    SwordModuleTextEntry *entry = [self textEntryForKey:[SwordKey swordKeyWithRef:reference] 
-                                               textType:TextTypeRendered];
-    if(entry) {
-        ret = [NSArray arrayWithObject:entry];
-    }
-    
-    return ret;
+    return [self textEntriesForReference:reference textType:TextTypeRendered];
 }
 
 - (SwordModuleTextEntry *)textEntryForKey:(SwordKey *)aKey textType:(TextPullType)aType {
@@ -686,6 +686,17 @@
     return [self textEntryForKey:[SwordKey swordKeyWithRef:aKeyString] textType:aType];
 }
 
+- (NSArray *)textEntriesForReference:(NSString *)aReference textType:(TextPullType)textType {
+    NSArray *ret = nil;
+    
+    SwordModuleTextEntry *entry = [self textEntryForKey:[SwordKey swordKeyWithRef:aReference] 
+                                               textType:textType];
+    if(entry) {
+        ret = [NSArray arrayWithObject:entry];
+    }
+    
+    return ret;    
+}
 
 - (void)writeEntry:(SwordModuleTextEntry *)anEntry {}
 




More information about the sword-cvs mailing list