Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: fpdfsdk/src/fsdk_baseannot.cpp

Issue 1172793002: Merge to XFA: Use stdint.h types throughout PDFium. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/src/fsdk_actionhandler.cpp ('k') | fpdfsdk/src/fsdk_baseform.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/fpdfxfa/fpdfxfa_doc.h" 8 #include "../include/fpdfxfa/fpdfxfa_doc.h"
9 #include "../include/fsdk_mgr.h" 9 #include "../include/fsdk_mgr.h"
10 #include "../include/fsdk_baseannot.h" 10 #include "../include/fsdk_baseannot.h"
11 11
12 12
13 //--------------------------------------------------------------------------- 13 //---------------------------------------------------------------------------
14 // CPDFSDK_DateTime 14 // CPDFSDK_DateTime
15 //--------------------------------------------------------------------------- 15 //---------------------------------------------------------------------------
16 int _gAfxGetTimeZoneInSeconds(FX_CHAR tzhour, FX_BYTE tzminute) 16 int _gAfxGetTimeZoneInSeconds(FX_CHAR tzhour, uint8_t tzminute)
17 { 17 {
18 return (int)tzhour * 3600 + (int)tzminute * (tzhour >= 0 ? 60 : -60); 18 return (int)tzhour * 3600 + (int)tzminute * (tzhour >= 0 ? 60 : -60);
19 } 19 }
20 20
21 FX_BOOL _gAfxIsLeapYear(FX_SHORT year) 21 FX_BOOL _gAfxIsLeapYear(int16_t year)
22 { 22 {
23 return ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0))); 23 return ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0)));
24 } 24 }
25 25
26 FX_WORD _gAfxGetYearDays(FX_SHORT year) 26 FX_WORD _gAfxGetYearDays(int16_t year)
27 { 27 {
28 return (_gAfxIsLeapYear(year) == TRUE ? 366 : 365); 28 return (_gAfxIsLeapYear(year) == TRUE ? 366 : 365);
29 } 29 }
30 30
31 FX_BYTE _gAfxGetMonthDays(FX_SHORT year, FX_BYTE month) 31 uint8_t _gAfxGetMonthDays(int16_t year, uint8_t month)
32 { 32 {
33 » FX_BYTE»mDays; 33 » uint8_t»mDays;
34 switch (month) 34 switch (month)
35 { 35 {
36 case 1: 36 case 1:
37 case 3: 37 case 3:
38 case 5: 38 case 5:
39 case 7: 39 case 7:
40 case 8: 40 case 8:
41 case 10: 41 case 10:
42 case 12: 42 case 12:
43 mDays = 31; 43 mDays = 31;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 CPDFSDK_DateTime& CPDFSDK_DateTime::operator = (const CPDFSDK_DateTime& datetime ) 111 CPDFSDK_DateTime& CPDFSDK_DateTime::operator = (const CPDFSDK_DateTime& datetime )
112 { 112 {
113 FXSYS_memcpy(&dt, &datetime.dt, sizeof(FX_DATETIME)); 113 FXSYS_memcpy(&dt, &datetime.dt, sizeof(FX_DATETIME));
114 return *this; 114 return *this;
115 } 115 }
116 116
117 CPDFSDK_DateTime& CPDFSDK_DateTime::operator = (const FX_SYSTEMTIME& st) 117 CPDFSDK_DateTime& CPDFSDK_DateTime::operator = (const FX_SYSTEMTIME& st)
118 { 118 {
119 tzset(); 119 tzset();
120 120
121 » dt.year = (FX_SHORT)st.wYear; 121 » dt.year = (int16_t)st.wYear;
122 » dt.month = (FX_BYTE)st.wMonth; 122 » dt.month = (uint8_t)st.wMonth;
123 » dt.day = (FX_BYTE)st.wDay; 123 » dt.day = (uint8_t)st.wDay;
124 » dt.hour = (FX_BYTE)st.wHour; 124 » dt.hour = (uint8_t)st.wHour;
125 » dt.minute = (FX_BYTE)st.wMinute; 125 » dt.minute = (uint8_t)st.wMinute;
126 » dt.second = (FX_BYTE)st.wSecond; 126 » dt.second = (uint8_t)st.wSecond;
127 // dt.tzHour = _timezone / 3600 * -1; 127 // dt.tzHour = _timezone / 3600 * -1;
128 // dt.tzMinute = (abs(_timezone) % 3600) / 60; 128 // dt.tzMinute = (abs(_timezone) % 3600) / 60;
129 return *this; 129 return *this;
130 } 130 }
131 131
132 FX_BOOL CPDFSDK_DateTime::operator == (CPDFSDK_DateTime& datetime) 132 FX_BOOL CPDFSDK_DateTime::operator == (CPDFSDK_DateTime& datetime)
133 { 133 {
134 return (FXSYS_memcmp(&dt, &datetime.dt, sizeof(FX_DATETIME)) == 0); 134 return (FXSYS_memcmp(&dt, &datetime.dt, sizeof(FX_DATETIME)) == 0);
135 } 135 }
136 136
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 j = 0; 228 j = 0;
229 k = 0; 229 k = 0;
230 while (i < strLength && j < 4) 230 while (i < strLength && j < 4)
231 { 231 {
232 ch = dtStr[i]; 232 ch = dtStr[i];
233 k = k * 10 + ch - '0'; 233 k = k * 10 + ch - '0';
234 j ++; 234 j ++;
235 if (ch < '0' || ch > '9') break; 235 if (ch < '0' || ch > '9') break;
236 i ++; 236 i ++;
237 } 237 }
238 » » dt.year = (FX_SHORT)k; 238 » » dt.year = (int16_t)k;
239 if (i >= strLength || j < 4) return *this; 239 if (i >= strLength || j < 4) return *this;
240 240
241 j = 0; 241 j = 0;
242 k = 0; 242 k = 0;
243 while (i < strLength && j < 2) 243 while (i < strLength && j < 2)
244 { 244 {
245 ch = dtStr[i]; 245 ch = dtStr[i];
246 k = k * 10 + ch - '0'; 246 k = k * 10 + ch - '0';
247 j ++; 247 j ++;
248 if (ch < '0' || ch > '9') break; 248 if (ch < '0' || ch > '9') break;
249 i ++; 249 i ++;
250 } 250 }
251 » » dt.month = (FX_BYTE)k; 251 » » dt.month = (uint8_t)k;
252 if (i >= strLength || j < 2) return *this; 252 if (i >= strLength || j < 2) return *this;
253 253
254 j = 0; 254 j = 0;
255 k = 0; 255 k = 0;
256 while (i < strLength && j < 2) 256 while (i < strLength && j < 2)
257 { 257 {
258 ch = dtStr[i]; 258 ch = dtStr[i];
259 k = k * 10 + ch - '0'; 259 k = k * 10 + ch - '0';
260 j ++; 260 j ++;
261 if (ch < '0' || ch > '9') break; 261 if (ch < '0' || ch > '9') break;
262 i ++; 262 i ++;
263 } 263 }
264 » » dt.day = (FX_BYTE)k; 264 » » dt.day = (uint8_t)k;
265 if (i >= strLength || j < 2) return *this; 265 if (i >= strLength || j < 2) return *this;
266 266
267 j = 0; 267 j = 0;
268 k = 0; 268 k = 0;
269 while (i < strLength && j < 2) 269 while (i < strLength && j < 2)
270 { 270 {
271 ch = dtStr[i]; 271 ch = dtStr[i];
272 k = k * 10 + ch - '0'; 272 k = k * 10 + ch - '0';
273 j ++; 273 j ++;
274 if (ch < '0' || ch > '9') break; 274 if (ch < '0' || ch > '9') break;
275 i ++; 275 i ++;
276 } 276 }
277 » » dt.hour = (FX_BYTE)k; 277 » » dt.hour = (uint8_t)k;
278 if (i >= strLength || j < 2) return *this; 278 if (i >= strLength || j < 2) return *this;
279 279
280 j = 0; 280 j = 0;
281 k = 0; 281 k = 0;
282 while (i < strLength && j < 2) 282 while (i < strLength && j < 2)
283 { 283 {
284 ch = dtStr[i]; 284 ch = dtStr[i];
285 k = k * 10 + ch - '0'; 285 k = k * 10 + ch - '0';
286 j ++; 286 j ++;
287 if (ch < '0' || ch > '9') break; 287 if (ch < '0' || ch > '9') break;
288 i ++; 288 i ++;
289 } 289 }
290 » » dt.minute = (FX_BYTE)k; 290 » » dt.minute = (uint8_t)k;
291 if (i >= strLength || j < 2) return *this; 291 if (i >= strLength || j < 2) return *this;
292 292
293 j = 0; 293 j = 0;
294 k = 0; 294 k = 0;
295 while (i < strLength && j < 2) 295 while (i < strLength && j < 2)
296 { 296 {
297 ch = dtStr[i]; 297 ch = dtStr[i];
298 k = k * 10 + ch - '0'; 298 k = k * 10 + ch - '0';
299 j ++; 299 j ++;
300 if (ch < '0' || ch > '9') break; 300 if (ch < '0' || ch > '9') break;
301 i ++; 301 i ++;
302 } 302 }
303 » » dt.second = (FX_BYTE)k; 303 » » dt.second = (uint8_t)k;
304 if (i >= strLength || j < 2) return *this; 304 if (i >= strLength || j < 2) return *this;
305 305
306 ch = dtStr[i ++]; 306 ch = dtStr[i ++];
307 if (ch != '-' && ch != '+') return *this; 307 if (ch != '-' && ch != '+') return *this;
308 if (ch == '-') 308 if (ch == '-')
309 dt.tzHour = -1; 309 dt.tzHour = -1;
310 else 310 else
311 dt.tzHour = 1; 311 dt.tzHour = 1;
312 j = 0; 312 j = 0;
313 k = 0; 313 k = 0;
(...skipping 13 matching lines...) Expand all
327 j = 0; 327 j = 0;
328 k = 0; 328 k = 0;
329 while (i < strLength && j < 2) 329 while (i < strLength && j < 2)
330 { 330 {
331 ch = dtStr[i]; 331 ch = dtStr[i];
332 k = k * 10 + ch - '0'; 332 k = k * 10 + ch - '0';
333 j ++; 333 j ++;
334 if (ch < '0' || ch > '9') break; 334 if (ch < '0' || ch > '9') break;
335 i ++; 335 i ++;
336 } 336 }
337 » » dt.tzMinute = (FX_BYTE)k; 337 » » dt.tzMinute = (uint8_t)k;
338 if (i >= strLength || j < 2) return *this; 338 if (i >= strLength || j < 2) return *this;
339 } 339 }
340 340
341 return *this; 341 return *this;
342 } 342 }
343 343
344 CFX_ByteString CPDFSDK_DateTime::ToCommonDateTimeString() 344 CFX_ByteString CPDFSDK_DateTime::ToCommonDateTimeString()
345 { 345 {
346 CFX_ByteString str1; 346 CFX_ByteString str1;
347 str1.Format("%04d-%02d-%02d %02d:%02d:%02d ", dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second); 347 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
395 dt.AddSeconds(-_gAfxGetTimeZoneInSeconds(dt.dt.tzHour, dt.dt.tzMinute)); 395 dt.AddSeconds(-_gAfxGetTimeZoneInSeconds(dt.dt.tzHour, dt.dt.tzMinute));
396 dt.dt.tzHour = 0; 396 dt.dt.tzHour = 0;
397 dt.dt.tzMinute = 0; 397 dt.dt.tzMinute = 0;
398 return dt; 398 return dt;
399 } 399 }
400 400
401 CPDFSDK_DateTime& CPDFSDK_DateTime::AddDays(short days) 401 CPDFSDK_DateTime& CPDFSDK_DateTime::AddDays(short days)
402 { 402 {
403 if (days == 0) return *this; 403 if (days == 0) return *this;
404 404
405 » FX_SHORT» y = dt.year, yy; 405 » int16_t»y = dt.year, yy;
406 » FX_BYTE»» m = dt.month; 406 » uint8_t»» m = dt.month;
407 » FX_BYTE»» d = dt.day; 407 » uint8_t»» d = dt.day;
408 int mdays, ydays, ldays; 408 int mdays, ydays, ldays;
409 409
410 ldays = days; 410 ldays = days;
411 if (ldays > 0) 411 if (ldays > 0)
412 { 412 {
413 yy = y; 413 yy = y;
414 if (((FX_WORD)m * 100 + d) > 300) yy ++; 414 if (((FX_WORD)m * 100 + d) > 300) yy ++;
415 ydays = _gAfxGetYearDays(yy); 415 ydays = _gAfxGetYearDays(yy);
416 while (ldays >= ydays) 416 while (ldays >= ydays)
417 { 417 {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 if (n < 0) 483 if (n < 0)
484 { 484 {
485 days = (n - 86399) / 86400; 485 days = (n - 86399) / 86400;
486 n -= days * 86400; 486 n -= days * 86400;
487 } 487 }
488 else 488 else
489 { 489 {
490 days = n / 86400; 490 days = n / 86400;
491 n %= 86400; 491 n %= 86400;
492 } 492 }
493 » dt.hour = (FX_BYTE)(n / 3600); 493 » dt.hour = (uint8_t)(n / 3600);
494 dt.hour %= 24; 494 dt.hour %= 24;
495 n %= 3600; 495 n %= 3600;
496 » dt.minute = (FX_BYTE)(n / 60); 496 » dt.minute = (uint8_t)(n / 60);
497 » dt.second = (FX_BYTE)(n % 60); 497 » dt.second = (uint8_t)(n % 60);
498 if (days != 0) AddDays(days); 498 if (days != 0) AddDays(days);
499 499
500 return *this; 500 return *this;
501 } 501 }
502 502
503 503
504 //--------------------------------------------------------------------------- 504 //---------------------------------------------------------------------------
505 // CPDFSDK_Annot 505 // CPDFSDK_Annot
506 //--------------------------------------------------------------------------- 506 //---------------------------------------------------------------------------
507 CPDFSDK_Annot::CPDFSDK_Annot(CPDFSDK_PageView* pPageView) : 507 CPDFSDK_Annot::CPDFSDK_Annot(CPDFSDK_PageView* pPageView) :
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 955
956 pParentDict = pAPTypeDict; 956 pParentDict = pAPTypeDict;
957 pStream = pAPTypeDict->GetStream(sAPState); 957 pStream = pAPTypeDict->GetStream(sAPState);
958 } 958 }
959 959
960 if (!pStream) 960 if (!pStream)
961 { 961 {
962 ASSERT(m_pPageView != NULL); 962 ASSERT(m_pPageView != NULL);
963 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); 963 CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
964 ASSERT(pDoc != NULL); 964 ASSERT(pDoc != NULL);
965 » » 965
966 pStream = FX_NEW CPDF_Stream(NULL, 0, NULL); 966 pStream = FX_NEW CPDF_Stream(NULL, 0, NULL);
967 » » FX_INT32 objnum = pDoc->AddIndirectObject(pStream); 967 » » int32_t objnum = pDoc->AddIndirectObject(pStream);
968 //pAPDict->SetAtReference(sAPType, pDoc, objnum); 968 //pAPDict->SetAtReference(sAPType, pDoc, objnum);
969 ASSERT(pParentDict != NULL); 969 ASSERT(pParentDict != NULL);
970 pParentDict->SetAtReference(sAPType, pDoc, objnum); 970 pParentDict->SetAtReference(sAPType, pDoc, objnum);
971 } 971 }
972 » 972
973 CPDF_Dictionary * pStreamDict = pStream->GetDict(); 973 CPDF_Dictionary * pStreamDict = pStream->GetDict();
974 974
975 if (!pStreamDict) 975 if (!pStreamDict)
976 { 976 {
977 pStreamDict = FX_NEW CPDF_Dictionary; 977 pStreamDict = FX_NEW CPDF_Dictionary;
978 pStreamDict->SetAtName("Type", "XObject"); 978 pStreamDict->SetAtName("Type", "XObject");
979 pStreamDict->SetAtName("Subtype", "Form"); 979 pStreamDict->SetAtName("Subtype", "Form");
980 pStreamDict->SetAtInteger("FormType", 1); 980 pStreamDict->SetAtInteger("FormType", 1);
981 pStream->InitStream(NULL,0,pStreamDict); 981 pStream->InitStream(NULL,0,pStreamDict);
982 } 982 }
983 983
984 if (pStreamDict) 984 if (pStreamDict)
985 { 985 {
986 pStreamDict->SetAtMatrix("Matrix",matrix); 986 pStreamDict->SetAtMatrix("Matrix",matrix);
987 pStreamDict->SetAtRect("BBox", rcBBox); 987 pStreamDict->SetAtRect("BBox", rcBBox);
988 } 988 }
989 989
990 » pStream->SetData((FX_BYTE*)sContents.c_str(), sContents.GetLength(), FAL SE, FALSE); 990 » pStream->SetData((uint8_t*)sContents.c_str(), sContents.GetLength(), FAL SE, FALSE);
991 } 991 }
992 992
993 #define BA_ANNOT_MINWIDTH 1 993 #define BA_ANNOT_MINWIDTH 1
994 #define BA_ANNOT_MINHEIGHT 1 994 #define BA_ANNOT_MINHEIGHT 1
995 995
996 FX_FLOAT CPDFSDK_Annot::GetMinWidth() const 996 FX_FLOAT CPDFSDK_Annot::GetMinWidth() const
997 { 997 {
998 return BA_ANNOT_MINWIDTH; 998 return BA_ANNOT_MINWIDTH;
999 } 999 }
1000 1000
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 return NULL; 1089 return NULL;
1090 } 1090 }
1091 1091
1092 CPDFXFA_Page* CPDFSDK_Annot::GetPDFXFAPage() 1092 CPDFXFA_Page* CPDFSDK_Annot::GetPDFXFAPage()
1093 { 1093 {
1094 if (m_pPageView) 1094 if (m_pPageView)
1095 return m_pPageView->GetPDFXFAPage(); 1095 return m_pPageView->GetPDFXFAPage();
1096 return NULL; 1096 return NULL;
1097 } 1097 }
1098 1098
OLDNEW
« no previous file with comments | « fpdfsdk/src/fsdk_actionhandler.cpp ('k') | fpdfsdk/src/fsdk_baseform.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698