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