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 #ifndef CORE_SRC_FPDFDOC_PDF_VT_H_ | 7 #ifndef CORE_SRC_FPDFDOC_PDF_VT_H_ |
8 #define CORE_SRC_FPDFDOC_PDF_VT_H_ | 8 #define CORE_SRC_FPDFDOC_PDF_VT_H_ |
9 | 9 |
10 class CPVT_Size; | 10 class CPVT_Size; |
(...skipping 26 matching lines...) Expand all Loading... |
37 CPVT_FloatRect() { left = top = right = bottom = 0.0f; } | 37 CPVT_FloatRect() { left = top = right = bottom = 0.0f; } |
38 CPVT_FloatRect(FX_FLOAT other_left, | 38 CPVT_FloatRect(FX_FLOAT other_left, |
39 FX_FLOAT other_top, | 39 FX_FLOAT other_top, |
40 FX_FLOAT other_right, | 40 FX_FLOAT other_right, |
41 FX_FLOAT other_bottom) { | 41 FX_FLOAT other_bottom) { |
42 left = other_left; | 42 left = other_left; |
43 top = other_top; | 43 top = other_top; |
44 right = other_right; | 44 right = other_right; |
45 bottom = other_bottom; | 45 bottom = other_bottom; |
46 } | 46 } |
47 explicit CPVT_FloatRect(const CPDF_Rect& rect) { | 47 explicit CPVT_FloatRect(const CFX_FloatRect& rect) { |
48 left = rect.left; | 48 left = rect.left; |
49 top = rect.top; | 49 top = rect.top; |
50 right = rect.right; | 50 right = rect.right; |
51 bottom = rect.bottom; | 51 bottom = rect.bottom; |
52 } | 52 } |
53 void Default() { left = top = right = bottom = 0.0f; } | 53 void Default() { left = top = right = bottom = 0.0f; } |
54 FX_FLOAT Height() const { | 54 FX_FLOAT Height() const { |
55 if (top > bottom) | 55 if (top > bottom) |
56 return top - bottom; | 56 return top - bottom; |
57 return bottom - top; | 57 return bottom - top; |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 CPVT_WordPlace AddLine(const CPVT_LineInfo& lineinfo); | 250 CPVT_WordPlace AddLine(const CPVT_LineInfo& lineinfo); |
251 void ClearWords(const CPVT_WordRange& PlaceRange); | 251 void ClearWords(const CPVT_WordRange& PlaceRange); |
252 void ClearWord(const CPVT_WordPlace& place); | 252 void ClearWord(const CPVT_WordPlace& place); |
253 CPVT_FloatRect Rearrange(); | 253 CPVT_FloatRect Rearrange(); |
254 CPVT_Size GetSectionSize(FX_FLOAT fFontSize); | 254 CPVT_Size GetSectionSize(FX_FLOAT fFontSize); |
255 CPVT_WordPlace GetBeginWordPlace() const; | 255 CPVT_WordPlace GetBeginWordPlace() const; |
256 CPVT_WordPlace GetEndWordPlace() const; | 256 CPVT_WordPlace GetEndWordPlace() const; |
257 CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace& place) const; | 257 CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace& place) const; |
258 CPVT_WordPlace GetNextWordPlace(const CPVT_WordPlace& place) const; | 258 CPVT_WordPlace GetNextWordPlace(const CPVT_WordPlace& place) const; |
259 void UpdateWordPlace(CPVT_WordPlace& place) const; | 259 void UpdateWordPlace(CPVT_WordPlace& place) const; |
260 CPVT_WordPlace SearchWordPlace(const CPDF_Point& point) const; | 260 CPVT_WordPlace SearchWordPlace(const CFX_FloatPoint& point) const; |
261 CPVT_WordPlace SearchWordPlace(FX_FLOAT fx, | 261 CPVT_WordPlace SearchWordPlace(FX_FLOAT fx, |
262 const CPVT_WordPlace& lineplace) const; | 262 const CPVT_WordPlace& lineplace) const; |
263 CPVT_WordPlace SearchWordPlace(FX_FLOAT fx, | 263 CPVT_WordPlace SearchWordPlace(FX_FLOAT fx, |
264 const CPVT_WordRange& range) const; | 264 const CPVT_WordRange& range) const; |
265 | 265 |
266 public: | 266 public: |
267 CPVT_WordPlace SecPlace; | 267 CPVT_WordPlace SecPlace; |
268 CPVT_SectionInfo m_SecInfo; | 268 CPVT_SectionInfo m_SecInfo; |
269 CLines m_LineArray; | 269 CLines m_LineArray; |
270 CPVT_ArrayTemplate<CPVT_WordInfo*> m_WordArray; | 270 CPVT_ArrayTemplate<CPVT_WordInfo*> m_WordArray; |
(...skipping 18 matching lines...) Expand all Loading... |
289 void OutputLines(); | 289 void OutputLines(); |
290 | 290 |
291 CPVT_FloatRect m_rcRet; | 291 CPVT_FloatRect m_rcRet; |
292 CPDF_VariableText* m_pVT; | 292 CPDF_VariableText* m_pVT; |
293 CSection* m_pSection; | 293 CSection* m_pSection; |
294 }; | 294 }; |
295 class CPDF_EditContainer { | 295 class CPDF_EditContainer { |
296 public: | 296 public: |
297 CPDF_EditContainer() : m_rcPlate(0, 0, 0, 0), m_rcContent(0, 0, 0, 0) {} | 297 CPDF_EditContainer() : m_rcPlate(0, 0, 0, 0), m_rcContent(0, 0, 0, 0) {} |
298 virtual ~CPDF_EditContainer() {} | 298 virtual ~CPDF_EditContainer() {} |
299 virtual void SetPlateRect(const CPDF_Rect& rect) { m_rcPlate = rect; } | 299 virtual void SetPlateRect(const CFX_FloatRect& rect) { m_rcPlate = rect; } |
300 virtual const CPDF_Rect& GetPlateRect() const { return m_rcPlate; } | 300 virtual const CFX_FloatRect& GetPlateRect() const { return m_rcPlate; } |
301 virtual void SetContentRect(const CPVT_FloatRect& rect) { | 301 virtual void SetContentRect(const CPVT_FloatRect& rect) { |
302 m_rcContent = rect; | 302 m_rcContent = rect; |
303 } | 303 } |
304 virtual CPDF_Rect GetContentRect() const { return m_rcContent; } | 304 virtual CFX_FloatRect GetContentRect() const { return m_rcContent; } |
305 FX_FLOAT GetPlateWidth() const { return m_rcPlate.right - m_rcPlate.left; } | 305 FX_FLOAT GetPlateWidth() const { return m_rcPlate.right - m_rcPlate.left; } |
306 FX_FLOAT GetPlateHeight() const { return m_rcPlate.top - m_rcPlate.bottom; } | 306 FX_FLOAT GetPlateHeight() const { return m_rcPlate.top - m_rcPlate.bottom; } |
307 CPVT_Size GetPlateSize() const { | 307 CPVT_Size GetPlateSize() const { |
308 return CPVT_Size(GetPlateWidth(), GetPlateHeight()); | 308 return CPVT_Size(GetPlateWidth(), GetPlateHeight()); |
309 } | 309 } |
310 CPDF_Point GetBTPoint() const { | 310 CFX_FloatPoint GetBTPoint() const { |
311 return CPDF_Point(m_rcPlate.left, m_rcPlate.top); | 311 return CFX_FloatPoint(m_rcPlate.left, m_rcPlate.top); |
312 } | 312 } |
313 CPDF_Point GetETPoint() const { | 313 CFX_FloatPoint GetETPoint() const { |
314 return CPDF_Point(m_rcPlate.right, m_rcPlate.bottom); | 314 return CFX_FloatPoint(m_rcPlate.right, m_rcPlate.bottom); |
315 } | 315 } |
316 inline CPDF_Point InToOut(const CPDF_Point& point) const { | 316 inline CFX_FloatPoint InToOut(const CFX_FloatPoint& point) const { |
317 return CPDF_Point(point.x + GetBTPoint().x, GetBTPoint().y - point.y); | 317 return CFX_FloatPoint(point.x + GetBTPoint().x, GetBTPoint().y - point.y); |
318 } | 318 } |
319 inline CPDF_Point OutToIn(const CPDF_Point& point) const { | 319 inline CFX_FloatPoint OutToIn(const CFX_FloatPoint& point) const { |
320 return CPDF_Point(point.x - GetBTPoint().x, GetBTPoint().y - point.y); | 320 return CFX_FloatPoint(point.x - GetBTPoint().x, GetBTPoint().y - point.y); |
321 } | 321 } |
322 inline CPDF_Rect InToOut(const CPVT_FloatRect& rect) const { | 322 inline CFX_FloatRect InToOut(const CPVT_FloatRect& rect) const { |
323 CPDF_Point ptLeftTop = InToOut(CPDF_Point(rect.left, rect.top)); | 323 CFX_FloatPoint ptLeftTop = InToOut(CFX_FloatPoint(rect.left, rect.top)); |
324 CPDF_Point ptRightBottom = InToOut(CPDF_Point(rect.right, rect.bottom)); | 324 CFX_FloatPoint ptRightBottom = |
325 return CPDF_Rect(ptLeftTop.x, ptRightBottom.y, ptRightBottom.x, | 325 InToOut(CFX_FloatPoint(rect.right, rect.bottom)); |
326 ptLeftTop.y); | 326 return CFX_FloatRect(ptLeftTop.x, ptRightBottom.y, ptRightBottom.x, |
| 327 ptLeftTop.y); |
327 } | 328 } |
328 inline CPVT_FloatRect OutToIn(const CPDF_Rect& rect) const { | 329 inline CPVT_FloatRect OutToIn(const CFX_FloatRect& rect) const { |
329 CPDF_Point ptLeftTop = OutToIn(CPDF_Point(rect.left, rect.top)); | 330 CFX_FloatPoint ptLeftTop = OutToIn(CFX_FloatPoint(rect.left, rect.top)); |
330 CPDF_Point ptRightBottom = OutToIn(CPDF_Point(rect.right, rect.bottom)); | 331 CFX_FloatPoint ptRightBottom = |
| 332 OutToIn(CFX_FloatPoint(rect.right, rect.bottom)); |
331 return CPVT_FloatRect(ptLeftTop.x, ptLeftTop.y, ptRightBottom.x, | 333 return CPVT_FloatRect(ptLeftTop.x, ptLeftTop.y, ptRightBottom.x, |
332 ptRightBottom.y); | 334 ptRightBottom.y); |
333 } | 335 } |
334 | 336 |
335 private: | 337 private: |
336 CPDF_Rect m_rcPlate; | 338 CFX_FloatRect m_rcPlate; |
337 CPVT_FloatRect m_rcContent; | 339 CPVT_FloatRect m_rcContent; |
338 }; | 340 }; |
339 | 341 |
340 class CPDF_VariableText : public IPDF_VariableText, private CPDF_EditContainer { | 342 class CPDF_VariableText : public IPDF_VariableText, private CPDF_EditContainer { |
341 friend class CTypeset; | 343 friend class CTypeset; |
342 friend class CSection; | 344 friend class CSection; |
343 friend class CPDF_VariableText_Iterator; | 345 friend class CPDF_VariableText_Iterator; |
344 | 346 |
345 public: | 347 public: |
346 CPDF_VariableText(); | 348 CPDF_VariableText(); |
347 ~CPDF_VariableText() override; | 349 ~CPDF_VariableText() override; |
348 | 350 |
349 // IPDF_VariableText | 351 // IPDF_VariableText |
350 IPDF_VariableText_Provider* SetProvider( | 352 IPDF_VariableText_Provider* SetProvider( |
351 IPDF_VariableText_Provider* pProvider) override; | 353 IPDF_VariableText_Provider* pProvider) override; |
352 IPDF_VariableText_Iterator* GetIterator() override; | 354 IPDF_VariableText_Iterator* GetIterator() override; |
353 void SetPlateRect(const CPDF_Rect& rect) override { | 355 void SetPlateRect(const CFX_FloatRect& rect) override { |
354 CPDF_EditContainer::SetPlateRect(rect); | 356 CPDF_EditContainer::SetPlateRect(rect); |
355 } | 357 } |
356 void SetAlignment(int32_t nFormat = 0) override { m_nAlignment = nFormat; } | 358 void SetAlignment(int32_t nFormat = 0) override { m_nAlignment = nFormat; } |
357 void SetPasswordChar(FX_WORD wSubWord = '*') override { | 359 void SetPasswordChar(FX_WORD wSubWord = '*') override { |
358 m_wSubWord = wSubWord; | 360 m_wSubWord = wSubWord; |
359 } | 361 } |
360 void SetLimitChar(int32_t nLimitChar = 0) override { | 362 void SetLimitChar(int32_t nLimitChar = 0) override { |
361 m_nLimitChar = nLimitChar; | 363 m_nLimitChar = nLimitChar; |
362 } | 364 } |
363 void SetCharSpace(FX_FLOAT fCharSpace = 0.0f) override { | 365 void SetCharSpace(FX_FLOAT fCharSpace = 0.0f) override { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 const CPVT_SecProps* pSecProps = NULL, | 402 const CPVT_SecProps* pSecProps = NULL, |
401 const CPVT_WordProps* pWordProps = NULL) override; | 403 const CPVT_WordProps* pWordProps = NULL) override; |
402 CPVT_WordPlace InsertText(const CPVT_WordPlace& place, | 404 CPVT_WordPlace InsertText(const CPVT_WordPlace& place, |
403 const FX_WCHAR* text, | 405 const FX_WCHAR* text, |
404 int32_t charset = 1, | 406 int32_t charset = 1, |
405 const CPVT_SecProps* pSecProps = NULL, | 407 const CPVT_SecProps* pSecProps = NULL, |
406 const CPVT_WordProps* pWordProps = NULL) override; | 408 const CPVT_WordProps* pWordProps = NULL) override; |
407 CPVT_WordPlace DeleteWords(const CPVT_WordRange& PlaceRange) override; | 409 CPVT_WordPlace DeleteWords(const CPVT_WordRange& PlaceRange) override; |
408 CPVT_WordPlace DeleteWord(const CPVT_WordPlace& place) override; | 410 CPVT_WordPlace DeleteWord(const CPVT_WordPlace& place) override; |
409 CPVT_WordPlace BackSpaceWord(const CPVT_WordPlace& place) override; | 411 CPVT_WordPlace BackSpaceWord(const CPVT_WordPlace& place) override; |
410 const CPDF_Rect& GetPlateRect() const override { | 412 const CFX_FloatRect& GetPlateRect() const override { |
411 return CPDF_EditContainer::GetPlateRect(); | 413 return CPDF_EditContainer::GetPlateRect(); |
412 } | 414 } |
413 CPDF_Rect GetContentRect() const override; | 415 CFX_FloatRect GetContentRect() const override; |
414 int32_t GetTotalWords() const override; | 416 int32_t GetTotalWords() const override; |
415 FX_FLOAT GetFontSize() const override { return m_fFontSize; } | 417 FX_FLOAT GetFontSize() const override { return m_fFontSize; } |
416 int32_t GetAlignment() const override { return m_nAlignment; } | 418 int32_t GetAlignment() const override { return m_nAlignment; } |
417 FX_WORD GetPasswordChar() const override { return GetSubWord(); } | 419 FX_WORD GetPasswordChar() const override { return GetSubWord(); } |
418 int32_t GetCharArray() const override { return m_nCharArray; } | 420 int32_t GetCharArray() const override { return m_nCharArray; } |
419 int32_t GetLimitChar() const override { return m_nLimitChar; } | 421 int32_t GetLimitChar() const override { return m_nLimitChar; } |
420 FX_BOOL IsMultiLine() const override { return m_bMultiLine; } | 422 FX_BOOL IsMultiLine() const override { return m_bMultiLine; } |
421 int32_t GetHorzScale() const override { return m_nHorzScale; } | 423 int32_t GetHorzScale() const override { return m_nHorzScale; } |
422 FX_FLOAT GetCharSpace() const override { return m_fCharSpace; } | 424 FX_FLOAT GetCharSpace() const override { return m_fCharSpace; } |
423 CPVT_WordPlace GetBeginWordPlace() const override; | 425 CPVT_WordPlace GetBeginWordPlace() const override; |
424 CPVT_WordPlace GetEndWordPlace() const override; | 426 CPVT_WordPlace GetEndWordPlace() const override; |
425 CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace& place) const override; | 427 CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace& place) const override; |
426 CPVT_WordPlace GetNextWordPlace(const CPVT_WordPlace& place) const override; | 428 CPVT_WordPlace GetNextWordPlace(const CPVT_WordPlace& place) const override; |
427 CPVT_WordPlace SearchWordPlace(const CPDF_Point& point) const override; | 429 CPVT_WordPlace SearchWordPlace(const CFX_FloatPoint& point) const override; |
428 CPVT_WordPlace GetUpWordPlace(const CPVT_WordPlace& place, | 430 CPVT_WordPlace GetUpWordPlace(const CPVT_WordPlace& place, |
429 const CPDF_Point& point) const override; | 431 const CFX_FloatPoint& point) const override; |
430 CPVT_WordPlace GetDownWordPlace(const CPVT_WordPlace& place, | 432 CPVT_WordPlace GetDownWordPlace(const CPVT_WordPlace& place, |
431 const CPDF_Point& point) const override; | 433 const CFX_FloatPoint& point) const override; |
432 CPVT_WordPlace GetLineBeginPlace(const CPVT_WordPlace& place) const override; | 434 CPVT_WordPlace GetLineBeginPlace(const CPVT_WordPlace& place) const override; |
433 CPVT_WordPlace GetLineEndPlace(const CPVT_WordPlace& place) const override; | 435 CPVT_WordPlace GetLineEndPlace(const CPVT_WordPlace& place) const override; |
434 CPVT_WordPlace GetSectionBeginPlace( | 436 CPVT_WordPlace GetSectionBeginPlace( |
435 const CPVT_WordPlace& place) const override; | 437 const CPVT_WordPlace& place) const override; |
436 CPVT_WordPlace GetSectionEndPlace(const CPVT_WordPlace& place) const override; | 438 CPVT_WordPlace GetSectionEndPlace(const CPVT_WordPlace& place) const override; |
437 void UpdateWordPlace(CPVT_WordPlace& place) const override; | 439 void UpdateWordPlace(CPVT_WordPlace& place) const override; |
438 CPVT_WordPlace AdjustLineHeader(const CPVT_WordPlace& place, | 440 CPVT_WordPlace AdjustLineHeader(const CPVT_WordPlace& place, |
439 FX_BOOL bPrevOrNext) const override; | 441 FX_BOOL bPrevOrNext) const override; |
440 int32_t WordPlaceToWordIndex(const CPVT_WordPlace& place) const override; | 442 int32_t WordPlaceToWordIndex(const CPVT_WordPlace& place) const override; |
441 CPVT_WordPlace WordIndexToWordPlace(int32_t index) const override; | 443 CPVT_WordPlace WordIndexToWordPlace(int32_t index) const override; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 void SetAt(int32_t nWordIndex) override; | 552 void SetAt(int32_t nWordIndex) override; |
551 void SetAt(const CPVT_WordPlace& place) override; | 553 void SetAt(const CPVT_WordPlace& place) override; |
552 const CPVT_WordPlace& GetAt() const override { return m_CurPos; } | 554 const CPVT_WordPlace& GetAt() const override { return m_CurPos; } |
553 | 555 |
554 private: | 556 private: |
555 CPVT_WordPlace m_CurPos; | 557 CPVT_WordPlace m_CurPos; |
556 CPDF_VariableText* m_pVT; | 558 CPDF_VariableText* m_pVT; |
557 }; | 559 }; |
558 | 560 |
559 #endif // CORE_SRC_FPDFDOC_PDF_VT_H_ | 561 #endif // CORE_SRC_FPDFDOC_PDF_VT_H_ |
OLD | NEW |