v8::Handle<v8::Object> JS_NewFxDynamicObj(IJS_Runtime* pJSRuntime, IFXJS_Context* pJSContext, int nObjDefnID) { v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; v8::Isolate::Scope isolate_scope(isolate); if(-1 == nObjDefnID) { v8::Local<v8::ObjectTemplate> objTempl = v8::ObjectTemplate::New(isolate); return objTempl->NewInstance(); } 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::Context> context = isolate->GetCurrentContext(); v8::Local<v8::ObjectTemplate> objTemp = v8::Local<v8::ObjectTemplate>::New(isolate, pObjDef->m_objTemplate); v8::Local<v8::Object> obj = objTemp->NewInstance(); CJS_PrivateData* pPrivateData = new CJS_PrivateData; pPrivateData->ObjDefID = nObjDefnID; obj->SetAlignedPointerInInternalField(0, pPrivateData); if(pObjDef->m_pConstructor) pObjDef->m_pConstructor(pJSContext, obj, context->Global()->GetPrototype()->ToObject()); return obj; }
FX_BOOL CPDF_PSProc::Parse(CPDF_SimpleParser& parser) { while (1) { CFX_ByteStringC word = parser.GetWord(); if (word.IsEmpty()) { return FALSE; } if (word == FX_BSTRC("}")) { return TRUE; } if (word == FX_BSTRC("{")) { CPDF_PSProc* pProc = FX_NEW CPDF_PSProc; m_Operators.Add((FX_LPVOID)PSOP_PROC); m_Operators.Add(pProc); if (!pProc->Parse(parser)) { return FALSE; } } else { int i = 0; while (_PDF_PSOpNames[i].name) { if (word == CFX_ByteStringC(_PDF_PSOpNames[i].name)) { m_Operators.Add((FX_LPVOID)_PDF_PSOpNames[i].op); break; } i ++; } if (_PDF_PSOpNames[i].name == NULL) { FX_FLOAT* pd = FX_Alloc(FX_FLOAT, 1); *pd = FX_atof(word); m_Operators.Add((FX_LPVOID)PSOP_CONST); m_Operators.Add(pd); } } } }
int32_t CBC_OnedCode128Writer::Encode128C(const CFX_ByteString& contents, CFX_PtrArray& patterns) { int32_t checkSum = 0; int32_t checkWeight = 1; int32_t position = 0; patterns.Add((int32_t*)CBC_OnedCode128Reader::CODE_PATTERNS[CODE_START_C]); checkSum += CODE_START_C * checkWeight; while (position < contents.GetLength()) { int32_t patternIndex = 0; FX_CHAR ch = contents.GetAt(position); if (ch < '0' || ch > '9') { patternIndex = (int32_t)ch; position++; } else { patternIndex = FXSYS_atoi(contents.Mid(position, 2)); if (contents.GetAt(position + 1) < '0' || contents.GetAt(position + 1) > '9') { position += 1; } else { position += 2; } } patterns.Add((int32_t*)CBC_OnedCode128Reader::CODE_PATTERNS[patternIndex]); checkSum += patternIndex * checkWeight; if (position != 0) { checkWeight++; } } return checkSum; }
static int InsertNewPage(CPDF_Document* pDoc, int iPage, CPDF_Dictionary* pPageDict, CFX_DWordArray &pageList) { CPDF_Dictionary* pRoot = pDoc->GetRoot(); if (!pRoot) { return -1; } CPDF_Dictionary* pPages = pRoot->GetDict(FX_BSTRC("Pages")); if (!pPages) { return -1; } int nPages = pDoc->GetPageCount(); if (iPage < 0 || iPage > nPages) { return -1; } if (iPage == nPages) { CPDF_Array* pPagesList = pPages->GetArray(FX_BSTRC("Kids")); if (!pPagesList) { pPagesList = FX_NEW CPDF_Array; pPages->SetAt(FX_BSTRC("Kids"), pPagesList); } pPagesList->Add(pPageDict, pDoc); pPages->SetAtInteger(FX_BSTRC("Count"), nPages + 1); pPageDict->SetAtReference(FX_BSTRC("Parent"), pDoc, pPages->GetObjNum()); } else { CFX_PtrArray stack; stack.Add(pPages); if (InsertDeletePDFPage(pDoc, pPages, iPage, pPageDict, TRUE, stack) < 0) { return -1; } } pageList.InsertAt(iPage, pPageDict->GetObjNum()); return iPage; }
int32_t CBC_DetectionResult::adjustRowNumbersFromLRI() { if (m_detectionResultColumns[0] == NULL) { return 0; } int32_t unadjustedCount = 0; CFX_PtrArray* codewords = ((CBC_DetectionResultColumn*)m_detectionResultColumns.GetAt(0)) ->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 = 1; barcodeColumn < m_barcodeColumnCount + 1 && invalidRowCounts < ADJUST_ROW_NUMBER_SKIP; barcodeColumn++) { CBC_Codeword* codeword = (CBC_Codeword*)((CBC_DetectionResultColumn*) m_detectionResultColumns[barcodeColumn]) ->getCodewords() ->GetAt(codewordsRow); if (codeword) { invalidRowCounts = adjustRowNumberIfValid(rowIndicatorRowNumber, invalidRowCounts, codeword); if (!codeword->hasValidRowNumber()) { unadjustedCount++; } } } } return unadjustedCount; }
CFX_ByteString CBC_PDF417Reader::Decode(CBC_BinaryBitmap* image, FX_BOOL multiple, int32_t hints, int32_t& e) { CFX_ByteString results; CBC_PDF417DetectorResult* detectorResult = CBC_Detector::detect(image, hints, multiple, e); BC_EXCEPTION_CHECK_ReturnValue(e, ""); for (int32_t i = 0; i < detectorResult->getPoints()->GetSize(); i++) { CFX_PtrArray* points = (CFX_PtrArray*)detectorResult->getPoints()->GetAt(i); CBC_CommonDecoderResult* ResultTemp = CBC_PDF417ScanningDecoder::decode( detectorResult->getBits(), (CBC_ResultPoint*)points->GetAt(4), (CBC_ResultPoint*)points->GetAt(5), (CBC_ResultPoint*)points->GetAt(6), (CBC_ResultPoint*)points->GetAt(7), getMinCodewordWidth(*points), getMaxCodewordWidth(*points), e); if (ResultTemp == NULL) { delete detectorResult; e = BCExceptiontNotFoundInstance; return ""; } results += ResultTemp->GetText(); delete ResultTemp; } delete detectorResult; return results; }
void JS_ReleaseRuntime(IJS_Runtime* pJSRuntime, v8::Persistent<v8::Context>& v8PersistentContext) { v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; v8::Isolate::Scope isolate_scope(isolate); v8::HandleScope handle_scope(isolate); v8::Local<v8::Context> context = v8::Local<v8::Context>::New(isolate, v8PersistentContext); v8::Context::Scope context_scope(context); 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); if(!pObjDef->m_StaticObj.IsEmpty()) { v8::Local<v8::Object> pObj = v8::Local<v8::Object>::New(isolate, pObjDef->m_StaticObj); if(pObjDef->m_pDestructor) pObjDef->m_pDestructor(pObj); JS_FreePrivate(pObj); } delete pObjDef; } delete pArray; isolate->SetData(0,NULL); }
FX_BOOL Document::resetForm(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) || m_pDocument->GetPermissions(FPDFPERM_FILL_FORM))) return FALSE; CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); ASSERT(pInterForm != NULL); CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); ASSERT(pPDFForm != NULL); v8::Isolate* isolate = GetIsolate(cc); CJS_Array aName(isolate); if (params.size() > 0) { switch (params[0].GetType()) { default: aName.Attach(params[0].ToV8Array()); break; case VT_string: aName.SetElement(0,params[0]); break; } CFX_PtrArray aFields; for (int i=0,isz=aName.GetLength(); i<isz; i++) { CJS_Value valElement(isolate); aName.GetElement(i,valElement); CFX_WideString swVal = valElement.ToCFXWideString(); for (int j=0,jsz=pPDFForm->CountFields(swVal); j<jsz; j++) { aFields.Add((void*)pPDFForm->GetField(j,swVal)); } } if (aFields.GetSize() > 0) { pPDFForm->ResetForm(aFields, TRUE, TRUE); m_pDocument->SetChangeMark(); } } else { pPDFForm->ResetForm(TRUE); m_pDocument->SetChangeMark(); } return TRUE; }
int CPDF_LinkList::CountLinks(CPDF_Page* pPage) { CFX_PtrArray* pPageLinkList = GetPageLinks(pPage); if (pPageLinkList == NULL) { return 0; } return pPageLinkList->GetSize(); }
CPDF_Link CPDF_LinkList::GetLink(CPDF_Page* pPage, int index) { CFX_PtrArray* pPageLinkList = GetPageLinks(pPage); if (pPageLinkList == NULL) { return NULL; } return (CPDF_Dictionary*)pPageLinkList->GetAt(index); }
int CPDF_LayoutElement::CountObjects() { if(m_pTaggedElement == NULL) { return 0; } CFX_PtrArray* pObj = &m_ObjArray; int size = pObj->GetSize(); return size; }
CFX_PtrArray* CBC_Detector::findVertices(CBC_CommonBitMatrix* matrix, int32_t startRow, int32_t startColumn) { int32_t height = matrix->GetHeight(); int32_t width = matrix->GetWidth(); CFX_PtrArray* result = new CFX_PtrArray; result->SetSize(8); CFX_PtrArray* startptr = findRowsWithPattern( matrix, height, width, startRow, startColumn, START_PATTERN, sizeof(START_PATTERN) / sizeof(START_PATTERN[0])); copyToResult( result, startptr, INDEXES_START_PATTERN, sizeof(INDEXES_START_PATTERN) / sizeof(INDEXES_START_PATTERN[0])); startptr->RemoveAll(); delete startptr; if (result->GetAt(4) != NULL) { startColumn = (int32_t)((CBC_ResultPoint*)result->GetAt(4))->GetX(); startRow = (int32_t)((CBC_ResultPoint*)result->GetAt(4))->GetY(); } CFX_PtrArray* stopptr = findRowsWithPattern( matrix, height, width, startRow, startColumn, STOP_PATTERN, sizeof(STOP_PATTERN) / sizeof(STOP_PATTERN[0])); copyToResult(result, stopptr, INDEXES_STOP_PATTERN, sizeof(INDEXES_STOP_PATTERN) / sizeof(INDEXES_STOP_PATTERN[0])); stopptr->RemoveAll(); delete stopptr; return result; }
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_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; }
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_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; }
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; }
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; }
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; }
CBC_CommonDecoderResult* CBC_DataMatrixDecoder::Decode( CBC_CommonBitMatrix* bits, int32_t& e) { CBC_DataMatrixBitMatrixParser parser; parser.Init(bits, e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); CBC_DataMatrixVersion* version = parser.GetVersion(); CFX_ByteArray* byteTemp = parser.ReadCodewords(e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); CBC_AutoPtr<CFX_ByteArray> codewords(byteTemp); CFX_PtrArray* dataBlocks = CBC_DataMatrixDataBlock::GetDataBlocks(codewords.get(), version, e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); int32_t dataBlocksCount = dataBlocks->GetSize(); int32_t totalBytes = 0; int32_t i, j; for (i = 0; i < dataBlocksCount; i++) { totalBytes += ((CBC_DataMatrixDataBlock*)(*dataBlocks)[i])->GetNumDataCodewords(); } CFX_ByteArray resultBytes; resultBytes.SetSize(totalBytes); for (j = 0; j < dataBlocksCount; j++) { CFX_ByteArray* codewordBytes = ((CBC_DataMatrixDataBlock*)(*dataBlocks)[j])->GetCodewords(); int32_t numDataCodewords = ((CBC_DataMatrixDataBlock*)(*dataBlocks)[j])->GetNumDataCodewords(); CorrectErrors(*codewordBytes, numDataCodewords, e); if (e != BCExceptionNO) { for (int32_t i = 0; i < dataBlocks->GetSize(); i++) { delete (CBC_DataMatrixDataBlock*)(*dataBlocks)[i]; } delete dataBlocks; dataBlocks = NULL; return NULL; } int32_t i; for (i = 0; i < numDataCodewords; i++) { resultBytes[i * dataBlocksCount + j] = (*codewordBytes)[i]; } } for (i = 0; i < (dataBlocks->GetSize()); i++) { delete (CBC_DataMatrixDataBlock*)(*dataBlocks)[i]; } delete dataBlocks; dataBlocks = NULL; CBC_CommonDecoderResult* resultR = CBC_DataMatrixDecodedBitStreamParser::Decode(resultBytes, e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); return resultR; }
int32_t CBC_DetectionResultRowIndicatorColumn::adjustCompleteIndicatorColumnRowNumbers( CBC_BarcodeMetadata barcodeMetadata) { CFX_PtrArray* codewords = getCodewords(); setRowNumbers(); removeIncorrectCodewords(codewords, barcodeMetadata); CBC_BoundingBox* boundingBox = getBoundingBox(); CBC_ResultPoint* top = m_isLeft ? boundingBox->getTopLeft() : boundingBox->getTopRight(); CBC_ResultPoint* bottom = m_isLeft ? boundingBox->getBottomLeft() : boundingBox->getBottomRight(); int32_t firstRow = imageRowToCodewordIndex((int32_t)top->GetY()); int32_t lastRow = imageRowToCodewordIndex((int32_t)bottom->GetY()); FX_FLOAT averageRowHeight = (lastRow - firstRow) / (FX_FLOAT)barcodeMetadata.getRowCount(); int32_t barcodeRow = -1; int32_t maxRowHeight = 1; int32_t currentRowHeight = 0; for (int32_t codewordsRow = firstRow; codewordsRow < lastRow; codewordsRow++) { if (codewords->GetAt(codewordsRow) == NULL) { continue; } CBC_Codeword* codeword = (CBC_Codeword*)codewords->GetAt(codewordsRow); int32_t rowDifference = codeword->getRowNumber() - barcodeRow; if (rowDifference == 0) { currentRowHeight++; } else if (rowDifference == 1) { maxRowHeight = maxRowHeight > currentRowHeight ? maxRowHeight : currentRowHeight; currentRowHeight = 1; barcodeRow = codeword->getRowNumber(); } else if (rowDifference < 0) { codewords->SetAt(codewordsRow, NULL); } else if (codeword->getRowNumber() >= barcodeMetadata.getRowCount()) { codewords->SetAt(codewordsRow, NULL); } else if (rowDifference > codewordsRow) { codewords->SetAt(codewordsRow, NULL); } else { int32_t checkedRows; if (maxRowHeight > 2) { checkedRows = (maxRowHeight - 2) * rowDifference; } else { checkedRows = rowDifference; } FX_BOOL closePreviousCodewordFound = checkedRows >= codewordsRow; for (int32_t i = 1; i <= checkedRows && !closePreviousCodewordFound; i++) { closePreviousCodewordFound = codewords->GetAt(codewordsRow - i) != NULL; } if (closePreviousCodewordFound) { codewords->SetAt(codewordsRow, NULL); } else { barcodeRow = codeword->getRowNumber(); currentRowHeight = 1; } } } return (int32_t)(averageRowHeight + 0.5); }
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; }
void CFWL_GridImp::SetScaledColRowsSize(const CFX_PtrArray& spanScaleds, FX_FLOAT fTotalSize, FX_FLOAT fTotalScaledNum) { int32_t iScaledColRows = spanScaleds.GetSize(); if (iScaledColRows < 1) { return; } CFX_PtrArray autoNoMinMaxs; FX_FLOAT fPerSize = fTotalSize / fTotalScaledNum; for (int32_t i = 0; i < iScaledColRows; i++) { CFWL_GridColRow* pColRow = static_cast<CFWL_GridColRow*>(spanScaleds[i]); if (!pColRow) { continue; } FX_FLOAT fSize = fPerSize * pColRow->m_Size.fLength; FX_FLOAT fOrgSize = pColRow->m_fActualSize; if (SetColRowActualSize(pColRow, fSize, TRUE)) { autoNoMinMaxs.Add(pColRow); } else { fTotalSize -= pColRow->m_fActualSize - fOrgSize; fTotalScaledNum -= pColRow->m_Size.fLength; int32_t iNoMinMax = iScaledColRows - (i + 1 - autoNoMinMaxs.GetSize()); if (iNoMinMax > 0 && fTotalSize > 0) { fPerSize = fTotalSize / fTotalScaledNum; } else { break; } } } int32_t iNormals = autoNoMinMaxs.GetSize(); if (fTotalSize > 0) { if (iNormals == iScaledColRows) { fPerSize = fTotalSize / fTotalScaledNum; for (int32_t i = 0; i < iNormals; i++) { CFWL_GridColRow* pColRow = static_cast<CFWL_GridColRow*>(autoNoMinMaxs[i]); if (!pColRow) { continue; } FX_FLOAT fSize = fPerSize * pColRow->m_Size.fLength; pColRow->m_fActualSize = fSize; } } else { SetScaledColRowsSize(autoNoMinMaxs, fTotalSize, fTotalScaledNum); } } else { } }
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); }
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; }
FX_BOOL CPDF_PSProc::Execute(CPDF_PSEngine* pEngine) { int size = m_Operators.GetSize(); for (int i = 0; i < size; i ++) { PDF_PSOP op = (PDF_PSOP)(FX_UINTPTR)m_Operators[i]; if (op == PSOP_PROC) { i ++; } else if (op == PSOP_CONST) { pEngine->Push(*(FX_FLOAT*)m_Operators[i + 1]); i ++; } else if (op == PSOP_IF) { if (i < 2 || m_Operators[i - 2] != (FX_LPVOID)PSOP_PROC) { return FALSE; } if ((int)pEngine->Pop()) { ((CPDF_PSProc*)m_Operators[i - 1])->Execute(pEngine); } } else if (op == PSOP_IFELSE) { if (i < 4 || m_Operators[i - 2] != (FX_LPVOID)PSOP_PROC || m_Operators[i - 4] != (FX_LPVOID)PSOP_PROC) { return FALSE; } if ((int)pEngine->Pop()) { ((CPDF_PSProc*)m_Operators[i - 3])->Execute(pEngine); } else { ((CPDF_PSProc*)m_Operators[i - 1])->Execute(pEngine); } } else { pEngine->DoOperator(op); } } return TRUE; }
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; }
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; }
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; }
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; }