| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "../../include/fpdfdoc/fpdf_doc.h" | 7 #include "../../include/fpdfdoc/fpdf_doc.h" |
| 8 #include "../../include/fpdfdoc/fpdf_vt.h" | 8 #include "../../include/fpdfdoc/fpdf_vt.h" |
| 9 #include "pdf_vt.h" | 9 #include "pdf_vt.h" |
| 10 const uint8_t gFontSizeSteps[] = { 4, 6, 8, 9, 10, 12, 14, 18, 20, 25,
30, 35, 40, 45, 50, 55, 60, 70, 80, 90, 100, 110, 120, 130, 144}; | 10 const uint8_t gFontSizeSteps[] = { 4, 6, 8, 9, 10, 12, 14, 18, 20, 25,
30, 35, 40, 45, 50, 55, 60, 70, 80, 90, 100, 110, 120, 130, 144}; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 } | 88 } |
| 89 CPVT_WordPlace CSection::AddLine(const CPVT_LineInfo & lineinfo) | 89 CPVT_WordPlace CSection::AddLine(const CPVT_LineInfo & lineinfo) |
| 90 { | 90 { |
| 91 return CPVT_WordPlace(SecPlace.nSecIndex, m_LineArray.Add(lineinfo), -1); | 91 return CPVT_WordPlace(SecPlace.nSecIndex, m_LineArray.Add(lineinfo), -1); |
| 92 } | 92 } |
| 93 CPVT_FloatRect CSection::Rearrange() | 93 CPVT_FloatRect CSection::Rearrange() |
| 94 { | 94 { |
| 95 ASSERT(m_pVT != NULL); | 95 ASSERT(m_pVT != NULL); |
| 96 if (m_pVT->m_nCharArray > 0) { | 96 if (m_pVT->m_nCharArray > 0) { |
| 97 return CTypeset(this).CharArray(); | 97 return CTypeset(this).CharArray(); |
| 98 } else { | |
| 99 return CTypeset(this).Typeset(); | |
| 100 } | 98 } |
| 99 return CTypeset(this).Typeset(); |
| 101 } | 100 } |
| 102 CPVT_Size CSection::GetSectionSize(FX_FLOAT fFontSize) | 101 CPVT_Size CSection::GetSectionSize(FX_FLOAT fFontSize) |
| 103 { | 102 { |
| 104 return CTypeset(this).GetEditSize(fFontSize); | 103 return CTypeset(this).GetEditSize(fFontSize); |
| 105 } | 104 } |
| 106 CPVT_WordPlace CSection::GetBeginWordPlace() const | 105 CPVT_WordPlace CSection::GetBeginWordPlace() const |
| 107 { | 106 { |
| 108 if (CLine * pLine = m_LineArray.GetAt(0)) { | 107 if (CLine * pLine = m_LineArray.GetAt(0)) { |
| 109 return pLine->GetBeginWordPlace(); | 108 return pLine->GetBeginWordPlace(); |
| 110 } else { | |
| 111 return SecPlace; | |
| 112 } | 109 } |
| 110 return SecPlace; |
| 113 } | 111 } |
| 114 CPVT_WordPlace CSection::GetEndWordPlace() const | 112 CPVT_WordPlace CSection::GetEndWordPlace() const |
| 115 { | 113 { |
| 116 if (CLine * pLine = m_LineArray.GetAt(m_LineArray.GetSize() - 1)) { | 114 if (CLine * pLine = m_LineArray.GetAt(m_LineArray.GetSize() - 1)) { |
| 117 return pLine->GetEndWordPlace(); | 115 return pLine->GetEndWordPlace(); |
| 118 } else { | |
| 119 return SecPlace; | |
| 120 } | 116 } |
| 117 return SecPlace; |
| 121 } | 118 } |
| 122 CPVT_WordPlace CSection::GetPrevWordPlace(const CPVT_WordPlace & place) const | 119 CPVT_WordPlace CSection::GetPrevWordPlace(const CPVT_WordPlace & place) const |
| 123 { | 120 { |
| 124 if (place.nLineIndex < 0) { | 121 if (place.nLineIndex < 0) { |
| 125 return GetBeginWordPlace(); | 122 return GetBeginWordPlace(); |
| 126 } | 123 } |
| 127 if (place.nLineIndex >= m_LineArray.GetSize()) { | 124 if (place.nLineIndex >= m_LineArray.GetSize()) { |
| 128 return GetEndWordPlace(); | 125 return GetEndWordPlace(); |
| 129 } | 126 } |
| 130 if (CLine * pLine = m_LineArray.GetAt(place.nLineIndex)) { | 127 if (CLine * pLine = m_LineArray.GetAt(place.nLineIndex)) { |
| 131 if (place.nWordIndex == pLine->m_LineInfo.nBeginWordIndex) { | 128 if (place.nWordIndex == pLine->m_LineInfo.nBeginWordIndex) { |
| 132 return CPVT_WordPlace(place.nSecIndex, place.nLineIndex, -1); | 129 return CPVT_WordPlace(place.nSecIndex, place.nLineIndex, -1); |
| 133 } else if (place.nWordIndex < pLine->m_LineInfo.nBeginWordIndex) { | 130 } |
| 131 if (place.nWordIndex < pLine->m_LineInfo.nBeginWordIndex) { |
| 134 if (CLine * pPrevLine = m_LineArray.GetAt(place.nLineIndex - 1)) { | 132 if (CLine * pPrevLine = m_LineArray.GetAt(place.nLineIndex - 1)) { |
| 135 return pPrevLine->GetEndWordPlace(); | 133 return pPrevLine->GetEndWordPlace(); |
| 136 } | 134 } |
| 137 } else { | 135 } else { |
| 138 return pLine->GetPrevWordPlace(place); | 136 return pLine->GetPrevWordPlace(place); |
| 139 } | 137 } |
| 140 } | 138 } |
| 141 return place; | 139 return place; |
| 142 } | 140 } |
| 143 CPVT_WordPlace CSection::GetNextWordPlace(const CPVT_WordPlace & place) const | 141 CPVT_WordPlace CSection::GetNextWordPlace(const CPVT_WordPlace & place) const |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 return FALSE; | 562 return FALSE; |
| 565 } | 563 } |
| 566 static FX_BOOL IsSpace(FX_WORD word) | 564 static FX_BOOL IsSpace(FX_WORD word) |
| 567 { | 565 { |
| 568 return (word == 0x0020 || word == 0x3000) ? TRUE : FALSE; | 566 return (word == 0x0020 || word == 0x3000) ? TRUE : FALSE; |
| 569 } | 567 } |
| 570 static FX_BOOL NeedDivision(FX_WORD prevWord, FX_WORD curWord) | 568 static FX_BOOL NeedDivision(FX_WORD prevWord, FX_WORD curWord) |
| 571 { | 569 { |
| 572 if ((IsLatin(prevWord) || IsDigit(prevWord)) && (IsLatin(curWord) || IsDigit
(curWord))) { | 570 if ((IsLatin(prevWord) || IsDigit(prevWord)) && (IsLatin(curWord) || IsDigit
(curWord))) { |
| 573 return FALSE; | 571 return FALSE; |
| 574 } else if (IsSpace(curWord) || IsPunctuation(curWord)) { | 572 } |
| 573 if (IsSpace(curWord) || IsPunctuation(curWord)) { |
| 575 return FALSE; | 574 return FALSE; |
| 576 } else if (IsConnectiveSymbol(prevWord) || IsConnectiveSymbol(curWord)) { | 575 } |
| 576 if (IsConnectiveSymbol(prevWord) || IsConnectiveSymbol(curWord)) { |
| 577 return FALSE; | 577 return FALSE; |
| 578 } else if (IsSpace(prevWord) || IsPunctuation(prevWord)) { | 578 } |
| 579 if (IsSpace(prevWord) || IsPunctuation(prevWord)) { |
| 579 return TRUE; | 580 return TRUE; |
| 580 } else if (IsPrefixSymbol(prevWord)) { | 581 } |
| 582 if (IsPrefixSymbol(prevWord)) { |
| 581 return FALSE; | 583 return FALSE; |
| 582 } else if (IsPrefixSymbol(curWord) || IsCJK(curWord)) { | 584 } |
| 585 if (IsPrefixSymbol(curWord) || IsCJK(curWord)) { |
| 583 return TRUE; | 586 return TRUE; |
| 584 } else if (IsCJK(prevWord)) { | 587 } |
| 588 if (IsCJK(prevWord)) { |
| 585 return TRUE; | 589 return TRUE; |
| 586 } | 590 } |
| 587 return FALSE; | 591 return FALSE; |
| 588 } | 592 } |
| 589 void CTypeset::SplitLines(FX_BOOL bTypeset, FX_FLOAT fFontSize) | 593 void CTypeset::SplitLines(FX_BOOL bTypeset, FX_FLOAT fFontSize) |
| 590 { | 594 { |
| 591 ASSERT(m_pVT != NULL); | 595 ASSERT(m_pVT != NULL); |
| 592 ASSERT(m_pSection != NULL); | 596 ASSERT(m_pSection != NULL); |
| 593 int32_t nLineHead = 0; | 597 int32_t nLineHead = 0; |
| 594 int32_t nLineTail = 0; | 598 int32_t nLineTail = 0; |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 } | 865 } |
| 862 if (m_nCharArray > 0 && nTotlaWords >= m_nCharArray) { | 866 if (m_nCharArray > 0 && nTotlaWords >= m_nCharArray) { |
| 863 return place; | 867 return place; |
| 864 } | 868 } |
| 865 CPVT_WordPlace newplace = place; | 869 CPVT_WordPlace newplace = place; |
| 866 newplace.nWordIndex ++; | 870 newplace.nWordIndex ++; |
| 867 if (m_bRichText) { | 871 if (m_bRichText) { |
| 868 CPVT_WordProps * pNewProps = pWordProps ? new CPVT_WordProps(*pWordProps
) : new CPVT_WordProps(); | 872 CPVT_WordProps * pNewProps = pWordProps ? new CPVT_WordProps(*pWordProps
) : new CPVT_WordProps(); |
| 869 pNewProps->nFontIndex = GetWordFontIndex(word, charset, pWordProps->nFon
tIndex); | 873 pNewProps->nFontIndex = GetWordFontIndex(word, charset, pWordProps->nFon
tIndex); |
| 870 return AddWord(newplace, CPVT_WordInfo(word, charset, -1, pNewProps)); | 874 return AddWord(newplace, CPVT_WordInfo(word, charset, -1, pNewProps)); |
| 871 } else { | |
| 872 int32_t nFontIndex = GetSubWord() > 0 ? GetDefaultFontIndex() : GetWordF
ontIndex(word, charset, GetDefaultFontIndex()); | |
| 873 return AddWord(newplace, CPVT_WordInfo(word, charset, nFontIndex, NULL))
; | |
| 874 } | 875 } |
| 875 return place; | 876 int32_t nFontIndex = GetSubWord() > 0 ? GetDefaultFontIndex() : GetWordFontI
ndex(word, charset, GetDefaultFontIndex()); |
| 877 return AddWord(newplace, CPVT_WordInfo(word, charset, nFontIndex, NULL)); |
| 876 } | 878 } |
| 877 CPVT_WordPlace CPDF_VariableText::InsertSection(const CPVT_WordPlace & place, co
nst CPVT_SecProps * pSecProps, | 879 CPVT_WordPlace CPDF_VariableText::InsertSection(const CPVT_WordPlace & place, co
nst CPVT_SecProps * pSecProps, |
| 878 const CPVT_WordProps * pWordProps) | 880 const CPVT_WordProps * pWordProps) |
| 879 { | 881 { |
| 880 int32_t nTotlaWords = GetTotalWords(); | 882 int32_t nTotlaWords = GetTotalWords(); |
| 881 if (m_nLimitChar > 0 && nTotlaWords >= m_nLimitChar) { | 883 if (m_nLimitChar > 0 && nTotlaWords >= m_nLimitChar) { |
| 882 return place; | 884 return place; |
| 883 } | 885 } |
| 884 if (m_nCharArray > 0 && nTotlaWords >= m_nCharArray) { | 886 if (m_nCharArray > 0 && nTotlaWords >= m_nCharArray) { |
| 885 return place; | 887 return place; |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1113 if( place.nSecIndex < 0) { | 1115 if( place.nSecIndex < 0) { |
| 1114 return GetBeginWordPlace(); | 1116 return GetBeginWordPlace(); |
| 1115 } | 1117 } |
| 1116 if (place.nSecIndex >= m_SectionArray.GetSize()) { | 1118 if (place.nSecIndex >= m_SectionArray.GetSize()) { |
| 1117 return GetEndWordPlace(); | 1119 return GetEndWordPlace(); |
| 1118 } | 1120 } |
| 1119 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) { | 1121 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) { |
| 1120 if (place.WordCmp(pSection->GetBeginWordPlace()) <= 0) { | 1122 if (place.WordCmp(pSection->GetBeginWordPlace()) <= 0) { |
| 1121 if (CSection * pPrevSection = m_SectionArray.GetAt(place.nSecIndex -
1)) { | 1123 if (CSection * pPrevSection = m_SectionArray.GetAt(place.nSecIndex -
1)) { |
| 1122 return pPrevSection->GetEndWordPlace(); | 1124 return pPrevSection->GetEndWordPlace(); |
| 1123 } else { | |
| 1124 return GetBeginWordPlace(); | |
| 1125 } | 1125 } |
| 1126 } else { | 1126 return GetBeginWordPlace(); |
| 1127 return pSection->GetPrevWordPlace(place); | |
| 1128 } | 1127 } |
| 1128 return pSection->GetPrevWordPlace(place); |
| 1129 } | 1129 } |
| 1130 return place; | 1130 return place; |
| 1131 } | 1131 } |
| 1132 CPVT_WordPlace CPDF_VariableText::GetNextWordPlace(const CPVT_WordPlace & place)
const | 1132 CPVT_WordPlace CPDF_VariableText::GetNextWordPlace(const CPVT_WordPlace & place)
const |
| 1133 { | 1133 { |
| 1134 if (place.nSecIndex < 0) { | 1134 if (place.nSecIndex < 0) { |
| 1135 return GetBeginWordPlace(); | 1135 return GetBeginWordPlace(); |
| 1136 } | 1136 } |
| 1137 if (place.nSecIndex >= m_SectionArray.GetSize()) { | 1137 if (place.nSecIndex >= m_SectionArray.GetSize()) { |
| 1138 return GetEndWordPlace(); | 1138 return GetEndWordPlace(); |
| 1139 } | 1139 } |
| 1140 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) { | 1140 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) { |
| 1141 if (place.WordCmp(pSection->GetEndWordPlace()) >= 0) { | 1141 if (place.WordCmp(pSection->GetEndWordPlace()) >= 0) { |
| 1142 if (CSection * pNextSection = m_SectionArray.GetAt(place.nSecIndex +
1)) { | 1142 if (CSection * pNextSection = m_SectionArray.GetAt(place.nSecIndex +
1)) { |
| 1143 return pNextSection->GetBeginWordPlace(); | 1143 return pNextSection->GetBeginWordPlace(); |
| 1144 } else { | |
| 1145 return GetEndWordPlace(); | |
| 1146 } | 1144 } |
| 1147 } else { | 1145 return GetEndWordPlace(); |
| 1148 return pSection->GetNextWordPlace(place); | |
| 1149 } | 1146 } |
| 1147 return pSection->GetNextWordPlace(place); |
| 1150 } | 1148 } |
| 1151 return place; | 1149 return place; |
| 1152 } | 1150 } |
| 1153 CPVT_WordPlace CPDF_VariableText::SearchWordPlace(const CPDF_Point & point) cons
t | 1151 CPVT_WordPlace CPDF_VariableText::SearchWordPlace(const CPDF_Point & point) cons
t |
| 1154 { | 1152 { |
| 1155 CPDF_Point pt = OutToIn(point); | 1153 CPDF_Point pt = OutToIn(point); |
| 1156 CPVT_WordPlace place = GetBeginWordPlace(); | 1154 CPVT_WordPlace place = GetBeginWordPlace(); |
| 1157 int32_t nLeft = 0; | 1155 int32_t nLeft = 0; |
| 1158 int32_t nRight = m_SectionArray.GetSize() - 1; | 1156 int32_t nRight = m_SectionArray.GetSize() - 1; |
| 1159 int32_t nMid = m_SectionArray.GetSize() / 2; | 1157 int32_t nMid = m_SectionArray.GetSize() / 2; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1194 } | 1192 } |
| 1195 return place; | 1193 return place; |
| 1196 } | 1194 } |
| 1197 CPVT_WordPlace CPDF_VariableText::GetUpWordPlace(const CPVT_WordPlace & place, c
onst CPDF_Point & point) const | 1195 CPVT_WordPlace CPDF_VariableText::GetUpWordPlace(const CPVT_WordPlace & place, c
onst CPDF_Point & point) const |
| 1198 { | 1196 { |
| 1199 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) { | 1197 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) { |
| 1200 CPVT_WordPlace temp = place; | 1198 CPVT_WordPlace temp = place; |
| 1201 CPDF_Point pt = OutToIn(point); | 1199 CPDF_Point pt = OutToIn(point); |
| 1202 if (temp.nLineIndex-- > 0) { | 1200 if (temp.nLineIndex-- > 0) { |
| 1203 return pSection->SearchWordPlace(pt.x - pSection->m_SecInfo.rcSectio
n.left, temp); | 1201 return pSection->SearchWordPlace(pt.x - pSection->m_SecInfo.rcSectio
n.left, temp); |
| 1204 } else { | 1202 } |
| 1205 if (temp.nSecIndex-- > 0) { | 1203 if (temp.nSecIndex-- > 0) { |
| 1206 if (CSection * pLastSection = m_SectionArray.GetAt(temp.nSecInde
x)) { | 1204 if (CSection * pLastSection = m_SectionArray.GetAt(temp.nSecIndex))
{ |
| 1207 temp.nLineIndex = pLastSection->m_LineArray.GetSize() - 1; | 1205 temp.nLineIndex = pLastSection->m_LineArray.GetSize() - 1; |
| 1208 return pLastSection->SearchWordPlace(pt.x - pLastSection->m_
SecInfo.rcSection.left, temp); | 1206 return pLastSection->SearchWordPlace(pt.x - pLastSection->m_SecI
nfo.rcSection.left, temp); |
| 1209 } | |
| 1210 } | 1207 } |
| 1211 } | 1208 } |
| 1212 } | 1209 } |
| 1213 return place; | 1210 return place; |
| 1214 } | 1211 } |
| 1215 CPVT_WordPlace CPDF_VariableText::GetDownWordPlace(const CPVT_WordPlace & place,
const CPDF_Point & point) const | 1212 CPVT_WordPlace CPDF_VariableText::GetDownWordPlace(const CPVT_WordPlace & place,
const CPDF_Point & point) const |
| 1216 { | 1213 { |
| 1217 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) { | 1214 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) { |
| 1218 CPVT_WordPlace temp = place; | 1215 CPVT_WordPlace temp = place; |
| 1219 CPDF_Point pt = OutToIn(point); | 1216 CPDF_Point pt = OutToIn(point); |
| 1220 if (temp.nLineIndex++ < pSection->m_LineArray.GetSize() - 1) { | 1217 if (temp.nLineIndex++ < pSection->m_LineArray.GetSize() - 1) { |
| 1221 return pSection->SearchWordPlace(pt.x - pSection->m_SecInfo.rcSectio
n.left, temp); | 1218 return pSection->SearchWordPlace(pt.x - pSection->m_SecInfo.rcSectio
n.left, temp); |
| 1222 } else { | 1219 } |
| 1223 if (temp.nSecIndex++ < m_SectionArray.GetSize() - 1) { | 1220 if (temp.nSecIndex++ < m_SectionArray.GetSize() - 1) { |
| 1224 if (CSection * pNextSection = m_SectionArray.GetAt(temp.nSecInde
x)) { | 1221 if (CSection * pNextSection = m_SectionArray.GetAt(temp.nSecIndex))
{ |
| 1225 temp.nLineIndex = 0; | 1222 temp.nLineIndex = 0; |
| 1226 return pNextSection->SearchWordPlace(pt.x - pSection->m_SecI
nfo.rcSection.left, temp); | 1223 return pNextSection->SearchWordPlace(pt.x - pSection->m_SecInfo.
rcSection.left, temp); |
| 1227 } | |
| 1228 } | 1224 } |
| 1229 } | 1225 } |
| 1230 } | 1226 } |
| 1231 return place; | 1227 return place; |
| 1232 } | 1228 } |
| 1233 CPVT_WordPlace CPDF_VariableText::GetLineBeginPlace(const CPVT_WordPlace & place
) const | 1229 CPVT_WordPlace CPDF_VariableText::GetLineBeginPlace(const CPVT_WordPlace & place
) const |
| 1234 { | 1230 { |
| 1235 return CPVT_WordPlace(place.nSecIndex, place.nLineIndex, -1); | 1231 return CPVT_WordPlace(place.nSecIndex, place.nLineIndex, -1); |
| 1236 } | 1232 } |
| 1237 CPVT_WordPlace CPDF_VariableText::GetLineEndPlace(const CPVT_WordPlace & place)
const | 1233 CPVT_WordPlace CPDF_VariableText::GetLineEndPlace(const CPVT_WordPlace & place)
const |
| 1238 { | 1234 { |
| 1239 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) | 1235 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { |
| 1240 if (CLine * pLine = pSection->m_LineArray.GetAt(place.nLineIndex)) { | 1236 if (CLine* pLine = pSection->m_LineArray.GetAt(place.nLineIndex)) |
| 1241 return pLine->GetEndWordPlace(); | 1237 return pLine->GetEndWordPlace(); |
| 1242 } | 1238 } |
| 1243 return place; | 1239 return place; |
| 1244 } | 1240 } |
| 1245 CPVT_WordPlace CPDF_VariableText::GetSectionBeginPlace(const CPVT_WordPlace & pl
ace) const | 1241 CPVT_WordPlace CPDF_VariableText::GetSectionBeginPlace(const CPVT_WordPlace & pl
ace) const |
| 1246 { | 1242 { |
| 1247 return CPVT_WordPlace(place.nSecIndex, 0, -1); | 1243 return CPVT_WordPlace(place.nSecIndex, 0, -1); |
| 1248 } | 1244 } |
| 1249 CPVT_WordPlace CPDF_VariableText::GetSectionEndPlace(const CPVT_WordPlace & plac
e) const | 1245 CPVT_WordPlace CPDF_VariableText::GetSectionEndPlace(const CPVT_WordPlace & plac
e) const |
| 1250 { | 1246 { |
| 1251 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) { | 1247 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) { |
| 1252 return pSection->GetEndWordPlace(); | 1248 return pSection->GetEndWordPlace(); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1429 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) { | 1425 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) { |
| 1430 for (int32_t w = pSection->m_WordArray.GetSize() - 1; w > wordplace.nWor
dIndex; w--) { | 1426 for (int32_t w = pSection->m_WordArray.GetSize() - 1; w > wordplace.nWor
dIndex; w--) { |
| 1431 delete pSection->m_WordArray.GetAt(w); | 1427 delete pSection->m_WordArray.GetAt(w); |
| 1432 pSection->m_WordArray.RemoveAt(w); | 1428 pSection->m_WordArray.RemoveAt(w); |
| 1433 } | 1429 } |
| 1434 } | 1430 } |
| 1435 } | 1431 } |
| 1436 CPVT_WordPlace CPDF_VariableText::AjustLineHeader(const CPVT_WordPlace & place,
FX_BOOL bPrevOrNext) const | 1432 CPVT_WordPlace CPDF_VariableText::AjustLineHeader(const CPVT_WordPlace & place,
FX_BOOL bPrevOrNext) const |
| 1437 { | 1433 { |
| 1438 if (place.nWordIndex < 0 && place.nLineIndex > 0) { | 1434 if (place.nWordIndex < 0 && place.nLineIndex > 0) { |
| 1439 if (bPrevOrNext) { | 1435 return bPrevOrNext ? GetPrevWordPlace(place) : GetNextWordPlace(place); |
| 1440 return GetPrevWordPlace(place); | |
| 1441 } else { | |
| 1442 return GetNextWordPlace(place); | |
| 1443 } | |
| 1444 } | 1436 } |
| 1445 return place; | 1437 return place; |
| 1446 } | 1438 } |
| 1447 FX_BOOL CPDF_VariableText::ClearEmptySection(const CPVT_WordPlace & place) | 1439 FX_BOOL CPDF_VariableText::ClearEmptySection(const CPVT_WordPlace & place) |
| 1448 { | 1440 { |
| 1449 if (place.nSecIndex == 0 && m_SectionArray.GetSize() == 1) { | 1441 if (place.nSecIndex == 0 && m_SectionArray.GetSize() == 1) { |
| 1450 return FALSE; | 1442 return FALSE; |
| 1451 } | 1443 } |
| 1452 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) { | 1444 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) { |
| 1453 if (pSection->m_WordArray.GetSize() == 0) { | 1445 if (pSection->m_WordArray.GetSize() == 0) { |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1629 rcRet.right = FPDF_MAX(rcSec.right, rcRet.right); | 1621 rcRet.right = FPDF_MAX(rcSec.right, rcRet.right); |
| 1630 rcRet.bottom = FPDF_MAX(rcSec.bottom, rcRet.bottom); | 1622 rcRet.bottom = FPDF_MAX(rcSec.bottom, rcRet.bottom); |
| 1631 } | 1623 } |
| 1632 fPosY += rcSec.Height(); | 1624 fPosY += rcSec.Height(); |
| 1633 } | 1625 } |
| 1634 } | 1626 } |
| 1635 return rcRet; | 1627 return rcRet; |
| 1636 } | 1628 } |
| 1637 int32_t CPDF_VariableText::GetCharWidth(int32_t nFontIndex, FX_WORD Word, FX_WOR
D SubWord, int32_t nWordStyle) | 1629 int32_t CPDF_VariableText::GetCharWidth(int32_t nFontIndex, FX_WORD Word, FX_WOR
D SubWord, int32_t nWordStyle) |
| 1638 { | 1630 { |
| 1639 if (m_pVTProvider) { | 1631 if (!m_pVTProvider) { |
| 1640 if (SubWord > 0) { | 1632 return 0; |
| 1641 return m_pVTProvider->GetCharWidth(nFontIndex, SubWord, nWordStyle); | |
| 1642 } else { | |
| 1643 return m_pVTProvider->GetCharWidth(nFontIndex, Word, nWordStyle); | |
| 1644 } | |
| 1645 } | 1633 } |
| 1646 return 0; | 1634 if (SubWord > 0) { |
| 1635 return m_pVTProvider->GetCharWidth(nFontIndex, SubWord, nWordStyle); |
| 1636 } |
| 1637 return m_pVTProvider->GetCharWidth(nFontIndex, Word, nWordStyle); |
| 1647 } | 1638 } |
| 1648 int32_t CPDF_VariableText::GetTypeAscent(int32_t nFontIndex) | 1639 int32_t CPDF_VariableText::GetTypeAscent(int32_t nFontIndex) |
| 1649 { | 1640 { |
| 1650 return m_pVTProvider ? m_pVTProvider->GetTypeAscent(nFontIndex) : 0; | 1641 return m_pVTProvider ? m_pVTProvider->GetTypeAscent(nFontIndex) : 0; |
| 1651 } | 1642 } |
| 1652 int32_t CPDF_VariableText::GetTypeDescent(int32_t nFontIndex) | 1643 int32_t CPDF_VariableText::GetTypeDescent(int32_t nFontIndex) |
| 1653 { | 1644 { |
| 1654 return m_pVTProvider ? m_pVTProvider->GetTypeDescent(nFontIndex) : 0; | 1645 return m_pVTProvider ? m_pVTProvider->GetTypeDescent(nFontIndex) : 0; |
| 1655 } | 1646 } |
| 1656 int32_t CPDF_VariableText::GetWordFontIndex(FX_WORD word, int32_t charset, int32
_t nFontIndex) | 1647 int32_t CPDF_VariableText::GetWordFontIndex(FX_WORD word, int32_t charset, int32
_t nFontIndex) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1691 ASSERT(m_pVT != NULL); | 1682 ASSERT(m_pVT != NULL); |
| 1692 m_CurPos = m_pVT->WordIndexToWordPlace(nWordIndex); | 1683 m_CurPos = m_pVT->WordIndexToWordPlace(nWordIndex); |
| 1693 } | 1684 } |
| 1694 void CPDF_VariableText_Iterator::SetAt(const CPVT_WordPlace & place) | 1685 void CPDF_VariableText_Iterator::SetAt(const CPVT_WordPlace & place) |
| 1695 { | 1686 { |
| 1696 ASSERT(m_pVT != NULL); | 1687 ASSERT(m_pVT != NULL); |
| 1697 m_CurPos = place; | 1688 m_CurPos = place; |
| 1698 } | 1689 } |
| 1699 FX_BOOL CPDF_VariableText_Iterator::NextWord() | 1690 FX_BOOL CPDF_VariableText_Iterator::NextWord() |
| 1700 { | 1691 { |
| 1701 ASSERT(m_pVT != NULL); | |
| 1702 if (m_CurPos == m_pVT->GetEndWordPlace()) { | 1692 if (m_CurPos == m_pVT->GetEndWordPlace()) { |
| 1703 return FALSE; | 1693 return FALSE; |
| 1704 } | 1694 } |
| 1705 m_CurPos = m_pVT->GetNextWordPlace(m_CurPos); | 1695 m_CurPos = m_pVT->GetNextWordPlace(m_CurPos); |
| 1706 return TRUE; | 1696 return TRUE; |
| 1707 } | 1697 } |
| 1708 FX_BOOL CPDF_VariableText_Iterator::PrevWord() | 1698 FX_BOOL CPDF_VariableText_Iterator::PrevWord() |
| 1709 { | 1699 { |
| 1710 ASSERT(m_pVT != NULL); | |
| 1711 if (m_CurPos == m_pVT->GetBeginWordPlace()) { | 1700 if (m_CurPos == m_pVT->GetBeginWordPlace()) { |
| 1712 return FALSE; | 1701 return FALSE; |
| 1713 } | 1702 } |
| 1714 m_CurPos = m_pVT->GetPrevWordPlace(m_CurPos); | 1703 m_CurPos = m_pVT->GetPrevWordPlace(m_CurPos); |
| 1715 return TRUE; | 1704 return TRUE; |
| 1716 } | 1705 } |
| 1717 FX_BOOL CPDF_VariableText_Iterator::NextLine() | 1706 FX_BOOL CPDF_VariableText_Iterator::NextLine() |
| 1718 { | 1707 { |
| 1719 ASSERT(m_pVT != NULL); | |
| 1720 if (CSection * pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { | 1708 if (CSection * pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { |
| 1721 if (m_CurPos.nLineIndex < pSection->m_LineArray.GetSize() - 1) { | 1709 if (m_CurPos.nLineIndex < pSection->m_LineArray.GetSize() - 1) { |
| 1722 m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex, m_CurPos.nLineIndex +
1, -1); | 1710 m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex, m_CurPos.nLineIndex +
1, -1); |
| 1723 return TRUE; | 1711 return TRUE; |
| 1724 } else { | 1712 } |
| 1725 if (m_CurPos.nSecIndex < m_pVT->m_SectionArray.GetSize() - 1) { | 1713 if (m_CurPos.nSecIndex < m_pVT->m_SectionArray.GetSize() - 1) { |
| 1726 m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex + 1, 0, -1); | 1714 m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex + 1, 0, -1); |
| 1727 return TRUE; | 1715 return TRUE; |
| 1728 } | |
| 1729 } | 1716 } |
| 1730 } | 1717 } |
| 1731 return FALSE; | 1718 return FALSE; |
| 1732 } | 1719 } |
| 1733 FX_BOOL CPDF_VariableText_Iterator::PrevLine() | 1720 FX_BOOL CPDF_VariableText_Iterator::PrevLine() |
| 1734 { | 1721 { |
| 1735 ASSERT(m_pVT != NULL); | |
| 1736 if (m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { | 1722 if (m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { |
| 1737 if (m_CurPos.nLineIndex > 0) { | 1723 if (m_CurPos.nLineIndex > 0) { |
| 1738 m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex, m_CurPos.nLineIndex -
1, -1); | 1724 m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex, m_CurPos.nLineIndex -
1, -1); |
| 1739 return TRUE; | 1725 return TRUE; |
| 1740 } else { | 1726 } |
| 1741 if (m_CurPos.nSecIndex > 0) { | 1727 if (m_CurPos.nSecIndex > 0) { |
| 1742 if (CSection * pLastSection = m_pVT->m_SectionArray.GetAt(m_CurP
os.nSecIndex - 1)) { | 1728 if (CSection * pLastSection = m_pVT->m_SectionArray.GetAt(m_CurPos.n
SecIndex - 1)) { |
| 1743 m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex - 1, pLastSecti
on->m_LineArray.GetSize() - 1, -1); | 1729 m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex - 1, pLastSection->
m_LineArray.GetSize() - 1, -1); |
| 1744 return TRUE; | 1730 return TRUE; |
| 1745 } | |
| 1746 } | 1731 } |
| 1747 } | 1732 } |
| 1748 } | 1733 } |
| 1749 return FALSE; | 1734 return FALSE; |
| 1750 } | 1735 } |
| 1751 FX_BOOL CPDF_VariableText_Iterator::NextSection() | 1736 FX_BOOL CPDF_VariableText_Iterator::NextSection() |
| 1752 { | 1737 { |
| 1753 ASSERT(m_pVT != NULL); | |
| 1754 if (m_CurPos.nSecIndex < m_pVT->m_SectionArray.GetSize() - 1) { | 1738 if (m_CurPos.nSecIndex < m_pVT->m_SectionArray.GetSize() - 1) { |
| 1755 m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex + 1, 0, -1); | 1739 m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex + 1, 0, -1); |
| 1756 return TRUE; | 1740 return TRUE; |
| 1757 } | 1741 } |
| 1758 return FALSE; | 1742 return FALSE; |
| 1759 } | 1743 } |
| 1760 FX_BOOL CPDF_VariableText_Iterator::PrevSection() | 1744 FX_BOOL CPDF_VariableText_Iterator::PrevSection() |
| 1761 { | 1745 { |
| 1762 ASSERT(m_pVT != NULL); | 1746 ASSERT(m_pVT != NULL); |
| 1763 if (m_CurPos.nSecIndex > 0) { | 1747 if (m_CurPos.nSecIndex > 0) { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1846 if (pSection->m_SecInfo.pSecProps) { | 1830 if (pSection->m_SecInfo.pSecProps) { |
| 1847 *pSection->m_SecInfo.pSecProps = section.SecProps; | 1831 *pSection->m_SecInfo.pSecProps = section.SecProps; |
| 1848 } | 1832 } |
| 1849 if (pSection->m_SecInfo.pWordProps) { | 1833 if (pSection->m_SecInfo.pWordProps) { |
| 1850 *pSection->m_SecInfo.pWordProps = section.WordProps; | 1834 *pSection->m_SecInfo.pWordProps = section.WordProps; |
| 1851 } | 1835 } |
| 1852 return TRUE; | 1836 return TRUE; |
| 1853 } | 1837 } |
| 1854 return FALSE; | 1838 return FALSE; |
| 1855 } | 1839 } |
| OLD | NEW |