diff --git a/ChangeLog b/ChangeLog index db848da20..8d6d2b357 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2007-05-30 Wolfgang Sourdeau + * SoObjects/SOGo/NSArray+Utilities.m ([NSMutableArray + -addRange:newRange]): new method that store a string + representation of the NSRange passed as parameter. + ([NSMutableArray -hasRangeIntersection:testRange]): tests whether + any range contained in self intersect with the one passed as parameter. + * SoObjects/SOGo/NSString+Utilities.m ([-stringByDetectingURLs]): store ranges in an array to prevent them from intersecting with each other during the passes. diff --git a/SoObjects/SOGo/NSArray+Utilities.h b/SoObjects/SOGo/NSArray+Utilities.h index 1f8c1bd29..025b2bcea 100644 --- a/SoObjects/SOGo/NSArray+Utilities.h +++ b/SoObjects/SOGo/NSArray+Utilities.h @@ -45,6 +45,9 @@ - (void) addObjectUniquely: (id) object; +- (void) addRange: (NSRange) newRange; +- (BOOL) hasRangeIntersection: (NSRange) testRange; + @end #endif /* NSARRAY_UTILITIES_H */ diff --git a/SoObjects/SOGo/NSArray+Utilities.m b/SoObjects/SOGo/NSArray+Utilities.m index d30f93ac3..66054efb8 100644 --- a/SoObjects/SOGo/NSArray+Utilities.m +++ b/SoObjects/SOGo/NSArray+Utilities.m @@ -91,5 +91,34 @@ [self addObject: object]; } +- (void) addRange: (NSRange) newRange +{ + [self addObject: NSStringFromRange (newRange)]; +} + +- (BOOL) hasRangeIntersection: (NSRange) testRange +{ + NSEnumerator *ranges; + NSString *currentRangeString; + NSRange currentRange; + BOOL response; + + response = NO; + + ranges = [self objectEnumerator]; + currentRangeString = [ranges nextObject]; + while (!response && currentRangeString) + { + currentRange = NSRangeFromString (currentRangeString); + if (NSLocationInRange (testRange.location, currentRange) + || NSLocationInRange (NSMaxRange (testRange), currentRange)) + response = YES; + else + currentRangeString = [ranges nextObject]; + } + + return response; +} + @end