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

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

Issue 1243953004: Re-land else-after-returns (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 5 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_annothandler.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/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, uint8_t 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(int16_t 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(int16_t 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 uint8_t _gAfxGetMonthDays(int16_t year, uint8_t month) 30 uint8_t _gAfxGetMonthDays(int16_t year, uint8_t month)
31 { 31 {
32 » uint8_t»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;
43 » » break; 43 break;
44 44
45 » case 4: 45 case 4:
46 » case 6: 46 case 6:
47 » case 9: 47 case 9:
48 » case 11: 48 case 11:
49 » » mDays = 30; 49 mDays = 30;
50 » » break; 50 break;
51 51
52 » case 2: 52 case 2:
53 » » if (_gAfxIsLeapYear(year) == TRUE) 53 if (_gAfxIsLeapYear(year) == TRUE)
54 » » » mDays = 29; 54 mDays = 29;
55 » » else 55 else
56 » » » mDays = 28; 56 mDays = 28;
57 » » break; 57 break;
58 58
59 » default: 59 default:
60 » » mDays = 0; 60 mDays = 0;
61 » » break; 61 break;
62 » } 62 }
63 63
64 » return mDays; 64 return mDays;
65 } 65 }
66 66
67 CPDFSDK_DateTime::CPDFSDK_DateTime() 67 CPDFSDK_DateTime::CPDFSDK_DateTime()
68 { 68 {
69 » ResetDateTime(); 69 ResetDateTime();
70 } 70 }
71 71
72 CPDFSDK_DateTime::CPDFSDK_DateTime(const CFX_ByteString& dtStr) 72 CPDFSDK_DateTime::CPDFSDK_DateTime(const CFX_ByteString& dtStr)
73 { 73 {
74 » ResetDateTime(); 74 ResetDateTime();
75 75
76 » FromPDFDateTimeString(dtStr); 76 FromPDFDateTimeString(dtStr);
77 } 77 }
78 78
79 CPDFSDK_DateTime::CPDFSDK_DateTime(const CPDFSDK_DateTime& datetime) 79 CPDFSDK_DateTime::CPDFSDK_DateTime(const CPDFSDK_DateTime& datetime)
80 { 80 {
81 » operator = (datetime); 81 operator = (datetime);
82 } 82 }
83 83
84 CPDFSDK_DateTime::CPDFSDK_DateTime(const FX_SYSTEMTIME& st) 84 CPDFSDK_DateTime::CPDFSDK_DateTime(const FX_SYSTEMTIME& st)
85 { 85 {
86 » operator = (st) ; 86 operator = (st) ;
87 } 87 }
88 88
89 89
90 void CPDFSDK_DateTime::ResetDateTime() 90 void CPDFSDK_DateTime::ResetDateTime()
91 { 91 {
92 » tzset(); 92 tzset();
93 93
94 » time_t» curTime; 94 time_t curTime;
95 » time(&curTime); 95 time(&curTime);
96 » struct tm* newtime; 96 struct tm* newtime;
97 » //newtime = gmtime(&curTime); 97 //newtime = gmtime(&curTime);
98 » newtime = localtime(&curTime); 98 newtime = localtime(&curTime);
99 99
100 » dt.year = newtime->tm_year + 1900; 100 dt.year = newtime->tm_year + 1900;
101 » dt.month = newtime->tm_mon + 1; 101 dt.month = newtime->tm_mon + 1;
102 » dt.day = newtime->tm_mday; 102 dt.day = newtime->tm_mday;
103 » dt.hour = newtime->tm_hour; 103 dt.hour = newtime->tm_hour;
104 » dt.minute = newtime->tm_min; 104 dt.minute = newtime->tm_min;
105 » dt.second = newtime->tm_sec; 105 dt.second = newtime->tm_sec;
106 // » dt.tzHour = _timezone / 3600 * -1; 106 // dt.tzHour = _timezone / 3600 * -1;
107 // » dt.tzMinute = (abs(_timezone) % 3600) / 60; 107 // dt.tzMinute = (abs(_timezone) % 3600) / 60;
108 } 108 }
109 109
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 = (int16_t)st.wYear; 120 dt.year = (int16_t)st.wYear;
121 » dt.month = (uint8_t)st.wMonth; 121 dt.month = (uint8_t)st.wMonth;
122 » dt.day = (uint8_t)st.wDay; 122 dt.day = (uint8_t)st.wDay;
123 » dt.hour = (uint8_t)st.wHour; 123 dt.hour = (uint8_t)st.wHour;
124 » dt.minute = (uint8_t)st.wMinute; 124 dt.minute = (uint8_t)st.wMinute;
125 » dt.second = (uint8_t)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
136 FX_BOOL CPDFSDK_DateTime::operator != (CPDFSDK_DateTime& datetime) 136 FX_BOOL CPDFSDK_DateTime::operator != (CPDFSDK_DateTime& datetime)
137 { 137 {
138 » return (FXSYS_memcmp(&dt, &datetime.dt, sizeof(FX_DATETIME)) != 0); 138 return (FXSYS_memcmp(&dt, &datetime.dt, sizeof(FX_DATETIME)) != 0);
139 } 139 }
140 140
141 FX_BOOL CPDFSDK_DateTime::operator > (CPDFSDK_DateTime& datetime) 141 FX_BOOL CPDFSDK_DateTime::operator > (CPDFSDK_DateTime& datetime)
142 { 142 {
143 » CPDFSDK_DateTime dt1 = ToGMT(); 143 CPDFSDK_DateTime dt1 = ToGMT();
144 » CPDFSDK_DateTime dt2 = datetime.ToGMT(); 144 CPDFSDK_DateTime dt2 = datetime.ToGMT();
145 » int d1 = (((int)dt1.dt.year) << 16) | (((int)dt1.dt.month) << 8) | (int) dt1.dt.day; 145 int d1 = (((int)dt1.dt.year) << 16) | (((int)dt1.dt.month) << 8) | (int)dt1. dt.day;
146 » int d2 = (((int)dt1.dt.hour) << 16) | (((int)dt1.dt.minute) << 8) | (int )dt1.dt.second; 146 int d2 = (((int)dt1.dt.hour) << 16) | (((int)dt1.dt.minute) << 8) | (int)dt1 .dt.second;
147 » int d3 = (((int)dt2.dt.year) << 16) | (((int)dt2.dt.month) << 8) | (int) dt2.dt.day; 147 int d3 = (((int)dt2.dt.year) << 16) | (((int)dt2.dt.month) << 8) | (int)dt2. dt.day;
148 » int d4 = (((int)dt2.dt.hour) << 16) | (((int)dt2.dt.minute) << 8) | (int )dt2.dt.second; 148 int d4 = (((int)dt2.dt.hour) << 16) | (((int)dt2.dt.minute) << 8) | (int)dt2 .dt.second;
149 149
150 » if (d1 > d3) return TRUE; 150 if (d1 > d3) return TRUE;
151 » if (d2 > d4) return TRUE; 151 if (d2 > d4) return TRUE;
152 » return FALSE; 152 return FALSE;
153 } 153 }
154 154
155 FX_BOOL CPDFSDK_DateTime::operator >= (CPDFSDK_DateTime& datetime) 155 FX_BOOL CPDFSDK_DateTime::operator >= (CPDFSDK_DateTime& datetime)
156 { 156 {
157 » CPDFSDK_DateTime dt1 = ToGMT(); 157 CPDFSDK_DateTime dt1 = ToGMT();
158 » CPDFSDK_DateTime dt2 = datetime.ToGMT(); 158 CPDFSDK_DateTime dt2 = datetime.ToGMT();
159 » int d1 = (((int)dt1.dt.year) << 16) | (((int)dt1.dt.month) << 8) | (int) dt1.dt.day; 159 int d1 = (((int)dt1.dt.year) << 16) | (((int)dt1.dt.month) << 8) | (int)dt1. dt.day;
160 » int d2 = (((int)dt1.dt.hour) << 16) | (((int)dt1.dt.minute) << 8) | (int )dt1.dt.second; 160 int d2 = (((int)dt1.dt.hour) << 16) | (((int)dt1.dt.minute) << 8) | (int)dt1 .dt.second;
161 » int d3 = (((int)dt2.dt.year) << 16) | (((int)dt2.dt.month) << 8) | (int) dt2.dt.day; 161 int d3 = (((int)dt2.dt.year) << 16) | (((int)dt2.dt.month) << 8) | (int)dt2. dt.day;
162 » int d4 = (((int)dt2.dt.hour) << 16) | (((int)dt2.dt.minute) << 8) | (int )dt2.dt.second; 162 int d4 = (((int)dt2.dt.hour) << 16) | (((int)dt2.dt.minute) << 8) | (int)dt2 .dt.second;
163 163
164 » if (d1 >= d3) return TRUE; 164 if (d1 >= d3) return TRUE;
165 » if (d2 >= d4) return TRUE; 165 if (d2 >= d4) return TRUE;
166 » return FALSE; 166 return FALSE;
167 } 167 }
168 168
169 FX_BOOL CPDFSDK_DateTime::operator < (CPDFSDK_DateTime& datetime) 169 FX_BOOL CPDFSDK_DateTime::operator < (CPDFSDK_DateTime& datetime)
170 { 170 {
171 » CPDFSDK_DateTime dt1 = ToGMT(); 171 CPDFSDK_DateTime dt1 = ToGMT();
172 » CPDFSDK_DateTime dt2 = datetime.ToGMT(); 172 CPDFSDK_DateTime dt2 = datetime.ToGMT();
173 » int d1 = (((int)dt1.dt.year) << 16) | (((int)dt1.dt.month) << 8) | (int) dt1.dt.day; 173 int d1 = (((int)dt1.dt.year) << 16) | (((int)dt1.dt.month) << 8) | (int)dt1. dt.day;
174 » int d2 = (((int)dt1.dt.hour) << 16) | (((int)dt1.dt.minute) << 8) | (int )dt1.dt.second; 174 int d2 = (((int)dt1.dt.hour) << 16) | (((int)dt1.dt.minute) << 8) | (int)dt1 .dt.second;
175 » int d3 = (((int)dt2.dt.year) << 16) | (((int)dt2.dt.month) << 8) | (int) dt2.dt.day; 175 int d3 = (((int)dt2.dt.year) << 16) | (((int)dt2.dt.month) << 8) | (int)dt2. dt.day;
176 » int d4 = (((int)dt2.dt.hour) << 16) | (((int)dt2.dt.minute) << 8) | (int )dt2.dt.second; 176 int d4 = (((int)dt2.dt.hour) << 16) | (((int)dt2.dt.minute) << 8) | (int)dt2 .dt.second;
177 177
178 » if (d1 < d3) return TRUE; 178 if (d1 < d3) return TRUE;
179 » if (d2 < d4) return TRUE; 179 if (d2 < d4) return TRUE;
180 » return FALSE; 180 return FALSE;
181 } 181 }
182 182
183 FX_BOOL CPDFSDK_DateTime::operator <= (CPDFSDK_DateTime& datetime) 183 FX_BOOL CPDFSDK_DateTime::operator <= (CPDFSDK_DateTime& datetime)
184 { 184 {
185 » CPDFSDK_DateTime dt1 = ToGMT(); 185 CPDFSDK_DateTime dt1 = ToGMT();
186 » CPDFSDK_DateTime dt2 = datetime.ToGMT(); 186 CPDFSDK_DateTime dt2 = datetime.ToGMT();
187 » int d1 = (((int)dt1.dt.year) << 16) | (((int)dt1.dt.month) << 8) | (int) dt1.dt.day; 187 int d1 = (((int)dt1.dt.year) << 16) | (((int)dt1.dt.month) << 8) | (int)dt1. dt.day;
188 » int d2 = (((int)dt1.dt.hour) << 16) | (((int)dt1.dt.minute) << 8) | (int )dt1.dt.second; 188 int d2 = (((int)dt1.dt.hour) << 16) | (((int)dt1.dt.minute) << 8) | (int)dt1 .dt.second;
189 » int d3 = (((int)dt2.dt.year) << 16) | (((int)dt2.dt.month) << 8) | (int) dt2.dt.day; 189 int d3 = (((int)dt2.dt.year) << 16) | (((int)dt2.dt.month) << 8) | (int)dt2. dt.day;
190 » int d4 = (((int)dt2.dt.hour) << 16) | (((int)dt2.dt.minute) << 8) | (int )dt2.dt.second; 190 int d4 = (((int)dt2.dt.hour) << 16) | (((int)dt2.dt.minute) << 8) | (int)dt2 .dt.second;
191 191
192 » if (d1 <= d3) return TRUE; 192 if (d1 <= d3) return TRUE;
193 » if (d2 <= d4) return TRUE; 193 if (d2 <= d4) return TRUE;
194 » return FALSE; 194 return FALSE;
195 } 195 }
196 196
197 CPDFSDK_DateTime::operator time_t() 197 CPDFSDK_DateTime::operator time_t()
198 { 198 {
199 » struct tm newtime; 199 struct tm newtime;
200 200
201 » newtime.tm_year = dt.year - 1900; 201 newtime.tm_year = dt.year - 1900;
202 » newtime.tm_mon = dt.month - 1; 202 newtime.tm_mon = dt.month - 1;
203 » newtime.tm_mday = dt.day; 203 newtime.tm_mday = dt.day;
204 » newtime.tm_hour = dt.hour; 204 newtime.tm_hour = dt.hour;
205 » newtime.tm_min = dt.minute; 205 newtime.tm_min = dt.minute;
206 » newtime.tm_sec = dt.second; 206 newtime.tm_sec = dt.second;
207 207
208 » return mktime(&newtime); 208 return mktime(&newtime);
209 } 209 }
210 210
211 CPDFSDK_DateTime& CPDFSDK_DateTime::FromPDFDateTimeString(const CFX_ByteString& dtStr) 211 CPDFSDK_DateTime& CPDFSDK_DateTime::FromPDFDateTimeString(const CFX_ByteString& dtStr)
212 { 212 {
213 » int strLength = dtStr.GetLength(); 213 int strLength = dtStr.GetLength();
214 » if (strLength > 0) 214 if (strLength > 0)
215 » { 215 {
216 » » int i = 0; 216 int i = 0;
217 » » int j, k; 217 int j, k;
218 » » FX_CHAR ch; 218 FX_CHAR ch;
219 » » while (i < strLength) 219 while (i < strLength)
220 » » { 220 {
221 » » » ch = dtStr[i]; 221 ch = dtStr[i];
222 » » » if (ch >= '0' && ch <= '9') break; 222 if (ch >= '0' && ch <= '9') break;
223 » » » i ++; 223 i ++;
224 » » } 224 }
225 » » if (i >= strLength) return *this; 225 if (i >= strLength) return *this;
226 226
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 = (int16_t)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 = (uint8_t)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 = (uint8_t)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 = (uint8_t)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 = (uint8_t)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 = (uint8_t)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;
313 » » while (i < strLength && j < 2) 313 while (i < strLength && j < 2)
314 » » { 314 {
315 » » » ch = dtStr[i]; 315 ch = dtStr[i];
316 » » » k = k * 10 + ch - '0'; 316 k = k * 10 + ch - '0';
317 » » » j ++; 317 j ++;
318 » » » if (ch < '0' || ch > '9') break; 318 if (ch < '0' || ch > '9') break;
319 » » » i ++; 319 i ++;
320 » » } 320 }
321 » » dt.tzHour *= (FX_CHAR)k; 321 dt.tzHour *= (FX_CHAR)k;
322 » » if (i >= strLength || j < 2) return *this; 322 if (i >= strLength || j < 2) return *this;
323 323
324 » » ch = dtStr[i ++]; 324 ch = dtStr[i ++];
325 » » if (ch != '\'') return *this; 325 if (ch != '\'') return *this;
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 = (uint8_t)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);
347 » if (dt.tzHour < 0) 347 if (dt.tzHour < 0)
348 » » str1 += "-"; 348 str1 += "-";
349 » else 349 else
350 » » str1 += "+"; 350 str1 += "+";
351 » CFX_ByteString str2; 351 CFX_ByteString str2;
352 » str2.Format("%02d:%02d", abs(dt.tzHour), dt.tzMinute); 352 str2.Format("%02d:%02d", abs(dt.tzHour), dt.tzMinute);
353 » return str1 + str2; 353 return str1 + str2;
354 } 354 }
355 355
356 CFX_ByteString CPDFSDK_DateTime::ToPDFDateTimeString() 356 CFX_ByteString CPDFSDK_DateTime::ToPDFDateTimeString()
357 { 357 {
358 » CFX_ByteString dtStr; 358 CFX_ByteString dtStr;
359 » char tempStr[32]; 359 char tempStr[32];
360 » memset(tempStr, 0, sizeof(tempStr)); 360 memset(tempStr, 0, sizeof(tempStr));
361 » FXSYS_snprintf(tempStr, sizeof(tempStr) - 1, "D:%04d%02d%02d%02d%02d%02d ", 361 FXSYS_snprintf(tempStr, sizeof(tempStr) - 1, "D:%04d%02d%02d%02d%02d%02d",
362 dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second); 362 dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second);
363 » dtStr = CFX_ByteString(tempStr); 363 dtStr = CFX_ByteString(tempStr);
364 » if (dt.tzHour < 0) 364 if (dt.tzHour < 0)
365 » » dtStr += CFX_ByteString("-"); 365 dtStr += CFX_ByteString("-");
366 » else 366 else
367 » » dtStr += CFX_ByteString("+"); 367 dtStr += CFX_ByteString("+");
368 » memset(tempStr, 0, sizeof(tempStr)); 368 memset(tempStr, 0, sizeof(tempStr));
369 » FXSYS_snprintf(tempStr, sizeof(tempStr) - 1, "%02d'%02d'", abs(dt.tzHour ), dt.tzMinute); 369 FXSYS_snprintf(tempStr, sizeof(tempStr) - 1, "%02d'%02d'", abs(dt.tzHour), d t.tzMinute);
370 » dtStr += CFX_ByteString(tempStr); 370 dtStr += CFX_ByteString(tempStr);
371 » return dtStr; 371 return dtStr;
372 } 372 }
373 373
374 void CPDFSDK_DateTime::ToSystemTime(FX_SYSTEMTIME& st) 374 void CPDFSDK_DateTime::ToSystemTime(FX_SYSTEMTIME& st)
375 { 375 {
376 » CPDFSDK_DateTime dt = *this; 376 CPDFSDK_DateTime dt = *this;
377 » time_t t = (time_t)dt; 377 time_t t = (time_t)dt;
378 » struct tm* pTime = localtime(&t); 378 struct tm* pTime = localtime(&t);
379 » if(pTime){ 379 if(pTime){
380 » » st.wYear = (FX_WORD)pTime->tm_year + 1900; 380 st.wYear = (FX_WORD)pTime->tm_year + 1900;
381 » » st.wMonth = (FX_WORD)pTime->tm_mon + 1; 381 st.wMonth = (FX_WORD)pTime->tm_mon + 1;
382 » » st.wDay = (FX_WORD)pTime->tm_mday; 382 st.wDay = (FX_WORD)pTime->tm_mday;
383 » » st.wDayOfWeek = (FX_WORD)pTime->tm_wday; 383 st.wDayOfWeek = (FX_WORD)pTime->tm_wday;
384 » » st.wHour = (FX_WORD)pTime->tm_hour; 384 st.wHour = (FX_WORD)pTime->tm_hour;
385 » » st.wMinute = (FX_WORD)pTime->tm_min; 385 st.wMinute = (FX_WORD)pTime->tm_min;
386 » » st.wSecond = (FX_WORD)pTime->tm_sec; 386 st.wSecond = (FX_WORD)pTime->tm_sec;
387 » » st.wMilliseconds = 0; 387 st.wMilliseconds = 0;
388 » } 388 }
389 } 389 }
390 390
391 CPDFSDK_DateTime CPDFSDK_DateTime::ToGMT() 391 CPDFSDK_DateTime CPDFSDK_DateTime::ToGMT()
392 { 392 {
393 » CPDFSDK_DateTime dt = *this; 393 CPDFSDK_DateTime dt = *this;
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 » int16_t»y = dt.year, yy; 404 int16_t y = dt.year, yy;
405 » uint8_t»» m = dt.month; 405 uint8_t m = dt.month;
406 » uint8_t»» 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 {
417 » » » y ++; 417 y ++;
418 » » » ldays -= ydays; 418 ldays -= ydays;
419 » » » yy ++; 419 yy ++;
420 » » » mdays = _gAfxGetMonthDays(y, m); 420 mdays = _gAfxGetMonthDays(y, m);
421 » » » if (d > mdays) 421 if (d > mdays)
422 » » » { 422 {
423 » » » » m ++; 423 m ++;
424 » » » » d -= mdays; 424 d -= mdays;
425 » » » } 425 }
426 » » » ydays = _gAfxGetYearDays(yy); 426 ydays = _gAfxGetYearDays(yy);
427 » » } 427 }
428 » » mdays = _gAfxGetMonthDays(y, m) - d + 1; 428 mdays = _gAfxGetMonthDays(y, m) - d + 1;
429 » » while (ldays >= mdays) 429 while (ldays >= mdays)
430 » » { 430 {
431 » » » ldays -= mdays; 431 ldays -= mdays;
432 » » » m ++; 432 m ++;
433 » » » d = 1; 433 d = 1;
434 » » » mdays = _gAfxGetMonthDays(y, m); 434 mdays = _gAfxGetMonthDays(y, m);
435 » » } 435 }
436 » » d += ldays; 436 d += ldays;
437 » } 437 }
438 » else 438 else
439 » { 439 {
440 » » ldays *= -1; 440 ldays *= -1;
441 » » yy = y; 441 yy = y;
442 » » if (((FX_WORD)m * 100 + d) < 300) yy --; 442 if (((FX_WORD)m * 100 + d) < 300) yy --;
443 » » ydays = _gAfxGetYearDays(yy); 443 ydays = _gAfxGetYearDays(yy);
444 » » while (ldays >= ydays) 444 while (ldays >= ydays)
445 » » { 445 {
446 » » » y --; 446 y --;
447 » » » ldays -= ydays; 447 ldays -= ydays;
448 » » » yy --; 448 yy --;
449 » » » mdays = _gAfxGetMonthDays(y, m); 449 mdays = _gAfxGetMonthDays(y, m);
450 » » » if (d > mdays) 450 if (d > mdays)
451 » » » { 451 {
452 » » » » m ++; 452 m ++;
453 » » » » d -= mdays; 453 d -= mdays;
454 » » » } 454 }
455 » » » ydays = _gAfxGetYearDays(yy); 455 ydays = _gAfxGetYearDays(yy);
456 » » } 456 }
457 » » while (ldays >= d) 457 while (ldays >= d)
458 » » { 458 {
459 » » » ldays -= d; 459 ldays -= d;
460 » » » m --; 460 m --;
461 » » » mdays = _gAfxGetMonthDays(y, m); 461 mdays = _gAfxGetMonthDays(y, m);
462 » » » d = mdays; 462 d = mdays;
463 » » } 463 }
464 » » d -= ldays; 464 d -= ldays;
465 » } 465 }
466 466
467 » dt.year = y; 467 dt.year = y;
468 » dt.month = m; 468 dt.month = m;
469 » dt.day = d; 469 dt.day = d;
470 470
471 » return *this; 471 return *this;
472 } 472 }
473 473
474 CPDFSDK_DateTime& CPDFSDK_DateTime::AddSeconds(int seconds) 474 CPDFSDK_DateTime& CPDFSDK_DateTime::AddSeconds(int seconds)
475 { 475 {
476 » if (seconds == 0) return *this; 476 if (seconds == 0) return *this;
477 477
478 » int» n; 478 int n;
479 » int» days; 479 int days;
480 480
481 » n = dt.hour * 3600 + dt.minute * 60 + dt.second + seconds; 481 n = dt.hour * 3600 + dt.minute * 60 + dt.second + seconds;
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 = (uint8_t)(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 = (uint8_t)(n / 60); 495 dt.minute = (uint8_t)(n / 60);
496 » dt.second = (uint8_t)(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) :
507 m_pAnnot(pAnnot), 507 m_pAnnot(pAnnot),
508 m_pPageView(pPageView), 508 m_pPageView(pPageView),
509 m_bSelected(FALSE), 509 m_bSelected(FALSE),
510 m_nTabOrder(-1) 510 m_nTabOrder(-1)
511 { 511 {
512 } 512 }
513 513
514 CPDFSDK_Annot::~CPDFSDK_Annot() 514 CPDFSDK_Annot::~CPDFSDK_Annot()
515 { 515 {
516 » m_pAnnot = NULL; 516 m_pAnnot = NULL;
517 » m_pPageView = NULL; 517 m_pPageView = NULL;
518 } 518 }
519 519
520 CPDF_Annot*» CPDFSDK_Annot::GetPDFAnnot() 520 CPDF_Annot* CPDFSDK_Annot::GetPDFAnnot()
521 { 521 {
522 » return m_pAnnot; 522 return m_pAnnot;
523 } 523 }
524 524
525 FX_DWORD CPDFSDK_Annot::GetFlags() 525 FX_DWORD CPDFSDK_Annot::GetFlags()
526 { 526 {
527 » ASSERT(m_pAnnot != NULL); 527 ASSERT(m_pAnnot != NULL);
528 528
529 » return m_pAnnot->GetFlags(); 529 return m_pAnnot->GetFlags();
530 } 530 }
531 531
532 void CPDFSDK_Annot::SetPage(CPDFSDK_PageView* pPageView) 532 void CPDFSDK_Annot::SetPage(CPDFSDK_PageView* pPageView)
533 { 533 {
534 » m_pPageView = pPageView; 534 m_pPageView = pPageView;
535 } 535 }
536 536
537 CPDFSDK_PageView* CPDFSDK_Annot::GetPageView() 537 CPDFSDK_PageView* CPDFSDK_Annot::GetPageView()
538 { 538 {
539 » return m_pPageView; 539 return m_pPageView;
540 } 540 }
541 541
542 FX_BOOL CPDFSDK_Annot::IsSelected() 542 FX_BOOL CPDFSDK_Annot::IsSelected()
543 { 543 {
544 » return m_bSelected; 544 return m_bSelected;
545 } 545 }
546 546
547 void CPDFSDK_Annot::SetSelected(FX_BOOL bSelected) 547 void CPDFSDK_Annot::SetSelected(FX_BOOL bSelected)
548 { 548 {
549 » m_bSelected = bSelected; 549 m_bSelected = bSelected;
550 } 550 }
551 551
552 // Tab Order 552 // Tab Order
553 int CPDFSDK_Annot::GetTabOrder() 553 int CPDFSDK_Annot::GetTabOrder()
554 { 554 {
555 » return m_nTabOrder; 555 return m_nTabOrder;
556 } 556 }
557 557
558 void CPDFSDK_Annot::SetTabOrder(int iTabOrder) 558 void CPDFSDK_Annot::SetTabOrder(int iTabOrder)
559 { 559 {
560 » m_nTabOrder = iTabOrder; 560 m_nTabOrder = iTabOrder;
561 } 561 }
562 562
563 CPDF_Dictionary* CPDFSDK_Annot::GetAnnotDict() const 563 CPDF_Dictionary* CPDFSDK_Annot::GetAnnotDict() const
564 { 564 {
565 » ASSERT(m_pAnnot != NULL); 565 ASSERT(m_pAnnot != NULL);
566 566
567 » return m_pAnnot->GetAnnotDict(); 567 return m_pAnnot->GetAnnotDict();
568 } 568 }
569 569
570 void CPDFSDK_Annot::SetRect(const CPDF_Rect& rect) 570 void CPDFSDK_Annot::SetRect(const CPDF_Rect& rect)
571 { 571 {
572 » ASSERT(rect.right - rect.left >= GetMinWidth()); 572 ASSERT(rect.right - rect.left >= GetMinWidth());
573 » ASSERT(rect.top - rect.bottom >= GetMinHeight()); 573 ASSERT(rect.top - rect.bottom >= GetMinHeight());
574 574
575 » m_pAnnot->GetAnnotDict()->SetAtRect("Rect", rect); 575 m_pAnnot->GetAnnotDict()->SetAtRect("Rect", rect);
576 } 576 }
577 577
578 CPDF_Rect CPDFSDK_Annot::GetRect() const 578 CPDF_Rect CPDFSDK_Annot::GetRect() const
579 { 579 {
580 » ASSERT(m_pAnnot != NULL); 580 ASSERT(m_pAnnot != NULL);
581 581
582 » CPDF_Rect rect; 582 CPDF_Rect rect;
583 » m_pAnnot->GetRect(rect); 583 m_pAnnot->GetRect(rect);
584 584
585 » return rect; 585 return rect;
586 } 586 }
587 587
588 CFX_ByteString CPDFSDK_Annot::GetType() const 588 CFX_ByteString CPDFSDK_Annot::GetType() const
589 { 589 {
590 » ASSERT(m_pAnnot != NULL); 590 ASSERT(m_pAnnot != NULL);
591 591
592 » return m_pAnnot->GetSubType(); 592 return m_pAnnot->GetSubType();
593 } 593 }
594 594
595 CFX_ByteString CPDFSDK_Annot::GetSubType() const 595 CFX_ByteString CPDFSDK_Annot::GetSubType() const
596 { 596 {
597 » return ""; 597 return "";
598 } 598 }
599 599
600 void CPDFSDK_Annot::DrawAppearance(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUser2Device, 600 void CPDFSDK_Annot::DrawAppearance(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUser2Device,
601 » » » » » » » » CPDF_Annot::A ppearanceMode mode, const CPDF_RenderOptions* pOptions) 601 CPDF_Annot::AppearanceMode mode, const CPDF_R enderOptions* pOptions)
602 { 602 {
603 » ASSERT(m_pPageView != NULL); 603 ASSERT(m_pPageView != NULL);
604 » ASSERT(m_pAnnot != NULL); 604 ASSERT(m_pAnnot != NULL);
605 605
606 » m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, pUser2Devic e, mode, pOptions); 606 m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, pUser2Device, m ode, pOptions);
607 } 607 }
608 608
609 FX_BOOL»CPDFSDK_Annot::IsAppearanceValid() 609 FX_BOOL CPDFSDK_Annot::IsAppearanceValid()
610 { 610 {
611 » return m_pAnnot->GetAnnotDict()->GetDict("AP") != NULL; 611 return m_pAnnot->GetAnnotDict()->GetDict("AP") != NULL;
612 } 612 }
613 613
614 FX_BOOL»CPDFSDK_Annot::IsAppearanceValid(CPDF_Annot::AppearanceMode mode) 614 FX_BOOL CPDFSDK_Annot::IsAppearanceValid(CPDF_Annot::AppearanceMode mode)
615 { 615 {
616 » CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDict("AP"); 616 CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDict("AP");
617 » if (pAP == NULL) return FALSE; 617 if (pAP == NULL) return FALSE;
618 618
619 » // Choose the right sub-ap 619 // Choose the right sub-ap
620 » const FX_CHAR* ap_entry = "N"; 620 const FX_CHAR* ap_entry = "N";
621 » if (mode == CPDF_Annot::Down) 621 if (mode == CPDF_Annot::Down)
622 » » ap_entry = "D"; 622 ap_entry = "D";
623 » else if (mode == CPDF_Annot::Rollover) 623 else if (mode == CPDF_Annot::Rollover)
624 » » ap_entry = "R"; 624 ap_entry = "R";
625 » if (!pAP->KeyExist(ap_entry)) 625 if (!pAP->KeyExist(ap_entry))
626 » » ap_entry = "N"; 626 ap_entry = "N";
627 627
628 » // Get the AP stream or subdirectory 628 // Get the AP stream or subdirectory
629 » CPDF_Object* psub = pAP->GetElementValue(ap_entry); 629 CPDF_Object* psub = pAP->GetElementValue(ap_entry);
630 » if (psub == NULL) return FALSE; 630 if (psub == NULL) return FALSE;
631 631
632 » return TRUE; 632 return TRUE;
633 } 633 }
634 634
635 void CPDFSDK_Annot::DrawBorder(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUs er2Device, 635 void CPDFSDK_Annot::DrawBorder(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUs er2Device,
636 » » » » » » const CPDF_RenderOptions* pOp tions) 636 const CPDF_RenderOptions* pOptions)
637 { 637 {
638 » ASSERT(m_pAnnot != NULL); 638 ASSERT(m_pAnnot != NULL);
639 » m_pAnnot->DrawBorder(pDevice, pUser2Device, pOptions); 639 m_pAnnot->DrawBorder(pDevice, pUser2Device, pOptions);
640 } 640 }
641 641
642 void CPDFSDK_Annot::ClearCachedAP() 642 void CPDFSDK_Annot::ClearCachedAP()
643 { 643 {
644 » ASSERT(m_pAnnot != NULL); 644 ASSERT(m_pAnnot != NULL);
645 » m_pAnnot->ClearCachedAP(); 645 m_pAnnot->ClearCachedAP();
646 } 646 }
647 647
648 void CPDFSDK_Annot::SetContents(const CFX_WideString& sContents) 648 void CPDFSDK_Annot::SetContents(const CFX_WideString& sContents)
649 { 649 {
650 » if (sContents.IsEmpty()) 650 if (sContents.IsEmpty())
651 » » m_pAnnot->GetAnnotDict()->RemoveAt("Contents"); 651 m_pAnnot->GetAnnotDict()->RemoveAt("Contents");
652 » else 652 else
653 » » m_pAnnot->GetAnnotDict()->SetAtString("Contents", PDF_EncodeText (sContents)); 653 m_pAnnot->GetAnnotDict()->SetAtString("Contents", PDF_EncodeText(sConten ts));
654 } 654 }
655 655
656 CFX_WideString CPDFSDK_Annot::GetContents() const 656 CFX_WideString CPDFSDK_Annot::GetContents() const
657 { 657 {
658 » return m_pAnnot->GetAnnotDict()->GetUnicodeText("Contents"); 658 return m_pAnnot->GetAnnotDict()->GetUnicodeText("Contents");
659 } 659 }
660 660
661 void CPDFSDK_Annot::SetAnnotName(const CFX_WideString& sName) 661 void CPDFSDK_Annot::SetAnnotName(const CFX_WideString& sName)
662 { 662 {
663 » if (sName.IsEmpty()) 663 if (sName.IsEmpty())
664 » » m_pAnnot->GetAnnotDict()->RemoveAt("NM"); 664 m_pAnnot->GetAnnotDict()->RemoveAt("NM");
665 » else 665 else
666 » » m_pAnnot->GetAnnotDict()->SetAtString("NM", PDF_EncodeText(sName )); 666 m_pAnnot->GetAnnotDict()->SetAtString("NM", PDF_EncodeText(sName));
667 } 667 }
668 668
669 CFX_WideString CPDFSDK_Annot::GetAnnotName() const 669 CFX_WideString CPDFSDK_Annot::GetAnnotName() const
670 { 670 {
671 » return m_pAnnot->GetAnnotDict()->GetUnicodeText("NM"); 671 return m_pAnnot->GetAnnotDict()->GetUnicodeText("NM");
672 } 672 }
673 673
674 void CPDFSDK_Annot::SetModifiedDate(const FX_SYSTEMTIME& st) 674 void CPDFSDK_Annot::SetModifiedDate(const FX_SYSTEMTIME& st)
675 { 675 {
676 » CPDFSDK_DateTime dt(st); 676 CPDFSDK_DateTime dt(st);
677 » CFX_ByteString str = dt.ToPDFDateTimeString(); 677 CFX_ByteString str = dt.ToPDFDateTimeString();
678 678
679 » if (str.IsEmpty()) 679 if (str.IsEmpty())
680 » » m_pAnnot->GetAnnotDict()->RemoveAt("M"); 680 m_pAnnot->GetAnnotDict()->RemoveAt("M");
681 » else 681 else
682 » » m_pAnnot->GetAnnotDict()->SetAtString("M", str); 682 m_pAnnot->GetAnnotDict()->SetAtString("M", str);
683 } 683 }
684 684
685 FX_SYSTEMTIME CPDFSDK_Annot::GetModifiedDate() const 685 FX_SYSTEMTIME CPDFSDK_Annot::GetModifiedDate() const
686 { 686 {
687 » FX_SYSTEMTIME systime; 687 FX_SYSTEMTIME systime;
688 » CFX_ByteString str = m_pAnnot->GetAnnotDict()->GetString("M"); 688 CFX_ByteString str = m_pAnnot->GetAnnotDict()->GetString("M");
689 689
690 » CPDFSDK_DateTime dt(str); 690 CPDFSDK_DateTime dt(str);
691 » dt.ToSystemTime(systime); 691 dt.ToSystemTime(systime);
692 692
693 » return systime; 693 return systime;
694 } 694 }
695 695
696 void CPDFSDK_Annot::SetFlags(int nFlags) 696 void CPDFSDK_Annot::SetFlags(int nFlags)
697 { 697 {
698 » m_pAnnot->GetAnnotDict()->SetAtInteger("F", nFlags); 698 m_pAnnot->GetAnnotDict()->SetAtInteger("F", nFlags);
699 } 699 }
700 700
701 int CPDFSDK_Annot::GetFlags() const 701 int CPDFSDK_Annot::GetFlags() const
702 { 702 {
703 » return m_pAnnot->GetAnnotDict()->GetInteger("F"); 703 return m_pAnnot->GetAnnotDict()->GetInteger("F");
704 } 704 }
705 705
706 void CPDFSDK_Annot::SetAppState(const CFX_ByteString& str) 706 void CPDFSDK_Annot::SetAppState(const CFX_ByteString& str)
707 { 707 {
708 » if (str.IsEmpty()) 708 if (str.IsEmpty())
709 » » m_pAnnot->GetAnnotDict()->RemoveAt("AS"); 709 m_pAnnot->GetAnnotDict()->RemoveAt("AS");
710 » else 710 else
711 » » m_pAnnot->GetAnnotDict()->SetAtString("AS", str); 711 m_pAnnot->GetAnnotDict()->SetAtString("AS", str);
712 } 712 }
713 713
714 CFX_ByteString CPDFSDK_Annot::GetAppState() const 714 CFX_ByteString CPDFSDK_Annot::GetAppState() const
715 { 715 {
716 » return m_pAnnot->GetAnnotDict()->GetString("AS"); 716 return m_pAnnot->GetAnnotDict()->GetString("AS");
717 } 717 }
718 718
719 void CPDFSDK_Annot::SetStructParent(int key) 719 void CPDFSDK_Annot::SetStructParent(int key)
720 { 720 {
721 » m_pAnnot->GetAnnotDict()->SetAtInteger("StructParent", key); 721 m_pAnnot->GetAnnotDict()->SetAtInteger("StructParent", key);
722 } 722 }
723 723
724 int» CPDFSDK_Annot::GetStructParent() const 724 int CPDFSDK_Annot::GetStructParent() const
725 { 725 {
726 » return m_pAnnot->GetAnnotDict()->GetInteger("StructParent"); 726 return m_pAnnot->GetAnnotDict()->GetInteger("StructParent");
727 } 727 }
728 728
729 //border 729 //border
730 void CPDFSDK_Annot::SetBorderWidth(int nWidth) 730 void CPDFSDK_Annot::SetBorderWidth(int nWidth)
731 { 731 {
732 » CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArray("Border"); 732 CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArray("Border");
733 733
734 » if (pBorder) 734 if (pBorder)
735 » { 735 {
736 » » pBorder->SetAt(2, new CPDF_Number(nWidth)); 736 pBorder->SetAt(2, new CPDF_Number(nWidth));
737 » } 737 }
738 » else 738 else
739 » { 739 {
740 » » CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS "); 740 CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS");
741 741
742 » » if (!pBSDict) 742 if (!pBSDict)
743 » » { 743 {
744 » » » pBSDict = new CPDF_Dictionary; 744 pBSDict = new CPDF_Dictionary;
745 » » » m_pAnnot->GetAnnotDict()->SetAt("BS", pBSDict); 745 m_pAnnot->GetAnnotDict()->SetAt("BS", pBSDict);
746 » » } 746 }
747 747
748 » » pBSDict->SetAtInteger("W", nWidth); 748 pBSDict->SetAtInteger("W", nWidth);
749 » } 749 }
750 } 750 }
751 751
752 int» CPDFSDK_Annot::GetBorderWidth() const 752 int CPDFSDK_Annot::GetBorderWidth() const
753 { 753 {
754 » CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArray("Border"); 754 if (CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArray("Border")) {
755 755 return pBorder->GetInteger(2);
756 » if (pBorder) 756 }
757 » { 757 if (CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS")) {
758 » » return pBorder->GetInteger(2); 758 return pBSDict->GetInteger("W", 1);
759 » } 759 }
760 » else 760 return 1;
761 » {
762 » » CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS ");
763
764 » » if (pBSDict)
765 » » {
766 » » » return pBSDict->GetInteger("W", 1);
767 » » }
768 » }
769 » return 1;
770 } 761 }
771 762
772 void CPDFSDK_Annot::SetBorderStyle(int nStyle) 763 void CPDFSDK_Annot::SetBorderStyle(int nStyle)
773 { 764 {
774 » CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS"); 765 CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS");
775 » if (!pBSDict) 766 if (!pBSDict)
776 » { 767 {
777 » » pBSDict = new CPDF_Dictionary; 768 pBSDict = new CPDF_Dictionary;
778 » » m_pAnnot->GetAnnotDict()->SetAt("BS", pBSDict); 769 m_pAnnot->GetAnnotDict()->SetAt("BS", pBSDict);
779 » } 770 }
780 771
781 » switch (nStyle) 772 switch (nStyle)
782 » { 773 {
783 » case BBS_SOLID: 774 case BBS_SOLID:
784 » » pBSDict->SetAtName("S", "S"); 775 pBSDict->SetAtName("S", "S");
785 » » break; 776 break;
786 » case BBS_DASH: 777 case BBS_DASH:
787 » » pBSDict->SetAtName("S", "D"); 778 pBSDict->SetAtName("S", "D");
788 » » break; 779 break;
789 » case BBS_BEVELED: 780 case BBS_BEVELED:
790 » » pBSDict->SetAtName("S", "B"); 781 pBSDict->SetAtName("S", "B");
791 » » break; 782 break;
792 » case BBS_INSET: 783 case BBS_INSET:
793 » » pBSDict->SetAtName("S", "I"); 784 pBSDict->SetAtName("S", "I");
794 » » break; 785 break;
795 » case BBS_UNDERLINE: 786 case BBS_UNDERLINE:
796 » » pBSDict->SetAtName("S", "U"); 787 pBSDict->SetAtName("S", "U");
797 » » break; 788 break;
798 » } 789 }
799 } 790 }
800 791
801 int» CPDFSDK_Annot::GetBorderStyle() const 792 int CPDFSDK_Annot::GetBorderStyle() const
802 { 793 {
803 » CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS"); 794 CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS");
804 » if (pBSDict) 795 if (pBSDict)
805 » { 796 {
806 » » CFX_ByteString sBorderStyle = pBSDict->GetString("S", "S"); 797 CFX_ByteString sBorderStyle = pBSDict->GetString("S", "S");
807 » » if (sBorderStyle == "S") return BBS_SOLID; 798 if (sBorderStyle == "S") return BBS_SOLID;
808 » » if (sBorderStyle == "D") return BBS_DASH; 799 if (sBorderStyle == "D") return BBS_DASH;
809 » » if (sBorderStyle == "B") return BBS_BEVELED; 800 if (sBorderStyle == "B") return BBS_BEVELED;
810 » » if (sBorderStyle == "I") return BBS_INSET; 801 if (sBorderStyle == "I") return BBS_INSET;
811 » » if (sBorderStyle == "U") return BBS_UNDERLINE; 802 if (sBorderStyle == "U") return BBS_UNDERLINE;
812 » } 803 }
813 804
814 » CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArray("Border"); 805 CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArray("Border");
815 » if (pBorder) 806 if (pBorder)
816 » { 807 {
817 » » if (pBorder->GetCount() >= 4) 808 if (pBorder->GetCount() >= 4)
818 » » { 809 {
819 » » » CPDF_Array *pDP = pBorder->GetArray(3); 810 CPDF_Array *pDP = pBorder->GetArray(3);
820 » » » if (pDP && pDP->GetCount() > 0) 811 if (pDP && pDP->GetCount() > 0)
821 » » » » return BBS_DASH; 812 return BBS_DASH;
822 » » } 813 }
823 » } 814 }
824 815
825 » return BBS_SOLID; 816 return BBS_SOLID;
826 } 817 }
827 818
828 void CPDFSDK_Annot::SetBorderDash(const CFX_IntArray& array) 819 void CPDFSDK_Annot::SetBorderDash(const CFX_IntArray& array)
829 { 820 {
830 » CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS"); 821 CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS");
831 » if (!pBSDict) 822 if (!pBSDict)
832 » { 823 {
833 » » pBSDict = new CPDF_Dictionary; 824 pBSDict = new CPDF_Dictionary;
834 » » m_pAnnot->GetAnnotDict()->SetAt("BS", pBSDict); 825 m_pAnnot->GetAnnotDict()->SetAt("BS", pBSDict);
835 » } 826 }
836 827
837 » CPDF_Array* pArray = new CPDF_Array; 828 CPDF_Array* pArray = new CPDF_Array;
838 » for (int i=0,sz=array.GetSize(); i<sz; i++) 829 for (int i=0,sz=array.GetSize(); i<sz; i++)
839 » { 830 {
840 » » pArray->AddInteger(array[i]); 831 pArray->AddInteger(array[i]);
841 » } 832 }
842 833
843 » pBSDict->SetAt("D", pArray); 834 pBSDict->SetAt("D", pArray);
844 } 835 }
845 836
846 void CPDFSDK_Annot::GetBorderDash(CFX_IntArray& array) const 837 void CPDFSDK_Annot::GetBorderDash(CFX_IntArray& array) const
847 { 838 {
848 » CPDF_Array* pDash = NULL; 839 CPDF_Array* pDash = NULL;
849 840
850 » CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArray("Border"); 841 CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArray("Border");
851 » if (pBorder) 842 if (pBorder)
852 » { 843 {
853 » » pDash = pBorder->GetArray(3); 844 pDash = pBorder->GetArray(3);
854 » } 845 }
855 » else 846 else
856 » { 847 {
857 » » CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS "); 848 CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS");
858 » » if (pBSDict) 849 if (pBSDict)
859 » » { 850 {
860 » » » pDash = pBSDict->GetArray("D"); 851 pDash = pBSDict->GetArray("D");
861 » » } 852 }
862 » } 853 }
863 854
864 » if (pDash) 855 if (pDash)
865 » { 856 {
866 » » for (int i=0,sz=pDash->GetCount(); i<sz; i++) 857 for (int i=0,sz=pDash->GetCount(); i<sz; i++)
867 » » { 858 {
868 » » » array.Add(pDash->GetInteger(i)); 859 array.Add(pDash->GetInteger(i));
869 » » } 860 }
870 » } 861 }
871 } 862 }
872 863
873 void CPDFSDK_Annot::SetColor(FX_COLORREF color) 864 void CPDFSDK_Annot::SetColor(FX_COLORREF color)
874 { 865 {
875 » CPDF_Array* pArray = new CPDF_Array; 866 CPDF_Array* pArray = new CPDF_Array;
876 » pArray->AddNumber((FX_FLOAT)FXSYS_GetRValue(color) / 255.0f); 867 pArray->AddNumber((FX_FLOAT)FXSYS_GetRValue(color) / 255.0f);
877 » pArray->AddNumber((FX_FLOAT)FXSYS_GetGValue(color) / 255.0f); 868 pArray->AddNumber((FX_FLOAT)FXSYS_GetGValue(color) / 255.0f);
878 » pArray->AddNumber((FX_FLOAT)FXSYS_GetBValue(color) / 255.0f); 869 pArray->AddNumber((FX_FLOAT)FXSYS_GetBValue(color) / 255.0f);
879 » m_pAnnot->GetAnnotDict()->SetAt("C", pArray); 870 m_pAnnot->GetAnnotDict()->SetAt("C", pArray);
880 } 871 }
881 872
882 void CPDFSDK_Annot::RemoveColor() 873 void CPDFSDK_Annot::RemoveColor()
883 { 874 {
884 » m_pAnnot->GetAnnotDict()->RemoveAt("C"); 875 m_pAnnot->GetAnnotDict()->RemoveAt("C");
885 } 876 }
886 877
887 FX_BOOL CPDFSDK_Annot::GetColor(FX_COLORREF& color) const 878 FX_BOOL CPDFSDK_Annot::GetColor(FX_COLORREF& color) const
888 { 879 {
889 » if (CPDF_Array* pEntry = m_pAnnot->GetAnnotDict()->GetArray("C")) 880 if (CPDF_Array* pEntry = m_pAnnot->GetAnnotDict()->GetArray("C"))
890 » { 881 {
891 » » int nCount = pEntry->GetCount(); 882 int nCount = pEntry->GetCount();
892 » » if (nCount == 1) 883 if (nCount == 1)
893 » » { 884 {
894 » » » FX_FLOAT g = pEntry->GetNumber(0) * 255; 885 FX_FLOAT g = pEntry->GetNumber(0) * 255;
895 886
896 » » » color = FXSYS_RGB((int)g, (int)g, (int)g); 887 color = FXSYS_RGB((int)g, (int)g, (int)g);
897 888
898 » » » return TRUE; 889 return TRUE;
899 » » } 890 }
900 » » else if (nCount == 3) 891 else if (nCount == 3)
901 » » { 892 {
902 » » » FX_FLOAT r = pEntry->GetNumber(0) * 255; 893 FX_FLOAT r = pEntry->GetNumber(0) * 255;
903 » » » FX_FLOAT g = pEntry->GetNumber(1) * 255; 894 FX_FLOAT g = pEntry->GetNumber(1) * 255;
904 » » » FX_FLOAT b = pEntry->GetNumber(2) * 255; 895 FX_FLOAT b = pEntry->GetNumber(2) * 255;
905 896
906 » » » color = FXSYS_RGB((int)r, (int)g, (int)b); 897 color = FXSYS_RGB((int)r, (int)g, (int)b);
907 898
908 » » » return TRUE; 899 return TRUE;
909 » » } 900 }
910 » » else if (nCount == 4) 901 else if (nCount == 4)
911 » » { 902 {
912 » » » FX_FLOAT c = pEntry->GetNumber(0); 903 FX_FLOAT c = pEntry->GetNumber(0);
913 » » » FX_FLOAT m = pEntry->GetNumber(1); 904 FX_FLOAT m = pEntry->GetNumber(1);
914 » » » FX_FLOAT y = pEntry->GetNumber(2); 905 FX_FLOAT y = pEntry->GetNumber(2);
915 » » » FX_FLOAT k = pEntry->GetNumber(3); 906 FX_FLOAT k = pEntry->GetNumber(3);
916 907
917 » » » FX_FLOAT r = 1.0f - FX_MIN(1.0f, c + k); 908 FX_FLOAT r = 1.0f - FX_MIN(1.0f, c + k);
918 » » » FX_FLOAT g = 1.0f - FX_MIN(1.0f, m + k); 909 FX_FLOAT g = 1.0f - FX_MIN(1.0f, m + k);
919 » » » FX_FLOAT b = 1.0f - FX_MIN(1.0f, y + k); 910 FX_FLOAT b = 1.0f - FX_MIN(1.0f, y + k);
920 911
921 » » » color = FXSYS_RGB((int)(r * 255), (int)(g * 255), (int)( b * 255)); 912 color = FXSYS_RGB((int)(r * 255), (int)(g * 255), (int)(b * 255));
922 913
923 » » » return TRUE; 914 return TRUE;
924 » » } 915 }
925 » } 916 }
926 917
927 » return FALSE; 918 return FALSE;
928 } 919 }
929 920
930 921
931 void CPDFSDK_Annot::WriteAppearance(const CFX_ByteString& sAPType, const CPDF_Re ct& rcBBox, 922 void CPDFSDK_Annot::WriteAppearance(const CFX_ByteString& sAPType, const CPDF_Re ct& rcBBox,
932 » » » » » » » » const CPDF_Matri x& matrix, const CFX_ByteString& sContents, 923 const CPDF_Matrix& matrix, const CFX_ByteString& sContents,
933 » » » » » » » » const CFX_ByteSt ring& sAPState) 924 const CFX_ByteString& sAPState)
934 { 925 {
935 » CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDict("AP"); 926 CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDict("AP");
936 927
937 » if (!pAPDict) 928 if (!pAPDict)
938 » { 929 {
939 » » pAPDict = new CPDF_Dictionary; 930 pAPDict = new CPDF_Dictionary;
940 » » m_pAnnot->GetAnnotDict()->SetAt("AP", pAPDict); 931 m_pAnnot->GetAnnotDict()->SetAt("AP", pAPDict);
941 » } 932 }
942 933
943 » CPDF_Stream* pStream = NULL; 934 CPDF_Stream* pStream = NULL;
944 » CPDF_Dictionary* pParentDict = NULL; 935 CPDF_Dictionary* pParentDict = NULL;
945 936
946 » if (sAPState.IsEmpty()) 937 if (sAPState.IsEmpty())
947 » { 938 {
948 » » pParentDict = pAPDict; 939 pParentDict = pAPDict;
949 » » pStream = pAPDict->GetStream(sAPType); 940 pStream = pAPDict->GetStream(sAPType);
950 » } 941 }
951 » else 942 else
952 » { 943 {
953 » » CPDF_Dictionary* pAPTypeDict = pAPDict->GetDict(sAPType); 944 CPDF_Dictionary* pAPTypeDict = pAPDict->GetDict(sAPType);
954 » » if (!pAPTypeDict) 945 if (!pAPTypeDict)
955 » » { 946 {
956 » » » pAPTypeDict = new CPDF_Dictionary; 947 pAPTypeDict = new CPDF_Dictionary;
957 » » » pAPDict->SetAt(sAPType, pAPTypeDict); 948 pAPDict->SetAt(sAPType, pAPTypeDict);
958 » » } 949 }
959 950
960 » » pParentDict = pAPTypeDict; 951 pParentDict = pAPTypeDict;
961 » » pStream = pAPTypeDict->GetStream(sAPState); 952 pStream = pAPTypeDict->GetStream(sAPState);
962 » } 953 }
963 954
964 » if (!pStream) 955 if (!pStream)
965 » { 956 {
966 » » CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); 957 CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
967 » » pStream = new CPDF_Stream(NULL, 0, NULL); 958 pStream = new CPDF_Stream(NULL, 0, NULL);
968 » » int32_t objnum = pDoc->AddIndirectObject(pStream); 959 int32_t objnum = pDoc->AddIndirectObject(pStream);
969 » » pParentDict->SetAtReference(sAPType, pDoc, objnum); 960 pParentDict->SetAtReference(sAPType, pDoc, objnum);
970 » } 961 }
971 962
972 » CPDF_Dictionary *pStreamDict = pStream->GetDict(); 963 CPDF_Dictionary *pStreamDict = pStream->GetDict();
973 » if (!pStreamDict) 964 if (!pStreamDict)
974 » { 965 {
975 » » pStreamDict = new CPDF_Dictionary; 966 pStreamDict = new CPDF_Dictionary;
976 » » pStreamDict->SetAtName("Type", "XObject"); 967 pStreamDict->SetAtName("Type", "XObject");
977 » » pStreamDict->SetAtName("Subtype", "Form"); 968 pStreamDict->SetAtName("Subtype", "Form");
978 » » pStreamDict->SetAtInteger("FormType", 1); 969 pStreamDict->SetAtInteger("FormType", 1);
979 » » pStream->InitStream(NULL,0,pStreamDict); 970 pStream->InitStream(NULL,0,pStreamDict);
980 » } 971 }
981 972
982 » if (pStreamDict) 973 if (pStreamDict)
983 » { 974 {
984 » » pStreamDict->SetAtMatrix("Matrix",matrix); 975 pStreamDict->SetAtMatrix("Matrix",matrix);
985 » » pStreamDict->SetAtRect("BBox", rcBBox); 976 pStreamDict->SetAtRect("BBox", rcBBox);
986 » } 977 }
987 978
988 » pStream->SetData((uint8_t*)sContents.c_str(), sContents.GetLength(), FAL SE, FALSE); 979 pStream->SetData((uint8_t*)sContents.c_str(), sContents.GetLength(), FALSE, FALSE);
989 } 980 }
990 981
991 #define BA_ANNOT_MINWIDTH» » » 1 982 #define BA_ANNOT_MINWIDTH 1
992 #define BA_ANNOT_MINHEIGHT» » » 1 983 #define BA_ANNOT_MINHEIGHT 1
993 984
994 FX_FLOAT CPDFSDK_Annot::GetMinWidth() const 985 FX_FLOAT CPDFSDK_Annot::GetMinWidth() const
995 { 986 {
996 » return BA_ANNOT_MINWIDTH; 987 return BA_ANNOT_MINWIDTH;
997 } 988 }
998 989
999 FX_FLOAT CPDFSDK_Annot::GetMinHeight() const 990 FX_FLOAT CPDFSDK_Annot::GetMinHeight() const
1000 { 991 {
1001 » return BA_ANNOT_MINHEIGHT; 992 return BA_ANNOT_MINHEIGHT;
1002 } 993 }
1003 994
1004 FX_BOOL CPDFSDK_Annot::CreateFormFiller() 995 FX_BOOL CPDFSDK_Annot::CreateFormFiller()
1005 { 996 {
1006 » return TRUE; 997 return TRUE;
1007 } 998 }
1008 FX_BOOL»CPDFSDK_Annot::IsVisible() const 999 FX_BOOL CPDFSDK_Annot::IsVisible() const
1009 { 1000 {
1010 » int nFlags = GetFlags(); 1001 int nFlags = GetFlags();
1011 » return !((nFlags & ANNOTFLAG_INVISIBLE) || (nFlags & ANNOTFLAG_HIDDEN) | | (nFlags & ANNOTFLAG_NOVIEW)); 1002 return !((nFlags & ANNOTFLAG_INVISIBLE) || (nFlags & ANNOTFLAG_HIDDEN) || (n Flags & ANNOTFLAG_NOVIEW));
1012 } 1003 }
1013 1004
1014 CPDF_Action CPDFSDK_Annot::GetAction() const 1005 CPDF_Action CPDFSDK_Annot::GetAction() const
1015 { 1006 {
1016 » return CPDF_Action(m_pAnnot->GetAnnotDict()->GetDict("A")); 1007 return CPDF_Action(m_pAnnot->GetAnnotDict()->GetDict("A"));
1017 } 1008 }
1018 1009
1019 void CPDFSDK_Annot::SetAction(const CPDF_Action& action) 1010 void CPDFSDK_Annot::SetAction(const CPDF_Action& action)
1020 { 1011 {
1021 » ASSERT(action); 1012 ASSERT(action);
1022 » if ((CPDF_Action&)action != CPDF_Action(m_pAnnot->GetAnnotDict()->GetDic t("A"))) 1013 if ((CPDF_Action&)action != CPDF_Action(m_pAnnot->GetAnnotDict()->GetDict("A ")))
1023 » { 1014 {
1024 » » CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); 1015 CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
1025 » » CPDF_Dictionary* pDict = action.GetDict(); 1016 CPDF_Dictionary* pDict = action.GetDict();
1026 » » if (pDict && pDict->GetObjNum() == 0) { 1017 if (pDict && pDict->GetObjNum() == 0) {
1027 » » » pDoc->AddIndirectObject(pDict); 1018 pDoc->AddIndirectObject(pDict);
1028 » » } 1019 }
1029 » » m_pAnnot->GetAnnotDict()->SetAtReference("A", pDoc, pDict->GetOb jNum()); 1020 m_pAnnot->GetAnnotDict()->SetAtReference("A", pDoc, pDict->GetObjNum());
1030 » } 1021 }
1031 } 1022 }
1032 1023
1033 void CPDFSDK_Annot::RemoveAction() 1024 void CPDFSDK_Annot::RemoveAction()
1034 { 1025 {
1035 » m_pAnnot->GetAnnotDict()->RemoveAt("A"); 1026 m_pAnnot->GetAnnotDict()->RemoveAt("A");
1036 } 1027 }
1037 1028
1038 CPDF_AAction CPDFSDK_Annot::GetAAction() const 1029 CPDF_AAction CPDFSDK_Annot::GetAAction() const
1039 { 1030 {
1040 » return m_pAnnot->GetAnnotDict()->GetDict("AA"); 1031 return m_pAnnot->GetAnnotDict()->GetDict("AA");
1041 } 1032 }
1042 1033
1043 void CPDFSDK_Annot::SetAAction(const CPDF_AAction& aa) 1034 void CPDFSDK_Annot::SetAAction(const CPDF_AAction& aa)
1044 { 1035 {
1045 » ASSERT(aa != NULL); 1036 ASSERT(aa != NULL);
1046 1037
1047 » if ((CPDF_AAction&)aa != m_pAnnot->GetAnnotDict()->GetDict("AA")) 1038 if ((CPDF_AAction&)aa != m_pAnnot->GetAnnotDict()->GetDict("AA"))
1048 » » m_pAnnot->GetAnnotDict()->SetAt("AA", (CPDF_AAction&)aa); 1039 m_pAnnot->GetAnnotDict()->SetAt("AA", (CPDF_AAction&)aa);
1049 } 1040 }
1050 1041
1051 void CPDFSDK_Annot::RemoveAAction() 1042 void CPDFSDK_Annot::RemoveAAction()
1052 { 1043 {
1053 » m_pAnnot->GetAnnotDict()->RemoveAt("AA"); 1044 m_pAnnot->GetAnnotDict()->RemoveAt("AA");
1054 } 1045 }
1055 1046
1056 CPDF_Action» CPDFSDK_Annot::GetAAction(CPDF_AAction::AActionType eAAT) 1047 CPDF_Action CPDFSDK_Annot::GetAAction(CPDF_AAction::AActionType eAAT)
1057 { 1048 {
1058 » CPDF_AAction AAction = GetAAction(); 1049 CPDF_AAction AAction = GetAAction();
1059 1050
1060 » if (AAction.ActionExist(eAAT)) 1051 if (AAction.ActionExist(eAAT))
1061 » » return AAction.GetAction(eAAT); 1052 return AAction.GetAction(eAAT);
1062 1053
1063 » if (eAAT == CPDF_AAction::ButtonUp) 1054 if (eAAT == CPDF_AAction::ButtonUp)
1064 » » return GetAction(); 1055 return GetAction();
1065 1056
1066 » return CPDF_Action(); 1057 return CPDF_Action();
1067 } 1058 }
1068 1059
1069 void CPDFSDK_Annot::Annot_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2 Device, CPDF_RenderOptions* pOptions) 1060 void CPDFSDK_Annot::Annot_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2 Device, CPDF_RenderOptions* pOptions)
1070 { 1061 {
1071 1062
1072 » m_pAnnot->GetAPForm(m_pPageView->GetPDFPage(), CPDF_Annot::Normal); 1063 m_pAnnot->GetAPForm(m_pPageView->GetPDFPage(), CPDF_Annot::Normal);
1073 » m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, pUser2Devic e, CPDF_Annot::Normal, NULL); 1064 m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, pUser2Device, C PDF_Annot::Normal, NULL);
1074 1065
1075 » return ; 1066 return ;
1076 } 1067 }
1077 1068
1078 CPDF_Page* CPDFSDK_Annot::GetPDFPage() 1069 CPDF_Page* CPDFSDK_Annot::GetPDFPage()
1079 { 1070 {
1080 » if(m_pPageView) 1071 if(m_pPageView)
1081 » » return m_pPageView->GetPDFPage(); 1072 return m_pPageView->GetPDFPage();
1082 » return NULL; 1073 return NULL;
1083 } 1074 }
1084 1075
OLDNEW
« no previous file with comments | « fpdfsdk/src/fsdk_annothandler.cpp ('k') | fpdfsdk/src/fsdk_baseform.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698