OLD | NEW |
---|---|
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
108 | 108 |
109 CPDFSDK_DateTime& CPDFSDK_DateTime::operator=( | 109 CPDFSDK_DateTime& CPDFSDK_DateTime::operator=( |
110 const CPDFSDK_DateTime& datetime) { | 110 const CPDFSDK_DateTime& datetime) { |
111 FXSYS_memcpy(&dt, &datetime.dt, sizeof(FX_DATETIME)); | 111 FXSYS_memcpy(&dt, &datetime.dt, sizeof(FX_DATETIME)); |
112 return *this; | 112 return *this; |
113 } | 113 } |
114 | 114 |
115 CPDFSDK_DateTime& CPDFSDK_DateTime::operator=(const FX_SYSTEMTIME& st) { | 115 CPDFSDK_DateTime& CPDFSDK_DateTime::operator=(const FX_SYSTEMTIME& st) { |
116 tzset(); | 116 tzset(); |
117 | 117 |
118 dt.year = (int16_t)st.wYear; | 118 dt.year = static_cast<int16_t>(st.wYear); |
119 dt.month = (uint8_t)st.wMonth; | 119 dt.month = static_cast<uint8_t>(st.wMonth); |
120 dt.day = (uint8_t)st.wDay; | 120 dt.day = static_cast<uint8_t>(st.wDay); |
121 dt.hour = (uint8_t)st.wHour; | 121 dt.hour = static_cast<uint8_t>(st.wHour); |
122 dt.minute = (uint8_t)st.wMinute; | 122 dt.minute = static_cast<uint8_t>(st.wMinute); |
123 dt.second = (uint8_t)st.wSecond; | 123 dt.second = static_cast<uint8_t>(st.wSecond); |
124 return *this; | 124 return *this; |
125 } | 125 } |
126 | 126 |
127 bool CPDFSDK_DateTime::operator==(const CPDFSDK_DateTime& datetime) const { | 127 bool CPDFSDK_DateTime::operator==(const CPDFSDK_DateTime& datetime) const { |
128 return (FXSYS_memcmp(&dt, &datetime.dt, sizeof(FX_DATETIME)) == 0); | 128 return (FXSYS_memcmp(&dt, &datetime.dt, sizeof(FX_DATETIME)) == 0); |
129 } | 129 } |
130 | 130 |
131 bool CPDFSDK_DateTime::operator!=(const CPDFSDK_DateTime& datetime) const { | 131 bool CPDFSDK_DateTime::operator!=(const CPDFSDK_DateTime& datetime) const { |
132 return !(*this == datetime); | 132 return !(*this == datetime); |
133 } | 133 } |
134 | 134 |
135 bool CPDFSDK_DateTime::operator>(const CPDFSDK_DateTime& datetime) const { | 135 time_t CPDFSDK_DateTime::ToTime_t() const { |
136 CPDFSDK_DateTime dt1 = ToGMT(); | |
137 CPDFSDK_DateTime dt2 = datetime.ToGMT(); | |
138 int d1 = | |
139 (((int)dt1.dt.year) << 16) | (((int)dt1.dt.month) << 8) | (int)dt1.dt.day; | |
140 int d2 = (((int)dt1.dt.hour) << 16) | (((int)dt1.dt.minute) << 8) | | |
141 (int)dt1.dt.second; | |
142 int d3 = | |
143 (((int)dt2.dt.year) << 16) | (((int)dt2.dt.month) << 8) | (int)dt2.dt.day; | |
144 int d4 = (((int)dt2.dt.hour) << 16) | (((int)dt2.dt.minute) << 8) | | |
145 (int)dt2.dt.second; | |
146 | |
147 return d1 > d3 || d2 > d4; | |
148 } | |
149 | |
150 bool CPDFSDK_DateTime::operator>=(const CPDFSDK_DateTime& datetime) const { | |
151 CPDFSDK_DateTime dt1 = ToGMT(); | |
152 CPDFSDK_DateTime dt2 = datetime.ToGMT(); | |
153 int d1 = | |
154 (((int)dt1.dt.year) << 16) | (((int)dt1.dt.month) << 8) | (int)dt1.dt.day; | |
155 int d2 = (((int)dt1.dt.hour) << 16) | (((int)dt1.dt.minute) << 8) | | |
156 (int)dt1.dt.second; | |
157 int d3 = | |
158 (((int)dt2.dt.year) << 16) | (((int)dt2.dt.month) << 8) | (int)dt2.dt.day; | |
159 int d4 = (((int)dt2.dt.hour) << 16) | (((int)dt2.dt.minute) << 8) | | |
160 (int)dt2.dt.second; | |
161 | |
162 return d1 >= d3 || d2 >= d4; | |
163 } | |
164 | |
165 bool CPDFSDK_DateTime::operator<(const CPDFSDK_DateTime& datetime) const { | |
166 CPDFSDK_DateTime dt1 = ToGMT(); | |
167 CPDFSDK_DateTime dt2 = datetime.ToGMT(); | |
168 int d1 = | |
169 (((int)dt1.dt.year) << 16) | (((int)dt1.dt.month) << 8) | (int)dt1.dt.day; | |
170 int d2 = (((int)dt1.dt.hour) << 16) | (((int)dt1.dt.minute) << 8) | | |
171 (int)dt1.dt.second; | |
172 int d3 = | |
173 (((int)dt2.dt.year) << 16) | (((int)dt2.dt.month) << 8) | (int)dt2.dt.day; | |
174 int d4 = (((int)dt2.dt.hour) << 16) | (((int)dt2.dt.minute) << 8) | | |
175 (int)dt2.dt.second; | |
176 | |
177 return d1 < d3 || d2 < d4; | |
178 } | |
179 | |
180 bool CPDFSDK_DateTime::operator<=(const CPDFSDK_DateTime& datetime) const { | |
181 CPDFSDK_DateTime dt1 = ToGMT(); | |
182 CPDFSDK_DateTime dt2 = datetime.ToGMT(); | |
183 int d1 = | |
184 (((int)dt1.dt.year) << 16) | (((int)dt1.dt.month) << 8) | (int)dt1.dt.day; | |
185 int d2 = (((int)dt1.dt.hour) << 16) | (((int)dt1.dt.minute) << 8) | | |
186 (int)dt1.dt.second; | |
187 int d3 = | |
188 (((int)dt2.dt.year) << 16) | (((int)dt2.dt.month) << 8) | (int)dt2.dt.day; | |
189 int d4 = (((int)dt2.dt.hour) << 16) | (((int)dt2.dt.minute) << 8) | | |
190 (int)dt2.dt.second; | |
191 | |
192 return d1 <= d3 || d2 <= d4; | |
193 } | |
194 | |
195 CPDFSDK_DateTime::operator time_t() { | |
196 struct tm newtime; | 136 struct tm newtime; |
197 | 137 |
198 newtime.tm_year = dt.year - 1900; | 138 newtime.tm_year = dt.year - 1900; |
199 newtime.tm_mon = dt.month - 1; | 139 newtime.tm_mon = dt.month - 1; |
200 newtime.tm_mday = dt.day; | 140 newtime.tm_mday = dt.day; |
201 newtime.tm_hour = dt.hour; | 141 newtime.tm_hour = dt.hour; |
202 newtime.tm_min = dt.minute; | 142 newtime.tm_min = dt.minute; |
203 newtime.tm_sec = dt.second; | 143 newtime.tm_sec = dt.second; |
204 | 144 |
205 return mktime(&newtime); | 145 return mktime(&newtime); |
206 } | 146 } |
207 | 147 |
208 CPDFSDK_DateTime& CPDFSDK_DateTime::FromPDFDateTimeString( | 148 CPDFSDK_DateTime& CPDFSDK_DateTime::FromPDFDateTimeString( |
209 const CFX_ByteString& dtStr) { | 149 const CFX_ByteString& dtStr) { |
210 int strLength = dtStr.GetLength(); | 150 int strLength = dtStr.GetLength(); |
211 if (strLength > 0) { | 151 if (strLength > 0) { |
dsinclair
2016/06/08 13:15:13
nit: make this an early return?
Wei Li
2016/06/08 16:58:56
Done.
| |
212 int i = 0; | 152 int i = 0; |
213 int j, k; | |
214 FX_CHAR ch; | |
215 while (i < strLength && !std::isdigit(dtStr[i])) | 153 while (i < strLength && !std::isdigit(dtStr[i])) |
216 ++i; | 154 ++i; |
217 | 155 |
218 if (i >= strLength) | 156 if (i >= strLength) |
219 return *this; | 157 return *this; |
220 | 158 |
221 j = 0; | 159 int j = 0; |
222 k = 0; | 160 int k = 0; |
161 FX_CHAR ch; | |
223 while (i < strLength && j < 4) { | 162 while (i < strLength && j < 4) { |
224 ch = dtStr[i]; | 163 ch = dtStr[i]; |
225 k = k * 10 + FXSYS_toDecimalDigit(ch); | 164 k = k * 10 + FXSYS_toDecimalDigit(ch); |
226 j++; | 165 j++; |
227 if (!std::isdigit(ch)) | 166 if (!std::isdigit(ch)) |
228 break; | 167 break; |
229 i++; | 168 i++; |
230 } | 169 } |
231 dt.year = (int16_t)k; | 170 dt.year = static_cast<int16_t>(k); |
232 if (i >= strLength || j < 4) | 171 if (i >= strLength || j < 4) |
233 return *this; | 172 return *this; |
234 | 173 |
235 j = 0; | 174 j = 0; |
236 k = 0; | 175 k = 0; |
237 while (i < strLength && j < 2) { | 176 while (i < strLength && j < 2) { |
238 ch = dtStr[i]; | 177 ch = dtStr[i]; |
239 k = k * 10 + FXSYS_toDecimalDigit(ch); | 178 k = k * 10 + FXSYS_toDecimalDigit(ch); |
240 j++; | 179 j++; |
241 if (!std::isdigit(ch)) | 180 if (!std::isdigit(ch)) |
242 break; | 181 break; |
243 i++; | 182 i++; |
244 } | 183 } |
245 dt.month = (uint8_t)k; | 184 dt.month = static_cast<uint8_t>(k); |
246 if (i >= strLength || j < 2) | 185 if (i >= strLength || j < 2) |
247 return *this; | 186 return *this; |
248 | 187 |
249 j = 0; | 188 j = 0; |
250 k = 0; | 189 k = 0; |
251 while (i < strLength && j < 2) { | 190 while (i < strLength && j < 2) { |
252 ch = dtStr[i]; | 191 ch = dtStr[i]; |
253 k = k * 10 + FXSYS_toDecimalDigit(ch); | 192 k = k * 10 + FXSYS_toDecimalDigit(ch); |
254 j++; | 193 j++; |
255 if (!std::isdigit(ch)) | 194 if (!std::isdigit(ch)) |
256 break; | 195 break; |
257 i++; | 196 i++; |
258 } | 197 } |
259 dt.day = (uint8_t)k; | 198 dt.day = static_cast<uint8_t>(k); |
260 if (i >= strLength || j < 2) | 199 if (i >= strLength || j < 2) |
261 return *this; | 200 return *this; |
262 | 201 |
263 j = 0; | 202 j = 0; |
264 k = 0; | 203 k = 0; |
265 while (i < strLength && j < 2) { | 204 while (i < strLength && j < 2) { |
266 ch = dtStr[i]; | 205 ch = dtStr[i]; |
267 k = k * 10 + FXSYS_toDecimalDigit(ch); | 206 k = k * 10 + FXSYS_toDecimalDigit(ch); |
268 j++; | 207 j++; |
269 if (!std::isdigit(ch)) | 208 if (!std::isdigit(ch)) |
270 break; | 209 break; |
271 i++; | 210 i++; |
272 } | 211 } |
273 dt.hour = (uint8_t)k; | 212 dt.hour = static_cast<uint8_t>(k); |
274 if (i >= strLength || j < 2) | 213 if (i >= strLength || j < 2) |
275 return *this; | 214 return *this; |
276 | 215 |
277 j = 0; | 216 j = 0; |
278 k = 0; | 217 k = 0; |
279 while (i < strLength && j < 2) { | 218 while (i < strLength && j < 2) { |
280 ch = dtStr[i]; | 219 ch = dtStr[i]; |
281 k = k * 10 + FXSYS_toDecimalDigit(ch); | 220 k = k * 10 + FXSYS_toDecimalDigit(ch); |
282 j++; | 221 j++; |
283 if (!std::isdigit(ch)) | 222 if (!std::isdigit(ch)) |
284 break; | 223 break; |
285 i++; | 224 i++; |
286 } | 225 } |
287 dt.minute = (uint8_t)k; | 226 dt.minute = static_cast<uint8_t>(k); |
288 if (i >= strLength || j < 2) | 227 if (i >= strLength || j < 2) |
289 return *this; | 228 return *this; |
290 | 229 |
291 j = 0; | 230 j = 0; |
292 k = 0; | 231 k = 0; |
293 while (i < strLength && j < 2) { | 232 while (i < strLength && j < 2) { |
294 ch = dtStr[i]; | 233 ch = dtStr[i]; |
295 k = k * 10 + FXSYS_toDecimalDigit(ch); | 234 k = k * 10 + FXSYS_toDecimalDigit(ch); |
296 j++; | 235 j++; |
297 if (!std::isdigit(ch)) | 236 if (!std::isdigit(ch)) |
298 break; | 237 break; |
299 i++; | 238 i++; |
300 } | 239 } |
301 dt.second = (uint8_t)k; | 240 dt.second = static_cast<uint8_t>(k); |
302 if (i >= strLength || j < 2) | 241 if (i >= strLength || j < 2) |
303 return *this; | 242 return *this; |
304 | 243 |
305 ch = dtStr[i++]; | 244 ch = dtStr[i++]; |
306 if (ch != '-' && ch != '+') | 245 if (ch != '-' && ch != '+') |
307 return *this; | 246 return *this; |
308 if (ch == '-') | 247 if (ch == '-') |
309 dt.tzHour = -1; | 248 dt.tzHour = -1; |
310 else | 249 else |
311 dt.tzHour = 1; | 250 dt.tzHour = 1; |
312 j = 0; | 251 j = 0; |
313 k = 0; | 252 k = 0; |
314 while (i < strLength && j < 2) { | 253 while (i < strLength && j < 2) { |
315 ch = dtStr[i]; | 254 ch = dtStr[i]; |
316 k = k * 10 + FXSYS_toDecimalDigit(ch); | 255 k = k * 10 + FXSYS_toDecimalDigit(ch); |
317 j++; | 256 j++; |
318 if (!std::isdigit(ch)) | 257 if (!std::isdigit(ch)) |
319 break; | 258 break; |
320 i++; | 259 i++; |
321 } | 260 } |
322 dt.tzHour *= (FX_CHAR)k; | 261 dt.tzHour *= static_cast<int8_t>(k); |
323 if (i >= strLength || j < 2) | 262 if (i >= strLength || j < 2) |
324 return *this; | 263 return *this; |
325 | 264 |
326 ch = dtStr[i++]; | 265 if (dtStr[i++] != '\'') |
327 if (ch != '\'') | |
328 return *this; | 266 return *this; |
329 j = 0; | 267 j = 0; |
330 k = 0; | 268 k = 0; |
331 while (i < strLength && j < 2) { | 269 while (i < strLength && j < 2) { |
332 ch = dtStr[i]; | 270 ch = dtStr[i]; |
333 k = k * 10 + FXSYS_toDecimalDigit(ch); | 271 k = k * 10 + FXSYS_toDecimalDigit(ch); |
334 j++; | 272 j++; |
335 if (!std::isdigit(ch)) | 273 if (!std::isdigit(ch)) |
336 break; | 274 break; |
337 i++; | 275 i++; |
338 } | 276 } |
339 dt.tzMinute = (uint8_t)k; | 277 dt.tzMinute = static_cast<uint8_t>(k); |
340 if (i >= strLength || j < 2) | 278 if (i >= strLength || j < 2) |
341 return *this; | 279 return *this; |
342 } | 280 } |
343 | 281 |
344 return *this; | 282 return *this; |
345 } | 283 } |
346 | 284 |
347 CFX_ByteString CPDFSDK_DateTime::ToCommonDateTimeString() { | 285 CFX_ByteString CPDFSDK_DateTime::ToCommonDateTimeString() { |
348 CFX_ByteString str1; | 286 CFX_ByteString str1; |
349 str1.Format("%04d-%02u-%02u %02u:%02u:%02u ", dt.year, dt.month, dt.day, | 287 str1.Format("%04d-%02u-%02u %02u:%02u:%02u ", dt.year, dt.month, dt.day, |
(...skipping 19 matching lines...) Expand all Loading... | |
369 else | 307 else |
370 dtStr += CFX_ByteString("+"); | 308 dtStr += CFX_ByteString("+"); |
371 memset(tempStr, 0, sizeof(tempStr)); | 309 memset(tempStr, 0, sizeof(tempStr)); |
372 FXSYS_snprintf(tempStr, sizeof(tempStr) - 1, "%02d'%02u'", abs(dt.tzHour), | 310 FXSYS_snprintf(tempStr, sizeof(tempStr) - 1, "%02d'%02u'", abs(dt.tzHour), |
373 dt.tzMinute); | 311 dt.tzMinute); |
374 dtStr += CFX_ByteString(tempStr); | 312 dtStr += CFX_ByteString(tempStr); |
375 return dtStr; | 313 return dtStr; |
376 } | 314 } |
377 | 315 |
378 void CPDFSDK_DateTime::ToSystemTime(FX_SYSTEMTIME& st) { | 316 void CPDFSDK_DateTime::ToSystemTime(FX_SYSTEMTIME& st) { |
379 time_t t = (time_t)(*this); | 317 time_t t = this->ToTime_t(); |
380 struct tm* pTime = localtime(&t); | 318 struct tm* pTime = localtime(&t); |
381 if (pTime) { | 319 if (pTime) { |
382 st.wYear = (uint16_t)pTime->tm_year + 1900; | 320 st.wYear = static_cast<uint16_t>(pTime->tm_year) + 1900; |
383 st.wMonth = (uint16_t)pTime->tm_mon + 1; | 321 st.wMonth = static_cast<uint16_t>(pTime->tm_mon) + 1; |
384 st.wDay = (uint16_t)pTime->tm_mday; | 322 st.wDay = static_cast<uint16_t>(pTime->tm_mday); |
385 st.wDayOfWeek = (uint16_t)pTime->tm_wday; | 323 st.wDayOfWeek = static_cast<uint16_t>(pTime->tm_wday); |
386 st.wHour = (uint16_t)pTime->tm_hour; | 324 st.wHour = static_cast<uint16_t>(pTime->tm_hour); |
387 st.wMinute = (uint16_t)pTime->tm_min; | 325 st.wMinute = static_cast<uint16_t>(pTime->tm_min); |
388 st.wSecond = (uint16_t)pTime->tm_sec; | 326 st.wSecond = static_cast<uint16_t>(pTime->tm_sec); |
389 st.wMilliseconds = 0; | 327 st.wMilliseconds = 0; |
390 } | 328 } |
391 } | 329 } |
392 | 330 |
393 CPDFSDK_DateTime CPDFSDK_DateTime::ToGMT() const { | 331 CPDFSDK_DateTime CPDFSDK_DateTime::ToGMT() const { |
394 CPDFSDK_DateTime new_dt = *this; | 332 CPDFSDK_DateTime new_dt = *this; |
395 new_dt.AddSeconds( | 333 new_dt.AddSeconds( |
396 -gAfxGetTimeZoneInSeconds(new_dt.dt.tzHour, new_dt.dt.tzMinute)); | 334 -gAfxGetTimeZoneInSeconds(new_dt.dt.tzHour, new_dt.dt.tzMinute)); |
397 new_dt.dt.tzHour = 0; | 335 new_dt.dt.tzHour = 0; |
398 new_dt.dt.tzMinute = 0; | 336 new_dt.dt.tzMinute = 0; |
399 return new_dt; | 337 return new_dt; |
400 } | 338 } |
401 | 339 |
402 CPDFSDK_DateTime& CPDFSDK_DateTime::AddDays(short days) { | 340 CPDFSDK_DateTime& CPDFSDK_DateTime::AddDays(short days) { |
403 if (days == 0) | 341 if (days == 0) |
404 return *this; | 342 return *this; |
405 | 343 |
406 int16_t y = dt.year, yy; | 344 int16_t y = dt.year; |
407 uint8_t m = dt.month; | 345 uint8_t m = dt.month; |
408 uint8_t d = dt.day; | 346 uint8_t d = dt.day; |
409 int mdays, ydays, ldays; | |
410 | 347 |
411 ldays = days; | 348 int ldays = days; |
412 if (ldays > 0) { | 349 if (ldays > 0) { |
413 yy = y; | 350 int16_t yy = y; |
414 if (((uint16_t)m * 100 + d) > 300) | 351 if ((static_cast<uint16_t>(m) * 100 + d) > 300) |
415 yy++; | 352 yy++; |
416 ydays = gAfxGetYearDays(yy); | 353 int ydays = gAfxGetYearDays(yy); |
354 int mdays; | |
417 while (ldays >= ydays) { | 355 while (ldays >= ydays) { |
418 y++; | 356 y++; |
419 ldays -= ydays; | 357 ldays -= ydays; |
420 yy++; | 358 yy++; |
421 mdays = gAfxGetMonthDays(y, m); | 359 mdays = gAfxGetMonthDays(y, m); |
422 if (d > mdays) { | 360 if (d > mdays) { |
423 m++; | 361 m++; |
424 d -= mdays; | 362 d -= mdays; |
425 } | 363 } |
426 ydays = gAfxGetYearDays(yy); | 364 ydays = gAfxGetYearDays(yy); |
427 } | 365 } |
428 mdays = gAfxGetMonthDays(y, m) - d + 1; | 366 mdays = gAfxGetMonthDays(y, m) - d + 1; |
429 while (ldays >= mdays) { | 367 while (ldays >= mdays) { |
430 ldays -= mdays; | 368 ldays -= mdays; |
431 m++; | 369 m++; |
432 d = 1; | 370 d = 1; |
433 mdays = gAfxGetMonthDays(y, m); | 371 mdays = gAfxGetMonthDays(y, m); |
434 } | 372 } |
435 d += ldays; | 373 d += ldays; |
436 } else { | 374 } else { |
437 ldays *= -1; | 375 ldays *= -1; |
438 yy = y; | 376 int16_t yy = y; |
439 if (((uint16_t)m * 100 + d) < 300) | 377 if ((static_cast<uint16_t>(m) * 100 + d) < 300) |
440 yy--; | 378 yy--; |
441 ydays = gAfxGetYearDays(yy); | 379 int ydays = gAfxGetYearDays(yy); |
442 while (ldays >= ydays) { | 380 while (ldays >= ydays) { |
443 y--; | 381 y--; |
444 ldays -= ydays; | 382 ldays -= ydays; |
445 yy--; | 383 yy--; |
446 mdays = gAfxGetMonthDays(y, m); | 384 int mdays = gAfxGetMonthDays(y, m); |
447 if (d > mdays) { | 385 if (d > mdays) { |
448 m++; | 386 m++; |
449 d -= mdays; | 387 d -= mdays; |
450 } | 388 } |
451 ydays = gAfxGetYearDays(yy); | 389 ydays = gAfxGetYearDays(yy); |
452 } | 390 } |
453 while (ldays >= d) { | 391 while (ldays >= d) { |
454 ldays -= d; | 392 ldays -= d; |
455 m--; | 393 m--; |
456 mdays = gAfxGetMonthDays(y, m); | 394 d = gAfxGetMonthDays(y, m); |
457 d = mdays; | |
458 } | 395 } |
459 d -= ldays; | 396 d -= ldays; |
460 } | 397 } |
461 | 398 |
462 dt.year = y; | 399 dt.year = y; |
463 dt.month = m; | 400 dt.month = m; |
464 dt.day = d; | 401 dt.day = d; |
465 | 402 |
466 return *this; | 403 return *this; |
467 } | 404 } |
468 | 405 |
469 CPDFSDK_DateTime& CPDFSDK_DateTime::AddSeconds(int seconds) { | 406 CPDFSDK_DateTime& CPDFSDK_DateTime::AddSeconds(int seconds) { |
470 if (seconds == 0) | 407 if (seconds == 0) |
471 return *this; | 408 return *this; |
472 | 409 |
473 int n; | 410 int n; |
474 int days; | 411 int days; |
475 | 412 |
476 n = dt.hour * 3600 + dt.minute * 60 + dt.second + seconds; | 413 n = dt.hour * 3600 + dt.minute * 60 + dt.second + seconds; |
477 if (n < 0) { | 414 if (n < 0) { |
478 days = (n - 86399) / 86400; | 415 days = (n - 86399) / 86400; |
479 n -= days * 86400; | 416 n -= days * 86400; |
480 } else { | 417 } else { |
481 days = n / 86400; | 418 days = n / 86400; |
482 n %= 86400; | 419 n %= 86400; |
483 } | 420 } |
484 dt.hour = (uint8_t)(n / 3600); | 421 dt.hour = static_cast<uint8_t>(n / 3600); |
485 dt.hour %= 24; | 422 dt.hour %= 24; |
486 n %= 3600; | 423 n %= 3600; |
487 dt.minute = (uint8_t)(n / 60); | 424 dt.minute = static_cast<uint8_t>(n / 60); |
488 dt.second = (uint8_t)(n % 60); | 425 dt.second = static_cast<uint8_t>(n % 60); |
489 if (days != 0) | 426 if (days != 0) |
490 AddDays(days); | 427 AddDays(days); |
491 | 428 |
492 return *this; | 429 return *this; |
493 } | 430 } |
494 | 431 |
495 CPDFSDK_Annot::CPDFSDK_Annot(CPDFSDK_PageView* pPageView) | 432 CPDFSDK_Annot::CPDFSDK_Annot(CPDFSDK_PageView* pPageView) |
496 : m_pPageView(pPageView), m_bSelected(FALSE), m_nTabOrder(-1) {} | 433 : m_pPageView(pPageView), m_bSelected(FALSE), m_nTabOrder(-1) {} |
497 | 434 |
498 CPDFSDK_BAAnnot::CPDFSDK_BAAnnot(CPDF_Annot* pAnnot, | 435 CPDFSDK_BAAnnot::CPDFSDK_BAAnnot(CPDF_Annot* pAnnot, |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
927 | 864 |
928 CPDF_Page* CPDFSDK_Annot::GetPDFPage() { | 865 CPDF_Page* CPDFSDK_Annot::GetPDFPage() { |
929 return m_pPageView ? m_pPageView->GetPDFPage() : nullptr; | 866 return m_pPageView ? m_pPageView->GetPDFPage() : nullptr; |
930 } | 867 } |
931 | 868 |
932 #ifdef PDF_ENABLE_XFA | 869 #ifdef PDF_ENABLE_XFA |
933 CPDFXFA_Page* CPDFSDK_Annot::GetPDFXFAPage() { | 870 CPDFXFA_Page* CPDFSDK_Annot::GetPDFXFAPage() { |
934 return m_pPageView ? m_pPageView->GetPDFXFAPage() : nullptr; | 871 return m_pPageView ? m_pPageView->GetPDFXFAPage() : nullptr; |
935 } | 872 } |
936 #endif // PDF_ENABLE_XFA | 873 #endif // PDF_ENABLE_XFA |
OLD | NEW |