diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-12-13 18:05:38 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-12-13 18:05:38 +0000 |
commit | e03171e52ec4232369ab3b46e11d3a0abe1eb630 (patch) | |
tree | 6a57f6a0948032e6ec387c22d8b462215e6ca1e4 /core/fpdfapi/page/cpdf_textobject.h | |
parent | 8bbfdf2fca7197a0eccfef7b6fc27c590a44e7f7 (diff) | |
parent | 326d96bf5d52fdcf790b467b13f58ba3df3e81e4 (diff) | |
download | pdfium-e03171e52ec4232369ab3b46e11d3a0abe1eb630.tar.gz |
Merge cherrypicks of ['googleplex-android-review.googlesource.com/23916086'] into udc-platform-release.android-platform-14.0.0_r8android-platform-14.0.0_r7android-platform-14.0.0_r6android-platform-14.0.0_r5android-platform-14.0.0_r4android14-platform-release
Change-Id: If925f85c6a039b56ff549fd5327795f57b9cd12c
Diffstat (limited to 'core/fpdfapi/page/cpdf_textobject.h')
-rw-r--r-- | core/fpdfapi/page/cpdf_textobject.h | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/core/fpdfapi/page/cpdf_textobject.h b/core/fpdfapi/page/cpdf_textobject.h index ad9918ecd..4a936bcc5 100644 --- a/core/fpdfapi/page/cpdf_textobject.h +++ b/core/fpdfapi/page/cpdf_textobject.h @@ -1,4 +1,4 @@ -// Copyright 2016 PDFium Authors. All rights reserved. +// Copyright 2016 The PDFium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -7,30 +7,33 @@ #ifndef CORE_FPDFAPI_PAGE_CPDF_TEXTOBJECT_H_ #define CORE_FPDFAPI_PAGE_CPDF_TEXTOBJECT_H_ +#include <stddef.h> +#include <stdint.h> + #include <memory> #include <vector> #include "core/fpdfapi/page/cpdf_pageobject.h" +#include "core/fxcrt/fx_coordinates.h" #include "core/fxcrt/fx_string.h" -#include "core/fxcrt/fx_system.h" #include "core/fxcrt/retain_ptr.h" -class CPDF_TextObjectItem { +class CPDF_TextObject final : public CPDF_PageObject { public: - CPDF_TextObjectItem(); - ~CPDF_TextObjectItem(); + struct Item { + Item(); + Item(const Item& that); + ~Item(); - uint32_t m_CharCode; - CFX_PointF m_Origin; -}; + uint32_t m_CharCode = 0; + CFX_PointF m_Origin; + }; -class CPDF_TextObject final : public CPDF_PageObject { - public: explicit CPDF_TextObject(int32_t content_stream); CPDF_TextObject(); ~CPDF_TextObject() override; - // CPDF_PageObject + // CPDF_PageObject: Type GetType() const override; void Transform(const CFX_Matrix& matrix) override; bool IsText() const override; @@ -40,11 +43,11 @@ class CPDF_TextObject final : public CPDF_PageObject { std::unique_ptr<CPDF_TextObject> Clone() const; size_t CountItems() const; - void GetItemInfo(size_t index, CPDF_TextObjectItem* pInfo) const; + Item GetItemInfo(size_t index) const; size_t CountChars() const; - void GetCharInfo(size_t index, uint32_t* charcode, float* kerning) const; - void GetCharInfo(size_t index, CPDF_TextObjectItem* pInfo) const; + uint32_t GetCharCode(size_t index) const; + Item GetCharInfo(size_t index) const; float GetCharWidth(uint32_t charcode) const; int CountWords() const; WideString GetWordString(int nWordIndex) const; @@ -56,21 +59,25 @@ class CPDF_TextObject final : public CPDF_PageObject { float GetFontSize() const; TextRenderingMode GetTextRenderMode() const; + void SetTextRenderMode(TextRenderingMode mode); void SetText(const ByteString& str); void SetPosition(const CFX_PointF& pos) { m_Pos = pos; } - void RecalcPositionData(); - const std::vector<uint32_t>& GetCharCodes() const { return m_CharCodes; } const std::vector<float>& GetCharPositions() const { return m_CharPos; } + // Caller is expected to call SetDirty(true) when done changing the object. + void SetTextMatrix(const CFX_Matrix& matrix); + void SetSegments(const ByteString* pStrs, const std::vector<float>& kernings, size_t nSegs); CFX_PointF CalcPositionData(float horz_scale); private: + float CalcPositionDataInternal(const RetainPtr<CPDF_Font>& pFont); + CFX_PointF m_Pos; std::vector<uint32_t> m_CharCodes; std::vector<float> m_CharPos; |