| 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/javascript/JavaScript.h" | 7 #include "../../include/javascript/JavaScript.h" |
| 8 #include "../../include/javascript/IJavaScript.h" | 8 #include "../../include/javascript/IJavaScript.h" |
| 9 #include "../../include/javascript/JS_Define.h" | 9 #include "../../include/javascript/JS_Define.h" |
| 10 #include "../../include/javascript/JS_Object.h" | 10 #include "../../include/javascript/JS_Object.h" |
| 11 #include "../../include/javascript/JS_Value.h" | 11 #include "../../include/javascript/JS_Value.h" |
| 12 #include "../../include/javascript/Document.h" | 12 #include "../../include/javascript/Document.h" |
| 13 #include "../../include/javascript/JS_EventHandler.h" | 13 #include "../../include/javascript/JS_EventHandler.h" |
| 14 #include "../../include/javascript/JS_Context.h" | 14 #include "../../include/javascript/JS_Context.h" |
| 15 #include "../../include/javascript/JS_Runtime.h" | 15 #include "../../include/javascript/JS_Runtime.h" |
| 16 #include "../../include/javascript/app.h" | 16 #include "../../include/javascript/app.h" |
| 17 #include "../../include/javascript/Field.h" | 17 #include "../../include/javascript/Field.h" |
| 18 #include "../../include/javascript/Icon.h" | 18 #include "../../include/javascript/Icon.h" |
| 19 #include "../../include/javascript/resource.h" | 19 #include "../../include/javascript/resource.h" |
| 20 | 20 |
| 21 #include "../../../third_party/base/numerics/safe_math.h" | 21 #include "../../../third_party/base/numerics/safe_math.h" |
| 22 | 22 |
| 23 static v8::Isolate* GetIsolate(IFXJS_Context* cc) | 23 static v8::Isolate* GetIsolate(IFXJS_Context* cc) |
| 24 { | 24 { |
| 25 » CJS_Context* pContext = (CJS_Context *)cc; | 25 CJS_Context* pContext = (CJS_Context *)cc; |
| 26 » ASSERT(pContext != NULL); | 26 ASSERT(pContext != NULL); |
| 27 | 27 |
| 28 » CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 28 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 29 » ASSERT(pRuntime != NULL); | 29 ASSERT(pRuntime != NULL); |
| 30 | 30 |
| 31 » return pRuntime->GetIsolate(); | 31 return pRuntime->GetIsolate(); |
| 32 } | 32 } |
| 33 | 33 |
| 34 BEGIN_JS_STATIC_CONST(CJS_PrintParamsObj) | 34 BEGIN_JS_STATIC_CONST(CJS_PrintParamsObj) |
| 35 END_JS_STATIC_CONST() | 35 END_JS_STATIC_CONST() |
| 36 | 36 |
| 37 BEGIN_JS_STATIC_PROP(CJS_PrintParamsObj) | 37 BEGIN_JS_STATIC_PROP(CJS_PrintParamsObj) |
| 38 END_JS_STATIC_PROP() | 38 END_JS_STATIC_PROP() |
| 39 | 39 |
| 40 BEGIN_JS_STATIC_METHOD(CJS_PrintParamsObj) | 40 BEGIN_JS_STATIC_METHOD(CJS_PrintParamsObj) |
| 41 END_JS_STATIC_METHOD() | 41 END_JS_STATIC_METHOD() |
| 42 | 42 |
| 43 IMPLEMENT_JS_CLASS(CJS_PrintParamsObj, PrintParamsObj) | 43 IMPLEMENT_JS_CLASS(CJS_PrintParamsObj, PrintParamsObj) |
| 44 | 44 |
| 45 PrintParamsObj::PrintParamsObj(CJS_Object* pJSObject) | 45 PrintParamsObj::PrintParamsObj(CJS_Object* pJSObject) |
| 46 : CJS_EmbedObj(pJSObject) | 46 : CJS_EmbedObj(pJSObject) |
| 47 { | 47 { |
| 48 » bUI = TRUE; | 48 bUI = TRUE; |
| 49 » nStart = 0; | 49 nStart = 0; |
| 50 » nEnd = 0; | 50 nEnd = 0; |
| 51 » bSilent = FALSE; | 51 bSilent = FALSE; |
| 52 » bShrinkToFit = FALSE; | 52 bShrinkToFit = FALSE; |
| 53 » bPrintAsImage = FALSE; | 53 bPrintAsImage = FALSE; |
| 54 » bReverse = FALSE; | 54 bReverse = FALSE; |
| 55 » bAnnotations = TRUE; | 55 bAnnotations = TRUE; |
| 56 } | 56 } |
| 57 | 57 |
| 58 /* ---------------------- Document ---------------------- */ | 58 /* ---------------------- Document ---------------------- */ |
| 59 | 59 |
| 60 #define MINWIDTH 5.0f | 60 #define MINWIDTH 5.0f |
| 61 #define MINHEIGHT 5.0f | 61 #define MINHEIGHT 5.0f |
| 62 | 62 |
| 63 BEGIN_JS_STATIC_CONST(CJS_Document) | 63 BEGIN_JS_STATIC_CONST(CJS_Document) |
| 64 END_JS_STATIC_CONST() | 64 END_JS_STATIC_CONST() |
| 65 | 65 |
| 66 BEGIN_JS_STATIC_PROP(CJS_Document) | 66 BEGIN_JS_STATIC_PROP(CJS_Document) |
| 67 » JS_STATIC_PROP_ENTRY(ADBE) | 67 JS_STATIC_PROP_ENTRY(ADBE) |
| 68 » JS_STATIC_PROP_ENTRY(author) | 68 JS_STATIC_PROP_ENTRY(author) |
| 69 » JS_STATIC_PROP_ENTRY(baseURL) | 69 JS_STATIC_PROP_ENTRY(baseURL) |
| 70 » JS_STATIC_PROP_ENTRY(bookmarkRoot) | 70 JS_STATIC_PROP_ENTRY(bookmarkRoot) |
| 71 » JS_STATIC_PROP_ENTRY(calculate) | 71 JS_STATIC_PROP_ENTRY(calculate) |
| 72 » JS_STATIC_PROP_ENTRY(Collab) | 72 JS_STATIC_PROP_ENTRY(Collab) |
| 73 » JS_STATIC_PROP_ENTRY(creationDate) | 73 JS_STATIC_PROP_ENTRY(creationDate) |
| 74 » JS_STATIC_PROP_ENTRY(creator) | 74 JS_STATIC_PROP_ENTRY(creator) |
| 75 » JS_STATIC_PROP_ENTRY(delay) | 75 JS_STATIC_PROP_ENTRY(delay) |
| 76 » JS_STATIC_PROP_ENTRY(dirty) | 76 JS_STATIC_PROP_ENTRY(dirty) |
| 77 » JS_STATIC_PROP_ENTRY(documentFileName) | 77 JS_STATIC_PROP_ENTRY(documentFileName) |
| 78 » JS_STATIC_PROP_ENTRY(external) | 78 JS_STATIC_PROP_ENTRY(external) |
| 79 » JS_STATIC_PROP_ENTRY(filesize) | 79 JS_STATIC_PROP_ENTRY(filesize) |
| 80 » JS_STATIC_PROP_ENTRY(icons) | 80 JS_STATIC_PROP_ENTRY(icons) |
| 81 » JS_STATIC_PROP_ENTRY(info) | 81 JS_STATIC_PROP_ENTRY(info) |
| 82 » JS_STATIC_PROP_ENTRY(keywords) | 82 JS_STATIC_PROP_ENTRY(keywords) |
| 83 » JS_STATIC_PROP_ENTRY(layout) | 83 JS_STATIC_PROP_ENTRY(layout) |
| 84 » JS_STATIC_PROP_ENTRY(media) | 84 JS_STATIC_PROP_ENTRY(media) |
| 85 » JS_STATIC_PROP_ENTRY(modDate) | 85 JS_STATIC_PROP_ENTRY(modDate) |
| 86 » JS_STATIC_PROP_ENTRY(mouseX) | 86 JS_STATIC_PROP_ENTRY(mouseX) |
| 87 » JS_STATIC_PROP_ENTRY(mouseY) | 87 JS_STATIC_PROP_ENTRY(mouseY) |
| 88 » JS_STATIC_PROP_ENTRY(numFields) | 88 JS_STATIC_PROP_ENTRY(numFields) |
| 89 » JS_STATIC_PROP_ENTRY(numPages) | 89 JS_STATIC_PROP_ENTRY(numPages) |
| 90 » JS_STATIC_PROP_ENTRY(pageNum) | 90 JS_STATIC_PROP_ENTRY(pageNum) |
| 91 » JS_STATIC_PROP_ENTRY(pageWindowRect) | 91 JS_STATIC_PROP_ENTRY(pageWindowRect) |
| 92 » JS_STATIC_PROP_ENTRY(path) | 92 JS_STATIC_PROP_ENTRY(path) |
| 93 » JS_STATIC_PROP_ENTRY(producer) | 93 JS_STATIC_PROP_ENTRY(producer) |
| 94 » JS_STATIC_PROP_ENTRY(subject) | 94 JS_STATIC_PROP_ENTRY(subject) |
| 95 » JS_STATIC_PROP_ENTRY(title) | 95 JS_STATIC_PROP_ENTRY(title) |
| 96 » JS_STATIC_PROP_ENTRY(zoom) | 96 JS_STATIC_PROP_ENTRY(zoom) |
| 97 » JS_STATIC_PROP_ENTRY(zoomType) | 97 JS_STATIC_PROP_ENTRY(zoomType) |
| 98 END_JS_STATIC_PROP() | 98 END_JS_STATIC_PROP() |
| 99 | 99 |
| 100 BEGIN_JS_STATIC_METHOD(CJS_Document) | 100 BEGIN_JS_STATIC_METHOD(CJS_Document) |
| 101 » JS_STATIC_METHOD_ENTRY(addAnnot) | 101 JS_STATIC_METHOD_ENTRY(addAnnot) |
| 102 » JS_STATIC_METHOD_ENTRY(addField) | 102 JS_STATIC_METHOD_ENTRY(addField) |
| 103 » JS_STATIC_METHOD_ENTRY(addLink) | 103 JS_STATIC_METHOD_ENTRY(addLink) |
| 104 » JS_STATIC_METHOD_ENTRY(addIcon) | 104 JS_STATIC_METHOD_ENTRY(addIcon) |
| 105 » JS_STATIC_METHOD_ENTRY(calculateNow) | 105 JS_STATIC_METHOD_ENTRY(calculateNow) |
| 106 » JS_STATIC_METHOD_ENTRY(closeDoc) | 106 JS_STATIC_METHOD_ENTRY(closeDoc) |
| 107 » JS_STATIC_METHOD_ENTRY(createDataObject) | 107 JS_STATIC_METHOD_ENTRY(createDataObject) |
| 108 » JS_STATIC_METHOD_ENTRY(deletePages) | 108 JS_STATIC_METHOD_ENTRY(deletePages) |
| 109 » JS_STATIC_METHOD_ENTRY(exportAsText) | 109 JS_STATIC_METHOD_ENTRY(exportAsText) |
| 110 » JS_STATIC_METHOD_ENTRY(exportAsFDF) | 110 JS_STATIC_METHOD_ENTRY(exportAsFDF) |
| 111 » JS_STATIC_METHOD_ENTRY(exportAsXFDF) | 111 JS_STATIC_METHOD_ENTRY(exportAsXFDF) |
| 112 » JS_STATIC_METHOD_ENTRY(extractPages) | 112 JS_STATIC_METHOD_ENTRY(extractPages) |
| 113 » JS_STATIC_METHOD_ENTRY(getAnnot) | 113 JS_STATIC_METHOD_ENTRY(getAnnot) |
| 114 » JS_STATIC_METHOD_ENTRY(getAnnots) | 114 JS_STATIC_METHOD_ENTRY(getAnnots) |
| 115 » JS_STATIC_METHOD_ENTRY(getAnnot3D) | 115 JS_STATIC_METHOD_ENTRY(getAnnot3D) |
| 116 » JS_STATIC_METHOD_ENTRY(getAnnots3D) | 116 JS_STATIC_METHOD_ENTRY(getAnnots3D) |
| 117 » JS_STATIC_METHOD_ENTRY(getField) | 117 JS_STATIC_METHOD_ENTRY(getField) |
| 118 » JS_STATIC_METHOD_ENTRY(getIcon) | 118 JS_STATIC_METHOD_ENTRY(getIcon) |
| 119 » JS_STATIC_METHOD_ENTRY(getLinks) | 119 JS_STATIC_METHOD_ENTRY(getLinks) |
| 120 » JS_STATIC_METHOD_ENTRY(getNthFieldName) | 120 JS_STATIC_METHOD_ENTRY(getNthFieldName) |
| 121 » JS_STATIC_METHOD_ENTRY(getOCGs) | 121 JS_STATIC_METHOD_ENTRY(getOCGs) |
| 122 » JS_STATIC_METHOD_ENTRY(getPageBox) | 122 JS_STATIC_METHOD_ENTRY(getPageBox) |
| 123 » JS_STATIC_METHOD_ENTRY(getPageNthWord) | 123 JS_STATIC_METHOD_ENTRY(getPageNthWord) |
| 124 » JS_STATIC_METHOD_ENTRY(getPageNthWordQuads) | 124 JS_STATIC_METHOD_ENTRY(getPageNthWordQuads) |
| 125 » JS_STATIC_METHOD_ENTRY(getPageNumWords) | 125 JS_STATIC_METHOD_ENTRY(getPageNumWords) |
| 126 » JS_STATIC_METHOD_ENTRY(getPrintParams) | 126 JS_STATIC_METHOD_ENTRY(getPrintParams) |
| 127 » JS_STATIC_METHOD_ENTRY(getURL) | 127 JS_STATIC_METHOD_ENTRY(getURL) |
| 128 » JS_STATIC_METHOD_ENTRY(importAnFDF) | 128 JS_STATIC_METHOD_ENTRY(importAnFDF) |
| 129 » JS_STATIC_METHOD_ENTRY(importAnXFDF) | 129 JS_STATIC_METHOD_ENTRY(importAnXFDF) |
| 130 » JS_STATIC_METHOD_ENTRY(importTextData) | 130 JS_STATIC_METHOD_ENTRY(importTextData) |
| 131 » JS_STATIC_METHOD_ENTRY(insertPages) | 131 JS_STATIC_METHOD_ENTRY(insertPages) |
| 132 » JS_STATIC_METHOD_ENTRY(mailForm) | 132 JS_STATIC_METHOD_ENTRY(mailForm) |
| 133 » JS_STATIC_METHOD_ENTRY(print) | 133 JS_STATIC_METHOD_ENTRY(print) |
| 134 » JS_STATIC_METHOD_ENTRY(removeField) | 134 JS_STATIC_METHOD_ENTRY(removeField) |
| 135 » JS_STATIC_METHOD_ENTRY(replacePages) | 135 JS_STATIC_METHOD_ENTRY(replacePages) |
| 136 » JS_STATIC_METHOD_ENTRY(resetForm) | 136 JS_STATIC_METHOD_ENTRY(resetForm) |
| 137 » JS_STATIC_METHOD_ENTRY(removeIcon) | 137 JS_STATIC_METHOD_ENTRY(removeIcon) |
| 138 » JS_STATIC_METHOD_ENTRY(saveAs) | 138 JS_STATIC_METHOD_ENTRY(saveAs) |
| 139 » JS_STATIC_METHOD_ENTRY(submitForm) | 139 JS_STATIC_METHOD_ENTRY(submitForm) |
| 140 » JS_STATIC_METHOD_ENTRY(mailDoc) | 140 JS_STATIC_METHOD_ENTRY(mailDoc) |
| 141 END_JS_STATIC_METHOD() | 141 END_JS_STATIC_METHOD() |
| 142 | 142 |
| 143 IMPLEMENT_JS_CLASS(CJS_Document, Document) | 143 IMPLEMENT_JS_CLASS(CJS_Document, Document) |
| 144 | 144 |
| 145 FX_BOOL»CJS_Document::InitInstance(IFXJS_Context* cc) | 145 FX_BOOL CJS_Document::InitInstance(IFXJS_Context* cc) |
| 146 { | 146 { |
| 147 » CJS_Context* pContext = (CJS_Context*)cc; | 147 CJS_Context* pContext = (CJS_Context*)cc; |
| 148 » ASSERT(pContext != NULL); | 148 ASSERT(pContext != NULL); |
| 149 | 149 |
| 150 » Document* pDoc = (Document*)GetEmbedObject(); | 150 Document* pDoc = (Document*)GetEmbedObject(); |
| 151 » ASSERT(pDoc != NULL); | 151 ASSERT(pDoc != NULL); |
| 152 | 152 |
| 153 » pDoc->AttachDoc(pContext->GetReaderDocument()); | 153 pDoc->AttachDoc(pContext->GetReaderDocument()); |
| 154 » pDoc->SetIsolate(pContext->GetJSRuntime()->GetIsolate()); | 154 pDoc->SetIsolate(pContext->GetJSRuntime()->GetIsolate()); |
| 155 » return TRUE; | 155 return TRUE; |
| 156 }; | 156 }; |
| 157 | 157 |
| 158 /* --------------------------------- Document ---------------------------------
*/ | 158 /* --------------------------------- Document ---------------------------------
*/ |
| 159 | 159 |
| 160 Document::Document(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject), | 160 Document::Document(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject), |
| 161 » m_isolate(NULL), | 161 m_isolate(NULL), |
| 162 » m_pIconTree(NULL), | 162 m_pIconTree(NULL), |
| 163 » m_pDocument(NULL), | 163 m_pDocument(NULL), |
| 164 » m_cwBaseURL(L""), | 164 m_cwBaseURL(L""), |
| 165 » m_bDelay(FALSE) | 165 m_bDelay(FALSE) |
| 166 { | 166 { |
| 167 } | 167 } |
| 168 | 168 |
| 169 Document::~Document() | 169 Document::~Document() |
| 170 { | 170 { |
| 171 » if (m_pIconTree) | 171 if (m_pIconTree) |
| 172 » { | 172 { |
| 173 » » m_pIconTree->DeleteIconTree(); | 173 m_pIconTree->DeleteIconTree(); |
| 174 » » delete m_pIconTree; | 174 delete m_pIconTree; |
| 175 » » m_pIconTree = NULL; | 175 m_pIconTree = NULL; |
| 176 » } | 176 } |
| 177 » for (int i=0; i<m_DelayData.GetSize(); i++) | 177 for (int i=0; i<m_DelayData.GetSize(); i++) |
| 178 » { | 178 { |
| 179 » » if (CJS_DelayData* pData = m_DelayData.GetAt(i)) | 179 if (CJS_DelayData* pData = m_DelayData.GetAt(i)) |
| 180 » » { | 180 { |
| 181 » » » delete pData; | 181 delete pData; |
| 182 » » » pData = NULL; | 182 pData = NULL; |
| 183 » » » m_DelayData.SetAt(i, NULL); | 183 m_DelayData.SetAt(i, NULL); |
| 184 | 184 |
| 185 » » } | 185 } |
| 186 » } | 186 } |
| 187 | 187 |
| 188 » m_DelayData.RemoveAll(); | 188 m_DelayData.RemoveAll(); |
| 189 » m_DelayAnnotData.RemoveAll(); | 189 m_DelayAnnotData.RemoveAll(); |
| 190 } | 190 } |
| 191 | 191 |
| 192 //the total number of fileds in document. | 192 //the total number of fileds in document. |
| 193 FX_BOOL Document::numFields(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString
& sError) | 193 FX_BOOL Document::numFields(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString
& sError) |
| 194 { | 194 { |
| 195 » if (vp.IsSetting()) { | 195 if (vp.IsSetting()) { |
| 196 » » CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 196 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
| 197 » » sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); | 197 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); |
| 198 » » return FALSE; | 198 return FALSE; |
| 199 » } | 199 } |
| 200 » CPDFSDK_InterForm *pInterForm = m_pDocument->GetInterForm(); | 200 CPDFSDK_InterForm *pInterForm = m_pDocument->GetInterForm(); |
| 201 » CPDF_InterForm *pPDFForm = pInterForm->GetInterForm(); | 201 CPDF_InterForm *pPDFForm = pInterForm->GetInterForm(); |
| 202 » vp << (int)pPDFForm->CountFields(); | 202 vp << (int)pPDFForm->CountFields(); |
| 203 » return TRUE; | 203 return TRUE; |
| 204 } | 204 } |
| 205 | 205 |
| 206 FX_BOOL Document::dirty(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) | 206 FX_BOOL Document::dirty(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) |
| 207 { | 207 { |
| 208 » ASSERT(m_pDocument != NULL); | 208 ASSERT(m_pDocument != NULL); |
| 209 | 209 |
| 210 » if (vp.IsGetting()) | 210 if (vp.IsGetting()) |
| 211 » { | 211 { |
| 212 » » if (m_pDocument->GetChangeMark()) | 212 if (m_pDocument->GetChangeMark()) |
| 213 » » » vp << true; | 213 vp << true; |
| 214 » » else | 214 else |
| 215 » » » vp << false; | 215 vp << false; |
| 216 » } | 216 } |
| 217 » else | 217 else |
| 218 » { | 218 { |
| 219 » » bool bChanged = false; | 219 bool bChanged = false; |
| 220 | 220 |
| 221 » » vp >> bChanged; | 221 vp >> bChanged; |
| 222 | 222 |
| 223 » » if (bChanged) | 223 if (bChanged) |
| 224 » » » m_pDocument->SetChangeMark(); | 224 m_pDocument->SetChangeMark(); |
| 225 » » else | 225 else |
| 226 » » » m_pDocument->ClearChangeMark(); | 226 m_pDocument->ClearChangeMark(); |
| 227 » } | 227 } |
| 228 | 228 |
| 229 » return TRUE; | 229 return TRUE; |
| 230 } | 230 } |
| 231 | 231 |
| 232 FX_BOOL Document::ADBE(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr
ror) | 232 FX_BOOL Document::ADBE(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr
ror) |
| 233 { | 233 { |
| 234 » ASSERT(m_pDocument != NULL); | 234 ASSERT(m_pDocument != NULL); |
| 235 | 235 |
| 236 » if (vp.IsGetting()) | 236 if (vp.IsGetting()) |
| 237 » { | 237 { |
| 238 » » vp.SetNull(); | 238 vp.SetNull(); |
| 239 » } | 239 } |
| 240 » else | 240 else |
| 241 » { | 241 { |
| 242 » } | 242 } |
| 243 | 243 |
| 244 » return TRUE; | 244 return TRUE; |
| 245 } | 245 } |
| 246 | 246 |
| 247 FX_BOOL Document::pageNum(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) | 247 FX_BOOL Document::pageNum(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) |
| 248 { | 248 { |
| 249 » ASSERT(m_pDocument != NULL); | 249 ASSERT(m_pDocument != NULL); |
| 250 | 250 |
| 251 » if (vp.IsGetting()) | 251 if (vp.IsGetting()) |
| 252 » { | 252 { |
| 253 » » if (CPDFSDK_PageView* pPageView = m_pDocument->GetCurrentView()) | 253 if (CPDFSDK_PageView* pPageView = m_pDocument->GetCurrentView()) |
| 254 » » { | 254 { |
| 255 » » » vp << pPageView->GetPageIndex(); | 255 vp << pPageView->GetPageIndex(); |
| 256 » » } | 256 } |
| 257 » } | 257 } |
| 258 » else | 258 else |
| 259 » { | 259 { |
| 260 » » int iPageCount = m_pDocument->GetPageCount(); | 260 int iPageCount = m_pDocument->GetPageCount(); |
| 261 » » int iPageNum = 0; | 261 int iPageNum = 0; |
| 262 » » vp >> iPageNum; | 262 vp >> iPageNum; |
| 263 | 263 |
| 264 » » CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | 264 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); |
| 265 » » if (iPageNum >= 0 && iPageNum < iPageCount) | 265 if (iPageNum >= 0 && iPageNum < iPageCount) |
| 266 » » { | 266 { |
| 267 » » » pEnv->JS_docgotoPage(iPageNum); | 267 pEnv->JS_docgotoPage(iPageNum); |
| 268 » » } | 268 } |
| 269 » » else if (iPageNum >= iPageCount) | 269 else if (iPageNum >= iPageCount) |
| 270 » » { | 270 { |
| 271 » » » pEnv->JS_docgotoPage(iPageCount-1); | 271 pEnv->JS_docgotoPage(iPageCount-1); |
| 272 » » } | 272 } |
| 273 » » else if (iPageNum < 0) | 273 else if (iPageNum < 0) |
| 274 » » { | 274 { |
| 275 » » » pEnv->JS_docgotoPage(0); | 275 pEnv->JS_docgotoPage(0); |
| 276 » » } | 276 } |
| 277 » } | 277 } |
| 278 | 278 |
| 279 » return TRUE; | 279 return TRUE; |
| 280 } | 280 } |
| 281 | 281 |
| 282 FX_BOOL Document::ParserParams(JSObject* pObj,CJS_AnnotObj& annotobj) | 282 FX_BOOL Document::ParserParams(JSObject* pObj,CJS_AnnotObj& annotobj) |
| 283 { | 283 { |
| 284 » // Not supported. | 284 // Not supported. |
| 285 » return TRUE; | 285 return TRUE; |
| 286 } | 286 } |
| 287 | 287 |
| 288 FX_BOOL Document::addAnnot(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) | 288 FX_BOOL Document::addAnnot(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) |
| 289 { | 289 { |
| 290 » // Not supported. | 290 // Not supported. |
| 291 » return TRUE; | 291 return TRUE; |
| 292 } | 292 } |
| 293 | 293 |
| 294 FX_BOOL Document::addField(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) | 294 FX_BOOL Document::addField(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) |
| 295 { | 295 { |
| 296 » // Not supported. | 296 // Not supported. |
| 297 » return TRUE; | 297 return TRUE; |
| 298 } | 298 } |
| 299 | 299 |
| 300 FX_BOOL Document::exportAsText(IFXJS_Context* cc, const CJS_Parameters& params,
CJS_Value& vRet, CFX_WideString& sError) | 300 FX_BOOL Document::exportAsText(IFXJS_Context* cc, const CJS_Parameters& params,
CJS_Value& vRet, CFX_WideString& sError) |
| 301 { | 301 { |
| 302 » // Unsafe, not supported. | 302 // Unsafe, not supported. |
| 303 » return TRUE; | 303 return TRUE; |
| 304 } | 304 } |
| 305 | 305 |
| 306 FX_BOOL Document::exportAsFDF(IFXJS_Context* cc, const CJS_Parameters& params, C
JS_Value& vRet, CFX_WideString& sError) | 306 FX_BOOL Document::exportAsFDF(IFXJS_Context* cc, const CJS_Parameters& params, C
JS_Value& vRet, CFX_WideString& sError) |
| 307 { | 307 { |
| 308 » // Unsafe, not supported. | 308 // Unsafe, not supported. |
| 309 » return TRUE; | 309 return TRUE; |
| 310 } | 310 } |
| 311 | 311 |
| 312 FX_BOOL Document::exportAsXFDF(IFXJS_Context* cc, const CJS_Parameters& params,
CJS_Value& vRet, CFX_WideString& sError) | 312 FX_BOOL Document::exportAsXFDF(IFXJS_Context* cc, const CJS_Parameters& params,
CJS_Value& vRet, CFX_WideString& sError) |
| 313 { | 313 { |
| 314 » // Unsafe, not supported. | 314 // Unsafe, not supported. |
| 315 » return TRUE; | 315 return TRUE; |
| 316 } | 316 } |
| 317 | 317 |
| 318 //Maps a field object in PDF document to a JavaScript variable | 318 //Maps a field object in PDF document to a JavaScript variable |
| 319 //comment: | 319 //comment: |
| 320 //note: the paremter cName, this is clue how to treat if the cName is not a vali
able filed name in this document | 320 //note: the paremter cName, this is clue how to treat if the cName is not a vali
able filed name in this document |
| 321 | 321 |
| 322 FX_BOOL Document::getField(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) | 322 FX_BOOL Document::getField(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) |
| 323 { | 323 { |
| 324 » CJS_Context* pContext = (CJS_Context*)cc; | 324 CJS_Context* pContext = (CJS_Context*)cc; |
| 325 » if (params.size() < 1) { | 325 if (params.size() < 1) { |
| 326 » » sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 326 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 327 » » return FALSE; | 327 return FALSE; |
| 328 » } | 328 } |
| 329 | 329 |
| 330 » CFX_WideString wideName = params[0].ToCFXWideString(); | 330 CFX_WideString wideName = params[0].ToCFXWideString(); |
| 331 | 331 |
| 332 » CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); | 332 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); |
| 333 » CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); | 333 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); |
| 334 » if (pPDFForm->CountFields(wideName) <= 0) | 334 if (pPDFForm->CountFields(wideName) <= 0) |
| 335 » { | 335 { |
| 336 » » vRet.SetNull(); | 336 vRet.SetNull(); |
| 337 » » return TRUE; | 337 return TRUE; |
| 338 » } | 338 } |
| 339 | 339 |
| 340 » CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 340 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 341 » JSFXObject pFieldObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObj
DefnID(*pRuntime, L"Field")); | 341 JSFXObject pFieldObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDefn
ID(*pRuntime, L"Field")); |
| 342 | 342 |
| 343 » v8::Isolate* isolate = GetIsolate(cc); | 343 v8::Isolate* isolate = GetIsolate(cc); |
| 344 » CJS_Field* pJSField = (CJS_Field*)JS_GetPrivate(isolate,pFieldObj); | 344 CJS_Field* pJSField = (CJS_Field*)JS_GetPrivate(isolate,pFieldObj); |
| 345 » Field* pField = (Field *)pJSField->GetEmbedObject(); | 345 Field* pField = (Field *)pJSField->GetEmbedObject(); |
| 346 » pField->AttachField(this, wideName); | 346 pField->AttachField(this, wideName); |
| 347 | 347 |
| 348 » vRet = pJSField; | 348 vRet = pJSField; |
| 349 » return TRUE; | 349 return TRUE; |
| 350 } | 350 } |
| 351 | 351 |
| 352 //Gets the name of the nth field in the document | 352 //Gets the name of the nth field in the document |
| 353 FX_BOOL Document::getNthFieldName(IFXJS_Context* cc, const CJS_Parameters& param
s, CJS_Value& vRet, CFX_WideString& sError) | 353 FX_BOOL Document::getNthFieldName(IFXJS_Context* cc, const CJS_Parameters& param
s, CJS_Value& vRet, CFX_WideString& sError) |
| 354 { | 354 { |
| 355 » CJS_Context* pContext = (CJS_Context*)cc; | 355 CJS_Context* pContext = (CJS_Context*)cc; |
| 356 » if (params.size() != 1) { | 356 if (params.size() != 1) { |
| 357 » » sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 357 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 358 » » return FALSE; | 358 return FALSE; |
| 359 » } | 359 } |
| 360 | 360 |
| 361 » int nIndex = params[0].ToInt(); | 361 int nIndex = params[0].ToInt(); |
| 362 » if (nIndex < 0) { | 362 if (nIndex < 0) { |
| 363 » » sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); | 363 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); |
| 364 » » return FALSE; | 364 return FALSE; |
| 365 » } | 365 } |
| 366 | 366 |
| 367 » CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); | 367 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); |
| 368 » CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); | 368 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); |
| 369 » CPDF_FormField* pField = pPDFForm->GetField(nIndex); | 369 CPDF_FormField* pField = pPDFForm->GetField(nIndex); |
| 370 » if (!pField) | 370 if (!pField) |
| 371 » » return FALSE; | 371 return FALSE; |
| 372 | 372 |
| 373 » vRet = pField->GetFullName().c_str(); | 373 vRet = pField->GetFullName().c_str(); |
| 374 » return TRUE; | 374 return TRUE; |
| 375 } | 375 } |
| 376 | 376 |
| 377 FX_BOOL Document::importAnFDF(IFXJS_Context* cc, const CJS_Parameters& params, C
JS_Value& vRet, CFX_WideString& sError) | 377 FX_BOOL Document::importAnFDF(IFXJS_Context* cc, const CJS_Parameters& params, C
JS_Value& vRet, CFX_WideString& sError) |
| 378 { | 378 { |
| 379 » // Unsafe, not supported. | 379 // Unsafe, not supported. |
| 380 » return TRUE; | 380 return TRUE; |
| 381 } | 381 } |
| 382 | 382 |
| 383 FX_BOOL Document::importAnXFDF(IFXJS_Context* cc, const CJS_Parameters& params,
CJS_Value& vRet, CFX_WideString& sError) | 383 FX_BOOL Document::importAnXFDF(IFXJS_Context* cc, const CJS_Parameters& params,
CJS_Value& vRet, CFX_WideString& sError) |
| 384 { | 384 { |
| 385 » // Unsafe, not supported. | 385 // Unsafe, not supported. |
| 386 » return TRUE; | 386 return TRUE; |
| 387 } | 387 } |
| 388 | 388 |
| 389 FX_BOOL Document::importTextData(IFXJS_Context* cc, const CJS_Parameters& params
, CJS_Value& vRet, CFX_WideString& sError) | 389 FX_BOOL Document::importTextData(IFXJS_Context* cc, const CJS_Parameters& params
, CJS_Value& vRet, CFX_WideString& sError) |
| 390 { | 390 { |
| 391 » // Unsafe, not supported. | 391 // Unsafe, not supported. |
| 392 » return TRUE; | 392 return TRUE; |
| 393 } | 393 } |
| 394 | 394 |
| 395 //exports the form data and mails the resulting fdf file as an attachment to all
recipients. | 395 //exports the form data and mails the resulting fdf file as an attachment to all
recipients. |
| 396 //comment: need reader supports | 396 //comment: need reader supports |
| 397 //note: | 397 //note: |
| 398 //int CPDFSDK_Document::mailForm(FX_BOOL bUI,String cto,string ccc,string cbcc,s
tring cSubject,string cms); | 398 //int CPDFSDK_Document::mailForm(FX_BOOL bUI,String cto,string ccc,string cbcc,s
tring cSubject,string cms); |
| 399 | 399 |
| 400 FX_BOOL Document::mailForm(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) | 400 FX_BOOL Document::mailForm(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) |
| 401 { | 401 { |
| 402 » ASSERT(m_pDocument != NULL); | 402 ASSERT(m_pDocument != NULL); |
| 403 | 403 |
| 404 » if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; | 404 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; |
| 405 | 405 |
| 406 » int iLength = params.size(); | 406 int iLength = params.size(); |
| 407 | 407 |
| 408 » FX_BOOL bUI = iLength > 0 ? params[0].ToBool() : TRUE; | 408 FX_BOOL bUI = iLength > 0 ? params[0].ToBool() : TRUE; |
| 409 » CFX_WideString cTo = iLength > 1 ? params[1].ToCFXWideString() : L""; | 409 CFX_WideString cTo = iLength > 1 ? params[1].ToCFXWideString() : L""; |
| 410 » CFX_WideString cCc = iLength > 2 ? params[2].ToCFXWideString() : L""; | 410 CFX_WideString cCc = iLength > 2 ? params[2].ToCFXWideString() : L""; |
| 411 » CFX_WideString cBcc = iLength > 3 ? params[3].ToCFXWideString() : L""; | 411 CFX_WideString cBcc = iLength > 3 ? params[3].ToCFXWideString() : L""; |
| 412 » CFX_WideString cSubject = iLength > 4 ? params[4].ToCFXWideString() : L"
"; | 412 CFX_WideString cSubject = iLength > 4 ? params[4].ToCFXWideString() : L""; |
| 413 » CFX_WideString cMsg = iLength > 5 ? params[5].ToCFXWideString() : L""; | 413 CFX_WideString cMsg = iLength > 5 ? params[5].ToCFXWideString() : L""; |
| 414 | 414 |
| 415 » CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); | 415 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterFor
m(); |
| 416 » ASSERT(pInterForm != NULL); | 416 ASSERT(pInterForm != NULL); |
| 417 | 417 |
| 418 » CFX_ByteTextBuf textBuf; | 418 CFX_ByteTextBuf textBuf; |
| 419 » if (!pInterForm->ExportFormToFDFTextBuf(textBuf)) | 419 if (!pInterForm->ExportFormToFDFTextBuf(textBuf)) |
| 420 » » return FALSE; | 420 return FALSE; |
| 421 | 421 |
| 422 » CJS_Context* pContext = (CJS_Context*)cc; | 422 CJS_Context* pContext = (CJS_Context*)cc; |
| 423 » ASSERT(pContext != NULL); | 423 ASSERT(pContext != NULL); |
| 424 » CPDFDoc_Environment* pEnv = pContext->GetReaderApp(); | 424 CPDFDoc_Environment* pEnv = pContext->GetReaderApp(); |
| 425 » ASSERT(pEnv != NULL); | 425 ASSERT(pEnv != NULL); |
| 426 » CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 426 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 427 » ASSERT(pRuntime != NULL); | 427 ASSERT(pRuntime != NULL); |
| 428 | 428 |
| 429 » pRuntime->BeginBlock(); | 429 pRuntime->BeginBlock(); |
| 430 » pEnv->JS_docmailForm(textBuf.GetBuffer(), textBuf.GetLength(), bUI, cTo.
c_str(), cSubject.c_str(), cCc.c_str(), cBcc.c_str(), cMsg.c_str()); | 430 pEnv->JS_docmailForm(textBuf.GetBuffer(), textBuf.GetLength(), bUI, cTo.c_st
r(), cSubject.c_str(), cCc.c_str(), cBcc.c_str(), cMsg.c_str()); |
| 431 » pRuntime->EndBlock(); | 431 pRuntime->EndBlock(); |
| 432 » return TRUE; | 432 return TRUE; |
| 433 } | 433 } |
| 434 | 434 |
| 435 FX_BOOL Document::print(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
ue& vRet, CFX_WideString& sError) | 435 FX_BOOL Document::print(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
ue& vRet, CFX_WideString& sError) |
| 436 { | 436 { |
| 437 » CJS_Context* pContext = (CJS_Context*)cc; | 437 CJS_Context* pContext = (CJS_Context*)cc; |
| 438 » ASSERT(pContext != NULL); | 438 ASSERT(pContext != NULL); |
| 439 » CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 439 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 440 » ASSERT(pRuntime != NULL); | 440 ASSERT(pRuntime != NULL); |
| 441 | 441 |
| 442 » FX_BOOL bUI = TRUE; | 442 FX_BOOL bUI = TRUE; |
| 443 » int nStart = 0; | 443 int nStart = 0; |
| 444 » int nEnd = 0; | 444 int nEnd = 0; |
| 445 » FX_BOOL bSilent = FALSE; | 445 FX_BOOL bSilent = FALSE; |
| 446 » FX_BOOL bShrinkToFit = FALSE; | 446 FX_BOOL bShrinkToFit = FALSE; |
| 447 » FX_BOOL bPrintAsImage = FALSE; | 447 FX_BOOL bPrintAsImage = FALSE; |
| 448 » FX_BOOL bReverse = FALSE; | 448 FX_BOOL bReverse = FALSE; |
| 449 » FX_BOOL bAnnotations = FALSE; | 449 FX_BOOL bAnnotations = FALSE; |
| 450 | 450 |
| 451 » int nlength = params.size(); | 451 int nlength = params.size(); |
| 452 » if(nlength ==9) | 452 if(nlength ==9) |
| 453 » { | 453 { |
| 454 » » if (params[8].GetType() == VT_fxobject) | 454 if (params[8].GetType() == VT_fxobject) |
| 455 » » { | 455 { |
| 456 » » » JSFXObject pObj = params[8].ToV8Object(); | 456 JSFXObject pObj = params[8].ToV8Object(); |
| 457 » » » { | 457 { |
| 458 » » » » if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pR
untime, L"PrintParamsObj")) | 458 if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pRuntime, L"PrintP
aramsObj")) |
| 459 » » » » { | 459 { |
| 460 » » » » » if (CJS_Object* pJSObj = params[8].ToCJS
Object()) | 460 if (CJS_Object* pJSObj = params[8].ToCJSObject()) |
| 461 » » » » » { | 461 { |
| 462 » » » » » » » if (PrintParamsObj* ppri
ntparamsObj = (PrintParamsObj*)pJSObj->GetEmbedObject()) | 462 if (PrintParamsObj* pprintparamsObj = (PrintParamsOb
j*)pJSObj->GetEmbedObject()) |
| 463 » » » » » » » { | 463 { |
| 464 » » » » » » » » bUI = pprintpara
msObj->bUI; | 464 bUI = pprintparamsObj->bUI; |
| 465 » » » » » » » » nStart = pprintp
aramsObj->nStart; | 465 nStart = pprintparamsObj->nStart; |
| 466 » » » » » » » » nEnd = pprintpar
amsObj->nEnd; | 466 nEnd = pprintparamsObj->nEnd; |
| 467 » » » » » » » » bSilent = pprint
paramsObj->bSilent; | 467 bSilent = pprintparamsObj->bSilent; |
| 468 » » » » » » » » bShrinkToFit = p
printparamsObj->bShrinkToFit; | 468 bShrinkToFit = pprintparamsObj->bShrinkToFit; |
| 469 » » » » » » » » bPrintAsImage =
pprintparamsObj->bPrintAsImage; | 469 bPrintAsImage = pprintparamsObj->bPrintAsImage; |
| 470 » » » » » » » » bReverse = pprin
tparamsObj->bReverse; | 470 bReverse = pprintparamsObj->bReverse; |
| 471 » » » » » » » » bAnnotations = p
printparamsObj->bAnnotations; | 471 bAnnotations = pprintparamsObj->bAnnotations; |
| 472 » » » » » » » } | 472 } |
| 473 » » » » » } | 473 } |
| 474 » » » » } | 474 } |
| 475 » » » } | 475 } |
| 476 » » } | 476 } |
| 477 » } | 477 } |
| 478 » else | 478 else |
| 479 » { | 479 { |
| 480 » » if(nlength >= 1) | 480 if(nlength >= 1) |
| 481 » » » bUI = params[0].ToBool(); | 481 bUI = params[0].ToBool(); |
| 482 » » if(nlength >= 2) | 482 if(nlength >= 2) |
| 483 » » » nStart = params[1].ToInt(); | 483 nStart = params[1].ToInt(); |
| 484 » » if(nlength >= 3) | 484 if(nlength >= 3) |
| 485 » » » nEnd = params[2].ToInt(); | 485 nEnd = params[2].ToInt(); |
| 486 » » if(nlength >= 4) | 486 if(nlength >= 4) |
| 487 » » » bSilent = params[3].ToBool(); | 487 bSilent = params[3].ToBool(); |
| 488 » » if(nlength >= 5) | 488 if(nlength >= 5) |
| 489 » » » bShrinkToFit = params[4].ToBool(); | 489 bShrinkToFit = params[4].ToBool(); |
| 490 » » if(nlength >= 6) | 490 if(nlength >= 6) |
| 491 » » » bPrintAsImage = params[5].ToBool(); | 491 bPrintAsImage = params[5].ToBool(); |
| 492 » » if(nlength >= 7) | 492 if(nlength >= 7) |
| 493 » » » bReverse = params[6].ToBool(); | 493 bReverse = params[6].ToBool(); |
| 494 » » if(nlength >= 8) | 494 if(nlength >= 8) |
| 495 » » » bAnnotations = params[7].ToBool(); | 495 bAnnotations = params[7].ToBool(); |
| 496 » } | 496 } |
| 497 | 497 |
| 498 » ASSERT(m_pDocument != NULL); | 498 ASSERT(m_pDocument != NULL); |
| 499 | 499 |
| 500 » if (CPDFDoc_Environment* pEnv = m_pDocument->GetEnv()) | 500 if (CPDFDoc_Environment* pEnv = m_pDocument->GetEnv()) |
| 501 » { | 501 { |
| 502 » » pEnv->JS_docprint(bUI, nStart, nEnd, bSilent, bShrinkToFit, bPri
ntAsImage, bReverse, bAnnotations); | 502 pEnv->JS_docprint(bUI, nStart, nEnd, bSilent, bShrinkToFit, bPrintAsImag
e, bReverse, bAnnotations); |
| 503 » » return TRUE; | 503 return TRUE; |
| 504 » } | 504 } |
| 505 » return FALSE; | 505 return FALSE; |
| 506 } | 506 } |
| 507 | 507 |
| 508 //removes the specified field from the document. | 508 //removes the specified field from the document. |
| 509 //comment: | 509 //comment: |
| 510 //note: if the filed name is not retional, adobe is dumb for it. | 510 //note: if the filed name is not retional, adobe is dumb for it. |
| 511 | 511 |
| 512 FX_BOOL Document::removeField(IFXJS_Context* cc, const CJS_Parameters& params, C
JS_Value& vRet, CFX_WideString& sError) | 512 FX_BOOL Document::removeField(IFXJS_Context* cc, const CJS_Parameters& params, C
JS_Value& vRet, CFX_WideString& sError) |
| 513 { | 513 { |
| 514 » ASSERT(m_pDocument != NULL); | 514 ASSERT(m_pDocument != NULL); |
| 515 | 515 |
| 516 » if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || | 516 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || |
| 517 » » m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM))) return FALSE; | 517 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM))) return FALSE; |
| 518 | 518 |
| 519 » CJS_Context* pContext = (CJS_Context*)cc; | 519 CJS_Context* pContext = (CJS_Context*)cc; |
| 520 » if (params.size() != 1) { | 520 if (params.size() != 1) { |
| 521 » » sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 521 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 522 » » return FALSE; | 522 return FALSE; |
| 523 » } | 523 } |
| 524 | 524 |
| 525 » CFX_WideString sFieldName = params[0].ToCFXWideString(); | 525 CFX_WideString sFieldName = params[0].ToCFXWideString(); |
| 526 » CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); | 526 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterFor
m(); |
| 527 » ASSERT(pInterForm != NULL); | 527 ASSERT(pInterForm != NULL); |
| 528 | 528 |
| 529 » CFX_PtrArray widgets; | 529 CFX_PtrArray widgets; |
| 530 » pInterForm->GetWidgets(sFieldName, widgets); | 530 pInterForm->GetWidgets(sFieldName, widgets); |
| 531 | 531 |
| 532 » int nSize = widgets.GetSize(); | 532 int nSize = widgets.GetSize(); |
| 533 | 533 |
| 534 » if (nSize > 0) | 534 if (nSize > 0) |
| 535 » { | 535 { |
| 536 » » for (int i=0; i<nSize; i++) | 536 for (int i=0; i<nSize; i++) |
| 537 » » { | 537 { |
| 538 » » » CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widgets[i]; | 538 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widgets[i]; |
| 539 » » » ASSERT(pWidget != NULL); | 539 ASSERT(pWidget != NULL); |
| 540 | 540 |
| 541 » » » CPDF_Rect rcAnnot = pWidget->GetRect(); | 541 CPDF_Rect rcAnnot = pWidget->GetRect(); |
| 542 » » » rcAnnot.left -= 1; | 542 rcAnnot.left -= 1; |
| 543 » » » rcAnnot.bottom -= 1; | 543 rcAnnot.bottom -= 1; |
| 544 » » » rcAnnot.right += 1; | 544 rcAnnot.right += 1; |
| 545 » » » rcAnnot.top += 1; | 545 rcAnnot.top += 1; |
| 546 | 546 |
| 547 » » » CFX_RectArray aRefresh; | 547 CFX_RectArray aRefresh; |
| 548 » » » aRefresh.Add(rcAnnot); | 548 aRefresh.Add(rcAnnot); |
| 549 | 549 |
| 550 CPDFXFA_Page* pPage = pWidget->GetPDFXFAPage(); | 550 CPDFXFA_Page* pPage = pWidget->GetPDFXFAPage(); |
| 551 ASSERT(pPage != NULL); | 551 ASSERT(pPage != NULL); |
| 552 | 552 |
| 553 » » » CPDFSDK_PageView* pPageView = m_pDocument->GetPageView(p
Page); | 553 CPDFSDK_PageView* pPageView = m_pDocument->GetPageView(pPage); |
| 554 » » » pPageView->DeleteAnnot(pWidget); | 554 pPageView->DeleteAnnot(pWidget); |
| 555 | 555 |
| 556 » » » pPageView->UpdateRects(aRefresh); | 556 pPageView->UpdateRects(aRefresh); |
| 557 » » } | 557 } |
| 558 » » m_pDocument->SetChangeMark(); | 558 m_pDocument->SetChangeMark(); |
| 559 » } | 559 } |
| 560 | 560 |
| 561 » return TRUE; | 561 return TRUE; |
| 562 } | 562 } |
| 563 | 563 |
| 564 //reset filed values within a document. | 564 //reset filed values within a document. |
| 565 //comment: | 565 //comment: |
| 566 //note: if the fields names r not rational, aodbe is dumb for it. | 566 //note: if the fields names r not rational, aodbe is dumb for it. |
| 567 | 567 |
| 568 FX_BOOL Document::resetForm(IFXJS_Context* cc, const CJS_Parameters& params, CJS
_Value& vRet, CFX_WideString& sError) | 568 FX_BOOL Document::resetForm(IFXJS_Context* cc, const CJS_Parameters& params, CJS
_Value& vRet, CFX_WideString& sError) |
| 569 { | 569 { |
| 570 » ASSERT(m_pDocument != NULL); | 570 ASSERT(m_pDocument != NULL); |
| 571 | 571 |
| 572 » if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || | 572 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || |
| 573 » » m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) || | 573 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) || |
| 574 » » m_pDocument->GetPermissions(FPDFPERM_FILL_FORM))) return FALSE; | 574 m_pDocument->GetPermissions(FPDFPERM_FILL_FORM))) return FALSE; |
| 575 | 575 |
| 576 » CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); | 576 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterFor
m(); |
| 577 » ASSERT(pInterForm != NULL); | 577 ASSERT(pInterForm != NULL); |
| 578 | 578 |
| 579 » CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); | 579 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); |
| 580 » ASSERT(pPDFForm != NULL); | 580 ASSERT(pPDFForm != NULL); |
| 581 | 581 |
| 582 » v8::Isolate* isolate = GetIsolate(cc); | 582 v8::Isolate* isolate = GetIsolate(cc); |
| 583 » CJS_Array aName(isolate); | 583 CJS_Array aName(isolate); |
| 584 | 584 |
| 585 » if (params.size() > 0) | 585 if (params.size() > 0) |
| 586 » { | 586 { |
| 587 » » switch (params[0].GetType()) | 587 switch (params[0].GetType()) |
| 588 » » { | 588 { |
| 589 » » default: | 589 default: |
| 590 » » » aName.Attach(params[0].ToV8Array()); | 590 aName.Attach(params[0].ToV8Array()); |
| 591 » » » break; | 591 break; |
| 592 » » case VT_string: | 592 case VT_string: |
| 593 » » » aName.SetElement(0,params[0]); | 593 aName.SetElement(0,params[0]); |
| 594 » » » break; | 594 break; |
| 595 » » } | 595 } |
| 596 | 596 |
| 597 » » CFX_PtrArray aFields; | 597 CFX_PtrArray aFields; |
| 598 | 598 |
| 599 » » for (int i=0,isz=aName.GetLength(); i<isz; i++) | 599 for (int i=0,isz=aName.GetLength(); i<isz; i++) |
| 600 » » { | 600 { |
| 601 » » » CJS_Value valElement(isolate); | 601 CJS_Value valElement(isolate); |
| 602 » » » aName.GetElement(i,valElement); | 602 aName.GetElement(i,valElement); |
| 603 » » » CFX_WideString swVal = valElement.ToCFXWideString(); | 603 CFX_WideString swVal = valElement.ToCFXWideString(); |
| 604 | 604 |
| 605 » » » for (int j=0,jsz=pPDFForm->CountFields(swVal); j<jsz; j+
+) | 605 for (int j=0,jsz=pPDFForm->CountFields(swVal); j<jsz; j++) |
| 606 » » » { | 606 { |
| 607 » » » » aFields.Add((void*)pPDFForm->GetField(j,swVal)); | 607 aFields.Add((void*)pPDFForm->GetField(j,swVal)); |
| 608 » » » } | 608 } |
| 609 » » } | 609 } |
| 610 | 610 |
| 611 » » if (aFields.GetSize() > 0) | 611 if (aFields.GetSize() > 0) |
| 612 » » { | 612 { |
| 613 » » » pPDFForm->ResetForm(aFields, TRUE, TRUE); | 613 pPDFForm->ResetForm(aFields, TRUE, TRUE); |
| 614 » » » m_pDocument->SetChangeMark(); | 614 m_pDocument->SetChangeMark(); |
| 615 | 615 |
| 616 » » } | 616 } |
| 617 » } | 617 } |
| 618 » else | 618 else |
| 619 » { | 619 { |
| 620 » » pPDFForm->ResetForm(TRUE); | 620 pPDFForm->ResetForm(TRUE); |
| 621 » » m_pDocument->SetChangeMark(); | 621 m_pDocument->SetChangeMark(); |
| 622 | 622 |
| 623 » } | 623 } |
| 624 | 624 |
| 625 » return TRUE; | 625 return TRUE; |
| 626 } | 626 } |
| 627 | 627 |
| 628 | 628 |
| 629 FX_BOOL Document::saveAs(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va
lue& vRet, CFX_WideString& sError) | 629 FX_BOOL Document::saveAs(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va
lue& vRet, CFX_WideString& sError) |
| 630 { | 630 { |
| 631 // Unsafe, not supported. | 631 // Unsafe, not supported. |
| 632 return TRUE; | 632 return TRUE; |
| 633 } | 633 } |
| 634 | 634 |
| 635 | 635 |
| 636 FX_BOOL Document::submitForm(IFXJS_Context* cc, const CJS_Parameters& params, CJ
S_Value& vRet, CFX_WideString& sError) | 636 FX_BOOL Document::submitForm(IFXJS_Context* cc, const CJS_Parameters& params, CJ
S_Value& vRet, CFX_WideString& sError) |
| 637 { | 637 { |
| 638 » ASSERT(m_pDocument != NULL); | 638 ASSERT(m_pDocument != NULL); |
| 639 » CJS_Context* pContext = (CJS_Context*)cc; | 639 CJS_Context* pContext = (CJS_Context*)cc; |
| 640 » int nSize = params.size(); | 640 int nSize = params.size(); |
| 641 » if (nSize < 1) { | 641 if (nSize < 1) { |
| 642 » » sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 642 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 643 » » return FALSE; | 643 return FALSE; |
| 644 » } | 644 } |
| 645 | 645 |
| 646 » CFX_WideString strURL; | 646 CFX_WideString strURL; |
| 647 » FX_BOOL bFDF = TRUE; | 647 FX_BOOL bFDF = TRUE; |
| 648 » FX_BOOL bEmpty = FALSE; | 648 FX_BOOL bEmpty = FALSE; |
| 649 » v8::Isolate* isolate = GetIsolate(cc); | 649 v8::Isolate* isolate = GetIsolate(cc); |
| 650 » CJS_Array aFields(isolate); | 650 CJS_Array aFields(isolate); |
| 651 | 651 |
| 652 » CJS_Value v = params[0]; | 652 CJS_Value v = params[0]; |
| 653 » if (v.GetType() == VT_string) | 653 if (v.GetType() == VT_string) |
| 654 » { | 654 { |
| 655 » » strURL = params[0].ToCFXWideString(); | 655 strURL = params[0].ToCFXWideString(); |
| 656 » » if (nSize > 1) | 656 if (nSize > 1) |
| 657 » » » bFDF = params[1].ToBool(); | 657 bFDF = params[1].ToBool(); |
| 658 » » if (nSize > 2) | 658 if (nSize > 2) |
| 659 » » » bEmpty = params[2].ToBool(); | 659 bEmpty = params[2].ToBool(); |
| 660 » » if (nSize > 3) | 660 if (nSize > 3) |
| 661 » » » aFields.Attach(params[3].ToV8Array()); | 661 aFields.Attach(params[3].ToV8Array()); |
| 662 » } | 662 } |
| 663 » else if (v.GetType() == VT_object) | 663 else if (v.GetType() == VT_object) |
| 664 » { | 664 { |
| 665 » » JSObject pObj = params[0].ToV8Object(); | 665 JSObject pObj = params[0].ToV8Object(); |
| 666 » » v8::Local<v8::Value> pValue = JS_GetObjectElement(isolate, pObj,
L"cURL"); | 666 v8::Local<v8::Value> pValue = JS_GetObjectElement(isolate, pObj, L"cURL"
); |
| 667 » » if (!pValue.IsEmpty()) | 667 if (!pValue.IsEmpty()) |
| 668 » » » strURL = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValu
e)).ToCFXWideString(); | 668 strURL = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWid
eString(); |
| 669 » » pValue = JS_GetObjectElement(isolate, pObj, L"bFDF"); | 669 pValue = JS_GetObjectElement(isolate, pObj, L"bFDF"); |
| 670 » » bFDF = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBool
(); | 670 bFDF = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBool(); |
| 671 » » pValue = JS_GetObjectElement(isolate, pObj, L"bEmpty"); | 671 pValue = JS_GetObjectElement(isolate, pObj, L"bEmpty"); |
| 672 » » bEmpty = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBo
ol(); | 672 bEmpty = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBool(); |
| 673 » » pValue = JS_GetObjectElement(isolate, pObj,L"aFields"); | 673 pValue = JS_GetObjectElement(isolate, pObj,L"aFields"); |
| 674 » » aFields.Attach(CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)
).ToV8Array()); | 674 aFields.Attach(CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToV8Ar
ray()); |
| 675 » } | 675 } |
| 676 | 676 |
| 677 » CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); | 677 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 678 » ASSERT(pInterForm != NULL); | 678 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterFor
m(); |
| 679 » CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); | 679 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); |
| 680 » ASSERT(pPDFInterForm != NULL); | 680 FX_BOOL bAll = (aFields.GetLength() == 0); |
| 681 if (bAll && bEmpty) |
| 682 { |
| 683 if (pPDFInterForm->CheckRequiredFields()) |
| 684 { |
| 685 pRuntime->BeginBlock(); |
| 686 pInterForm->SubmitForm(strURL, FALSE); |
| 687 pRuntime->EndBlock(); |
| 688 } |
| 689 return TRUE; |
| 690 } |
| 681 | 691 |
| 682 » FX_BOOL bAll = (aFields.GetLength() == 0); | 692 CFX_PtrArray fieldObjects; |
| 693 for (int i=0,sz=aFields.GetLength(); i<sz; i++) |
| 694 { |
| 695 CJS_Value valName(isolate); |
| 696 aFields.GetElement(i, valName); |
| 683 | 697 |
| 684 » if (bAll && bEmpty) | 698 CFX_WideString sName = valName.ToCFXWideString(); |
| 685 » { | 699 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); |
| 686 » » CJS_Context* pContext = (CJS_Context*)cc; | 700 for (int j = 0, jsz = pPDFForm->CountFields(sName); j < jsz; ++j) |
| 687 » » ASSERT(pContext != NULL); | 701 { |
| 688 » » CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 702 CPDF_FormField* pField = pPDFForm->GetField(j, sName); |
| 689 » » ASSERT(pRuntime != NULL); | 703 if (!bEmpty && pField->GetValue().IsEmpty()) |
| 704 continue; |
| 690 | 705 |
| 706 fieldObjects.Add(pField); |
| 707 } |
| 708 } |
| 691 | 709 |
| 692 » » if (pPDFInterForm->CheckRequiredFields()) | 710 if (pPDFInterForm->CheckRequiredFields(&fieldObjects, TRUE)) |
| 693 » » { | 711 { |
| 694 » » » pRuntime->BeginBlock(); | 712 pRuntime->BeginBlock(); |
| 695 » » » pInterForm->SubmitForm(strURL, FALSE); | 713 pInterForm->SubmitFields(strURL, fieldObjects, TRUE, !bFDF); |
| 696 » » » pRuntime->EndBlock(); | 714 pRuntime->EndBlock(); |
| 697 » » } | 715 } |
| 698 | 716 return TRUE; |
| 699 » » return TRUE; | |
| 700 » } | |
| 701 » else | |
| 702 » { | |
| 703 » » CFX_PtrArray fieldObjects; | |
| 704 | |
| 705 » » for (int i=0,sz=aFields.GetLength(); i<sz; i++) | |
| 706 » » { | |
| 707 » » » CJS_Value valName(isolate); | |
| 708 » » » aFields.GetElement(i, valName); | |
| 709 » » » CFX_WideString sName = valName.ToCFXWideString(); | |
| 710 | |
| 711 » » » CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); | |
| 712 » » » ASSERT(pPDFForm != NULL); | |
| 713 | |
| 714 » » » for (int j=0, jsz=pPDFForm->CountFields(sName); j<jsz; j
++) | |
| 715 » » » { | |
| 716 » » » » CPDF_FormField* pField = pPDFForm->GetField(j, s
Name); | |
| 717 » » » » if (!bEmpty && pField->GetValue().IsEmpty()) | |
| 718 » » » » » continue; | |
| 719 | |
| 720 » » » » fieldObjects.Add(pField); | |
| 721 » » » } | |
| 722 » » } | |
| 723 | |
| 724 » » CJS_Context* pContext = (CJS_Context*)cc; | |
| 725 » » ASSERT(pContext != NULL); | |
| 726 » » CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | |
| 727 » » ASSERT(pRuntime != NULL); | |
| 728 | |
| 729 | |
| 730 » » if (pPDFInterForm->CheckRequiredFields(&fieldObjects, TRUE)) | |
| 731 » » { | |
| 732 » » » pRuntime->BeginBlock(); | |
| 733 » » » pInterForm->SubmitFields(strURL, fieldObjects, TRUE, !bF
DF); | |
| 734 » » » pRuntime->EndBlock(); | |
| 735 » » } | |
| 736 | |
| 737 » » return TRUE; | |
| 738 » } | |
| 739 | |
| 740 } | 717 } |
| 741 | 718 |
| 742 ////////////////////////////////////////////////////////////////////////////////
////////////// | 719 ////////////////////////////////////////////////////////////////////////////////
////////////// |
| 743 | 720 |
| 744 void Document::AttachDoc(CPDFSDK_Document *pDoc) | 721 void Document::AttachDoc(CPDFSDK_Document *pDoc) |
| 745 { | 722 { |
| 746 » m_pDocument = pDoc; | 723 m_pDocument = pDoc; |
| 747 } | 724 } |
| 748 | 725 |
| 749 CPDFSDK_Document * Document::GetReaderDoc() | 726 CPDFSDK_Document * Document::GetReaderDoc() |
| 750 { | 727 { |
| 751 » return m_pDocument; | 728 return m_pDocument; |
| 752 } | 729 } |
| 753 | 730 |
| 754 FX_BOOL Document::ExtractFileName(CPDFSDK_Document *pDoc,CFX_ByteString &strFile
Name) | 731 FX_BOOL Document::ExtractFileName(CPDFSDK_Document *pDoc,CFX_ByteString &strFile
Name) |
| 755 { | 732 { |
| 756 » return FALSE; | 733 return FALSE; |
| 757 } | 734 } |
| 758 | 735 |
| 759 FX_BOOL Document::ExtractFolderName(CPDFSDK_Document *pDoc,CFX_ByteString &strFo
lderName) | 736 FX_BOOL Document::ExtractFolderName(CPDFSDK_Document *pDoc,CFX_ByteString &strFo
lderName) |
| 760 { | 737 { |
| 761 » return FALSE; | 738 return FALSE; |
| 762 } | 739 } |
| 763 | 740 |
| 764 FX_BOOL Document::bookmarkRoot(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideStr
ing& sError) | 741 FX_BOOL Document::bookmarkRoot(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideStr
ing& sError) |
| 765 { | 742 { |
| 766 » return TRUE; | 743 return TRUE; |
| 767 } | 744 } |
| 768 | 745 |
| 769 FX_BOOL Document::mailDoc(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) | 746 FX_BOOL Document::mailDoc(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) |
| 770 { | 747 { |
| 771 » ASSERT(m_pDocument != NULL); | 748 ASSERT(m_pDocument != NULL); |
| 772 | 749 |
| 773 » FX_BOOL bUI = TRUE; | 750 FX_BOOL bUI = TRUE; |
| 774 » CFX_WideString cTo = L""; | 751 CFX_WideString cTo = L""; |
| 775 » CFX_WideString cCc = L""; | 752 CFX_WideString cCc = L""; |
| 776 » CFX_WideString cBcc = L""; | 753 CFX_WideString cBcc = L""; |
| 777 » CFX_WideString cSubject = L""; | 754 CFX_WideString cSubject = L""; |
| 778 » CFX_WideString cMsg = L""; | 755 CFX_WideString cMsg = L""; |
| 779 | 756 |
| 780 » if (params.size() >= 1) | 757 if (params.size() >= 1) |
| 781 » » bUI = params[0].ToBool(); | 758 bUI = params[0].ToBool(); |
| 782 » if (params.size() >= 2) | 759 if (params.size() >= 2) |
| 783 » » cTo = params[1].ToCFXWideString(); | 760 cTo = params[1].ToCFXWideString(); |
| 784 » if (params.size() >= 3) | 761 if (params.size() >= 3) |
| 785 » » cCc = params[2].ToCFXWideString(); | 762 cCc = params[2].ToCFXWideString(); |
| 786 » if (params.size() >= 4) | 763 if (params.size() >= 4) |
| 787 » » cBcc = params[3].ToCFXWideString(); | 764 cBcc = params[3].ToCFXWideString(); |
| 788 » if (params.size() >= 5) | 765 if (params.size() >= 5) |
| 789 » » cSubject = params[4].ToCFXWideString(); | 766 cSubject = params[4].ToCFXWideString(); |
| 790 » if (params.size() >= 6) | 767 if (params.size() >= 6) |
| 791 » » cMsg = params[5].ToCFXWideString(); | 768 cMsg = params[5].ToCFXWideString(); |
| 792 | 769 |
| 793 » v8::Isolate* isolate = GetIsolate(cc); | 770 v8::Isolate* isolate = GetIsolate(cc); |
| 794 | 771 |
| 795 » if(params.size() >= 1 && params[0].GetType() == VT_object) | 772 if(params.size() >= 1 && params[0].GetType() == VT_object) |
| 796 » { | 773 { |
| 797 » » JSObject pObj = params[0].ToV8Object(); | 774 JSObject pObj = params[0].ToV8Object(); |
| 798 | 775 |
| 799 » » v8::Local<v8::Value> pValue = JS_GetObjectElement(isolate,pObj,
L"bUI"); | 776 v8::Local<v8::Value> pValue = JS_GetObjectElement(isolate,pObj, L"bUI"); |
| 800 » » bUI = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToInt(); | 777 bUI = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToInt(); |
| 801 | 778 |
| 802 » » pValue = JS_GetObjectElement(isolate,pObj, L"cTo"); | 779 pValue = JS_GetObjectElement(isolate,pObj, L"cTo"); |
| 803 » » cTo = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFXWide
String(); | 780 cTo = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFXWideString()
; |
| 804 | 781 |
| 805 » » pValue = JS_GetObjectElement(isolate,pObj, L"cCc"); | 782 pValue = JS_GetObjectElement(isolate,pObj, L"cCc"); |
| 806 » » cCc = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFXWide
String(); | 783 cCc = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFXWideString()
; |
| 807 | 784 |
| 808 » » pValue = JS_GetObjectElement(isolate,pObj, L"cBcc"); | 785 pValue = JS_GetObjectElement(isolate,pObj, L"cBcc"); |
| 809 » » cBcc = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFXWid
eString(); | 786 cBcc = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFXWideString(
); |
| 810 | 787 |
| 811 » » pValue = JS_GetObjectElement(isolate,pObj, L"cSubject"); | 788 pValue = JS_GetObjectElement(isolate,pObj, L"cSubject"); |
| 812 » » cSubject = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCF
XWideString(); | 789 cSubject = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFXWideStr
ing(); |
| 813 | 790 |
| 814 » » pValue = JS_GetObjectElement(isolate,pObj, L"cMsg"); | 791 pValue = JS_GetObjectElement(isolate,pObj, L"cMsg"); |
| 815 » » cMsg = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFXWid
eString(); | 792 cMsg = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFXWideString(
); |
| 816 | 793 |
| 817 » } | 794 } |
| 818 | 795 |
| 819 » CJS_Context* pContext = (CJS_Context*)cc; | 796 CJS_Context* pContext = (CJS_Context*)cc; |
| 820 » ASSERT(pContext != NULL); | 797 ASSERT(pContext != NULL); |
| 821 » CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 798 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 822 » ASSERT(pRuntime != NULL); | 799 ASSERT(pRuntime != NULL); |
| 823 | 800 |
| 824 » pRuntime->BeginBlock(); | 801 pRuntime->BeginBlock(); |
| 825 » CPDFDoc_Environment* pEnv = pRuntime->GetReaderApp(); | 802 CPDFDoc_Environment* pEnv = pRuntime->GetReaderApp(); |
| 826 » pEnv->JS_docmailForm(NULL, 0, bUI, cTo.c_str(), cSubject.c_str(), cCc.c_
str(), cBcc.c_str(), cMsg.c_str()); | 803 pEnv->JS_docmailForm(NULL, 0, bUI, cTo.c_str(), cSubject.c_str(), cCc.c_str(
), cBcc.c_str(), cMsg.c_str()); |
| 827 » pRuntime->EndBlock(); | 804 pRuntime->EndBlock(); |
| 828 | 805 |
| 829 » return TRUE; | 806 return TRUE; |
| 830 } | 807 } |
| 831 | 808 |
| 832 FX_BOOL Document::author(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) | 809 FX_BOOL Document::author(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) |
| 833 { | 810 { |
| 834 » ASSERT(m_pDocument != NULL); | 811 ASSERT(m_pDocument != NULL); |
| 835 | 812 |
| 836 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetPDFDoc()->
GetInfo(); | 813 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetPDFDoc()->
GetInfo(); |
| 837 if (!pDictionary)return FALSE; | 814 if (!pDictionary)return FALSE; |
| 838 | 815 |
| 839 » if (vp.IsGetting()) | 816 if (vp.IsGetting()) |
| 840 » { | 817 { |
| 841 » » vp << pDictionary->GetUnicodeText("Author"); | 818 vp << pDictionary->GetUnicodeText("Author"); |
| 842 » » return TRUE; | 819 return TRUE; |
| 843 » } | 820 } |
| 844 » else | 821 else |
| 845 » { | 822 { |
| 846 » » if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE; | 823 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE; |
| 847 | 824 |
| 848 » » CFX_WideString csAuthor; | 825 CFX_WideString csAuthor; |
| 849 » » vp >> csAuthor; | 826 vp >> csAuthor; |
| 850 » » pDictionary->SetAtString("Author", PDF_EncodeText(csAuthor)); | 827 pDictionary->SetAtString("Author", PDF_EncodeText(csAuthor)); |
| 851 » » m_pDocument->SetChangeMark(); | 828 m_pDocument->SetChangeMark(); |
| 852 » » return TRUE; | 829 return TRUE; |
| 853 » } | 830 } |
| 854 } | 831 } |
| 855 | 832 |
| 856 FX_BOOL Document::info(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr
ror) | 833 FX_BOOL Document::info(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr
ror) |
| 857 { | 834 { |
| 858 ASSERT(m_pDocument != NULL); | 835 ASSERT(m_pDocument != NULL); |
| 859 | 836 |
| 860 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetPDFDoc()->
GetInfo(); | 837 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetPDFDoc()->
GetInfo(); |
| 861 if (!pDictionary)return FALSE; | 838 if (!pDictionary)return FALSE; |
| 862 | 839 |
| 863 CFX_WideString cwAuthor = pDictionary->GetUnicodeText("A
uthor"); | 840 CFX_WideString cwAuthor = pDictionary->GetUnicodeText("A
uthor"); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 return TRUE; | 884 return TRUE; |
| 908 } | 885 } |
| 909 else | 886 else |
| 910 { | 887 { |
| 911 return TRUE; | 888 return TRUE; |
| 912 } | 889 } |
| 913 } | 890 } |
| 914 | 891 |
| 915 FX_BOOL Document::creationDate(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideStr
ing& sError) | 892 FX_BOOL Document::creationDate(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideStr
ing& sError) |
| 916 { | 893 { |
| 917 ASSERT(m_pDocument != NULL); | |
| 918 | |
| 919 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetPDFDoc()->
GetInfo(); | 894 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetPDFDoc()->
GetInfo(); |
| 920 » if (!pDictionary)return FALSE; | 895 » if (!pDictionary) |
| 896 return FALSE; |
| 921 | 897 |
| 922 if (vp.IsGetting()) | 898 if (vp.IsGetting()) |
| 923 { | 899 { |
| 924 vp << pDictionary->GetUnicodeText("CreationDate"); | 900 vp << pDictionary->GetUnicodeText("CreationDate"); |
| 925 return TRUE; | |
| 926 } | 901 } |
| 927 else | 902 else |
| 928 { | 903 { |
| 929 » » if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE; | 904 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) |
| 905 return FALSE; |
| 930 | 906 |
| 931 » » CFX_WideString csCreationDate; | 907 CFX_WideString csCreationDate; |
| 932 » » vp >> csCreationDate; | 908 vp >> csCreationDate; |
| 933 » » pDictionary->SetAtString("CreationDate", PDF_EncodeText(csCreati
onDate)); | 909 pDictionary->SetAtString("CreationDate", PDF_EncodeText(csCreationDate))
; |
| 934 » » m_pDocument->SetChangeMark(); | 910 m_pDocument->SetChangeMark(); |
| 935 | 911 } |
| 936 » » return TRUE; | 912 return TRUE; |
| 937 » } | |
| 938 } | 913 } |
| 939 | 914 |
| 940 FX_BOOL Document::creator(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) | 915 FX_BOOL Document::creator(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) |
| 941 { | 916 { |
| 942 » ASSERT(m_pDocument != NULL); | 917 » CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetPDFDoc()->
GetInfo(); |
| 918 » if (!pDictionary) |
| 919 return FALSE; |
| 943 | 920 |
| 944 » CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetPDFDoc()->
GetInfo(); | 921 if (vp.IsGetting()) |
| 945 » if (!pDictionary)return FALSE; | 922 { |
| 923 vp << pDictionary->GetUnicodeText("Creator"); |
| 924 } |
| 925 else |
| 926 { |
| 927 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) |
| 928 return FALSE; |
| 946 | 929 |
| 947 » if (vp.IsGetting()) | 930 CFX_WideString csCreator; |
| 948 » { | 931 vp >> csCreator; |
| 949 » » vp << pDictionary->GetUnicodeText("Creator"); | 932 pDictionary->SetAtString("Creator", PDF_EncodeText(csCreator)); |
| 950 » » return TRUE; | 933 m_pDocument->SetChangeMark(); |
| 951 » } | 934 } |
| 952 » else | 935 return TRUE; |
| 953 » { | |
| 954 » » if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE; | |
| 955 | |
| 956 » » CFX_WideString csCreator; | |
| 957 » » vp >> csCreator; | |
| 958 » » pDictionary->SetAtString("Creator", PDF_EncodeText(csCreator)); | |
| 959 » » m_pDocument->SetChangeMark(); | |
| 960 » » return TRUE; | |
| 961 » } | |
| 962 } | 936 } |
| 963 | 937 |
| 964 FX_BOOL Document::delay(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) | 938 FX_BOOL Document::delay(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) |
| 965 { | 939 { |
| 966 if (vp.IsGetting()) | 940 if (vp.IsGetting()) |
| 967 { | 941 { |
| 968 vp << m_bDelay; | 942 vp << m_bDelay; |
| 969 return TRUE; | |
| 970 } | 943 } |
| 971 else | 944 else |
| 972 { | 945 { |
| 973 ASSERT(m_pDocument != NULL); | 946 ASSERT(m_pDocument != NULL); |
| 974 | 947 |
| 975 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE; | 948 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE; |
| 976 | 949 |
| 977 bool b; | 950 bool b; |
| 978 vp >> b; | 951 vp >> b; |
| 979 | 952 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 992 { | 965 { |
| 993 if (CJS_DelayData* pData = m_DelayData.GetAt(i)) | 966 if (CJS_DelayData* pData = m_DelayData.GetAt(i)) |
| 994 { | 967 { |
| 995 Field::DoDelay(m_pDocument, pData); | 968 Field::DoDelay(m_pDocument, pData); |
| 996 delete m_DelayData.GetAt(i); | 969 delete m_DelayData.GetAt(i); |
| 997 } | 970 } |
| 998 } | 971 } |
| 999 m_DelayData.RemoveAll(); | 972 m_DelayData.RemoveAll(); |
| 1000 } | 973 } |
| 1001 | 974 |
| 1002 return TRUE; | |
| 1003 } | 975 } |
| 976 return TRUE; |
| 1004 } | 977 } |
| 1005 | 978 |
| 1006 FX_BOOL Document::keywords(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) | 979 FX_BOOL Document::keywords(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) |
| 1007 { | 980 { |
| 1008 ASSERT(m_pDocument != NULL); | |
| 1009 | |
| 1010 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetPDFDoc()->
GetInfo(); | 981 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetPDFDoc()->
GetInfo(); |
| 1011 » if (!pDictionary)return FALSE; | 982 if (!pDictionary) |
| 1012 | 983 return FALSE; |
| 1013 » if (vp.IsGetting()) | 984 |
| 1014 » { | 985 if (vp.IsGetting()) |
| 1015 » » vp << pDictionary->GetUnicodeText("Keywords"); | 986 { |
| 1016 » » return TRUE; | 987 vp << pDictionary->GetUnicodeText("Keywords"); |
| 1017 » } | 988 } |
| 1018 » else | 989 else |
| 1019 » { | 990 { |
| 1020 » » if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE; | 991 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) |
| 1021 | 992 return FALSE; |
| 1022 » » CFX_WideString csKeywords; | 993 |
| 1023 » » vp >> csKeywords; | 994 CFX_WideString csKeywords; |
| 1024 » » pDictionary->SetAtString("Keywords", PDF_EncodeText(csKeywords))
; | 995 vp >> csKeywords; |
| 1025 » » m_pDocument->SetChangeMark(); | 996 pDictionary->SetAtString("Keywords", PDF_EncodeText(csKeywords)); |
| 1026 » » return TRUE; | 997 m_pDocument->SetChangeMark(); |
| 1027 » } | 998 } |
| 999 return TRUE; |
| 1028 } | 1000 } |
| 1029 | 1001 |
| 1030 FX_BOOL Document::modDate(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) | 1002 FX_BOOL Document::modDate(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) |
| 1031 { | 1003 { |
| 1032 ASSERT(m_pDocument != NULL); | |
| 1033 | |
| 1034 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetPDFDoc()->
GetInfo(); | 1004 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetPDFDoc()->
GetInfo(); |
| 1035 » if (!pDictionary)return FALSE; | 1005 if (!pDictionary) |
| 1036 | 1006 return FALSE; |
| 1037 » if (vp.IsGetting()) | 1007 |
| 1038 » { | 1008 if (vp.IsGetting()) |
| 1039 » » vp << pDictionary->GetUnicodeText("ModDate"); | 1009 { |
| 1040 » » return TRUE; | 1010 vp << pDictionary->GetUnicodeText("ModDate"); |
| 1041 » } | 1011 } |
| 1042 » else | 1012 else |
| 1043 » { | 1013 { |
| 1044 » » if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE; | 1014 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) |
| 1045 | 1015 return FALSE; |
| 1046 » » CFX_WideString csmodDate; | 1016 |
| 1047 » » vp >> csmodDate; | 1017 CFX_WideString csmodDate; |
| 1048 » » pDictionary->SetAtString("ModDate", PDF_EncodeText(csmodDate)); | 1018 vp >> csmodDate; |
| 1049 » » m_pDocument->SetChangeMark(); | 1019 pDictionary->SetAtString("ModDate", PDF_EncodeText(csmodDate)); |
| 1050 » » return TRUE; | 1020 m_pDocument->SetChangeMark(); |
| 1051 » } | 1021 } |
| 1022 return TRUE; |
| 1052 } | 1023 } |
| 1053 | 1024 |
| 1054 FX_BOOL Document::producer(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) | 1025 FX_BOOL Document::producer(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) |
| 1055 { | 1026 { |
| 1056 ASSERT(m_pDocument != NULL); | |
| 1057 | |
| 1058 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetPDFDoc()->
GetInfo(); | 1027 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetPDFDoc()->
GetInfo(); |
| 1059 » if (!pDictionary)return FALSE; | 1028 if (!pDictionary) |
| 1060 | 1029 return FALSE; |
| 1061 » if (vp.IsGetting()) | 1030 |
| 1062 » { | 1031 if (vp.IsGetting()) |
| 1063 » » vp << pDictionary->GetUnicodeText("Producer"); | 1032 { |
| 1064 » » return TRUE; | 1033 vp << pDictionary->GetUnicodeText("Producer"); |
| 1065 » } | 1034 } |
| 1066 » else | 1035 else |
| 1067 » { | 1036 { |
| 1068 » » if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE; | 1037 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) |
| 1069 | 1038 return FALSE; |
| 1070 » » CFX_WideString csproducer; | 1039 |
| 1071 » » vp >> csproducer; | 1040 CFX_WideString csproducer; |
| 1072 » » pDictionary->SetAtString("Producer", PDF_EncodeText(csproducer))
; | 1041 vp >> csproducer; |
| 1073 » » m_pDocument->SetChangeMark(); | 1042 pDictionary->SetAtString("Producer", PDF_EncodeText(csproducer)); |
| 1074 » » return TRUE; | 1043 m_pDocument->SetChangeMark(); |
| 1075 » } | 1044 } |
| 1045 return TRUE; |
| 1076 } | 1046 } |
| 1077 | 1047 |
| 1078 FX_BOOL Document::subject(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) | 1048 FX_BOOL Document::subject(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) |
| 1079 { | 1049 { |
| 1080 ASSERT(m_pDocument != NULL); | |
| 1081 | |
| 1082 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetPDFDoc()->
GetInfo(); | 1050 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetPDFDoc()->
GetInfo(); |
| 1083 » if (!pDictionary)return FALSE; | 1051 if (!pDictionary) |
| 1084 | 1052 return FALSE; |
| 1085 » if (vp.IsGetting()) | 1053 |
| 1086 » { | 1054 if (vp.IsGetting()) |
| 1087 » » vp << pDictionary->GetUnicodeText("Subject"); | 1055 { |
| 1088 » » return TRUE; | 1056 vp << pDictionary->GetUnicodeText("Subject"); |
| 1089 » } | 1057 } |
| 1090 » else | 1058 else |
| 1091 » { | 1059 { |
| 1092 » » if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE; | 1060 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) |
| 1093 | 1061 return FALSE; |
| 1094 » » CFX_WideString cssubject; | 1062 |
| 1095 » » vp >> cssubject; | 1063 CFX_WideString cssubject; |
| 1096 » » pDictionary->SetAtString("Subject", PDF_EncodeText(cssubject)); | 1064 vp >> cssubject; |
| 1097 » » m_pDocument->SetChangeMark(); | 1065 pDictionary->SetAtString("Subject", PDF_EncodeText(cssubject)); |
| 1098 » » return TRUE; | 1066 m_pDocument->SetChangeMark(); |
| 1099 » } | 1067 } |
| 1068 return TRUE; |
| 1100 } | 1069 } |
| 1101 | 1070 |
| 1102 FX_BOOL Document::title(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) | 1071 FX_BOOL Document::title(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) |
| 1103 { | 1072 { |
| 1104 » ASSERT(m_pDocument != NULL); | 1073 if (m_pDocument == NULL || m_pDocument->GetDocument() == NULL) |
| 1105 | 1074 return FALSE; |
| 1106 » if (m_pDocument == NULL || m_pDocument->GetDocument() == NULL) | |
| 1107 » » return FALSE; | |
| 1108 | 1075 |
| 1109 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetPDFDoc()->
GetInfo(); | 1076 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetPDFDoc()->
GetInfo(); |
| 1110 » if (!pDictionary)return FALSE; | 1077 if (!pDictionary) |
| 1111 | 1078 return FALSE; |
| 1112 » if (vp.IsGetting()) | 1079 |
| 1113 » { | 1080 if (vp.IsGetting()) |
| 1114 » » vp << pDictionary->GetUnicodeText("Title"); | 1081 { |
| 1115 » » return TRUE; | 1082 vp << pDictionary->GetUnicodeText("Title"); |
| 1116 » } | 1083 } |
| 1117 » else | 1084 else |
| 1118 » { | 1085 { |
| 1119 » » if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE; | 1086 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) |
| 1120 | 1087 return FALSE; |
| 1121 » » CFX_WideString cstitle; | 1088 |
| 1122 » » vp >> cstitle; | 1089 CFX_WideString cstitle; |
| 1123 » » pDictionary->SetAtString("Title", PDF_EncodeText(cstitle)); | 1090 vp >> cstitle; |
| 1124 » » m_pDocument->SetChangeMark(); | 1091 pDictionary->SetAtString("Title", PDF_EncodeText(cstitle)); |
| 1125 » » return TRUE; | 1092 m_pDocument->SetChangeMark(); |
| 1126 » } | 1093 } |
| 1094 return TRUE; |
| 1127 } | 1095 } |
| 1128 | 1096 |
| 1129 FX_BOOL Document::numPages(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) | 1097 FX_BOOL Document::numPages(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) |
| 1130 { | 1098 { |
| 1131 » if (vp.IsSetting()) { | 1099 if (vp.IsSetting()) { |
| 1132 » » CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 1100 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
| 1133 » » sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); | 1101 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); |
| 1134 » » return FALSE; | 1102 return FALSE; |
| 1135 » } | 1103 } |
| 1136 » vp << m_pDocument->GetPageCount(); | 1104 vp << m_pDocument->GetPageCount(); |
| 1137 » return TRUE; | 1105 return TRUE; |
| 1138 } | 1106 } |
| 1139 | 1107 |
| 1140 FX_BOOL Document::external(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) | 1108 FX_BOOL Document::external(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) |
| 1141 { | 1109 { |
| 1142 » //In Chrome case,should always return true. | 1110 //In Chrome case,should always return true. |
| 1143 » if (vp.IsGetting()) { | 1111 if (vp.IsGetting()) { |
| 1144 » » vp << TRUE; | 1112 vp << TRUE; |
| 1145 » } | 1113 } |
| 1146 » return TRUE; | 1114 return TRUE; |
| 1147 } | 1115 } |
| 1148 | 1116 |
| 1149 FX_BOOL Document::filesize(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) | 1117 FX_BOOL Document::filesize(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) |
| 1150 { | 1118 { |
| 1151 » if (vp.IsSetting()) { | 1119 if (vp.IsSetting()) { |
| 1152 » » CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 1120 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
| 1153 » » sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); | 1121 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); |
| 1154 » » return FALSE; | 1122 return FALSE; |
| 1155 » } | 1123 } |
| 1156 » vp << 0; | 1124 vp << 0; |
| 1157 » return TRUE; | 1125 return TRUE; |
| 1158 } | 1126 } |
| 1159 | 1127 |
| 1160 FX_BOOL Document::mouseX(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) | 1128 FX_BOOL Document::mouseX(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) |
| 1161 { | 1129 { |
| 1162 » return TRUE; | 1130 return TRUE; |
| 1163 } | 1131 } |
| 1164 | 1132 |
| 1165 FX_BOOL Document::mouseY(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) | 1133 FX_BOOL Document::mouseY(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) |
| 1166 { | 1134 { |
| 1167 » return TRUE; | 1135 return TRUE; |
| 1168 } | 1136 } |
| 1169 | 1137 |
| 1170 FX_BOOL Document::baseURL(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) | 1138 FX_BOOL Document::baseURL(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) |
| 1171 { | 1139 { |
| 1172 » if (vp.IsGetting()) | 1140 if (vp.IsGetting()) |
| 1173 » { | 1141 { |
| 1174 » » vp << m_cwBaseURL; | 1142 vp << m_cwBaseURL; |
| 1175 » } | 1143 } |
| 1176 » else | 1144 else |
| 1177 » { | 1145 { |
| 1178 » » vp >> m_cwBaseURL; | 1146 vp >> m_cwBaseURL; |
| 1179 » } | 1147 } |
| 1180 » return TRUE; | 1148 return TRUE; |
| 1181 } | 1149 } |
| 1182 | 1150 |
| 1183 FX_BOOL Document::calculate(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString
& sError) | 1151 FX_BOOL Document::calculate(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString
& sError) |
| 1184 { | 1152 { |
| 1185 » ASSERT(m_pDocument != NULL); | 1153 ASSERT(m_pDocument != NULL); |
| 1186 | 1154 |
| 1187 » CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); | 1155 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterFor
m(); |
| 1188 » ASSERT(pInterForm != NULL); | 1156 ASSERT(pInterForm != NULL); |
| 1189 | 1157 |
| 1190 » if (vp.IsGetting()) | 1158 if (vp.IsGetting()) |
| 1191 » { | 1159 { |
| 1192 » » if (pInterForm->IsCalculateEnabled()) | 1160 if (pInterForm->IsCalculateEnabled()) |
| 1193 » » » vp << true; | 1161 vp << true; |
| 1194 » » else | 1162 else |
| 1195 » » » vp << false; | 1163 vp << false; |
| 1196 » } | 1164 } |
| 1197 » else | 1165 else |
| 1198 » { | 1166 { |
| 1199 » » bool bCalculate; | 1167 bool bCalculate; |
| 1200 » » vp >> bCalculate; | 1168 vp >> bCalculate; |
| 1201 | 1169 |
| 1202 » » pInterForm->EnableCalculate(bCalculate); | 1170 pInterForm->EnableCalculate(bCalculate); |
| 1203 » } | 1171 } |
| 1204 | 1172 |
| 1205 » return TRUE; | 1173 return TRUE; |
| 1206 } | 1174 } |
| 1207 | 1175 |
| 1208 FX_BOOL Document::documentFileName(IFXJS_Context* cc, CJS_PropValue& vp, CFX_Wid
eString& sError) | 1176 FX_BOOL Document::documentFileName(IFXJS_Context* cc, CJS_PropValue& vp, CFX_Wid
eString& sError) |
| 1209 { | 1177 { |
| 1210 » if (vp.IsSetting()) { | 1178 if (vp.IsSetting()) { |
| 1211 » » CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 1179 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
| 1212 » » sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); | 1180 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); |
| 1213 » » return FALSE; | 1181 return FALSE; |
| 1214 » } | 1182 } |
| 1215 » CFX_WideString wsFilePath = m_pDocument->GetPath(); | 1183 CFX_WideString wsFilePath = m_pDocument->GetPath(); |
| 1216 » int32_t i = wsFilePath.GetLength() - 1; | 1184 int32_t i = wsFilePath.GetLength() - 1; |
| 1217 » for ( ; i >= 0; i-- ) | 1185 for ( ; i >= 0; i-- ) |
| 1218 » { | 1186 { |
| 1219 » » if ( wsFilePath.GetAt( i ) == L'\\' || wsFilePath.GetAt( i ) ==
L'/' ) | 1187 if ( wsFilePath.GetAt( i ) == L'\\' || wsFilePath.GetAt( i ) == L'/' ) |
| 1220 » » » break; | 1188 break; |
| 1221 » } | 1189 } |
| 1222 » if ( i >= 0 && i < wsFilePath.GetLength() - 1 ) | 1190 if ( i >= 0 && i < wsFilePath.GetLength() - 1 ) |
| 1223 » { | 1191 { |
| 1224 » » vp << ( wsFilePath.GetBuffer( wsFilePath.GetLength() ) + i + 1 )
; | 1192 vp << ( wsFilePath.GetBuffer( wsFilePath.GetLength() ) + i + 1 ); |
| 1225 » }else{ | 1193 }else{ |
| 1226 » » vp << L""; | 1194 vp << L""; |
| 1227 » } | 1195 } |
| 1228 » return TRUE; | 1196 return TRUE; |
| 1229 } | 1197 } |
| 1230 | 1198 |
| 1231 CFX_WideString Document::ReversalStr(CFX_WideString cbFrom) | 1199 CFX_WideString Document::ReversalStr(CFX_WideString cbFrom) |
| 1232 { | 1200 { |
| 1233 » size_t iLength = cbFrom.GetLength(); | 1201 size_t iLength = cbFrom.GetLength(); |
| 1234 pdfium::base::CheckedNumeric<size_t> iSize = sizeof(wchar_t); | 1202 pdfium::base::CheckedNumeric<size_t> iSize = sizeof(wchar_t); |
| 1235 » iSize *= (iLength + 1); | 1203 iSize *= (iLength + 1); |
| 1236 » wchar_t* pResult = (wchar_t*)malloc(iSize.ValueOrDie()); | 1204 wchar_t* pResult = (wchar_t*)malloc(iSize.ValueOrDie()); |
| 1237 » wchar_t* pFrom = (wchar_t*)cbFrom.GetBuffer(iLength); | 1205 wchar_t* pFrom = (wchar_t*)cbFrom.GetBuffer(iLength); |
| 1238 | 1206 |
| 1239 » for (size_t i = 0; i < iLength; i++) | 1207 for (size_t i = 0; i < iLength; i++) |
| 1240 » { | 1208 { |
| 1241 » » pResult[i] = *(pFrom + iLength - i - 1); | 1209 pResult[i] = *(pFrom + iLength - i - 1); |
| 1242 » } | 1210 } |
| 1243 » pResult[iLength] = L'\0'; | 1211 pResult[iLength] = L'\0'; |
| 1244 | 1212 |
| 1245 » cbFrom.ReleaseBuffer(); | 1213 cbFrom.ReleaseBuffer(); |
| 1246 » CFX_WideString cbRet = CFX_WideString(pResult); | 1214 CFX_WideString cbRet = CFX_WideString(pResult); |
| 1247 » free(pResult); | 1215 free(pResult); |
| 1248 » pResult = NULL; | 1216 pResult = NULL; |
| 1249 » return cbRet; | 1217 return cbRet; |
| 1250 } | 1218 } |
| 1251 | 1219 |
| 1252 CFX_WideString Document::CutString(CFX_WideString cbFrom) | 1220 CFX_WideString Document::CutString(CFX_WideString cbFrom) |
| 1253 { | 1221 { |
| 1254 » size_t iLength = cbFrom.GetLength(); | 1222 size_t iLength = cbFrom.GetLength(); |
| 1255 » pdfium::base::CheckedNumeric<size_t> iSize = sizeof(wchar_t); | 1223 pdfium::base::CheckedNumeric<size_t> iSize = sizeof(wchar_t); |
| 1256 » iSize *= (iLength + 1); | 1224 iSize *= (iLength + 1); |
| 1257 » wchar_t* pResult = (wchar_t*)malloc(iSize.ValueOrDie()); | 1225 wchar_t* pResult = (wchar_t*)malloc(iSize.ValueOrDie()); |
| 1258 » wchar_t* pFrom = (wchar_t*)cbFrom.GetBuffer(iLength); | 1226 wchar_t* pFrom = (wchar_t*)cbFrom.GetBuffer(iLength); |
| 1259 | 1227 |
| 1260 » for (int i = 0; i < iLength; i++) | 1228 for (int i = 0; i < iLength; i++) |
| 1261 » { | 1229 { |
| 1262 » » if (pFrom[i] == L'\\' || pFrom[i] == L'/') | 1230 if (pFrom[i] == L'\\' || pFrom[i] == L'/') |
| 1263 » » { | 1231 { |
| 1264 » » » pResult[i] = L'\0'; | 1232 pResult[i] = L'\0'; |
| 1265 » » » break; | 1233 break; |
| 1266 » » } | 1234 } |
| 1267 » » pResult[i] = pFrom[i]; | 1235 pResult[i] = pFrom[i]; |
| 1268 » } | 1236 } |
| 1269 » pResult[iLength] = L'\0'; | 1237 pResult[iLength] = L'\0'; |
| 1270 | 1238 |
| 1271 » cbFrom.ReleaseBuffer(); | 1239 cbFrom.ReleaseBuffer(); |
| 1272 » CFX_WideString cbRet = CFX_WideString(pResult); | 1240 CFX_WideString cbRet = CFX_WideString(pResult); |
| 1273 » free(pResult); | 1241 free(pResult); |
| 1274 » pResult = NULL; | 1242 pResult = NULL; |
| 1275 » return cbRet; | 1243 return cbRet; |
| 1276 } | 1244 } |
| 1277 | 1245 |
| 1278 FX_BOOL Document::path(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr
ror) | 1246 FX_BOOL Document::path(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr
ror) |
| 1279 { | 1247 { |
| 1280 » if (vp.IsSetting()) { | 1248 if (vp.IsSetting()) { |
| 1281 » » CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 1249 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
| 1282 » » sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); | 1250 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); |
| 1283 » » return FALSE; | 1251 return FALSE; |
| 1284 » } | 1252 } |
| 1285 » vp << app::SysPathToPDFPath(m_pDocument->GetPath()); | 1253 vp << app::SysPathToPDFPath(m_pDocument->GetPath()); |
| 1286 » return TRUE; | 1254 return TRUE; |
| 1287 } | 1255 } |
| 1288 | 1256 |
| 1289 FX_BOOL Document::pageWindowRect(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideS
tring& sError) | 1257 FX_BOOL Document::pageWindowRect(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideS
tring& sError) |
| 1290 { | 1258 { |
| 1291 » return TRUE; | 1259 return TRUE; |
| 1292 } | 1260 } |
| 1293 | 1261 |
| 1294 FX_BOOL Document::layout(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) | 1262 FX_BOOL Document::layout(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) |
| 1295 { | 1263 { |
| 1296 » return TRUE; | 1264 return TRUE; |
| 1297 } | 1265 } |
| 1298 | 1266 |
| 1299 FX_BOOL Document::addLink(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) | 1267 FX_BOOL Document::addLink(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) |
| 1300 { | 1268 { |
| 1301 » return TRUE; | 1269 return TRUE; |
| 1302 } | 1270 } |
| 1303 | 1271 |
| 1304 FX_BOOL Document::closeDoc(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) | 1272 FX_BOOL Document::closeDoc(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) |
| 1305 { | 1273 { |
| 1306 » ASSERT(m_pDocument != NULL); | 1274 ASSERT(m_pDocument != NULL); |
| 1307 » return TRUE; | 1275 return TRUE; |
| 1308 } | 1276 } |
| 1309 | 1277 |
| 1310 FX_BOOL Document::getPageBox(IFXJS_Context* cc, const CJS_Parameters& params, CJ
S_Value& vRet, CFX_WideString& sError) | 1278 FX_BOOL Document::getPageBox(IFXJS_Context* cc, const CJS_Parameters& params, CJ
S_Value& vRet, CFX_WideString& sError) |
| 1311 { | 1279 { |
| 1312 » return TRUE; | 1280 return TRUE; |
| 1313 } | 1281 } |
| 1314 | 1282 |
| 1315 FX_BOOL Document::getAnnot(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) | 1283 FX_BOOL Document::getAnnot(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) |
| 1316 { | 1284 { |
| 1317 » return TRUE; | 1285 return TRUE; |
| 1318 } | 1286 } |
| 1319 | 1287 |
| 1320 FX_BOOL Document::getAnnots(IFXJS_Context* cc, const CJS_Parameters& params, CJS
_Value& vRet, CFX_WideString& sError) | 1288 FX_BOOL Document::getAnnots(IFXJS_Context* cc, const CJS_Parameters& params, CJS
_Value& vRet, CFX_WideString& sError) |
| 1321 { | 1289 { |
| 1322 » vRet.SetNull(); | 1290 vRet.SetNull(); |
| 1323 » return TRUE; | 1291 return TRUE; |
| 1324 } | 1292 } |
| 1325 | 1293 |
| 1326 FX_BOOL Document::getAnnot3D(IFXJS_Context* cc, const CJS_Parameters& params, CJ
S_Value& vRet, CFX_WideString& sError) | 1294 FX_BOOL Document::getAnnot3D(IFXJS_Context* cc, const CJS_Parameters& params, CJ
S_Value& vRet, CFX_WideString& sError) |
| 1327 { | 1295 { |
| 1328 » vRet.SetNull(); | 1296 vRet.SetNull(); |
| 1329 » return TRUE; | 1297 return TRUE; |
| 1330 } | 1298 } |
| 1331 | 1299 |
| 1332 FX_BOOL Document::getAnnots3D(IFXJS_Context* cc, const CJS_Parameters& params, C
JS_Value& vRet, CFX_WideString& sError) | 1300 FX_BOOL Document::getAnnots3D(IFXJS_Context* cc, const CJS_Parameters& params, C
JS_Value& vRet, CFX_WideString& sError) |
| 1333 { | 1301 { |
| 1334 » vRet = VT_undefined; | 1302 vRet = VT_undefined; |
| 1335 » return TRUE; | 1303 return TRUE; |
| 1336 } | 1304 } |
| 1337 | 1305 |
| 1338 FX_BOOL Document::getOCGs(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) | 1306 FX_BOOL Document::getOCGs(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) |
| 1339 { | 1307 { |
| 1340 » return TRUE; | 1308 return TRUE; |
| 1341 } | 1309 } |
| 1342 | 1310 |
| 1343 FX_BOOL Document::getLinks(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) | 1311 FX_BOOL Document::getLinks(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) |
| 1344 { | 1312 { |
| 1345 » return TRUE; | 1313 return TRUE; |
| 1346 } | 1314 } |
| 1347 | 1315 |
| 1348 bool Document::IsEnclosedInRect(CFX_FloatRect rect, CFX_FloatRect LinkRect) | 1316 bool Document::IsEnclosedInRect(CFX_FloatRect rect, CFX_FloatRect LinkRect) |
| 1349 { | 1317 { |
| 1350 » if (rect.left <= LinkRect.left | 1318 return (rect.left <= LinkRect.left && |
| 1351 » && rect.top <= LinkRect.top | 1319 rect.top <= LinkRect.top && |
| 1352 » && rect.right >= LinkRect.right | 1320 rect.right >= LinkRect.right && |
| 1353 » && rect.bottom >= LinkRect.bottom) | 1321 rect.bottom >= LinkRect.bottom); |
| 1354 » » return true; | |
| 1355 » else | |
| 1356 » » return false; | |
| 1357 } | 1322 } |
| 1358 | 1323 |
| 1359 void IconTree::InsertIconElement(IconElement* pNewIcon) | 1324 void IconTree::InsertIconElement(IconElement* pNewIcon) |
| 1360 { | 1325 { |
| 1361 » if (!pNewIcon)return; | 1326 if (!pNewIcon)return; |
| 1362 | 1327 |
| 1363 » if (m_pHead == NULL && m_pEnd == NULL) | 1328 if (m_pHead == NULL && m_pEnd == NULL) |
| 1364 » { | 1329 { |
| 1365 » » m_pHead = m_pEnd = pNewIcon; | 1330 m_pHead = m_pEnd = pNewIcon; |
| 1366 » » m_iLength++; | 1331 m_iLength++; |
| 1367 » } | 1332 } |
| 1368 » else | 1333 else |
| 1369 » { | 1334 { |
| 1370 » » m_pEnd->NextIcon = pNewIcon; | 1335 m_pEnd->NextIcon = pNewIcon; |
| 1371 » » m_pEnd = pNewIcon; | 1336 m_pEnd = pNewIcon; |
| 1372 » » m_iLength++; | 1337 m_iLength++; |
| 1373 » } | 1338 } |
| 1374 } | 1339 } |
| 1375 | 1340 |
| 1376 void IconTree::DeleteIconTree() | 1341 void IconTree::DeleteIconTree() |
| 1377 { | 1342 { |
| 1378 » if (!m_pHead || !m_pEnd)return; | 1343 if (!m_pHead || !m_pEnd)return; |
| 1379 | 1344 |
| 1380 » IconElement* pTemp = NULL; | 1345 IconElement* pTemp = NULL; |
| 1381 » while(m_pEnd != m_pHead) | 1346 while(m_pEnd != m_pHead) |
| 1382 » { | 1347 { |
| 1383 » » pTemp = m_pHead; | 1348 pTemp = m_pHead; |
| 1384 » » m_pHead = m_pHead->NextIcon; | 1349 m_pHead = m_pHead->NextIcon; |
| 1385 » » delete pTemp; | 1350 delete pTemp; |
| 1386 » } | 1351 } |
| 1387 | 1352 |
| 1388 » delete m_pEnd; | 1353 delete m_pEnd; |
| 1389 » m_pHead = NULL; | 1354 m_pHead = NULL; |
| 1390 » m_pEnd = NULL; | 1355 m_pEnd = NULL; |
| 1391 } | 1356 } |
| 1392 | 1357 |
| 1393 int IconTree::GetLength() | 1358 int IconTree::GetLength() |
| 1394 { | 1359 { |
| 1395 » return m_iLength; | 1360 return m_iLength; |
| 1396 } | 1361 } |
| 1397 | 1362 |
| 1398 IconElement* IconTree::operator [](int iIndex) | 1363 IconElement* IconTree::operator [](int iIndex) |
| 1399 { | 1364 { |
| 1400 » if (iIndex >= 0 && iIndex <= m_iLength) | 1365 if (iIndex >= 0 && iIndex <= m_iLength) |
| 1401 » { | 1366 { |
| 1402 » » IconElement* pTemp = m_pHead; | 1367 IconElement* pTemp = m_pHead; |
| 1403 » » for (int i = 0; i < iIndex; i++) | 1368 for (int i = 0; i < iIndex; i++) |
| 1404 » » { | 1369 { |
| 1405 » » » pTemp = pTemp->NextIcon; | 1370 pTemp = pTemp->NextIcon; |
| 1406 » » } | 1371 } |
| 1407 » » return pTemp; | 1372 return pTemp; |
| 1408 » } | 1373 } |
| 1409 » else | 1374 return NULL; |
| 1410 » » return NULL; | |
| 1411 } | 1375 } |
| 1412 | 1376 |
| 1413 void IconTree::DeleteIconElement(CFX_WideString swIconName) | 1377 void IconTree::DeleteIconElement(CFX_WideString swIconName) |
| 1414 { | 1378 { |
| 1415 IconElement* pTemp = m_pHead; | 1379 IconElement* pTemp = m_pHead; |
| 1416 int iLoopCount = m_iLength; | 1380 int iLoopCount = m_iLength; |
| 1417 for (int i = 0; i < iLoopCount - 1; i++) | 1381 for (int i = 0; i < iLoopCount - 1; i++) |
| 1418 { | 1382 { |
| 1419 if (pTemp == m_pEnd) | 1383 if (pTemp == m_pEnd) |
| 1420 break; | 1384 break; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1446 | 1410 |
| 1447 continue; | 1411 continue; |
| 1448 } | 1412 } |
| 1449 | 1413 |
| 1450 pTemp = pTemp->NextIcon; | 1414 pTemp = pTemp->NextIcon; |
| 1451 } | 1415 } |
| 1452 } | 1416 } |
| 1453 | 1417 |
| 1454 FX_BOOL Document::addIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) | 1418 FX_BOOL Document::addIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) |
| 1455 { | 1419 { |
| 1456 » CJS_Context* pContext = (CJS_Context*)cc; | 1420 CJS_Context* pContext = (CJS_Context*)cc; |
| 1457 » if (params.size() != 2) { | 1421 if (params.size() != 2) { |
| 1458 » » sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 1422 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 1459 » » return FALSE; | 1423 return FALSE; |
| 1460 » } | 1424 } |
| 1461 | 1425 |
| 1462 » CFX_WideString swIconName = params[0].ToCFXWideString(); | 1426 CFX_WideString swIconName = params[0].ToCFXWideString(); |
| 1463 » JSFXObject pJSIcon = params[1].ToV8Object(); | 1427 JSFXObject pJSIcon = params[1].ToV8Object(); |
| 1464 | 1428 |
| 1465 » CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 1429 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 1466 » if (JS_GetObjDefnID(pJSIcon) != JS_GetObjDefnID(*pRuntime, L"Icon")) { | 1430 if (JS_GetObjDefnID(pJSIcon) != JS_GetObjDefnID(*pRuntime, L"Icon")) { |
| 1467 » » sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR); | 1431 sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR); |
| 1468 » » return FALSE; | 1432 return FALSE; |
| 1469 » } | 1433 } |
| 1470 | 1434 |
| 1471 » CJS_EmbedObj* pEmbedObj = params[1].ToCJSObject()->GetEmbedObject(); | 1435 CJS_EmbedObj* pEmbedObj = params[1].ToCJSObject()->GetEmbedObject(); |
| 1472 » if (!pEmbedObj) { | 1436 if (!pEmbedObj) { |
| 1473 » » sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR); | 1437 sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR); |
| 1474 » » return FALSE; | 1438 return FALSE; |
| 1475 » } | 1439 } |
| 1476 | 1440 |
| 1477 » Icon* pIcon = (Icon*)pEmbedObj; | 1441 Icon* pIcon = (Icon*)pEmbedObj; |
| 1478 » if (!m_pIconTree) | 1442 if (!m_pIconTree) |
| 1479 » » m_pIconTree = new IconTree(); | 1443 m_pIconTree = new IconTree(); |
| 1480 | 1444 |
| 1481 » IconElement* pNewIcon = new IconElement(); | 1445 IconElement* pNewIcon = new IconElement(); |
| 1482 » pNewIcon->IconName = swIconName; | 1446 pNewIcon->IconName = swIconName; |
| 1483 » pNewIcon->NextIcon = NULL; | 1447 pNewIcon->NextIcon = NULL; |
| 1484 » pNewIcon->IconStream = pIcon; | 1448 pNewIcon->IconStream = pIcon; |
| 1485 » m_pIconTree->InsertIconElement(pNewIcon); | 1449 m_pIconTree->InsertIconElement(pNewIcon); |
| 1486 » return TRUE; | 1450 return TRUE; |
| 1487 } | 1451 } |
| 1488 | 1452 |
| 1489 FX_BOOL Document::icons(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) | 1453 FX_BOOL Document::icons(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) |
| 1490 { | 1454 { |
| 1491 » if (vp.IsSetting()) { | 1455 if (vp.IsSetting()) { |
| 1492 » » CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 1456 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
| 1493 » » sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); | 1457 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); |
| 1494 » » return FALSE; | 1458 return FALSE; |
| 1495 » } | 1459 } |
| 1496 | 1460 |
| 1497 » if (!m_pIconTree) | 1461 if (!m_pIconTree) |
| 1498 » { | 1462 { |
| 1499 » » vp.SetNull(); | 1463 vp.SetNull(); |
| 1500 » » return TRUE; | 1464 return TRUE; |
| 1501 » } | 1465 } |
| 1502 | 1466 |
| 1503 » CJS_Array Icons(m_isolate); | 1467 CJS_Array Icons(m_isolate); |
| 1504 » IconElement* pIconElement = NULL; | 1468 IconElement* pIconElement = NULL; |
| 1505 » int iIconTreeLength = m_pIconTree->GetLength(); | 1469 int iIconTreeLength = m_pIconTree->GetLength(); |
| 1506 | 1470 |
| 1507 » CJS_Context* pContext = (CJS_Context *)cc; | 1471 CJS_Context* pContext = (CJS_Context *)cc; |
| 1508 » CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 1472 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 1509 | 1473 |
| 1510 » for (int i = 0; i < iIconTreeLength; i++) | 1474 for (int i = 0; i < iIconTreeLength; i++) |
| 1511 » { | 1475 { |
| 1512 » » pIconElement = (*m_pIconTree)[i]; | 1476 pIconElement = (*m_pIconTree)[i]; |
| 1513 | 1477 |
| 1514 » » JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_Ge
tObjDefnID(*pRuntime, L"Icon")); | 1478 JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDefn
ID(*pRuntime, L"Icon")); |
| 1515 » » if (pObj.IsEmpty()) return FALSE; | 1479 if (pObj.IsEmpty()) return FALSE; |
| 1516 | 1480 |
| 1517 » » CJS_Icon * pJS_Icon = (CJS_Icon *)JS_GetPrivate(pObj); | 1481 CJS_Icon * pJS_Icon = (CJS_Icon *)JS_GetPrivate(pObj); |
| 1518 » » if (!pJS_Icon) return FALSE; | 1482 if (!pJS_Icon) return FALSE; |
| 1519 | 1483 |
| 1520 » » Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); | 1484 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); |
| 1521 » » if (!pIcon)return FALSE; | 1485 if (!pIcon)return FALSE; |
| 1522 | 1486 |
| 1523 » » pIcon->SetStream(pIconElement->IconStream->GetStream()); | 1487 pIcon->SetStream(pIconElement->IconStream->GetStream()); |
| 1524 » » pIcon->SetIconName(pIconElement->IconName); | 1488 pIcon->SetIconName(pIconElement->IconName); |
| 1525 » » Icons.SetElement(i, CJS_Value(m_isolate,pJS_Icon)); | 1489 Icons.SetElement(i, CJS_Value(m_isolate,pJS_Icon)); |
| 1526 » } | 1490 } |
| 1527 | 1491 |
| 1528 » vp << Icons; | 1492 vp << Icons; |
| 1529 » return TRUE; | 1493 return TRUE; |
| 1530 } | 1494 } |
| 1531 | 1495 |
| 1532 FX_BOOL Document::getIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) | 1496 FX_BOOL Document::getIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) |
| 1533 { | 1497 { |
| 1534 » CJS_Context* pContext = (CJS_Context *)cc; | 1498 CJS_Context* pContext = (CJS_Context *)cc; |
| 1535 » if (params.size() != 1) { | 1499 if (params.size() != 1) { |
| 1536 » » sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 1500 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 1537 » » return FALSE; | 1501 return FALSE; |
| 1538 » } | 1502 } |
| 1539 | 1503 |
| 1540 » if(!m_pIconTree) | 1504 if(!m_pIconTree) |
| 1541 » » return FALSE; | 1505 return FALSE; |
| 1542 » CFX_WideString swIconName = params[0].ToCFXWideString(); | 1506 CFX_WideString swIconName = params[0].ToCFXWideString(); |
| 1543 » int iIconCounts = m_pIconTree->GetLength(); | 1507 int iIconCounts = m_pIconTree->GetLength(); |
| 1544 | 1508 |
| 1545 » CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 1509 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 1546 | 1510 |
| 1547 » for (int i = 0; i < iIconCounts; i++) | 1511 for (int i = 0; i < iIconCounts; i++) |
| 1548 » { | 1512 { |
| 1549 » » if ((*m_pIconTree)[i]->IconName == swIconName) | 1513 if ((*m_pIconTree)[i]->IconName == swIconName) |
| 1550 » » { | 1514 { |
| 1551 » » » Icon* pRetIcon = (*m_pIconTree)[i]->IconStream; | 1515 Icon* pRetIcon = (*m_pIconTree)[i]->IconStream; |
| 1552 | 1516 |
| 1553 » » » JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContex
t, JS_GetObjDefnID(*pRuntime, L"Icon")); | 1517 JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObj
DefnID(*pRuntime, L"Icon")); |
| 1554 » » » if (pObj.IsEmpty()) return FALSE; | 1518 if (pObj.IsEmpty()) return FALSE; |
| 1555 | 1519 |
| 1556 » » » CJS_Icon * pJS_Icon = (CJS_Icon *)JS_GetPrivate(pObj); | 1520 CJS_Icon * pJS_Icon = (CJS_Icon *)JS_GetPrivate(pObj); |
| 1557 » » » if (!pJS_Icon) return FALSE; | 1521 if (!pJS_Icon) return FALSE; |
| 1558 | 1522 |
| 1559 » » » Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); | 1523 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); |
| 1560 » » » if (!pIcon)return FALSE; | 1524 if (!pIcon)return FALSE; |
| 1561 | 1525 |
| 1562 » » » pIcon->SetIconName(swIconName); | 1526 pIcon->SetIconName(swIconName); |
| 1563 » » » pIcon->SetStream(pRetIcon->GetStream()); | 1527 pIcon->SetStream(pRetIcon->GetStream()); |
| 1564 » » » vRet = pJS_Icon; | 1528 vRet = pJS_Icon; |
| 1565 » » » return TRUE; | 1529 return TRUE; |
| 1566 » » } | 1530 } |
| 1567 » } | 1531 } |
| 1568 | 1532 |
| 1569 » return FALSE; | 1533 return FALSE; |
| 1570 } | 1534 } |
| 1571 | 1535 |
| 1572 FX_BOOL Document::removeIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJ
S_Value& vRet, CFX_WideString& sError) | 1536 FX_BOOL Document::removeIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJ
S_Value& vRet, CFX_WideString& sError) |
| 1573 { | 1537 { |
| 1574 CJS_Context* pContext = (CJS_Context *)cc; | 1538 CJS_Context* pContext = (CJS_Context *)cc; |
| 1575 if (params.size() != 1) { | 1539 if (params.size() != 1) { |
| 1576 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 1540 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 1577 return FALSE; | 1541 return FALSE; |
| 1578 } | 1542 } |
| 1579 | 1543 |
| 1580 if(!m_pIconTree) | 1544 if(!m_pIconTree) |
| 1581 return FALSE; | 1545 return FALSE; |
| 1582 CFX_WideString swIconName = params[0].ToCFXWideString(); | 1546 CFX_WideString swIconName = params[0].ToCFXWideString(); |
| 1583 return TRUE; | 1547 return TRUE; |
| 1584 } | 1548 } |
| 1585 | 1549 |
| 1586 FX_BOOL Document::createDataObject(IFXJS_Context* cc, const CJS_Parameters& para
ms, CJS_Value& vRet, CFX_WideString& sError) | 1550 FX_BOOL Document::createDataObject(IFXJS_Context* cc, const CJS_Parameters& para
ms, CJS_Value& vRet, CFX_WideString& sError) |
| 1587 { | 1551 { |
| 1588 // Unsafe, not implemented. | 1552 // Unsafe, not implemented. |
| 1589 return TRUE; | 1553 return TRUE; |
| 1590 } | 1554 } |
| 1591 | 1555 |
| 1592 FX_BOOL Document::media(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) | 1556 FX_BOOL Document::media(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) |
| 1593 { | 1557 { |
| 1594 » return TRUE; | 1558 return TRUE; |
| 1595 } | 1559 } |
| 1596 | 1560 |
| 1597 FX_BOOL Document::calculateNow(IFXJS_Context* cc, const CJS_Parameters& params,
CJS_Value& vRet, CFX_WideString& sError) | 1561 FX_BOOL Document::calculateNow(IFXJS_Context* cc, const CJS_Parameters& params,
CJS_Value& vRet, CFX_WideString& sError) |
| 1598 { | 1562 { |
| 1599 » ASSERT(m_pDocument != NULL); | 1563 ASSERT(m_pDocument != NULL); |
| 1600 | 1564 |
| 1601 » if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || | 1565 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || |
| 1602 » » m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) || | 1566 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) || |
| 1603 » » m_pDocument->GetPermissions(FPDFPERM_FILL_FORM))) return FALSE; | 1567 m_pDocument->GetPermissions(FPDFPERM_FILL_FORM))) return FALSE; |
| 1604 | 1568 |
| 1605 » CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); | 1569 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterFor
m(); |
| 1606 » ASSERT(pInterForm != NULL); | 1570 ASSERT(pInterForm != NULL); |
| 1607 » pInterForm->OnCalculate(); | 1571 pInterForm->OnCalculate(); |
| 1608 » return TRUE; | 1572 return TRUE; |
| 1609 } | 1573 } |
| 1610 | 1574 |
| 1611 FX_BOOL Document::Collab(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) | 1575 FX_BOOL Document::Collab(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) |
| 1612 { | 1576 { |
| 1613 » return TRUE; | 1577 return TRUE; |
| 1614 } | 1578 } |
| 1615 | 1579 |
| 1616 FX_BOOL Document::getPageNthWord(IFXJS_Context* cc, const CJS_Parameters& params
, CJS_Value& vRet, CFX_WideString& sError) | 1580 FX_BOOL Document::getPageNthWord(IFXJS_Context* cc, const CJS_Parameters& params
, CJS_Value& vRet, CFX_WideString& sError) |
| 1617 { | 1581 { |
| 1618 » ASSERT(m_pDocument != NULL); | 1582 ASSERT(m_pDocument != NULL); |
| 1619 | 1583 |
| 1620 » if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; | 1584 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; |
| 1621 | 1585 |
| 1622 » int nPageNo = params.GetSize() > 0 ? params[0].ToInt() : 0; | 1586 int nPageNo = params.GetSize() > 0 ? params[0].ToInt() : 0; |
| 1623 » int nWordNo = params.GetSize() > 1 ? params[1].ToInt() : 0; | 1587 int nWordNo = params.GetSize() > 1 ? params[1].ToInt() : 0; |
| 1624 » bool bStrip = params.GetSize() > 2 ? params[2].ToBool() : true; | 1588 bool bStrip = params.GetSize() > 2 ? params[2].ToBool() : true; |
| 1625 | 1589 |
| 1626 CPDF_Document* pDocument = m_pDocument->GetDocument()->GetPDFDoc(); | 1590 CPDF_Document* pDocument = m_pDocument->GetDocument()->GetPDFDoc(); |
| 1627 » if (!pDocument) return FALSE; | 1591 » if (!pDocument) |
| 1628 | 1592 return FALSE; |
| 1629 » CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 1593 |
| 1630 » if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) | 1594 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
| 1631 » { | 1595 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) |
| 1632 » » sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); | 1596 { |
| 1633 » » return FALSE; | 1597 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); |
| 1634 » } | 1598 return FALSE; |
| 1635 | 1599 } |
| 1636 » CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo); | 1600 |
| 1637 » if (!pPageDict) return FALSE; | 1601 CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo); |
| 1638 | 1602 if (!pPageDict) return FALSE; |
| 1639 » CPDF_Page page; | 1603 |
| 1640 » page.Load(pDocument, pPageDict); | 1604 CPDF_Page page; |
| 1641 » page.StartParse(); | 1605 page.Load(pDocument, pPageDict); |
| 1642 » page.ParseContent(); | 1606 page.StartParse(); |
| 1643 | 1607 page.ParseContent(); |
| 1644 » FX_POSITION pos = page.GetFirstObjectPosition(); | 1608 |
| 1645 | 1609 FX_POSITION pos = page.GetFirstObjectPosition(); |
| 1646 » int nWords = 0; | 1610 |
| 1647 | 1611 int nWords = 0; |
| 1648 » CFX_WideString swRet; | 1612 |
| 1649 | 1613 CFX_WideString swRet; |
| 1650 » while (pos) | 1614 |
| 1651 » { | 1615 while (pos) |
| 1652 » » if (CPDF_PageObject* pPageObj = page.GetNextObject(pos)) | 1616 { |
| 1653 » » { | 1617 if (CPDF_PageObject* pPageObj = page.GetNextObject(pos)) |
| 1654 » » » if (pPageObj->m_Type == PDFPAGE_TEXT) | 1618 { |
| 1655 » » » { | 1619 if (pPageObj->m_Type == PDFPAGE_TEXT) |
| 1656 » » » » int nObjWords = CountWords((CPDF_TextObject*)pPa
geObj); | 1620 { |
| 1657 | 1621 int nObjWords = CountWords((CPDF_TextObject*)pPageObj); |
| 1658 » » » » if (nWords + nObjWords >= nWordNo) | 1622 |
| 1659 » » » » { | 1623 if (nWords + nObjWords >= nWordNo) |
| 1660 » » » » » swRet = GetObjWordStr((CPDF_TextObject*)
pPageObj, nWordNo - nWords); | 1624 { |
| 1661 » » » » » break; | 1625 swRet = GetObjWordStr((CPDF_TextObject*)pPageObj, nWordNo -
nWords); |
| 1662 » » » » } | 1626 break; |
| 1663 | 1627 } |
| 1664 » » » » nWords += nObjWords; | 1628 |
| 1665 » » » } | 1629 nWords += nObjWords; |
| 1666 » » } | 1630 } |
| 1667 » } | 1631 } |
| 1668 | 1632 } |
| 1669 » if (bStrip) | 1633 |
| 1670 » { | 1634 if (bStrip) |
| 1671 » » swRet.TrimLeft(); | 1635 { |
| 1672 » » swRet.TrimRight(); | 1636 swRet.TrimLeft(); |
| 1673 » } | 1637 swRet.TrimRight(); |
| 1674 | 1638 } |
| 1675 » vRet = swRet.c_str(); | 1639 |
| 1676 » return TRUE; | 1640 vRet = swRet.c_str(); |
| 1641 return TRUE; |
| 1677 } | 1642 } |
| 1678 | 1643 |
| 1679 FX_BOOL Document::getPageNthWordQuads(IFXJS_Context* cc, const CJS_Parameters& p
arams, CJS_Value& vRet, CFX_WideString& sError) | 1644 FX_BOOL Document::getPageNthWordQuads(IFXJS_Context* cc, const CJS_Parameters& p
arams, CJS_Value& vRet, CFX_WideString& sError) |
| 1680 { | 1645 { |
| 1681 » ASSERT(m_pDocument != NULL); | 1646 ASSERT(m_pDocument != NULL); |
| 1682 | 1647 |
| 1683 » if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; | 1648 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; |
| 1684 | 1649 |
| 1685 » return FALSE; | 1650 return FALSE; |
| 1686 } | 1651 } |
| 1687 | 1652 |
| 1688 FX_BOOL Document::getPageNumWords(IFXJS_Context* cc, const CJS_Parameters& param
s, CJS_Value& vRet, CFX_WideString& sError) | 1653 FX_BOOL Document::getPageNumWords(IFXJS_Context* cc, const CJS_Parameters& param
s, CJS_Value& vRet, CFX_WideString& sError) |
| 1689 { | 1654 { |
| 1690 » ASSERT(m_pDocument != NULL); | 1655 ASSERT(m_pDocument != NULL); |
| 1691 | 1656 |
| 1692 » if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; | 1657 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; |
| 1693 | 1658 |
| 1694 » int nPageNo = params.GetSize() > 0 ? params[0].ToInt() : 0; | 1659 int nPageNo = params.GetSize() > 0 ? params[0].ToInt() : 0; |
| 1695 | |
| 1696 CPDF_Document* pDocument = m_pDocument->GetDocument()->GetPDFDoc(); | 1660 CPDF_Document* pDocument = m_pDocument->GetDocument()->GetPDFDoc(); |
| 1697 » ASSERT(pDocument != NULL); | 1661 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
| 1698 | 1662 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) |
| 1699 » CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 1663 { |
| 1700 » if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) | 1664 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); |
| 1701 » { | 1665 return FALSE; |
| 1702 » » sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); | 1666 } |
| 1703 » » return FALSE; | 1667 |
| 1704 » } | 1668 CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo); |
| 1705 | 1669 if (!pPageDict) return FALSE; |
| 1706 » CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo); | 1670 |
| 1707 » if (!pPageDict) return FALSE; | 1671 CPDF_Page page; |
| 1708 | 1672 page.Load(pDocument, pPageDict); |
| 1709 » CPDF_Page page; | 1673 page.StartParse(); |
| 1710 » page.Load(pDocument, pPageDict); | 1674 page.ParseContent(); |
| 1711 » page.StartParse(); | 1675 |
| 1712 » page.ParseContent(); | 1676 FX_POSITION pos = page.GetFirstObjectPosition(); |
| 1713 | 1677 |
| 1714 » FX_POSITION pos = page.GetFirstObjectPosition(); | 1678 int nWords = 0; |
| 1715 | 1679 |
| 1716 » int nWords = 0; | 1680 while (pos) |
| 1717 | 1681 { |
| 1718 » while (pos) | 1682 if (CPDF_PageObject* pPageObj = page.GetNextObject(pos)) |
| 1719 » { | 1683 { |
| 1720 » » if (CPDF_PageObject* pPageObj = page.GetNextObject(pos)) | 1684 if (pPageObj->m_Type == PDFPAGE_TEXT) |
| 1721 » » { | 1685 { |
| 1722 » » » if (pPageObj->m_Type == PDFPAGE_TEXT) | 1686 CPDF_TextObject* pTextObj = (CPDF_TextObject*)pPageObj; |
| 1723 » » » { | 1687 nWords += CountWords(pTextObj); |
| 1724 » » » » CPDF_TextObject* pTextObj = (CPDF_TextObject*)pP
ageObj; | 1688 } |
| 1725 » » » » nWords += CountWords(pTextObj); | 1689 } |
| 1726 » » » } | 1690 } |
| 1727 » » } | 1691 |
| 1728 » } | 1692 vRet = nWords; |
| 1729 | 1693 |
| 1730 » vRet = nWords; | 1694 return TRUE; |
| 1731 | |
| 1732 » return TRUE; | |
| 1733 } | 1695 } |
| 1734 | 1696 |
| 1735 FX_BOOL Document::getPrintParams(IFXJS_Context* cc, const CJS_Parameters& params
, CJS_Value& vRet, CFX_WideString& sError) | 1697 FX_BOOL Document::getPrintParams(IFXJS_Context* cc, const CJS_Parameters& params
, CJS_Value& vRet, CFX_WideString& sError) |
| 1736 { | 1698 { |
| 1737 » CJS_Context* pContext = (CJS_Context*)cc; | 1699 CJS_Context* pContext = (CJS_Context*)cc; |
| 1738 » CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 1700 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 1739 » JSFXObject pRetObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDe
fnID(*pRuntime, L"PrintParamsObj")); | 1701 JSFXObject pRetObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDefnID
(*pRuntime, L"PrintParamsObj")); |
| 1740 | 1702 |
| 1741 » // Not implemented yet. | 1703 // Not implemented yet. |
| 1742 | 1704 |
| 1743 » vRet = pRetObj; | 1705 vRet = pRetObj; |
| 1744 » return TRUE; | 1706 return TRUE; |
| 1745 } | 1707 } |
| 1746 | 1708 |
| 1747 #define ISLATINWORD(u)» (u != 0x20 && u <= 0x28FF) | 1709 #define ISLATINWORD(u) (u != 0x20 && u <= 0x28FF) |
| 1748 | 1710 |
| 1749 int» Document::CountWords(CPDF_TextObject* pTextObj) | 1711 int Document::CountWords(CPDF_TextObject* pTextObj) |
| 1750 { | 1712 { |
| 1751 » if (!pTextObj) return 0; | 1713 if (!pTextObj) return 0; |
| 1752 | 1714 |
| 1753 » int nWords = 0; | 1715 int nWords = 0; |
| 1754 | 1716 |
| 1755 » CPDF_Font* pFont = pTextObj->GetFont(); | 1717 CPDF_Font* pFont = pTextObj->GetFont(); |
| 1756 » if (!pFont) return 0; | 1718 if (!pFont) return 0; |
| 1757 | 1719 |
| 1758 » FX_BOOL bIsLatin = FALSE; | 1720 FX_BOOL bIsLatin = FALSE; |
| 1759 | 1721 |
| 1760 » for (int i=0, sz=pTextObj->CountChars(); i<sz; i++) | 1722 for (int i=0, sz=pTextObj->CountChars(); i<sz; i++) |
| 1761 » { | 1723 { |
| 1762 » » FX_DWORD charcode = -1; | 1724 FX_DWORD charcode = -1; |
| 1763 » » FX_FLOAT kerning; | 1725 FX_FLOAT kerning; |
| 1764 | 1726 |
| 1765 » » pTextObj->GetCharInfo(i, charcode, kerning); | 1727 pTextObj->GetCharInfo(i, charcode, kerning); |
| 1766 » » CFX_WideString swUnicode = pFont->UnicodeFromCharCode(charcode); | 1728 CFX_WideString swUnicode = pFont->UnicodeFromCharCode(charcode); |
| 1767 | 1729 |
| 1768 » » FX_WORD unicode = 0; | 1730 FX_WORD unicode = 0; |
| 1769 » » if (swUnicode.GetLength() > 0) | 1731 if (swUnicode.GetLength() > 0) |
| 1770 » » » unicode = swUnicode[0]; | 1732 unicode = swUnicode[0]; |
| 1771 | 1733 |
| 1772 » » if (ISLATINWORD(unicode) && bIsLatin) | 1734 if (ISLATINWORD(unicode) && bIsLatin) |
| 1773 » » » continue; | 1735 continue; |
| 1774 | 1736 |
| 1775 » » bIsLatin = ISLATINWORD(unicode); | 1737 bIsLatin = ISLATINWORD(unicode); |
| 1776 » » if (unicode != 0x20) | 1738 if (unicode != 0x20) |
| 1777 » » » nWords++; | 1739 nWords++; |
| 1778 » } | 1740 } |
| 1779 | 1741 |
| 1780 » return nWords; | 1742 return nWords; |
| 1781 } | 1743 } |
| 1782 | 1744 |
| 1783 CFX_WideString Document::GetObjWordStr(CPDF_TextObject* pTextObj, int nWordIndex
) | 1745 CFX_WideString Document::GetObjWordStr(CPDF_TextObject* pTextObj, int nWordIndex
) |
| 1784 { | 1746 { |
| 1785 » ASSERT(pTextObj != NULL); | 1747 ASSERT(pTextObj != NULL); |
| 1786 | 1748 |
| 1787 » CFX_WideString swRet; | 1749 CFX_WideString swRet; |
| 1788 | 1750 |
| 1789 » CPDF_Font* pFont = pTextObj->GetFont(); | 1751 CPDF_Font* pFont = pTextObj->GetFont(); |
| 1790 » if (!pFont) return L""; | 1752 if (!pFont) return L""; |
| 1791 | 1753 |
| 1792 » int nWords = 0; | 1754 int nWords = 0; |
| 1793 » FX_BOOL bIsLatin = FALSE; | 1755 FX_BOOL bIsLatin = FALSE; |
| 1794 | 1756 |
| 1795 » for (int i=0, sz=pTextObj->CountChars(); i<sz; i++) | 1757 for (int i=0, sz=pTextObj->CountChars(); i<sz; i++) |
| 1796 » { | 1758 { |
| 1797 » » FX_DWORD charcode = -1; | 1759 FX_DWORD charcode = -1; |
| 1798 » » FX_FLOAT kerning; | 1760 FX_FLOAT kerning; |
| 1799 | 1761 |
| 1800 » » pTextObj->GetCharInfo(i, charcode, kerning); | 1762 pTextObj->GetCharInfo(i, charcode, kerning); |
| 1801 » » CFX_WideString swUnicode = pFont->UnicodeFromCharCode(charcode); | 1763 CFX_WideString swUnicode = pFont->UnicodeFromCharCode(charcode); |
| 1802 | 1764 |
| 1803 » » FX_WORD unicode = 0; | 1765 FX_WORD unicode = 0; |
| 1804 » » if (swUnicode.GetLength() > 0) | 1766 if (swUnicode.GetLength() > 0) |
| 1805 » » » unicode = swUnicode[0]; | 1767 unicode = swUnicode[0]; |
| 1806 | 1768 |
| 1807 » » if (ISLATINWORD(unicode) && bIsLatin) | 1769 if (ISLATINWORD(unicode) && bIsLatin) |
| 1808 » » { | 1770 { |
| 1809 » » } | 1771 } |
| 1810 » » else | 1772 else |
| 1811 » » { | 1773 { |
| 1812 » » » bIsLatin = ISLATINWORD(unicode); | 1774 bIsLatin = ISLATINWORD(unicode); |
| 1813 » » » if (unicode != 0x20) | 1775 if (unicode != 0x20) |
| 1814 » » » » nWords++; | 1776 nWords++; |
| 1815 » » } | 1777 } |
| 1816 | 1778 |
| 1817 » » if (nWords-1 == nWordIndex) | 1779 if (nWords-1 == nWordIndex) |
| 1818 » » » swRet += unicode; | 1780 swRet += unicode; |
| 1819 » } | 1781 } |
| 1820 | 1782 |
| 1821 » return swRet; | 1783 return swRet; |
| 1822 } | 1784 } |
| 1823 | 1785 |
| 1824 FX_BOOL Document::zoom(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr
ror) | 1786 FX_BOOL Document::zoom(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr
ror) |
| 1825 { | 1787 { |
| 1826 | 1788 |
| 1827 » return TRUE; | 1789 return TRUE; |
| 1828 } | 1790 } |
| 1829 | 1791 |
| 1830 /** | 1792 /** |
| 1831 (none,» NoVary) | 1793 (none, NoVary) |
| 1832 (fitP,» FitPage) | 1794 (fitP, FitPage) |
| 1833 (fitW,» FitWidth) | 1795 (fitW, FitWidth) |
| 1834 (fitH,» FitHeight) | 1796 (fitH, FitHeight) |
| 1835 (fitV,» FitVisibleWidth) | 1797 (fitV, FitVisibleWidth) |
| 1836 (pref,» Preferred) | 1798 (pref, Preferred) |
| 1837 (refW,» ReflowWidth) | 1799 (refW, ReflowWidth) |
| 1838 */ | 1800 */ |
| 1839 | 1801 |
| 1840 FX_BOOL Document::zoomType(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) | 1802 FX_BOOL Document::zoomType(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) |
| 1841 { | 1803 { |
| 1842 » return TRUE; | 1804 return TRUE; |
| 1843 } | 1805 } |
| 1844 | 1806 |
| 1845 FX_BOOL Document::deletePages(IFXJS_Context* cc, const CJS_Parameters& params, C
JS_Value& vRet, CFX_WideString& sError) | 1807 FX_BOOL Document::deletePages(IFXJS_Context* cc, const CJS_Parameters& params, C
JS_Value& vRet, CFX_WideString& sError) |
| 1846 { | 1808 { |
| 1847 v8::Isolate* isolate = GetIsolate(cc); | 1809 v8::Isolate* isolate = GetIsolate(cc); |
| 1848 ASSERT(m_pDocument != NULL); | 1810 ASSERT(m_pDocument != NULL); |
| 1849 | 1811 |
| 1850 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || | 1812 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || |
| 1851 m_pDocument->GetPermissions(FPDFPERM_ASSEMBLE))) return FALSE; | 1813 m_pDocument->GetPermissions(FPDFPERM_ASSEMBLE))) return FALSE; |
| 1852 | 1814 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1914 } | 1876 } |
| 1915 | 1877 |
| 1916 FX_BOOL Document::getURL(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va
lue& vRet, CFX_WideString& sError) | 1878 FX_BOOL Document::getURL(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va
lue& vRet, CFX_WideString& sError) |
| 1917 { | 1879 { |
| 1918 // Unsafe, not supported. | 1880 // Unsafe, not supported. |
| 1919 return TRUE; | 1881 return TRUE; |
| 1920 } | 1882 } |
| 1921 | 1883 |
| 1922 void Document::AddDelayData(CJS_DelayData* pData) | 1884 void Document::AddDelayData(CJS_DelayData* pData) |
| 1923 { | 1885 { |
| 1924 » m_DelayData.Add(pData); | 1886 m_DelayData.Add(pData); |
| 1925 } | 1887 } |
| 1926 | 1888 |
| 1927 void Document::DoFieldDelay(const CFX_WideString& sFieldName, int nControlIndex) | 1889 void Document::DoFieldDelay(const CFX_WideString& sFieldName, int nControlIndex) |
| 1928 { | 1890 { |
| 1929 CFX_DWordArray DelArray; | 1891 CFX_DWordArray DelArray; |
| 1930 | 1892 |
| 1931 for (int i=0,sz=m_DelayData.GetSize(); i<sz; i++) | 1893 for (int i=0,sz=m_DelayData.GetSize(); i<sz; i++) |
| 1932 { | 1894 { |
| 1933 if (CJS_DelayData* pData = m_DelayData.GetAt(i)) | 1895 if (CJS_DelayData* pData = m_DelayData.GetAt(i)) |
| 1934 { | 1896 { |
| 1935 if (pData->sFieldName == sFieldName && pData->nControlIn
dex == nControlIndex) | 1897 if (pData->sFieldName == sFieldName && pData->nControlIn
dex == nControlIndex) |
| 1936 { | 1898 { |
| 1937 Field::DoDelay(m_pDocument, pData); | 1899 Field::DoDelay(m_pDocument, pData); |
| 1938 delete pData; | 1900 delete pData; |
| 1939 m_DelayData.SetAt(i, NULL); | 1901 m_DelayData.SetAt(i, NULL); |
| 1940 DelArray.Add(i); | 1902 DelArray.Add(i); |
| 1941 } | 1903 } |
| 1942 } | 1904 } |
| 1943 } | 1905 } |
| 1944 | 1906 |
| 1945 for (int j=DelArray.GetSize()-1; j>=0; j--) | 1907 for (int j=DelArray.GetSize()-1; j>=0; j--) |
| 1946 { | 1908 { |
| 1947 m_DelayData.RemoveAt(DelArray[j]); | 1909 m_DelayData.RemoveAt(DelArray[j]); |
| 1948 } | 1910 } |
| 1949 } | 1911 } |
| 1950 | 1912 |
| 1951 void Document::AddDelayAnnotData(CJS_AnnotObj *pData) | 1913 void Document::AddDelayAnnotData(CJS_AnnotObj *pData) |
| 1952 { | 1914 { |
| 1953 » m_DelayAnnotData.Add(pData); | 1915 m_DelayAnnotData.Add(pData); |
| 1954 } | 1916 } |
| 1955 | 1917 |
| 1956 void Document::DoAnnotDelay() | 1918 void Document::DoAnnotDelay() |
| 1957 { | 1919 { |
| 1958 » CFX_DWordArray DelArray; | 1920 CFX_DWordArray DelArray; |
| 1959 | 1921 |
| 1960 » for (int j=DelArray.GetSize()-1; j>=0; j--) | 1922 for (int j=DelArray.GetSize()-1; j>=0; j--) |
| 1961 » { | 1923 { |
| 1962 » » m_DelayData.RemoveAt(DelArray[j]); | 1924 m_DelayData.RemoveAt(DelArray[j]); |
| 1963 » } | 1925 } |
| 1964 } | 1926 } |
| 1965 | 1927 |
| 1966 CJS_Document* Document::GetCJSDoc() const | 1928 CJS_Document* Document::GetCJSDoc() const |
| 1967 { | 1929 { |
| 1968 » return static_cast<CJS_Document*>(m_pJSObject); | 1930 return static_cast<CJS_Document*>(m_pJSObject); |
| 1969 } | 1931 } |
| 1970 | |
| OLD | NEW |