CPDF_PageObject* CPDF_LayoutElement::GetObject(int index) { if(m_pTaggedElement == NULL) { return NULL; } CFX_PtrArray *pObj = &m_ObjArray; int size = pObj->GetSize(); if(index < size) { return (CPDF_PageObject*)pObj->GetAt(index); } return NULL; }
CBC_PDF417DetectorResult::~CBC_PDF417DetectorResult() { for (int32_t i = 0; i < m_points->GetSize(); i++) { CFX_PtrArray* temp = (CFX_PtrArray*)m_points->GetAt(i); for (int32_t j = 0; j < temp->GetSize(); j++) { delete (CBC_ResultPoint*)temp->GetAt(j); } temp->RemoveAll(); delete temp; } m_points->RemoveAll(); delete m_points; }
void CFWL_CheckBoxImp::NextStates() { FX_DWORD dwFirststate = m_pProperties->m_dwStates; if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_RadioButton) { if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == FWL_STATE_CKB_Unchecked) { CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); if (!pWidgetMgr->IsFormDisabled()) { CFX_PtrArray radioarr; pWidgetMgr->GetSameGroupRadioButton(m_pInterface, radioarr); IFWL_CheckBox* pCheckBox = NULL; int32_t iCount = radioarr.GetSize(); for (int32_t i = 0; i < iCount; i++) { pCheckBox = static_cast<IFWL_CheckBox*>(radioarr[i]); if (pCheckBox != m_pInterface && pCheckBox->GetStates() & FWL_STATE_CKB_Checked) { pCheckBox->SetCheckState(0); CFX_RectF rt; pCheckBox->GetWidgetRect(rt); rt.left = rt.top = 0; m_pWidgetMgr->RepaintWidget(pCheckBox, &rt); break; } } } m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked; } } else { if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == FWL_STATE_CKB_Neutral) { m_pProperties->m_dwStates &= ~FWL_STATE_CKB_CheckMask; if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) { m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked; } } else if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == FWL_STATE_CKB_Checked) { m_pProperties->m_dwStates &= ~FWL_STATE_CKB_CheckMask; } else { if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) { m_pProperties->m_dwStates |= FWL_STATE_CKB_Neutral; } else { m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked; } } } Repaint(&m_rtClient); FX_DWORD dwLaststate = m_pProperties->m_dwStates; if (dwFirststate != dwLaststate) { CFWL_EvtCkbCheckStateChanged wmCheckBoxState; wmCheckBoxState.m_pSrcTarget = m_pInterface; DispatchEvent(&wmCheckBoxState); } }
CBC_BarcodeMetadata* CBC_DetectionResultRowIndicatorColumn::getBarcodeMetadata() { CFX_PtrArray* codewords = getCodewords(); CBC_BarcodeValue barcodeColumnCount; CBC_BarcodeValue barcodeRowCountUpperPart; CBC_BarcodeValue barcodeRowCountLowerPart; CBC_BarcodeValue barcodeECLevel; for (int32_t i = 0; i < codewords->GetSize(); i++) { CBC_Codeword* codeword = (CBC_Codeword*)codewords->GetAt(i); if (codeword == NULL) { continue; } codeword->setRowNumberAsRowIndicatorColumn(); int32_t rowIndicatorValue = codeword->getValue() % 30; int32_t codewordRowNumber = codeword->getRowNumber(); if (!m_isLeft) { codewordRowNumber += 2; } switch (codewordRowNumber % 3) { case 0: barcodeRowCountUpperPart.setValue(rowIndicatorValue * 3 + 1); break; case 1: barcodeECLevel.setValue(rowIndicatorValue / 3); barcodeRowCountLowerPart.setValue(rowIndicatorValue % 3); break; case 2: barcodeColumnCount.setValue(rowIndicatorValue + 1); break; } } if ((barcodeColumnCount.getValue()->GetSize() == 0) || (barcodeRowCountUpperPart.getValue()->GetSize() == 0) || (barcodeRowCountLowerPart.getValue()->GetSize() == 0) || (barcodeECLevel.getValue()->GetSize() == 0) || barcodeColumnCount.getValue()->GetAt(0) < 1 || barcodeRowCountUpperPart.getValue()->GetAt(0) + barcodeRowCountLowerPart.getValue()->GetAt(0) < CBC_PDF417Common::MIN_ROWS_IN_BARCODE || barcodeRowCountUpperPart.getValue()->GetAt(0) + barcodeRowCountLowerPart.getValue()->GetAt(0) > CBC_PDF417Common::MAX_ROWS_IN_BARCODE) { return NULL; } CBC_BarcodeMetadata* barcodeMetadata = new CBC_BarcodeMetadata(barcodeColumnCount.getValue()->GetAt(0), barcodeRowCountUpperPart.getValue()->GetAt(0), barcodeRowCountLowerPart.getValue()->GetAt(0), barcodeECLevel.getValue()->GetAt(0)); removeIncorrectCodewords(codewords, *barcodeMetadata); return barcodeMetadata; }
int CountFields(int nLevel = 0) { if (nLevel > nMaxRecursion) { return 0; } if (field_ptr) { return 1; } int count = 0; for (int i = 0; i < children.GetSize(); i++) { count += ((_Node*)children.GetAt(i))->CountFields(nLevel + 1); } return count; }
v8::Handle<v8::Object> JS_GetStaticObj(IJS_Runtime* pJSRuntime, int nObjDefnID) { v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; v8::Isolate::Scope isolate_scope(isolate); CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0); if(!pArray) return v8::Handle<v8::Object>(); if(nObjDefnID<0 || nObjDefnID>= pArray->GetSize()) return v8::Handle<v8::Object>(); CJS_ObjDefintion* pObjDef = (CJS_ObjDefintion*)pArray->GetAt(nObjDefnID); v8::Local<v8::Object> obj = v8::Local<v8::Object>::New(isolate,pObjDef->m_StaticObj); return obj; }
FX_BOOL Document::removeField(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) { ASSERT(m_pDocument != NULL); if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM))) return FALSE; CJS_Context* pContext = (CJS_Context*)cc; if (params.size() != 1) { sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); return FALSE; } CFX_WideString sFieldName = params[0].ToCFXWideString(); CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); ASSERT(pInterForm != NULL); CFX_PtrArray widgets; pInterForm->GetWidgets(sFieldName, widgets); int nSize = widgets.GetSize(); if (nSize > 0) { for (int i=0; i<nSize; i++) { CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widgets[i]; ASSERT(pWidget != NULL); CPDF_Rect rcAnnot = pWidget->GetRect(); rcAnnot.left -= 1; rcAnnot.bottom -= 1; rcAnnot.right += 1; rcAnnot.top += 1; CFX_RectArray aRefresh; aRefresh.Add(rcAnnot); CPDF_Page* pPage = pWidget->GetPDFPage(); ASSERT(pPage != NULL); CPDFSDK_PageView* pPageView = m_pDocument->GetPageView(pPage); pPageView->DeleteAnnot(pWidget); pPageView->UpdateRects(aRefresh); } m_pDocument->SetChangeMark(); } return TRUE; }
void CFWL_GridImp::SetSpanAutoColRowSize(const CFX_PtrArray& spanAutos, FX_FLOAT fTotalSize) { int32_t iAutoColRows = spanAutos.GetSize(); if (iAutoColRows < 1) { return; } CFX_PtrArray autoNoMinMaxs; FX_FLOAT fAutoPer = fTotalSize / iAutoColRows; for (int32_t j = 0; j < iAutoColRows; j++) { CFWL_GridColRow* pColumn = static_cast<CFWL_GridColRow*>(spanAutos[j]); FX_FLOAT fOrgSize = pColumn->m_fActualSize; if (SetColRowActualSize(pColumn, pColumn->m_fActualSize + fAutoPer, TRUE)) { autoNoMinMaxs.Add(pColumn); } else { fTotalSize -= pColumn->m_fActualSize - fOrgSize; int32_t iNoMinMax = iAutoColRows - (j + 1 - autoNoMinMaxs.GetSize()); if (iNoMinMax > 0 && fTotalSize > 0) { fAutoPer = fTotalSize / iNoMinMax; } else { break; } } } int32_t iNormals = autoNoMinMaxs.GetSize(); if (fTotalSize > 0) { if (iNormals == iAutoColRows) { fAutoPer = fTotalSize / iNormals; for (int32_t k = 0; k < iNormals; k++) { CFWL_GridColRow* pColumn = static_cast<CFWL_GridColRow*>(autoNoMinMaxs[k]); pColumn->m_fActualSize += fAutoPer; } } else { SetSpanAutoColRowSize(autoNoMinMaxs, fTotalSize); } } else { } }
int JS_DefineObj(IJS_Runtime* pJSRuntime, const wchar_t* sObjName, FXJSOBJTYPE eObjType, LP_CONSTRUCTOR pConstructor, LP_DESTRUCTOR pDestructor, unsigned bApplyNew) { v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; v8::Isolate::Scope isolate_scope(isolate); v8::HandleScope handle_scope(isolate); CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0); if(!pArray) { pArray = new CFX_PtrArray(); isolate->SetData(0, pArray); } CJS_ObjDefintion* pObjDef = new CJS_ObjDefintion(isolate, sObjName, eObjType, pConstructor, pDestructor, bApplyNew); pArray->Add(pObjDef); return pArray->GetSize()-1; }
CFX_PtrArray* CBC_Detector::detect(FX_BOOL multiple, CBC_CommonBitMatrix* bitMatrix) { CFX_PtrArray* barcodeCoordinates = new CFX_PtrArray; int32_t row = 0; int32_t column = 0; FX_BOOL foundBarcodeInRow = FALSE; while (row < bitMatrix->GetHeight()) { CFX_PtrArray* vertices = findVertices(bitMatrix, row, column); if (vertices->GetAt(0) == NULL && vertices->GetAt(3) == NULL) { if (!foundBarcodeInRow) { if (vertices) { delete (vertices); } break; } foundBarcodeInRow = FALSE; column = 0; for (int32_t i = 0; i < barcodeCoordinates->GetSize(); i++) { CFX_PtrArray* barcodeCoordinate = (CFX_PtrArray*)barcodeCoordinates->GetAt(i); if (barcodeCoordinate->GetAt(1) != NULL) { row = row > ((CBC_ResultPoint*)barcodeCoordinate->GetAt(1))->GetY(); } if (barcodeCoordinate->GetAt(3) != NULL) { row = row > ((CBC_ResultPoint*)barcodeCoordinate->GetAt(3))->GetY(); } } row += ROW_STEP; if (vertices) { delete (vertices); } continue; } foundBarcodeInRow = TRUE; barcodeCoordinates->Add(vertices); if (!multiple) { break; } if (vertices->GetAt(2) != NULL) { column = (int32_t)((CBC_ResultPoint*)vertices->GetAt(2))->GetX(); row = (int32_t)((CBC_ResultPoint*)vertices->GetAt(2))->GetY(); } else { column = (int32_t)((CBC_ResultPoint*)vertices->GetAt(4))->GetX(); row = (int32_t)((CBC_ResultPoint*)vertices->GetAt(4))->GetY(); } } return barcodeCoordinates; }
void JS_InitialRuntime(IJS_Runtime* pJSRuntime,IFXJS_Runtime* pFXRuntime, IFXJS_Context* context, v8::Persistent<v8::Context>& v8PersistentContext) { v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; v8::Isolate::Scope isolate_scope(isolate); v8::HandleScope handle_scope(isolate); v8::Persistent<v8::ObjectTemplate>& globalObjTemp = _getGlobalObjectTemplate(pJSRuntime); v8::Handle<v8::Context> v8Context = v8::Context::New(isolate, NULL, v8::Local<v8::ObjectTemplate>::New(isolate, globalObjTemp)); v8::Context::Scope context_scope(v8Context); v8::Handle<v8::External> ptr = v8::External::New(isolate, pFXRuntime); v8Context->SetEmbedderData(1, ptr); CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0); if(!pArray) return; for(int i=0; i<pArray->GetSize(); i++) { CJS_ObjDefintion* pObjDef = (CJS_ObjDefintion*)pArray->GetAt(i); CFX_WideString ws = CFX_WideString(pObjDef->objName); CFX_ByteString bs = ws.UTF8Encode(); v8::Handle<v8::String> objName = v8::String::NewFromUtf8(isolate, bs.c_str(), v8::String::kNormalString, bs.GetLength()); if(pObjDef->objType == JS_DYNAMIC) { //Document is set as global object, need to construct it first. if(ws.Equal(L"Document")) { CJS_PrivateData* pPrivateData = new CJS_PrivateData; pPrivateData->ObjDefID = i; v8Context->Global()->GetPrototype()->ToObject()->SetAlignedPointerInInternalField(0, pPrivateData); if(pObjDef->m_pConstructor) pObjDef->m_pConstructor(context, v8Context->Global()->GetPrototype()->ToObject(), v8Context->Global()->GetPrototype()->ToObject()); } } else { v8::Handle<v8::Object> obj = JS_NewFxDynamicObj(pJSRuntime, context, i); v8Context->Global()->Set(objName, obj); pObjDef->m_StaticObj.Reset(isolate, obj); } } v8PersistentContext.Reset(isolate, v8Context); }
int JS_DefineObjAllProperties(IJS_Runtime* pJSRuntime, int nObjDefnID, v8::NamedPropertyQueryCallback pPropQurey, v8::NamedPropertyGetterCallback pPropGet, v8::NamedPropertySetterCallback pPropPut, v8::NamedPropertyDeleterCallback pPropDel) { v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; v8::Isolate::Scope isolate_scope(isolate); v8::HandleScope handle_scope(isolate); CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0); if(!pArray) return 0; if(nObjDefnID<0 || nObjDefnID>= pArray->GetSize()) return 0; CJS_ObjDefintion* pObjDef = (CJS_ObjDefintion*)pArray->GetAt(nObjDefnID); v8::Local<v8::ObjectTemplate> objTemp = v8::Local<v8::ObjectTemplate>::New(isolate, pObjDef->m_objTemplate); objTemp->SetNamedPropertyHandler(pPropGet, pPropPut, pPropQurey, pPropDel); pObjDef->m_objTemplate.Reset(isolate,objTemp); return 0; }
CPDF_Link CPDF_LinkList::GetLinkAtPoint(CPDF_Page* pPage, FX_FLOAT pdf_x, FX_FLOAT pdf_y) { CFX_PtrArray* pPageLinkList = GetPageLinks(pPage); if (pPageLinkList == NULL) { return NULL; } int size = pPageLinkList->GetSize(); for (int i = 0; i < size; i ++) { CPDF_Link Link = (CPDF_Dictionary*)pPageLinkList->GetAt(i); CPDF_Rect rect = Link.GetRect(); if (rect.Contains(pdf_x, pdf_y)) { return Link; } } return NULL; }
int JS_GetObjDefnID(IJS_Runtime * pJSRuntime, const wchar_t* pObjName) { v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; v8::Isolate::Scope isolate_scope(isolate); CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0); if(!pArray) return -1; for(int i=0; i<pArray->GetSize(); i++) { CJS_ObjDefintion* pObjDef = (CJS_ObjDefintion*)pArray->GetAt(i); if(FXSYS_wcscmp(pObjDef->objName, pObjName) == 0) return i; } return -1; }
CPDF_FormField* GetField(int* fields_to_go) { if (field_ptr) { if (*fields_to_go == 0) { return field_ptr; } --*fields_to_go; return NULL; } for (int i = 0; i < children.GetSize(); i++) { _Node* pNode = (_Node*)children.GetAt(i); CPDF_FormField* pField = pNode->GetField(fields_to_go); if (pField) { return pField; } } return NULL; }
static v8::Persistent<v8::ObjectTemplate>& _getGlobalObjectTemplate(IJS_Runtime* pJSRuntime) { v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; v8::Isolate::Scope isolate_scope(isolate); v8::HandleScope handle_scope(isolate); CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0); ASSERT(pArray != NULL); for(int i=0; i<pArray->GetSize(); i++) { CJS_ObjDefintion* pObjDef = (CJS_ObjDefintion*)pArray->GetAt(i); if(pObjDef->m_bSetAsGlobalObject) return pObjDef->m_objTemplate; } static v8::Persistent<v8::ObjectTemplate> gloabalObjectTemplate; return gloabalObjectTemplate; }
void CBC_DetectionResult::adjustRowNumbers(int32_t barcodeColumn, int32_t codewordsRow, CFX_PtrArray* codewords) { CBC_Codeword* codeword = (CBC_Codeword*)codewords->GetAt(codewordsRow); CFX_PtrArray* previousColumnCodewords = ((CBC_DetectionResultColumn*)m_detectionResultColumns.GetAt( barcodeColumn - 1)) ->getCodewords(); CFX_PtrArray* nextColumnCodewords = previousColumnCodewords; if (m_detectionResultColumns[barcodeColumn + 1]) { nextColumnCodewords = ((CBC_DetectionResultColumn*) m_detectionResultColumns[barcodeColumn + 1]) ->getCodewords(); } CFX_PtrArray otherCodewords; otherCodewords.SetSize(14); otherCodewords[2] = previousColumnCodewords->GetAt(codewordsRow); otherCodewords[3] = nextColumnCodewords->GetAt(codewordsRow); if (codewordsRow > 0) { otherCodewords[0] = codewords->GetAt(codewordsRow - 1); otherCodewords[4] = previousColumnCodewords->GetAt(codewordsRow - 1); otherCodewords[5] = nextColumnCodewords->GetAt(codewordsRow - 1); } if (codewordsRow > 1) { otherCodewords[8] = codewords->GetAt(codewordsRow - 2); otherCodewords[10] = previousColumnCodewords->GetAt(codewordsRow - 2); otherCodewords[11] = nextColumnCodewords->GetAt(codewordsRow - 2); } if (codewordsRow < codewords->GetSize() - 1) { otherCodewords[1] = codewords->GetAt(codewordsRow + 1); otherCodewords[6] = previousColumnCodewords->GetAt(codewordsRow + 1); otherCodewords[7] = nextColumnCodewords->GetAt(codewordsRow + 1); } if (codewordsRow < codewords->GetSize() - 2) { otherCodewords[9] = codewords->GetAt(codewordsRow + 2); otherCodewords[12] = previousColumnCodewords->GetAt(codewordsRow + 2); otherCodewords[13] = nextColumnCodewords->GetAt(codewordsRow + 2); } for (int32_t i = 0; i < otherCodewords.GetSize(); i++) { CBC_Codeword* otherCodeword = (CBC_Codeword*)otherCodewords.GetAt(i); if (adjustRowNumber(codeword, otherCodeword)) { return; } } }
static int InsertDeletePDFPage(CPDF_Document* pDoc, CPDF_Dictionary* pPages, int nPagesToGo, CPDF_Dictionary* pPage, FX_BOOL bInsert, CFX_PtrArray& stackList) { CPDF_Array* pKidList = pPages->GetArray("Kids"); if (!pKidList) { return -1; } int nKids = pKidList->GetCount(); for (int i = 0; i < nKids; i ++) { CPDF_Dictionary* pKid = pKidList->GetDict(i); if (pKid->GetString("Type") == FX_BSTRC("Page")) { if (nPagesToGo == 0) { if (bInsert) { pKidList->InsertAt(i, CPDF_Reference::Create(pDoc, pPage->GetObjNum())); pPage->SetAtReference("Parent", pDoc, pPages->GetObjNum()); } else { pKidList->RemoveAt(i); } pPages->SetAtInteger("Count", pPages->GetInteger("Count") + (bInsert ? 1 : -1)); return 1; } nPagesToGo --; } else { int nPages = pKid->GetInteger("Count"); if (nPagesToGo < nPages) { int stackCount = stackList.GetSize(); for (int j = 0; j < stackCount; ++j) { if (pKid == stackList[j]) { return -1; } } stackList.Add(pKid); if (InsertDeletePDFPage(pDoc, pKid, nPagesToGo, pPage, bInsert, stackList) < 0) { return -1; } stackList.RemoveAt(stackCount); pPages->SetAtInteger("Count", pPages->GetInteger("Count") + (bInsert ? 1 : -1)); return 1; } nPagesToGo -= nPages; } } return 0; }
int JS_DefineObjConst(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sConstName, v8::Handle<v8::Value> pDefault) { v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; v8::Isolate::Scope isolate_scope(isolate); v8::HandleScope handle_scope(isolate); CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0); if(!pArray) return 0; CFX_WideString ws = CFX_WideString(sConstName); CFX_ByteString bsConstName = ws.UTF8Encode(); if(nObjDefnID<0 || nObjDefnID>= pArray->GetSize()) return 0; CJS_ObjDefintion* pObjDef = (CJS_ObjDefintion*)pArray->GetAt(nObjDefnID); v8::Local<v8::ObjectTemplate> objTemp = v8::Local<v8::ObjectTemplate>::New(isolate, pObjDef->m_objTemplate); objTemp->Set(isolate, FX_LPCSTR(bsConstName), pDefault); pObjDef->m_objTemplate.Reset(isolate,objTemp); return 0; }
int JS_DefineObjMethod(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sMethodName, v8::FunctionCallback pMethodCall) { v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; v8::Isolate::Scope isolate_scope(isolate); v8::HandleScope handle_scope(isolate); CFX_WideString ws = CFX_WideString(sMethodName); CFX_ByteString bsMethodName = ws.UTF8Encode(); CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0); if(!pArray) return 0; if(nObjDefnID<0 || nObjDefnID>= pArray->GetSize()) return 0; CJS_ObjDefintion* pObjDef = (CJS_ObjDefintion*)pArray->GetAt(nObjDefnID); v8::Local<v8::ObjectTemplate> objTemp = v8::Local<v8::ObjectTemplate>::New(isolate, pObjDef->m_objTemplate); objTemp->Set(v8::String::NewFromUtf8(isolate, FX_LPCSTR(bsMethodName)), v8::FunctionTemplate::New(isolate, pMethodCall), v8::ReadOnly); pObjDef->m_objTemplate.Reset(isolate,objTemp); return 0; }
int JS_DefineObjProperty(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sPropName, v8::AccessorGetterCallback pPropGet, v8::AccessorSetterCallback pPropPut) { v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; v8::Isolate::Scope isolate_scope(isolate); v8::HandleScope handle_scope(isolate); CFX_WideString ws = CFX_WideString(sPropName); CFX_ByteString bsPropertyName = ws.UTF8Encode(); CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0); if(!pArray) return 0; if(nObjDefnID<0 || nObjDefnID>= pArray->GetSize()) return 0; CJS_ObjDefintion* pObjDef = (CJS_ObjDefintion*)pArray->GetAt(nObjDefnID); v8::Local<v8::ObjectTemplate> objTemp = v8::Local<v8::ObjectTemplate>::New(isolate, pObjDef->m_objTemplate); objTemp->SetAccessor(v8::String::NewFromUtf8(isolate, FX_LPCSTR(bsPropertyName)), pPropGet, pPropPut); pObjDef->m_objTemplate.Reset(isolate,objTemp); return 0; }
FPDF_BOOL _FPDF_Doc_Save(FPDF_DOCUMENT document, FPDF_FILEWRITE* pFileWrite, FPDF_DWORD flags, FPDF_BOOL bSetVersion, int fileVerion) { CPDF_Document* pPDFDoc = CPDFDocumentFromFPDFDocument(document); if (!pPDFDoc) return 0; #ifdef PDF_ENABLE_XFA CPDFXFA_Document* pDoc = (CPDFXFA_Document*)document; CFX_PtrArray fileList; _SendPreSaveToXFADoc(pDoc, fileList); #endif // PDF_ENABLE_XFA if (flags < FPDF_INCREMENTAL || flags > FPDF_REMOVE_SECURITY) { flags = 0; } CPDF_Creator FileMaker(pPDFDoc); if (bSetVersion) FileMaker.SetFileVersion(fileVerion); if (flags == FPDF_REMOVE_SECURITY) { flags = 0; FileMaker.RemoveSecurity(); } CFX_IFileWrite* pStreamWrite = NULL; FX_BOOL bRet; pStreamWrite = new CFX_IFileWrite; pStreamWrite->Init(pFileWrite); bRet = FileMaker.Create(pStreamWrite, flags); #ifdef PDF_ENABLE_XFA _SendPostSaveToXFADoc(pDoc); for (int i = 0; i < fileList.GetSize(); i++) { IFX_FileStream* pFile = (IFX_FileStream*)fileList.GetAt(i); pFile->Release(); } fileList.RemoveAll(); #endif // PDF_ENABLE_XFA pStreamWrite->Release(); return bRet; }
int32_t CBC_DetectionResult::adjustRowNumbersFromBothRI() { if (m_detectionResultColumns[0] == NULL || m_detectionResultColumns[m_barcodeColumnCount + 1] == NULL) { return 0; } CFX_PtrArray* LRIcodewords = ((CBC_DetectionResultColumn*)m_detectionResultColumns[0])->getCodewords(); CFX_PtrArray* RRIcodewords = ((CBC_DetectionResultColumn*) m_detectionResultColumns[m_barcodeColumnCount + 1]) ->getCodewords(); for (int32_t codewordsRow = 0; codewordsRow < LRIcodewords->GetSize(); codewordsRow++) { if (LRIcodewords->GetAt(codewordsRow) && RRIcodewords->GetAt(codewordsRow) && ((CBC_Codeword*)LRIcodewords->GetAt(codewordsRow))->getRowNumber() == ((CBC_Codeword*)RRIcodewords->GetAt(codewordsRow)) ->getRowNumber()) { for (int32_t barcodeColumn = 1; barcodeColumn <= m_barcodeColumnCount; barcodeColumn++) { CBC_Codeword* codeword = (CBC_Codeword*)((CBC_DetectionResultColumn*) m_detectionResultColumns[barcodeColumn]) ->getCodewords() ->GetAt(codewordsRow); if (codeword == NULL) { continue; } codeword->setRowNumber( ((CBC_Codeword*)LRIcodewords->GetAt(codewordsRow))->getRowNumber()); if (!codeword->hasValidRowNumber()) { ((CBC_DetectionResultColumn*)m_detectionResultColumns[barcodeColumn]) ->getCodewords() ->SetAt(codewordsRow, NULL); } } } } return 0; }
int32_t CXFA_FMProgram::ParseProgram() { CFX_PtrArray* expressions = 0; m_parse.NextToken(); if (!m_pErrorInfo.message.IsEmpty()) { return -1; } expressions = m_parse.ParseTopExpression(); if (!m_pErrorInfo.message.IsEmpty()) { CXFA_FMExpression* e = 0; for (int32_t u = 0; u < expressions->GetSize(); ++u) { e = (CXFA_FMExpression*)expressions->GetAt(u); if (e) { delete e; } } delete expressions; return -1; } m_globalFunction = new CXFA_FMFunctionDefinition(1, 1, FX_WSTRC(L""), 0, expressions); return 0; }
int32_t CBC_DetectionResult::adjustRowNumbers() { int32_t unadjustedCount = adjustRowNumbersByRow(); if (unadjustedCount == 0) { return 0; } for (int32_t barcodeColumn = 1; barcodeColumn < m_barcodeColumnCount + 1; barcodeColumn++) { CFX_PtrArray* codewords = ((CBC_DetectionResultColumn*)m_detectionResultColumns[barcodeColumn]) ->getCodewords(); for (int32_t codewordsRow = 0; codewordsRow < codewords->GetSize(); codewordsRow++) { if (codewords->GetAt(codewordsRow) == NULL) { continue; } if (!((CBC_Codeword*)codewords->GetAt(codewordsRow)) ->hasValidRowNumber()) { adjustRowNumbers(barcodeColumn, codewordsRow, codewords); } } } return unadjustedCount; }
int32_t CBC_DetectionResult::adjustRowNumbersFromRRI() { if (m_detectionResultColumns[m_barcodeColumnCount + 1] == NULL) { return 0; } int32_t unadjustedCount = 0; CFX_PtrArray* codewords = ((CBC_DetectionResultColumn*)m_detectionResultColumns.GetAt( m_barcodeColumnCount + 1)) ->getCodewords(); for (int32_t codewordsRow = 0; codewordsRow < codewords->GetSize(); codewordsRow++) { if (codewords->GetAt(codewordsRow) == NULL) { continue; } int32_t rowIndicatorRowNumber = ((CBC_Codeword*)codewords->GetAt(codewordsRow))->getRowNumber(); int32_t invalidRowCounts = 0; for (int32_t barcodeColumn = m_barcodeColumnCount + 1; barcodeColumn > 0 && invalidRowCounts < ADJUST_ROW_NUMBER_SKIP; barcodeColumn--) { CBC_Codeword* codeword = (CBC_Codeword*)((CBC_DetectionResultColumn*) m_detectionResultColumns.GetAt(barcodeColumn)) ->getCodewords() ->GetAt(codewordsRow); if (codeword) { invalidRowCounts = adjustRowNumberIfValid(rowIndicatorRowNumber, invalidRowCounts, codeword); if (!codeword->hasValidRowNumber()) { unadjustedCount++; } } } } return unadjustedCount; }
CFX_WideString CBC_HighLevelEncoder::encodeHighLevel(CFX_WideString msg, CFX_WideString ecLevel, SymbolShapeHint shape, CBC_Dimension* minSize, CBC_Dimension* maxSize, int32_t& e) { CBC_EncoderContext context(msg, ecLevel, e); BC_EXCEPTION_CHECK_ReturnValue(e, (FX_WCHAR*)""); context.setSymbolShape(shape); context.setSizeConstraints(minSize, maxSize); if ((msg.Mid(0, 6) == MACRO_05_HEADER) && (msg.Mid(msg.GetLength() - 1, 1) == MACRO_TRAILER)) { context.writeCodeword(MACRO_05); context.setSkipAtEnd(2); context.m_pos += 6; } else if ((msg.Mid(0, 6) == MACRO_06_HEADER) && (msg.Mid(msg.GetLength() - 1, 1) == MACRO_TRAILER)) { context.writeCodeword(MACRO_06); context.setSkipAtEnd(2); context.m_pos += 6; } CFX_PtrArray encoders; encoders.Add(new CBC_ASCIIEncoder()); encoders.Add(new CBC_C40Encoder()); encoders.Add(new CBC_TextEncoder()); encoders.Add(new CBC_X12Encoder()); encoders.Add(new CBC_EdifactEncoder()); encoders.Add(new CBC_Base256Encoder()); int32_t encodingMode = ASCII_ENCODATION; while (context.hasMoreCharacters()) { ((CBC_Encoder*)encoders.GetAt(encodingMode))->Encode(context, e); if (e != BCExceptionNO) { for (int32_t i = 0; i < encoders.GetSize(); i++) { delete (CBC_Encoder*)encoders.GetAt(i); } encoders.RemoveAll(); return (FX_WCHAR*)""; } if (context.m_newEncoding >= 0) { encodingMode = context.m_newEncoding; context.resetEncoderSignal(); } } int32_t len = context.m_codewords.GetLength(); context.updateSymbolInfo(e); if (e != BCExceptionNO) { for (int32_t i = 0; i < encoders.GetSize(); i++) { delete (CBC_Encoder*)encoders.GetAt(i); } encoders.RemoveAll(); return (FX_WCHAR*)""; } int32_t capacity = context.m_symbolInfo->m_dataCapacity; if (len < capacity) { if (encodingMode != ASCII_ENCODATION && encodingMode != BASE256_ENCODATION) { context.writeCodeword(0x00fe); } } CFX_WideString codewords = context.m_codewords; if (codewords.GetLength() < capacity) { codewords += PAD; } while (codewords.GetLength() < capacity) { codewords += (randomize253State(PAD, codewords.GetLength() + 1)); } for (int32_t i = 0; i < encoders.GetSize(); i++) { delete (CBC_Encoder*)encoders.GetAt(i); } encoders.RemoveAll(); return codewords; }
FX_FLOAT CFWL_GridImp::ProcessUnCertainRows() { int32_t iRows = m_Rows.GetSize(); if (iRows < 1) { CFWL_GridColRow* pColRow = new CFWL_GridColRow; pColRow->m_Size.eUnit = FWL_GRIDUNIT_Auto; ProcAutoColRow(pColRow, 0, FALSE); FX_FLOAT fWidth = pColRow->m_fActualSize; delete pColRow; return fWidth; } FX_FLOAT fFixedHeight = 0; CFX_PtrArray autoRows; CFX_PtrArray scaledRows; FX_FLOAT fScaledRowNum = 0; FX_FLOAT fScaledMaxPerHeight = 0; for (int32_t i = 0; i < iRows; i++) { CFWL_GridColRow* pColRow = static_cast<CFWL_GridColRow*>(m_Rows[i]); if (!pColRow) { continue; } switch (pColRow->m_Size.eUnit) { case FWL_GRIDUNIT_Fixed: { SetColRowActualSize(pColRow, pColRow->m_Size.fLength); fFixedHeight += pColRow->m_fActualSize; break; } case FWL_GRIDUNIT_Auto: { ProcAutoColRow(pColRow, i, FALSE); autoRows.Add(pColRow); break; } case FWL_GRIDUNIT_Scaled: default: { ProcAutoColRow(pColRow, i, FALSE); fScaledRowNum += pColRow->m_Size.fLength; scaledRows.Add(pColRow); if (pColRow->m_Size.fLength > 0) { FX_FLOAT fPerHeight = pColRow->m_fActualSize / pColRow->m_Size.fLength; if (fPerHeight > fScaledMaxPerHeight) { fScaledMaxPerHeight = fPerHeight; } } break; } } } iRows = scaledRows.GetSize(); for (int32_t j = 0; j < iRows; j++) { CFWL_GridColRow* pColRow = static_cast<CFWL_GridColRow*>(scaledRows[j]); if (!pColRow) { continue; } SetColRowActualSize(pColRow, fScaledMaxPerHeight * pColRow->m_Size.fLength); } FX_POSITION ps = m_mapWidgetInfo.GetStartPosition(); while (ps) { void* key = nullptr; void* value = nullptr; m_mapWidgetInfo.GetNextAssoc(ps, key, value); IFWL_Widget* pWidget = static_cast<IFWL_Widget*>(key); CFWL_GridWidgetInfo* pInfo = static_cast<CFWL_GridWidgetInfo*>(value); if (pInfo->m_iRowSpan < 2) { continue; } CFX_PtrArray spanAutoRows; CFX_PtrArray spanScaledRows; FX_FLOAT fSpanSize = 0; FX_FLOAT fScaledSum = 0; int32_t iAutoColRows = 0; int32_t iScaledColRows = 0; for (int32_t i = 0; i < pInfo->m_iRowSpan; i++) { CFWL_GridColRow* pRow = reinterpret_cast<CFWL_GridColRow*>( GetColRow(FALSE, pInfo->m_iRow + i)); if (!pRow) { break; } fSpanSize += pRow->m_fActualSize; if (pRow->m_Size.eUnit == FWL_GRIDUNIT_Auto) { iAutoColRows++; spanAutoRows.Add(pRow); } else if (pRow->m_Size.eUnit == FWL_GRIDUNIT_Scaled) { iScaledColRows++; fScaledSum += pRow->m_Size.fLength; spanScaledRows.Add(pRow); } } if (iAutoColRows < 1 && iScaledColRows < 1) { continue; } FX_FLOAT fWidgetHeight = CalcAutoColumnWidgetHeight(pWidget, pInfo); if (fWidgetHeight > fSpanSize) { if (iScaledColRows > 0) { if (fScaledSum <= 0) { continue; } SetSpanScaledColRowSize(spanScaledRows, fWidgetHeight - fSpanSize, fScaledSum); } else { SetSpanAutoColRowSize(spanAutoRows, fWidgetHeight - fSpanSize); } } } FX_FLOAT fAutoHeigt = 0; int32_t iAutoRows = autoRows.GetSize(); for (int32_t m = 0; m < iAutoRows; m++) { fAutoHeigt += static_cast<CFWL_GridColRow*>(autoRows[m])->m_fActualSize; } FX_FLOAT fScaledHeight = 0; iRows = scaledRows.GetSize(); for (int32_t n = 0; n < iRows; n++) { fScaledHeight += static_cast<CFWL_GridColRow*>(scaledRows[n])->m_fActualSize; } return fFixedHeight + fAutoHeigt + fScaledHeight; }
FX_FLOAT CFWL_GridImp::ProcessUnCertainColumns() { int32_t iColumns = m_Columns.GetSize(); if (iColumns < 1) { CFWL_GridColRow* pColRow = new CFWL_GridColRow; pColRow->m_Size.eUnit = FWL_GRIDUNIT_Auto; ProcAutoColRow(pColRow, 0, TRUE); FX_FLOAT fWidth = pColRow->m_fActualSize; delete pColRow; return fWidth; } FX_FLOAT fFixedWidth = 0; CFX_PtrArray autoColumns; CFX_PtrArray scaledColumns; FX_FLOAT fScaledColumnNum = 0; FX_FLOAT fScaledMaxPerWidth = 0; for (int32_t i = 0; i < iColumns; i++) { CFWL_GridColRow* pColRow = reinterpret_cast<CFWL_GridColRow*>(m_Columns[i]); if (!pColRow) { continue; } switch (pColRow->m_Size.eUnit) { case FWL_GRIDUNIT_Fixed: { SetColRowActualSize(pColRow, pColRow->m_Size.fLength); fFixedWidth += pColRow->m_fActualSize; break; } case FWL_GRIDUNIT_Auto: { ProcAutoColRow(pColRow, i, TRUE); autoColumns.Add(pColRow); break; } case FWL_GRIDUNIT_Scaled: default: { ProcAutoColRow(pColRow, i, TRUE); fScaledColumnNum += pColRow->m_Size.fLength; scaledColumns.Add(pColRow); if (pColRow->m_Size.fLength <= 0) { break; } FX_FLOAT fPerWidth = pColRow->m_fActualSize / pColRow->m_Size.fLength; if (fPerWidth > fScaledMaxPerWidth) { fScaledMaxPerWidth = fPerWidth; } } } } iColumns = scaledColumns.GetSize(); for (int32_t j = 0; j < iColumns; j++) { CFWL_GridColRow* pColRow = static_cast<CFWL_GridColRow*>(scaledColumns[j]); if (!pColRow) { continue; } SetColRowActualSize(pColRow, fScaledMaxPerWidth * pColRow->m_Size.fLength); } FX_POSITION ps = m_mapWidgetInfo.GetStartPosition(); while (ps) { IFWL_Widget* pWidget = NULL; CFWL_GridWidgetInfo* pInfo = NULL; m_mapWidgetInfo.GetNextAssoc(ps, (void*&)pWidget, (void*&)pInfo); if (!pInfo || pInfo->m_iColumnSpan < 2) { continue; } CFX_PtrArray spanAutoColumns; CFX_PtrArray spanScaledColumns; FX_FLOAT fSpanSize = 0; FX_FLOAT fScaledSum = 0; int32_t iAutoColRows = 0; int32_t iScaledColRows = 0; for (int32_t i = 0; i < pInfo->m_iColumnSpan; i++) { CFWL_GridColRow* pColumn = reinterpret_cast<CFWL_GridColRow*>( GetColRow(TRUE, pInfo->m_iColumn + i)); if (!pColumn) { break; } fSpanSize += pColumn->m_fActualSize; if (pColumn->m_Size.eUnit == FWL_GRIDUNIT_Auto) { iAutoColRows++; spanAutoColumns.Add(pColumn); } else if (pColumn->m_Size.eUnit == FWL_GRIDUNIT_Scaled) { iScaledColRows++; fScaledSum += pColumn->m_Size.fLength; spanScaledColumns.Add(pColumn); } } if (iAutoColRows < 1 && iScaledColRows < 1) { continue; } FX_FLOAT fWidgetWidth = CalcAutoColumnWidgetWidth(pWidget, pInfo); if (fWidgetWidth > fSpanSize) { if (iScaledColRows > 0) { if (fScaledSum <= 0) { continue; } SetSpanScaledColRowSize(spanScaledColumns, fWidgetWidth - fSpanSize, fScaledSum); } else { SetSpanAutoColRowSize(spanAutoColumns, fWidgetWidth - fSpanSize); } } } FX_FLOAT fAutoWidth = 0; int32_t iAutoCols = autoColumns.GetSize(); for (int32_t m = 0; m < iAutoCols; m++) { fAutoWidth += static_cast<CFWL_GridColRow*>(autoColumns[m])->m_fActualSize; } FX_FLOAT fScaledWidth = 0; iColumns = scaledColumns.GetSize(); for (int32_t n = 0; n < iColumns; n++) { fScaledWidth += static_cast<CFWL_GridColRow*>(scaledColumns[n])->m_fActualSize; } return fFixedWidth + fAutoWidth + fScaledWidth; }
FX_FLOAT CFWL_GridImp::ProcessRows(FX_FLOAT fHeight) { if (fHeight <= 0) { return ProcessUnCertainRows(); } int32_t iRows = m_Rows.GetSize(); if (iRows < 1) { return fHeight; } FX_FLOAT fFixedHeight = 0; FX_FLOAT fAutoHeigt = 0; CFX_PtrArray autoRows; CFX_PtrArray scaledRows; FX_FLOAT fScaledRowNum = 0; for (int32_t i = 0; i < iRows; i++) { CFWL_GridColRow* pColRow = static_cast<CFWL_GridColRow*>(m_Rows[i]); if (!pColRow) { continue; } switch (pColRow->m_Size.eUnit) { case FWL_GRIDUNIT_Fixed: { SetColRowActualSize(pColRow, pColRow->m_Size.fLength); fFixedHeight += pColRow->m_fActualSize; break; } case FWL_GRIDUNIT_Auto: { ProcAutoColRow(pColRow, i, FALSE); autoRows.Add(pColRow); break; } case FWL_GRIDUNIT_Scaled: default: { fScaledRowNum += pColRow->m_Size.fLength; scaledRows.Add(pColRow); SetColRowActualSize(pColRow, 0); break; } } } FX_POSITION ps = m_mapWidgetInfo.GetStartPosition(); while (ps) { IFWL_Widget* pWidget = NULL; CFWL_GridWidgetInfo* pInfo = NULL; m_mapWidgetInfo.GetNextAssoc(ps, (void*&)pWidget, (void*&)pInfo); if (!pInfo || pInfo->m_iRowSpan < 2) { continue; } CFX_PtrArray spanAutoRows; FX_FLOAT fSpanSize = 0; int32_t iAutoColRows = 0; int32_t iScaledColRows = 0; for (int32_t i = 0; i < pInfo->m_iRowSpan; i++) { CFWL_GridColRow* pRow = reinterpret_cast<CFWL_GridColRow*>( GetColRow(FALSE, pInfo->m_iRow + i)); if (!pRow) { break; } fSpanSize += pRow->m_fActualSize; if (pRow->m_Size.eUnit == FWL_GRIDUNIT_Auto) { iAutoColRows++; spanAutoRows.Add(pRow); } else if (pRow->m_Size.eUnit == FWL_GRIDUNIT_Scaled) { iScaledColRows++; } } if (iAutoColRows < 1) { continue; } FX_FLOAT fWidgetHeight = CalcAutoColumnWidgetHeight(pWidget, pInfo); if (fWidgetHeight > fSpanSize) { if (iScaledColRows > 0) { } else { SetSpanAutoColRowSize(spanAutoRows, fWidgetHeight - fSpanSize); } } } int32_t iAutoRows = autoRows.GetSize(); for (int32_t k = 0; k < iAutoRows; k++) { fAutoHeigt += reinterpret_cast<CFWL_GridColRow*>(autoRows[k])->m_fActualSize; } FX_FLOAT fScaledHeight = fHeight - fFixedHeight - fAutoHeigt; if (fScaledHeight > 0 && fScaledRowNum > 0) { SetScaledColRowsSize(scaledRows, fScaledHeight, fScaledRowNum); } return fHeight; }