| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | |
| 6 | |
| 7 #ifndef FPDFSDK_INCLUDE_JAVASCRIPT_DOCUMENT_H_ | |
| 8 #define FPDFSDK_INCLUDE_JAVASCRIPT_DOCUMENT_H_ | |
| 9 | |
| 10 #include "JS_Define.h" | |
| 11 | |
| 12 class PrintParamsObj : public CJS_EmbedObj { | |
| 13 public: | |
| 14 PrintParamsObj(CJS_Object* pJSObject); | |
| 15 ~PrintParamsObj() override {} | |
| 16 | |
| 17 public: | |
| 18 FX_BOOL bUI; | |
| 19 int nStart; | |
| 20 int nEnd; | |
| 21 FX_BOOL bSilent; | |
| 22 FX_BOOL bShrinkToFit; | |
| 23 FX_BOOL bPrintAsImage; | |
| 24 FX_BOOL bReverse; | |
| 25 FX_BOOL bAnnotations; | |
| 26 }; | |
| 27 | |
| 28 class CJS_PrintParamsObj : public CJS_Object { | |
| 29 public: | |
| 30 CJS_PrintParamsObj(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {} | |
| 31 ~CJS_PrintParamsObj() override {} | |
| 32 | |
| 33 DECLARE_JS_CLASS(CJS_PrintParamsObj); | |
| 34 }; | |
| 35 | |
| 36 class Icon; | |
| 37 class Field; | |
| 38 | |
| 39 struct IconElement { | |
| 40 IconElement() : IconName(L""), NextIcon(NULL), IconStream(NULL) {} | |
| 41 virtual ~IconElement() {} | |
| 42 CFX_WideString IconName; | |
| 43 IconElement* NextIcon; | |
| 44 Icon* IconStream; | |
| 45 }; | |
| 46 | |
| 47 class IconTree { | |
| 48 public: | |
| 49 IconTree() : m_pHead(NULL), m_pEnd(NULL), m_iLength(0) {} | |
| 50 | |
| 51 virtual ~IconTree() {} | |
| 52 | |
| 53 public: | |
| 54 void InsertIconElement(IconElement* pNewIcon); | |
| 55 void DeleteIconTree(); | |
| 56 int GetLength(); | |
| 57 IconElement* operator[](int iIndex); | |
| 58 | |
| 59 private: | |
| 60 IconElement* m_pHead; | |
| 61 IconElement* m_pEnd; | |
| 62 int m_iLength; | |
| 63 }; | |
| 64 | |
| 65 struct CJS_DelayData; | |
| 66 struct CJS_DelayAnnot; | |
| 67 struct CJS_AnnotObj; | |
| 68 | |
| 69 class Document : public CJS_EmbedObj { | |
| 70 public: | |
| 71 Document(CJS_Object* pJSObject); | |
| 72 ~Document() override; | |
| 73 | |
| 74 public: | |
| 75 FX_BOOL ADBE(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); | |
| 76 FX_BOOL author(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); | |
| 77 FX_BOOL baseURL(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); | |
| 78 FX_BOOL bookmarkRoot(IFXJS_Context* cc, | |
| 79 CJS_PropValue& vp, | |
| 80 CFX_WideString& sError); | |
| 81 FX_BOOL calculate(IFXJS_Context* cc, | |
| 82 CJS_PropValue& vp, | |
| 83 CFX_WideString& sError); | |
| 84 FX_BOOL Collab(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); | |
| 85 FX_BOOL creationDate(IFXJS_Context* cc, | |
| 86 CJS_PropValue& vp, | |
| 87 CFX_WideString& sError); | |
| 88 FX_BOOL creator(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); | |
| 89 FX_BOOL delay(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); | |
| 90 FX_BOOL dirty(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); | |
| 91 FX_BOOL documentFileName(IFXJS_Context* cc, | |
| 92 CJS_PropValue& vp, | |
| 93 CFX_WideString& sError); | |
| 94 FX_BOOL external(IFXJS_Context* cc, | |
| 95 CJS_PropValue& vp, | |
| 96 CFX_WideString& sError); | |
| 97 FX_BOOL filesize(IFXJS_Context* cc, | |
| 98 CJS_PropValue& vp, | |
| 99 CFX_WideString& sError); | |
| 100 FX_BOOL icons(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); | |
| 101 FX_BOOL info(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); | |
| 102 FX_BOOL keywords(IFXJS_Context* cc, | |
| 103 CJS_PropValue& vp, | |
| 104 CFX_WideString& sError); | |
| 105 FX_BOOL layout(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); | |
| 106 FX_BOOL media(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); | |
| 107 FX_BOOL modDate(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); | |
| 108 FX_BOOL mouseX(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); | |
| 109 FX_BOOL mouseY(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); | |
| 110 FX_BOOL numFields(IFXJS_Context* cc, | |
| 111 CJS_PropValue& vp, | |
| 112 CFX_WideString& sError); | |
| 113 FX_BOOL numPages(IFXJS_Context* cc, | |
| 114 CJS_PropValue& vp, | |
| 115 CFX_WideString& sError); | |
| 116 FX_BOOL pageNum(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); | |
| 117 FX_BOOL pageWindowRect(IFXJS_Context* cc, | |
| 118 CJS_PropValue& vp, | |
| 119 CFX_WideString& sError); | |
| 120 FX_BOOL path(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); | |
| 121 FX_BOOL producer(IFXJS_Context* cc, | |
| 122 CJS_PropValue& vp, | |
| 123 CFX_WideString& sError); | |
| 124 FX_BOOL subject(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); | |
| 125 FX_BOOL title(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); | |
| 126 FX_BOOL zoom(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); | |
| 127 FX_BOOL zoomType(IFXJS_Context* cc, | |
| 128 CJS_PropValue& vp, | |
| 129 CFX_WideString& sError); | |
| 130 | |
| 131 FX_BOOL addAnnot(IFXJS_Context* cc, | |
| 132 const CJS_Parameters& params, | |
| 133 CJS_Value& vRet, | |
| 134 CFX_WideString& sError); | |
| 135 FX_BOOL addField(IFXJS_Context* cc, | |
| 136 const CJS_Parameters& params, | |
| 137 CJS_Value& vRet, | |
| 138 CFX_WideString& sError); | |
| 139 FX_BOOL addLink(IFXJS_Context* cc, | |
| 140 const CJS_Parameters& params, | |
| 141 CJS_Value& vRet, | |
| 142 CFX_WideString& sError); | |
| 143 FX_BOOL addIcon(IFXJS_Context* cc, | |
| 144 const CJS_Parameters& params, | |
| 145 CJS_Value& vRet, | |
| 146 CFX_WideString& sError); | |
| 147 FX_BOOL calculateNow(IFXJS_Context* cc, | |
| 148 const CJS_Parameters& params, | |
| 149 CJS_Value& vRet, | |
| 150 CFX_WideString& sError); | |
| 151 FX_BOOL closeDoc(IFXJS_Context* cc, | |
| 152 const CJS_Parameters& params, | |
| 153 CJS_Value& vRet, | |
| 154 CFX_WideString& sError); | |
| 155 FX_BOOL createDataObject(IFXJS_Context* cc, | |
| 156 const CJS_Parameters& params, | |
| 157 CJS_Value& vRet, | |
| 158 CFX_WideString& sError); | |
| 159 FX_BOOL deletePages(IFXJS_Context* cc, | |
| 160 const CJS_Parameters& params, | |
| 161 CJS_Value& vRet, | |
| 162 CFX_WideString& sError); | |
| 163 FX_BOOL exportAsText(IFXJS_Context* cc, | |
| 164 const CJS_Parameters& params, | |
| 165 CJS_Value& vRet, | |
| 166 CFX_WideString& sError); | |
| 167 FX_BOOL exportAsFDF(IFXJS_Context* cc, | |
| 168 const CJS_Parameters& params, | |
| 169 CJS_Value& vRet, | |
| 170 CFX_WideString& sError); | |
| 171 FX_BOOL exportAsXFDF(IFXJS_Context* cc, | |
| 172 const CJS_Parameters& params, | |
| 173 CJS_Value& vRet, | |
| 174 CFX_WideString& sError); | |
| 175 FX_BOOL extractPages(IFXJS_Context* cc, | |
| 176 const CJS_Parameters& params, | |
| 177 CJS_Value& vRet, | |
| 178 CFX_WideString& sError); | |
| 179 FX_BOOL getAnnot(IFXJS_Context* cc, | |
| 180 const CJS_Parameters& params, | |
| 181 CJS_Value& vRet, | |
| 182 CFX_WideString& sError); | |
| 183 FX_BOOL getAnnots(IFXJS_Context* cc, | |
| 184 const CJS_Parameters& params, | |
| 185 CJS_Value& vRet, | |
| 186 CFX_WideString& sError); | |
| 187 FX_BOOL getAnnot3D(IFXJS_Context* cc, | |
| 188 const CJS_Parameters& params, | |
| 189 CJS_Value& vRet, | |
| 190 CFX_WideString& sError); | |
| 191 FX_BOOL getAnnots3D(IFXJS_Context* cc, | |
| 192 const CJS_Parameters& params, | |
| 193 CJS_Value& vRet, | |
| 194 CFX_WideString& sError); | |
| 195 FX_BOOL getField(IFXJS_Context* cc, | |
| 196 const CJS_Parameters& params, | |
| 197 CJS_Value& vRet, | |
| 198 CFX_WideString& sError); | |
| 199 FX_BOOL getIcon(IFXJS_Context* cc, | |
| 200 const CJS_Parameters& params, | |
| 201 CJS_Value& vRet, | |
| 202 CFX_WideString& sError); | |
| 203 FX_BOOL getLinks(IFXJS_Context* cc, | |
| 204 const CJS_Parameters& params, | |
| 205 CJS_Value& vRet, | |
| 206 CFX_WideString& sError); | |
| 207 FX_BOOL getNthFieldName(IFXJS_Context* cc, | |
| 208 const CJS_Parameters& params, | |
| 209 CJS_Value& vRet, | |
| 210 CFX_WideString& sError); | |
| 211 FX_BOOL getOCGs(IFXJS_Context* cc, | |
| 212 const CJS_Parameters& params, | |
| 213 CJS_Value& vRet, | |
| 214 CFX_WideString& sError); | |
| 215 FX_BOOL getPageBox(IFXJS_Context* cc, | |
| 216 const CJS_Parameters& params, | |
| 217 CJS_Value& vRet, | |
| 218 CFX_WideString& sError); | |
| 219 FX_BOOL getPageNthWord(IFXJS_Context* cc, | |
| 220 const CJS_Parameters& params, | |
| 221 CJS_Value& vRet, | |
| 222 CFX_WideString& sError); | |
| 223 FX_BOOL getPageNthWordQuads(IFXJS_Context* cc, | |
| 224 const CJS_Parameters& params, | |
| 225 CJS_Value& vRet, | |
| 226 CFX_WideString& sError); | |
| 227 FX_BOOL getPageNumWords(IFXJS_Context* cc, | |
| 228 const CJS_Parameters& params, | |
| 229 CJS_Value& vRet, | |
| 230 CFX_WideString& sError); | |
| 231 FX_BOOL getPrintParams(IFXJS_Context* cc, | |
| 232 const CJS_Parameters& params, | |
| 233 CJS_Value& vRet, | |
| 234 CFX_WideString& sError); | |
| 235 FX_BOOL getURL(IFXJS_Context* cc, | |
| 236 const CJS_Parameters& params, | |
| 237 CJS_Value& vRet, | |
| 238 CFX_WideString& sError); | |
| 239 FX_BOOL importAnFDF(IFXJS_Context* cc, | |
| 240 const CJS_Parameters& params, | |
| 241 CJS_Value& vRet, | |
| 242 CFX_WideString& sError); | |
| 243 FX_BOOL importAnXFDF(IFXJS_Context* cc, | |
| 244 const CJS_Parameters& params, | |
| 245 CJS_Value& vRet, | |
| 246 CFX_WideString& sError); | |
| 247 FX_BOOL importTextData(IFXJS_Context* cc, | |
| 248 const CJS_Parameters& params, | |
| 249 CJS_Value& vRet, | |
| 250 CFX_WideString& sError); | |
| 251 FX_BOOL insertPages(IFXJS_Context* cc, | |
| 252 const CJS_Parameters& params, | |
| 253 CJS_Value& vRet, | |
| 254 CFX_WideString& sError); | |
| 255 FX_BOOL mailForm(IFXJS_Context* cc, | |
| 256 const CJS_Parameters& params, | |
| 257 CJS_Value& vRet, | |
| 258 CFX_WideString& sError); | |
| 259 FX_BOOL print(IFXJS_Context* cc, | |
| 260 const CJS_Parameters& params, | |
| 261 CJS_Value& vRet, | |
| 262 CFX_WideString& sError); | |
| 263 FX_BOOL removeField(IFXJS_Context* cc, | |
| 264 const CJS_Parameters& params, | |
| 265 CJS_Value& vRet, | |
| 266 CFX_WideString& sError); | |
| 267 FX_BOOL replacePages(IFXJS_Context* cc, | |
| 268 const CJS_Parameters& params, | |
| 269 CJS_Value& vRet, | |
| 270 CFX_WideString& sError); | |
| 271 FX_BOOL resetForm(IFXJS_Context* cc, | |
| 272 const CJS_Parameters& params, | |
| 273 CJS_Value& vRet, | |
| 274 CFX_WideString& sError); | |
| 275 FX_BOOL saveAs(IFXJS_Context* cc, | |
| 276 const CJS_Parameters& params, | |
| 277 CJS_Value& vRet, | |
| 278 CFX_WideString& sError); | |
| 279 FX_BOOL submitForm(IFXJS_Context* cc, | |
| 280 const CJS_Parameters& params, | |
| 281 CJS_Value& vRet, | |
| 282 CFX_WideString& sError); | |
| 283 FX_BOOL mailDoc(IFXJS_Context* cc, | |
| 284 const CJS_Parameters& params, | |
| 285 CJS_Value& vRet, | |
| 286 CFX_WideString& sError); | |
| 287 FX_BOOL removeIcon(IFXJS_Context* cc, | |
| 288 const CJS_Parameters& params, | |
| 289 CJS_Value& vRet, | |
| 290 CFX_WideString& sError); | |
| 291 | |
| 292 public: | |
| 293 void AttachDoc(CPDFSDK_Document* pDoc); | |
| 294 CPDFSDK_Document* GetReaderDoc(); | |
| 295 static FX_BOOL ExtractFileName(CPDFSDK_Document* pDoc, | |
| 296 CFX_ByteString& strFileName); | |
| 297 static FX_BOOL ExtractFolderName(CPDFSDK_Document* pDoc, | |
| 298 CFX_ByteString& strFolderName); | |
| 299 void AddDelayData(CJS_DelayData* pData); | |
| 300 void DoFieldDelay(const CFX_WideString& sFieldName, int nControlIndex); | |
| 301 void AddDelayAnnotData(CJS_AnnotObj* pData); | |
| 302 void DoAnnotDelay(); | |
| 303 void SetIsolate(v8::Isolate* isolate) { m_isolate = isolate; } | |
| 304 CJS_Document* GetCJSDoc() const; | |
| 305 | |
| 306 private: | |
| 307 CFX_WideString ReversalStr(CFX_WideString cbFrom); | |
| 308 CFX_WideString CutString(CFX_WideString cbFrom); | |
| 309 bool IsEnclosedInRect(CFX_FloatRect rect, CFX_FloatRect LinkRect); | |
| 310 int CountWords(CPDF_TextObject* pTextObj); | |
| 311 CFX_WideString GetObjWordStr(CPDF_TextObject* pTextObj, int nWordIndex); | |
| 312 | |
| 313 v8::Isolate* m_isolate; | |
| 314 IconTree* m_pIconTree; | |
| 315 CPDFSDK_Document* m_pDocument; | |
| 316 CFX_WideString m_cwBaseURL; | |
| 317 bool m_bDelay; | |
| 318 CFX_ArrayTemplate<CJS_DelayData*> m_DelayData; | |
| 319 CFX_ArrayTemplate<CJS_AnnotObj*> m_DelayAnnotData; | |
| 320 }; | |
| 321 | |
| 322 class CJS_Document : public CJS_Object { | |
| 323 public: | |
| 324 explicit CJS_Document(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {} | |
| 325 ~CJS_Document() override {} | |
| 326 | |
| 327 // CJS_Object | |
| 328 FX_BOOL InitInstance(IFXJS_Context* cc) override; | |
| 329 | |
| 330 DECLARE_JS_CLASS(CJS_Document); | |
| 331 | |
| 332 JS_STATIC_PROP(ADBE, Document); | |
| 333 JS_STATIC_PROP(author, Document); | |
| 334 JS_STATIC_PROP(baseURL, Document); | |
| 335 JS_STATIC_PROP(bookmarkRoot, Document); | |
| 336 JS_STATIC_PROP(calculate, Document); | |
| 337 JS_STATIC_PROP(Collab, Document); | |
| 338 JS_STATIC_PROP(creationDate, Document); | |
| 339 JS_STATIC_PROP(creator, Document); | |
| 340 JS_STATIC_PROP(delay, Document); | |
| 341 JS_STATIC_PROP(dirty, Document); | |
| 342 JS_STATIC_PROP(documentFileName, Document); | |
| 343 JS_STATIC_PROP(external, Document); | |
| 344 JS_STATIC_PROP(filesize, Document); | |
| 345 JS_STATIC_PROP(icons, Document); | |
| 346 JS_STATIC_PROP(info, Document); | |
| 347 JS_STATIC_PROP(keywords, Document); | |
| 348 JS_STATIC_PROP(layout, Document); | |
| 349 JS_STATIC_PROP(media, Document); | |
| 350 JS_STATIC_PROP(modDate, Document); | |
| 351 JS_STATIC_PROP(mouseX, Document); | |
| 352 JS_STATIC_PROP(mouseY, Document); | |
| 353 JS_STATIC_PROP(numFields, Document); | |
| 354 JS_STATIC_PROP(numPages, Document); | |
| 355 JS_STATIC_PROP(pageNum, Document); | |
| 356 JS_STATIC_PROP(pageWindowRect, Document); | |
| 357 JS_STATIC_PROP(path, Document); | |
| 358 JS_STATIC_PROP(producer, Document); | |
| 359 JS_STATIC_PROP(subject, Document); | |
| 360 JS_STATIC_PROP(title, Document); | |
| 361 JS_STATIC_PROP(zoom, Document); | |
| 362 JS_STATIC_PROP(zoomType, Document); | |
| 363 | |
| 364 JS_STATIC_METHOD(addAnnot, Document); | |
| 365 JS_STATIC_METHOD(addField, Document); | |
| 366 JS_STATIC_METHOD(addLink, Document); | |
| 367 JS_STATIC_METHOD(addIcon, Document); | |
| 368 JS_STATIC_METHOD(calculateNow, Document); | |
| 369 JS_STATIC_METHOD(closeDoc, Document); | |
| 370 JS_STATIC_METHOD(createDataObject, Document); | |
| 371 JS_STATIC_METHOD(deletePages, Document); | |
| 372 JS_STATIC_METHOD(exportAsText, Document); | |
| 373 JS_STATIC_METHOD(exportAsFDF, Document); | |
| 374 JS_STATIC_METHOD(exportAsXFDF, Document); | |
| 375 JS_STATIC_METHOD(extractPages, Document); | |
| 376 JS_STATIC_METHOD(getAnnot, Document); | |
| 377 JS_STATIC_METHOD(getAnnots, Document); | |
| 378 JS_STATIC_METHOD(getAnnot3D, Document); | |
| 379 JS_STATIC_METHOD(getAnnots3D, Document); | |
| 380 JS_STATIC_METHOD(getField, Document); | |
| 381 JS_STATIC_METHOD(getIcon, Document); | |
| 382 JS_STATIC_METHOD(getLinks, Document); | |
| 383 JS_STATIC_METHOD(getNthFieldName, Document); | |
| 384 JS_STATIC_METHOD(getOCGs, Document); | |
| 385 JS_STATIC_METHOD(getPageBox, Document); | |
| 386 JS_STATIC_METHOD(getPageNthWord, Document); | |
| 387 JS_STATIC_METHOD(getPageNthWordQuads, Document); | |
| 388 JS_STATIC_METHOD(getPageNumWords, Document); | |
| 389 JS_STATIC_METHOD(getPrintParams, Document); | |
| 390 JS_STATIC_METHOD(getURL, Document); | |
| 391 JS_STATIC_METHOD(importAnFDF, Document); | |
| 392 JS_STATIC_METHOD(importAnXFDF, Document); | |
| 393 JS_STATIC_METHOD(importTextData, Document); | |
| 394 JS_STATIC_METHOD(insertPages, Document); | |
| 395 JS_STATIC_METHOD(mailForm, Document); | |
| 396 JS_STATIC_METHOD(print, Document); | |
| 397 JS_STATIC_METHOD(removeField, Document); | |
| 398 JS_STATIC_METHOD(replacePages, Document); | |
| 399 JS_STATIC_METHOD(removeIcon, Document); | |
| 400 JS_STATIC_METHOD(resetForm, Document); | |
| 401 JS_STATIC_METHOD(saveAs, Document); | |
| 402 JS_STATIC_METHOD(submitForm, Document); | |
| 403 JS_STATIC_METHOD(mailDoc, Document); | |
| 404 }; | |
| 405 | |
| 406 #endif // FPDFSDK_INCLUDE_JAVASCRIPT_DOCUMENT_H_ | |
| OLD | NEW |