| 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 "../../core/include/fxcrt/fx_ext.h" |
| 7 #include "../include/fsdk_define.h" | 8 #include "../include/fsdk_define.h" |
| 8 #include "../include/fsdk_mgr.h" | 9 #include "../include/fsdk_mgr.h" |
| 9 #include "../include/fsdk_baseannot.h" | 10 #include "../include/fsdk_baseannot.h" |
| 10 | 11 |
| 11 int _gAfxGetTimeZoneInSeconds(FX_CHAR tzhour, uint8_t tzminute) { | 12 int _gAfxGetTimeZoneInSeconds(FX_CHAR tzhour, uint8_t tzminute) { |
| 12 return (int)tzhour * 3600 + (int)tzminute * (tzhour >= 0 ? 60 : -60); | 13 return (int)tzhour * 3600 + (int)tzminute * (tzhour >= 0 ? 60 : -60); |
| 13 } | 14 } |
| 14 | 15 |
| 15 FX_BOOL _gAfxIsLeapYear(int16_t year) { | 16 FX_BOOL _gAfxIsLeapYear(int16_t year) { |
| 16 return ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0))); | 17 return ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0))); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 return mktime(&newtime); | 210 return mktime(&newtime); |
| 210 } | 211 } |
| 211 | 212 |
| 212 CPDFSDK_DateTime& CPDFSDK_DateTime::FromPDFDateTimeString( | 213 CPDFSDK_DateTime& CPDFSDK_DateTime::FromPDFDateTimeString( |
| 213 const CFX_ByteString& dtStr) { | 214 const CFX_ByteString& dtStr) { |
| 214 int strLength = dtStr.GetLength(); | 215 int strLength = dtStr.GetLength(); |
| 215 if (strLength > 0) { | 216 if (strLength > 0) { |
| 216 int i = 0; | 217 int i = 0; |
| 217 int j, k; | 218 int j, k; |
| 218 FX_CHAR ch; | 219 FX_CHAR ch; |
| 219 while (i < strLength) { | 220 while (i < strLength && !std::isdigit(dtStr[i])) |
| 220 ch = dtStr[i]; | 221 ++i; |
| 221 if (ch >= '0' && ch <= '9') | 222 |
| 222 break; | |
| 223 i++; | |
| 224 } | |
| 225 if (i >= strLength) | 223 if (i >= strLength) |
| 226 return *this; | 224 return *this; |
| 227 | 225 |
| 228 j = 0; | 226 j = 0; |
| 229 k = 0; | 227 k = 0; |
| 230 while (i < strLength && j < 4) { | 228 while (i < strLength && j < 4) { |
| 231 ch = dtStr[i]; | 229 ch = dtStr[i]; |
| 232 k = k * 10 + ch - '0'; | 230 k = k * 10 + FXSYS_toDecimalDigit(ch); |
| 233 j++; | 231 j++; |
| 234 if (ch < '0' || ch > '9') | 232 if (!std::isdigit(ch)) |
| 235 break; | 233 break; |
| 236 i++; | 234 i++; |
| 237 } | 235 } |
| 238 dt.year = (int16_t)k; | 236 dt.year = (int16_t)k; |
| 239 if (i >= strLength || j < 4) | 237 if (i >= strLength || j < 4) |
| 240 return *this; | 238 return *this; |
| 241 | 239 |
| 242 j = 0; | 240 j = 0; |
| 243 k = 0; | 241 k = 0; |
| 244 while (i < strLength && j < 2) { | 242 while (i < strLength && j < 2) { |
| 245 ch = dtStr[i]; | 243 ch = dtStr[i]; |
| 246 k = k * 10 + ch - '0'; | 244 k = k * 10 + FXSYS_toDecimalDigit(ch); |
| 247 j++; | 245 j++; |
| 248 if (ch < '0' || ch > '9') | 246 if (!std::isdigit(ch)) |
| 249 break; | 247 break; |
| 250 i++; | 248 i++; |
| 251 } | 249 } |
| 252 dt.month = (uint8_t)k; | 250 dt.month = (uint8_t)k; |
| 253 if (i >= strLength || j < 2) | 251 if (i >= strLength || j < 2) |
| 254 return *this; | 252 return *this; |
| 255 | 253 |
| 256 j = 0; | 254 j = 0; |
| 257 k = 0; | 255 k = 0; |
| 258 while (i < strLength && j < 2) { | 256 while (i < strLength && j < 2) { |
| 259 ch = dtStr[i]; | 257 ch = dtStr[i]; |
| 260 k = k * 10 + ch - '0'; | 258 k = k * 10 + FXSYS_toDecimalDigit(ch); |
| 261 j++; | 259 j++; |
| 262 if (ch < '0' || ch > '9') | 260 if (!std::isdigit(ch)) |
| 263 break; | 261 break; |
| 264 i++; | 262 i++; |
| 265 } | 263 } |
| 266 dt.day = (uint8_t)k; | 264 dt.day = (uint8_t)k; |
| 267 if (i >= strLength || j < 2) | 265 if (i >= strLength || j < 2) |
| 268 return *this; | 266 return *this; |
| 269 | 267 |
| 270 j = 0; | 268 j = 0; |
| 271 k = 0; | 269 k = 0; |
| 272 while (i < strLength && j < 2) { | 270 while (i < strLength && j < 2) { |
| 273 ch = dtStr[i]; | 271 ch = dtStr[i]; |
| 274 k = k * 10 + ch - '0'; | 272 k = k * 10 + FXSYS_toDecimalDigit(ch); |
| 275 j++; | 273 j++; |
| 276 if (ch < '0' || ch > '9') | 274 if (!std::isdigit(ch)) |
| 277 break; | 275 break; |
| 278 i++; | 276 i++; |
| 279 } | 277 } |
| 280 dt.hour = (uint8_t)k; | 278 dt.hour = (uint8_t)k; |
| 281 if (i >= strLength || j < 2) | 279 if (i >= strLength || j < 2) |
| 282 return *this; | 280 return *this; |
| 283 | 281 |
| 284 j = 0; | 282 j = 0; |
| 285 k = 0; | 283 k = 0; |
| 286 while (i < strLength && j < 2) { | 284 while (i < strLength && j < 2) { |
| 287 ch = dtStr[i]; | 285 ch = dtStr[i]; |
| 288 k = k * 10 + ch - '0'; | 286 k = k * 10 + FXSYS_toDecimalDigit(ch); |
| 289 j++; | 287 j++; |
| 290 if (ch < '0' || ch > '9') | 288 if (!std::isdigit(ch)) |
| 291 break; | 289 break; |
| 292 i++; | 290 i++; |
| 293 } | 291 } |
| 294 dt.minute = (uint8_t)k; | 292 dt.minute = (uint8_t)k; |
| 295 if (i >= strLength || j < 2) | 293 if (i >= strLength || j < 2) |
| 296 return *this; | 294 return *this; |
| 297 | 295 |
| 298 j = 0; | 296 j = 0; |
| 299 k = 0; | 297 k = 0; |
| 300 while (i < strLength && j < 2) { | 298 while (i < strLength && j < 2) { |
| 301 ch = dtStr[i]; | 299 ch = dtStr[i]; |
| 302 k = k * 10 + ch - '0'; | 300 k = k * 10 + FXSYS_toDecimalDigit(ch); |
| 303 j++; | 301 j++; |
| 304 if (ch < '0' || ch > '9') | 302 if (!std::isdigit(ch)) |
| 305 break; | 303 break; |
| 306 i++; | 304 i++; |
| 307 } | 305 } |
| 308 dt.second = (uint8_t)k; | 306 dt.second = (uint8_t)k; |
| 309 if (i >= strLength || j < 2) | 307 if (i >= strLength || j < 2) |
| 310 return *this; | 308 return *this; |
| 311 | 309 |
| 312 ch = dtStr[i++]; | 310 ch = dtStr[i++]; |
| 313 if (ch != '-' && ch != '+') | 311 if (ch != '-' && ch != '+') |
| 314 return *this; | 312 return *this; |
| 315 if (ch == '-') | 313 if (ch == '-') |
| 316 dt.tzHour = -1; | 314 dt.tzHour = -1; |
| 317 else | 315 else |
| 318 dt.tzHour = 1; | 316 dt.tzHour = 1; |
| 319 j = 0; | 317 j = 0; |
| 320 k = 0; | 318 k = 0; |
| 321 while (i < strLength && j < 2) { | 319 while (i < strLength && j < 2) { |
| 322 ch = dtStr[i]; | 320 ch = dtStr[i]; |
| 323 k = k * 10 + ch - '0'; | 321 k = k * 10 + FXSYS_toDecimalDigit(ch); |
| 324 j++; | 322 j++; |
| 325 if (ch < '0' || ch > '9') | 323 if (!std::isdigit(ch)) |
| 326 break; | 324 break; |
| 327 i++; | 325 i++; |
| 328 } | 326 } |
| 329 dt.tzHour *= (FX_CHAR)k; | 327 dt.tzHour *= (FX_CHAR)k; |
| 330 if (i >= strLength || j < 2) | 328 if (i >= strLength || j < 2) |
| 331 return *this; | 329 return *this; |
| 332 | 330 |
| 333 ch = dtStr[i++]; | 331 ch = dtStr[i++]; |
| 334 if (ch != '\'') | 332 if (ch != '\'') |
| 335 return *this; | 333 return *this; |
| 336 j = 0; | 334 j = 0; |
| 337 k = 0; | 335 k = 0; |
| 338 while (i < strLength && j < 2) { | 336 while (i < strLength && j < 2) { |
| 339 ch = dtStr[i]; | 337 ch = dtStr[i]; |
| 340 k = k * 10 + ch - '0'; | 338 k = k * 10 + FXSYS_toDecimalDigit(ch); |
| 341 j++; | 339 j++; |
| 342 if (ch < '0' || ch > '9') | 340 if (!std::isdigit(ch)) |
| 343 break; | 341 break; |
| 344 i++; | 342 i++; |
| 345 } | 343 } |
| 346 dt.tzMinute = (uint8_t)k; | 344 dt.tzMinute = (uint8_t)k; |
| 347 if (i >= strLength || j < 2) | 345 if (i >= strLength || j < 2) |
| 348 return *this; | 346 return *this; |
| 349 } | 347 } |
| 350 | 348 |
| 351 return *this; | 349 return *this; |
| 352 } | 350 } |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 976 CPDF_Annot::Normal, NULL); | 974 CPDF_Annot::Normal, NULL); |
| 977 | 975 |
| 978 return; | 976 return; |
| 979 } | 977 } |
| 980 | 978 |
| 981 CPDF_Page* CPDFSDK_Annot::GetPDFPage() { | 979 CPDF_Page* CPDFSDK_Annot::GetPDFPage() { |
| 982 if (m_pPageView) | 980 if (m_pPageView) |
| 983 return m_pPageView->GetPDFPage(); | 981 return m_pPageView->GetPDFPage(); |
| 984 return NULL; | 982 return NULL; |
| 985 } | 983 } |
| OLD | NEW |