From abf46473c29e1c4ed858b187126092a24a1695ff Mon Sep 17 00:00:00 2001 From: znek Date: Wed, 2 Mar 2005 15:11:21 +0000 Subject: [PATCH] various bugfixes and optimizations git-svn-id: http://svn.opengroupware.org/SOPE/trunk@608 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- sope-ical/NGiCal/ChangeLog | 6 +++ sope-ical/NGiCal/NGiCal.xcode/project.pbxproj | 4 +- sope-ical/NGiCal/Version | 2 +- sope-ical/NGiCal/iCalRecurrenceCalculator.m | 54 ++++++++++++++----- 4 files changed, 51 insertions(+), 15 deletions(-) diff --git a/sope-ical/NGiCal/ChangeLog b/sope-ical/NGiCal/ChangeLog index 7409c5ec..f2ca3804 100644 --- a/sope-ical/NGiCal/ChangeLog +++ b/sope-ical/NGiCal/ChangeLog @@ -1,3 +1,9 @@ +2005-03-02 Marcus Mueller + + * iCalRecurrenceCalculator.m: optimized exception date handling in + complex calculation method quite a bit. Fixed bugs in all calculation + methods by introducing checks on the desired range. (v4.5.48) + 2005-02-28 Marcus Mueller * v4.5.47 diff --git a/sope-ical/NGiCal/NGiCal.xcode/project.pbxproj b/sope-ical/NGiCal/NGiCal.xcode/project.pbxproj index 7bedbf0d..dda6ae5a 100644 --- a/sope-ical/NGiCal/NGiCal.xcode/project.pbxproj +++ b/sope-ical/NGiCal/NGiCal.xcode/project.pbxproj @@ -173,7 +173,7 @@ ); buildSettings = { DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 4.5.47; + DYLIB_CURRENT_VERSION = 4.5.48; FRAMEWORK_SEARCH_PATHS = "\"$(USER_LIBRARY_DIR)/EmbeddedFrameworks\""; FRAMEWORK_VERSION = A; GCC_PRECOMPILE_PREFIX_HEADER = NO; @@ -587,7 +587,7 @@ ); buildSettings = { DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 4.5.47; + DYLIB_CURRENT_VERSION = 4.5.48; FRAMEWORK_SEARCH_PATHS = "$(LOCAL_LIBRARY_DIR)/Frameworks"; FRAMEWORK_VERSION = A; GCC_PRECOMPILE_PREFIX_HEADER = YES; diff --git a/sope-ical/NGiCal/Version b/sope-ical/NGiCal/Version index e3250f18..aa4b2707 100644 --- a/sope-ical/NGiCal/Version +++ b/sope-ical/NGiCal/Version @@ -2,7 +2,7 @@ MAJOR_VERSION=4 MINOR_VERSION=5 -SUBMINOR_VERSION:=47 +SUBMINOR_VERSION:=48 # v4.5.40 requires NGExtensions v4.5.145 # v4.5.37 requires NGExtensions v4.5.140 diff --git a/sope-ical/NGiCal/iCalRecurrenceCalculator.m b/sope-ical/NGiCal/iCalRecurrenceCalculator.m index d51e845a..797037e1 100644 --- a/sope-ical/NGiCal/iCalRecurrenceCalculator.m +++ b/sope-ical/NGiCal/iCalRecurrenceCalculator.m @@ -103,6 +103,7 @@ static Class yearlyCalcClass = Nil; id rule; iCalRecurrenceCalculator *calc; NSMutableArray *ranges; + NSMutableArray *exDates; unsigned i, count, rCount; ranges = [NSMutableArray array]; @@ -141,22 +142,46 @@ static Class yearlyCalcClass = Nil; if (![ranges count]) return nil; - /* exception dates are also possible */ - rCount = [ranges count]; + /* exception dates */ + count = [_exDates count]; + if (!count) return ranges; + + /* sort out exDates not within range */ + + exDates = [NSMutableArray arrayWithCapacity:count]; for (i = 0; i < count; i++) { - id exDate; - NGCalendarDateRange *r; - unsigned k; + id exDate; exDate = [_exDates objectAtIndex:i]; if (![exDate isKindOfClass:NSCalendarDateClass]) { exDate = [NSCalendarDate calendarDateWithICalRepresentation:exDate]; } + if ([_r containsDate:exDate]) + [exDates addObject:exDate]; + } + + /* remove matching exDates from ranges */ + + count = [exDates count]; + if (!count) return ranges; + + rCount = [ranges count]; + for (i = 0; i < count; i++) { + NSCalendarDate *exDate; + NGCalendarDateRange *r; + unsigned k; + + exDate = [exDates objectAtIndex:i]; for (k = 0; k < rCount; k++) { - r = [ranges objectAtIndex:(rCount - k) - 1]; + unsigned rIdx; + + rIdx = (rCount - k) - 1; + r = [ranges objectAtIndex:rIdx]; if ([r containsDate:exDate]) { - [ranges removeObjectAtIndex:k]; + [ranges removeObjectAtIndex:rIdx]; + rCount--; + break; /* this is safe because we know that ranges don't overlap */ } } } @@ -340,7 +365,8 @@ static Class yearlyCalcClass = Nil; end = [start addTimeInterval:[self->firstRange duration]]; r = [NGCalendarDateRange calendarDateRangeWithStartDate:start endDate:end]; - [ranges addObject:r]; + if ([_r containsDateRange:r]) + [ranges addObject:r]; } } } @@ -437,7 +463,8 @@ static Class yearlyCalcClass = Nil; end = [start addTimeInterval:[self->firstRange duration]]; r = [NGCalendarDateRange calendarDateRangeWithStartDate:start endDate:end]; - [ranges addObject:r]; + if ([_r containsDateRange:r]) + [ranges addObject:r]; } } } @@ -485,7 +512,8 @@ static Class yearlyCalcClass = Nil; end = [start addTimeInterval:[self->firstRange duration]]; r = [NGCalendarDateRange calendarDateRangeWithStartDate:start endDate:end]; - [ranges addObject:r]; + if ([_r containsDateRange:r]) + [ranges addObject:r]; } } } @@ -553,7 +581,8 @@ static Class yearlyCalcClass = Nil; end = [start addTimeInterval:[self->firstRange duration]]; r = [NGCalendarDateRange calendarDateRangeWithStartDate:start endDate:end]; - [ranges addObject:r]; + if ([_r containsDateRange:r]) + [ranges addObject:r]; } } return ranges; @@ -614,7 +643,8 @@ static Class yearlyCalcClass = Nil; end = [start addTimeInterval:[self->firstRange duration]]; r = [NGCalendarDateRange calendarDateRangeWithStartDate:start endDate:end]; - [ranges addObject:r]; + if ([_r containsDateRange:r]) + [ranges addObject:r]; } } return ranges; -- 2.39.5