diff options
Diffstat (limited to 'core/src/fpdfdoc')
-rw-r--r-- | core/src/fpdfdoc/doc_action.cpp | 27 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_ap.cpp | 14 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_basic.cpp | 11 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_form.cpp | 208 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_formcontrol.cpp | 33 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_formfield.cpp | 5 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_metadata.cpp | 16 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_ocg.cpp | 11 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_utils.cpp | 8 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_vt.cpp | 120 |
10 files changed, 239 insertions, 214 deletions
diff --git a/core/src/fpdfdoc/doc_action.cpp b/core/src/fpdfdoc/doc_action.cpp index 851b2d6709..da2e05af2e 100644 --- a/core/src/fpdfdoc/doc_action.cpp +++ b/core/src/fpdfdoc/doc_action.cpp @@ -112,11 +112,9 @@ FX_DWORD CPDF_ActionFields::GetFieldsCount() const int iType = pFields->GetType(); if (iType == PDFOBJ_DICTIONARY) { return 1; - } - if (iType == PDFOBJ_STRING) { + } else if (iType == PDFOBJ_STRING) { return 1; - } - if (iType == PDFOBJ_ARRAY) { + } else if (iType == PDFOBJ_ARRAY) { return ((CPDF_Array*)pFields)->GetCount(); } return 0; @@ -209,17 +207,16 @@ CFX_WideString CPDF_Action::GetJavaScript() const } CPDF_Dictionary* CPDF_Action::GetAnnot() const { - if (!m_pDict) { - return nullptr; + if (m_pDict == NULL) { + return NULL; } CFX_ByteString csType = m_pDict->GetString("S"); if (csType == FX_BSTRC("Rendition")) { return m_pDict->GetDict("AN"); - } - if (csType == FX_BSTRC("Movie")) { + } else if (csType == FX_BSTRC("Movie")) { return m_pDict->GetDict("Annotation"); } - return nullptr; + return NULL; } int32_t CPDF_Action::GetOperationType() const { @@ -229,19 +226,15 @@ int32_t CPDF_Action::GetOperationType() const CFX_ByteString csType = m_pDict->GetString("S"); if (csType == FX_BSTRC("Rendition")) { return m_pDict->GetInteger("OP"); - } - if (csType == FX_BSTRC("Movie")) { + } else if (csType == FX_BSTRC("Movie")) { CFX_ByteString csOP = m_pDict->GetString("Operation"); if (csOP == FX_BSTRC("Play")) { return 0; - } - if (csOP == FX_BSTRC("Stop")) { + } else if (csOP == FX_BSTRC("Stop")) { return 1; - } - if (csOP == FX_BSTRC("Pause")) { + } else if (csOP == FX_BSTRC("Pause")) { return 2; - } - if (csOP == FX_BSTRC("Resume")) { + } else if (csOP == FX_BSTRC("Resume")) { return 3; } } diff --git a/core/src/fpdfdoc/doc_ap.cpp b/core/src/fpdfdoc/doc_ap.cpp index f94a4d60e0..2d991b39c2 100644 --- a/core/src/fpdfdoc/doc_ap.cpp +++ b/core/src/fpdfdoc/doc_ap.cpp @@ -17,13 +17,13 @@ FX_BOOL FPDF_GenerateAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict) FX_DWORD flags = FPDF_GetFieldAttr(pAnnotDict, "Ff")? FPDF_GetFieldAttr(pAnnotDict, "Ff")->GetInteger() : 0; if (field_type == "Tx") { return CPVT_GenerateAP::GenerateTextFieldAP(pDoc, pAnnotDict); - } - if (field_type == "Ch") { - return (flags & (1 << 17)) ? - CPVT_GenerateAP::GenerateComboBoxAP(pDoc, pAnnotDict) : - CPVT_GenerateAP::GenerateListBoxAP(pDoc, pAnnotDict); - } - if (field_type == "Btn") { + } else if (field_type == "Ch") { + if (flags & (1 << 17)) { + return CPVT_GenerateAP::GenerateComboBoxAP(pDoc, pAnnotDict); + } else { + return CPVT_GenerateAP::GenerateListBoxAP(pDoc, pAnnotDict); + } + } else if (field_type == "Btn") { if (!(flags & (1 << 16))) { if (!pAnnotDict->KeyExist("AS")) { if (CPDF_Dictionary* pParentDict = pAnnotDict->GetDict("Parent")) { diff --git a/core/src/fpdfdoc/doc_basic.cpp b/core/src/fpdfdoc/doc_basic.cpp index 3ba109b016..9d31d15624 100644 --- a/core/src/fpdfdoc/doc_basic.cpp +++ b/core/src/fpdfdoc/doc_basic.cpp @@ -148,12 +148,13 @@ static CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode, int nIndex, int& nCur if (nIndex >= nCurIndex + nCount) { nCurIndex += nCount; return NULL; + } else { + if (ppFind != NULL) { + *ppFind = pNames; + } + csName = pNames->GetString((nIndex - nCurIndex) * 2); + return pNames->GetElementValue((nIndex - nCurIndex) * 2 + 1); } - if (ppFind != NULL) { - *ppFind = pNames; - } - csName = pNames->GetString((nIndex - nCurIndex) * 2); - return pNames->GetElementValue((nIndex - nCurIndex) * 2 + 1); } CPDF_Array* pKids = pNode->GetArray(FX_BSTRC("Kids")); if (pKids == NULL) { diff --git a/core/src/fpdfdoc/doc_form.cpp b/core/src/fpdfdoc/doc_form.cpp index 735231cc1d..2b59bee6ee 100644 --- a/core/src/fpdfdoc/doc_form.cpp +++ b/core/src/fpdfdoc/doc_form.cpp @@ -354,11 +354,12 @@ static int CALLBACK EnumFontFamExProc( ENUMLOGFONTEXA *lpelfe, { if (FontType != 0x004 || strchr(lpelfe->elfLogFont.lfFaceName, '@') != NULL) { return 1; + } else { + LPDF_FONTDATA pData = (LPDF_FONTDATA)lParam; + memcpy(&pData->lf, &lpelfe->elfLogFont, sizeof(LOGFONTA)); + pData->bFind = TRUE; + return 0; } - LPDF_FONTDATA pData = (LPDF_FONTDATA)lParam; - memcpy(&pData->lf, &lpelfe->elfLogFont, sizeof(LOGFONTA)); - pData->bFind = TRUE; - return 0; } static FX_BOOL RetrieveSpecificFont(LOGFONTA& lf) { @@ -696,39 +697,41 @@ int CPDF_InterForm::CompareFieldName(const CFX_ByteString& name1, const CFX_Byte { const FX_CHAR* ptr1 = name1; const FX_CHAR* ptr2 = name2; - if (name1.GetLength() == name2.GetLength()) { + if (name1.GetLength() != name2.GetLength()) { + int i = 0; + while (ptr1[i] == ptr2[i]) { + i ++; + } + if (i == name1.GetLength()) { + return 2; + } + if (i == name2.GetLength()) { + return 3; + } + return 0; + } else { return name1 == name2 ? 1 : 0; } - int i = 0; - while (ptr1[i] == ptr2[i]) { - i ++; - } - if (i == name1.GetLength()) { - return 2; - } - if (i == name2.GetLength()) { - return 3; - } - return 0; } int CPDF_InterForm::CompareFieldName(const CFX_WideString& name1, const CFX_WideString& name2) { const FX_WCHAR* ptr1 = name1.c_str(); const FX_WCHAR* ptr2 = name2.c_str(); - if (name1.GetLength() == name2.GetLength()) { + if (name1.GetLength() != name2.GetLength()) { + int i = 0; + while (ptr1[i] == ptr2[i]) { + i ++; + } + if (i == name1.GetLength()) { + return 2; + } + if (i == name2.GetLength()) { + return 3; + } + return 0; + } else { return name1 == name2 ? 1 : 0; } - int i = 0; - while (ptr1[i] == ptr2[i]) { - i ++; - } - if (i == name1.GetLength()) { - return 2; - } - if (i == name2.GetLength()) { - return 3; - } - return 0; } FX_DWORD CPDF_InterForm::CountFields(const CFX_WideString &csFieldName) { @@ -897,104 +900,115 @@ CPDF_FormControl* CPDF_InterForm::GetControlByDict(CPDF_Dictionary* pWidgetDict) } FX_DWORD CPDF_InterForm::CountInternalFields(const CFX_WideString& csFieldName) const { - if (!m_pFormDict) { + if (m_pFormDict == NULL) { return 0; } CPDF_Array* pArray = m_pFormDict->GetArray("Fields"); - if (!pArray) { + if (pArray == NULL) { return 0; } if (csFieldName.IsEmpty()) { return pArray->GetCount(); - } - int iLength = csFieldName.GetLength(); - int iPos = 0; - CPDF_Dictionary* pDict = NULL; - while (pArray != NULL) { - CFX_WideString csSub; - if (iPos < iLength && csFieldName[iPos] == L'.') { - iPos ++; - } - while (iPos < iLength && csFieldName[iPos] != L'.') { - csSub += csFieldName[iPos ++]; - } - int iCount = pArray->GetCount(); - FX_BOOL bFind = FALSE; - for (int i = 0; i < iCount; i ++) { - pDict = pArray->GetDict(i); - if (pDict == NULL) { - continue; + } else { + int iLength = csFieldName.GetLength(); + int iPos = 0; + CPDF_Dictionary* pDict = NULL; + while (pArray != NULL) { + CFX_WideString csSub; + if (iPos < iLength && csFieldName[iPos] == L'.') { + iPos ++; } - CFX_WideString csT = pDict->GetUnicodeText("T"); - if (csT == csSub) { - bFind = TRUE; + while (iPos < iLength && csFieldName[iPos] != L'.') { + csSub += csFieldName[iPos ++]; + } + int iCount = pArray->GetCount(); + FX_BOOL bFind = FALSE; + for (int i = 0; i < iCount; i ++) { + pDict = pArray->GetDict(i); + if (pDict == NULL) { + continue; + } + CFX_WideString csT = pDict->GetUnicodeText("T"); + if (csT == csSub) { + bFind = TRUE; + break; + } + } + if (!bFind) { + return 0; + } + if (iPos >= iLength) { break; } + pArray = pDict->GetArray("Kids"); } - if (!bFind) { + if (pDict == NULL) { return 0; + } else { + pArray = pDict->GetArray("Kids"); + if (pArray == NULL) { + return 1; + } else { + return pArray->GetCount(); + } } - if (iPos >= iLength) { - break; - } - pArray = pDict->GetArray("Kids"); - } - if (!pDict) { - return 0; } - pArray = pDict->GetArray("Kids"); - return pArray ? pArray->GetCount() : 1; } - CPDF_Dictionary* CPDF_InterForm::GetInternalField(FX_DWORD index, const CFX_WideString& csFieldName) const { - if (!m_pFormDict) { - return nullptr; + if (m_pFormDict == NULL) { + return NULL; } CPDF_Array* pArray = m_pFormDict->GetArray("Fields"); - if (!pArray) { - return nullptr; + if (pArray == NULL) { + return 0; } if (csFieldName.IsEmpty()) { return pArray->GetDict(index); - } - int iLength = csFieldName.GetLength(); - int iPos = 0; - CPDF_Dictionary* pDict = NULL; - while (pArray != NULL) { - CFX_WideString csSub; - if (iPos < iLength && csFieldName[iPos] == L'.') { - iPos ++; - } - while (iPos < iLength && csFieldName[iPos] != L'.') { - csSub += csFieldName[iPos ++]; - } - int iCount = pArray->GetCount(); - FX_BOOL bFind = FALSE; - for (int i = 0; i < iCount; i ++) { - pDict = pArray->GetDict(i); - if (pDict == NULL) { - continue; + } else { + int iLength = csFieldName.GetLength(); + int iPos = 0; + CPDF_Dictionary* pDict = NULL; + while (pArray != NULL) { + CFX_WideString csSub; + if (iPos < iLength && csFieldName[iPos] == L'.') { + iPos ++; } - CFX_WideString csT = pDict->GetUnicodeText("T"); - if (csT == csSub) { - bFind = TRUE; + while (iPos < iLength && csFieldName[iPos] != L'.') { + csSub += csFieldName[iPos ++]; + } + int iCount = pArray->GetCount(); + FX_BOOL bFind = FALSE; + for (int i = 0; i < iCount; i ++) { + pDict = pArray->GetDict(i); + if (pDict == NULL) { + continue; + } + CFX_WideString csT = pDict->GetUnicodeText("T"); + if (csT == csSub) { + bFind = TRUE; + break; + } + } + if (!bFind) { + return NULL; + } + if (iPos >= iLength) { break; } + pArray = pDict->GetArray("Kids"); } - if (!bFind) { + if (pDict == NULL) { return NULL; + } else { + pArray = pDict->GetArray("Kids"); + if (pArray == NULL) { + return pDict; + } else { + return pArray->GetDict(index); + } } - if (iPos >= iLength) { - break; - } - pArray = pDict->GetArray("Kids"); - } - if (!pDict) { - return nullptr; } - pArray = pDict->GetArray("Kids"); - return pArray ? pArray->GetDict(index) : pDict; } FX_BOOL CPDF_InterForm::NeedConstructAP() { diff --git a/core/src/fpdfdoc/doc_formcontrol.cpp b/core/src/fpdfdoc/doc_formcontrol.cpp index 87eee92c2e..7fa17b8ffa 100644 --- a/core/src/fpdfdoc/doc_formcontrol.cpp +++ b/core/src/fpdfdoc/doc_formcontrol.cpp @@ -262,27 +262,29 @@ CPDF_Action CPDF_FormControl::GetAction() } CPDF_AAction CPDF_FormControl::GetAdditionalAction() { - if (!m_pWidgetDict) { - return nullptr; + if (m_pWidgetDict == NULL) { + return NULL; } if (m_pWidgetDict->KeyExist("AA")) { return m_pWidgetDict->GetDict("AA"); + } else { + return m_pField->GetAdditionalAction(); } - return m_pField->GetAdditionalAction(); } CPDF_DefaultAppearance CPDF_FormControl::GetDefaultAppearance() { - if (!m_pWidgetDict) { + if (m_pWidgetDict == NULL) { return CFX_ByteString(); } if (m_pWidgetDict->KeyExist("DA")) { return m_pWidgetDict->GetString("DA"); + } else { + CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "DA"); + if (pObj == NULL) { + return m_pField->m_pForm->GetDefaultAppearance(); + } + return pObj->GetString(); } - CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "DA"); - if (!pObj) { - return m_pField->m_pForm->GetDefaultAppearance(); - } - return pObj->GetString(); } CPDF_Font* CPDF_FormControl::GetDefaultControlFont() @@ -331,17 +333,18 @@ CPDF_Font* CPDF_FormControl::GetDefaultControlFont() int CPDF_FormControl::GetControlAlignment() { - if (!m_pWidgetDict) { + if (m_pWidgetDict == NULL) { return 0; } if (m_pWidgetDict->KeyExist("Q")) { return m_pWidgetDict->GetInteger("Q", 0); + } else { + CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "Q"); + if (pObj == NULL) { + return m_pField->m_pForm->GetFormAlignment(); + } + return pObj->GetInteger(); } - CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "Q"); - if (pObj == NULL) { - return m_pField->m_pForm->GetFormAlignment(); - } - return pObj->GetInteger(); } FX_BOOL CPDF_ApSettings::HasMKEntry(const CFX_ByteStringC& csEntry) { diff --git a/core/src/fpdfdoc/doc_formfield.cpp b/core/src/fpdfdoc/doc_formfield.cpp index 087eba8aa4..d1acab8e81 100644 --- a/core/src/fpdfdoc/doc_formfield.cpp +++ b/core/src/fpdfdoc/doc_formfield.cpp @@ -472,15 +472,14 @@ int CPDF_FormField::GetSelectedIndex(int index) return -1; } } - if (pValue->GetType() == PDFOBJ_NUMBER) { - return pValue->GetInteger(); - } CFX_WideString sel_value; if (pValue->GetType() == PDFOBJ_STRING) { if (index != 0) { return -1; } sel_value = pValue->GetUnicodeText(); + } else if (pValue->GetType() == PDFOBJ_NUMBER) { + return pValue->GetInteger(); } else { if (pValue->GetType() != PDFOBJ_ARRAY) { return -1; diff --git a/core/src/fpdfdoc/doc_metadata.cpp b/core/src/fpdfdoc/doc_metadata.cpp index aeeb1d1f60..211bc25329 100644 --- a/core/src/fpdfdoc/doc_metadata.cpp +++ b/core/src/fpdfdoc/doc_metadata.cpp @@ -112,8 +112,7 @@ int32_t CPDF_Metadata::GetString(const CFX_ByteStringC& bsItem, CFX_WideString & } wsStr = pElmnt->GetContent(0); return wsStr.GetLength(); - } - if (bsItem == FX_BSTRC("Author")) { + } else if (bsItem == FX_BSTRC("Author")) { CXML_Element *pElmnt = pTag->GetElement(NULL, bsTag); if (!pElmnt) { continue; @@ -128,13 +127,14 @@ int32_t CPDF_Metadata::GetString(const CFX_ByteStringC& bsItem, CFX_WideString & } wsStr = pElmnt->GetContent(0); return wsStr.GetLength(); + } else { + CXML_Element *pElmnt = pTag->GetElement(NULL, bsTag); + if (!pElmnt) { + continue; + } + wsStr = pElmnt->GetContent(0); + return wsStr.GetLength(); } - CXML_Element *pElmnt = pTag->GetElement(NULL, bsTag); - if (!pElmnt) { - continue; - } - wsStr = pElmnt->GetContent(0); - return wsStr.GetLength(); } return -1; } diff --git a/core/src/fpdfdoc/doc_ocg.cpp b/core/src/fpdfdoc/doc_ocg.cpp index d525227219..8477cb85d0 100644 --- a/core/src/fpdfdoc/doc_ocg.cpp +++ b/core/src/fpdfdoc/doc_ocg.cpp @@ -207,11 +207,11 @@ FX_BOOL CPDF_OCContext::GetOCGVE(CPDF_Array *pExpression, FX_BOOL bFromConfig, i } if (pOCGObj->GetType() == PDFOBJ_DICTIONARY) { return !(bFromConfig ? LoadOCGState((CPDF_Dictionary*)pOCGObj) : GetOCGVisible((CPDF_Dictionary*)pOCGObj)); - } - if (pOCGObj->GetType() == PDFOBJ_ARRAY) { + } else if (pOCGObj->GetType() == PDFOBJ_ARRAY) { return !GetOCGVE((CPDF_Array*)pOCGObj, bFromConfig, nLevel + 1); + } else { + return FALSE; } - return FALSE; } if (csOperator == FX_BSTRC("Or") || csOperator == FX_BSTRC("And")) { FX_BOOL bValue = FALSE; @@ -286,14 +286,15 @@ FX_BOOL CPDF_OCContext::LoadOCMDState(const CPDF_Dictionary *pOCMDDict, FX_BOOL } FX_BOOL CPDF_OCContext::CheckOCGVisible(const CPDF_Dictionary *pOCGDict) { - if (!pOCGDict) { + if (pOCGDict == NULL) { return TRUE; } CFX_ByteString csType = pOCGDict->GetString(FX_BSTRC("Type"), FX_BSTRC("OCG")); if (csType == FX_BSTRC("OCG")) { return GetOCGVisible(pOCGDict); + } else { + return LoadOCMDState(pOCGDict, FALSE); } - return LoadOCMDState(pOCGDict, FALSE); } void CPDF_OCContext::ResetOCContext() { diff --git a/core/src/fpdfdoc/doc_utils.cpp b/core/src/fpdfdoc/doc_utils.cpp index 96d2ccf689..10ca14697d 100644 --- a/core/src/fpdfdoc/doc_utils.cpp +++ b/core/src/fpdfdoc/doc_utils.cpp @@ -655,17 +655,15 @@ CPDF_Font* GetDefaultInterFormFont(CPDF_Dictionary* pFormDict, CPDF_Document* pD } CPDF_IconFit::ScaleMethod CPDF_IconFit::GetScaleMethod() { - if (!m_pDict) { + if (m_pDict == NULL) { return Always; } CFX_ByteString csSW = m_pDict->GetString("SW", "A"); if (csSW == "B") { return Bigger; - } - if (csSW == "S") { + } else if (csSW == "S") { return Smaller; - } - if (csSW == "N") { + } else if (csSW == "N") { return Never; } return Always; diff --git a/core/src/fpdfdoc/doc_vt.cpp b/core/src/fpdfdoc/doc_vt.cpp index 230ba764e4..c6fdf0e3e7 100644 --- a/core/src/fpdfdoc/doc_vt.cpp +++ b/core/src/fpdfdoc/doc_vt.cpp @@ -95,8 +95,9 @@ CPVT_FloatRect CSection::Rearrange() ASSERT(m_pVT != NULL); if (m_pVT->m_nCharArray > 0) { return CTypeset(this).CharArray(); + } else { + return CTypeset(this).Typeset(); } - return CTypeset(this).Typeset(); } CPVT_Size CSection::GetSectionSize(FX_FLOAT fFontSize) { @@ -106,15 +107,17 @@ CPVT_WordPlace CSection::GetBeginWordPlace() const { if (CLine * pLine = m_LineArray.GetAt(0)) { return pLine->GetBeginWordPlace(); + } else { + return SecPlace; } - return SecPlace; } CPVT_WordPlace CSection::GetEndWordPlace() const { if (CLine * pLine = m_LineArray.GetAt(m_LineArray.GetSize() - 1)) { return pLine->GetEndWordPlace(); + } else { + return SecPlace; } - return SecPlace; } CPVT_WordPlace CSection::GetPrevWordPlace(const CPVT_WordPlace & place) const { @@ -127,8 +130,7 @@ CPVT_WordPlace CSection::GetPrevWordPlace(const CPVT_WordPlace & place) const if (CLine * pLine = m_LineArray.GetAt(place.nLineIndex)) { if (place.nWordIndex == pLine->m_LineInfo.nBeginWordIndex) { return CPVT_WordPlace(place.nSecIndex, place.nLineIndex, -1); - } - if (place.nWordIndex < pLine->m_LineInfo.nBeginWordIndex) { + } else if (place.nWordIndex < pLine->m_LineInfo.nBeginWordIndex) { if (CLine * pPrevLine = m_LineArray.GetAt(place.nLineIndex - 1)) { return pPrevLine->GetEndWordPlace(); } @@ -569,23 +571,17 @@ static FX_BOOL NeedDivision(FX_WORD prevWord, FX_WORD curWord) { if ((IsLatin(prevWord) || IsDigit(prevWord)) && (IsLatin(curWord) || IsDigit(curWord))) { return FALSE; - } - if (IsSpace(curWord) || IsPunctuation(curWord)) { + } else if (IsSpace(curWord) || IsPunctuation(curWord)) { return FALSE; - } - if (IsConnectiveSymbol(prevWord) || IsConnectiveSymbol(curWord)) { + } else if (IsConnectiveSymbol(prevWord) || IsConnectiveSymbol(curWord)) { return FALSE; - } - if (IsSpace(prevWord) || IsPunctuation(prevWord)) { + } else if (IsSpace(prevWord) || IsPunctuation(prevWord)) { return TRUE; - } - if (IsPrefixSymbol(prevWord)) { + } else if (IsPrefixSymbol(prevWord)) { return FALSE; - } - if (IsPrefixSymbol(curWord) || IsCJK(curWord)) { + } else if (IsPrefixSymbol(curWord) || IsCJK(curWord)) { return TRUE; - } - if (IsCJK(prevWord)) { + } else if (IsCJK(prevWord)) { return TRUE; } return FALSE; @@ -872,9 +868,11 @@ CPVT_WordPlace CPDF_VariableText::InsertWord(const CPVT_WordPlace & place, FX_WO CPVT_WordProps * pNewProps = pWordProps ? new CPVT_WordProps(*pWordProps) : new CPVT_WordProps(); pNewProps->nFontIndex = GetWordFontIndex(word, charset, pWordProps->nFontIndex); return AddWord(newplace, CPVT_WordInfo(word, charset, -1, pNewProps)); + } else { + int32_t nFontIndex = GetSubWord() > 0 ? GetDefaultFontIndex() : GetWordFontIndex(word, charset, GetDefaultFontIndex()); + return AddWord(newplace, CPVT_WordInfo(word, charset, nFontIndex, NULL)); } - int32_t nFontIndex = GetSubWord() > 0 ? GetDefaultFontIndex() : GetWordFontIndex(word, charset, GetDefaultFontIndex()); - return AddWord(newplace, CPVT_WordInfo(word, charset, nFontIndex, NULL)); + return place; } CPVT_WordPlace CPDF_VariableText::InsertSection(const CPVT_WordPlace & place, const CPVT_SecProps * pSecProps, const CPVT_WordProps * pWordProps) @@ -1122,10 +1120,12 @@ CPVT_WordPlace CPDF_VariableText::GetPrevWordPlace(const CPVT_WordPlace & place) if (place.WordCmp(pSection->GetBeginWordPlace()) <= 0) { if (CSection * pPrevSection = m_SectionArray.GetAt(place.nSecIndex - 1)) { return pPrevSection->GetEndWordPlace(); + } else { + return GetBeginWordPlace(); } - return GetBeginWordPlace(); + } else { + return pSection->GetPrevWordPlace(place); } - return pSection->GetPrevWordPlace(place); } return place; } @@ -1141,10 +1141,12 @@ CPVT_WordPlace CPDF_VariableText::GetNextWordPlace(const CPVT_WordPlace & place) if (place.WordCmp(pSection->GetEndWordPlace()) >= 0) { if (CSection * pNextSection = m_SectionArray.GetAt(place.nSecIndex + 1)) { return pNextSection->GetBeginWordPlace(); + } else { + return GetEndWordPlace(); } - return GetEndWordPlace(); + } else { + return pSection->GetNextWordPlace(place); } - return pSection->GetNextWordPlace(place); } return place; } @@ -1199,11 +1201,12 @@ CPVT_WordPlace CPDF_VariableText::GetUpWordPlace(const CPVT_WordPlace & place, c CPDF_Point pt = OutToIn(point); if (temp.nLineIndex-- > 0) { return pSection->SearchWordPlace(pt.x - pSection->m_SecInfo.rcSection.left, temp); - } - if (temp.nSecIndex-- > 0) { - if (CSection * pLastSection = m_SectionArray.GetAt(temp.nSecIndex)) { - temp.nLineIndex = pLastSection->m_LineArray.GetSize() - 1; - return pLastSection->SearchWordPlace(pt.x - pLastSection->m_SecInfo.rcSection.left, temp); + } else { + if (temp.nSecIndex-- > 0) { + if (CSection * pLastSection = m_SectionArray.GetAt(temp.nSecIndex)) { + temp.nLineIndex = pLastSection->m_LineArray.GetSize() - 1; + return pLastSection->SearchWordPlace(pt.x - pLastSection->m_SecInfo.rcSection.left, temp); + } } } } @@ -1216,11 +1219,12 @@ CPVT_WordPlace CPDF_VariableText::GetDownWordPlace(const CPVT_WordPlace & place, CPDF_Point pt = OutToIn(point); if (temp.nLineIndex++ < pSection->m_LineArray.GetSize() - 1) { return pSection->SearchWordPlace(pt.x - pSection->m_SecInfo.rcSection.left, temp); - } - if (temp.nSecIndex++ < m_SectionArray.GetSize() - 1) { - if (CSection * pNextSection = m_SectionArray.GetAt(temp.nSecIndex)) { - temp.nLineIndex = 0; - return pNextSection->SearchWordPlace(pt.x - pSection->m_SecInfo.rcSection.left, temp); + } else { + if (temp.nSecIndex++ < m_SectionArray.GetSize() - 1) { + if (CSection * pNextSection = m_SectionArray.GetAt(temp.nSecIndex)) { + temp.nLineIndex = 0; + return pNextSection->SearchWordPlace(pt.x - pSection->m_SecInfo.rcSection.left, temp); + } } } } @@ -1232,10 +1236,10 @@ CPVT_WordPlace CPDF_VariableText::GetLineBeginPlace(const CPVT_WordPlace & place } CPVT_WordPlace CPDF_VariableText::GetLineEndPlace(const CPVT_WordPlace & place) const { - if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { - if (CLine* pLine = pSection->m_LineArray.GetAt(place.nLineIndex)) + if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) + if (CLine * pLine = pSection->m_LineArray.GetAt(place.nLineIndex)) { return pLine->GetEndWordPlace(); - } + } return place; } CPVT_WordPlace CPDF_VariableText::GetSectionBeginPlace(const CPVT_WordPlace & place) const @@ -1432,7 +1436,11 @@ void CPDF_VariableText::ClearSectionRightWords(const CPVT_WordPlace & place) CPVT_WordPlace CPDF_VariableText::AjustLineHeader(const CPVT_WordPlace & place, FX_BOOL bPrevOrNext) const { if (place.nWordIndex < 0 && place.nLineIndex > 0) { - return bPrevOrNext ? GetPrevWordPlace(place) : GetNextWordPlace(place); + if (bPrevOrNext) { + return GetPrevWordPlace(place); + } else { + return GetNextWordPlace(place); + } } return place; } @@ -1628,13 +1636,14 @@ CPVT_FloatRect CPDF_VariableText::RearrangeSections(const CPVT_WordRange & Place } int32_t CPDF_VariableText::GetCharWidth(int32_t nFontIndex, FX_WORD Word, FX_WORD SubWord, int32_t nWordStyle) { - if (!m_pVTProvider) { - return 0; - } - if (SubWord > 0) { - return m_pVTProvider->GetCharWidth(nFontIndex, SubWord, nWordStyle); + if (m_pVTProvider) { + if (SubWord > 0) { + return m_pVTProvider->GetCharWidth(nFontIndex, SubWord, nWordStyle); + } else { + return m_pVTProvider->GetCharWidth(nFontIndex, Word, nWordStyle); + } } - return m_pVTProvider->GetCharWidth(nFontIndex, Word, nWordStyle); + return 0; } int32_t CPDF_VariableText::GetTypeAscent(int32_t nFontIndex) { @@ -1689,6 +1698,7 @@ void CPDF_VariableText_Iterator::SetAt(const CPVT_WordPlace & place) } FX_BOOL CPDF_VariableText_Iterator::NextWord() { + ASSERT(m_pVT != NULL); if (m_CurPos == m_pVT->GetEndWordPlace()) { return FALSE; } @@ -1697,6 +1707,7 @@ FX_BOOL CPDF_VariableText_Iterator::NextWord() } FX_BOOL CPDF_VariableText_Iterator::PrevWord() { + ASSERT(m_pVT != NULL); if (m_CurPos == m_pVT->GetBeginWordPlace()) { return FALSE; } @@ -1705,29 +1716,33 @@ FX_BOOL CPDF_VariableText_Iterator::PrevWord() } FX_BOOL CPDF_VariableText_Iterator::NextLine() { + ASSERT(m_pVT != NULL); if (CSection * pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { if (m_CurPos.nLineIndex < pSection->m_LineArray.GetSize() - 1) { m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex, m_CurPos.nLineIndex + 1, -1); return TRUE; - } - if (m_CurPos.nSecIndex < m_pVT->m_SectionArray.GetSize() - 1) { - m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex + 1, 0, -1); - return TRUE; + } else { + if (m_CurPos.nSecIndex < m_pVT->m_SectionArray.GetSize() - 1) { + m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex + 1, 0, -1); + return TRUE; + } } } return FALSE; } FX_BOOL CPDF_VariableText_Iterator::PrevLine() { + ASSERT(m_pVT != NULL); if (m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { if (m_CurPos.nLineIndex > 0) { m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex, m_CurPos.nLineIndex - 1, -1); return TRUE; - } - if (m_CurPos.nSecIndex > 0) { - if (CSection * pLastSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex - 1)) { - m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex - 1, pLastSection->m_LineArray.GetSize() - 1, -1); - return TRUE; + } else { + if (m_CurPos.nSecIndex > 0) { + if (CSection * pLastSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex - 1)) { + m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex - 1, pLastSection->m_LineArray.GetSize() - 1, -1); + return TRUE; + } } } } @@ -1735,6 +1750,7 @@ FX_BOOL CPDF_VariableText_Iterator::PrevLine() } FX_BOOL CPDF_VariableText_Iterator::NextSection() { + ASSERT(m_pVT != NULL); if (m_CurPos.nSecIndex < m_pVT->m_SectionArray.GetSize() - 1) { m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex + 1, 0, -1); return TRUE; |