| 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 "core/fpdfapi/fpdf_page/include/cpdf_pageobject.h" | 7 #include "core/fpdfapi/fpdf_page/include/cpdf_pageobject.h" |
| 8 #include "core/fpdfapi/fpdf_page/include/cpdf_pageobjectholder.h" | 8 #include "core/fpdfapi/fpdf_page/include/cpdf_pageobjectholder.h" |
| 9 #include "core/fpdfapi/fpdf_page/include/cpdf_pathobject.h" | 9 #include "core/fpdfapi/fpdf_page/include/cpdf_pathobject.h" |
| 10 #include "core/fpdfapi/fpdf_page/include/cpdf_textobject.h" | 10 #include "core/fpdfapi/fpdf_page/include/cpdf_textobject.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 const CFX_FloatPoint& ptOffset, | 100 const CFX_FloatPoint& ptOffset, |
| 101 const CPVT_WordRange* pRange) { | 101 const CPVT_WordRange* pRange) { |
| 102 pDevice->SaveState(); | 102 pDevice->SaveState(); |
| 103 | 103 |
| 104 if (!rcClip.IsEmpty()) { | 104 if (!rcClip.IsEmpty()) { |
| 105 CFX_FloatRect rcTemp = rcClip; | 105 CFX_FloatRect rcTemp = rcClip; |
| 106 pUser2Device->TransformRect(rcTemp); | 106 pUser2Device->TransformRect(rcTemp); |
| 107 pDevice->SetClip_Rect(rcTemp.ToFxRect()); | 107 pDevice->SetClip_Rect(rcTemp.ToFxRect()); |
| 108 } | 108 } |
| 109 | 109 |
| 110 if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) { | 110 IFX_Edit_Iterator* pIterator = pEdit->GetIterator(); |
| 111 if (pEdit->GetFontMap()) { | 111 if (pEdit->GetFontMap()) { |
| 112 if (pRange) | 112 if (pRange) |
| 113 pIterator->SetAt(pRange->BeginPos); | 113 pIterator->SetAt(pRange->BeginPos); |
| 114 else | 114 else |
| 115 pIterator->SetAt(0); | 115 pIterator->SetAt(0); |
| 116 | 116 |
| 117 while (pIterator->NextWord()) { | 117 while (pIterator->NextWord()) { |
| 118 CPVT_WordPlace place = pIterator->GetAt(); | 118 CPVT_WordPlace place = pIterator->GetAt(); |
| 119 if (pRange && place.WordCmp(pRange->EndPos) > 0) | 119 if (pRange && place.WordCmp(pRange->EndPos) > 0) |
| 120 break; | 120 break; |
| 121 | 121 |
| 122 CPVT_Word word; | 122 CPVT_Word word; |
| 123 if (pIterator->GetWord(word)) { | 123 if (pIterator->GetWord(word)) { |
| 124 CFX_PathData pathUnderline; | 124 CFX_PathData pathUnderline; |
| 125 CFX_FloatRect rcUnderline = GetUnderLineRect(word); | 125 CFX_FloatRect rcUnderline = GetUnderLineRect(word); |
| 126 rcUnderline.left += ptOffset.x; | 126 rcUnderline.left += ptOffset.x; |
| 127 rcUnderline.right += ptOffset.x; | 127 rcUnderline.right += ptOffset.x; |
| 128 rcUnderline.top += ptOffset.y; | 128 rcUnderline.top += ptOffset.y; |
| 129 rcUnderline.bottom += ptOffset.y; | 129 rcUnderline.bottom += ptOffset.y; |
| 130 pathUnderline.AppendRect(rcUnderline.left, rcUnderline.bottom, | 130 pathUnderline.AppendRect(rcUnderline.left, rcUnderline.bottom, |
| 131 rcUnderline.right, rcUnderline.top); | 131 rcUnderline.right, rcUnderline.top); |
| 132 | 132 |
| 133 pDevice->DrawPath(&pathUnderline, pUser2Device, NULL, color, 0, | 133 pDevice->DrawPath(&pathUnderline, pUser2Device, NULL, color, 0, |
| 134 FXFILL_WINDING); | 134 FXFILL_WINDING); |
| 135 } | |
| 136 } | 135 } |
| 137 } | 136 } |
| 138 } | 137 } |
| 139 | 138 |
| 140 pDevice->RestoreState(); | 139 pDevice->RestoreState(); |
| 141 } | 140 } |
| 142 | 141 |
| 143 void IFX_Edit::DrawEdit(CFX_RenderDevice* pDevice, | 142 void IFX_Edit::DrawEdit(CFX_RenderDevice* pDevice, |
| 144 CFX_Matrix* pUser2Device, | 143 CFX_Matrix* pUser2Device, |
| 145 IFX_Edit* pEdit, | 144 IFX_Edit* pEdit, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 169 CFX_FloatPoint ptBT(0.0f, 0.0f); | 168 CFX_FloatPoint ptBT(0.0f, 0.0f); |
| 170 | 169 |
| 171 pDevice->SaveState(); | 170 pDevice->SaveState(); |
| 172 | 171 |
| 173 if (!rcClip.IsEmpty()) { | 172 if (!rcClip.IsEmpty()) { |
| 174 CFX_FloatRect rcTemp = rcClip; | 173 CFX_FloatRect rcTemp = rcClip; |
| 175 pUser2Device->TransformRect(rcTemp); | 174 pUser2Device->TransformRect(rcTemp); |
| 176 pDevice->SetClip_Rect(rcTemp.ToFxRect()); | 175 pDevice->SetClip_Rect(rcTemp.ToFxRect()); |
| 177 } | 176 } |
| 178 | 177 |
| 179 if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) { | 178 IFX_Edit_Iterator* pIterator = pEdit->GetIterator(); |
| 180 if (IPVT_FontMap* pFontMap = pEdit->GetFontMap()) { | 179 if (IPVT_FontMap* pFontMap = pEdit->GetFontMap()) { |
| 181 if (pRange) | 180 if (pRange) |
| 182 pIterator->SetAt(pRange->BeginPos); | 181 pIterator->SetAt(pRange->BeginPos); |
| 183 else | 182 else |
| 184 pIterator->SetAt(0); | 183 pIterator->SetAt(0); |
| 185 | 184 |
| 186 CPVT_WordPlace oldplace; | 185 CPVT_WordPlace oldplace; |
| 187 | 186 |
| 188 while (pIterator->NextWord()) { | 187 while (pIterator->NextWord()) { |
| 189 CPVT_WordPlace place = pIterator->GetAt(); | 188 CPVT_WordPlace place = pIterator->GetAt(); |
| 190 if (pRange && place.WordCmp(pRange->EndPos) > 0) | 189 if (pRange && place.WordCmp(pRange->EndPos) > 0) |
| 191 break; | 190 break; |
| 192 | 191 |
| 193 if (wrSelect.IsExist()) { | 192 if (wrSelect.IsExist()) { |
| 194 bSelect = place.WordCmp(wrSelect.BeginPos) > 0 && | 193 bSelect = place.WordCmp(wrSelect.BeginPos) > 0 && |
| 195 place.WordCmp(wrSelect.EndPos) <= 0; | 194 place.WordCmp(wrSelect.EndPos) <= 0; |
| 196 if (bSelect) { | 195 if (bSelect) { |
| 197 crCurFill = crWhite; | 196 crCurFill = crWhite; |
| 197 } else { |
| 198 crCurFill = crTextFill; |
| 199 } |
| 200 } |
| 201 if (pSystemHandler && pSystemHandler->IsSelectionImplemented()) { |
| 202 crCurFill = crTextFill; |
| 203 crOldFill = crCurFill; |
| 204 } |
| 205 CPVT_Word word; |
| 206 if (pIterator->GetWord(word)) { |
| 207 if (bSelect) { |
| 208 CPVT_Line line; |
| 209 pIterator->GetLine(line); |
| 210 |
| 211 if (pSystemHandler && pSystemHandler->IsSelectionImplemented()) { |
| 212 CFX_FloatRect rc(word.ptWord.x, line.ptLine.y + line.fLineDescent, |
| 213 word.ptWord.x + word.fWidth, |
| 214 line.ptLine.y + line.fLineAscent); |
| 215 rc.Intersect(rcClip); |
| 216 pSystemHandler->OutputSelectedRect(pFFLData, rc); |
| 198 } else { | 217 } else { |
| 199 crCurFill = crTextFill; | 218 CFX_PathData pathSelBK; |
| 219 pathSelBK.AppendRect( |
| 220 word.ptWord.x, line.ptLine.y + line.fLineDescent, |
| 221 word.ptWord.x + word.fWidth, line.ptLine.y + line.fLineAscent); |
| 222 |
| 223 pDevice->DrawPath(&pathSelBK, pUser2Device, NULL, crSelBK, 0, |
| 224 FXFILL_WINDING); |
| 200 } | 225 } |
| 201 } | 226 } |
| 202 if (pSystemHandler && pSystemHandler->IsSelectionImplemented()) { | |
| 203 crCurFill = crTextFill; | |
| 204 crOldFill = crCurFill; | |
| 205 } | |
| 206 CPVT_Word word; | |
| 207 if (pIterator->GetWord(word)) { | |
| 208 if (bSelect) { | |
| 209 CPVT_Line line; | |
| 210 pIterator->GetLine(line); | |
| 211 | 227 |
| 212 if (pSystemHandler && pSystemHandler->IsSelectionImplemented()) { | 228 if (bContinuous) { |
| 213 CFX_FloatRect rc(word.ptWord.x, line.ptLine.y + line.fLineDescent, | 229 if (place.LineCmp(oldplace) != 0 || word.nFontIndex != nFontIndex || |
| 214 word.ptWord.x + word.fWidth, | 230 crOldFill != crCurFill) { |
| 215 line.ptLine.y + line.fLineAscent); | 231 if (sTextBuf.GetLength() > 0) { |
| 216 rc.Intersect(rcClip); | 232 DrawTextString( |
| 217 pSystemHandler->OutputSelectedRect(pFFLData, rc); | 233 pDevice, |
| 218 } else { | 234 CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), |
| 219 CFX_PathData pathSelBK; | 235 pFontMap->GetPDFFont(nFontIndex), fFontSize, pUser2Device, |
| 220 pathSelBK.AppendRect(word.ptWord.x, | 236 sTextBuf.AsStringC(), crOldFill, crTextStroke, nHorzScale); |
| 221 line.ptLine.y + line.fLineDescent, | |
| 222 word.ptWord.x + word.fWidth, | |
| 223 line.ptLine.y + line.fLineAscent); | |
| 224 | 237 |
| 225 pDevice->DrawPath(&pathSelBK, pUser2Device, NULL, crSelBK, 0, | 238 sTextBuf.Clear(); |
| 226 FXFILL_WINDING); | |
| 227 } | 239 } |
| 240 nFontIndex = word.nFontIndex; |
| 241 ptBT = word.ptWord; |
| 242 crOldFill = crCurFill; |
| 228 } | 243 } |
| 229 | 244 |
| 230 if (bContinuous) { | 245 sTextBuf << GetPDFWordString(pFontMap, word.nFontIndex, word.Word, |
| 231 if (place.LineCmp(oldplace) != 0 || word.nFontIndex != nFontIndex || | 246 SubWord) |
| 232 crOldFill != crCurFill) { | 247 .AsStringC(); |
| 233 if (sTextBuf.GetLength() > 0) { | 248 } else { |
| 234 DrawTextString( | 249 DrawTextString( |
| 235 pDevice, | 250 pDevice, CFX_FloatPoint(word.ptWord.x + ptOffset.x, |
| 236 CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), | 251 word.ptWord.y + ptOffset.y), |
| 237 pFontMap->GetPDFFont(nFontIndex), fFontSize, pUser2Device, | 252 pFontMap->GetPDFFont(word.nFontIndex), fFontSize, pUser2Device, |
| 238 sTextBuf.AsStringC(), crOldFill, crTextStroke, nHorzScale); | 253 GetPDFWordString(pFontMap, word.nFontIndex, word.Word, SubWord), |
| 254 crCurFill, crTextStroke, nHorzScale); |
| 255 } |
| 256 oldplace = place; |
| 257 } |
| 258 } |
| 239 | 259 |
| 240 sTextBuf.Clear(); | 260 if (sTextBuf.GetLength() > 0) { |
| 241 } | 261 DrawTextString(pDevice, |
| 242 nFontIndex = word.nFontIndex; | 262 CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), |
| 243 ptBT = word.ptWord; | 263 pFontMap->GetPDFFont(nFontIndex), fFontSize, pUser2Device, |
| 244 crOldFill = crCurFill; | 264 sTextBuf.AsStringC(), crOldFill, crTextStroke, nHorzScale); |
| 245 } | |
| 246 | |
| 247 sTextBuf << GetPDFWordString(pFontMap, word.nFontIndex, word.Word, | |
| 248 SubWord) | |
| 249 .AsStringC(); | |
| 250 } else { | |
| 251 DrawTextString( | |
| 252 pDevice, CFX_FloatPoint(word.ptWord.x + ptOffset.x, | |
| 253 word.ptWord.y + ptOffset.y), | |
| 254 pFontMap->GetPDFFont(word.nFontIndex), fFontSize, pUser2Device, | |
| 255 GetPDFWordString(pFontMap, word.nFontIndex, word.Word, SubWord), | |
| 256 crCurFill, crTextStroke, nHorzScale); | |
| 257 } | |
| 258 oldplace = place; | |
| 259 } | |
| 260 } | |
| 261 | |
| 262 if (sTextBuf.GetLength() > 0) { | |
| 263 DrawTextString( | |
| 264 pDevice, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), | |
| 265 pFontMap->GetPDFFont(nFontIndex), fFontSize, pUser2Device, | |
| 266 sTextBuf.AsStringC(), crOldFill, crTextStroke, nHorzScale); | |
| 267 } | |
| 268 } | 265 } |
| 269 } | 266 } |
| 270 | 267 |
| 271 pDevice->RestoreState(); | 268 pDevice->RestoreState(); |
| 272 } | 269 } |
| 273 | 270 |
| 274 void IFX_Edit::DrawRichEdit(CFX_RenderDevice* pDevice, | 271 void IFX_Edit::DrawRichEdit(CFX_RenderDevice* pDevice, |
| 275 CFX_Matrix* pUser2Device, | 272 CFX_Matrix* pUser2Device, |
| 276 IFX_Edit* pEdit, | 273 IFX_Edit* pEdit, |
| 277 const CFX_FloatRect& rcClip, | 274 const CFX_FloatRect& rcClip, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 290 CFX_FloatPoint ptBT(0.0f, 0.0f); | 287 CFX_FloatPoint ptBT(0.0f, 0.0f); |
| 291 | 288 |
| 292 pDevice->SaveState(); | 289 pDevice->SaveState(); |
| 293 | 290 |
| 294 if (!rcClip.IsEmpty()) { | 291 if (!rcClip.IsEmpty()) { |
| 295 CFX_FloatRect rcTemp = rcClip; | 292 CFX_FloatRect rcTemp = rcClip; |
| 296 pUser2Device->TransformRect(rcTemp); | 293 pUser2Device->TransformRect(rcTemp); |
| 297 pDevice->SetClip_Rect(rcTemp.ToFxRect()); | 294 pDevice->SetClip_Rect(rcTemp.ToFxRect()); |
| 298 } | 295 } |
| 299 | 296 |
| 300 if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) { | 297 IFX_Edit_Iterator* pIterator = pEdit->GetIterator(); |
| 301 if (IPVT_FontMap* pFontMap = pEdit->GetFontMap()) { | 298 if (IPVT_FontMap* pFontMap = pEdit->GetFontMap()) { |
| 302 if (pRange) | 299 if (pRange) |
| 303 pIterator->SetAt(pRange->BeginPos); | 300 pIterator->SetAt(pRange->BeginPos); |
| 304 else | 301 else |
| 305 pIterator->SetAt(0); | 302 pIterator->SetAt(0); |
| 306 | 303 |
| 307 CPVT_WordPlace oldplace; | 304 CPVT_WordPlace oldplace; |
| 308 | 305 |
| 309 while (pIterator->NextWord()) { | 306 while (pIterator->NextWord()) { |
| 310 CPVT_WordPlace place = pIterator->GetAt(); | 307 CPVT_WordPlace place = pIterator->GetAt(); |
| 311 if (pRange && place.WordCmp(pRange->EndPos) > 0) | 308 if (pRange && place.WordCmp(pRange->EndPos) > 0) |
| 312 break; | 309 break; |
| 313 | 310 |
| 314 CPVT_Word word; | 311 CPVT_Word word; |
| 315 if (pIterator->GetWord(word)) { | 312 if (pIterator->GetWord(word)) { |
| 316 word.WordProps.fFontSize = word.fFontSize; | 313 word.WordProps.fFontSize = word.fFontSize; |
| 317 | 314 |
| 318 crCurText = ArgbEncode(255, word.WordProps.dwWordColor); | 315 crCurText = ArgbEncode(255, word.WordProps.dwWordColor); |
| 319 | 316 |
| 320 if (wrSelect.IsExist()) { | 317 if (wrSelect.IsExist()) { |
| 321 bSelect = place.WordCmp(wrSelect.BeginPos) > 0 && | 318 bSelect = place.WordCmp(wrSelect.BeginPos) > 0 && |
| 322 place.WordCmp(wrSelect.EndPos) <= 0; | 319 place.WordCmp(wrSelect.EndPos) <= 0; |
| 323 if (bSelect) { | 320 if (bSelect) { |
| 324 crCurText = crWhite; | 321 crCurText = crWhite; |
| 325 } | |
| 326 } | 322 } |
| 323 } |
| 327 | 324 |
| 328 if (bSelect) { | 325 if (bSelect) { |
| 329 CPVT_Line line; | 326 CPVT_Line line; |
| 330 pIterator->GetLine(line); | 327 pIterator->GetLine(line); |
| 331 | 328 |
| 332 CFX_PathData pathSelBK; | 329 CFX_PathData pathSelBK; |
| 333 pathSelBK.AppendRect(word.ptWord.x + ptOffset.x, | 330 pathSelBK.AppendRect(word.ptWord.x + ptOffset.x, |
| 334 line.ptLine.y + line.fLineDescent + ptOffset.y, | 331 line.ptLine.y + line.fLineDescent + ptOffset.y, |
| 335 word.ptWord.x + word.fWidth + ptOffset.x, | 332 word.ptWord.x + word.fWidth + ptOffset.x, |
| 336 line.ptLine.y + line.fLineAscent + ptOffset.y); | 333 line.ptLine.y + line.fLineAscent + ptOffset.y); |
| 337 | 334 |
| 338 pDevice->DrawPath(&pathSelBK, pUser2Device, NULL, crSelBK, 0, | 335 pDevice->DrawPath(&pathSelBK, pUser2Device, NULL, crSelBK, 0, |
| 339 FXFILL_WINDING); | 336 FXFILL_WINDING); |
| 337 } |
| 338 |
| 339 if (place.LineCmp(oldplace) != 0 || word.WordProps.fCharSpace > 0.0f || |
| 340 word.WordProps.nHorzScale != 100 || |
| 341 FXSYS_memcmp(&word.WordProps, &wp, sizeof(CPVT_WordProps)) != 0 || |
| 342 crOld != crCurText) { |
| 343 if (sTextBuf.GetLength() > 0) { |
| 344 DrawTextString( |
| 345 pDevice, |
| 346 CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), |
| 347 pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, pUser2Device, |
| 348 sTextBuf.AsStringC(), crOld, 0, wp.nHorzScale); |
| 349 |
| 350 sTextBuf.Clear(); |
| 340 } | 351 } |
| 352 wp = word.WordProps; |
| 353 ptBT = word.ptWord; |
| 354 crOld = crCurText; |
| 355 } |
| 341 | 356 |
| 342 if (place.LineCmp(oldplace) != 0 || | 357 sTextBuf << GetPDFWordString(pFontMap, word.WordProps.nFontIndex, |
| 343 word.WordProps.fCharSpace > 0.0f || | 358 word.Word, 0) |
| 344 word.WordProps.nHorzScale != 100 || | 359 .AsStringC(); |
| 345 FXSYS_memcmp(&word.WordProps, &wp, sizeof(CPVT_WordProps)) != 0 || | |
| 346 crOld != crCurText) { | |
| 347 if (sTextBuf.GetLength() > 0) { | |
| 348 DrawTextString( | |
| 349 pDevice, | |
| 350 CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), | |
| 351 pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, | |
| 352 pUser2Device, sTextBuf.AsStringC(), crOld, 0, wp.nHorzScale); | |
| 353 | 360 |
| 354 sTextBuf.Clear(); | 361 if (word.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) { |
| 355 } | 362 CFX_PathData pathUnderline; |
| 356 wp = word.WordProps; | 363 CFX_FloatRect rcUnderline = GetUnderLineRect(word); |
| 357 ptBT = word.ptWord; | 364 pathUnderline.AppendRect(rcUnderline.left, rcUnderline.bottom, |
| 358 crOld = crCurText; | 365 rcUnderline.right, rcUnderline.top); |
| 359 } | |
| 360 | 366 |
| 361 sTextBuf << GetPDFWordString(pFontMap, word.WordProps.nFontIndex, | 367 pDevice->DrawPath(&pathUnderline, pUser2Device, NULL, crCurText, 0, |
| 362 word.Word, 0) | 368 FXFILL_WINDING); |
| 363 .AsStringC(); | 369 } |
| 364 | 370 |
| 365 if (word.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) { | 371 if (word.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) { |
| 366 CFX_PathData pathUnderline; | 372 CFX_PathData pathCrossout; |
| 367 CFX_FloatRect rcUnderline = GetUnderLineRect(word); | 373 CFX_FloatRect rcCrossout = GetCrossoutRect(word); |
| 368 pathUnderline.AppendRect(rcUnderline.left, rcUnderline.bottom, | 374 pathCrossout.AppendRect(rcCrossout.left, rcCrossout.bottom, |
| 369 rcUnderline.right, rcUnderline.top); | 375 rcCrossout.right, rcCrossout.top); |
| 370 | 376 |
| 371 pDevice->DrawPath(&pathUnderline, pUser2Device, NULL, crCurText, 0, | 377 pDevice->DrawPath(&pathCrossout, pUser2Device, NULL, crCurText, 0, |
| 372 FXFILL_WINDING); | 378 FXFILL_WINDING); |
| 373 } | 379 } |
| 374 | 380 |
| 375 if (word.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) { | 381 oldplace = place; |
| 376 CFX_PathData pathCrossout; | 382 } |
| 377 CFX_FloatRect rcCrossout = GetCrossoutRect(word); | 383 } |
| 378 pathCrossout.AppendRect(rcCrossout.left, rcCrossout.bottom, | |
| 379 rcCrossout.right, rcCrossout.top); | |
| 380 | 384 |
| 381 pDevice->DrawPath(&pathCrossout, pUser2Device, NULL, crCurText, 0, | 385 if (sTextBuf.GetLength() > 0) { |
| 382 FXFILL_WINDING); | 386 DrawTextString( |
| 383 } | 387 pDevice, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), |
| 384 | 388 pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, pUser2Device, |
| 385 oldplace = place; | 389 sTextBuf.AsStringC(), crOld, 0, wp.nHorzScale); |
| 386 } | |
| 387 } | |
| 388 | |
| 389 if (sTextBuf.GetLength() > 0) { | |
| 390 DrawTextString( | |
| 391 pDevice, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), | |
| 392 pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, pUser2Device, | |
| 393 sTextBuf.AsStringC(), crOld, 0, wp.nHorzScale); | |
| 394 } | |
| 395 } | 390 } |
| 396 } | 391 } |
| 397 | 392 |
| 398 pDevice->RestoreState(); | 393 pDevice->RestoreState(); |
| 399 } | 394 } |
| 400 | 395 |
| 401 static void AddRectToPageObjects(CPDF_PageObjectHolder* pObjectHolder, | 396 static void AddRectToPageObjects(CPDF_PageObjectHolder* pObjectHolder, |
| 402 FX_COLORREF crFill, | 397 FX_COLORREF crFill, |
| 403 const CFX_FloatRect& rcFill) { | 398 const CFX_FloatRect& rcFill) { |
| 404 std::unique_ptr<CPDF_PathObject> pPathObj(new CPDF_PathObject); | 399 std::unique_ptr<CPDF_PathObject> pPathObj(new CPDF_PathObject); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray) { | 459 CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray) { |
| 465 FX_FLOAT fFontSize = pEdit->GetFontSize(); | 460 FX_FLOAT fFontSize = pEdit->GetFontSize(); |
| 466 | 461 |
| 467 int32_t nOldFontIndex = -1; | 462 int32_t nOldFontIndex = -1; |
| 468 | 463 |
| 469 CFX_ByteTextBuf sTextBuf; | 464 CFX_ByteTextBuf sTextBuf; |
| 470 CFX_FloatPoint ptBT(0.0f, 0.0f); | 465 CFX_FloatPoint ptBT(0.0f, 0.0f); |
| 471 | 466 |
| 472 ObjArray.RemoveAll(); | 467 ObjArray.RemoveAll(); |
| 473 | 468 |
| 474 if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) { | 469 IFX_Edit_Iterator* pIterator = pEdit->GetIterator(); |
| 475 if (IPVT_FontMap* pFontMap = pEdit->GetFontMap()) { | 470 if (IPVT_FontMap* pFontMap = pEdit->GetFontMap()) { |
| 476 if (pRange) | 471 if (pRange) |
| 477 pIterator->SetAt(pRange->BeginPos); | 472 pIterator->SetAt(pRange->BeginPos); |
| 478 else | 473 else |
| 479 pIterator->SetAt(0); | 474 pIterator->SetAt(0); |
| 480 | 475 |
| 481 CPVT_WordPlace oldplace; | 476 CPVT_WordPlace oldplace; |
| 482 | 477 |
| 483 while (pIterator->NextWord()) { | 478 while (pIterator->NextWord()) { |
| 484 CPVT_WordPlace place = pIterator->GetAt(); | 479 CPVT_WordPlace place = pIterator->GetAt(); |
| 485 if (pRange && place.WordCmp(pRange->EndPos) > 0) | 480 if (pRange && place.WordCmp(pRange->EndPos) > 0) |
| 486 break; | 481 break; |
| 487 | 482 |
| 488 CPVT_Word word; | 483 CPVT_Word word; |
| 489 if (pIterator->GetWord(word)) { | 484 if (pIterator->GetWord(word)) { |
| 490 if (place.LineCmp(oldplace) != 0 || | 485 if (place.LineCmp(oldplace) != 0 || nOldFontIndex != word.nFontIndex) { |
| 491 nOldFontIndex != word.nFontIndex) { | 486 if (sTextBuf.GetLength() > 0) { |
| 492 if (sTextBuf.GetLength() > 0) { | 487 ObjArray.Add(AddTextObjToPageObjects( |
| 493 ObjArray.Add(AddTextObjToPageObjects( | 488 pObjectHolder, crText, pFontMap->GetPDFFont(nOldFontIndex), |
| 494 pObjectHolder, crText, pFontMap->GetPDFFont(nOldFontIndex), | 489 fFontSize, 0.0f, 100, |
| 495 fFontSize, 0.0f, 100, | 490 CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), |
| 496 CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), | 491 sTextBuf.AsStringC())); |
| 497 sTextBuf.AsStringC())); | |
| 498 | 492 |
| 499 sTextBuf.Clear(); | 493 sTextBuf.Clear(); |
| 500 } | |
| 501 | |
| 502 ptBT = word.ptWord; | |
| 503 nOldFontIndex = word.nFontIndex; | |
| 504 } | 494 } |
| 505 | 495 |
| 506 sTextBuf << GetPDFWordString(pFontMap, word.nFontIndex, word.Word, 0) | 496 ptBT = word.ptWord; |
| 507 .AsStringC(); | 497 nOldFontIndex = word.nFontIndex; |
| 508 oldplace = place; | |
| 509 } | 498 } |
| 499 |
| 500 sTextBuf << GetPDFWordString(pFontMap, word.nFontIndex, word.Word, 0) |
| 501 .AsStringC(); |
| 502 oldplace = place; |
| 510 } | 503 } |
| 504 } |
| 511 | 505 |
| 512 if (sTextBuf.GetLength() > 0) { | 506 if (sTextBuf.GetLength() > 0) { |
| 513 ObjArray.Add(AddTextObjToPageObjects( | 507 ObjArray.Add(AddTextObjToPageObjects( |
| 514 pObjectHolder, crText, pFontMap->GetPDFFont(nOldFontIndex), | 508 pObjectHolder, crText, pFontMap->GetPDFFont(nOldFontIndex), fFontSize, |
| 515 fFontSize, 0.0f, 100, | 509 0.0f, 100, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), |
| 516 CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), | 510 sTextBuf.AsStringC())); |
| 517 sTextBuf.AsStringC())); | |
| 518 } | |
| 519 } | 511 } |
| 520 } | 512 } |
| 521 } | 513 } |
| 522 | 514 |
| 523 void IFX_Edit::GenerateRichPageObjects( | 515 void IFX_Edit::GenerateRichPageObjects( |
| 524 CPDF_PageObjectHolder* pObjectHolder, | 516 CPDF_PageObjectHolder* pObjectHolder, |
| 525 IFX_Edit* pEdit, | 517 IFX_Edit* pEdit, |
| 526 const CFX_FloatPoint& ptOffset, | 518 const CFX_FloatPoint& ptOffset, |
| 527 const CPVT_WordRange* pRange, | 519 const CPVT_WordRange* pRange, |
| 528 CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray) { | 520 CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray) { |
| 529 FX_COLORREF crCurText = ArgbEncode(255, 0, 0, 0); | 521 FX_COLORREF crCurText = ArgbEncode(255, 0, 0, 0); |
| 530 FX_COLORREF crOld = crCurText; | 522 FX_COLORREF crOld = crCurText; |
| 531 | 523 |
| 532 CFX_ByteTextBuf sTextBuf; | 524 CFX_ByteTextBuf sTextBuf; |
| 533 CPVT_WordProps wp; | 525 CPVT_WordProps wp; |
| 534 CFX_FloatPoint ptBT(0.0f, 0.0f); | 526 CFX_FloatPoint ptBT(0.0f, 0.0f); |
| 535 | 527 |
| 536 ObjArray.RemoveAll(); | 528 ObjArray.RemoveAll(); |
| 537 | 529 |
| 538 if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) { | 530 IFX_Edit_Iterator* pIterator = pEdit->GetIterator(); |
| 539 if (IPVT_FontMap* pFontMap = pEdit->GetFontMap()) { | 531 if (IPVT_FontMap* pFontMap = pEdit->GetFontMap()) { |
| 540 if (pRange) | 532 if (pRange) |
| 541 pIterator->SetAt(pRange->BeginPos); | 533 pIterator->SetAt(pRange->BeginPos); |
| 542 else | 534 else |
| 543 pIterator->SetAt(0); | 535 pIterator->SetAt(0); |
| 544 | 536 |
| 545 CPVT_WordPlace oldplace; | 537 CPVT_WordPlace oldplace; |
| 546 | 538 |
| 547 while (pIterator->NextWord()) { | 539 while (pIterator->NextWord()) { |
| 548 CPVT_WordPlace place = pIterator->GetAt(); | 540 CPVT_WordPlace place = pIterator->GetAt(); |
| 549 if (pRange && place.WordCmp(pRange->EndPos) > 0) | 541 if (pRange && place.WordCmp(pRange->EndPos) > 0) |
| 550 break; | 542 break; |
| 551 | 543 |
| 552 CPVT_Word word; | 544 CPVT_Word word; |
| 553 if (pIterator->GetWord(word)) { | 545 if (pIterator->GetWord(word)) { |
| 554 word.WordProps.fFontSize = word.fFontSize; | 546 word.WordProps.fFontSize = word.fFontSize; |
| 555 | 547 |
| 556 crCurText = ArgbEncode(255, word.WordProps.dwWordColor); | 548 crCurText = ArgbEncode(255, word.WordProps.dwWordColor); |
| 557 | 549 |
| 558 if (place.LineCmp(oldplace) != 0 || | 550 if (place.LineCmp(oldplace) != 0 || word.WordProps.fCharSpace > 0.0f || |
| 559 word.WordProps.fCharSpace > 0.0f || | 551 word.WordProps.nHorzScale != 100 || |
| 560 word.WordProps.nHorzScale != 100 || | 552 FXSYS_memcmp(&word.WordProps, &wp, sizeof(CPVT_WordProps)) != 0 || |
| 561 FXSYS_memcmp(&word.WordProps, &wp, sizeof(CPVT_WordProps)) != 0 || | 553 crOld != crCurText) { |
| 562 crOld != crCurText) { | 554 if (sTextBuf.GetLength() > 0) { |
| 563 if (sTextBuf.GetLength() > 0) { | 555 ObjArray.Add(AddTextObjToPageObjects( |
| 564 ObjArray.Add(AddTextObjToPageObjects( | 556 pObjectHolder, crOld, pFontMap->GetPDFFont(wp.nFontIndex), |
| 565 pObjectHolder, crOld, pFontMap->GetPDFFont(wp.nFontIndex), | 557 wp.fFontSize, wp.fCharSpace, wp.nHorzScale, |
| 566 wp.fFontSize, wp.fCharSpace, wp.nHorzScale, | 558 CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), |
| 567 CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), | 559 sTextBuf.AsStringC())); |
| 568 sTextBuf.AsStringC())); | |
| 569 | 560 |
| 570 sTextBuf.Clear(); | 561 sTextBuf.Clear(); |
| 571 } | |
| 572 | |
| 573 wp = word.WordProps; | |
| 574 ptBT = word.ptWord; | |
| 575 crOld = crCurText; | |
| 576 } | 562 } |
| 577 | 563 |
| 578 sTextBuf << GetPDFWordString(pFontMap, word.WordProps.nFontIndex, | 564 wp = word.WordProps; |
| 579 word.Word, 0) | 565 ptBT = word.ptWord; |
| 580 .AsStringC(); | 566 crOld = crCurText; |
| 567 } |
| 581 | 568 |
| 582 if (word.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) { | 569 sTextBuf << GetPDFWordString(pFontMap, word.WordProps.nFontIndex, |
| 583 CFX_FloatRect rcUnderline = GetUnderLineRect(word); | 570 word.Word, 0) |
| 584 rcUnderline.left += ptOffset.x; | 571 .AsStringC(); |
| 585 rcUnderline.right += ptOffset.x; | |
| 586 rcUnderline.top += ptOffset.y; | |
| 587 rcUnderline.bottom += ptOffset.y; | |
| 588 | 572 |
| 589 AddRectToPageObjects(pObjectHolder, crCurText, rcUnderline); | 573 if (word.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) { |
| 590 } | 574 CFX_FloatRect rcUnderline = GetUnderLineRect(word); |
| 575 rcUnderline.left += ptOffset.x; |
| 576 rcUnderline.right += ptOffset.x; |
| 577 rcUnderline.top += ptOffset.y; |
| 578 rcUnderline.bottom += ptOffset.y; |
| 591 | 579 |
| 592 if (word.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) { | 580 AddRectToPageObjects(pObjectHolder, crCurText, rcUnderline); |
| 593 CFX_FloatRect rcCrossout = GetCrossoutRect(word); | 581 } |
| 594 rcCrossout.left += ptOffset.x; | |
| 595 rcCrossout.right += ptOffset.x; | |
| 596 rcCrossout.top += ptOffset.y; | |
| 597 rcCrossout.bottom += ptOffset.y; | |
| 598 | 582 |
| 599 AddRectToPageObjects(pObjectHolder, crCurText, rcCrossout); | 583 if (word.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) { |
| 600 } | 584 CFX_FloatRect rcCrossout = GetCrossoutRect(word); |
| 585 rcCrossout.left += ptOffset.x; |
| 586 rcCrossout.right += ptOffset.x; |
| 587 rcCrossout.top += ptOffset.y; |
| 588 rcCrossout.bottom += ptOffset.y; |
| 601 | 589 |
| 602 oldplace = place; | 590 AddRectToPageObjects(pObjectHolder, crCurText, rcCrossout); |
| 603 } | 591 } |
| 592 |
| 593 oldplace = place; |
| 604 } | 594 } |
| 595 } |
| 605 | 596 |
| 606 if (sTextBuf.GetLength() > 0) { | 597 if (sTextBuf.GetLength() > 0) { |
| 607 ObjArray.Add(AddTextObjToPageObjects( | 598 ObjArray.Add(AddTextObjToPageObjects( |
| 608 pObjectHolder, crOld, pFontMap->GetPDFFont(wp.nFontIndex), | 599 pObjectHolder, crOld, pFontMap->GetPDFFont(wp.nFontIndex), |
| 609 wp.fFontSize, wp.fCharSpace, wp.nHorzScale, | 600 wp.fFontSize, wp.fCharSpace, wp.nHorzScale, |
| 610 CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), | 601 CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), |
| 611 sTextBuf.AsStringC())); | 602 sTextBuf.AsStringC())); |
| 612 } | |
| 613 } | 603 } |
| 614 } | 604 } |
| 615 } | 605 } |
| 616 | 606 |
| 617 void IFX_Edit::GenerateUnderlineObjects(CPDF_PageObjectHolder* pObjectHolder, | 607 void IFX_Edit::GenerateUnderlineObjects(CPDF_PageObjectHolder* pObjectHolder, |
| 618 IFX_Edit* pEdit, | 608 IFX_Edit* pEdit, |
| 619 const CFX_FloatPoint& ptOffset, | 609 const CFX_FloatPoint& ptOffset, |
| 620 const CPVT_WordRange* pRange, | 610 const CPVT_WordRange* pRange, |
| 621 FX_COLORREF color) { | 611 FX_COLORREF color) { |
| 622 if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) { | 612 IFX_Edit_Iterator* pIterator = pEdit->GetIterator(); |
| 623 if (pEdit->GetFontMap()) { | 613 if (pEdit->GetFontMap()) { |
| 624 if (pRange) | 614 if (pRange) |
| 625 pIterator->SetAt(pRange->BeginPos); | 615 pIterator->SetAt(pRange->BeginPos); |
| 626 else | 616 else |
| 627 pIterator->SetAt(0); | 617 pIterator->SetAt(0); |
| 628 | 618 |
| 629 CPVT_WordPlace oldplace; | 619 CPVT_WordPlace oldplace; |
| 630 | 620 |
| 631 while (pIterator->NextWord()) { | 621 while (pIterator->NextWord()) { |
| 632 CPVT_WordPlace place = pIterator->GetAt(); | 622 CPVT_WordPlace place = pIterator->GetAt(); |
| 633 if (pRange && place.WordCmp(pRange->EndPos) > 0) | 623 if (pRange && place.WordCmp(pRange->EndPos) > 0) |
| 634 break; | 624 break; |
| 635 | 625 |
| 636 CPVT_Word word; | 626 CPVT_Word word; |
| 637 if (pIterator->GetWord(word)) { | 627 if (pIterator->GetWord(word)) { |
| 638 CFX_FloatRect rcUnderline = GetUnderLineRect(word); | 628 CFX_FloatRect rcUnderline = GetUnderLineRect(word); |
| 639 rcUnderline.left += ptOffset.x; | 629 rcUnderline.left += ptOffset.x; |
| 640 rcUnderline.right += ptOffset.x; | 630 rcUnderline.right += ptOffset.x; |
| 641 rcUnderline.top += ptOffset.y; | 631 rcUnderline.top += ptOffset.y; |
| 642 rcUnderline.bottom += ptOffset.y; | 632 rcUnderline.bottom += ptOffset.y; |
| 643 AddRectToPageObjects(pObjectHolder, color, rcUnderline); | 633 AddRectToPageObjects(pObjectHolder, color, rcUnderline); |
| 644 } | |
| 645 } | 634 } |
| 646 } | 635 } |
| 647 } | 636 } |
| 648 } | 637 } |
| OLD | NEW |