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 ResetAll(); 31 void ResetLinePlace(); 32 CPVT_WordPlace AddWord(const CPVT_WordPlace& place, 33 const CPVT_WordInfo& wordinfo); 34 CPVT_WordPlace AddLine(const CPVT_LineInfo& lineinfo); 35 void ClearWords(const CPVT_WordRange& PlaceRange); 36 void ClearWord(const CPVT_WordPlace& place); 37 CPVT_FloatRect Rearrange(); 38 CFX_SizeF GetSectionSize(float fFontSize); 39 CPVT_WordPlace GetBeginWordPlace() const; 40 CPVT_WordPlace GetEndWordPlace() const; 41 CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace& place) const; 42 CPVT_WordPlace GetNextWordPlace(const CPVT_WordPlace& place) const; 43 void UpdateWordPlace(CPVT_WordPlace& place) const; 44 CPVT_WordPlace SearchWordPlace(const CFX_PointF& point) const; 45 CPVT_WordPlace SearchWordPlace(float fx, 46 const CPVT_WordPlace& lineplace) const; 47 CPVT_WordPlace SearchWordPlace(float fx, const CPVT_WordRange& range) const; 48 49 CPVT_WordPlace SecPlace; 50 CPVT_FloatRect m_Rect; 51 std::vector<std::unique_ptr<CLine>> m_LineArray; 52 std::vector<std::unique_ptr<CPVT_WordInfo>> m_WordArray; 53 54 private: 55 friend class CTypeset; 56 57 void ClearLeftWords(int32_t nWordIndex); 58 void ClearRightWords(int32_t nWordIndex); 59 void ClearMidWords(int32_t nBeginIndex, int32_t nEndIndex); 60 61 UnownedPtr<CPDF_VariableText> const m_pVT; 62 }; 63 64 #endif // CORE_FPDFDOC_CSECTION_H_ 65