| 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 } | 221 } |
| 222 | 222 |
| 223 if (bContinuous) { | 223 if (bContinuous) { |
| 224 if (place.LineCmp(oldplace) != 0 || word.nFontIndex != nFontIndex || | 224 if (place.LineCmp(oldplace) != 0 || word.nFontIndex != nFontIndex || |
| 225 crOldFill != crCurFill) { | 225 crOldFill != crCurFill) { |
| 226 if (sTextBuf.GetLength() > 0) { | 226 if (sTextBuf.GetLength() > 0) { |
| 227 DrawTextString( | 227 DrawTextString( |
| 228 pDevice, | 228 pDevice, |
| 229 CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), | 229 CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), |
| 230 pFontMap->GetPDFFont(nFontIndex), fFontSize, pUser2Device, | 230 pFontMap->GetPDFFont(nFontIndex), fFontSize, pUser2Device, |
| 231 sTextBuf.AsStringC(), crOldFill, crTextStroke, nHorzScale); | 231 sTextBuf.MakeString(), crOldFill, crTextStroke, nHorzScale); |
| 232 | 232 |
| 233 sTextBuf.Clear(); | 233 sTextBuf.Clear(); |
| 234 } | 234 } |
| 235 nFontIndex = word.nFontIndex; | 235 nFontIndex = word.nFontIndex; |
| 236 ptBT = word.ptWord; | 236 ptBT = word.ptWord; |
| 237 crOldFill = crCurFill; | 237 crOldFill = crCurFill; |
| 238 } | 238 } |
| 239 | 239 |
| 240 sTextBuf << GetPDFWordString(pFontMap, word.nFontIndex, word.Word, | 240 sTextBuf << GetPDFWordString(pFontMap, word.nFontIndex, word.Word, |
| 241 SubWord) | 241 SubWord) |
| 242 .AsStringC(); | 242 .AsStringC(); |
| 243 } else { | 243 } else { |
| 244 DrawTextString( | 244 DrawTextString( |
| 245 pDevice, CFX_FloatPoint(word.ptWord.x + ptOffset.x, | 245 pDevice, CFX_FloatPoint(word.ptWord.x + ptOffset.x, |
| 246 word.ptWord.y + ptOffset.y), | 246 word.ptWord.y + ptOffset.y), |
| 247 pFontMap->GetPDFFont(word.nFontIndex), fFontSize, pUser2Device, | 247 pFontMap->GetPDFFont(word.nFontIndex), fFontSize, pUser2Device, |
| 248 GetPDFWordString(pFontMap, word.nFontIndex, word.Word, SubWord), | 248 GetPDFWordString(pFontMap, word.nFontIndex, word.Word, SubWord), |
| 249 crCurFill, crTextStroke, nHorzScale); | 249 crCurFill, crTextStroke, nHorzScale); |
| 250 } | 250 } |
| 251 oldplace = place; | 251 oldplace = place; |
| 252 } | 252 } |
| 253 } | 253 } |
| 254 | 254 |
| 255 if (sTextBuf.GetLength() > 0) { | 255 if (sTextBuf.GetLength() > 0) { |
| 256 DrawTextString(pDevice, | 256 DrawTextString( |
| 257 CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), | 257 pDevice, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), |
| 258 pFontMap->GetPDFFont(nFontIndex), fFontSize, pUser2Device, | 258 pFontMap->GetPDFFont(nFontIndex), fFontSize, pUser2Device, |
| 259 sTextBuf.AsStringC(), crOldFill, crTextStroke, nHorzScale); | 259 sTextBuf.MakeString(), crOldFill, crTextStroke, nHorzScale); |
| 260 } | 260 } |
| 261 } | 261 } |
| 262 | 262 |
| 263 pDevice->RestoreState(); | 263 pDevice->RestoreState(); |
| 264 } | 264 } |
| 265 | 265 |
| 266 void IFX_Edit::DrawRichEdit(CFX_RenderDevice* pDevice, | 266 void IFX_Edit::DrawRichEdit(CFX_RenderDevice* pDevice, |
| 267 CFX_Matrix* pUser2Device, | 267 CFX_Matrix* pUser2Device, |
| 268 IFX_Edit* pEdit, | 268 IFX_Edit* pEdit, |
| 269 const CFX_FloatRect& rcClip, | 269 const CFX_FloatRect& rcClip, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 | 333 |
| 334 if (place.LineCmp(oldplace) != 0 || word.WordProps.fCharSpace > 0.0f || | 334 if (place.LineCmp(oldplace) != 0 || word.WordProps.fCharSpace > 0.0f || |
| 335 word.WordProps.nHorzScale != 100 || | 335 word.WordProps.nHorzScale != 100 || |
| 336 FXSYS_memcmp(&word.WordProps, &wp, sizeof(CPVT_WordProps)) != 0 || | 336 FXSYS_memcmp(&word.WordProps, &wp, sizeof(CPVT_WordProps)) != 0 || |
| 337 crOld != crCurText) { | 337 crOld != crCurText) { |
| 338 if (sTextBuf.GetLength() > 0) { | 338 if (sTextBuf.GetLength() > 0) { |
| 339 DrawTextString( | 339 DrawTextString( |
| 340 pDevice, | 340 pDevice, |
| 341 CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), | 341 CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), |
| 342 pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, pUser2Device, | 342 pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, pUser2Device, |
| 343 sTextBuf.AsStringC(), crOld, 0, wp.nHorzScale); | 343 sTextBuf.MakeString(), crOld, 0, wp.nHorzScale); |
| 344 | 344 |
| 345 sTextBuf.Clear(); | 345 sTextBuf.Clear(); |
| 346 } | 346 } |
| 347 wp = word.WordProps; | 347 wp = word.WordProps; |
| 348 ptBT = word.ptWord; | 348 ptBT = word.ptWord; |
| 349 crOld = crCurText; | 349 crOld = crCurText; |
| 350 } | 350 } |
| 351 | 351 |
| 352 sTextBuf << GetPDFWordString(pFontMap, word.WordProps.nFontIndex, | 352 sTextBuf << GetPDFWordString(pFontMap, word.WordProps.nFontIndex, |
| 353 word.Word, 0) | 353 word.Word, 0) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 374 } | 374 } |
| 375 | 375 |
| 376 oldplace = place; | 376 oldplace = place; |
| 377 } | 377 } |
| 378 } | 378 } |
| 379 | 379 |
| 380 if (sTextBuf.GetLength() > 0) { | 380 if (sTextBuf.GetLength() > 0) { |
| 381 DrawTextString( | 381 DrawTextString( |
| 382 pDevice, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), | 382 pDevice, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), |
| 383 pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, pUser2Device, | 383 pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, pUser2Device, |
| 384 sTextBuf.AsStringC(), crOld, 0, wp.nHorzScale); | 384 sTextBuf.MakeString(), crOld, 0, wp.nHorzScale); |
| 385 } | 385 } |
| 386 } | 386 } |
| 387 | 387 |
| 388 pDevice->RestoreState(); | 388 pDevice->RestoreState(); |
| 389 } | 389 } |
| 390 | 390 |
| 391 static void AddRectToPageObjects(CPDF_PageObjectHolder* pObjectHolder, | 391 static void AddRectToPageObjects(CPDF_PageObjectHolder* pObjectHolder, |
| 392 FX_COLORREF crFill, | 392 FX_COLORREF crFill, |
| 393 const CFX_FloatRect& rcFill) { | 393 const CFX_FloatRect& rcFill) { |
| 394 std::unique_ptr<CPDF_PathObject> pPathObj(new CPDF_PathObject); | 394 std::unique_ptr<CPDF_PathObject> pPathObj(new CPDF_PathObject); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 break; | 476 break; |
| 477 | 477 |
| 478 CPVT_Word word; | 478 CPVT_Word word; |
| 479 if (pIterator->GetWord(word)) { | 479 if (pIterator->GetWord(word)) { |
| 480 if (place.LineCmp(oldplace) != 0 || nOldFontIndex != word.nFontIndex) { | 480 if (place.LineCmp(oldplace) != 0 || nOldFontIndex != word.nFontIndex) { |
| 481 if (sTextBuf.GetLength() > 0) { | 481 if (sTextBuf.GetLength() > 0) { |
| 482 ObjArray.Add(AddTextObjToPageObjects( | 482 ObjArray.Add(AddTextObjToPageObjects( |
| 483 pObjectHolder, crText, pFontMap->GetPDFFont(nOldFontIndex), | 483 pObjectHolder, crText, pFontMap->GetPDFFont(nOldFontIndex), |
| 484 fFontSize, 0.0f, 100, | 484 fFontSize, 0.0f, 100, |
| 485 CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), | 485 CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), |
| 486 sTextBuf.AsStringC())); | 486 sTextBuf.MakeString())); |
| 487 | 487 |
| 488 sTextBuf.Clear(); | 488 sTextBuf.Clear(); |
| 489 } | 489 } |
| 490 | 490 |
| 491 ptBT = word.ptWord; | 491 ptBT = word.ptWord; |
| 492 nOldFontIndex = word.nFontIndex; | 492 nOldFontIndex = word.nFontIndex; |
| 493 } | 493 } |
| 494 | 494 |
| 495 sTextBuf << GetPDFWordString(pFontMap, word.nFontIndex, word.Word, 0) | 495 sTextBuf << GetPDFWordString(pFontMap, word.nFontIndex, word.Word, 0) |
| 496 .AsStringC(); | 496 .AsStringC(); |
| 497 oldplace = place; | 497 oldplace = place; |
| 498 } | 498 } |
| 499 } | 499 } |
| 500 | 500 |
| 501 if (sTextBuf.GetLength() > 0) { | 501 if (sTextBuf.GetLength() > 0) { |
| 502 ObjArray.Add(AddTextObjToPageObjects( | 502 ObjArray.Add(AddTextObjToPageObjects( |
| 503 pObjectHolder, crText, pFontMap->GetPDFFont(nOldFontIndex), fFontSize, | 503 pObjectHolder, crText, pFontMap->GetPDFFont(nOldFontIndex), fFontSize, |
| 504 0.0f, 100, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), | 504 0.0f, 100, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), |
| 505 sTextBuf.AsStringC())); | 505 sTextBuf.MakeString())); |
| 506 } | 506 } |
| 507 } | 507 } |
| 508 } | 508 } |
| 509 | 509 |
| 510 void IFX_Edit::GenerateRichPageObjects( | 510 void IFX_Edit::GenerateRichPageObjects( |
| 511 CPDF_PageObjectHolder* pObjectHolder, | 511 CPDF_PageObjectHolder* pObjectHolder, |
| 512 IFX_Edit* pEdit, | 512 IFX_Edit* pEdit, |
| 513 const CFX_FloatPoint& ptOffset, | 513 const CFX_FloatPoint& ptOffset, |
| 514 const CPVT_WordRange* pRange, | 514 const CPVT_WordRange* pRange, |
| 515 CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray) { | 515 CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 544 | 544 |
| 545 if (place.LineCmp(oldplace) != 0 || word.WordProps.fCharSpace > 0.0f || | 545 if (place.LineCmp(oldplace) != 0 || word.WordProps.fCharSpace > 0.0f || |
| 546 word.WordProps.nHorzScale != 100 || | 546 word.WordProps.nHorzScale != 100 || |
| 547 FXSYS_memcmp(&word.WordProps, &wp, sizeof(CPVT_WordProps)) != 0 || | 547 FXSYS_memcmp(&word.WordProps, &wp, sizeof(CPVT_WordProps)) != 0 || |
| 548 crOld != crCurText) { | 548 crOld != crCurText) { |
| 549 if (sTextBuf.GetLength() > 0) { | 549 if (sTextBuf.GetLength() > 0) { |
| 550 ObjArray.Add(AddTextObjToPageObjects( | 550 ObjArray.Add(AddTextObjToPageObjects( |
| 551 pObjectHolder, crOld, pFontMap->GetPDFFont(wp.nFontIndex), | 551 pObjectHolder, crOld, pFontMap->GetPDFFont(wp.nFontIndex), |
| 552 wp.fFontSize, wp.fCharSpace, wp.nHorzScale, | 552 wp.fFontSize, wp.fCharSpace, wp.nHorzScale, |
| 553 CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), | 553 CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), |
| 554 sTextBuf.AsStringC())); | 554 sTextBuf.MakeString())); |
| 555 | 555 |
| 556 sTextBuf.Clear(); | 556 sTextBuf.Clear(); |
| 557 } | 557 } |
| 558 | 558 |
| 559 wp = word.WordProps; | 559 wp = word.WordProps; |
| 560 ptBT = word.ptWord; | 560 ptBT = word.ptWord; |
| 561 crOld = crCurText; | 561 crOld = crCurText; |
| 562 } | 562 } |
| 563 | 563 |
| 564 sTextBuf << GetPDFWordString(pFontMap, word.WordProps.nFontIndex, | 564 sTextBuf << GetPDFWordString(pFontMap, word.WordProps.nFontIndex, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 587 | 587 |
| 588 oldplace = place; | 588 oldplace = place; |
| 589 } | 589 } |
| 590 } | 590 } |
| 591 | 591 |
| 592 if (sTextBuf.GetLength() > 0) { | 592 if (sTextBuf.GetLength() > 0) { |
| 593 ObjArray.Add(AddTextObjToPageObjects( | 593 ObjArray.Add(AddTextObjToPageObjects( |
| 594 pObjectHolder, crOld, pFontMap->GetPDFFont(wp.nFontIndex), | 594 pObjectHolder, crOld, pFontMap->GetPDFFont(wp.nFontIndex), |
| 595 wp.fFontSize, wp.fCharSpace, wp.nHorzScale, | 595 wp.fFontSize, wp.fCharSpace, wp.nHorzScale, |
| 596 CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), | 596 CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), |
| 597 sTextBuf.AsStringC())); | 597 sTextBuf.MakeString())); |
| 598 } | 598 } |
| 599 } | 599 } |
| 600 } | 600 } |
| 601 | 601 |
| 602 void IFX_Edit::GenerateUnderlineObjects(CPDF_PageObjectHolder* pObjectHolder, | 602 void IFX_Edit::GenerateUnderlineObjects(CPDF_PageObjectHolder* pObjectHolder, |
| 603 IFX_Edit* pEdit, | 603 IFX_Edit* pEdit, |
| 604 const CFX_FloatPoint& ptOffset, | 604 const CFX_FloatPoint& ptOffset, |
| 605 const CPVT_WordRange* pRange, | 605 const CPVT_WordRange* pRange, |
| 606 FX_COLORREF color) { | 606 FX_COLORREF color) { |
| 607 IFX_Edit_Iterator* pIterator = pEdit->GetIterator(); | 607 IFX_Edit_Iterator* pIterator = pEdit->GetIterator(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 623 CFX_FloatRect rcUnderline = GetUnderLineRect(word); | 623 CFX_FloatRect rcUnderline = GetUnderLineRect(word); |
| 624 rcUnderline.left += ptOffset.x; | 624 rcUnderline.left += ptOffset.x; |
| 625 rcUnderline.right += ptOffset.x; | 625 rcUnderline.right += ptOffset.x; |
| 626 rcUnderline.top += ptOffset.y; | 626 rcUnderline.top += ptOffset.y; |
| 627 rcUnderline.bottom += ptOffset.y; | 627 rcUnderline.bottom += ptOffset.y; |
| 628 AddRectToPageObjects(pObjectHolder, color, rcUnderline); | 628 AddRectToPageObjects(pObjectHolder, color, rcUnderline); |
| 629 } | 629 } |
| 630 } | 630 } |
| 631 } | 631 } |
| 632 } | 632 } |
| OLD | NEW |