int CInterval:: valueInterval(double r) const { double increment = calcIncrement(); if (increment <= 0.0) return 0; double start = valueStart(); double ii = 1.0/increment; int interval = int((r - start)*ii); return interval; }
void CInterval:: intervalValues(int i, double &min, double &max) const { double start = valueStart(); double increment = calcIncrement(); if (increment > 0.0) { min = start + i*increment; max = min + increment; } else { min = start; max = min; } }
/* * get "charset" information from clipboard data * return value can be: * 1. "UTF-16": mozilla or "text/html" with "charset=utf-16" * 2. "UNKNOWN": mozilla can't detect what encode it use * 3. other: "text/html" with other charset than utf-16 */ void GetHTMLCharset(guchar * data, PRInt32 dataLength, nsCString& str) { // if detect "FFFE" or "FEFF", assume UTF-16 PRUnichar* beginChar = (PRUnichar*)data; if ((beginChar[0] == 0xFFFE) || (beginChar[0] == 0xFEFF)) { str.AssignLiteral("UTF-16"); return; } // no "FFFE" and "FEFF", assume ASCII first to find "charset" info const nsDependentCString htmlStr((const char *)data, dataLength); nsACString::const_iterator start, end; htmlStr.BeginReading(start); htmlStr.EndReading(end); nsACString::const_iterator valueStart(start), valueEnd(start); if (CaseInsensitiveFindInReadable( NS_LITERAL_CSTRING("CONTENT=\"text/html;"), start, end)) { start = end; htmlStr.EndReading(end); if (CaseInsensitiveFindInReadable( NS_LITERAL_CSTRING("charset="), start, end)) { valueStart = end; start = end; htmlStr.EndReading(end); if (FindCharInReadable('"', start, end)) valueEnd = start; } } // find "charset" in HTML if (valueStart != valueEnd) { str = Substring(valueStart, valueEnd); ToUpperCase(str); #ifdef DEBUG_CLIPBOARD printf("Charset of HTML = %s\n", charsetUpperStr.get()); #endif return; } str.AssignLiteral("UNKNOWN"); }
double CInterval:: interval(int i) const { if (isDate()) { if (timeType_ == TimeType::YEARS) { return yearsToTime(startTime_.year + i*calcIncrement()); } else if (timeType_ == TimeType::MONTHS) { return monthsToTime(startTime_, startTime_.month + i*calcIncrement()); } else if (timeType_ == TimeType::DAYS) { return daysToTime(startTime_, startTime_.day + i*calcIncrement()); } else { return 0; } } else if (isTime()) { if (timeType_ == TimeType::HOURS) { return hoursToTime(startTime_, startTime_.hour + i*calcIncrement()); } else if (timeType_ == TimeType::MINUTES) { return minutesToTime(startTime_, startTime_.minute + i*calcIncrement()); } else if (timeType_ == TimeType::SECONDS) { return secondsToTime(startTime_, startTime_.second + i*calcIncrement()); } else { return 0; } } else { return valueStart() + i*calcIncrement(); } }