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