| 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/cpvt_generateap.h" | 7 #include "core/fpdfdoc/cpvt_generateap.h" |
| 8 | 8 |
| 9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" | 9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" |
| 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 subWord = '*'; | 238 subWord = '*'; |
| 239 vt.SetPasswordChar(subWord); | 239 vt.SetPasswordChar(subWord); |
| 240 } | 240 } |
| 241 FX_BOOL bCharArray = (dwFlags >> 24) & 1; | 241 FX_BOOL bCharArray = (dwFlags >> 24) & 1; |
| 242 if (bCharArray) | 242 if (bCharArray) |
| 243 vt.SetCharArray(dwMaxLen); | 243 vt.SetCharArray(dwMaxLen); |
| 244 else | 244 else |
| 245 vt.SetLimitChar(dwMaxLen); | 245 vt.SetLimitChar(dwMaxLen); |
| 246 | 246 |
| 247 vt.Initialize(); | 247 vt.Initialize(); |
| 248 vt.SetText(swValue.c_str()); | 248 vt.SetText(swValue); |
| 249 vt.RearrangeAll(); | 249 vt.RearrangeAll(); |
| 250 CFX_FloatRect rcContent = vt.GetContentRect(); | 250 CFX_FloatRect rcContent = vt.GetContentRect(); |
| 251 CFX_FloatPoint ptOffset(0.0f, 0.0f); | 251 CFX_FloatPoint ptOffset(0.0f, 0.0f); |
| 252 if (!bMultiLine) { | 252 if (!bMultiLine) { |
| 253 ptOffset = | 253 ptOffset = |
| 254 CFX_FloatPoint(0.0f, (rcContent.Height() - rcBody.Height()) / 2.0f); | 254 CFX_FloatPoint(0.0f, (rcContent.Height() - rcBody.Height()) / 2.0f); |
| 255 } | 255 } |
| 256 CFX_ByteString sBody = CPVT_GenerateAP::GenerateEditAP( | 256 CFX_ByteString sBody = CPVT_GenerateAP::GenerateEditAP( |
| 257 &map, vt.GetIterator(), ptOffset, !bCharArray, subWord); | 257 &map, vt.GetIterator(), ptOffset, !bCharArray, subWord); |
| 258 if (sBody.GetLength() > 0) { | 258 if (sBody.GetLength() > 0) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 288 CFX_FloatRect rcEdit = rcBody; | 288 CFX_FloatRect rcEdit = rcBody; |
| 289 rcEdit.right = rcButton.left; | 289 rcEdit.right = rcButton.left; |
| 290 rcEdit.Normalize(); | 290 rcEdit.Normalize(); |
| 291 vt.SetPlateRect(rcEdit); | 291 vt.SetPlateRect(rcEdit); |
| 292 if (IsFloatZero(fFontSize)) | 292 if (IsFloatZero(fFontSize)) |
| 293 vt.SetAutoFontSize(TRUE); | 293 vt.SetAutoFontSize(TRUE); |
| 294 else | 294 else |
| 295 vt.SetFontSize(fFontSize); | 295 vt.SetFontSize(fFontSize); |
| 296 | 296 |
| 297 vt.Initialize(); | 297 vt.Initialize(); |
| 298 vt.SetText(swValue.c_str()); | 298 vt.SetText(swValue); |
| 299 vt.RearrangeAll(); | 299 vt.RearrangeAll(); |
| 300 CFX_FloatRect rcContent = vt.GetContentRect(); | 300 CFX_FloatRect rcContent = vt.GetContentRect(); |
| 301 CFX_FloatPoint ptOffset = | 301 CFX_FloatPoint ptOffset = |
| 302 CFX_FloatPoint(0.0f, (rcContent.Height() - rcEdit.Height()) / 2.0f); | 302 CFX_FloatPoint(0.0f, (rcContent.Height() - rcEdit.Height()) / 2.0f); |
| 303 CFX_ByteString sEdit = CPVT_GenerateAP::GenerateEditAP( | 303 CFX_ByteString sEdit = CPVT_GenerateAP::GenerateEditAP( |
| 304 &map, vt.GetIterator(), ptOffset, TRUE, 0); | 304 &map, vt.GetIterator(), ptOffset, TRUE, 0); |
| 305 if (sEdit.GetLength() > 0) { | 305 if (sEdit.GetLength() > 0) { |
| 306 sAppStream << "/Tx BMC\n" | 306 sAppStream << "/Tx BMC\n" |
| 307 << "q\n"; | 307 << "q\n"; |
| 308 sAppStream << rcEdit.left << " " << rcEdit.bottom << " " | 308 sAppStream << rcEdit.left << " " << rcEdit.bottom << " " |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 } | 378 } |
| 379 } | 379 } |
| 380 } | 380 } |
| 381 CPDF_VariableText vt; | 381 CPDF_VariableText vt; |
| 382 vt.SetProvider(&prd); | 382 vt.SetProvider(&prd); |
| 383 vt.SetPlateRect( | 383 vt.SetPlateRect( |
| 384 CFX_FloatRect(rcBody.left, 0.0f, rcBody.right, 0.0f)); | 384 CFX_FloatRect(rcBody.left, 0.0f, rcBody.right, 0.0f)); |
| 385 vt.SetFontSize(IsFloatZero(fFontSize) ? 12.0f : fFontSize); | 385 vt.SetFontSize(IsFloatZero(fFontSize) ? 12.0f : fFontSize); |
| 386 | 386 |
| 387 vt.Initialize(); | 387 vt.Initialize(); |
| 388 vt.SetText(swItem.c_str()); | 388 vt.SetText(swItem); |
| 389 vt.RearrangeAll(); | 389 vt.RearrangeAll(); |
| 390 FX_FLOAT fItemHeight = vt.GetContentRect().Height(); | 390 FX_FLOAT fItemHeight = vt.GetContentRect().Height(); |
| 391 if (bSelected) { | 391 if (bSelected) { |
| 392 CFX_FloatRect rcItem = CFX_FloatRect( | 392 CFX_FloatRect rcItem = CFX_FloatRect( |
| 393 rcBody.left, fy - fItemHeight, rcBody.right, fy); | 393 rcBody.left, fy - fItemHeight, rcBody.right, fy); |
| 394 sBody << "q\n" | 394 sBody << "q\n" |
| 395 << CPVT_GenerateAP::GenerateColorAP( | 395 << CPVT_GenerateAP::GenerateColorAP( |
| 396 CPVT_Color(CPVT_Color::kRGB, 0, 51.0f / 255.0f, | 396 CPVT_Color(CPVT_Color::kRGB, 0, 51.0f / 255.0f, |
| 397 113.0f / 255.0f), | 397 113.0f / 255.0f), |
| 398 PaintOperation::FILL) | 398 PaintOperation::FILL) |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 | 520 |
| 521 CPDF_VariableText::Provider prd(&map); | 521 CPDF_VariableText::Provider prd(&map); |
| 522 CPDF_VariableText vt; | 522 CPDF_VariableText vt; |
| 523 vt.SetProvider(&prd); | 523 vt.SetProvider(&prd); |
| 524 vt.SetPlateRect(pAnnotDict.GetRectBy("Rect")); | 524 vt.SetPlateRect(pAnnotDict.GetRectBy("Rect")); |
| 525 vt.SetFontSize(12); | 525 vt.SetFontSize(12); |
| 526 vt.SetAutoReturn(TRUE); | 526 vt.SetAutoReturn(TRUE); |
| 527 vt.SetMultiLine(TRUE); | 527 vt.SetMultiLine(TRUE); |
| 528 | 528 |
| 529 vt.Initialize(); | 529 vt.Initialize(); |
| 530 vt.SetText(swValue.c_str()); | 530 vt.SetText(swValue); |
| 531 vt.RearrangeAll(); | 531 vt.RearrangeAll(); |
| 532 CFX_FloatPoint ptOffset(3.0f, -3.0f); | 532 CFX_FloatPoint ptOffset(3.0f, -3.0f); |
| 533 CFX_ByteString sContent = CPVT_GenerateAP::GenerateEditAP( | 533 CFX_ByteString sContent = CPVT_GenerateAP::GenerateEditAP( |
| 534 &map, vt.GetIterator(), ptOffset, FALSE, 0); | 534 &map, vt.GetIterator(), ptOffset, FALSE, 0); |
| 535 | 535 |
| 536 if (sContent.IsEmpty()) | 536 if (sContent.IsEmpty()) |
| 537 return CFX_ByteString(); | 537 return CFX_ByteString(); |
| 538 | 538 |
| 539 CFX_ByteTextBuf sAppStream; | 539 CFX_ByteTextBuf sAppStream; |
| 540 sAppStream << "BT\n" | 540 sAppStream << "BT\n" |
| (...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1345 int32_t nFontIndex, | 1345 int32_t nFontIndex, |
| 1346 FX_FLOAT fFontSize) { | 1346 FX_FLOAT fFontSize) { |
| 1347 CFX_ByteTextBuf sRet; | 1347 CFX_ByteTextBuf sRet; |
| 1348 if (pFontMap) { | 1348 if (pFontMap) { |
| 1349 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); | 1349 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); |
| 1350 if (sFontAlias.GetLength() > 0 && fFontSize > 0) | 1350 if (sFontAlias.GetLength() > 0 && fFontSize > 0) |
| 1351 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; | 1351 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; |
| 1352 } | 1352 } |
| 1353 return sRet.MakeString(); | 1353 return sRet.MakeString(); |
| 1354 } | 1354 } |
| OLD | NEW |