summaryrefslogtreecommitdiff
path: root/fpdfsdk/fxedit
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-07-20 11:07:00 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-07-20 15:33:39 +0000
commit14ddd425193946692042fcd910857963d333be3b (patch)
treef287d1e2f5e41545e29a75fd32188d02862a5b81 /fpdfsdk/fxedit
parent2c4a805ac3d649caf34b125fdda1450c7ba8432f (diff)
downloadpdfium-14ddd425193946692042fcd910857963d333be3b.tar.xz
Consolidate Appearance Stream code in CPWL_AppStream.
This CL moves the remaining appearance stream code to CPWL_AppStream. The unused GetThisAppearanceStream methods have been removed. Change-Id: I0bdfbb11962ee7975394a40a1ea45d076ee9151d Reviewed-on: https://pdfium-review.googlesource.com/8312 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'fpdfsdk/fxedit')
-rw-r--r--fpdfsdk/fxedit/fxet_edit.cpp164
-rw-r--r--fpdfsdk/fxedit/fxet_edit.h8
2 files changed, 0 insertions, 172 deletions
diff --git a/fpdfsdk/fxedit/fxet_edit.cpp b/fpdfsdk/fxedit/fxet_edit.cpp
index cf382f8426..41019b3459 100644
--- a/fpdfsdk/fxedit/fxet_edit.cpp
+++ b/fpdfsdk/fxedit/fxet_edit.cpp
@@ -38,27 +38,6 @@ namespace {
const int kEditUndoMaxItems = 10000;
-CFX_ByteString GetWordRenderString(const CFX_ByteString& strWords) {
- if (strWords.GetLength() > 0)
- return PDF_EncodeString(strWords, false) + " Tj\n";
- return CFX_ByteString();
-}
-
-CFX_ByteString GetFontSetString(IPVT_FontMap* pFontMap,
- int32_t nFontIndex,
- float fFontSize) {
- if (!pFontMap)
- return CFX_ByteString();
-
- CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex);
- if (sFontAlias.GetLength() <= 0 || fFontSize <= 0)
- return CFX_ByteString();
-
- std::ostringstream sRet;
- sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n";
- return CFX_ByteString(sRet);
-}
-
void DrawTextString(CFX_RenderDevice* pDevice,
const CFX_PointF& pt,
CPDF_Font* pFont,
@@ -514,149 +493,6 @@ void CFXEU_InsertText::Undo() {
}
// static
-CFX_ByteString CFX_Edit::GetEditAppearanceStream(CFX_Edit* pEdit,
- const CFX_PointF& ptOffset,
- const CPVT_WordRange* pRange,
- bool bContinuous,
- uint16_t SubWord) {
- CFX_Edit_Iterator* pIterator = pEdit->GetIterator();
- if (pRange)
- pIterator->SetAt(pRange->BeginPos);
- else
- pIterator->SetAt(0);
-
- std::ostringstream sEditStream;
- std::ostringstream sWords;
- int32_t nCurFontIndex = -1;
- CFX_PointF ptOld;
- CFX_PointF ptNew;
- CPVT_WordPlace oldplace;
-
- while (pIterator->NextWord()) {
- CPVT_WordPlace place = pIterator->GetAt();
- if (pRange && place > pRange->EndPos)
- break;
-
- if (bContinuous) {
- if (place.LineCmp(oldplace) != 0) {
- if (sWords.tellp() > 0) {
- sEditStream << GetWordRenderString(CFX_ByteString(sWords));
- sWords.str("");
- }
-
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- ptNew = CFX_PointF(word.ptWord.x + ptOffset.x,
- word.ptWord.y + ptOffset.y);
- } else {
- CPVT_Line line;
- pIterator->GetLine(line);
- ptNew = CFX_PointF(line.ptLine.x + ptOffset.x,
- line.ptLine.y + ptOffset.y);
- }
-
- if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
- sEditStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y
- << " Td\n";
-
- ptOld = ptNew;
- }
- }
-
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- if (word.nFontIndex != nCurFontIndex) {
- if (sWords.tellp() > 0) {
- sEditStream << GetWordRenderString(CFX_ByteString(sWords));
- sWords.str("");
- }
- sEditStream << GetFontSetString(pEdit->GetFontMap(), word.nFontIndex,
- word.fFontSize);
- nCurFontIndex = word.nFontIndex;
- }
-
- sWords << GetPDFWordString(pEdit->GetFontMap(), nCurFontIndex,
- word.Word, SubWord);
- }
-
- oldplace = place;
- } else {
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- ptNew =
- CFX_PointF(word.ptWord.x + ptOffset.x, word.ptWord.y + ptOffset.y);
-
- if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
- sEditStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y
- << " Td\n";
- ptOld = ptNew;
- }
-
- if (word.nFontIndex != nCurFontIndex) {
- sEditStream << GetFontSetString(pEdit->GetFontMap(), word.nFontIndex,
- word.fFontSize);
- nCurFontIndex = word.nFontIndex;
- }
-
- sEditStream << GetWordRenderString(GetPDFWordString(
- pEdit->GetFontMap(), nCurFontIndex, word.Word, SubWord));
- }
- }
- }
-
- if (sWords.tellp() > 0) {
- sEditStream << GetWordRenderString(CFX_ByteString(sWords));
- sWords.str("");
- }
-
- std::ostringstream sAppStream;
- if (sEditStream.tellp() > 0) {
- int32_t nHorzScale = pEdit->GetHorzScale();
- if (nHorzScale != 100) {
- sAppStream << nHorzScale << " Tz\n";
- }
-
- float fCharSpace = pEdit->GetCharSpace();
- if (!IsFloatZero(fCharSpace)) {
- sAppStream << fCharSpace << " Tc\n";
- }
-
- sAppStream << sEditStream.str();
- }
-
- return CFX_ByteString(sAppStream);
-}
-
-// static
-CFX_ByteString CFX_Edit::GetSelectAppearanceStream(
- CFX_Edit* pEdit,
- const CFX_PointF& ptOffset,
- const CPVT_WordRange* pRange) {
- if (!pRange || pRange->IsEmpty())
- return CFX_ByteString();
-
- CFX_Edit_Iterator* pIterator = pEdit->GetIterator();
- pIterator->SetAt(pRange->BeginPos);
-
- std::ostringstream sRet;
- while (pIterator->NextWord()) {
- CPVT_WordPlace place = pIterator->GetAt();
- if (place > pRange->EndPos)
- 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";
- }
- }
-
- return CFX_ByteString(sRet);
-}
-
-// static
void CFX_Edit::DrawEdit(CFX_RenderDevice* pDevice,
CFX_Matrix* pUser2Device,
CFX_Edit* pEdit,
diff --git a/fpdfsdk/fxedit/fxet_edit.h b/fpdfsdk/fxedit/fxet_edit.h
index 01759aaba9..c0c8442d52 100644
--- a/fpdfsdk/fxedit/fxet_edit.h
+++ b/fpdfsdk/fxedit/fxet_edit.h
@@ -286,14 +286,6 @@ class CFXEU_InsertText : public CFX_Edit_UndoItem {
class CFX_Edit {
public:
- static CFX_ByteString GetEditAppearanceStream(CFX_Edit* pEdit,
- const CFX_PointF& ptOffset,
- const CPVT_WordRange* pRange,
- bool bContinuous,
- uint16_t SubWord);
- static CFX_ByteString GetSelectAppearanceStream(CFX_Edit* pEdit,
- const CFX_PointF& ptOffset,
- const CPVT_WordRange* pRange);
static void DrawEdit(CFX_RenderDevice* pDevice,
CFX_Matrix* pUser2Device,
CFX_Edit* pEdit,