John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1 | // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 4 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
Dan Sinclair | 10cfea1 | 2015-11-16 13:09:00 -0500 | [diff] [blame] | 7 | #include "core/include/fxcrt/fx_ext.h" |
Lei Zhang | bde53d2 | 2015-11-12 22:21:30 -0800 | [diff] [blame] | 8 | #include "fpdfsdk/include/fsdk_baseannot.h" |
| 9 | #include "fpdfsdk/include/fsdk_define.h" |
| 10 | #include "fpdfsdk/include/fsdk_mgr.h" |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 11 | |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 12 | #ifdef PDF_ENABLE_XFA |
| 13 | #include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h" |
| 14 | #endif // PDF_ENABLE_XFA |
| 15 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 16 | int _gAfxGetTimeZoneInSeconds(FX_CHAR tzhour, uint8_t tzminute) { |
| 17 | return (int)tzhour * 3600 + (int)tzminute * (tzhour >= 0 ? 60 : -60); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 18 | } |
| 19 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 20 | FX_BOOL _gAfxIsLeapYear(int16_t year) { |
| 21 | return ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0))); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 22 | } |
| 23 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 24 | FX_WORD _gAfxGetYearDays(int16_t year) { |
| 25 | return (_gAfxIsLeapYear(year) == TRUE ? 366 : 365); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 26 | } |
| 27 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 28 | uint8_t _gAfxGetMonthDays(int16_t year, uint8_t month) { |
| 29 | uint8_t mDays; |
| 30 | switch (month) { |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 31 | case 1: |
| 32 | case 3: |
| 33 | case 5: |
| 34 | case 7: |
| 35 | case 8: |
| 36 | case 10: |
| 37 | case 12: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 38 | mDays = 31; |
| 39 | break; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 40 | |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 41 | case 4: |
| 42 | case 6: |
| 43 | case 9: |
| 44 | case 11: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 45 | mDays = 30; |
| 46 | break; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 47 | |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 48 | case 2: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 49 | if (_gAfxIsLeapYear(year) == TRUE) |
| 50 | mDays = 29; |
| 51 | else |
| 52 | mDays = 28; |
| 53 | break; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 54 | |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 55 | default: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 56 | mDays = 0; |
| 57 | break; |
| 58 | } |
| 59 | |
| 60 | return mDays; |
| 61 | } |
| 62 | |
| 63 | CPDFSDK_DateTime::CPDFSDK_DateTime() { |
| 64 | ResetDateTime(); |
| 65 | } |
| 66 | |
| 67 | CPDFSDK_DateTime::CPDFSDK_DateTime(const CFX_ByteString& dtStr) { |
| 68 | ResetDateTime(); |
| 69 | |
| 70 | FromPDFDateTimeString(dtStr); |
| 71 | } |
| 72 | |
| 73 | CPDFSDK_DateTime::CPDFSDK_DateTime(const CPDFSDK_DateTime& datetime) { |
| 74 | operator=(datetime); |
| 75 | } |
| 76 | |
| 77 | CPDFSDK_DateTime::CPDFSDK_DateTime(const FX_SYSTEMTIME& st) { |
| 78 | operator=(st); |
| 79 | } |
| 80 | |
| 81 | void CPDFSDK_DateTime::ResetDateTime() { |
| 82 | tzset(); |
| 83 | |
| 84 | time_t curTime; |
| 85 | time(&curTime); |
| 86 | struct tm* newtime; |
| 87 | // newtime = gmtime(&curTime); |
| 88 | newtime = localtime(&curTime); |
| 89 | |
| 90 | dt.year = newtime->tm_year + 1900; |
| 91 | dt.month = newtime->tm_mon + 1; |
| 92 | dt.day = newtime->tm_mday; |
| 93 | dt.hour = newtime->tm_hour; |
| 94 | dt.minute = newtime->tm_min; |
| 95 | dt.second = newtime->tm_sec; |
| 96 | // dt.tzHour = _timezone / 3600 * -1; |
| 97 | // dt.tzMinute = (abs(_timezone) % 3600) / 60; |
| 98 | } |
| 99 | |
| 100 | CPDFSDK_DateTime& CPDFSDK_DateTime::operator=( |
| 101 | const CPDFSDK_DateTime& datetime) { |
| 102 | FXSYS_memcpy(&dt, &datetime.dt, sizeof(FX_DATETIME)); |
| 103 | return *this; |
| 104 | } |
| 105 | |
| 106 | CPDFSDK_DateTime& CPDFSDK_DateTime::operator=(const FX_SYSTEMTIME& st) { |
| 107 | tzset(); |
| 108 | |
| 109 | dt.year = (int16_t)st.wYear; |
| 110 | dt.month = (uint8_t)st.wMonth; |
| 111 | dt.day = (uint8_t)st.wDay; |
| 112 | dt.hour = (uint8_t)st.wHour; |
| 113 | dt.minute = (uint8_t)st.wMinute; |
| 114 | dt.second = (uint8_t)st.wSecond; |
| 115 | // dt.tzHour = _timezone / 3600 * -1; |
| 116 | // dt.tzMinute = (abs(_timezone) % 3600) / 60; |
| 117 | return *this; |
| 118 | } |
| 119 | |
| 120 | FX_BOOL CPDFSDK_DateTime::operator==(CPDFSDK_DateTime& datetime) { |
| 121 | return (FXSYS_memcmp(&dt, &datetime.dt, sizeof(FX_DATETIME)) == 0); |
| 122 | } |
| 123 | |
| 124 | FX_BOOL CPDFSDK_DateTime::operator!=(CPDFSDK_DateTime& datetime) { |
| 125 | return (FXSYS_memcmp(&dt, &datetime.dt, sizeof(FX_DATETIME)) != 0); |
| 126 | } |
| 127 | |
| 128 | FX_BOOL CPDFSDK_DateTime::operator>(CPDFSDK_DateTime& datetime) { |
| 129 | CPDFSDK_DateTime dt1 = ToGMT(); |
| 130 | CPDFSDK_DateTime dt2 = datetime.ToGMT(); |
| 131 | int d1 = |
| 132 | (((int)dt1.dt.year) << 16) | (((int)dt1.dt.month) << 8) | (int)dt1.dt.day; |
| 133 | int d2 = (((int)dt1.dt.hour) << 16) | (((int)dt1.dt.minute) << 8) | |
| 134 | (int)dt1.dt.second; |
| 135 | int d3 = |
| 136 | (((int)dt2.dt.year) << 16) | (((int)dt2.dt.month) << 8) | (int)dt2.dt.day; |
| 137 | int d4 = (((int)dt2.dt.hour) << 16) | (((int)dt2.dt.minute) << 8) | |
| 138 | (int)dt2.dt.second; |
| 139 | |
| 140 | if (d1 > d3) |
| 141 | return TRUE; |
| 142 | if (d2 > d4) |
| 143 | return TRUE; |
| 144 | return FALSE; |
| 145 | } |
| 146 | |
| 147 | FX_BOOL CPDFSDK_DateTime::operator>=(CPDFSDK_DateTime& datetime) { |
| 148 | CPDFSDK_DateTime dt1 = ToGMT(); |
| 149 | CPDFSDK_DateTime dt2 = datetime.ToGMT(); |
| 150 | int d1 = |
| 151 | (((int)dt1.dt.year) << 16) | (((int)dt1.dt.month) << 8) | (int)dt1.dt.day; |
| 152 | int d2 = (((int)dt1.dt.hour) << 16) | (((int)dt1.dt.minute) << 8) | |
| 153 | (int)dt1.dt.second; |
| 154 | int d3 = |
| 155 | (((int)dt2.dt.year) << 16) | (((int)dt2.dt.month) << 8) | (int)dt2.dt.day; |
| 156 | int d4 = (((int)dt2.dt.hour) << 16) | (((int)dt2.dt.minute) << 8) | |
| 157 | (int)dt2.dt.second; |
| 158 | |
| 159 | if (d1 >= d3) |
| 160 | return TRUE; |
| 161 | if (d2 >= d4) |
| 162 | return TRUE; |
| 163 | return FALSE; |
| 164 | } |
| 165 | |
| 166 | FX_BOOL CPDFSDK_DateTime::operator<(CPDFSDK_DateTime& datetime) { |
| 167 | CPDFSDK_DateTime dt1 = ToGMT(); |
| 168 | CPDFSDK_DateTime dt2 = datetime.ToGMT(); |
| 169 | int d1 = |
| 170 | (((int)dt1.dt.year) << 16) | (((int)dt1.dt.month) << 8) | (int)dt1.dt.day; |
| 171 | int d2 = (((int)dt1.dt.hour) << 16) | (((int)dt1.dt.minute) << 8) | |
| 172 | (int)dt1.dt.second; |
| 173 | int d3 = |
| 174 | (((int)dt2.dt.year) << 16) | (((int)dt2.dt.month) << 8) | (int)dt2.dt.day; |
| 175 | int d4 = (((int)dt2.dt.hour) << 16) | (((int)dt2.dt.minute) << 8) | |
| 176 | (int)dt2.dt.second; |
| 177 | |
| 178 | if (d1 < d3) |
| 179 | return TRUE; |
| 180 | if (d2 < d4) |
| 181 | return TRUE; |
| 182 | return FALSE; |
| 183 | } |
| 184 | |
| 185 | FX_BOOL CPDFSDK_DateTime::operator<=(CPDFSDK_DateTime& datetime) { |
| 186 | CPDFSDK_DateTime dt1 = ToGMT(); |
| 187 | CPDFSDK_DateTime dt2 = datetime.ToGMT(); |
| 188 | int d1 = |
| 189 | (((int)dt1.dt.year) << 16) | (((int)dt1.dt.month) << 8) | (int)dt1.dt.day; |
| 190 | int d2 = (((int)dt1.dt.hour) << 16) | (((int)dt1.dt.minute) << 8) | |
| 191 | (int)dt1.dt.second; |
| 192 | int d3 = |
| 193 | (((int)dt2.dt.year) << 16) | (((int)dt2.dt.month) << 8) | (int)dt2.dt.day; |
| 194 | int d4 = (((int)dt2.dt.hour) << 16) | (((int)dt2.dt.minute) << 8) | |
| 195 | (int)dt2.dt.second; |
| 196 | |
| 197 | if (d1 <= d3) |
| 198 | return TRUE; |
| 199 | if (d2 <= d4) |
| 200 | return TRUE; |
| 201 | return FALSE; |
| 202 | } |
| 203 | |
| 204 | CPDFSDK_DateTime::operator time_t() { |
| 205 | struct tm newtime; |
| 206 | |
| 207 | newtime.tm_year = dt.year - 1900; |
| 208 | newtime.tm_mon = dt.month - 1; |
| 209 | newtime.tm_mday = dt.day; |
| 210 | newtime.tm_hour = dt.hour; |
| 211 | newtime.tm_min = dt.minute; |
| 212 | newtime.tm_sec = dt.second; |
| 213 | |
| 214 | return mktime(&newtime); |
| 215 | } |
| 216 | |
| 217 | CPDFSDK_DateTime& CPDFSDK_DateTime::FromPDFDateTimeString( |
| 218 | const CFX_ByteString& dtStr) { |
| 219 | int strLength = dtStr.GetLength(); |
| 220 | if (strLength > 0) { |
| 221 | int i = 0; |
| 222 | int j, k; |
| 223 | FX_CHAR ch; |
Dan Sinclair | 10cfea1 | 2015-11-16 13:09:00 -0500 | [diff] [blame] | 224 | while (i < strLength && !std::isdigit(dtStr[i])) |
| 225 | ++i; |
| 226 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 227 | if (i >= strLength) |
| 228 | return *this; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 229 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 230 | j = 0; |
| 231 | k = 0; |
| 232 | while (i < strLength && j < 4) { |
| 233 | ch = dtStr[i]; |
Dan Sinclair | 10cfea1 | 2015-11-16 13:09:00 -0500 | [diff] [blame] | 234 | k = k * 10 + FXSYS_toDecimalDigit(ch); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 235 | j++; |
Dan Sinclair | 10cfea1 | 2015-11-16 13:09:00 -0500 | [diff] [blame] | 236 | if (!std::isdigit(ch)) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 237 | break; |
| 238 | i++; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 239 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 240 | dt.year = (int16_t)k; |
| 241 | if (i >= strLength || j < 4) |
| 242 | return *this; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 243 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 244 | j = 0; |
| 245 | k = 0; |
| 246 | while (i < strLength && j < 2) { |
| 247 | ch = dtStr[i]; |
Dan Sinclair | 10cfea1 | 2015-11-16 13:09:00 -0500 | [diff] [blame] | 248 | k = k * 10 + FXSYS_toDecimalDigit(ch); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 249 | j++; |
Dan Sinclair | 10cfea1 | 2015-11-16 13:09:00 -0500 | [diff] [blame] | 250 | if (!std::isdigit(ch)) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 251 | break; |
| 252 | i++; |
| 253 | } |
| 254 | dt.month = (uint8_t)k; |
| 255 | if (i >= strLength || j < 2) |
| 256 | return *this; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 257 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 258 | j = 0; |
| 259 | k = 0; |
| 260 | while (i < strLength && j < 2) { |
| 261 | ch = dtStr[i]; |
Dan Sinclair | 10cfea1 | 2015-11-16 13:09:00 -0500 | [diff] [blame] | 262 | k = k * 10 + FXSYS_toDecimalDigit(ch); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 263 | j++; |
Dan Sinclair | 10cfea1 | 2015-11-16 13:09:00 -0500 | [diff] [blame] | 264 | if (!std::isdigit(ch)) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 265 | break; |
| 266 | i++; |
| 267 | } |
| 268 | dt.day = (uint8_t)k; |
| 269 | if (i >= strLength || j < 2) |
| 270 | return *this; |
| 271 | |
| 272 | j = 0; |
| 273 | k = 0; |
| 274 | while (i < strLength && j < 2) { |
| 275 | ch = dtStr[i]; |
Dan Sinclair | 10cfea1 | 2015-11-16 13:09:00 -0500 | [diff] [blame] | 276 | k = k * 10 + FXSYS_toDecimalDigit(ch); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 277 | j++; |
Dan Sinclair | 10cfea1 | 2015-11-16 13:09:00 -0500 | [diff] [blame] | 278 | if (!std::isdigit(ch)) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 279 | break; |
| 280 | i++; |
| 281 | } |
| 282 | dt.hour = (uint8_t)k; |
| 283 | if (i >= strLength || j < 2) |
| 284 | return *this; |
| 285 | |
| 286 | j = 0; |
| 287 | k = 0; |
| 288 | while (i < strLength && j < 2) { |
| 289 | ch = dtStr[i]; |
Dan Sinclair | 10cfea1 | 2015-11-16 13:09:00 -0500 | [diff] [blame] | 290 | k = k * 10 + FXSYS_toDecimalDigit(ch); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 291 | j++; |
Dan Sinclair | 10cfea1 | 2015-11-16 13:09:00 -0500 | [diff] [blame] | 292 | if (!std::isdigit(ch)) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 293 | break; |
| 294 | i++; |
| 295 | } |
| 296 | dt.minute = (uint8_t)k; |
| 297 | if (i >= strLength || j < 2) |
| 298 | return *this; |
| 299 | |
| 300 | j = 0; |
| 301 | k = 0; |
| 302 | while (i < strLength && j < 2) { |
| 303 | ch = dtStr[i]; |
Dan Sinclair | 10cfea1 | 2015-11-16 13:09:00 -0500 | [diff] [blame] | 304 | k = k * 10 + FXSYS_toDecimalDigit(ch); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 305 | j++; |
Dan Sinclair | 10cfea1 | 2015-11-16 13:09:00 -0500 | [diff] [blame] | 306 | if (!std::isdigit(ch)) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 307 | break; |
| 308 | i++; |
| 309 | } |
| 310 | dt.second = (uint8_t)k; |
| 311 | if (i >= strLength || j < 2) |
| 312 | return *this; |
| 313 | |
| 314 | ch = dtStr[i++]; |
| 315 | if (ch != '-' && ch != '+') |
| 316 | return *this; |
| 317 | if (ch == '-') |
| 318 | dt.tzHour = -1; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 319 | else |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 320 | dt.tzHour = 1; |
| 321 | j = 0; |
| 322 | k = 0; |
| 323 | while (i < strLength && j < 2) { |
| 324 | ch = dtStr[i]; |
Dan Sinclair | 10cfea1 | 2015-11-16 13:09:00 -0500 | [diff] [blame] | 325 | k = k * 10 + FXSYS_toDecimalDigit(ch); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 326 | j++; |
Dan Sinclair | 10cfea1 | 2015-11-16 13:09:00 -0500 | [diff] [blame] | 327 | if (!std::isdigit(ch)) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 328 | break; |
| 329 | i++; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 330 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 331 | dt.tzHour *= (FX_CHAR)k; |
| 332 | if (i >= strLength || j < 2) |
| 333 | return *this; |
| 334 | |
| 335 | ch = dtStr[i++]; |
| 336 | if (ch != '\'') |
| 337 | return *this; |
| 338 | j = 0; |
| 339 | k = 0; |
| 340 | while (i < strLength && j < 2) { |
| 341 | ch = dtStr[i]; |
Dan Sinclair | 10cfea1 | 2015-11-16 13:09:00 -0500 | [diff] [blame] | 342 | k = k * 10 + FXSYS_toDecimalDigit(ch); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 343 | j++; |
Dan Sinclair | 10cfea1 | 2015-11-16 13:09:00 -0500 | [diff] [blame] | 344 | if (!std::isdigit(ch)) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 345 | break; |
| 346 | i++; |
| 347 | } |
| 348 | dt.tzMinute = (uint8_t)k; |
| 349 | if (i >= strLength || j < 2) |
| 350 | return *this; |
| 351 | } |
| 352 | |
| 353 | return *this; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 354 | } |
| 355 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 356 | CFX_ByteString CPDFSDK_DateTime::ToCommonDateTimeString() { |
| 357 | CFX_ByteString str1; |
| 358 | str1.Format("%04d-%02d-%02d %02d:%02d:%02d ", dt.year, dt.month, dt.day, |
| 359 | dt.hour, dt.minute, dt.second); |
| 360 | if (dt.tzHour < 0) |
| 361 | str1 += "-"; |
| 362 | else |
| 363 | str1 += "+"; |
| 364 | CFX_ByteString str2; |
| 365 | str2.Format("%02d:%02d", abs(dt.tzHour), dt.tzMinute); |
| 366 | return str1 + str2; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 367 | } |
| 368 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 369 | CFX_ByteString CPDFSDK_DateTime::ToPDFDateTimeString() { |
| 370 | CFX_ByteString dtStr; |
| 371 | char tempStr[32]; |
| 372 | memset(tempStr, 0, sizeof(tempStr)); |
| 373 | FXSYS_snprintf(tempStr, sizeof(tempStr) - 1, "D:%04d%02d%02d%02d%02d%02d", |
| 374 | dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second); |
| 375 | dtStr = CFX_ByteString(tempStr); |
| 376 | if (dt.tzHour < 0) |
| 377 | dtStr += CFX_ByteString("-"); |
| 378 | else |
| 379 | dtStr += CFX_ByteString("+"); |
| 380 | memset(tempStr, 0, sizeof(tempStr)); |
| 381 | FXSYS_snprintf(tempStr, sizeof(tempStr) - 1, "%02d'%02d'", abs(dt.tzHour), |
| 382 | dt.tzMinute); |
| 383 | dtStr += CFX_ByteString(tempStr); |
| 384 | return dtStr; |
| 385 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 386 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 387 | void CPDFSDK_DateTime::ToSystemTime(FX_SYSTEMTIME& st) { |
| 388 | CPDFSDK_DateTime dt = *this; |
| 389 | time_t t = (time_t)dt; |
| 390 | struct tm* pTime = localtime(&t); |
| 391 | if (pTime) { |
| 392 | st.wYear = (FX_WORD)pTime->tm_year + 1900; |
| 393 | st.wMonth = (FX_WORD)pTime->tm_mon + 1; |
| 394 | st.wDay = (FX_WORD)pTime->tm_mday; |
| 395 | st.wDayOfWeek = (FX_WORD)pTime->tm_wday; |
| 396 | st.wHour = (FX_WORD)pTime->tm_hour; |
| 397 | st.wMinute = (FX_WORD)pTime->tm_min; |
| 398 | st.wSecond = (FX_WORD)pTime->tm_sec; |
| 399 | st.wMilliseconds = 0; |
| 400 | } |
| 401 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 402 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 403 | CPDFSDK_DateTime CPDFSDK_DateTime::ToGMT() { |
| 404 | CPDFSDK_DateTime dt = *this; |
| 405 | dt.AddSeconds(-_gAfxGetTimeZoneInSeconds(dt.dt.tzHour, dt.dt.tzMinute)); |
| 406 | dt.dt.tzHour = 0; |
| 407 | dt.dt.tzMinute = 0; |
| 408 | return dt; |
| 409 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 410 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 411 | CPDFSDK_DateTime& CPDFSDK_DateTime::AddDays(short days) { |
| 412 | if (days == 0) |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 413 | return *this; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 414 | |
| 415 | int16_t y = dt.year, yy; |
| 416 | uint8_t m = dt.month; |
| 417 | uint8_t d = dt.day; |
| 418 | int mdays, ydays, ldays; |
| 419 | |
| 420 | ldays = days; |
| 421 | if (ldays > 0) { |
| 422 | yy = y; |
| 423 | if (((FX_WORD)m * 100 + d) > 300) |
| 424 | yy++; |
| 425 | ydays = _gAfxGetYearDays(yy); |
| 426 | while (ldays >= ydays) { |
| 427 | y++; |
| 428 | ldays -= ydays; |
| 429 | yy++; |
| 430 | mdays = _gAfxGetMonthDays(y, m); |
| 431 | if (d > mdays) { |
| 432 | m++; |
| 433 | d -= mdays; |
| 434 | } |
| 435 | ydays = _gAfxGetYearDays(yy); |
| 436 | } |
| 437 | mdays = _gAfxGetMonthDays(y, m) - d + 1; |
| 438 | while (ldays >= mdays) { |
| 439 | ldays -= mdays; |
| 440 | m++; |
| 441 | d = 1; |
| 442 | mdays = _gAfxGetMonthDays(y, m); |
| 443 | } |
| 444 | d += ldays; |
| 445 | } else { |
| 446 | ldays *= -1; |
| 447 | yy = y; |
| 448 | if (((FX_WORD)m * 100 + d) < 300) |
| 449 | yy--; |
| 450 | ydays = _gAfxGetYearDays(yy); |
| 451 | while (ldays >= ydays) { |
| 452 | y--; |
| 453 | ldays -= ydays; |
| 454 | yy--; |
| 455 | mdays = _gAfxGetMonthDays(y, m); |
| 456 | if (d > mdays) { |
| 457 | m++; |
| 458 | d -= mdays; |
| 459 | } |
| 460 | ydays = _gAfxGetYearDays(yy); |
| 461 | } |
| 462 | while (ldays >= d) { |
| 463 | ldays -= d; |
| 464 | m--; |
| 465 | mdays = _gAfxGetMonthDays(y, m); |
| 466 | d = mdays; |
| 467 | } |
| 468 | d -= ldays; |
| 469 | } |
| 470 | |
| 471 | dt.year = y; |
| 472 | dt.month = m; |
| 473 | dt.day = d; |
| 474 | |
| 475 | return *this; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 476 | } |
| 477 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 478 | CPDFSDK_DateTime& CPDFSDK_DateTime::AddSeconds(int seconds) { |
| 479 | if (seconds == 0) |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 480 | return *this; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 481 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 482 | int n; |
| 483 | int days; |
| 484 | |
| 485 | n = dt.hour * 3600 + dt.minute * 60 + dt.second + seconds; |
| 486 | if (n < 0) { |
| 487 | days = (n - 86399) / 86400; |
| 488 | n -= days * 86400; |
| 489 | } else { |
| 490 | days = n / 86400; |
| 491 | n %= 86400; |
| 492 | } |
| 493 | dt.hour = (uint8_t)(n / 3600); |
| 494 | dt.hour %= 24; |
| 495 | n %= 3600; |
| 496 | dt.minute = (uint8_t)(n / 60); |
| 497 | dt.second = (uint8_t)(n % 60); |
| 498 | if (days != 0) |
| 499 | AddDays(days); |
| 500 | |
| 501 | return *this; |
| 502 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 503 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 504 | CPDFSDK_Annot::CPDFSDK_Annot(CPDFSDK_PageView* pPageView) |
Dan Sinclair | bfe042a | 2015-11-04 14:04:13 -0500 | [diff] [blame] | 505 | : m_pPageView(pPageView), m_bSelected(FALSE), m_nTabOrder(-1) { |
| 506 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 507 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 508 | CPDFSDK_BAAnnot::CPDFSDK_BAAnnot(CPDF_Annot* pAnnot, |
| 509 | CPDFSDK_PageView* pPageView) |
Dan Sinclair | bfe042a | 2015-11-04 14:04:13 -0500 | [diff] [blame] | 510 | : CPDFSDK_Annot(pPageView), m_pAnnot(pAnnot) { |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 511 | } |
| 512 | |
Tom Sepez | 3343d14 | 2015-11-02 09:54:54 -0800 | [diff] [blame] | 513 | CPDF_Annot* CPDFSDK_BAAnnot::GetPDFAnnot() const { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 514 | return m_pAnnot; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 515 | } |
| 516 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 517 | FX_BOOL CPDFSDK_Annot::IsSelected() { |
| 518 | return m_bSelected; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 519 | } |
| 520 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 521 | void CPDFSDK_Annot::SetSelected(FX_BOOL bSelected) { |
| 522 | m_bSelected = bSelected; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 523 | } |
| 524 | |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 525 | // Tab Order |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 526 | int CPDFSDK_Annot::GetTabOrder() { |
| 527 | return m_nTabOrder; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 528 | } |
| 529 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 530 | void CPDFSDK_Annot::SetTabOrder(int iTabOrder) { |
| 531 | m_nTabOrder = iTabOrder; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 532 | } |
| 533 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 534 | CPDF_Dictionary* CPDFSDK_BAAnnot::GetAnnotDict() const { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 535 | return m_pAnnot->GetAnnotDict(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 536 | } |
| 537 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 538 | void CPDFSDK_BAAnnot::SetRect(const CPDF_Rect& rect) { |
| 539 | ASSERT(rect.right - rect.left >= GetMinWidth()); |
| 540 | ASSERT(rect.top - rect.bottom >= GetMinHeight()); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 541 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 542 | m_pAnnot->GetAnnotDict()->SetAtRect("Rect", rect); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 543 | } |
| 544 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 545 | CPDF_Rect CPDFSDK_BAAnnot::GetRect() const { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 546 | CPDF_Rect rect; |
| 547 | m_pAnnot->GetRect(rect); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 548 | return rect; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 549 | } |
| 550 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 551 | CFX_ByteString CPDFSDK_BAAnnot::GetType() const { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 552 | return m_pAnnot->GetSubType(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 553 | } |
| 554 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 555 | CFX_ByteString CPDFSDK_BAAnnot::GetSubType() const { |
| 556 | return ""; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 557 | } |
| 558 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 559 | void CPDFSDK_BAAnnot::DrawAppearance(CFX_RenderDevice* pDevice, |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 560 | const CFX_Matrix* pUser2Device, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 561 | CPDF_Annot::AppearanceMode mode, |
| 562 | const CPDF_RenderOptions* pOptions) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 563 | m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, pUser2Device, |
| 564 | mode, pOptions); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 565 | } |
| 566 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 567 | FX_BOOL CPDFSDK_BAAnnot::IsAppearanceValid() { |
| 568 | return m_pAnnot->GetAnnotDict()->GetDict("AP") != NULL; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 569 | } |
| 570 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 571 | FX_BOOL CPDFSDK_BAAnnot::IsAppearanceValid(CPDF_Annot::AppearanceMode mode) { |
| 572 | CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDict("AP"); |
| 573 | if (pAP == NULL) |
| 574 | return FALSE; |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 575 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 576 | // Choose the right sub-ap |
| 577 | const FX_CHAR* ap_entry = "N"; |
| 578 | if (mode == CPDF_Annot::Down) |
| 579 | ap_entry = "D"; |
| 580 | else if (mode == CPDF_Annot::Rollover) |
| 581 | ap_entry = "R"; |
| 582 | if (!pAP->KeyExist(ap_entry)) |
| 583 | ap_entry = "N"; |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 584 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 585 | // Get the AP stream or subdirectory |
| 586 | CPDF_Object* psub = pAP->GetElementValue(ap_entry); |
| 587 | if (psub == NULL) |
| 588 | return FALSE; |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 589 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 590 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 591 | } |
| 592 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 593 | void CPDFSDK_BAAnnot::DrawBorder(CFX_RenderDevice* pDevice, |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 594 | const CFX_Matrix* pUser2Device, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 595 | const CPDF_RenderOptions* pOptions) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 596 | m_pAnnot->DrawBorder(pDevice, pUser2Device, pOptions); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 597 | } |
| 598 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 599 | void CPDFSDK_BAAnnot::ClearCachedAP() { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 600 | m_pAnnot->ClearCachedAP(); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 601 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 602 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 603 | void CPDFSDK_BAAnnot::SetContents(const CFX_WideString& sContents) { |
| 604 | if (sContents.IsEmpty()) |
| 605 | m_pAnnot->GetAnnotDict()->RemoveAt("Contents"); |
| 606 | else |
| 607 | m_pAnnot->GetAnnotDict()->SetAtString("Contents", |
| 608 | PDF_EncodeText(sContents)); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 609 | } |
| 610 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 611 | CFX_WideString CPDFSDK_BAAnnot::GetContents() const { |
| 612 | return m_pAnnot->GetAnnotDict()->GetUnicodeText("Contents"); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 613 | } |
| 614 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 615 | void CPDFSDK_BAAnnot::SetAnnotName(const CFX_WideString& sName) { |
| 616 | if (sName.IsEmpty()) |
| 617 | m_pAnnot->GetAnnotDict()->RemoveAt("NM"); |
| 618 | else |
| 619 | m_pAnnot->GetAnnotDict()->SetAtString("NM", PDF_EncodeText(sName)); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 620 | } |
| 621 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 622 | CFX_WideString CPDFSDK_BAAnnot::GetAnnotName() const { |
| 623 | return m_pAnnot->GetAnnotDict()->GetUnicodeText("NM"); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 624 | } |
| 625 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 626 | void CPDFSDK_BAAnnot::SetModifiedDate(const FX_SYSTEMTIME& st) { |
| 627 | CPDFSDK_DateTime dt(st); |
| 628 | CFX_ByteString str = dt.ToPDFDateTimeString(); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 629 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 630 | if (str.IsEmpty()) |
| 631 | m_pAnnot->GetAnnotDict()->RemoveAt("M"); |
| 632 | else |
| 633 | m_pAnnot->GetAnnotDict()->SetAtString("M", str); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 634 | } |
| 635 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 636 | FX_SYSTEMTIME CPDFSDK_BAAnnot::GetModifiedDate() const { |
| 637 | FX_SYSTEMTIME systime; |
| 638 | CFX_ByteString str = m_pAnnot->GetAnnotDict()->GetString("M"); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 639 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 640 | CPDFSDK_DateTime dt(str); |
| 641 | dt.ToSystemTime(systime); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 642 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 643 | return systime; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 644 | } |
| 645 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 646 | void CPDFSDK_BAAnnot::SetFlags(int nFlags) { |
| 647 | m_pAnnot->GetAnnotDict()->SetAtInteger("F", nFlags); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 648 | } |
| 649 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 650 | int CPDFSDK_BAAnnot::GetFlags() const { |
| 651 | return m_pAnnot->GetAnnotDict()->GetInteger("F"); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 652 | } |
| 653 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 654 | void CPDFSDK_BAAnnot::SetAppState(const CFX_ByteString& str) { |
| 655 | if (str.IsEmpty()) |
| 656 | m_pAnnot->GetAnnotDict()->RemoveAt("AS"); |
| 657 | else |
| 658 | m_pAnnot->GetAnnotDict()->SetAtString("AS", str); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 659 | } |
| 660 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 661 | CFX_ByteString CPDFSDK_BAAnnot::GetAppState() const { |
| 662 | return m_pAnnot->GetAnnotDict()->GetString("AS"); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 663 | } |
| 664 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 665 | void CPDFSDK_BAAnnot::SetStructParent(int key) { |
| 666 | m_pAnnot->GetAnnotDict()->SetAtInteger("StructParent", key); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 667 | } |
| 668 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 669 | int CPDFSDK_BAAnnot::GetStructParent() const { |
| 670 | return m_pAnnot->GetAnnotDict()->GetInteger("StructParent"); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 671 | } |
| 672 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 673 | // border |
| 674 | void CPDFSDK_BAAnnot::SetBorderWidth(int nWidth) { |
| 675 | CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArray("Border"); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 676 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 677 | if (pBorder) { |
Tom Sepez | ae51c81 | 2015-08-05 12:34:06 -0700 | [diff] [blame] | 678 | pBorder->SetAt(2, new CPDF_Number(nWidth)); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 679 | } else { |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 680 | CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS"); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 681 | |
| 682 | if (!pBSDict) { |
Tom Sepez | ae51c81 | 2015-08-05 12:34:06 -0700 | [diff] [blame] | 683 | pBSDict = new CPDF_Dictionary; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 684 | m_pAnnot->GetAnnotDict()->SetAt("BS", pBSDict); |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 685 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 686 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 687 | pBSDict->SetAtInteger("W", nWidth); |
| 688 | } |
| 689 | } |
| 690 | |
| 691 | int CPDFSDK_BAAnnot::GetBorderWidth() const { |
| 692 | if (CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArray("Border")) { |
| 693 | return pBorder->GetInteger(2); |
| 694 | } |
| 695 | if (CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS")) { |
| 696 | return pBSDict->GetInteger("W", 1); |
| 697 | } |
| 698 | return 1; |
| 699 | } |
| 700 | |
| 701 | void CPDFSDK_BAAnnot::SetBorderStyle(int nStyle) { |
| 702 | CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS"); |
| 703 | if (!pBSDict) { |
| 704 | pBSDict = new CPDF_Dictionary; |
| 705 | m_pAnnot->GetAnnotDict()->SetAt("BS", pBSDict); |
| 706 | } |
| 707 | |
| 708 | switch (nStyle) { |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 709 | case BBS_SOLID: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 710 | pBSDict->SetAtName("S", "S"); |
| 711 | break; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 712 | case BBS_DASH: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 713 | pBSDict->SetAtName("S", "D"); |
| 714 | break; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 715 | case BBS_BEVELED: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 716 | pBSDict->SetAtName("S", "B"); |
| 717 | break; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 718 | case BBS_INSET: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 719 | pBSDict->SetAtName("S", "I"); |
| 720 | break; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 721 | case BBS_UNDERLINE: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 722 | pBSDict->SetAtName("S", "U"); |
| 723 | break; |
| 724 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 725 | } |
| 726 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 727 | int CPDFSDK_BAAnnot::GetBorderStyle() const { |
| 728 | CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS"); |
| 729 | if (pBSDict) { |
| 730 | CFX_ByteString sBorderStyle = pBSDict->GetString("S", "S"); |
| 731 | if (sBorderStyle == "S") |
| 732 | return BBS_SOLID; |
| 733 | if (sBorderStyle == "D") |
| 734 | return BBS_DASH; |
| 735 | if (sBorderStyle == "B") |
| 736 | return BBS_BEVELED; |
| 737 | if (sBorderStyle == "I") |
| 738 | return BBS_INSET; |
| 739 | if (sBorderStyle == "U") |
| 740 | return BBS_UNDERLINE; |
| 741 | } |
| 742 | |
| 743 | CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArray("Border"); |
| 744 | if (pBorder) { |
| 745 | if (pBorder->GetCount() >= 4) { |
| 746 | CPDF_Array* pDP = pBorder->GetArray(3); |
| 747 | if (pDP && pDP->GetCount() > 0) |
| 748 | return BBS_DASH; |
| 749 | } |
| 750 | } |
| 751 | |
| 752 | return BBS_SOLID; |
| 753 | } |
| 754 | |
| 755 | void CPDFSDK_BAAnnot::SetBorderDash(const CFX_IntArray& array) { |
| 756 | CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS"); |
| 757 | if (!pBSDict) { |
| 758 | pBSDict = new CPDF_Dictionary; |
| 759 | m_pAnnot->GetAnnotDict()->SetAt("BS", pBSDict); |
| 760 | } |
| 761 | |
Tom Sepez | ae51c81 | 2015-08-05 12:34:06 -0700 | [diff] [blame] | 762 | CPDF_Array* pArray = new CPDF_Array; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 763 | for (int i = 0, sz = array.GetSize(); i < sz; i++) { |
| 764 | pArray->AddInteger(array[i]); |
| 765 | } |
| 766 | |
| 767 | pBSDict->SetAt("D", pArray); |
| 768 | } |
| 769 | |
| 770 | void CPDFSDK_BAAnnot::GetBorderDash(CFX_IntArray& array) const { |
| 771 | CPDF_Array* pDash = NULL; |
| 772 | |
| 773 | CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArray("Border"); |
| 774 | if (pBorder) { |
| 775 | pDash = pBorder->GetArray(3); |
| 776 | } else { |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 777 | CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS"); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 778 | if (pBSDict) { |
| 779 | pDash = pBSDict->GetArray("D"); |
| 780 | } |
| 781 | } |
| 782 | |
| 783 | if (pDash) { |
| 784 | for (int i = 0, sz = pDash->GetCount(); i < sz; i++) { |
| 785 | array.Add(pDash->GetInteger(i)); |
| 786 | } |
| 787 | } |
| 788 | } |
| 789 | |
| 790 | void CPDFSDK_BAAnnot::SetColor(FX_COLORREF color) { |
| 791 | CPDF_Array* pArray = new CPDF_Array; |
| 792 | pArray->AddNumber((FX_FLOAT)FXSYS_GetRValue(color) / 255.0f); |
| 793 | pArray->AddNumber((FX_FLOAT)FXSYS_GetGValue(color) / 255.0f); |
| 794 | pArray->AddNumber((FX_FLOAT)FXSYS_GetBValue(color) / 255.0f); |
| 795 | m_pAnnot->GetAnnotDict()->SetAt("C", pArray); |
| 796 | } |
| 797 | |
| 798 | void CPDFSDK_BAAnnot::RemoveColor() { |
| 799 | m_pAnnot->GetAnnotDict()->RemoveAt("C"); |
| 800 | } |
| 801 | |
| 802 | FX_BOOL CPDFSDK_BAAnnot::GetColor(FX_COLORREF& color) const { |
| 803 | if (CPDF_Array* pEntry = m_pAnnot->GetAnnotDict()->GetArray("C")) { |
| 804 | int nCount = pEntry->GetCount(); |
| 805 | if (nCount == 1) { |
| 806 | FX_FLOAT g = pEntry->GetNumber(0) * 255; |
| 807 | |
| 808 | color = FXSYS_RGB((int)g, (int)g, (int)g); |
| 809 | |
| 810 | return TRUE; |
| 811 | } else if (nCount == 3) { |
| 812 | FX_FLOAT r = pEntry->GetNumber(0) * 255; |
| 813 | FX_FLOAT g = pEntry->GetNumber(1) * 255; |
| 814 | FX_FLOAT b = pEntry->GetNumber(2) * 255; |
| 815 | |
| 816 | color = FXSYS_RGB((int)r, (int)g, (int)b); |
| 817 | |
| 818 | return TRUE; |
| 819 | } else if (nCount == 4) { |
| 820 | FX_FLOAT c = pEntry->GetNumber(0); |
| 821 | FX_FLOAT m = pEntry->GetNumber(1); |
| 822 | FX_FLOAT y = pEntry->GetNumber(2); |
| 823 | FX_FLOAT k = pEntry->GetNumber(3); |
| 824 | |
| 825 | FX_FLOAT r = 1.0f - FX_MIN(1.0f, c + k); |
| 826 | FX_FLOAT g = 1.0f - FX_MIN(1.0f, m + k); |
| 827 | FX_FLOAT b = 1.0f - FX_MIN(1.0f, y + k); |
| 828 | |
| 829 | color = FXSYS_RGB((int)(r * 255), (int)(g * 255), (int)(b * 255)); |
| 830 | |
| 831 | return TRUE; |
| 832 | } |
| 833 | } |
| 834 | |
| 835 | return FALSE; |
| 836 | } |
| 837 | |
| 838 | void CPDFSDK_BAAnnot::WriteAppearance(const CFX_ByteString& sAPType, |
| 839 | const CPDF_Rect& rcBBox, |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 840 | const CFX_Matrix& matrix, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 841 | const CFX_ByteString& sContents, |
| 842 | const CFX_ByteString& sAPState) { |
| 843 | CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDict("AP"); |
| 844 | |
| 845 | if (!pAPDict) { |
| 846 | pAPDict = new CPDF_Dictionary; |
| 847 | m_pAnnot->GetAnnotDict()->SetAt("AP", pAPDict); |
| 848 | } |
| 849 | |
Dan Sinclair | bfe042a | 2015-11-04 14:04:13 -0500 | [diff] [blame] | 850 | CPDF_Stream* pStream = nullptr; |
| 851 | CPDF_Dictionary* pParentDict = nullptr; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 852 | |
| 853 | if (sAPState.IsEmpty()) { |
| 854 | pParentDict = pAPDict; |
| 855 | pStream = pAPDict->GetStream(sAPType); |
| 856 | } else { |
| 857 | CPDF_Dictionary* pAPTypeDict = pAPDict->GetDict(sAPType); |
| 858 | if (!pAPTypeDict) { |
Tom Sepez | ae51c81 | 2015-08-05 12:34:06 -0700 | [diff] [blame] | 859 | pAPTypeDict = new CPDF_Dictionary; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 860 | pAPDict->SetAt(sAPType, pAPTypeDict); |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 861 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 862 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 863 | pParentDict = pAPTypeDict; |
| 864 | pStream = pAPTypeDict->GetStream(sAPState); |
| 865 | } |
| 866 | |
| 867 | if (!pStream) { |
Dan Sinclair | bfe042a | 2015-11-04 14:04:13 -0500 | [diff] [blame] | 868 | pStream = new CPDF_Stream(nullptr, 0, nullptr); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 869 | |
Dan Sinclair | bfe042a | 2015-11-04 14:04:13 -0500 | [diff] [blame] | 870 | CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 871 | int32_t objnum = pDoc->AddIndirectObject(pStream); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 872 | pParentDict->SetAtReference(sAPType, pDoc, objnum); |
| 873 | } |
| 874 | |
| 875 | CPDF_Dictionary* pStreamDict = pStream->GetDict(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 876 | if (!pStreamDict) { |
Tom Sepez | ae51c81 | 2015-08-05 12:34:06 -0700 | [diff] [blame] | 877 | pStreamDict = new CPDF_Dictionary; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 878 | pStreamDict->SetAtName("Type", "XObject"); |
| 879 | pStreamDict->SetAtName("Subtype", "Form"); |
| 880 | pStreamDict->SetAtInteger("FormType", 1); |
Dan Sinclair | bfe042a | 2015-11-04 14:04:13 -0500 | [diff] [blame] | 881 | pStream->InitStream(nullptr, 0, pStreamDict); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 882 | } |
| 883 | |
| 884 | if (pStreamDict) { |
| 885 | pStreamDict->SetAtMatrix("Matrix", matrix); |
| 886 | pStreamDict->SetAtRect("BBox", rcBBox); |
| 887 | } |
| 888 | |
| 889 | pStream->SetData((uint8_t*)sContents.c_str(), sContents.GetLength(), FALSE, |
| 890 | FALSE); |
| 891 | } |
| 892 | |
| 893 | #define BA_ANNOT_MINWIDTH 1 |
| 894 | #define BA_ANNOT_MINHEIGHT 1 |
| 895 | |
| 896 | FX_FLOAT CPDFSDK_Annot::GetMinWidth() const { |
| 897 | return BA_ANNOT_MINWIDTH; |
| 898 | } |
| 899 | |
| 900 | FX_FLOAT CPDFSDK_Annot::GetMinHeight() const { |
| 901 | return BA_ANNOT_MINHEIGHT; |
| 902 | } |
| 903 | |
| 904 | FX_BOOL CPDFSDK_BAAnnot::CreateFormFiller() { |
| 905 | return TRUE; |
| 906 | } |
| 907 | FX_BOOL CPDFSDK_BAAnnot::IsVisible() const { |
| 908 | int nFlags = GetFlags(); |
| 909 | return !((nFlags & ANNOTFLAG_INVISIBLE) || (nFlags & ANNOTFLAG_HIDDEN) || |
| 910 | (nFlags & ANNOTFLAG_NOVIEW)); |
| 911 | } |
| 912 | |
| 913 | CPDF_Action CPDFSDK_BAAnnot::GetAction() const { |
| 914 | return CPDF_Action(m_pAnnot->GetAnnotDict()->GetDict("A")); |
| 915 | } |
| 916 | |
| 917 | void CPDFSDK_BAAnnot::SetAction(const CPDF_Action& action) { |
| 918 | ASSERT(action); |
| 919 | if ((CPDF_Action&)action != |
| 920 | CPDF_Action(m_pAnnot->GetAnnotDict()->GetDict("A"))) { |
| 921 | CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); |
| 922 | CPDF_Dictionary* pDict = action.GetDict(); |
| 923 | if (pDict && pDict->GetObjNum() == 0) { |
| 924 | pDoc->AddIndirectObject(pDict); |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 925 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 926 | m_pAnnot->GetAnnotDict()->SetAtReference("A", pDoc, pDict->GetObjNum()); |
| 927 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 928 | } |
| 929 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 930 | void CPDFSDK_BAAnnot::RemoveAction() { |
| 931 | m_pAnnot->GetAnnotDict()->RemoveAt("A"); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 932 | } |
| 933 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 934 | CPDF_AAction CPDFSDK_BAAnnot::GetAAction() const { |
| 935 | return m_pAnnot->GetAnnotDict()->GetDict("AA"); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 936 | } |
| 937 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 938 | void CPDFSDK_BAAnnot::SetAAction(const CPDF_AAction& aa) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 939 | if ((CPDF_AAction&)aa != m_pAnnot->GetAnnotDict()->GetDict("AA")) |
| 940 | m_pAnnot->GetAnnotDict()->SetAt("AA", (CPDF_AAction&)aa); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 941 | } |
| 942 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 943 | void CPDFSDK_BAAnnot::RemoveAAction() { |
| 944 | m_pAnnot->GetAnnotDict()->RemoveAt("AA"); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 945 | } |
| 946 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 947 | CPDF_Action CPDFSDK_BAAnnot::GetAAction(CPDF_AAction::AActionType eAAT) { |
| 948 | CPDF_AAction AAction = GetAAction(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 949 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 950 | if (AAction.ActionExist(eAAT)) |
| 951 | return AAction.GetAction(eAAT); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 952 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 953 | if (eAAT == CPDF_AAction::ButtonUp) |
| 954 | return GetAction(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 955 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 956 | return CPDF_Action(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 957 | } |
| 958 | |
Tom Sepez | 51da093 | 2015-11-25 16:05:49 -0800 | [diff] [blame] | 959 | #ifdef PDF_ENABLE_XFA |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 960 | FX_BOOL CPDFSDK_BAAnnot::IsXFAField() { |
| 961 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 962 | } |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 963 | #endif // PDF_ENABLE_XFA |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 964 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 965 | void CPDFSDK_BAAnnot::Annot_OnDraw(CFX_RenderDevice* pDevice, |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 966 | CFX_Matrix* pUser2Device, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 967 | CPDF_RenderOptions* pOptions) { |
| 968 | m_pAnnot->GetAPForm(m_pPageView->GetPDFPage(), CPDF_Annot::Normal); |
| 969 | m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, pUser2Device, |
| 970 | CPDF_Annot::Normal, NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 971 | } |
| 972 | |
Tom Sepez | 50d12ad | 2015-11-24 09:50:51 -0800 | [diff] [blame] | 973 | UnderlyingPageType* CPDFSDK_Annot::GetUnderlyingPage() { |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 974 | #ifdef PDF_ENABLE_XFA |
Tom Sepez | 50d12ad | 2015-11-24 09:50:51 -0800 | [diff] [blame] | 975 | return GetPDFXFAPage(); |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 976 | #else // PDF_ENABLE_XFA |
| 977 | return GetPDFPage(); |
| 978 | #endif // PDF_ENABLE_XFA |
Tom Sepez | 50d12ad | 2015-11-24 09:50:51 -0800 | [diff] [blame] | 979 | } |
| 980 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 981 | CPDF_Page* CPDFSDK_Annot::GetPDFPage() { |
| 982 | if (m_pPageView) |
| 983 | return m_pPageView->GetPDFPage(); |
| 984 | return NULL; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 985 | } |
| 986 | |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 987 | #ifdef PDF_ENABLE_XFA |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 988 | CPDFXFA_Page* CPDFSDK_Annot::GetPDFXFAPage() { |
| 989 | if (m_pPageView) |
| 990 | return m_pPageView->GetPDFXFAPage(); |
| 991 | return NULL; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 992 | } |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 993 | #endif // PDF_ENABLE_XFA |