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