Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(934)

Unified Diff: core/fpdfdoc/ctypeset.cpp

Issue 1979463002: Move some classes out of doc_vt.cpp into their own files. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Move CTypeset into its own file. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/fpdfdoc/csection.cpp ('k') | core/fpdfdoc/doc_vt.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfdoc/ctypeset.cpp
diff --git a/core/fpdfdoc/doc_vt.cpp b/core/fpdfdoc/ctypeset.cpp
similarity index 63%
copy from core/fpdfdoc/doc_vt.cpp
copy to core/fpdfdoc/ctypeset.cpp
index 7ca279b41b213a621f1db6b372d5304792f152b1..076c9018851e772edd8f268a11b42c8f8cc59999 100644
--- a/core/fpdfdoc/doc_vt.cpp
+++ b/core/fpdfdoc/ctypeset.cpp
@@ -1,397 +1,19 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
+// Copyright 2016 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+#include "core/fpdfdoc/ctypeset.h"
+
#include <algorithm>
-#include "core/fpdfdoc/cpvt_wordinfo.h"
#include "core/fpdfdoc/csection.h"
-#include "core/fpdfdoc/include/cpdf_variabletext.h"
-#include "core/fpdfdoc/include/fpdf_doc.h"
-#include "core/fpdfdoc/pdf_vt.h"
-
-CLine::CLine() {}
-CLine::~CLine() {}
-CPVT_WordPlace CLine::GetBeginWordPlace() const {
- return CPVT_WordPlace(LinePlace.nSecIndex, LinePlace.nLineIndex, -1);
-}
-CPVT_WordPlace CLine::GetEndWordPlace() const {
- return CPVT_WordPlace(LinePlace.nSecIndex, LinePlace.nLineIndex,
- m_LineInfo.nEndWordIndex);
-}
-CPVT_WordPlace CLine::GetPrevWordPlace(const CPVT_WordPlace& place) const {
- if (place.nWordIndex > m_LineInfo.nEndWordIndex) {
- return CPVT_WordPlace(place.nSecIndex, place.nLineIndex,
- m_LineInfo.nEndWordIndex);
- }
- return CPVT_WordPlace(place.nSecIndex, place.nLineIndex,
- place.nWordIndex - 1);
-}
-CPVT_WordPlace CLine::GetNextWordPlace(const CPVT_WordPlace& place) const {
- if (place.nWordIndex < m_LineInfo.nBeginWordIndex) {
- return CPVT_WordPlace(place.nSecIndex, place.nLineIndex,
- m_LineInfo.nBeginWordIndex);
- }
- return CPVT_WordPlace(place.nSecIndex, place.nLineIndex,
- place.nWordIndex + 1);
-}
-CSection::CSection(CPDF_VariableText* pVT) : m_pVT(pVT) {}
-CSection::~CSection() {
- ResetAll();
-}
-void CSection::ResetAll() {
- ResetWordArray();
- ResetLineArray();
-}
-void CSection::ResetLineArray() {
- m_LineArray.RemoveAll();
-}
-void CSection::ResetWordArray() {
- for (int32_t i = 0, sz = m_WordArray.GetSize(); i < sz; i++) {
- delete m_WordArray.GetAt(i);
- }
- m_WordArray.RemoveAll();
-}
-void CSection::ResetLinePlace() {
- for (int32_t i = 0, sz = m_LineArray.GetSize(); i < sz; i++) {
- if (CLine* pLine = m_LineArray.GetAt(i)) {
- pLine->LinePlace = CPVT_WordPlace(SecPlace.nSecIndex, i, -1);
- }
- }
-}
-CPVT_WordPlace CSection::AddWord(const CPVT_WordPlace& place,
- const CPVT_WordInfo& wordinfo) {
- CPVT_WordInfo* pWord = new CPVT_WordInfo(wordinfo);
- int32_t nWordIndex =
- std::max(std::min(place.nWordIndex, m_WordArray.GetSize()), 0);
- if (nWordIndex == m_WordArray.GetSize()) {
- m_WordArray.Add(pWord);
- } else {
- m_WordArray.InsertAt(nWordIndex, pWord);
- }
- return place;
-}
-CPVT_WordPlace CSection::AddLine(const CPVT_LineInfo& lineinfo) {
- return CPVT_WordPlace(SecPlace.nSecIndex, m_LineArray.Add(lineinfo), -1);
-}
-CPVT_FloatRect CSection::Rearrange() {
- if (m_pVT->m_nCharArray > 0) {
- return CTypeset(this).CharArray();
- }
- return CTypeset(this).Typeset();
-}
-CFX_SizeF CSection::GetSectionSize(FX_FLOAT fFontSize) {
- return CTypeset(this).GetEditSize(fFontSize);
-}
-CPVT_WordPlace CSection::GetBeginWordPlace() const {
- if (CLine* pLine = m_LineArray.GetAt(0)) {
- return pLine->GetBeginWordPlace();
- }
- return SecPlace;
-}
-CPVT_WordPlace CSection::GetEndWordPlace() const {
- if (CLine* pLine = m_LineArray.GetAt(m_LineArray.GetSize() - 1)) {
- return pLine->GetEndWordPlace();
- }
- return SecPlace;
-}
-CPVT_WordPlace CSection::GetPrevWordPlace(const CPVT_WordPlace& place) const {
- if (place.nLineIndex < 0) {
- return GetBeginWordPlace();
- }
- if (place.nLineIndex >= m_LineArray.GetSize()) {
- return GetEndWordPlace();
- }
- 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) {
- if (CLine* pPrevLine = m_LineArray.GetAt(place.nLineIndex - 1)) {
- return pPrevLine->GetEndWordPlace();
- }
- } else {
- return pLine->GetPrevWordPlace(place);
- }
- }
- return place;
-}
-CPVT_WordPlace CSection::GetNextWordPlace(const CPVT_WordPlace& place) const {
- if (place.nLineIndex < 0) {
- return GetBeginWordPlace();
- }
- if (place.nLineIndex >= m_LineArray.GetSize()) {
- return GetEndWordPlace();
- }
- if (CLine* pLine = m_LineArray.GetAt(place.nLineIndex)) {
- if (place.nWordIndex >= pLine->m_LineInfo.nEndWordIndex) {
- if (CLine* pNextLine = m_LineArray.GetAt(place.nLineIndex + 1)) {
- return pNextLine->GetBeginWordPlace();
- }
- } else {
- return pLine->GetNextWordPlace(place);
- }
- }
- return place;
-}
-void CSection::UpdateWordPlace(CPVT_WordPlace& place) const {
- int32_t nLeft = 0;
- int32_t nRight = m_LineArray.GetSize() - 1;
- int32_t nMid = (nLeft + nRight) / 2;
- while (nLeft <= nRight) {
- if (CLine* pLine = m_LineArray.GetAt(nMid)) {
- if (place.nWordIndex < pLine->m_LineInfo.nBeginWordIndex) {
- nRight = nMid - 1;
- nMid = (nLeft + nRight) / 2;
- } else if (place.nWordIndex > pLine->m_LineInfo.nEndWordIndex) {
- nLeft = nMid + 1;
- nMid = (nLeft + nRight) / 2;
- } else {
- place.nLineIndex = nMid;
- return;
- }
- } else {
- break;
- }
- }
-}
-CPVT_WordPlace CSection::SearchWordPlace(const CFX_FloatPoint& point) const {
- ASSERT(m_pVT);
- CPVT_WordPlace place = GetBeginWordPlace();
- FX_BOOL bUp = TRUE;
- FX_BOOL bDown = TRUE;
- int32_t nLeft = 0;
- int32_t nRight = m_LineArray.GetSize() - 1;
- int32_t nMid = m_LineArray.GetSize() / 2;
- FX_FLOAT fTop = 0;
- FX_FLOAT fBottom = 0;
- while (nLeft <= nRight) {
- if (CLine* pLine = m_LineArray.GetAt(nMid)) {
- fTop = pLine->m_LineInfo.fLineY - pLine->m_LineInfo.fLineAscent -
- m_pVT->GetLineLeading(m_SecInfo);
- fBottom = pLine->m_LineInfo.fLineY - pLine->m_LineInfo.fLineDescent;
- if (IsFloatBigger(point.y, fTop)) {
- bUp = FALSE;
- }
- if (IsFloatSmaller(point.y, fBottom)) {
- bDown = FALSE;
- }
- if (IsFloatSmaller(point.y, fTop)) {
- nRight = nMid - 1;
- nMid = (nLeft + nRight) / 2;
- continue;
- } else if (IsFloatBigger(point.y, fBottom)) {
- nLeft = nMid + 1;
- nMid = (nLeft + nRight) / 2;
- continue;
- } else {
- place = SearchWordPlace(
- point.x,
- CPVT_WordRange(pLine->GetNextWordPlace(pLine->GetBeginWordPlace()),
- pLine->GetEndWordPlace()));
- place.nLineIndex = nMid;
- return place;
- }
- }
- }
- if (bUp) {
- place = GetBeginWordPlace();
- }
- if (bDown) {
- place = GetEndWordPlace();
- }
- return place;
-}
-CPVT_WordPlace CSection::SearchWordPlace(
- FX_FLOAT fx,
- const CPVT_WordPlace& lineplace) const {
- if (CLine* pLine = m_LineArray.GetAt(lineplace.nLineIndex)) {
- return SearchWordPlace(
- fx - m_SecInfo.rcSection.left,
- CPVT_WordRange(pLine->GetNextWordPlace(pLine->GetBeginWordPlace()),
- pLine->GetEndWordPlace()));
- }
- return GetBeginWordPlace();
-}
-CPVT_WordPlace CSection::SearchWordPlace(FX_FLOAT fx,
- const CPVT_WordRange& range) const {
- CPVT_WordPlace wordplace = range.BeginPos;
- wordplace.nWordIndex = -1;
- if (!m_pVT) {
- return wordplace;
- }
- int32_t nLeft = range.BeginPos.nWordIndex;
- int32_t nRight = range.EndPos.nWordIndex + 1;
- int32_t nMid = (nLeft + nRight) / 2;
- while (nLeft < nRight) {
- if (nMid == nLeft) {
- break;
- }
- if (nMid == nRight) {
- nMid--;
- break;
- }
- if (CPVT_WordInfo* pWord = m_WordArray.GetAt(nMid)) {
- if (fx >
- pWord->fWordX + m_pVT->GetWordWidth(*pWord) * VARIABLETEXT_HALF) {
- nLeft = nMid;
- nMid = (nLeft + nRight) / 2;
- continue;
- } else {
- nRight = nMid;
- nMid = (nLeft + nRight) / 2;
- continue;
- }
- } else {
- break;
- }
- }
- if (CPVT_WordInfo* pWord = m_WordArray.GetAt(nMid)) {
- if (fx > pWord->fWordX + m_pVT->GetWordWidth(*pWord) * VARIABLETEXT_HALF) {
- wordplace.nWordIndex = nMid;
- }
- }
- return wordplace;
-}
-void CSection::ClearLeftWords(int32_t nWordIndex) {
- for (int32_t i = nWordIndex; i >= 0; i--) {
- delete m_WordArray.GetAt(i);
- m_WordArray.RemoveAt(i);
- }
-}
-void CSection::ClearRightWords(int32_t nWordIndex) {
- for (int32_t i = m_WordArray.GetSize() - 1; i > nWordIndex; i--) {
- delete m_WordArray.GetAt(i);
- m_WordArray.RemoveAt(i);
- }
-}
-void CSection::ClearMidWords(int32_t nBeginIndex, int32_t nEndIndex) {
- for (int32_t i = nEndIndex; i > nBeginIndex; i--) {
- delete m_WordArray.GetAt(i);
- m_WordArray.RemoveAt(i);
- }
-}
-void CSection::ClearWords(const CPVT_WordRange& PlaceRange) {
- CPVT_WordPlace SecBeginPos = GetBeginWordPlace();
- CPVT_WordPlace SecEndPos = GetEndWordPlace();
- if (PlaceRange.BeginPos.WordCmp(SecBeginPos) >= 0) {
- if (PlaceRange.EndPos.WordCmp(SecEndPos) <= 0) {
- ClearMidWords(PlaceRange.BeginPos.nWordIndex,
- PlaceRange.EndPos.nWordIndex);
- } else {
- ClearRightWords(PlaceRange.BeginPos.nWordIndex);
- }
- } else if (PlaceRange.EndPos.WordCmp(SecEndPos) <= 0) {
- ClearLeftWords(PlaceRange.EndPos.nWordIndex);
- } else {
- ResetWordArray();
- }
-}
-void CSection::ClearWord(const CPVT_WordPlace& place) {
- delete m_WordArray.GetAt(place.nWordIndex);
- m_WordArray.RemoveAt(place.nWordIndex);
-}
-CTypeset::CTypeset(CSection* pSection)
- : m_rcRet(0.0f, 0.0f, 0.0f, 0.0f),
- m_pVT(pSection->m_pVT),
- m_pSection(pSection) {}
-CTypeset::~CTypeset() {}
-CPVT_FloatRect CTypeset::CharArray() {
- ASSERT(m_pSection);
- FX_FLOAT fLineAscent =
- m_pVT->GetFontAscent(m_pVT->GetDefaultFontIndex(), m_pVT->GetFontSize());
- FX_FLOAT fLineDescent =
- m_pVT->GetFontDescent(m_pVT->GetDefaultFontIndex(), m_pVT->GetFontSize());
- m_rcRet.Default();
- FX_FLOAT x = 0.0f, y = 0.0f;
- FX_FLOAT fNextWidth;
- int32_t nStart = 0;
- FX_FLOAT fNodeWidth = m_pVT->GetPlateWidth() /
- (m_pVT->m_nCharArray <= 0 ? 1 : m_pVT->m_nCharArray);
- if (CLine* pLine = m_pSection->m_LineArray.GetAt(0)) {
- x = 0.0f;
- y += m_pVT->GetLineLeading(m_pSection->m_SecInfo);
- y += fLineAscent;
- nStart = 0;
- switch (m_pVT->GetAlignment(m_pSection->m_SecInfo)) {
- case 0:
- pLine->m_LineInfo.fLineX = fNodeWidth * VARIABLETEXT_HALF;
- break;
- case 1:
- nStart = (m_pVT->m_nCharArray - m_pSection->m_WordArray.GetSize()) / 2;
- pLine->m_LineInfo.fLineX =
- fNodeWidth * nStart - fNodeWidth * VARIABLETEXT_HALF;
- break;
- case 2:
- nStart = m_pVT->m_nCharArray - m_pSection->m_WordArray.GetSize();
- pLine->m_LineInfo.fLineX =
- fNodeWidth * nStart - fNodeWidth * VARIABLETEXT_HALF;
- break;
- }
- for (int32_t w = 0, sz = m_pSection->m_WordArray.GetSize(); w < sz; w++) {
- if (w >= m_pVT->m_nCharArray) {
- break;
- }
- fNextWidth = 0;
- if (CPVT_WordInfo* pNextWord =
- (CPVT_WordInfo*)m_pSection->m_WordArray.GetAt(w + 1)) {
- pNextWord->fWordTail = 0;
- fNextWidth = m_pVT->GetWordWidth(*pNextWord);
- }
- if (CPVT_WordInfo* pWord =
- (CPVT_WordInfo*)m_pSection->m_WordArray.GetAt(w)) {
- pWord->fWordTail = 0;
- FX_FLOAT fWordWidth = m_pVT->GetWordWidth(*pWord);
- FX_FLOAT fWordAscent = m_pVT->GetWordAscent(*pWord);
- FX_FLOAT fWordDescent = m_pVT->GetWordDescent(*pWord);
- x = (FX_FLOAT)(fNodeWidth * (w + nStart + 0.5) -
- fWordWidth * VARIABLETEXT_HALF);
- pWord->fWordX = x;
- pWord->fWordY = y;
- if (w == 0) {
- pLine->m_LineInfo.fLineX = x;
- }
- if (w != m_pSection->m_WordArray.GetSize() - 1) {
- pWord->fWordTail =
- (fNodeWidth - (fWordWidth + fNextWidth) * VARIABLETEXT_HALF > 0
- ? fNodeWidth - (fWordWidth + fNextWidth) * VARIABLETEXT_HALF
- : 0);
- } else {
- pWord->fWordTail = 0;
- }
- x += fWordWidth;
- fLineAscent = std::max(fLineAscent, fWordAscent);
- fLineDescent = std::min(fLineDescent, fWordDescent);
- }
- }
- pLine->m_LineInfo.nBeginWordIndex = 0;
- pLine->m_LineInfo.nEndWordIndex = m_pSection->m_WordArray.GetSize() - 1;
- pLine->m_LineInfo.fLineY = y;
- pLine->m_LineInfo.fLineWidth = x - pLine->m_LineInfo.fLineX;
- pLine->m_LineInfo.fLineAscent = fLineAscent;
- pLine->m_LineInfo.fLineDescent = fLineDescent;
- y -= fLineDescent;
- }
- return m_rcRet = CPVT_FloatRect(0, 0, x, y);
-}
-CFX_SizeF CTypeset::GetEditSize(FX_FLOAT fFontSize) {
- ASSERT(m_pSection);
- ASSERT(m_pVT);
- SplitLines(FALSE, fFontSize);
- return CFX_SizeF(m_rcRet.Width(), m_rcRet.Height());
-}
-CPVT_FloatRect CTypeset::Typeset() {
- ASSERT(m_pVT);
- m_pSection->m_LineArray.Empty();
- SplitLines(TRUE, 0.0f);
- m_pSection->m_LineArray.Clear();
- OutputLines();
- return m_rcRet;
-}
+#include "core/fpdfdoc/cpvt_wordinfo.h"
-static const uint8_t special_chars[128] = {
+namespace {
+
+const uint8_t special_chars[128] = {
0x00, 0x0C, 0x08, 0x0C, 0x08, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x00,
@@ -405,7 +27,7 @@ static const uint8_t special_chars[128] = {
0x01, 0x01, 0x01, 0x0C, 0x00, 0x08, 0x00, 0x00,
};
-static bool IsLatin(uint16_t word) {
+bool IsLatin(uint16_t word) {
if (word <= 0x007F)
return !!(special_chars[word] & 0x01);
@@ -418,11 +40,11 @@ static bool IsLatin(uint16_t word) {
(word >= 0xFF41 && word <= 0xFF5A));
}
-static bool IsDigit(uint32_t word) {
+bool IsDigit(uint32_t word) {
return word >= 0x0030 && word <= 0x0039;
}
-static bool IsCJK(uint32_t word) {
+bool IsCJK(uint32_t word) {
if ((word >= 0x1100 && word <= 0x11FF) ||
(word >= 0x2E80 && word <= 0x2FFF) ||
(word >= 0x3040 && word <= 0x9FBF) ||
@@ -443,7 +65,7 @@ static bool IsCJK(uint32_t word) {
return word >= 0xFF66 && word <= 0xFF9D;
}
-static bool IsPunctuation(uint32_t word) {
+bool IsPunctuation(uint32_t word) {
if (word <= 0x007F)
return !!(special_chars[word] & 0x08);
@@ -490,11 +112,11 @@ static bool IsPunctuation(uint32_t word) {
return false;
}
-static bool IsConnectiveSymbol(uint32_t word) {
+bool IsConnectiveSymbol(uint32_t word) {
return word <= 0x007F && (special_chars[word] & 0x20);
}
-static bool IsOpenStylePunctuation(uint32_t word) {
+bool IsOpenStylePunctuation(uint32_t word) {
if (word <= 0x007F)
return !!(special_chars[word] & 0x04);
@@ -504,7 +126,7 @@ static bool IsOpenStylePunctuation(uint32_t word) {
word == 0xFF3B || word == 0xFF5B || word == 0xFF62);
}
-static bool IsCurrencySymbol(uint16_t word) {
+bool IsCurrencySymbol(uint16_t word) {
return (word == 0x0024 || word == 0x0080 || word == 0x00A2 ||
word == 0x00A3 || word == 0x00A4 || word == 0x00A5 ||
(word >= 0x20A0 && word <= 0x20CF) || word == 0xFE69 ||
@@ -512,15 +134,15 @@ static bool IsCurrencySymbol(uint16_t word) {
word == 0xFFE5 || word == 0xFFE6);
}
-static bool IsPrefixSymbol(uint16_t word) {
+bool IsPrefixSymbol(uint16_t word) {
return IsCurrencySymbol(word) || word == 0x2116;
}
-static bool IsSpace(uint16_t word) {
+bool IsSpace(uint16_t word) {
return word == 0x0020 || word == 0x3000;
}
-static bool NeedDivision(uint16_t prevWord, uint16_t curWord) {
+bool NeedDivision(uint16_t prevWord, uint16_t curWord) {
if ((IsLatin(prevWord) || IsDigit(prevWord)) &&
(IsLatin(curWord) || IsDigit(curWord))) {
return false;
@@ -546,6 +168,110 @@ static bool NeedDivision(uint16_t prevWord, uint16_t curWord) {
return false;
}
+} // namespace
+
+CTypeset::CTypeset(CSection* pSection)
+ : m_rcRet(0.0f, 0.0f, 0.0f, 0.0f),
+ m_pVT(pSection->m_pVT),
+ m_pSection(pSection) {}
+
+CTypeset::~CTypeset() {}
+
+CPVT_FloatRect CTypeset::CharArray() {
+ ASSERT(m_pSection);
+ FX_FLOAT fLineAscent =
+ m_pVT->GetFontAscent(m_pVT->GetDefaultFontIndex(), m_pVT->GetFontSize());
+ FX_FLOAT fLineDescent =
+ m_pVT->GetFontDescent(m_pVT->GetDefaultFontIndex(), m_pVT->GetFontSize());
+ m_rcRet.Default();
+ FX_FLOAT x = 0.0f, y = 0.0f;
+ FX_FLOAT fNextWidth;
+ int32_t nStart = 0;
+ FX_FLOAT fNodeWidth = m_pVT->GetPlateWidth() /
+ (m_pVT->m_nCharArray <= 0 ? 1 : m_pVT->m_nCharArray);
+ if (CLine* pLine = m_pSection->m_LineArray.GetAt(0)) {
+ x = 0.0f;
+ y += m_pVT->GetLineLeading(m_pSection->m_SecInfo);
+ y += fLineAscent;
+ nStart = 0;
+ switch (m_pVT->GetAlignment(m_pSection->m_SecInfo)) {
+ case 0:
+ pLine->m_LineInfo.fLineX = fNodeWidth * VARIABLETEXT_HALF;
+ break;
+ case 1:
+ nStart = (m_pVT->m_nCharArray - m_pSection->m_WordArray.GetSize()) / 2;
+ pLine->m_LineInfo.fLineX =
+ fNodeWidth * nStart - fNodeWidth * VARIABLETEXT_HALF;
+ break;
+ case 2:
+ nStart = m_pVT->m_nCharArray - m_pSection->m_WordArray.GetSize();
+ pLine->m_LineInfo.fLineX =
+ fNodeWidth * nStart - fNodeWidth * VARIABLETEXT_HALF;
+ break;
+ }
+ for (int32_t w = 0, sz = m_pSection->m_WordArray.GetSize(); w < sz; w++) {
+ if (w >= m_pVT->m_nCharArray) {
+ break;
+ }
+ fNextWidth = 0;
+ if (CPVT_WordInfo* pNextWord =
+ (CPVT_WordInfo*)m_pSection->m_WordArray.GetAt(w + 1)) {
+ pNextWord->fWordTail = 0;
+ fNextWidth = m_pVT->GetWordWidth(*pNextWord);
+ }
+ if (CPVT_WordInfo* pWord =
+ (CPVT_WordInfo*)m_pSection->m_WordArray.GetAt(w)) {
+ pWord->fWordTail = 0;
+ FX_FLOAT fWordWidth = m_pVT->GetWordWidth(*pWord);
+ FX_FLOAT fWordAscent = m_pVT->GetWordAscent(*pWord);
+ FX_FLOAT fWordDescent = m_pVT->GetWordDescent(*pWord);
+ x = (FX_FLOAT)(fNodeWidth * (w + nStart + 0.5) -
+ fWordWidth * VARIABLETEXT_HALF);
+ pWord->fWordX = x;
+ pWord->fWordY = y;
+ if (w == 0) {
+ pLine->m_LineInfo.fLineX = x;
+ }
+ if (w != m_pSection->m_WordArray.GetSize() - 1) {
+ pWord->fWordTail =
+ (fNodeWidth - (fWordWidth + fNextWidth) * VARIABLETEXT_HALF > 0
+ ? fNodeWidth - (fWordWidth + fNextWidth) * VARIABLETEXT_HALF
+ : 0);
+ } else {
+ pWord->fWordTail = 0;
+ }
+ x += fWordWidth;
+ fLineAscent = std::max(fLineAscent, fWordAscent);
+ fLineDescent = std::min(fLineDescent, fWordDescent);
+ }
+ }
+ pLine->m_LineInfo.nBeginWordIndex = 0;
+ pLine->m_LineInfo.nEndWordIndex = m_pSection->m_WordArray.GetSize() - 1;
+ pLine->m_LineInfo.fLineY = y;
+ pLine->m_LineInfo.fLineWidth = x - pLine->m_LineInfo.fLineX;
+ pLine->m_LineInfo.fLineAscent = fLineAscent;
+ pLine->m_LineInfo.fLineDescent = fLineDescent;
+ y -= fLineDescent;
+ }
+ return m_rcRet = CPVT_FloatRect(0, 0, x, y);
+}
+
+CFX_SizeF CTypeset::GetEditSize(FX_FLOAT fFontSize) {
+ ASSERT(m_pSection);
+ ASSERT(m_pVT);
+ SplitLines(FALSE, fFontSize);
+ return CFX_SizeF(m_rcRet.Width(), m_rcRet.Height());
+}
+
+CPVT_FloatRect CTypeset::Typeset() {
+ ASSERT(m_pVT);
+ m_pSection->m_LineArray.Empty();
+ SplitLines(TRUE, 0.0f);
+ m_pSection->m_LineArray.Clear();
+ OutputLines();
+ return m_rcRet;
+}
+
void CTypeset::SplitLines(FX_BOOL bTypeset, FX_FLOAT fFontSize) {
ASSERT(m_pVT);
ASSERT(m_pSection);
@@ -693,6 +419,7 @@ void CTypeset::SplitLines(FX_BOOL bTypeset, FX_FLOAT fFontSize) {
}
m_rcRet = CPVT_FloatRect(0, 0, fMaxX, fMaxY);
}
+
void CTypeset::OutputLines() {
ASSERT(m_pVT);
ASSERT(m_pSection);
« no previous file with comments | « core/fpdfdoc/csection.cpp ('k') | core/fpdfdoc/doc_vt.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698