1 // Copyright 2016 PDFium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #ifndef CORE_FPDFDOC_CSECTION_H_ 8 #define CORE_FPDFDOC_CSECTION_H_ 9 10 #include <memory> 11 #include <vector> 12 13 #include "core/fpdfdoc/cline.h" 14 #include "core/fpdfdoc/cpvt_wordinfo.h" 15 #include "core/fpdfdoc/cpvt_wordrange.h" 16 #include "core/fpdfdoc/ctypeset.h" 17 #include "core/fxcrt/fx_coordinates.h" 18 #include "core/fxcrt/fx_system.h" 19 20 class CPDF_VariableText; 21 class CPVT_LineInfo; 22 struct CPVT_WordLine; 23 struct CPVT_WordPlace; 24 25 class CSection final { 26 public: 27 explicit CSection(CPDF_VariableText* pVT); 28 ~CSection(); 29 30 void ResetLinePlace(); 31 CPVT_WordPlace AddWord(const CPVT_WordPlace& place, 32 const CPVT_WordInfo& wordinfo); 33 CPVT_WordPlace AddLine(const CPVT_LineInfo& lineinfo); 34 void ClearWords(const CPVT_WordRange& PlaceRange); 35 void ClearWord(const CPVT_WordPlace& place); 36 CPVT_FloatRect Rearrange(); 37 CFX_SizeF GetSectionSize(float fFontSize); 38 CPVT_WordPlace GetBeginWordPlace() const; 39 CPVT_WordPlace GetEndWordPlace() const; 40 CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace& place) const; 41 CPVT_WordPlace GetNextWordPlace(const CPVT_WordPlace& place) const; 42 void UpdateWordPlace(CPVT_WordPlace& place) const; 43 CPVT_WordPlace SearchWordPlace(const CFX_PointF& point) const; 44 CPVT_WordPlace SearchWordPlace(float fx, 45 const CPVT_WordPlace& lineplace) const; 46 CPVT_WordPlace SearchWordPlace(float fx, const CPVT_WordRange& range) const; 47 48 CPVT_WordPlace SecPlace; 49 CPVT_FloatRect m_Rect; 50 std::vector<std::unique_ptr<CLine>> m_LineArray; 51 std::vector<std::unique_ptr<CPVT_WordInfo>> m_WordArray; 52 53 private: 54 friend class CTypeset; 55 56 void ClearLeftWords(int32_t nWordIndex); 57 void ClearRightWords(int32_t nWordIndex); 58 void ClearMidWords(int32_t nBeginIndex, int32_t nEndIndex); 59 60 UnownedPtr<CPDF_VariableText> const m_pVT; 61 }; 62 63 #endif // CORE_FPDFDOC_CSECTION_H_ 64