| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/fpdfdoc/cpdf_variabletext.h" | 7 #include "core/fpdfdoc/cpdf_variabletext.h" |
| 8 | 8 |
| 9 #include "core/fpdfapi/font/cpdf_font.h" | 9 #include "core/fpdfapi/font/cpdf_font.h" |
| 10 #include "core/fpdfdoc/cline.h" | 10 #include "core/fpdfdoc/cline.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 if (pDefFont->CharCodeFromUnicode(word) != CPDF_Font::kInvalidCharCode) | 62 if (pDefFont->CharCodeFromUnicode(word) != CPDF_Font::kInvalidCharCode) |
| 63 return 0; | 63 return 0; |
| 64 } | 64 } |
| 65 if (CPDF_Font* pSysFont = m_pFontMap->GetPDFFont(1)) { | 65 if (CPDF_Font* pSysFont = m_pFontMap->GetPDFFont(1)) { |
| 66 if (pSysFont->CharCodeFromUnicode(word) != CPDF_Font::kInvalidCharCode) | 66 if (pSysFont->CharCodeFromUnicode(word) != CPDF_Font::kInvalidCharCode) |
| 67 return 1; | 67 return 1; |
| 68 } | 68 } |
| 69 return -1; | 69 return -1; |
| 70 } | 70 } |
| 71 | 71 |
| 72 FX_BOOL CPDF_VariableText::Provider::IsLatinWord(uint16_t word) { | 72 bool CPDF_VariableText::Provider::IsLatinWord(uint16_t word) { |
| 73 return (word >= 0x61 && word <= 0x7A) || (word >= 0x41 && word <= 0x5A) || | 73 return (word >= 0x61 && word <= 0x7A) || (word >= 0x41 && word <= 0x5A) || |
| 74 word == 0x2D || word == 0x27; | 74 word == 0x2D || word == 0x27; |
| 75 } | 75 } |
| 76 | 76 |
| 77 int32_t CPDF_VariableText::Provider::GetDefaultFontIndex() { | 77 int32_t CPDF_VariableText::Provider::GetDefaultFontIndex() { |
| 78 return 0; | 78 return 0; |
| 79 } | 79 } |
| 80 | 80 |
| 81 CPDF_VariableText::Iterator::Iterator(CPDF_VariableText* pVT) | 81 CPDF_VariableText::Iterator::Iterator(CPDF_VariableText* pVT) |
| 82 : m_CurPos(-1, -1, -1), m_pVT(pVT) {} | 82 : m_CurPos(-1, -1, -1), m_pVT(pVT) {} |
| 83 | 83 |
| 84 CPDF_VariableText::Iterator::~Iterator() {} | 84 CPDF_VariableText::Iterator::~Iterator() {} |
| 85 | 85 |
| 86 void CPDF_VariableText::Iterator::SetAt(int32_t nWordIndex) { | 86 void CPDF_VariableText::Iterator::SetAt(int32_t nWordIndex) { |
| 87 m_CurPos = m_pVT->WordIndexToWordPlace(nWordIndex); | 87 m_CurPos = m_pVT->WordIndexToWordPlace(nWordIndex); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void CPDF_VariableText::Iterator::SetAt(const CPVT_WordPlace& place) { | 90 void CPDF_VariableText::Iterator::SetAt(const CPVT_WordPlace& place) { |
| 91 ASSERT(m_pVT); | 91 ASSERT(m_pVT); |
| 92 m_CurPos = place; | 92 m_CurPos = place; |
| 93 } | 93 } |
| 94 | 94 |
| 95 FX_BOOL CPDF_VariableText::Iterator::NextWord() { | 95 bool CPDF_VariableText::Iterator::NextWord() { |
| 96 if (m_CurPos == m_pVT->GetEndWordPlace()) | 96 if (m_CurPos == m_pVT->GetEndWordPlace()) |
| 97 return FALSE; | 97 return false; |
| 98 | 98 |
| 99 m_CurPos = m_pVT->GetNextWordPlace(m_CurPos); | 99 m_CurPos = m_pVT->GetNextWordPlace(m_CurPos); |
| 100 return TRUE; | 100 return true; |
| 101 } | 101 } |
| 102 | 102 |
| 103 FX_BOOL CPDF_VariableText::Iterator::PrevWord() { | 103 bool CPDF_VariableText::Iterator::PrevWord() { |
| 104 if (m_CurPos == m_pVT->GetBeginWordPlace()) | 104 if (m_CurPos == m_pVT->GetBeginWordPlace()) |
| 105 return FALSE; | 105 return false; |
| 106 | 106 |
| 107 m_CurPos = m_pVT->GetPrevWordPlace(m_CurPos); | 107 m_CurPos = m_pVT->GetPrevWordPlace(m_CurPos); |
| 108 return TRUE; | 108 return true; |
| 109 } | 109 } |
| 110 | 110 |
| 111 FX_BOOL CPDF_VariableText::Iterator::NextLine() { | 111 bool CPDF_VariableText::Iterator::NextLine() { |
| 112 if (CSection* pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { | 112 if (CSection* pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { |
| 113 if (m_CurPos.nLineIndex < pSection->m_LineArray.GetSize() - 1) { | 113 if (m_CurPos.nLineIndex < pSection->m_LineArray.GetSize() - 1) { |
| 114 m_CurPos = | 114 m_CurPos = |
| 115 CPVT_WordPlace(m_CurPos.nSecIndex, m_CurPos.nLineIndex + 1, -1); | 115 CPVT_WordPlace(m_CurPos.nSecIndex, m_CurPos.nLineIndex + 1, -1); |
| 116 return TRUE; | 116 return true; |
| 117 } | 117 } |
| 118 if (m_CurPos.nSecIndex < m_pVT->m_SectionArray.GetSize() - 1) { | 118 if (m_CurPos.nSecIndex < m_pVT->m_SectionArray.GetSize() - 1) { |
| 119 m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex + 1, 0, -1); | 119 m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex + 1, 0, -1); |
| 120 return TRUE; | 120 return true; |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 return FALSE; | 123 return false; |
| 124 } | 124 } |
| 125 | 125 |
| 126 FX_BOOL CPDF_VariableText::Iterator::PrevLine() { | 126 bool CPDF_VariableText::Iterator::PrevLine() { |
| 127 if (m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { | 127 if (m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { |
| 128 if (m_CurPos.nLineIndex > 0) { | 128 if (m_CurPos.nLineIndex > 0) { |
| 129 m_CurPos = | 129 m_CurPos = |
| 130 CPVT_WordPlace(m_CurPos.nSecIndex, m_CurPos.nLineIndex - 1, -1); | 130 CPVT_WordPlace(m_CurPos.nSecIndex, m_CurPos.nLineIndex - 1, -1); |
| 131 return TRUE; | 131 return true; |
| 132 } | 132 } |
| 133 if (m_CurPos.nSecIndex > 0) { | 133 if (m_CurPos.nSecIndex > 0) { |
| 134 if (CSection* pLastSection = | 134 if (CSection* pLastSection = |
| 135 m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex - 1)) { | 135 m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex - 1)) { |
| 136 m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex - 1, | 136 m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex - 1, |
| 137 pLastSection->m_LineArray.GetSize() - 1, -1); | 137 pLastSection->m_LineArray.GetSize() - 1, -1); |
| 138 return TRUE; | 138 return true; |
| 139 } | 139 } |
| 140 } | 140 } |
| 141 } | 141 } |
| 142 return FALSE; | 142 return false; |
| 143 } | 143 } |
| 144 | 144 |
| 145 FX_BOOL CPDF_VariableText::Iterator::NextSection() { | 145 bool CPDF_VariableText::Iterator::NextSection() { |
| 146 if (m_CurPos.nSecIndex < m_pVT->m_SectionArray.GetSize() - 1) { | 146 if (m_CurPos.nSecIndex < m_pVT->m_SectionArray.GetSize() - 1) { |
| 147 m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex + 1, 0, -1); | 147 m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex + 1, 0, -1); |
| 148 return TRUE; | 148 return true; |
| 149 } | 149 } |
| 150 return FALSE; | 150 return false; |
| 151 } | 151 } |
| 152 | 152 |
| 153 FX_BOOL CPDF_VariableText::Iterator::PrevSection() { | 153 bool CPDF_VariableText::Iterator::PrevSection() { |
| 154 ASSERT(m_pVT); | 154 ASSERT(m_pVT); |
| 155 if (m_CurPos.nSecIndex > 0) { | 155 if (m_CurPos.nSecIndex > 0) { |
| 156 m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex - 1, 0, -1); | 156 m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex - 1, 0, -1); |
| 157 return TRUE; | 157 return true; |
| 158 } | 158 } |
| 159 return FALSE; | 159 return false; |
| 160 } | 160 } |
| 161 | 161 |
| 162 FX_BOOL CPDF_VariableText::Iterator::GetWord(CPVT_Word& word) const { | 162 bool CPDF_VariableText::Iterator::GetWord(CPVT_Word& word) const { |
| 163 word.WordPlace = m_CurPos; | 163 word.WordPlace = m_CurPos; |
| 164 if (CSection* pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { | 164 if (CSection* pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { |
| 165 if (pSection->m_LineArray.GetAt(m_CurPos.nLineIndex)) { | 165 if (pSection->m_LineArray.GetAt(m_CurPos.nLineIndex)) { |
| 166 if (CPVT_WordInfo* pWord = | 166 if (CPVT_WordInfo* pWord = |
| 167 pSection->m_WordArray.GetAt(m_CurPos.nWordIndex)) { | 167 pSection->m_WordArray.GetAt(m_CurPos.nWordIndex)) { |
| 168 word.Word = pWord->Word; | 168 word.Word = pWord->Word; |
| 169 word.nCharset = pWord->nCharset; | 169 word.nCharset = pWord->nCharset; |
| 170 word.fWidth = m_pVT->GetWordWidth(*pWord); | 170 word.fWidth = m_pVT->GetWordWidth(*pWord); |
| 171 word.ptWord = m_pVT->InToOut( | 171 word.ptWord = m_pVT->InToOut( |
| 172 CFX_FloatPoint(pWord->fWordX + pSection->m_SecInfo.rcSection.left, | 172 CFX_FloatPoint(pWord->fWordX + pSection->m_SecInfo.rcSection.left, |
| 173 pWord->fWordY + pSection->m_SecInfo.rcSection.top)); | 173 pWord->fWordY + pSection->m_SecInfo.rcSection.top)); |
| 174 word.fAscent = m_pVT->GetWordAscent(*pWord); | 174 word.fAscent = m_pVT->GetWordAscent(*pWord); |
| 175 word.fDescent = m_pVT->GetWordDescent(*pWord); | 175 word.fDescent = m_pVT->GetWordDescent(*pWord); |
| 176 if (pWord->pWordProps) | 176 if (pWord->pWordProps) |
| 177 word.WordProps = *pWord->pWordProps; | 177 word.WordProps = *pWord->pWordProps; |
| 178 | 178 |
| 179 word.nFontIndex = m_pVT->GetWordFontIndex(*pWord); | 179 word.nFontIndex = m_pVT->GetWordFontIndex(*pWord); |
| 180 word.fFontSize = m_pVT->GetWordFontSize(*pWord); | 180 word.fFontSize = m_pVT->GetWordFontSize(*pWord); |
| 181 return TRUE; | 181 return true; |
| 182 } | 182 } |
| 183 } | 183 } |
| 184 } | 184 } |
| 185 return FALSE; | 185 return false; |
| 186 } | 186 } |
| 187 | 187 |
| 188 FX_BOOL CPDF_VariableText::Iterator::SetWord(const CPVT_Word& word) { | 188 bool CPDF_VariableText::Iterator::SetWord(const CPVT_Word& word) { |
| 189 if (CSection* pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { | 189 if (CSection* pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { |
| 190 if (CPVT_WordInfo* pWord = | 190 if (CPVT_WordInfo* pWord = |
| 191 pSection->m_WordArray.GetAt(m_CurPos.nWordIndex)) { | 191 pSection->m_WordArray.GetAt(m_CurPos.nWordIndex)) { |
| 192 if (pWord->pWordProps) | 192 if (pWord->pWordProps) |
| 193 *pWord->pWordProps = word.WordProps; | 193 *pWord->pWordProps = word.WordProps; |
| 194 return TRUE; | 194 return true; |
| 195 } | 195 } |
| 196 } | 196 } |
| 197 return FALSE; | 197 return false; |
| 198 } | 198 } |
| 199 | 199 |
| 200 FX_BOOL CPDF_VariableText::Iterator::GetLine(CPVT_Line& line) const { | 200 bool CPDF_VariableText::Iterator::GetLine(CPVT_Line& line) const { |
| 201 ASSERT(m_pVT); | 201 ASSERT(m_pVT); |
| 202 line.lineplace = CPVT_WordPlace(m_CurPos.nSecIndex, m_CurPos.nLineIndex, -1); | 202 line.lineplace = CPVT_WordPlace(m_CurPos.nSecIndex, m_CurPos.nLineIndex, -1); |
| 203 if (CSection* pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { | 203 if (CSection* pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { |
| 204 if (CLine* pLine = pSection->m_LineArray.GetAt(m_CurPos.nLineIndex)) { | 204 if (CLine* pLine = pSection->m_LineArray.GetAt(m_CurPos.nLineIndex)) { |
| 205 line.ptLine = m_pVT->InToOut(CFX_FloatPoint( | 205 line.ptLine = m_pVT->InToOut(CFX_FloatPoint( |
| 206 pLine->m_LineInfo.fLineX + pSection->m_SecInfo.rcSection.left, | 206 pLine->m_LineInfo.fLineX + pSection->m_SecInfo.rcSection.left, |
| 207 pLine->m_LineInfo.fLineY + pSection->m_SecInfo.rcSection.top)); | 207 pLine->m_LineInfo.fLineY + pSection->m_SecInfo.rcSection.top)); |
| 208 line.fLineWidth = pLine->m_LineInfo.fLineWidth; | 208 line.fLineWidth = pLine->m_LineInfo.fLineWidth; |
| 209 line.fLineAscent = pLine->m_LineInfo.fLineAscent; | 209 line.fLineAscent = pLine->m_LineInfo.fLineAscent; |
| 210 line.fLineDescent = pLine->m_LineInfo.fLineDescent; | 210 line.fLineDescent = pLine->m_LineInfo.fLineDescent; |
| 211 line.lineEnd = pLine->GetEndWordPlace(); | 211 line.lineEnd = pLine->GetEndWordPlace(); |
| 212 return TRUE; | 212 return true; |
| 213 } | 213 } |
| 214 } | 214 } |
| 215 return FALSE; | 215 return false; |
| 216 } | 216 } |
| 217 | 217 |
| 218 FX_BOOL CPDF_VariableText::Iterator::GetSection(CPVT_Section& section) const { | 218 bool CPDF_VariableText::Iterator::GetSection(CPVT_Section& section) const { |
| 219 section.secplace = CPVT_WordPlace(m_CurPos.nSecIndex, 0, -1); | 219 section.secplace = CPVT_WordPlace(m_CurPos.nSecIndex, 0, -1); |
| 220 if (CSection* pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { | 220 if (CSection* pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { |
| 221 section.rcSection = m_pVT->InToOut(pSection->m_SecInfo.rcSection); | 221 section.rcSection = m_pVT->InToOut(pSection->m_SecInfo.rcSection); |
| 222 if (pSection->m_SecInfo.pSecProps) | 222 if (pSection->m_SecInfo.pSecProps) |
| 223 section.SecProps = *pSection->m_SecInfo.pSecProps; | 223 section.SecProps = *pSection->m_SecInfo.pSecProps; |
| 224 if (pSection->m_SecInfo.pWordProps) | 224 if (pSection->m_SecInfo.pWordProps) |
| 225 section.WordProps = *pSection->m_SecInfo.pWordProps; | 225 section.WordProps = *pSection->m_SecInfo.pWordProps; |
| 226 return TRUE; | 226 return true; |
| 227 } | 227 } |
| 228 return FALSE; | 228 return false; |
| 229 } | 229 } |
| 230 | 230 |
| 231 FX_BOOL CPDF_VariableText::Iterator::SetSection(const CPVT_Section& section) { | 231 bool CPDF_VariableText::Iterator::SetSection(const CPVT_Section& section) { |
| 232 if (CSection* pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { | 232 if (CSection* pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { |
| 233 if (pSection->m_SecInfo.pSecProps) | 233 if (pSection->m_SecInfo.pSecProps) |
| 234 *pSection->m_SecInfo.pSecProps = section.SecProps; | 234 *pSection->m_SecInfo.pSecProps = section.SecProps; |
| 235 if (pSection->m_SecInfo.pWordProps) | 235 if (pSection->m_SecInfo.pWordProps) |
| 236 *pSection->m_SecInfo.pWordProps = section.WordProps; | 236 *pSection->m_SecInfo.pWordProps = section.WordProps; |
| 237 return TRUE; | 237 return true; |
| 238 } | 238 } |
| 239 return FALSE; | 239 return false; |
| 240 } | 240 } |
| 241 | 241 |
| 242 CPDF_VariableText::CPDF_VariableText() | 242 CPDF_VariableText::CPDF_VariableText() |
| 243 : m_nLimitChar(0), | 243 : m_nLimitChar(0), |
| 244 m_nCharArray(0), | 244 m_nCharArray(0), |
| 245 m_bMultiLine(FALSE), | 245 m_bMultiLine(false), |
| 246 m_bLimitWidth(FALSE), | 246 m_bLimitWidth(false), |
| 247 m_bAutoFontSize(FALSE), | 247 m_bAutoFontSize(false), |
| 248 m_nAlignment(0), | 248 m_nAlignment(0), |
| 249 m_fLineLeading(0.0f), | 249 m_fLineLeading(0.0f), |
| 250 m_fCharSpace(0.0f), | 250 m_fCharSpace(0.0f), |
| 251 m_nHorzScale(100), | 251 m_nHorzScale(100), |
| 252 m_wSubWord(0), | 252 m_wSubWord(0), |
| 253 m_fFontSize(0.0f), | 253 m_fFontSize(0.0f), |
| 254 m_bInitial(FALSE), | 254 m_bInitial(false), |
| 255 m_pVTProvider(nullptr) {} | 255 m_pVTProvider(nullptr) {} |
| 256 | 256 |
| 257 CPDF_VariableText::~CPDF_VariableText() { | 257 CPDF_VariableText::~CPDF_VariableText() { |
| 258 ResetAll(); | 258 ResetAll(); |
| 259 } | 259 } |
| 260 | 260 |
| 261 void CPDF_VariableText::Initialize() { | 261 void CPDF_VariableText::Initialize() { |
| 262 if (!m_bInitial) { | 262 if (!m_bInitial) { |
| 263 CPVT_SectionInfo secinfo; | 263 CPVT_SectionInfo secinfo; |
| 264 CPVT_WordPlace place; | 264 CPVT_WordPlace place; |
| 265 place.nSecIndex = 0; | 265 place.nSecIndex = 0; |
| 266 AddSection(place, secinfo); | 266 AddSection(place, secinfo); |
| 267 CPVT_LineInfo lineinfo; | 267 CPVT_LineInfo lineinfo; |
| 268 lineinfo.fLineAscent = GetFontAscent(GetDefaultFontIndex(), GetFontSize()); | 268 lineinfo.fLineAscent = GetFontAscent(GetDefaultFontIndex(), GetFontSize()); |
| 269 lineinfo.fLineDescent = | 269 lineinfo.fLineDescent = |
| 270 GetFontDescent(GetDefaultFontIndex(), GetFontSize()); | 270 GetFontDescent(GetDefaultFontIndex(), GetFontSize()); |
| 271 AddLine(place, lineinfo); | 271 AddLine(place, lineinfo); |
| 272 if (CSection* pSection = m_SectionArray.GetAt(0)) | 272 if (CSection* pSection = m_SectionArray.GetAt(0)) |
| 273 pSection->ResetLinePlace(); | 273 pSection->ResetLinePlace(); |
| 274 | 274 |
| 275 m_bInitial = TRUE; | 275 m_bInitial = true; |
| 276 } | 276 } |
| 277 } | 277 } |
| 278 | 278 |
| 279 void CPDF_VariableText::ResetAll() { | 279 void CPDF_VariableText::ResetAll() { |
| 280 m_bInitial = FALSE; | 280 m_bInitial = false; |
| 281 ResetSectionArray(); | 281 ResetSectionArray(); |
| 282 } | 282 } |
| 283 | 283 |
| 284 CPVT_WordPlace CPDF_VariableText::InsertWord(const CPVT_WordPlace& place, | 284 CPVT_WordPlace CPDF_VariableText::InsertWord(const CPVT_WordPlace& place, |
| 285 uint16_t word, | 285 uint16_t word, |
| 286 int32_t charset, | 286 int32_t charset, |
| 287 const CPVT_WordProps* pWordProps) { | 287 const CPVT_WordProps* pWordProps) { |
| 288 int32_t nTotlaWords = GetTotalWords(); | 288 int32_t nTotlaWords = GetTotalWords(); |
| 289 if (m_nLimitChar > 0 && nTotlaWords >= m_nLimitChar) | 289 if (m_nLimitChar > 0 && nTotlaWords >= m_nLimitChar) |
| 290 return place; | 290 return place; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 break; | 365 break; |
| 366 } | 366 } |
| 367 if (wp == oldwp) | 367 if (wp == oldwp) |
| 368 break; | 368 break; |
| 369 } | 369 } |
| 370 return wp; | 370 return wp; |
| 371 } | 371 } |
| 372 | 372 |
| 373 CPVT_WordPlace CPDF_VariableText::DeleteWords( | 373 CPVT_WordPlace CPDF_VariableText::DeleteWords( |
| 374 const CPVT_WordRange& PlaceRange) { | 374 const CPVT_WordRange& PlaceRange) { |
| 375 FX_BOOL bLastSecPos = FALSE; | 375 bool bLastSecPos = false; |
| 376 if (CSection* pSection = m_SectionArray.GetAt(PlaceRange.EndPos.nSecIndex)) | 376 if (CSection* pSection = m_SectionArray.GetAt(PlaceRange.EndPos.nSecIndex)) |
| 377 bLastSecPos = (PlaceRange.EndPos == pSection->GetEndWordPlace()); | 377 bLastSecPos = (PlaceRange.EndPos == pSection->GetEndWordPlace()); |
| 378 | 378 |
| 379 ClearWords(PlaceRange); | 379 ClearWords(PlaceRange); |
| 380 if (PlaceRange.BeginPos.nSecIndex != PlaceRange.EndPos.nSecIndex) { | 380 if (PlaceRange.BeginPos.nSecIndex != PlaceRange.EndPos.nSecIndex) { |
| 381 ClearEmptySections(PlaceRange); | 381 ClearEmptySections(PlaceRange); |
| 382 if (!bLastSecPos) | 382 if (!bLastSecPos) |
| 383 LinkLatterSection(PlaceRange.BeginPos); | 383 LinkLatterSection(PlaceRange.BeginPos); |
| 384 } | 384 } |
| 385 return PlaceRange.BeginPos; | 385 return PlaceRange.BeginPos; |
| 386 } | 386 } |
| 387 | 387 |
| 388 CPVT_WordPlace CPDF_VariableText::DeleteWord(const CPVT_WordPlace& place) { | 388 CPVT_WordPlace CPDF_VariableText::DeleteWord(const CPVT_WordPlace& place) { |
| 389 return ClearRightWord(AdjustLineHeader(place, TRUE)); | 389 return ClearRightWord(AdjustLineHeader(place, true)); |
| 390 } | 390 } |
| 391 | 391 |
| 392 CPVT_WordPlace CPDF_VariableText::BackSpaceWord(const CPVT_WordPlace& place) { | 392 CPVT_WordPlace CPDF_VariableText::BackSpaceWord(const CPVT_WordPlace& place) { |
| 393 return ClearLeftWord(AdjustLineHeader(place, TRUE)); | 393 return ClearLeftWord(AdjustLineHeader(place, true)); |
| 394 } | 394 } |
| 395 | 395 |
| 396 void CPDF_VariableText::SetText(const CFX_WideString& swText) { | 396 void CPDF_VariableText::SetText(const CFX_WideString& swText) { |
| 397 DeleteWords(CPVT_WordRange(GetBeginWordPlace(), GetEndWordPlace())); | 397 DeleteWords(CPVT_WordRange(GetBeginWordPlace(), GetEndWordPlace())); |
| 398 CPVT_WordPlace wp(0, 0, -1); | 398 CPVT_WordPlace wp(0, 0, -1); |
| 399 CPVT_SectionInfo secinfo; | 399 CPVT_SectionInfo secinfo; |
| 400 if (CSection* pSection = m_SectionArray.GetAt(0)) | 400 if (CSection* pSection = m_SectionArray.GetAt(0)) |
| 401 pSection->m_SecInfo = secinfo; | 401 pSection->m_SecInfo = secinfo; |
| 402 | 402 |
| 403 int32_t nCharCount = 0; | 403 int32_t nCharCount = 0; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 nCharCount++; | 440 nCharCount++; |
| 441 } | 441 } |
| 442 } | 442 } |
| 443 | 443 |
| 444 void CPDF_VariableText::UpdateWordPlace(CPVT_WordPlace& place) const { | 444 void CPDF_VariableText::UpdateWordPlace(CPVT_WordPlace& place) const { |
| 445 if (place.nSecIndex < 0) | 445 if (place.nSecIndex < 0) |
| 446 place = GetBeginWordPlace(); | 446 place = GetBeginWordPlace(); |
| 447 if (place.nSecIndex >= m_SectionArray.GetSize()) | 447 if (place.nSecIndex >= m_SectionArray.GetSize()) |
| 448 place = GetEndWordPlace(); | 448 place = GetEndWordPlace(); |
| 449 | 449 |
| 450 place = AdjustLineHeader(place, TRUE); | 450 place = AdjustLineHeader(place, true); |
| 451 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) | 451 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) |
| 452 pSection->UpdateWordPlace(place); | 452 pSection->UpdateWordPlace(place); |
| 453 } | 453 } |
| 454 | 454 |
| 455 int32_t CPDF_VariableText::WordPlaceToWordIndex( | 455 int32_t CPDF_VariableText::WordPlaceToWordIndex( |
| 456 const CPVT_WordPlace& place) const { | 456 const CPVT_WordPlace& place) const { |
| 457 CPVT_WordPlace newplace = place; | 457 CPVT_WordPlace newplace = place; |
| 458 UpdateWordPlace(newplace); | 458 UpdateWordPlace(newplace); |
| 459 int32_t nIndex = 0; | 459 int32_t nIndex = 0; |
| 460 int32_t i = 0; | 460 int32_t i = 0; |
| 461 int32_t sz = 0; | 461 int32_t sz = 0; |
| 462 for (i = 0, sz = m_SectionArray.GetSize(); i < sz && i < newplace.nSecIndex; | 462 for (i = 0, sz = m_SectionArray.GetSize(); i < sz && i < newplace.nSecIndex; |
| 463 i++) { | 463 i++) { |
| 464 if (CSection* pSection = m_SectionArray.GetAt(i)) { | 464 if (CSection* pSection = m_SectionArray.GetAt(i)) { |
| 465 nIndex += pSection->m_WordArray.GetSize(); | 465 nIndex += pSection->m_WordArray.GetSize(); |
| 466 if (i != m_SectionArray.GetSize() - 1) | 466 if (i != m_SectionArray.GetSize() - 1) |
| 467 nIndex += kReturnLength; | 467 nIndex += kReturnLength; |
| 468 } | 468 } |
| 469 } | 469 } |
| 470 if (i >= 0 && i < m_SectionArray.GetSize()) | 470 if (i >= 0 && i < m_SectionArray.GetSize()) |
| 471 nIndex += newplace.nWordIndex + kReturnLength; | 471 nIndex += newplace.nWordIndex + kReturnLength; |
| 472 return nIndex; | 472 return nIndex; |
| 473 } | 473 } |
| 474 | 474 |
| 475 CPVT_WordPlace CPDF_VariableText::WordIndexToWordPlace(int32_t index) const { | 475 CPVT_WordPlace CPDF_VariableText::WordIndexToWordPlace(int32_t index) const { |
| 476 CPVT_WordPlace place = GetBeginWordPlace(); | 476 CPVT_WordPlace place = GetBeginWordPlace(); |
| 477 int32_t nOldIndex = 0, nIndex = 0; | 477 int32_t nOldIndex = 0, nIndex = 0; |
| 478 FX_BOOL bFind = FALSE; | 478 bool bFind = false; |
| 479 for (int32_t i = 0, sz = m_SectionArray.GetSize(); i < sz; i++) { | 479 for (int32_t i = 0, sz = m_SectionArray.GetSize(); i < sz; i++) { |
| 480 if (CSection* pSection = m_SectionArray.GetAt(i)) { | 480 if (CSection* pSection = m_SectionArray.GetAt(i)) { |
| 481 nIndex += pSection->m_WordArray.GetSize(); | 481 nIndex += pSection->m_WordArray.GetSize(); |
| 482 if (nIndex == index) { | 482 if (nIndex == index) { |
| 483 place = pSection->GetEndWordPlace(); | 483 place = pSection->GetEndWordPlace(); |
| 484 bFind = TRUE; | 484 bFind = true; |
| 485 break; | 485 break; |
| 486 } else if (nIndex > index) { | 486 } else if (nIndex > index) { |
| 487 place.nSecIndex = i; | 487 place.nSecIndex = i; |
| 488 place.nWordIndex = index - nOldIndex - 1; | 488 place.nWordIndex = index - nOldIndex - 1; |
| 489 pSection->UpdateWordPlace(place); | 489 pSection->UpdateWordPlace(place); |
| 490 bFind = TRUE; | 490 bFind = true; |
| 491 break; | 491 break; |
| 492 } | 492 } |
| 493 if (i != m_SectionArray.GetSize() - 1) | 493 if (i != m_SectionArray.GetSize() - 1) |
| 494 nIndex += kReturnLength; | 494 nIndex += kReturnLength; |
| 495 nOldIndex = nIndex; | 495 nOldIndex = nIndex; |
| 496 } | 496 } |
| 497 } | 497 } |
| 498 if (!bFind) | 498 if (!bFind) |
| 499 place = GetEndWordPlace(); | 499 place = GetEndWordPlace(); |
| 500 return place; | 500 return place; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 return place; | 544 return place; |
| 545 } | 545 } |
| 546 | 546 |
| 547 CPVT_WordPlace CPDF_VariableText::SearchWordPlace( | 547 CPVT_WordPlace CPDF_VariableText::SearchWordPlace( |
| 548 const CFX_FloatPoint& point) const { | 548 const CFX_FloatPoint& point) const { |
| 549 CFX_FloatPoint pt = OutToIn(point); | 549 CFX_FloatPoint pt = OutToIn(point); |
| 550 CPVT_WordPlace place = GetBeginWordPlace(); | 550 CPVT_WordPlace place = GetBeginWordPlace(); |
| 551 int32_t nLeft = 0; | 551 int32_t nLeft = 0; |
| 552 int32_t nRight = m_SectionArray.GetSize() - 1; | 552 int32_t nRight = m_SectionArray.GetSize() - 1; |
| 553 int32_t nMid = m_SectionArray.GetSize() / 2; | 553 int32_t nMid = m_SectionArray.GetSize() / 2; |
| 554 FX_BOOL bUp = TRUE; | 554 bool bUp = true; |
| 555 FX_BOOL bDown = TRUE; | 555 bool bDown = true; |
| 556 while (nLeft <= nRight) { | 556 while (nLeft <= nRight) { |
| 557 if (CSection* pSection = m_SectionArray.GetAt(nMid)) { | 557 if (CSection* pSection = m_SectionArray.GetAt(nMid)) { |
| 558 if (IsFloatBigger(pt.y, pSection->m_SecInfo.rcSection.top)) { | 558 if (IsFloatBigger(pt.y, pSection->m_SecInfo.rcSection.top)) { |
| 559 bUp = FALSE; | 559 bUp = false; |
| 560 } | 560 } |
| 561 if (IsFloatBigger(pSection->m_SecInfo.rcSection.bottom, pt.y)) { | 561 if (IsFloatBigger(pSection->m_SecInfo.rcSection.bottom, pt.y)) { |
| 562 bDown = FALSE; | 562 bDown = false; |
| 563 } | 563 } |
| 564 if (IsFloatSmaller(pt.y, pSection->m_SecInfo.rcSection.top)) { | 564 if (IsFloatSmaller(pt.y, pSection->m_SecInfo.rcSection.top)) { |
| 565 nRight = nMid - 1; | 565 nRight = nMid - 1; |
| 566 nMid = (nLeft + nRight) / 2; | 566 nMid = (nLeft + nRight) / 2; |
| 567 continue; | 567 continue; |
| 568 } else if (IsFloatBigger(pt.y, pSection->m_SecInfo.rcSection.bottom)) { | 568 } else if (IsFloatBigger(pt.y, pSection->m_SecInfo.rcSection.bottom)) { |
| 569 nLeft = nMid + 1; | 569 nLeft = nMid + 1; |
| 570 nMid = (nLeft + nRight) / 2; | 570 nMid = (nLeft + nRight) / 2; |
| 571 continue; | 571 continue; |
| 572 } else { | 572 } else { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 return place; | 705 return place; |
| 706 } | 706 } |
| 707 CPVT_WordPlace newplace = place; | 707 CPVT_WordPlace newplace = place; |
| 708 newplace.nSecIndex = | 708 newplace.nSecIndex = |
| 709 std::max(std::min(newplace.nSecIndex, m_SectionArray.GetSize() - 1), 0); | 709 std::max(std::min(newplace.nSecIndex, m_SectionArray.GetSize() - 1), 0); |
| 710 if (CSection* pSection = m_SectionArray.GetAt(newplace.nSecIndex)) | 710 if (CSection* pSection = m_SectionArray.GetAt(newplace.nSecIndex)) |
| 711 return pSection->AddWord(newplace, wordinfo); | 711 return pSection->AddWord(newplace, wordinfo); |
| 712 return place; | 712 return place; |
| 713 } | 713 } |
| 714 | 714 |
| 715 FX_BOOL CPDF_VariableText::GetWordInfo(const CPVT_WordPlace& place, | 715 bool CPDF_VariableText::GetWordInfo(const CPVT_WordPlace& place, |
| 716 CPVT_WordInfo& wordinfo) { | 716 CPVT_WordInfo& wordinfo) { |
| 717 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { | 717 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { |
| 718 if (CPVT_WordInfo* pWord = pSection->m_WordArray.GetAt(place.nWordIndex)) { | 718 if (CPVT_WordInfo* pWord = pSection->m_WordArray.GetAt(place.nWordIndex)) { |
| 719 wordinfo = *pWord; | 719 wordinfo = *pWord; |
| 720 return TRUE; | 720 return true; |
| 721 } | 721 } |
| 722 } | 722 } |
| 723 return FALSE; | 723 return false; |
| 724 } | 724 } |
| 725 | 725 |
| 726 FX_BOOL CPDF_VariableText::SetWordInfo(const CPVT_WordPlace& place, | 726 bool CPDF_VariableText::SetWordInfo(const CPVT_WordPlace& place, |
| 727 const CPVT_WordInfo& wordinfo) { | 727 const CPVT_WordInfo& wordinfo) { |
| 728 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { | 728 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { |
| 729 if (CPVT_WordInfo* pWord = pSection->m_WordArray.GetAt(place.nWordIndex)) { | 729 if (CPVT_WordInfo* pWord = pSection->m_WordArray.GetAt(place.nWordIndex)) { |
| 730 *pWord = wordinfo; | 730 *pWord = wordinfo; |
| 731 return TRUE; | 731 return true; |
| 732 } | 732 } |
| 733 } | 733 } |
| 734 return FALSE; | 734 return false; |
| 735 } | 735 } |
| 736 | 736 |
| 737 FX_BOOL CPDF_VariableText::GetLineInfo(const CPVT_WordPlace& place, | 737 bool CPDF_VariableText::GetLineInfo(const CPVT_WordPlace& place, |
| 738 CPVT_LineInfo& lineinfo) { | 738 CPVT_LineInfo& lineinfo) { |
| 739 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { | 739 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { |
| 740 if (CLine* pLine = pSection->m_LineArray.GetAt(place.nLineIndex)) { | 740 if (CLine* pLine = pSection->m_LineArray.GetAt(place.nLineIndex)) { |
| 741 lineinfo = pLine->m_LineInfo; | 741 lineinfo = pLine->m_LineInfo; |
| 742 return TRUE; | 742 return true; |
| 743 } | 743 } |
| 744 } | 744 } |
| 745 return FALSE; | 745 return false; |
| 746 } | 746 } |
| 747 | 747 |
| 748 FX_BOOL CPDF_VariableText::GetSectionInfo(const CPVT_WordPlace& place, | 748 bool CPDF_VariableText::GetSectionInfo(const CPVT_WordPlace& place, |
| 749 CPVT_SectionInfo& secinfo) { | 749 CPVT_SectionInfo& secinfo) { |
| 750 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { | 750 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { |
| 751 secinfo = pSection->m_SecInfo; | 751 secinfo = pSection->m_SecInfo; |
| 752 return TRUE; | 752 return true; |
| 753 } | 753 } |
| 754 return FALSE; | 754 return false; |
| 755 } | 755 } |
| 756 | 756 |
| 757 void CPDF_VariableText::SetPlateRect(const CFX_FloatRect& rect) { | 757 void CPDF_VariableText::SetPlateRect(const CFX_FloatRect& rect) { |
| 758 m_rcPlate = rect; | 758 m_rcPlate = rect; |
| 759 } | 759 } |
| 760 | 760 |
| 761 void CPDF_VariableText::SetContentRect(const CPVT_FloatRect& rect) { | 761 void CPDF_VariableText::SetContentRect(const CPVT_FloatRect& rect) { |
| 762 m_rcContent = rect; | 762 m_rcContent = rect; |
| 763 } | 763 } |
| 764 | 764 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 | 847 |
| 848 FX_FLOAT CPDF_VariableText::GetCharSpace(const CPVT_WordInfo& WordInfo) { | 848 FX_FLOAT CPDF_VariableText::GetCharSpace(const CPVT_WordInfo& WordInfo) { |
| 849 return m_fCharSpace; | 849 return m_fCharSpace; |
| 850 } | 850 } |
| 851 | 851 |
| 852 int32_t CPDF_VariableText::GetHorzScale(const CPVT_WordInfo& WordInfo) { | 852 int32_t CPDF_VariableText::GetHorzScale(const CPVT_WordInfo& WordInfo) { |
| 853 return m_nHorzScale; | 853 return m_nHorzScale; |
| 854 } | 854 } |
| 855 | 855 |
| 856 void CPDF_VariableText::ClearSectionRightWords(const CPVT_WordPlace& place) { | 856 void CPDF_VariableText::ClearSectionRightWords(const CPVT_WordPlace& place) { |
| 857 CPVT_WordPlace wordplace = AdjustLineHeader(place, TRUE); | 857 CPVT_WordPlace wordplace = AdjustLineHeader(place, true); |
| 858 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { | 858 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { |
| 859 for (int32_t w = pSection->m_WordArray.GetSize() - 1; | 859 for (int32_t w = pSection->m_WordArray.GetSize() - 1; |
| 860 w > wordplace.nWordIndex; w--) { | 860 w > wordplace.nWordIndex; w--) { |
| 861 delete pSection->m_WordArray.GetAt(w); | 861 delete pSection->m_WordArray.GetAt(w); |
| 862 pSection->m_WordArray.RemoveAt(w); | 862 pSection->m_WordArray.RemoveAt(w); |
| 863 } | 863 } |
| 864 } | 864 } |
| 865 } | 865 } |
| 866 | 866 |
| 867 CPVT_WordPlace CPDF_VariableText::AdjustLineHeader(const CPVT_WordPlace& place, | 867 CPVT_WordPlace CPDF_VariableText::AdjustLineHeader(const CPVT_WordPlace& place, |
| 868 FX_BOOL bPrevOrNext) const { | 868 bool bPrevOrNext) const { |
| 869 if (place.nWordIndex < 0 && place.nLineIndex > 0) | 869 if (place.nWordIndex < 0 && place.nLineIndex > 0) |
| 870 return bPrevOrNext ? GetPrevWordPlace(place) : GetNextWordPlace(place); | 870 return bPrevOrNext ? GetPrevWordPlace(place) : GetNextWordPlace(place); |
| 871 return place; | 871 return place; |
| 872 } | 872 } |
| 873 | 873 |
| 874 FX_BOOL CPDF_VariableText::ClearEmptySection(const CPVT_WordPlace& place) { | 874 bool CPDF_VariableText::ClearEmptySection(const CPVT_WordPlace& place) { |
| 875 if (place.nSecIndex == 0 && m_SectionArray.GetSize() == 1) | 875 if (place.nSecIndex == 0 && m_SectionArray.GetSize() == 1) |
| 876 return FALSE; | 876 return false; |
| 877 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { | 877 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { |
| 878 if (pSection->m_WordArray.GetSize() == 0) { | 878 if (pSection->m_WordArray.GetSize() == 0) { |
| 879 delete pSection; | 879 delete pSection; |
| 880 m_SectionArray.RemoveAt(place.nSecIndex); | 880 m_SectionArray.RemoveAt(place.nSecIndex); |
| 881 return TRUE; | 881 return true; |
| 882 } | 882 } |
| 883 } | 883 } |
| 884 return FALSE; | 884 return false; |
| 885 } | 885 } |
| 886 | 886 |
| 887 void CPDF_VariableText::ClearEmptySections(const CPVT_WordRange& PlaceRange) { | 887 void CPDF_VariableText::ClearEmptySections(const CPVT_WordRange& PlaceRange) { |
| 888 CPVT_WordPlace wordplace; | 888 CPVT_WordPlace wordplace; |
| 889 for (int32_t s = PlaceRange.EndPos.nSecIndex; | 889 for (int32_t s = PlaceRange.EndPos.nSecIndex; |
| 890 s > PlaceRange.BeginPos.nSecIndex; s--) { | 890 s > PlaceRange.BeginPos.nSecIndex; s--) { |
| 891 wordplace.nSecIndex = s; | 891 wordplace.nSecIndex = s; |
| 892 ClearEmptySection(wordplace); | 892 ClearEmptySection(wordplace); |
| 893 } | 893 } |
| 894 } | 894 } |
| 895 | 895 |
| 896 void CPDF_VariableText::LinkLatterSection(const CPVT_WordPlace& place) { | 896 void CPDF_VariableText::LinkLatterSection(const CPVT_WordPlace& place) { |
| 897 CPVT_WordPlace oldplace = AdjustLineHeader(place, TRUE); | 897 CPVT_WordPlace oldplace = AdjustLineHeader(place, true); |
| 898 if (CSection* pNextSection = m_SectionArray.GetAt(place.nSecIndex + 1)) { | 898 if (CSection* pNextSection = m_SectionArray.GetAt(place.nSecIndex + 1)) { |
| 899 if (CSection* pSection = m_SectionArray.GetAt(oldplace.nSecIndex)) { | 899 if (CSection* pSection = m_SectionArray.GetAt(oldplace.nSecIndex)) { |
| 900 for (int32_t w = 0, sz = pNextSection->m_WordArray.GetSize(); w < sz; | 900 for (int32_t w = 0, sz = pNextSection->m_WordArray.GetSize(); w < sz; |
| 901 w++) { | 901 w++) { |
| 902 if (CPVT_WordInfo* pWord = pNextSection->m_WordArray.GetAt(w)) { | 902 if (CPVT_WordInfo* pWord = pNextSection->m_WordArray.GetAt(w)) { |
| 903 oldplace.nWordIndex++; | 903 oldplace.nWordIndex++; |
| 904 pSection->AddWord(oldplace, *pWord); | 904 pSection->AddWord(oldplace, *pWord); |
| 905 } | 905 } |
| 906 } | 906 } |
| 907 } | 907 } |
| 908 delete pNextSection; | 908 delete pNextSection; |
| 909 m_SectionArray.RemoveAt(place.nSecIndex + 1); | 909 m_SectionArray.RemoveAt(place.nSecIndex + 1); |
| 910 } | 910 } |
| 911 } | 911 } |
| 912 | 912 |
| 913 void CPDF_VariableText::ClearWords(const CPVT_WordRange& PlaceRange) { | 913 void CPDF_VariableText::ClearWords(const CPVT_WordRange& PlaceRange) { |
| 914 CPVT_WordRange NewRange; | 914 CPVT_WordRange NewRange; |
| 915 NewRange.BeginPos = AdjustLineHeader(PlaceRange.BeginPos, TRUE); | 915 NewRange.BeginPos = AdjustLineHeader(PlaceRange.BeginPos, true); |
| 916 NewRange.EndPos = AdjustLineHeader(PlaceRange.EndPos, TRUE); | 916 NewRange.EndPos = AdjustLineHeader(PlaceRange.EndPos, true); |
| 917 for (int32_t s = NewRange.EndPos.nSecIndex; s >= NewRange.BeginPos.nSecIndex; | 917 for (int32_t s = NewRange.EndPos.nSecIndex; s >= NewRange.BeginPos.nSecIndex; |
| 918 s--) { | 918 s--) { |
| 919 if (CSection* pSection = m_SectionArray.GetAt(s)) | 919 if (CSection* pSection = m_SectionArray.GetAt(s)) |
| 920 pSection->ClearWords(NewRange); | 920 pSection->ClearWords(NewRange); |
| 921 } | 921 } |
| 922 } | 922 } |
| 923 | 923 |
| 924 CPVT_WordPlace CPDF_VariableText::ClearLeftWord(const CPVT_WordPlace& place) { | 924 CPVT_WordPlace CPDF_VariableText::ClearLeftWord(const CPVT_WordPlace& place) { |
| 925 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { | 925 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { |
| 926 CPVT_WordPlace leftplace = GetPrevWordPlace(place); | 926 CPVT_WordPlace leftplace = GetPrevWordPlace(place); |
| 927 if (leftplace != place) { | 927 if (leftplace != place) { |
| 928 if (leftplace.nSecIndex != place.nSecIndex) { | 928 if (leftplace.nSecIndex != place.nSecIndex) { |
| 929 if (pSection->m_WordArray.GetSize() == 0) | 929 if (pSection->m_WordArray.GetSize() == 0) |
| 930 ClearEmptySection(place); | 930 ClearEmptySection(place); |
| 931 else | 931 else |
| 932 LinkLatterSection(leftplace); | 932 LinkLatterSection(leftplace); |
| 933 } else { | 933 } else { |
| 934 pSection->ClearWord(place); | 934 pSection->ClearWord(place); |
| 935 } | 935 } |
| 936 } | 936 } |
| 937 return leftplace; | 937 return leftplace; |
| 938 } | 938 } |
| 939 return place; | 939 return place; |
| 940 } | 940 } |
| 941 | 941 |
| 942 CPVT_WordPlace CPDF_VariableText::ClearRightWord(const CPVT_WordPlace& place) { | 942 CPVT_WordPlace CPDF_VariableText::ClearRightWord(const CPVT_WordPlace& place) { |
| 943 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { | 943 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { |
| 944 CPVT_WordPlace rightplace = | 944 CPVT_WordPlace rightplace = |
| 945 AdjustLineHeader(GetNextWordPlace(place), FALSE); | 945 AdjustLineHeader(GetNextWordPlace(place), false); |
| 946 if (rightplace != place) { | 946 if (rightplace != place) { |
| 947 if (rightplace.nSecIndex != place.nSecIndex) | 947 if (rightplace.nSecIndex != place.nSecIndex) |
| 948 LinkLatterSection(place); | 948 LinkLatterSection(place); |
| 949 else | 949 else |
| 950 pSection->ClearWord(rightplace); | 950 pSection->ClearWord(rightplace); |
| 951 } | 951 } |
| 952 } | 952 } |
| 953 return place; | 953 return place; |
| 954 } | 954 } |
| 955 | 955 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1081 int32_t nFontIndex) { | 1081 int32_t nFontIndex) { |
| 1082 return m_pVTProvider | 1082 return m_pVTProvider |
| 1083 ? m_pVTProvider->GetWordFontIndex(word, charset, nFontIndex) | 1083 ? m_pVTProvider->GetWordFontIndex(word, charset, nFontIndex) |
| 1084 : -1; | 1084 : -1; |
| 1085 } | 1085 } |
| 1086 | 1086 |
| 1087 int32_t CPDF_VariableText::GetDefaultFontIndex() { | 1087 int32_t CPDF_VariableText::GetDefaultFontIndex() { |
| 1088 return m_pVTProvider ? m_pVTProvider->GetDefaultFontIndex() : -1; | 1088 return m_pVTProvider ? m_pVTProvider->GetDefaultFontIndex() : -1; |
| 1089 } | 1089 } |
| 1090 | 1090 |
| 1091 FX_BOOL CPDF_VariableText::IsLatinWord(uint16_t word) { | 1091 bool CPDF_VariableText::IsLatinWord(uint16_t word) { |
| 1092 return m_pVTProvider ? m_pVTProvider->IsLatinWord(word) : FALSE; | 1092 return m_pVTProvider ? m_pVTProvider->IsLatinWord(word) : false; |
| 1093 } | 1093 } |
| 1094 | 1094 |
| 1095 CPDF_VariableText::Iterator* CPDF_VariableText::GetIterator() { | 1095 CPDF_VariableText::Iterator* CPDF_VariableText::GetIterator() { |
| 1096 if (!m_pVTIterator) | 1096 if (!m_pVTIterator) |
| 1097 m_pVTIterator.reset(new CPDF_VariableText::Iterator(this)); | 1097 m_pVTIterator.reset(new CPDF_VariableText::Iterator(this)); |
| 1098 return m_pVTIterator.get(); | 1098 return m_pVTIterator.get(); |
| 1099 } | 1099 } |
| 1100 | 1100 |
| 1101 void CPDF_VariableText::SetProvider(CPDF_VariableText::Provider* pProvider) { | 1101 void CPDF_VariableText::SetProvider(CPDF_VariableText::Provider* pProvider) { |
| 1102 m_pVTProvider = pProvider; | 1102 m_pVTProvider = pProvider; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1130 ptLeftTop.y); | 1130 ptLeftTop.y); |
| 1131 } | 1131 } |
| 1132 | 1132 |
| 1133 CPVT_FloatRect CPDF_VariableText::OutToIn(const CFX_FloatRect& rect) const { | 1133 CPVT_FloatRect CPDF_VariableText::OutToIn(const CFX_FloatRect& rect) const { |
| 1134 CFX_FloatPoint ptLeftTop = OutToIn(CFX_FloatPoint(rect.left, rect.top)); | 1134 CFX_FloatPoint ptLeftTop = OutToIn(CFX_FloatPoint(rect.left, rect.top)); |
| 1135 CFX_FloatPoint ptRightBottom = | 1135 CFX_FloatPoint ptRightBottom = |
| 1136 OutToIn(CFX_FloatPoint(rect.right, rect.bottom)); | 1136 OutToIn(CFX_FloatPoint(rect.right, rect.bottom)); |
| 1137 return CPVT_FloatRect(ptLeftTop.x, ptLeftTop.y, ptRightBottom.x, | 1137 return CPVT_FloatRect(ptLeftTop.x, ptLeftTop.y, ptRightBottom.x, |
| 1138 ptRightBottom.y); | 1138 ptRightBottom.y); |
| 1139 } | 1139 } |
| OLD | NEW |