summaryrefslogtreecommitdiff
path: root/fpdfsdk/fxedit
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/fxedit')
-rw-r--r--fpdfsdk/fxedit/fxet_ap.cpp116
1 files changed, 60 insertions, 56 deletions
diff --git a/fpdfsdk/fxedit/fxet_ap.cpp b/fpdfsdk/fxedit/fxet_ap.cpp
index 5420b46218..863a2d2133 100644
--- a/fpdfsdk/fxedit/fxet_ap.cpp
+++ b/fpdfsdk/fxedit/fxet_ap.cpp
@@ -11,69 +11,74 @@
#include "fpdfsdk/fxedit/include/fx_edit.h"
#include "fpdfsdk/fxedit/include/fxet_edit.h"
+namespace {
+
+CFX_ByteString GetWordRenderString(const CFX_ByteString& strWords) {
+ if (strWords.GetLength() > 0)
+ return PDF_EncodeString(strWords) + " Tj\n";
+ return CFX_ByteString();
+}
+
+CFX_ByteString GetFontSetString(IPVT_FontMap* pFontMap,
+ int32_t nFontIndex,
+ FX_FLOAT fFontSize) {
+ if (!pFontMap)
+ return CFX_ByteString();
+
+ CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex);
+ if (sFontAlias.GetLength() <= 0 || fFontSize <= 0)
+ return CFX_ByteString();
+
+ CFX_ByteTextBuf sRet;
+ sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n";
+ return sRet.MakeString();
+}
+
+} // namespace
+
CFX_ByteString GetPDFWordString(IPVT_FontMap* pFontMap,
int32_t nFontIndex,
uint16_t Word,
uint16_t SubWord) {
+ CPDF_Font* pPDFFont = pFontMap->GetPDFFont(nFontIndex);
+ if (!pPDFFont)
+ return CFX_ByteString();
+
CFX_ByteString sWord;
- if (CPDF_Font* pPDFFont = pFontMap->GetPDFFont(nFontIndex)) {
- if (SubWord > 0) {
- Word = SubWord;
- } else {
- uint32_t dwCharCode =
- pPDFFont->IsUnicodeCompatible()
- ? pPDFFont->CharCodeFromUnicode(Word)
- : pFontMap->CharCodeFromUnicode(nFontIndex, Word);
-
- if (dwCharCode > 0) {
- pPDFFont->AppendChar(sWord, dwCharCode);
- return sWord;
- }
+ if (SubWord > 0) {
+ Word = SubWord;
+ } else {
+ uint32_t dwCharCode = pPDFFont->IsUnicodeCompatible()
+ ? pPDFFont->CharCodeFromUnicode(Word)
+ : pFontMap->CharCodeFromUnicode(nFontIndex, Word);
+
+ if (dwCharCode > 0) {
+ pPDFFont->AppendChar(sWord, dwCharCode);
+ return sWord;
}
-
- pPDFFont->AppendChar(sWord, Word);
}
+ pPDFFont->AppendChar(sWord, Word);
return sWord;
}
-static CFX_ByteString GetWordRenderString(const CFX_ByteString& strWords) {
- if (strWords.GetLength() > 0)
- return PDF_EncodeString(strWords) + " Tj\n";
-
- return "";
-}
-
-static CFX_ByteString GetFontSetString(IPVT_FontMap* pFontMap,
- int32_t nFontIndex,
- FX_FLOAT fFontSize) {
- CFX_ByteTextBuf sRet;
- if (pFontMap) {
- CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex);
- if (sFontAlias.GetLength() > 0 && fFontSize > 0)
- sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n";
- }
- return sRet.MakeString();
-}
-
CFX_ByteString IFX_Edit::GetEditAppearanceStream(IFX_Edit* pEdit,
const CFX_FloatPoint& ptOffset,
const CPVT_WordRange* pRange,
FX_BOOL bContinuous,
uint16_t SubWord) {
- CFX_ByteTextBuf sEditStream, sWords;
-
- CFX_FloatPoint ptOld(0.0f, 0.0f), ptNew(0.0f, 0.0f);
- int32_t nCurFontIndex = -1;
-
IFX_Edit_Iterator* pIterator = pEdit->GetIterator();
if (pRange)
pIterator->SetAt(pRange->BeginPos);
else
pIterator->SetAt(0);
+ CFX_ByteTextBuf sEditStream;
+ CFX_ByteTextBuf sWords;
+ int32_t nCurFontIndex = -1;
+ CFX_FloatPoint ptOld(0.0f, 0.0f);
+ CFX_FloatPoint ptNew(0.0f, 0.0f);
CPVT_WordPlace oldplace;
-
while (pIterator->NextWord()) {
CPVT_WordPlace place = pIterator->GetAt();
@@ -174,25 +179,24 @@ CFX_ByteString IFX_Edit::GetSelectAppearanceStream(
IFX_Edit* pEdit,
const CFX_FloatPoint& ptOffset,
const CPVT_WordRange* pRange) {
- CFX_ByteTextBuf sRet;
-
- if (pRange && pRange->IsExist()) {
- IFX_Edit_Iterator* pIterator = pEdit->GetIterator();
- pIterator->SetAt(pRange->BeginPos);
+ if (!pRange || !pRange->IsExist())
+ return CFX_ByteString();
- while (pIterator->NextWord()) {
- CPVT_WordPlace place = pIterator->GetAt();
+ IFX_Edit_Iterator* pIterator = pEdit->GetIterator();
+ pIterator->SetAt(pRange->BeginPos);
- if (pRange && place.WordCmp(pRange->EndPos) > 0)
- break;
+ CFX_ByteTextBuf sRet;
+ while (pIterator->NextWord()) {
+ CPVT_WordPlace place = pIterator->GetAt();
+ if (place.WordCmp(pRange->EndPos) > 0)
+ break;
- CPVT_Word word;
- CPVT_Line line;
- if (pIterator->GetWord(word) && pIterator->GetLine(line)) {
- sRet << word.ptWord.x + ptOffset.x << " "
- << line.ptLine.y + line.fLineDescent << " " << word.fWidth << " "
- << line.fLineAscent - line.fLineDescent << " re\nf\n";
- }
+ CPVT_Word word;
+ CPVT_Line line;
+ if (pIterator->GetWord(word) && pIterator->GetLine(line)) {
+ sRet << word.ptWord.x + ptOffset.x << " "
+ << line.ptLine.y + line.fLineDescent << " " << word.fWidth << " "
+ << line.fLineAscent - line.fLineDescent << " re\nf\n";
}
}