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 "fpdfsdk/pdfwindow/PWL_Edit.h" | 7 #include "fpdfsdk/pdfwindow/PWL_Edit.h" |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 247 matching lines...) Loading... |
258 CFX_FloatRect rcClient = GetClientRect(); | 258 CFX_FloatRect rcClient = GetClientRect(); |
259 CFX_ByteTextBuf sLine; | 259 CFX_ByteTextBuf sLine; |
260 | 260 |
261 int32_t nCharArray = m_pEdit->GetCharArray(); | 261 int32_t nCharArray = m_pEdit->GetCharArray(); |
262 | 262 |
263 if (nCharArray > 0) { | 263 if (nCharArray > 0) { |
264 switch (GetBorderStyle()) { | 264 switch (GetBorderStyle()) { |
265 case PBS_SOLID: { | 265 case PBS_SOLID: { |
266 sLine << "q\n" << GetBorderWidth() << " w\n" | 266 sLine << "q\n" << GetBorderWidth() << " w\n" |
267 << CPWL_Utils::GetColorAppStream(GetBorderColor(), FALSE) | 267 << CPWL_Utils::GetColorAppStream(GetBorderColor(), FALSE) |
| 268 .AsByteStringC() |
268 << " 2 J 0 j\n"; | 269 << " 2 J 0 j\n"; |
269 | 270 |
270 for (int32_t i = 1; i < nCharArray; i++) { | 271 for (int32_t i = 1; i < nCharArray; i++) { |
271 sLine << rcClient.left + | 272 sLine << rcClient.left + |
272 ((rcClient.right - rcClient.left) / nCharArray) * i | 273 ((rcClient.right - rcClient.left) / nCharArray) * i |
273 << " " << rcClient.bottom << " m\n" | 274 << " " << rcClient.bottom << " m\n" |
274 << rcClient.left + | 275 << rcClient.left + |
275 ((rcClient.right - rcClient.left) / nCharArray) * i | 276 ((rcClient.right - rcClient.left) / nCharArray) * i |
276 << " " << rcClient.top << " l S\n"; | 277 << " " << rcClient.top << " l S\n"; |
277 } | 278 } |
278 | 279 |
279 sLine << "Q\n"; | 280 sLine << "Q\n"; |
280 } break; | 281 } break; |
281 case PBS_DASH: { | 282 case PBS_DASH: { |
282 sLine << "q\n" << GetBorderWidth() << " w\n" | 283 sLine << "q\n" << GetBorderWidth() << " w\n" |
283 << CPWL_Utils::GetColorAppStream(GetBorderColor(), FALSE) | 284 << CPWL_Utils::GetColorAppStream(GetBorderColor(), FALSE) |
| 285 .AsByteStringC() |
284 << " 2 J 0 j\n" | 286 << " 2 J 0 j\n" |
285 << "[" << GetBorderDash().nDash << " " << GetBorderDash().nGap | 287 << "[" << GetBorderDash().nDash << " " << GetBorderDash().nGap |
286 << "] " << GetBorderDash().nPhase << " d\n"; | 288 << "] " << GetBorderDash().nPhase << " d\n"; |
287 | 289 |
288 for (int32_t i = 1; i < nCharArray; i++) { | 290 for (int32_t i = 1; i < nCharArray; i++) { |
289 sLine << rcClient.left + | 291 sLine << rcClient.left + |
290 ((rcClient.right - rcClient.left) / nCharArray) * i | 292 ((rcClient.right - rcClient.left) / nCharArray) * i |
291 << " " << rcClient.bottom << " m\n" | 293 << " " << rcClient.bottom << " m\n" |
292 << rcClient.left + | 294 << rcClient.left + |
293 ((rcClient.right - rcClient.left) / nCharArray) * i | 295 ((rcClient.right - rcClient.left) / nCharArray) * i |
(...skipping 18 matching lines...) Loading... |
312 CPVT_WordRange wrSelBefore(wrWhole.BeginPos, wrSelect.BeginPos); | 314 CPVT_WordRange wrSelBefore(wrWhole.BeginPos, wrSelect.BeginPos); |
313 CPVT_WordRange wrSelAfter(wrSelect.EndPos, wrWhole.EndPos); | 315 CPVT_WordRange wrSelAfter(wrSelect.EndPos, wrWhole.EndPos); |
314 | 316 |
315 CPVT_WordRange wrTemp = | 317 CPVT_WordRange wrTemp = |
316 CPWL_Utils::OverlapWordRange(GetSelectWordRange(), wrVisible); | 318 CPWL_Utils::OverlapWordRange(GetSelectWordRange(), wrVisible); |
317 CFX_ByteString sEditSel = | 319 CFX_ByteString sEditSel = |
318 CPWL_Utils::GetEditSelAppStream(m_pEdit, ptOffset, &wrTemp); | 320 CPWL_Utils::GetEditSelAppStream(m_pEdit, ptOffset, &wrTemp); |
319 | 321 |
320 if (sEditSel.GetLength() > 0) | 322 if (sEditSel.GetLength() > 0) |
321 sText << CPWL_Utils::GetColorAppStream(PWL_DEFAULT_SELBACKCOLOR) | 323 sText << CPWL_Utils::GetColorAppStream(PWL_DEFAULT_SELBACKCOLOR) |
322 << sEditSel; | 324 .AsByteStringC() |
| 325 << sEditSel.AsByteStringC(); |
323 | 326 |
324 wrTemp = CPWL_Utils::OverlapWordRange(wrVisible, wrSelBefore); | 327 wrTemp = CPWL_Utils::OverlapWordRange(wrVisible, wrSelBefore); |
325 CFX_ByteString sEditBefore = CPWL_Utils::GetEditAppStream( | 328 CFX_ByteString sEditBefore = CPWL_Utils::GetEditAppStream( |
326 m_pEdit, ptOffset, &wrTemp, !HasFlag(PES_CHARARRAY), | 329 m_pEdit, ptOffset, &wrTemp, !HasFlag(PES_CHARARRAY), |
327 m_pEdit->GetPasswordChar()); | 330 m_pEdit->GetPasswordChar()); |
328 | 331 |
329 if (sEditBefore.GetLength() > 0) | 332 if (sEditBefore.GetLength() > 0) |
330 sText << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()) | 333 sText << "BT\n" |
331 << sEditBefore << "ET\n"; | 334 << CPWL_Utils::GetColorAppStream(GetTextColor()).AsByteStringC() |
| 335 << sEditBefore.AsByteStringC() << "ET\n"; |
332 | 336 |
333 wrTemp = CPWL_Utils::OverlapWordRange(wrVisible, wrSelect); | 337 wrTemp = CPWL_Utils::OverlapWordRange(wrVisible, wrSelect); |
334 CFX_ByteString sEditMid = CPWL_Utils::GetEditAppStream( | 338 CFX_ByteString sEditMid = CPWL_Utils::GetEditAppStream( |
335 m_pEdit, ptOffset, &wrTemp, !HasFlag(PES_CHARARRAY), | 339 m_pEdit, ptOffset, &wrTemp, !HasFlag(PES_CHARARRAY), |
336 m_pEdit->GetPasswordChar()); | 340 m_pEdit->GetPasswordChar()); |
337 | 341 |
338 if (sEditMid.GetLength() > 0) | 342 if (sEditMid.GetLength() > 0) |
339 sText << "BT\n" | 343 sText << "BT\n" |
340 << CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_GRAY, 1)) | 344 << CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_GRAY, 1)) |
341 << sEditMid << "ET\n"; | 345 .AsByteStringC() |
| 346 << sEditMid.AsByteStringC() << "ET\n"; |
342 | 347 |
343 wrTemp = CPWL_Utils::OverlapWordRange(wrVisible, wrSelAfter); | 348 wrTemp = CPWL_Utils::OverlapWordRange(wrVisible, wrSelAfter); |
344 CFX_ByteString sEditAfter = CPWL_Utils::GetEditAppStream( | 349 CFX_ByteString sEditAfter = CPWL_Utils::GetEditAppStream( |
345 m_pEdit, ptOffset, &wrTemp, !HasFlag(PES_CHARARRAY), | 350 m_pEdit, ptOffset, &wrTemp, !HasFlag(PES_CHARARRAY), |
346 m_pEdit->GetPasswordChar()); | 351 m_pEdit->GetPasswordChar()); |
347 | 352 |
348 if (sEditAfter.GetLength() > 0) | 353 if (sEditAfter.GetLength() > 0) |
349 sText << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()) | 354 sText << "BT\n" |
350 << sEditAfter << "ET\n"; | 355 << CPWL_Utils::GetColorAppStream(GetTextColor()).AsByteStringC() |
| 356 << sEditAfter.AsByteStringC() << "ET\n"; |
351 | 357 |
352 if (HasFlag(PES_SPELLCHECK)) { | 358 if (HasFlag(PES_SPELLCHECK)) { |
353 CFX_ByteString sSpellCheck = CPWL_Utils::GetSpellCheckAppStream( | 359 CFX_ByteString sSpellCheck = CPWL_Utils::GetSpellCheckAppStream( |
354 m_pEdit, m_pSpellCheck, ptOffset, &wrVisible); | 360 m_pEdit, m_pSpellCheck, ptOffset, &wrVisible); |
355 if (sSpellCheck.GetLength() > 0) | 361 if (sSpellCheck.GetLength() > 0) |
356 sText << CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_RGB, 1, 0, 0), | 362 sText << CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_RGB, 1, 0, 0), |
357 FALSE) | 363 FALSE) |
358 << sSpellCheck; | 364 .AsByteStringC() |
| 365 << sSpellCheck.AsByteStringC(); |
359 } | 366 } |
360 | 367 |
361 if (sText.GetLength() > 0) { | 368 if (sText.GetLength() > 0) { |
362 CFX_FloatRect rcClient = GetClientRect(); | 369 CFX_FloatRect rcClient = GetClientRect(); |
363 sAppStream << "q\n/Tx BMC\n"; | 370 sAppStream << "q\n/Tx BMC\n"; |
364 | 371 |
365 if (!HasFlag(PES_TEXTOVERFLOW)) | 372 if (!HasFlag(PES_TEXTOVERFLOW)) |
366 sAppStream << rcClient.left << " " << rcClient.bottom << " " | 373 sAppStream << rcClient.left << " " << rcClient.bottom << " " |
367 << rcClient.right - rcClient.left << " " | 374 << rcClient.right - rcClient.left << " " |
368 << rcClient.top - rcClient.bottom << " re W n\n"; | 375 << rcClient.top - rcClient.bottom << " re W n\n"; |
(...skipping 366 matching lines...) Loading... |
735 | 742 |
736 return CPVT_WordRange(); | 743 return CPVT_WordRange(); |
737 } | 744 } |
738 | 745 |
739 CFX_ByteString CPWL_Edit::GetTextAppearanceStream( | 746 CFX_ByteString CPWL_Edit::GetTextAppearanceStream( |
740 const CFX_FloatPoint& ptOffset) const { | 747 const CFX_FloatPoint& ptOffset) const { |
741 CFX_ByteTextBuf sRet; | 748 CFX_ByteTextBuf sRet; |
742 CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(m_pEdit, ptOffset); | 749 CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(m_pEdit, ptOffset); |
743 | 750 |
744 if (sEdit.GetLength() > 0) { | 751 if (sEdit.GetLength() > 0) { |
745 sRet << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()) << sEdit | 752 sRet << "BT\n" |
746 << "ET\n"; | 753 << CPWL_Utils::GetColorAppStream(GetTextColor()).AsByteStringC() |
| 754 << sEdit.AsByteStringC() << "ET\n"; |
747 } | 755 } |
748 | 756 |
749 return sRet.GetByteString(); | 757 return sRet.GetByteString(); |
750 } | 758 } |
751 | 759 |
752 CFX_ByteString CPWL_Edit::GetCaretAppearanceStream( | 760 CFX_ByteString CPWL_Edit::GetCaretAppearanceStream( |
753 const CFX_FloatPoint& ptOffset) const { | 761 const CFX_FloatPoint& ptOffset) const { |
754 if (m_pEditCaret) | 762 if (m_pEditCaret) |
755 return m_pEditCaret->GetCaretAppearanceStream(ptOffset); | 763 return m_pEditCaret->GetCaretAppearanceStream(ptOffset); |
756 | 764 |
(...skipping 426 matching lines...) Loading... |
1183 } | 1191 } |
1184 | 1192 |
1185 void CPWL_Edit::GeneratePageObjects(CPDF_PageObjectHolder* pObjectHolder, | 1193 void CPWL_Edit::GeneratePageObjects(CPDF_PageObjectHolder* pObjectHolder, |
1186 const CFX_FloatPoint& ptOffset) { | 1194 const CFX_FloatPoint& ptOffset) { |
1187 CFX_ArrayTemplate<CPDF_TextObject*> ObjArray; | 1195 CFX_ArrayTemplate<CPDF_TextObject*> ObjArray; |
1188 IFX_Edit::GeneratePageObjects( | 1196 IFX_Edit::GeneratePageObjects( |
1189 pObjectHolder, m_pEdit, ptOffset, NULL, | 1197 pObjectHolder, m_pEdit, ptOffset, NULL, |
1190 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), | 1198 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), |
1191 ObjArray); | 1199 ObjArray); |
1192 } | 1200 } |
OLD | NEW |