| 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 "../include/fsdk_define.h" | 7 #include "../include/fsdk_define.h" |
| 8 #include "../include/fsdk_mgr.h" | 8 #include "../include/fsdk_mgr.h" |
| 9 #include "../include/fsdk_baseannot.h" | 9 #include "../include/fsdk_baseannot.h" |
| 10 | 10 |
| 11 | 11 |
| 12 //--------------------------------------------------------------------------- | 12 //--------------------------------------------------------------------------- |
| 13 // CPDFSDK_DateTime
| 13 // CPDFSDK_DateTime
|
| 14 //--------------------------------------------------------------------------- | 14 //--------------------------------------------------------------------------- |
| 15 int _gAfxGetTimeZoneInSeconds(FX_CHAR tzhour, FX_BYTE tzminute) | 15 int _gAfxGetTimeZoneInSeconds(FX_CHAR tzhour, uint8_t tzminute) |
| 16 { | 16 { |
| 17 return (int)tzhour * 3600 + (int)tzminute * (tzhour >= 0 ? 60 : -60); | 17 return (int)tzhour * 3600 + (int)tzminute * (tzhour >= 0 ? 60 : -60); |
| 18 } | 18 } |
| 19 | 19 |
| 20 FX_BOOL _gAfxIsLeapYear(FX_SHORT year) | 20 FX_BOOL _gAfxIsLeapYear(int16_t year) |
| 21 { | 21 { |
| 22 return ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0))); | 22 return ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0))); |
| 23 } | 23 } |
| 24 | 24 |
| 25 FX_WORD _gAfxGetYearDays(FX_SHORT year) | 25 FX_WORD _gAfxGetYearDays(int16_t year) |
| 26 { | 26 { |
| 27 return (_gAfxIsLeapYear(year) == TRUE ? 366 : 365); | 27 return (_gAfxIsLeapYear(year) == TRUE ? 366 : 365); |
| 28 } | 28 } |
| 29 | 29 |
| 30 FX_BYTE _gAfxGetMonthDays(FX_SHORT year, FX_BYTE month) | 30 uint8_t _gAfxGetMonthDays(int16_t year, uint8_t month) |
| 31 { | 31 { |
| 32 » FX_BYTE»mDays; | 32 » uint8_t»mDays; |
| 33 switch (month) | 33 switch (month) |
| 34 { | 34 { |
| 35 case 1: | 35 case 1: |
| 36 case 3: | 36 case 3: |
| 37 case 5: | 37 case 5: |
| 38 case 7: | 38 case 7: |
| 39 case 8: | 39 case 8: |
| 40 case 10: | 40 case 10: |
| 41 case 12: | 41 case 12: |
| 42 mDays = 31; | 42 mDays = 31; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 CPDFSDK_DateTime& CPDFSDK_DateTime::operator = (const CPDFSDK_DateTime& datetime
) | 110 CPDFSDK_DateTime& CPDFSDK_DateTime::operator = (const CPDFSDK_DateTime& datetime
) |
| 111 { | 111 { |
| 112 FXSYS_memcpy(&dt, &datetime.dt, sizeof(FX_DATETIME)); | 112 FXSYS_memcpy(&dt, &datetime.dt, sizeof(FX_DATETIME)); |
| 113 return *this; | 113 return *this; |
| 114 } | 114 } |
| 115 | 115 |
| 116 CPDFSDK_DateTime& CPDFSDK_DateTime::operator = (const FX_SYSTEMTIME& st) | 116 CPDFSDK_DateTime& CPDFSDK_DateTime::operator = (const FX_SYSTEMTIME& st) |
| 117 { | 117 { |
| 118 tzset(); | 118 tzset(); |
| 119 | 119 |
| 120 » dt.year = (FX_SHORT)st.wYear; | 120 » dt.year = (int16_t)st.wYear; |
| 121 » dt.month = (FX_BYTE)st.wMonth; | 121 » dt.month = (uint8_t)st.wMonth; |
| 122 » dt.day = (FX_BYTE)st.wDay; | 122 » dt.day = (uint8_t)st.wDay; |
| 123 » dt.hour = (FX_BYTE)st.wHour; | 123 » dt.hour = (uint8_t)st.wHour; |
| 124 » dt.minute = (FX_BYTE)st.wMinute; | 124 » dt.minute = (uint8_t)st.wMinute; |
| 125 » dt.second = (FX_BYTE)st.wSecond; | 125 » dt.second = (uint8_t)st.wSecond; |
| 126 // dt.tzHour = _timezone / 3600 * -1; | 126 // dt.tzHour = _timezone / 3600 * -1; |
| 127 // dt.tzMinute = (abs(_timezone) % 3600) / 60; | 127 // dt.tzMinute = (abs(_timezone) % 3600) / 60; |
| 128 return *this; | 128 return *this; |
| 129 } | 129 } |
| 130 | 130 |
| 131 FX_BOOL CPDFSDK_DateTime::operator == (CPDFSDK_DateTime& datetime) | 131 FX_BOOL CPDFSDK_DateTime::operator == (CPDFSDK_DateTime& datetime) |
| 132 { | 132 { |
| 133 return (FXSYS_memcmp(&dt, &datetime.dt, sizeof(FX_DATETIME)) == 0); | 133 return (FXSYS_memcmp(&dt, &datetime.dt, sizeof(FX_DATETIME)) == 0); |
| 134 } | 134 } |
| 135 | 135 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 j = 0; | 227 j = 0; |
| 228 k = 0; | 228 k = 0; |
| 229 while (i < strLength && j < 4) | 229 while (i < strLength && j < 4) |
| 230 { | 230 { |
| 231 ch = dtStr[i]; | 231 ch = dtStr[i]; |
| 232 k = k * 10 + ch - '0'; | 232 k = k * 10 + ch - '0'; |
| 233 j ++; | 233 j ++; |
| 234 if (ch < '0' || ch > '9') break; | 234 if (ch < '0' || ch > '9') break; |
| 235 i ++; | 235 i ++; |
| 236 } | 236 } |
| 237 » » dt.year = (FX_SHORT)k; | 237 » » dt.year = (int16_t)k; |
| 238 if (i >= strLength || j < 4) return *this; | 238 if (i >= strLength || j < 4) return *this; |
| 239 | 239 |
| 240 j = 0; | 240 j = 0; |
| 241 k = 0; | 241 k = 0; |
| 242 while (i < strLength && j < 2) | 242 while (i < strLength && j < 2) |
| 243 { | 243 { |
| 244 ch = dtStr[i]; | 244 ch = dtStr[i]; |
| 245 k = k * 10 + ch - '0'; | 245 k = k * 10 + ch - '0'; |
| 246 j ++; | 246 j ++; |
| 247 if (ch < '0' || ch > '9') break; | 247 if (ch < '0' || ch > '9') break; |
| 248 i ++; | 248 i ++; |
| 249 } | 249 } |
| 250 » » dt.month = (FX_BYTE)k; | 250 » » dt.month = (uint8_t)k; |
| 251 if (i >= strLength || j < 2) return *this; | 251 if (i >= strLength || j < 2) return *this; |
| 252 | 252 |
| 253 j = 0; | 253 j = 0; |
| 254 k = 0; | 254 k = 0; |
| 255 while (i < strLength && j < 2) | 255 while (i < strLength && j < 2) |
| 256 { | 256 { |
| 257 ch = dtStr[i]; | 257 ch = dtStr[i]; |
| 258 k = k * 10 + ch - '0'; | 258 k = k * 10 + ch - '0'; |
| 259 j ++; | 259 j ++; |
| 260 if (ch < '0' || ch > '9') break; | 260 if (ch < '0' || ch > '9') break; |
| 261 i ++; | 261 i ++; |
| 262 } | 262 } |
| 263 » » dt.day = (FX_BYTE)k; | 263 » » dt.day = (uint8_t)k; |
| 264 if (i >= strLength || j < 2) return *this; | 264 if (i >= strLength || j < 2) return *this; |
| 265 | 265 |
| 266 j = 0; | 266 j = 0; |
| 267 k = 0; | 267 k = 0; |
| 268 while (i < strLength && j < 2) | 268 while (i < strLength && j < 2) |
| 269 { | 269 { |
| 270 ch = dtStr[i]; | 270 ch = dtStr[i]; |
| 271 k = k * 10 + ch - '0'; | 271 k = k * 10 + ch - '0'; |
| 272 j ++; | 272 j ++; |
| 273 if (ch < '0' || ch > '9') break; | 273 if (ch < '0' || ch > '9') break; |
| 274 i ++; | 274 i ++; |
| 275 } | 275 } |
| 276 » » dt.hour = (FX_BYTE)k; | 276 » » dt.hour = (uint8_t)k; |
| 277 if (i >= strLength || j < 2) return *this; | 277 if (i >= strLength || j < 2) return *this; |
| 278 | 278 |
| 279 j = 0; | 279 j = 0; |
| 280 k = 0; | 280 k = 0; |
| 281 while (i < strLength && j < 2) | 281 while (i < strLength && j < 2) |
| 282 { | 282 { |
| 283 ch = dtStr[i]; | 283 ch = dtStr[i]; |
| 284 k = k * 10 + ch - '0'; | 284 k = k * 10 + ch - '0'; |
| 285 j ++; | 285 j ++; |
| 286 if (ch < '0' || ch > '9') break; | 286 if (ch < '0' || ch > '9') break; |
| 287 i ++; | 287 i ++; |
| 288 } | 288 } |
| 289 » » dt.minute = (FX_BYTE)k; | 289 » » dt.minute = (uint8_t)k; |
| 290 if (i >= strLength || j < 2) return *this; | 290 if (i >= strLength || j < 2) return *this; |
| 291 | 291 |
| 292 j = 0; | 292 j = 0; |
| 293 k = 0; | 293 k = 0; |
| 294 while (i < strLength && j < 2) | 294 while (i < strLength && j < 2) |
| 295 { | 295 { |
| 296 ch = dtStr[i]; | 296 ch = dtStr[i]; |
| 297 k = k * 10 + ch - '0'; | 297 k = k * 10 + ch - '0'; |
| 298 j ++; | 298 j ++; |
| 299 if (ch < '0' || ch > '9') break; | 299 if (ch < '0' || ch > '9') break; |
| 300 i ++; | 300 i ++; |
| 301 } | 301 } |
| 302 » » dt.second = (FX_BYTE)k; | 302 » » dt.second = (uint8_t)k; |
| 303 if (i >= strLength || j < 2) return *this; | 303 if (i >= strLength || j < 2) return *this; |
| 304 | 304 |
| 305 ch = dtStr[i ++]; | 305 ch = dtStr[i ++]; |
| 306 if (ch != '-' && ch != '+') return *this; | 306 if (ch != '-' && ch != '+') return *this; |
| 307 if (ch == '-') | 307 if (ch == '-') |
| 308 dt.tzHour = -1; | 308 dt.tzHour = -1; |
| 309 else | 309 else |
| 310 dt.tzHour = 1; | 310 dt.tzHour = 1; |
| 311 j = 0; | 311 j = 0; |
| 312 k = 0; | 312 k = 0; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 326 j = 0; | 326 j = 0; |
| 327 k = 0; | 327 k = 0; |
| 328 while (i < strLength && j < 2) | 328 while (i < strLength && j < 2) |
| 329 { | 329 { |
| 330 ch = dtStr[i]; | 330 ch = dtStr[i]; |
| 331 k = k * 10 + ch - '0'; | 331 k = k * 10 + ch - '0'; |
| 332 j ++; | 332 j ++; |
| 333 if (ch < '0' || ch > '9') break; | 333 if (ch < '0' || ch > '9') break; |
| 334 i ++; | 334 i ++; |
| 335 } | 335 } |
| 336 » » dt.tzMinute = (FX_BYTE)k; | 336 » » dt.tzMinute = (uint8_t)k; |
| 337 if (i >= strLength || j < 2) return *this; | 337 if (i >= strLength || j < 2) return *this; |
| 338 } | 338 } |
| 339 | 339 |
| 340 return *this; | 340 return *this; |
| 341 } | 341 } |
| 342 | 342 |
| 343 CFX_ByteString CPDFSDK_DateTime::ToCommonDateTimeString() | 343 CFX_ByteString CPDFSDK_DateTime::ToCommonDateTimeString() |
| 344 { | 344 { |
| 345 CFX_ByteString str1; | 345 CFX_ByteString str1; |
| 346 str1.Format("%04d-%02d-%02d %02d:%02d:%02d ", dt.year, dt.month, dt.day,
dt.hour, dt.minute, dt.second); | 346 str1.Format("%04d-%02d-%02d %02d:%02d:%02d ", dt.year, dt.month, dt.day,
dt.hour, dt.minute, dt.second); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 dt.AddSeconds(-_gAfxGetTimeZoneInSeconds(dt.dt.tzHour, dt.dt.tzMinute)); | 394 dt.AddSeconds(-_gAfxGetTimeZoneInSeconds(dt.dt.tzHour, dt.dt.tzMinute)); |
| 395 dt.dt.tzHour = 0; | 395 dt.dt.tzHour = 0; |
| 396 dt.dt.tzMinute = 0; | 396 dt.dt.tzMinute = 0; |
| 397 return dt; | 397 return dt; |
| 398 } | 398 } |
| 399 | 399 |
| 400 CPDFSDK_DateTime& CPDFSDK_DateTime::AddDays(short days) | 400 CPDFSDK_DateTime& CPDFSDK_DateTime::AddDays(short days) |
| 401 { | 401 { |
| 402 if (days == 0) return *this; | 402 if (days == 0) return *this; |
| 403 | 403 |
| 404 » FX_SHORT» y = dt.year, yy; | 404 » int16_t»y = dt.year, yy; |
| 405 » FX_BYTE»» m = dt.month; | 405 » uint8_t»» m = dt.month; |
| 406 » FX_BYTE»» d = dt.day; | 406 » uint8_t»» d = dt.day; |
| 407 int mdays, ydays, ldays; | 407 int mdays, ydays, ldays; |
| 408 | 408 |
| 409 ldays = days; | 409 ldays = days; |
| 410 if (ldays > 0) | 410 if (ldays > 0) |
| 411 { | 411 { |
| 412 yy = y; | 412 yy = y; |
| 413 if (((FX_WORD)m * 100 + d) > 300) yy ++; | 413 if (((FX_WORD)m * 100 + d) > 300) yy ++; |
| 414 ydays = _gAfxGetYearDays(yy); | 414 ydays = _gAfxGetYearDays(yy); |
| 415 while (ldays >= ydays) | 415 while (ldays >= ydays) |
| 416 { | 416 { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 if (n < 0) | 482 if (n < 0) |
| 483 { | 483 { |
| 484 days = (n - 86399) / 86400; | 484 days = (n - 86399) / 86400; |
| 485 n -= days * 86400; | 485 n -= days * 86400; |
| 486 } | 486 } |
| 487 else | 487 else |
| 488 { | 488 { |
| 489 days = n / 86400; | 489 days = n / 86400; |
| 490 n %= 86400; | 490 n %= 86400; |
| 491 } | 491 } |
| 492 » dt.hour = (FX_BYTE)(n / 3600); | 492 » dt.hour = (uint8_t)(n / 3600); |
| 493 dt.hour %= 24; | 493 dt.hour %= 24; |
| 494 n %= 3600; | 494 n %= 3600; |
| 495 » dt.minute = (FX_BYTE)(n / 60); | 495 » dt.minute = (uint8_t)(n / 60); |
| 496 » dt.second = (FX_BYTE)(n % 60); | 496 » dt.second = (uint8_t)(n % 60); |
| 497 if (days != 0) AddDays(days); | 497 if (days != 0) AddDays(days); |
| 498 | 498 |
| 499 return *this; | 499 return *this; |
| 500 } | 500 } |
| 501 | 501 |
| 502 | 502 |
| 503 //--------------------------------------------------------------------------- | 503 //--------------------------------------------------------------------------- |
| 504 // CPDFSDK_Annot | 504 // CPDFSDK_Annot |
| 505 //--------------------------------------------------------------------------- | 505 //--------------------------------------------------------------------------- |
| 506 CPDFSDK_Annot::CPDFSDK_Annot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView) : | 506 CPDFSDK_Annot::CPDFSDK_Annot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView) : |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 958 } | 958 } |
| 959 | 959 |
| 960 pParentDict = pAPTypeDict; | 960 pParentDict = pAPTypeDict; |
| 961 pStream = pAPTypeDict->GetStream(sAPState); | 961 pStream = pAPTypeDict->GetStream(sAPState); |
| 962 } | 962 } |
| 963 | 963 |
| 964 if (!pStream) | 964 if (!pStream) |
| 965 { | 965 { |
| 966 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); | 966 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); |
| 967 pStream = new CPDF_Stream(NULL, 0, NULL); | 967 pStream = new CPDF_Stream(NULL, 0, NULL); |
| 968 » » FX_INT32 objnum = pDoc->AddIndirectObject(pStream); | 968 » » int32_t objnum = pDoc->AddIndirectObject(pStream); |
| 969 pParentDict->SetAtReference(sAPType, pDoc, objnum); | 969 pParentDict->SetAtReference(sAPType, pDoc, objnum); |
| 970 } | 970 } |
| 971 | 971 |
| 972 CPDF_Dictionary *pStreamDict = pStream->GetDict(); | 972 CPDF_Dictionary *pStreamDict = pStream->GetDict(); |
| 973 if (!pStreamDict) | 973 if (!pStreamDict) |
| 974 { | 974 { |
| 975 pStreamDict = new CPDF_Dictionary; | 975 pStreamDict = new CPDF_Dictionary; |
| 976 pStreamDict->SetAtName("Type", "XObject"); | 976 pStreamDict->SetAtName("Type", "XObject"); |
| 977 pStreamDict->SetAtName("Subtype", "Form"); | 977 pStreamDict->SetAtName("Subtype", "Form"); |
| 978 pStreamDict->SetAtInteger("FormType", 1); | 978 pStreamDict->SetAtInteger("FormType", 1); |
| 979 pStream->InitStream(NULL,0,pStreamDict); | 979 pStream->InitStream(NULL,0,pStreamDict); |
| 980 } | 980 } |
| 981 | 981 |
| 982 if (pStreamDict) | 982 if (pStreamDict) |
| 983 { | 983 { |
| 984 pStreamDict->SetAtMatrix("Matrix",matrix); | 984 pStreamDict->SetAtMatrix("Matrix",matrix); |
| 985 pStreamDict->SetAtRect("BBox", rcBBox); | 985 pStreamDict->SetAtRect("BBox", rcBBox); |
| 986 } | 986 } |
| 987 | 987 |
| 988 » pStream->SetData((FX_BYTE*)sContents.c_str(), sContents.GetLength(), FAL
SE, FALSE); | 988 » pStream->SetData((uint8_t*)sContents.c_str(), sContents.GetLength(), FAL
SE, FALSE); |
| 989 } | 989 } |
| 990 | 990 |
| 991 #define BA_ANNOT_MINWIDTH 1 | 991 #define BA_ANNOT_MINWIDTH 1 |
| 992 #define BA_ANNOT_MINHEIGHT 1 | 992 #define BA_ANNOT_MINHEIGHT 1 |
| 993 | 993 |
| 994 FX_FLOAT CPDFSDK_Annot::GetMinWidth() const | 994 FX_FLOAT CPDFSDK_Annot::GetMinWidth() const |
| 995 { | 995 { |
| 996 return BA_ANNOT_MINWIDTH; | 996 return BA_ANNOT_MINWIDTH; |
| 997 } | 997 } |
| 998 | 998 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1075 return ; | 1075 return ; |
| 1076 } | 1076 } |
| 1077 | 1077 |
| 1078 CPDF_Page* CPDFSDK_Annot::GetPDFPage() | 1078 CPDF_Page* CPDFSDK_Annot::GetPDFPage() |
| 1079 { | 1079 { |
| 1080 if(m_pPageView) | 1080 if(m_pPageView) |
| 1081 return m_pPageView->GetPDFPage(); | 1081 return m_pPageView->GetPDFPage(); |
| 1082 return NULL; | 1082 return NULL; |
| 1083 } | 1083 } |
| 1084 | 1084 |
| OLD | NEW |