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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 CFX_FloatRect rcClient = GetClientRect(); | 253 CFX_FloatRect rcClient = GetClientRect(); |
254 CFX_ByteTextBuf sLine; | 254 CFX_ByteTextBuf sLine; |
255 | 255 |
256 int32_t nCharArray = m_pEdit->GetCharArray(); | 256 int32_t nCharArray = m_pEdit->GetCharArray(); |
257 | 257 |
258 if (nCharArray > 0) { | 258 if (nCharArray > 0) { |
259 switch (GetBorderStyle()) { | 259 switch (GetBorderStyle()) { |
260 case PBS_SOLID: { | 260 case PBS_SOLID: { |
261 sLine << "q\n" << GetBorderWidth() << " w\n" | 261 sLine << "q\n" << GetBorderWidth() << " w\n" |
262 << CPWL_Utils::GetColorAppStream(GetBorderColor(), FALSE) | 262 << CPWL_Utils::GetColorAppStream(GetBorderColor(), FALSE) |
263 .AsByteStringC() | 263 .AsStringC() |
264 << " 2 J 0 j\n"; | 264 << " 2 J 0 j\n"; |
265 | 265 |
266 for (int32_t i = 1; i < nCharArray; i++) { | 266 for (int32_t i = 1; i < nCharArray; i++) { |
267 sLine << rcClient.left + | 267 sLine << rcClient.left + |
268 ((rcClient.right - rcClient.left) / nCharArray) * i | 268 ((rcClient.right - rcClient.left) / nCharArray) * i |
269 << " " << rcClient.bottom << " m\n" | 269 << " " << rcClient.bottom << " m\n" |
270 << rcClient.left + | 270 << rcClient.left + |
271 ((rcClient.right - rcClient.left) / nCharArray) * i | 271 ((rcClient.right - rcClient.left) / nCharArray) * i |
272 << " " << rcClient.top << " l S\n"; | 272 << " " << rcClient.top << " l S\n"; |
273 } | 273 } |
274 | 274 |
275 sLine << "Q\n"; | 275 sLine << "Q\n"; |
276 } break; | 276 } break; |
277 case PBS_DASH: { | 277 case PBS_DASH: { |
278 sLine << "q\n" << GetBorderWidth() << " w\n" | 278 sLine << "q\n" << GetBorderWidth() << " w\n" |
279 << CPWL_Utils::GetColorAppStream(GetBorderColor(), FALSE) | 279 << CPWL_Utils::GetColorAppStream(GetBorderColor(), FALSE) |
280 .AsByteStringC() | 280 .AsStringC() |
281 << " 2 J 0 j\n" | 281 << " 2 J 0 j\n" |
282 << "[" << GetBorderDash().nDash << " " << GetBorderDash().nGap | 282 << "[" << GetBorderDash().nDash << " " << GetBorderDash().nGap |
283 << "] " << GetBorderDash().nPhase << " d\n"; | 283 << "] " << GetBorderDash().nPhase << " d\n"; |
284 | 284 |
285 for (int32_t i = 1; i < nCharArray; i++) { | 285 for (int32_t i = 1; i < nCharArray; i++) { |
286 sLine << rcClient.left + | 286 sLine << rcClient.left + |
287 ((rcClient.right - rcClient.left) / nCharArray) * i | 287 ((rcClient.right - rcClient.left) / nCharArray) * i |
288 << " " << rcClient.bottom << " m\n" | 288 << " " << rcClient.bottom << " m\n" |
289 << rcClient.left + | 289 << rcClient.left + |
290 ((rcClient.right - rcClient.left) / nCharArray) * i | 290 ((rcClient.right - rcClient.left) / nCharArray) * i |
(...skipping 17 matching lines...) Expand all Loading... |
308 (HasFlag(PES_TEXTOVERFLOW) ? wrWhole : m_pEdit->GetVisibleWordRange()); | 308 (HasFlag(PES_TEXTOVERFLOW) ? wrWhole : m_pEdit->GetVisibleWordRange()); |
309 CPVT_WordRange wrSelBefore(wrWhole.BeginPos, wrSelect.BeginPos); | 309 CPVT_WordRange wrSelBefore(wrWhole.BeginPos, wrSelect.BeginPos); |
310 CPVT_WordRange wrSelAfter(wrSelect.EndPos, wrWhole.EndPos); | 310 CPVT_WordRange wrSelAfter(wrSelect.EndPos, wrWhole.EndPos); |
311 | 311 |
312 CPVT_WordRange wrTemp = | 312 CPVT_WordRange wrTemp = |
313 CPWL_Utils::OverlapWordRange(GetSelectWordRange(), wrVisible); | 313 CPWL_Utils::OverlapWordRange(GetSelectWordRange(), wrVisible); |
314 CFX_ByteString sEditSel = | 314 CFX_ByteString sEditSel = |
315 CPWL_Utils::GetEditSelAppStream(m_pEdit, ptOffset, &wrTemp); | 315 CPWL_Utils::GetEditSelAppStream(m_pEdit, ptOffset, &wrTemp); |
316 | 316 |
317 if (sEditSel.GetLength() > 0) | 317 if (sEditSel.GetLength() > 0) |
318 sText << CPWL_Utils::GetColorAppStream(PWL_DEFAULT_SELBACKCOLOR) | 318 sText << CPWL_Utils::GetColorAppStream(PWL_DEFAULT_SELBACKCOLOR).AsStringC() |
319 .AsByteStringC() | 319 << sEditSel.AsStringC(); |
320 << sEditSel.AsByteStringC(); | |
321 | 320 |
322 wrTemp = CPWL_Utils::OverlapWordRange(wrVisible, wrSelBefore); | 321 wrTemp = CPWL_Utils::OverlapWordRange(wrVisible, wrSelBefore); |
323 CFX_ByteString sEditBefore = CPWL_Utils::GetEditAppStream( | 322 CFX_ByteString sEditBefore = CPWL_Utils::GetEditAppStream( |
324 m_pEdit, ptOffset, &wrTemp, !HasFlag(PES_CHARARRAY), | 323 m_pEdit, ptOffset, &wrTemp, !HasFlag(PES_CHARARRAY), |
325 m_pEdit->GetPasswordChar()); | 324 m_pEdit->GetPasswordChar()); |
326 | 325 |
327 if (sEditBefore.GetLength() > 0) | 326 if (sEditBefore.GetLength() > 0) |
328 sText << "BT\n" | 327 sText << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()).AsStringC() |
329 << CPWL_Utils::GetColorAppStream(GetTextColor()).AsByteStringC() | 328 << sEditBefore.AsStringC() << "ET\n"; |
330 << sEditBefore.AsByteStringC() << "ET\n"; | |
331 | 329 |
332 wrTemp = CPWL_Utils::OverlapWordRange(wrVisible, wrSelect); | 330 wrTemp = CPWL_Utils::OverlapWordRange(wrVisible, wrSelect); |
333 CFX_ByteString sEditMid = CPWL_Utils::GetEditAppStream( | 331 CFX_ByteString sEditMid = CPWL_Utils::GetEditAppStream( |
334 m_pEdit, ptOffset, &wrTemp, !HasFlag(PES_CHARARRAY), | 332 m_pEdit, ptOffset, &wrTemp, !HasFlag(PES_CHARARRAY), |
335 m_pEdit->GetPasswordChar()); | 333 m_pEdit->GetPasswordChar()); |
336 | 334 |
337 if (sEditMid.GetLength() > 0) | 335 if (sEditMid.GetLength() > 0) |
338 sText << "BT\n" | 336 sText << "BT\n" |
339 << CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_GRAY, 1)) | 337 << CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_GRAY, 1)) |
340 .AsByteStringC() | 338 .AsStringC() |
341 << sEditMid.AsByteStringC() << "ET\n"; | 339 << sEditMid.AsStringC() << "ET\n"; |
342 | 340 |
343 wrTemp = CPWL_Utils::OverlapWordRange(wrVisible, wrSelAfter); | 341 wrTemp = CPWL_Utils::OverlapWordRange(wrVisible, wrSelAfter); |
344 CFX_ByteString sEditAfter = CPWL_Utils::GetEditAppStream( | 342 CFX_ByteString sEditAfter = CPWL_Utils::GetEditAppStream( |
345 m_pEdit, ptOffset, &wrTemp, !HasFlag(PES_CHARARRAY), | 343 m_pEdit, ptOffset, &wrTemp, !HasFlag(PES_CHARARRAY), |
346 m_pEdit->GetPasswordChar()); | 344 m_pEdit->GetPasswordChar()); |
347 | 345 |
348 if (sEditAfter.GetLength() > 0) | 346 if (sEditAfter.GetLength() > 0) |
349 sText << "BT\n" | 347 sText << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()).AsStringC() |
350 << CPWL_Utils::GetColorAppStream(GetTextColor()).AsByteStringC() | 348 << sEditAfter.AsStringC() << "ET\n"; |
351 << sEditAfter.AsByteStringC() << "ET\n"; | |
352 | 349 |
353 if (sText.GetLength() > 0) { | 350 if (sText.GetLength() > 0) { |
354 CFX_FloatRect rcClient = GetClientRect(); | 351 CFX_FloatRect rcClient = GetClientRect(); |
355 sAppStream << "q\n/Tx BMC\n"; | 352 sAppStream << "q\n/Tx BMC\n"; |
356 | 353 |
357 if (!HasFlag(PES_TEXTOVERFLOW)) | 354 if (!HasFlag(PES_TEXTOVERFLOW)) |
358 sAppStream << rcClient.left << " " << rcClient.bottom << " " | 355 sAppStream << rcClient.left << " " << rcClient.bottom << " " |
359 << rcClient.right - rcClient.left << " " | 356 << rcClient.right - rcClient.left << " " |
360 << rcClient.top - rcClient.bottom << " re W n\n"; | 357 << rcClient.top - rcClient.bottom << " re W n\n"; |
361 | 358 |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 | 697 |
701 return CPVT_WordRange(); | 698 return CPVT_WordRange(); |
702 } | 699 } |
703 | 700 |
704 CFX_ByteString CPWL_Edit::GetTextAppearanceStream( | 701 CFX_ByteString CPWL_Edit::GetTextAppearanceStream( |
705 const CFX_FloatPoint& ptOffset) const { | 702 const CFX_FloatPoint& ptOffset) const { |
706 CFX_ByteTextBuf sRet; | 703 CFX_ByteTextBuf sRet; |
707 CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(m_pEdit, ptOffset); | 704 CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(m_pEdit, ptOffset); |
708 | 705 |
709 if (sEdit.GetLength() > 0) { | 706 if (sEdit.GetLength() > 0) { |
710 sRet << "BT\n" | 707 sRet << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()).AsStringC() |
711 << CPWL_Utils::GetColorAppStream(GetTextColor()).AsByteStringC() | 708 << sEdit.AsStringC() << "ET\n"; |
712 << sEdit.AsByteStringC() << "ET\n"; | |
713 } | 709 } |
714 | 710 |
715 return sRet.GetByteString(); | 711 return sRet.GetByteString(); |
716 } | 712 } |
717 | 713 |
718 CFX_ByteString CPWL_Edit::GetCaretAppearanceStream( | 714 CFX_ByteString CPWL_Edit::GetCaretAppearanceStream( |
719 const CFX_FloatPoint& ptOffset) const { | 715 const CFX_FloatPoint& ptOffset) const { |
720 if (m_pEditCaret) | 716 if (m_pEditCaret) |
721 return m_pEditCaret->GetCaretAppearanceStream(ptOffset); | 717 return m_pEditCaret->GetCaretAppearanceStream(ptOffset); |
722 | 718 |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1142 } | 1138 } |
1143 | 1139 |
1144 void CPWL_Edit::GeneratePageObjects(CPDF_PageObjectHolder* pObjectHolder, | 1140 void CPWL_Edit::GeneratePageObjects(CPDF_PageObjectHolder* pObjectHolder, |
1145 const CFX_FloatPoint& ptOffset) { | 1141 const CFX_FloatPoint& ptOffset) { |
1146 CFX_ArrayTemplate<CPDF_TextObject*> ObjArray; | 1142 CFX_ArrayTemplate<CPDF_TextObject*> ObjArray; |
1147 IFX_Edit::GeneratePageObjects( | 1143 IFX_Edit::GeneratePageObjects( |
1148 pObjectHolder, m_pEdit, ptOffset, NULL, | 1144 pObjectHolder, m_pEdit, ptOffset, NULL, |
1149 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), | 1145 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), |
1150 ObjArray); | 1146 ObjArray); |
1151 } | 1147 } |
OLD | NEW |