summaryrefslogtreecommitdiff
path: root/xfa/fde
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fde')
-rw-r--r--xfa/fde/cfde_data.h46
-rw-r--r--xfa/fde/cfde_texteditengine.cpp9
-rw-r--r--xfa/fde/cfde_texteditengine.h9
-rw-r--r--xfa/fde/cfde_texteditengine_unittest.cpp1
-rw-r--r--xfa/fde/cfde_textout.cpp17
-rw-r--r--xfa/fde/cfde_textout.h73
6 files changed, 90 insertions, 65 deletions
diff --git a/xfa/fde/cfde_data.h b/xfa/fde/cfde_data.h
new file mode 100644
index 0000000000..d4ca63d071
--- /dev/null
+++ b/xfa/fde/cfde_data.h
@@ -0,0 +1,46 @@
+// Copyright 2018 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FDE_CFDE_DATA_H_
+#define XFA_FDE_CFDE_DATA_H_
+
+#include "core/fxcrt/fx_coordinates.h"
+
+enum class FDE_TextAlignment : uint8_t {
+ kTopLeft = 0,
+ kCenterLeft,
+ kCenter,
+ kCenterRight
+};
+
+struct FDE_TextStyle {
+ FDE_TextStyle()
+ : single_line_(false), line_wrap_(false), last_line_height_(false) {}
+ ~FDE_TextStyle() {}
+
+ void Reset() {
+ single_line_ = false;
+ line_wrap_ = false;
+ last_line_height_ = false;
+ }
+
+ bool single_line_;
+ bool line_wrap_;
+ bool last_line_height_;
+};
+
+struct FDE_TTOPIECE {
+ FDE_TTOPIECE();
+ FDE_TTOPIECE(const FDE_TTOPIECE& that);
+ ~FDE_TTOPIECE();
+
+ int32_t iStartChar;
+ int32_t iChars;
+ uint32_t dwCharStyles;
+ CFX_RectF rtPiece;
+};
+
+#endif // XFA_FDE_CFDE_DATA_H_
diff --git a/xfa/fde/cfde_texteditengine.cpp b/xfa/fde/cfde_texteditengine.cpp
index 2bcd1fc9de..d085a8d147 100644
--- a/xfa/fde/cfde_texteditengine.cpp
+++ b/xfa/fde/cfde_texteditengine.cpp
@@ -11,6 +11,7 @@
#include "xfa/fde/cfde_textout.h"
#include "xfa/fde/cfde_wordbreak_data.h"
+#include "xfa/fgas/font/cfgas_gefont.h"
namespace {
@@ -632,6 +633,10 @@ void CFDE_TextEditEngine::SetFont(RetainPtr<CFGAS_GEFont> font) {
is_dirty_ = true;
}
+RetainPtr<CFGAS_GEFont> CFDE_TextEditEngine::GetFont() const {
+ return font_;
+}
+
void CFDE_TextEditEngine::SetFontSize(float size) {
if (font_size_ == size)
return;
@@ -650,6 +655,10 @@ void CFDE_TextEditEngine::SetTabWidth(float width) {
is_dirty_ = true;
}
+float CFDE_TextEditEngine::GetFontAscent() const {
+ return (static_cast<float>(font_->GetAscent()) * font_size_) / 1000;
+}
+
void CFDE_TextEditEngine::SetAlignment(uint32_t alignment) {
if (alignment == character_alignment_)
return;
diff --git a/xfa/fde/cfde_texteditengine.h b/xfa/fde/cfde_texteditengine.h
index 980eeb207d..58f77edf31 100644
--- a/xfa/fde/cfde_texteditengine.h
+++ b/xfa/fde/cfde_texteditengine.h
@@ -15,9 +15,10 @@
#include "core/fxcrt/retain_ptr.h"
#include "core/fxge/cfx_renderdevice.h"
#include "core/fxge/fx_dib.h"
-#include "xfa/fgas/font/cfgas_gefont.h"
#include "xfa/fgas/layout/cfx_txtbreak.h"
+class CFGAS_GEFont;
+
struct FDE_TEXTEDITPIECE {
FDE_TEXTEDITPIECE();
FDE_TEXTEDITPIECE(const FDE_TEXTEDITPIECE& that);
@@ -97,14 +98,12 @@ class CFDE_TextEditEngine {
void SetAvailableWidth(size_t width);
void SetFont(RetainPtr<CFGAS_GEFont> font);
- RetainPtr<CFGAS_GEFont> GetFont() const { return font_; }
+ RetainPtr<CFGAS_GEFont> GetFont() const;
void SetFontSize(float size);
float GetFontSize() const { return font_size_; }
void SetFontColor(FX_ARGB color) { font_color_ = color; }
FX_ARGB GetFontColor() const { return font_color_; }
- float GetFontAscent() const {
- return (static_cast<float>(font_->GetAscent()) * font_size_) / 1000;
- }
+ float GetFontAscent() const;
void SetAlignment(uint32_t alignment);
float GetLineSpace() const { return line_spacing_; }
diff --git a/xfa/fde/cfde_texteditengine_unittest.cpp b/xfa/fde/cfde_texteditengine_unittest.cpp
index e6cff04507..522e61a011 100644
--- a/xfa/fde/cfde_texteditengine_unittest.cpp
+++ b/xfa/fde/cfde_texteditengine_unittest.cpp
@@ -7,6 +7,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/test_support.h"
#include "third_party/base/ptr_util.h"
+#include "xfa/fgas/font/cfgas_gefont.h"
class CFDE_TextEditEngineTest : public testing::Test {
public:
diff --git a/xfa/fde/cfde_textout.cpp b/xfa/fde/cfde_textout.cpp
index 2f41525c00..19e7ae6934 100644
--- a/xfa/fde/cfde_textout.cpp
+++ b/xfa/fde/cfde_textout.cpp
@@ -15,6 +15,7 @@
#include "core/fxge/cfx_pathdata.h"
#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
+#include "xfa/fgas/font/cfgas_gefont.h"
#include "xfa/fgas/layout/cfx_txtbreak.h"
namespace {
@@ -530,16 +531,18 @@ int32_t CFDE_TextOut::GetDisplayPos(FDE_TTOPIECE* pPiece) {
return m_pTxtBreak->GetDisplayPos(&tr, m_CharPos.data());
}
-CFDE_TTOLine::CFDE_TTOLine() : m_bNewReload(false) {}
+CFDE_TextOut::CFDE_TTOLine::CFDE_TTOLine() : m_bNewReload(false) {}
-CFDE_TTOLine::CFDE_TTOLine(const CFDE_TTOLine& ttoLine) : m_pieces(5) {
+CFDE_TextOut::CFDE_TTOLine::CFDE_TTOLine(const CFDE_TTOLine& ttoLine)
+ : m_pieces(5) {
m_bNewReload = ttoLine.m_bNewReload;
m_pieces = ttoLine.m_pieces;
}
-CFDE_TTOLine::~CFDE_TTOLine() {}
+CFDE_TextOut::CFDE_TTOLine::~CFDE_TTOLine() {}
-int32_t CFDE_TTOLine::AddPiece(int32_t index, const FDE_TTOPIECE& ttoPiece) {
+int32_t CFDE_TextOut::CFDE_TTOLine::AddPiece(int32_t index,
+ const FDE_TTOPIECE& ttoPiece) {
if (index >= pdfium::CollectionSize<int32_t>(m_pieces)) {
m_pieces.push_back(ttoPiece);
return pdfium::CollectionSize<int32_t>(m_pieces);
@@ -548,15 +551,15 @@ int32_t CFDE_TTOLine::AddPiece(int32_t index, const FDE_TTOPIECE& ttoPiece) {
return index;
}
-int32_t CFDE_TTOLine::GetSize() const {
+int32_t CFDE_TextOut::CFDE_TTOLine::GetSize() const {
return pdfium::CollectionSize<int32_t>(m_pieces);
}
-FDE_TTOPIECE* CFDE_TTOLine::GetPtrAt(int32_t index) {
+FDE_TTOPIECE* CFDE_TextOut::CFDE_TTOLine::GetPtrAt(int32_t index) {
return pdfium::IndexInBounds(m_pieces, index) ? &m_pieces[index] : nullptr;
}
-void CFDE_TTOLine::RemoveLast(int32_t icount) {
+void CFDE_TextOut::CFDE_TTOLine::RemoveLast(int32_t icount) {
if (icount < 0)
return;
m_pieces.erase(
diff --git a/xfa/fde/cfde_textout.h b/xfa/fde/cfde_textout.h
index f69c0a8717..6b6878e07c 100644
--- a/xfa/fde/cfde_textout.h
+++ b/xfa/fde/cfde_textout.h
@@ -15,64 +15,13 @@
#include "core/fxge/cfx_defaultrenderdevice.h"
#include "core/fxge/cfx_renderdevice.h"
#include "core/fxge/fx_dib.h"
-#include "xfa/fgas/font/cfgas_fontmgr.h"
+#include "xfa/fde/cfde_data.h"
class CFDE_RenderDevice;
+class CFGAS_GEFont;
class CFX_RenderDevice;
class CFX_TxtBreak;
-enum class FDE_TextAlignment : uint8_t {
- kTopLeft = 0,
- kCenterLeft,
- kCenter,
- kCenterRight
-};
-
-struct FDE_TextStyle {
- FDE_TextStyle()
- : single_line_(false), line_wrap_(false), last_line_height_(false) {}
- ~FDE_TextStyle() {}
-
- void Reset() {
- single_line_ = false;
- line_wrap_ = false;
- last_line_height_ = false;
- }
-
- bool single_line_;
- bool line_wrap_;
- bool last_line_height_;
-};
-
-struct FDE_TTOPIECE {
- FDE_TTOPIECE();
- FDE_TTOPIECE(const FDE_TTOPIECE& that);
- ~FDE_TTOPIECE();
-
- int32_t iStartChar;
- int32_t iChars;
- uint32_t dwCharStyles;
- CFX_RectF rtPiece;
-};
-
-class CFDE_TTOLine {
- public:
- CFDE_TTOLine();
- CFDE_TTOLine(const CFDE_TTOLine& ttoLine);
- ~CFDE_TTOLine();
-
- bool GetNewReload() const { return m_bNewReload; }
- void SetNewReload(bool reload) { m_bNewReload = reload; }
- int32_t AddPiece(int32_t index, const FDE_TTOPIECE& ttoPiece);
- int32_t GetSize() const;
- FDE_TTOPIECE* GetPtrAt(int32_t index);
- void RemoveLast(int32_t iCount);
-
- private:
- bool m_bNewReload;
- std::deque<FDE_TTOPIECE> m_pieces;
-};
-
class CFDE_TextOut {
public:
static bool DrawString(CFX_RenderDevice* device,
@@ -103,6 +52,24 @@ class CFDE_TextOut {
int32_t GetTotalLines() const { return m_iTotalLines; }
private:
+ class CFDE_TTOLine {
+ public:
+ CFDE_TTOLine();
+ CFDE_TTOLine(const CFDE_TTOLine& ttoLine);
+ ~CFDE_TTOLine();
+
+ bool GetNewReload() const { return m_bNewReload; }
+ void SetNewReload(bool reload) { m_bNewReload = reload; }
+ int32_t AddPiece(int32_t index, const FDE_TTOPIECE& ttoPiece);
+ int32_t GetSize() const;
+ FDE_TTOPIECE* GetPtrAt(int32_t index);
+ void RemoveLast(int32_t iCount);
+
+ private:
+ bool m_bNewReload;
+ std::deque<FDE_TTOPIECE> m_pieces;
+ };
+
bool RetrieveLineWidth(CFX_BreakType dwBreakStatus,
float& fStartPos,
float& fWidth,