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