| 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { | 192 void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { |
| 193 CPWL_Wnd::GetThisAppearanceStream(sAppStream); | 193 CPWL_Wnd::GetThisAppearanceStream(sAppStream); |
| 194 | 194 |
| 195 CFX_FloatRect rcClient = GetClientRect(); | 195 CFX_FloatRect rcClient = GetClientRect(); |
| 196 CFX_ByteTextBuf sLine; | 196 CFX_ByteTextBuf sLine; |
| 197 | 197 |
| 198 int32_t nCharArray = m_pEdit->GetCharArray(); | 198 int32_t nCharArray = m_pEdit->GetCharArray(); |
| 199 | 199 |
| 200 if (nCharArray > 0) { | 200 if (nCharArray > 0) { |
| 201 switch (GetBorderStyle()) { | 201 switch (GetBorderStyle()) { |
| 202 case PBS_SOLID: { | 202 case BorderStyle::SOLID: { |
| 203 sLine << "q\n" << GetBorderWidth() << " w\n" | 203 sLine << "q\n" << GetBorderWidth() << " w\n" |
| 204 << CPWL_Utils::GetColorAppStream(GetBorderColor(), FALSE) | 204 << CPWL_Utils::GetColorAppStream(GetBorderColor(), FALSE) |
| 205 .AsStringC() | 205 .AsStringC() |
| 206 << " 2 J 0 j\n"; | 206 << " 2 J 0 j\n"; |
| 207 | 207 |
| 208 for (int32_t i = 1; i < nCharArray; i++) { | 208 for (int32_t i = 1; i < nCharArray; i++) { |
| 209 sLine << rcClient.left + | 209 sLine << rcClient.left + |
| 210 ((rcClient.right - rcClient.left) / nCharArray) * i | 210 ((rcClient.right - rcClient.left) / nCharArray) * i |
| 211 << " " << rcClient.bottom << " m\n" | 211 << " " << rcClient.bottom << " m\n" |
| 212 << rcClient.left + | 212 << rcClient.left + |
| 213 ((rcClient.right - rcClient.left) / nCharArray) * i | 213 ((rcClient.right - rcClient.left) / nCharArray) * i |
| 214 << " " << rcClient.top << " l S\n"; | 214 << " " << rcClient.top << " l S\n"; |
| 215 } | 215 } |
| 216 | 216 |
| 217 sLine << "Q\n"; | 217 sLine << "Q\n"; |
| 218 } break; | 218 break; |
| 219 case PBS_DASH: { | 219 } |
| 220 case BorderStyle::DASH: { |
| 220 sLine << "q\n" << GetBorderWidth() << " w\n" | 221 sLine << "q\n" << GetBorderWidth() << " w\n" |
| 221 << CPWL_Utils::GetColorAppStream(GetBorderColor(), FALSE) | 222 << CPWL_Utils::GetColorAppStream(GetBorderColor(), FALSE) |
| 222 .AsStringC() | 223 .AsStringC() |
| 223 << " 2 J 0 j\n" | 224 << " 2 J 0 j\n" |
| 224 << "[" << GetBorderDash().nDash << " " << GetBorderDash().nGap | 225 << "[" << GetBorderDash().nDash << " " << GetBorderDash().nGap |
| 225 << "] " << GetBorderDash().nPhase << " d\n"; | 226 << "] " << GetBorderDash().nPhase << " d\n"; |
| 226 | 227 |
| 227 for (int32_t i = 1; i < nCharArray; i++) { | 228 for (int32_t i = 1; i < nCharArray; i++) { |
| 228 sLine << rcClient.left + | 229 sLine << rcClient.left + |
| 229 ((rcClient.right - rcClient.left) / nCharArray) * i | 230 ((rcClient.right - rcClient.left) / nCharArray) * i |
| 230 << " " << rcClient.bottom << " m\n" | 231 << " " << rcClient.bottom << " m\n" |
| 231 << rcClient.left + | 232 << rcClient.left + |
| 232 ((rcClient.right - rcClient.left) / nCharArray) * i | 233 ((rcClient.right - rcClient.left) / nCharArray) * i |
| 233 << " " << rcClient.top << " l S\n"; | 234 << " " << rcClient.top << " l S\n"; |
| 234 } | 235 } |
| 235 | 236 |
| 236 sLine << "Q\n"; | 237 sLine << "Q\n"; |
| 237 } break; | 238 break; |
| 239 } |
| 240 default: |
| 241 break; |
| 238 } | 242 } |
| 239 } | 243 } |
| 240 | 244 |
| 241 sAppStream << sLine; | 245 sAppStream << sLine; |
| 242 | 246 |
| 243 CFX_ByteTextBuf sText; | 247 CFX_ByteTextBuf sText; |
| 244 | 248 |
| 245 CFX_FloatPoint ptOffset = CFX_FloatPoint(0.0f, 0.0f); | 249 CFX_FloatPoint ptOffset = CFX_FloatPoint(0.0f, 0.0f); |
| 246 | 250 |
| 247 CPVT_WordRange wrWhole = m_pEdit->GetWholeWordRange(); | 251 CPVT_WordRange wrWhole = m_pEdit->GetWholeWordRange(); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 CFX_FloatRect rcClient = GetClientRect(); | 315 CFX_FloatRect rcClient = GetClientRect(); |
| 312 CFX_ByteTextBuf sLine; | 316 CFX_ByteTextBuf sLine; |
| 313 | 317 |
| 314 int32_t nCharArray = m_pEdit->GetCharArray(); | 318 int32_t nCharArray = m_pEdit->GetCharArray(); |
| 315 FX_SAFE_INT32 nCharArraySafe = nCharArray; | 319 FX_SAFE_INT32 nCharArraySafe = nCharArray; |
| 316 nCharArraySafe -= 1; | 320 nCharArraySafe -= 1; |
| 317 nCharArraySafe *= 2; | 321 nCharArraySafe *= 2; |
| 318 | 322 |
| 319 if (nCharArray > 0 && nCharArraySafe.IsValid()) { | 323 if (nCharArray > 0 && nCharArraySafe.IsValid()) { |
| 320 switch (GetBorderStyle()) { | 324 switch (GetBorderStyle()) { |
| 321 case PBS_SOLID: { | 325 case BorderStyle::SOLID: { |
| 322 CFX_GraphStateData gsd; | 326 CFX_GraphStateData gsd; |
| 323 gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth(); | 327 gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth(); |
| 324 | 328 |
| 325 CFX_PathData path; | 329 CFX_PathData path; |
| 326 path.SetPointCount(nCharArraySafe.ValueOrDie()); | 330 path.SetPointCount(nCharArraySafe.ValueOrDie()); |
| 327 | 331 |
| 328 for (int32_t i = 0; i < nCharArray - 1; i++) { | 332 for (int32_t i = 0; i < nCharArray - 1; i++) { |
| 329 path.SetPoint( | 333 path.SetPoint( |
| 330 i * 2, | 334 i * 2, |
| 331 rcClient.left + | 335 rcClient.left + |
| 332 ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), | 336 ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), |
| 333 rcClient.bottom, FXPT_MOVETO); | 337 rcClient.bottom, FXPT_MOVETO); |
| 334 path.SetPoint( | 338 path.SetPoint( |
| 335 i * 2 + 1, | 339 i * 2 + 1, |
| 336 rcClient.left + | 340 rcClient.left + |
| 337 ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), | 341 ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), |
| 338 rcClient.top, FXPT_LINETO); | 342 rcClient.top, FXPT_LINETO); |
| 339 } | 343 } |
| 340 if (path.GetPointCount() > 0) | 344 if (path.GetPointCount() > 0) { |
| 341 pDevice->DrawPath( | 345 pDevice->DrawPath( |
| 342 &path, pUser2Device, &gsd, 0, | 346 &path, pUser2Device, &gsd, 0, |
| 343 CPWL_Utils::PWLColorToFXColor(GetBorderColor(), 255), | 347 CPWL_Utils::PWLColorToFXColor(GetBorderColor(), 255), |
| 344 FXFILL_ALTERNATE); | 348 FXFILL_ALTERNATE); |
| 345 } break; | 349 } |
| 346 case PBS_DASH: { | 350 break; |
| 351 } |
| 352 case BorderStyle::DASH: { |
| 347 CFX_GraphStateData gsd; | 353 CFX_GraphStateData gsd; |
| 348 gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth(); | 354 gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth(); |
| 349 | 355 |
| 350 gsd.SetDashCount(2); | 356 gsd.SetDashCount(2); |
| 351 gsd.m_DashArray[0] = (FX_FLOAT)GetBorderDash().nDash; | 357 gsd.m_DashArray[0] = (FX_FLOAT)GetBorderDash().nDash; |
| 352 gsd.m_DashArray[1] = (FX_FLOAT)GetBorderDash().nGap; | 358 gsd.m_DashArray[1] = (FX_FLOAT)GetBorderDash().nGap; |
| 353 gsd.m_DashPhase = (FX_FLOAT)GetBorderDash().nPhase; | 359 gsd.m_DashPhase = (FX_FLOAT)GetBorderDash().nPhase; |
| 354 | 360 |
| 355 CFX_PathData path; | 361 CFX_PathData path; |
| 356 path.SetPointCount(nCharArraySafe.ValueOrDie()); | 362 path.SetPointCount(nCharArraySafe.ValueOrDie()); |
| 357 | 363 |
| 358 for (int32_t i = 0; i < nCharArray - 1; i++) { | 364 for (int32_t i = 0; i < nCharArray - 1; i++) { |
| 359 path.SetPoint( | 365 path.SetPoint( |
| 360 i * 2, | 366 i * 2, |
| 361 rcClient.left + | 367 rcClient.left + |
| 362 ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), | 368 ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), |
| 363 rcClient.bottom, FXPT_MOVETO); | 369 rcClient.bottom, FXPT_MOVETO); |
| 364 path.SetPoint( | 370 path.SetPoint( |
| 365 i * 2 + 1, | 371 i * 2 + 1, |
| 366 rcClient.left + | 372 rcClient.left + |
| 367 ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), | 373 ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), |
| 368 rcClient.top, FXPT_LINETO); | 374 rcClient.top, FXPT_LINETO); |
| 369 } | 375 } |
| 370 if (path.GetPointCount() > 0) | 376 if (path.GetPointCount() > 0) { |
| 371 pDevice->DrawPath( | 377 pDevice->DrawPath( |
| 372 &path, pUser2Device, &gsd, 0, | 378 &path, pUser2Device, &gsd, 0, |
| 373 CPWL_Utils::PWLColorToFXColor(GetBorderColor(), 255), | 379 CPWL_Utils::PWLColorToFXColor(GetBorderColor(), 255), |
| 374 FXFILL_ALTERNATE); | 380 FXFILL_ALTERNATE); |
| 375 } break; | 381 } |
| 382 break; |
| 383 } |
| 384 default: |
| 385 break; |
| 376 } | 386 } |
| 377 } | 387 } |
| 378 | 388 |
| 379 CFX_FloatRect rcClip; | 389 CFX_FloatRect rcClip; |
| 380 CPVT_WordRange wrRange = m_pEdit->GetVisibleWordRange(); | 390 CPVT_WordRange wrRange = m_pEdit->GetVisibleWordRange(); |
| 381 CPVT_WordRange* pRange = NULL; | 391 CPVT_WordRange* pRange = NULL; |
| 382 | 392 |
| 383 if (!HasFlag(PES_TEXTOVERFLOW)) { | 393 if (!HasFlag(PES_TEXTOVERFLOW)) { |
| 384 rcClip = GetClientRect(); | 394 rcClip = GetClientRect(); |
| 385 pRange = &wrRange; | 395 pRange = &wrRange; |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 } | 944 } |
| 935 | 945 |
| 936 void CPWL_Edit::GeneratePageObjects(CPDF_PageObjectHolder* pObjectHolder, | 946 void CPWL_Edit::GeneratePageObjects(CPDF_PageObjectHolder* pObjectHolder, |
| 937 const CFX_FloatPoint& ptOffset) { | 947 const CFX_FloatPoint& ptOffset) { |
| 938 CFX_ArrayTemplate<CPDF_TextObject*> ObjArray; | 948 CFX_ArrayTemplate<CPDF_TextObject*> ObjArray; |
| 939 IFX_Edit::GeneratePageObjects( | 949 IFX_Edit::GeneratePageObjects( |
| 940 pObjectHolder, m_pEdit, ptOffset, NULL, | 950 pObjectHolder, m_pEdit, ptOffset, NULL, |
| 941 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), | 951 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), |
| 942 ObjArray); | 952 ObjArray); |
| 943 } | 953 } |
| OLD | NEW |