summaryrefslogtreecommitdiff
path: root/xfa/fde
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fde')
-rw-r--r--xfa/fde/cfde_txtedtpage.cpp87
-rw-r--r--xfa/fde/cfde_txtedtpage.h31
-rw-r--r--xfa/fde/cfde_txtedttextset.cpp56
-rw-r--r--xfa/fde/cfde_txtedttextset.h27
-rw-r--r--xfa/fde/fde_iterator.cpp23
-rw-r--r--xfa/fde/fde_iterator.h8
-rw-r--r--xfa/fde/fde_render.cpp46
-rw-r--r--xfa/fde/fde_render.h4
-rw-r--r--xfa/fde/fde_visualset.h40
9 files changed, 117 insertions, 205 deletions
diff --git a/xfa/fde/cfde_txtedtpage.cpp b/xfa/fde/cfde_txtedtpage.cpp
index 8535459eb1..cecbf73b25 100644
--- a/xfa/fde/cfde_txtedtpage.cpp
+++ b/xfa/fde/cfde_txtedtpage.cpp
@@ -60,22 +60,7 @@ FDE_VISUALOBJTYPE CFDE_TxtEdtPage::GetType() {
return FDE_VISUALOBJ_Text;
}
-FX_BOOL CFDE_TxtEdtPage::GetBBox(FDE_HVISUALOBJ hVisualObj, CFX_RectF& bbox) {
- return FALSE;
-}
-
-FX_BOOL CFDE_TxtEdtPage::GetMatrix(FDE_HVISUALOBJ hVisualObj,
- CFX_Matrix& matrix) {
- return FALSE;
-}
-
-FX_BOOL CFDE_TxtEdtPage::GetRect(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) {
- return FALSE;
-}
-
-FX_BOOL CFDE_TxtEdtPage::GetClip(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) {
- return FALSE;
-}
+void CFDE_TxtEdtPage::GetRect(FDE_TEXTEDITPIECE* hVisualObj, CFX_RectF& rt) {}
int32_t CFDE_TxtEdtPage::GetCharRect(int32_t nIndex,
CFX_RectF& rect,
@@ -91,11 +76,7 @@ int32_t CFDE_TxtEdtPage::GetCharRect(int32_t nIndex,
if (nIndex >= pPiece->nStart &&
nIndex < (pPiece->nStart + pPiece->nCount)) {
CFX_RectFArray rectArr;
- if (bBBox) {
- m_pTextSet->GetCharRects_Impl((FDE_HVISUALOBJ)pPiece, rectArr, bBBox);
- } else {
- m_pTextSet->GetCharRects((FDE_HVISUALOBJ)pPiece, rectArr);
- }
+ m_pTextSet->GetCharRects(pPiece, rectArr, bBBox);
rect = rectArr[nIndex - pPiece->nStart];
return pPiece->nBidiLevel;
}
@@ -139,13 +120,13 @@ int32_t CFDE_TxtEdtPage::GetCharIndex(const CFX_PointF& fPoint,
}
NormalizePt2Rect(ptF, rtLine, kTolerance);
int32_t nCaret = 0;
- FDE_TEXTEDITPIECE* pPiece = NULL;
+ FDE_TEXTEDITPIECE* pPiece = nullptr;
for (i = nBgn; i <= nEnd; i++) {
pPiece = m_PieceMassArr.GetPtrAt(i);
nCaret = m_nPageStart + pPiece->nStart;
if (pPiece->rtPiece.Contains(ptF)) {
CFX_RectFArray rectArr;
- m_pTextSet->GetCharRects((FDE_HVISUALOBJ)pPiece, rectArr);
+ m_pTextSet->GetCharRects(pPiece, rectArr, FALSE);
int32_t nRtCount = rectArr.GetSize();
for (int32_t j = 0; j < nRtCount; j++) {
if (rectArr[j].Contains(ptF)) {
@@ -194,17 +175,17 @@ int32_t CFDE_TxtEdtPage::GetDisplayPos(const CFX_RectF& rtClip,
CFX_RectF* pBBox) const {
pCharPos = FX_Alloc(FXTEXT_CHARPOS, m_nCharCount);
int32_t nCharPosCount = 0;
- FDE_HVISUALOBJ hVisualObj = NULL;
+ FDE_TEXTEDITPIECE* pPiece = nullptr;
int32_t nVisualObjCount = m_PieceMassArr.GetSize();
FXTEXT_CHARPOS* pos = pCharPos;
CFX_RectF rtObj;
for (int32_t i = 0; i < nVisualObjCount; i++) {
- hVisualObj = (FDE_HVISUALOBJ)m_PieceMassArr.GetPtrAt(i);
- m_pTextSet->GetRect(hVisualObj, rtObj);
+ pPiece = m_PieceMassArr.GetPtrAt(i);
+ m_pTextSet->GetRect(pPiece, rtObj);
if (!rtClip.IntersectWith(rtObj)) {
continue;
}
- int32_t nCount = m_pTextSet->GetDisplayPos(hVisualObj, pos, FALSE);
+ int32_t nCount = m_pTextSet->GetDisplayPos(pPiece, pos, FALSE);
nCharPosCount += nCount;
pos += nCount;
}
@@ -234,7 +215,7 @@ void CFDE_TxtEdtPage::CalcRangeRectArray(int32_t nStart,
bEnd = TRUE;
}
CFX_RectFArray rcArr;
- m_pTextSet->GetCharRects((FDE_HVISUALOBJ)piece, rcArr);
+ m_pTextSet->GetCharRects(piece, rcArr, FALSE);
CFX_RectF rectPiece = rcArr[nStart - piece->nStart];
rectPiece.Union(rcArr[nRangeEnd]);
RectFArr.Add(rectPiece);
@@ -246,7 +227,7 @@ void CFDE_TxtEdtPage::CalcRangeRectArray(int32_t nStart,
} else {
if (nEnd >= piece->nStart && nEnd < (piece->nStart + piece->nCount)) {
CFX_RectFArray rcArr;
- m_pTextSet->GetCharRects((FDE_HVISUALOBJ)piece, rcArr);
+ m_pTextSet->GetCharRects(piece, rcArr, FALSE);
CFX_RectF rectPiece = rcArr[0];
rectPiece.Union(rcArr[nEnd - piece->nStart]);
RectFArr.Add(rectPiece);
@@ -324,15 +305,14 @@ int32_t CFDE_TxtEdtPage::LoadPage(const CFX_RectF* pClipBox,
FX_FLOAT fLineStep =
(bVertial && bLineReserve) ? (-pParams->fLineSpace) : pParams->fLineSpace;
FX_FLOAT fLinePos = fLineStart;
- if (m_pTextSet == NULL) {
+ if (!m_pTextSet)
m_pTextSet = new CFDE_TxtEdtTextSet(this);
- }
+
m_PieceMassArr.RemoveAll(TRUE);
uint32_t dwBreakStatus = FX_TXTBREAK_None;
int32_t nPieceStart = 0;
- if (m_pCharWidth != NULL) {
- delete[] m_pCharWidth;
- }
+ delete[] m_pCharWidth;
+
m_pCharWidth = new int32_t[nPageEnd - nPageStart + 1];
pBreak->EndBreak(FX_TXTBREAK_ParagraphBreak);
pBreak->ClearBreakPieces();
@@ -485,38 +465,31 @@ const CFX_RectF& CFDE_TxtEdtPage::GetContentsBox() {
return m_rtPageContents;
}
-FX_POSITION CFDE_TxtEdtPage::GetFirstPosition(FDE_HVISUALOBJ hCanvas) {
- if (m_PieceMassArr.GetSize() < 1) {
- return NULL;
- }
+FX_POSITION CFDE_TxtEdtPage::GetFirstPosition() {
+ if (m_PieceMassArr.GetSize() < 1)
+ return nullptr;
return (FX_POSITION)1;
}
-FDE_HVISUALOBJ CFDE_TxtEdtPage::GetNext(FDE_HVISUALOBJ hCanvas,
- FX_POSITION& pos,
- IFDE_VisualSet*& pVisualSet) {
- if (m_pTextSet == NULL) {
- pos = NULL;
- return NULL;
+FDE_TEXTEDITPIECE* CFDE_TxtEdtPage::GetNext(FX_POSITION& pos,
+ IFDE_VisualSet*& pVisualSet) {
+ if (!m_pTextSet) {
+ pos = nullptr;
+ return nullptr;
}
int32_t nPos = (int32_t)(uintptr_t)pos;
pVisualSet = m_pTextSet;
if (nPos + 1 > m_PieceMassArr.GetSize()) {
- pos = NULL;
+ pos = nullptr;
} else {
pos = (FX_POSITION)(uintptr_t)(nPos + 1);
}
- return (FDE_HVISUALOBJ)(m_PieceMassArr.GetPtrAt(nPos - 1));
-}
-
-FDE_HVISUALOBJ CFDE_TxtEdtPage::GetParentCanvas(FDE_HVISUALOBJ hCanvas,
- IFDE_VisualSet*& pVisualSet) {
- return NULL;
+ return m_PieceMassArr.GetPtrAt(nPos - 1);
}
-FX_WCHAR CFDE_TxtEdtPage::GetChar(void* pIdentity, int32_t index) const {
- int32_t nIndex =
- m_nPageStart + ((FDE_TEXTEDITPIECE*)pIdentity)->nStart + index;
+FX_WCHAR CFDE_TxtEdtPage::GetChar(const FDE_TEXTEDITPIECE* pIdentity,
+ int32_t index) const {
+ int32_t nIndex = m_nPageStart + pIdentity->nStart + index;
if (nIndex != m_pIter->GetAt()) {
m_pIter->SetAt(nIndex);
}
@@ -525,9 +498,9 @@ FX_WCHAR CFDE_TxtEdtPage::GetChar(void* pIdentity, int32_t index) const {
return wChar;
}
-int32_t CFDE_TxtEdtPage::GetWidth(void* pIdentity, int32_t index) const {
- int32_t nWidth =
- m_pCharWidth[((FDE_TEXTEDITPIECE*)pIdentity)->nStart + index];
+int32_t CFDE_TxtEdtPage::GetWidth(const FDE_TEXTEDITPIECE* pIdentity,
+ int32_t index) const {
+ int32_t nWidth = m_pCharWidth[pIdentity->nStart + index];
return nWidth;
}
diff --git a/xfa/fde/cfde_txtedtpage.h b/xfa/fde/cfde_txtedtpage.h
index ea329bff13..9adaee1fdc 100644
--- a/xfa/fde/cfde_txtedtpage.h
+++ b/xfa/fde/cfde_txtedtpage.h
@@ -10,15 +10,6 @@
#include "xfa/fde/ifde_txtedtpage.h"
#include "xfa/fde/ifx_chariter.h"
-struct FDE_TEXTEDITPIECE {
- int32_t nStart;
- int32_t nCount;
- int32_t nBidiLevel;
- CFX_RectF rtPiece;
- uint32_t dwCharStyles;
-};
-typedef CFX_MassArrayTemplate<FDE_TEXTEDITPIECE> CFDE_TXTEDTPieceMassArray;
-
class CFDE_TxtEdtEngine;
class CFDE_TxtEdtParag;
class CFDE_TxtEdtTextSet;
@@ -50,22 +41,18 @@ class CFDE_TxtEdtPage : public IFDE_TxtEdtPage {
// IFDE_VisualSet:
FDE_VISUALOBJTYPE GetType() override;
- FX_BOOL GetBBox(FDE_HVISUALOBJ hVisualObj, CFX_RectF& bbox) override;
- FX_BOOL GetMatrix(FDE_HVISUALOBJ hVisualObj, CFX_Matrix& matrix) override;
- FX_BOOL GetRect(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) override;
- FX_BOOL GetClip(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) override;
+ void GetRect(FDE_TEXTEDITPIECE* pPiece, CFX_RectF& rt) override;
// IFDE_CanvasSet:
- FX_POSITION GetFirstPosition(FDE_HVISUALOBJ hCanvas) override;
- FDE_HVISUALOBJ GetNext(FDE_HVISUALOBJ hCanvas,
- FX_POSITION& pos,
- IFDE_VisualSet*& pVisualSet) override;
- FDE_HVISUALOBJ GetParentCanvas(FDE_HVISUALOBJ hCanvas,
- IFDE_VisualSet*& pVisualSet) override;
+ FX_POSITION GetFirstPosition() override;
+ FDE_TEXTEDITPIECE* GetNext(FX_POSITION& pos,
+ IFDE_VisualSet*& pVisualSet) override;
// IFX_TxtAccess:
- FX_WCHAR GetChar(void* pIdentity, int32_t index) const override;
- int32_t GetWidth(void* pIdentity, int32_t index) const override;
+ FX_WCHAR GetChar(const FDE_TEXTEDITPIECE* pIdentity,
+ int32_t index) const override;
+ int32_t GetWidth(const FDE_TEXTEDITPIECE* pIdentity,
+ int32_t index) const override;
private:
void NormalizePt2Rect(CFX_PointF& ptF,
@@ -75,7 +62,7 @@ class CFDE_TxtEdtPage : public IFDE_TxtEdtPage {
std::unique_ptr<IFX_CharIter> m_pIter;
CFDE_TxtEdtTextSet* m_pTextSet;
CFDE_TxtEdtEngine* m_pEditEngine;
- CFDE_TXTEDTPieceMassArray m_PieceMassArr;
+ CFX_MassArrayTemplate<FDE_TEXTEDITPIECE> m_PieceMassArr;
CFDE_TxtEdtParag* m_pBgnParag;
CFDE_TxtEdtParag* m_pEndParag;
int32_t m_nRefCount;
diff --git a/xfa/fde/cfde_txtedttextset.cpp b/xfa/fde/cfde_txtedttextset.cpp
index 800f8c88b1..b06e430b1d 100644
--- a/xfa/fde/cfde_txtedttextset.cpp
+++ b/xfa/fde/cfde_txtedttextset.cpp
@@ -18,58 +18,39 @@ FDE_VISUALOBJTYPE CFDE_TxtEdtTextSet::GetType() {
return FDE_VISUALOBJ_Text;
}
-FX_BOOL CFDE_TxtEdtTextSet::GetBBox(FDE_HVISUALOBJ hVisualObj,
- CFX_RectF& bbox) {
- return FALSE;
+void CFDE_TxtEdtTextSet::GetRect(FDE_TEXTEDITPIECE* pPiece, CFX_RectF& rt) {
+ rt = pPiece->rtPiece;
}
-FX_BOOL CFDE_TxtEdtTextSet::GetMatrix(FDE_HVISUALOBJ hVisualObj,
- CFX_Matrix& matrix) {
- return FALSE;
-}
-
-FX_BOOL CFDE_TxtEdtTextSet::GetRect(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) {
- rt = reinterpret_cast<const FDE_TEXTEDITPIECE*>(hVisualObj)->rtPiece;
- return TRUE;
-}
-
-FX_BOOL CFDE_TxtEdtTextSet::GetClip(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) {
- return FALSE;
-}
-
-int32_t CFDE_TxtEdtTextSet::GetString(FDE_HVISUALOBJ hText,
+int32_t CFDE_TxtEdtTextSet::GetString(FDE_TEXTEDITPIECE* pPiece,
CFX_WideString& wsText) {
- const FDE_TEXTEDITPIECE* pPiece =
- reinterpret_cast<const FDE_TEXTEDITPIECE*>(hText);
FX_WCHAR* pBuffer = wsText.GetBuffer(pPiece->nCount);
for (int32_t i = 0; i < pPiece->nCount; i++) {
- pBuffer[i] = m_pPage->GetChar((void*)hText, i);
+ pBuffer[i] = m_pPage->GetChar(pPiece, i);
}
wsText.ReleaseBuffer(pPiece->nCount);
return pPiece->nCount;
}
-IFGAS_Font* CFDE_TxtEdtTextSet::GetFont(FDE_HVISUALOBJ hText) {
+IFGAS_Font* CFDE_TxtEdtTextSet::GetFont() {
return m_pPage->GetEngine()->GetEditParams()->pFont;
}
-FX_FLOAT CFDE_TxtEdtTextSet::GetFontSize(FDE_HVISUALOBJ hText) {
+FX_FLOAT CFDE_TxtEdtTextSet::GetFontSize() {
return m_pPage->GetEngine()->GetEditParams()->fFontSize;
}
-FX_ARGB CFDE_TxtEdtTextSet::GetFontColor(FDE_HVISUALOBJ hText) {
+FX_ARGB CFDE_TxtEdtTextSet::GetFontColor() {
return m_pPage->GetEngine()->GetEditParams()->dwFontColor;
}
-int32_t CFDE_TxtEdtTextSet::GetDisplayPos(FDE_HVISUALOBJ hText,
+int32_t CFDE_TxtEdtTextSet::GetDisplayPos(FDE_TEXTEDITPIECE* pPiece,
FXTEXT_CHARPOS* pCharPos,
FX_BOOL bCharCode,
CFX_WideString* pWSForms) {
- if (!hText)
+ if (!pPiece)
return 0;
- const FDE_TEXTEDITPIECE* pPiece =
- reinterpret_cast<const FDE_TEXTEDITPIECE*>(hText);
int32_t nLength = pPiece->nCount;
if (nLength < 1)
return 0;
@@ -81,7 +62,7 @@ int32_t CFDE_TxtEdtTextSet::GetDisplayPos(FDE_HVISUALOBJ hText,
uint32_t dwLayoutStyle = pBreak->GetLayoutStyles();
FX_TXTRUN tr;
tr.pAccess = m_pPage;
- tr.pIdentity = (void*)hText;
+ tr.pIdentity = pPiece;
tr.iLength = nLength;
tr.pFont = pTextParams->pFont;
tr.fFontSize = pTextParams->fFontSize;
@@ -93,19 +74,12 @@ int32_t CFDE_TxtEdtTextSet::GetDisplayPos(FDE_HVISUALOBJ hText,
return pBreak->GetDisplayPos(&tr, pCharPos, bCharCode, pWSForms);
}
-int32_t CFDE_TxtEdtTextSet::GetCharRects(FDE_HVISUALOBJ hText,
- CFX_RectFArray& rtArray) {
- return GetCharRects_Impl(hText, rtArray);
-}
-
-int32_t CFDE_TxtEdtTextSet::GetCharRects_Impl(FDE_HVISUALOBJ hText,
- CFX_RectFArray& rtArray,
- FX_BOOL bBBox) {
- if (!hText)
+int32_t CFDE_TxtEdtTextSet::GetCharRects(const FDE_TEXTEDITPIECE* pPiece,
+ CFX_RectFArray& rtArray,
+ FX_BOOL bBBox) {
+ if (!pPiece)
return 0;
- const FDE_TEXTEDITPIECE* pPiece =
- reinterpret_cast<const FDE_TEXTEDITPIECE*>(hText);
CFDE_TxtEdtEngine* pEngine =
static_cast<CFDE_TxtEdtEngine*>(m_pPage->GetEngine());
int32_t nLength = pPiece->nCount;
@@ -116,7 +90,7 @@ int32_t CFDE_TxtEdtTextSet::GetCharRects_Impl(FDE_HVISUALOBJ hText,
uint32_t dwLayoutStyle = pEngine->GetTextBreak()->GetLayoutStyles();
FX_TXTRUN tr;
tr.pAccess = m_pPage;
- tr.pIdentity = (void*)hText;
+ tr.pIdentity = pPiece;
tr.iLength = nLength;
tr.pFont = pTextParams->pFont;
tr.fFontSize = pTextParams->fFontSize;
diff --git a/xfa/fde/cfde_txtedttextset.h b/xfa/fde/cfde_txtedttextset.h
index c586de9969..78a9aabfd4 100644
--- a/xfa/fde/cfde_txtedttextset.h
+++ b/xfa/fde/cfde_txtedttextset.h
@@ -16,23 +16,22 @@ class CFDE_TxtEdtTextSet : public IFDE_TextSet {
explicit CFDE_TxtEdtTextSet(CFDE_TxtEdtPage* pPage);
~CFDE_TxtEdtTextSet() override;
+ // IFDE_VisualSet
FDE_VISUALOBJTYPE GetType() override;
- FX_BOOL GetBBox(FDE_HVISUALOBJ hVisualObj, CFX_RectF& bbox) override;
- FX_BOOL GetMatrix(FDE_HVISUALOBJ hVisualObj, CFX_Matrix& matrix) override;
- FX_BOOL GetRect(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) override;
- FX_BOOL GetClip(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) override;
- int32_t GetString(FDE_HVISUALOBJ hText, CFX_WideString& wsText) override;
- IFGAS_Font* GetFont(FDE_HVISUALOBJ hText) override;
- FX_FLOAT GetFontSize(FDE_HVISUALOBJ hText) override;
- FX_ARGB GetFontColor(FDE_HVISUALOBJ hText) override;
- int32_t GetDisplayPos(FDE_HVISUALOBJ hText,
+ void GetRect(FDE_TEXTEDITPIECE* hVisualObj, CFX_RectF& rt) override;
+
+ // IFDE_TextSet
+ int32_t GetString(FDE_TEXTEDITPIECE* pPiece, CFX_WideString& wsText) override;
+ IFGAS_Font* GetFont() override;
+ FX_FLOAT GetFontSize() override;
+ FX_ARGB GetFontColor() override;
+ int32_t GetDisplayPos(FDE_TEXTEDITPIECE* pPiece,
FXTEXT_CHARPOS* pCharPos,
FX_BOOL bCharCode = FALSE,
- CFX_WideString* pWSForms = NULL) override;
- int32_t GetCharRects(FDE_HVISUALOBJ hText, CFX_RectFArray& rtArray) override;
- int32_t GetCharRects_Impl(FDE_HVISUALOBJ hText,
- CFX_RectFArray& rtArray,
- FX_BOOL bBBox = FALSE);
+ CFX_WideString* pWSForms = nullptr) override;
+ int32_t GetCharRects(const FDE_TEXTEDITPIECE* pPiece,
+ CFX_RectFArray& rtArray,
+ FX_BOOL bBBox) override;
private:
CFDE_TxtEdtPage* const m_pPage;
diff --git a/xfa/fde/fde_iterator.cpp b/xfa/fde/fde_iterator.cpp
index 53d86e8520..d04467f06f 100644
--- a/xfa/fde/fde_iterator.cpp
+++ b/xfa/fde/fde_iterator.cpp
@@ -21,7 +21,7 @@ FX_BOOL CFDE_VisualSetIterator::AttachCanvas(IFDE_CanvasSet* pCanvas) {
FDE_CANVASITEM canvas;
canvas.hCanvas = nullptr;
canvas.pCanvas = pCanvas;
- canvas.hPos = pCanvas->GetFirstPosition(nullptr);
+ canvas.hPos = pCanvas->GetFirstPosition();
if (!canvas.hPos)
return FALSE;
@@ -40,7 +40,7 @@ FX_BOOL CFDE_VisualSetIterator::FilterObjects(uint32_t dwObjects) {
FDE_CANVASITEM* pCanvas = m_CanvasStack.GetTopElement();
ASSERT(pCanvas && pCanvas->pCanvas);
- pCanvas->hPos = pCanvas->pCanvas->GetFirstPosition(nullptr);
+ pCanvas->hPos = pCanvas->pCanvas->GetFirstPosition();
return !!pCanvas->hPos;
}
@@ -48,9 +48,10 @@ void CFDE_VisualSetIterator::Reset() {
FilterObjects(m_dwFilter);
}
-FDE_HVISUALOBJ CFDE_VisualSetIterator::GetNext(IFDE_VisualSet*& pVisualSet,
- FDE_HVISUALOBJ* phCanvasObj,
- IFDE_CanvasSet** ppCanvasSet) {
+FDE_TEXTEDITPIECE* CFDE_VisualSetIterator::GetNext(
+ IFDE_VisualSet*& pVisualSet,
+ FDE_TEXTEDITPIECE** phCanvasObj,
+ IFDE_CanvasSet** ppCanvasSet) {
while (m_CanvasStack.GetSize() > 0) {
FDE_CANVASITEM* pCanvas = m_CanvasStack.GetTopElement();
ASSERT(pCanvas && pCanvas->pCanvas);
@@ -63,16 +64,16 @@ FDE_HVISUALOBJ CFDE_VisualSetIterator::GetNext(IFDE_VisualSet*& pVisualSet,
continue;
}
do {
- FDE_HVISUALOBJ hObj = pCanvas->pCanvas->GetNext(
- pCanvas->hCanvas, pCanvas->hPos, pVisualSet);
- ASSERT(hObj);
+ FDE_TEXTEDITPIECE* pObj =
+ pCanvas->pCanvas->GetNext(pCanvas->hPos, pVisualSet);
+ ASSERT(pObj);
FDE_VISUALOBJTYPE eType = pVisualSet->GetType();
if (eType == FDE_VISUALOBJ_Canvas) {
FDE_CANVASITEM canvas;
- canvas.hCanvas = hObj;
+ canvas.hCanvas = pObj;
canvas.pCanvas = (IFDE_CanvasSet*)pVisualSet;
- canvas.hPos = canvas.pCanvas->GetFirstPosition(hObj);
+ canvas.hPos = canvas.pCanvas->GetFirstPosition();
m_CanvasStack.Push(canvas);
break;
}
@@ -82,7 +83,7 @@ FDE_HVISUALOBJ CFDE_VisualSetIterator::GetNext(IFDE_VisualSet*& pVisualSet,
*ppCanvasSet = pCanvas->pCanvas;
if (phCanvasObj)
*phCanvasObj = pCanvas->hCanvas;
- return hObj;
+ return pObj;
}
} while (pCanvas->hPos);
}
diff --git a/xfa/fde/fde_iterator.h b/xfa/fde/fde_iterator.h
index 4f3fdf3f29..d162e24af3 100644
--- a/xfa/fde/fde_iterator.h
+++ b/xfa/fde/fde_iterator.h
@@ -13,7 +13,7 @@
struct FDE_CANVASITEM {
IFDE_CanvasSet* pCanvas;
- FDE_HVISUALOBJ hCanvas;
+ FDE_TEXTEDITPIECE* hCanvas;
FX_POSITION hPos;
};
@@ -26,9 +26,9 @@ class CFDE_VisualSetIterator : public CFX_Target {
FX_BOOL FilterObjects(uint32_t dwObjects = 0xFFFFFFFF);
void Reset();
- FDE_HVISUALOBJ GetNext(IFDE_VisualSet*& pVisualSet,
- FDE_HVISUALOBJ* phCanvasObj = NULL,
- IFDE_CanvasSet** ppCanvasSet = NULL);
+ FDE_TEXTEDITPIECE* GetNext(IFDE_VisualSet*& pVisualSet,
+ FDE_TEXTEDITPIECE** phCanvasObj = nullptr,
+ IFDE_CanvasSet** ppCanvasSet = nullptr);
protected:
uint32_t m_dwFilter;
diff --git a/xfa/fde/fde_render.cpp b/xfa/fde/fde_render.cpp
index 57ad5bff72..6e6d739cf9 100644
--- a/xfa/fde/fde_render.cpp
+++ b/xfa/fde/fde_render.cpp
@@ -62,23 +62,23 @@ FDE_RENDERSTATUS CFDE_RenderContext::DoRender(IFX_Pause* pPause) {
}
rm.TransformRect(rtDocClip);
IFDE_VisualSet* pVisualSet;
- FDE_HVISUALOBJ hVisualObj;
+ FDE_TEXTEDITPIECE* pPiece;
CFX_RectF rtObj;
int32_t iCount = 0;
while (TRUE) {
- hVisualObj = m_pIterator->GetNext(pVisualSet);
- if (!hVisualObj || !pVisualSet) {
+ pPiece = m_pIterator->GetNext(pVisualSet);
+ if (!pPiece || !pVisualSet) {
eStatus = FDE_RENDERSTATUS_Done;
break;
}
rtObj.Empty();
- pVisualSet->GetRect(hVisualObj, rtObj);
+ pVisualSet->GetRect(pPiece, rtObj);
if (!rtDocClip.IntersectWith(rtObj))
continue;
switch (pVisualSet->GetType()) {
case FDE_VISUALOBJ_Text:
- RenderText((IFDE_TextSet*)pVisualSet, hVisualObj);
+ RenderText((IFDE_TextSet*)pVisualSet, pPiece);
iCount += 5;
break;
case FDE_VISUALOBJ_Canvas:
@@ -107,15 +107,15 @@ void CFDE_RenderContext::StopRender() {
}
void CFDE_RenderContext::RenderText(IFDE_TextSet* pTextSet,
- FDE_HVISUALOBJ hText) {
+ FDE_TEXTEDITPIECE* pText) {
ASSERT(m_pRenderDevice);
- ASSERT(pTextSet && hText);
+ ASSERT(pTextSet && pText);
- IFGAS_Font* pFont = pTextSet->GetFont(hText);
+ IFGAS_Font* pFont = pTextSet->GetFont();
if (!pFont)
return;
- int32_t iCount = pTextSet->GetDisplayPos(hText, nullptr, FALSE);
+ int32_t iCount = pTextSet->GetDisplayPos(pText, nullptr, FALSE);
if (iCount < 1)
return;
@@ -130,33 +130,11 @@ void CFDE_RenderContext::RenderText(IFDE_TextSet* pTextSet,
if (m_iCharPosCount < iCount)
m_iCharPosCount = iCount;
- iCount = pTextSet->GetDisplayPos(hText, m_pCharPos, FALSE);
- FX_FLOAT fFontSize = pTextSet->GetFontSize(hText);
- FX_ARGB dwColor = pTextSet->GetFontColor(hText);
+ iCount = pTextSet->GetDisplayPos(pText, m_pCharPos, FALSE);
+ FX_FLOAT fFontSize = pTextSet->GetFontSize();
+ FX_ARGB dwColor = pTextSet->GetFontColor();
m_pBrush->SetColor(dwColor);
- FX_BOOL bClip = ApplyClip(pTextSet, hText);
m_pRenderDevice->DrawString(m_pBrush.get(), pFont, m_pCharPos, iCount,
fFontSize, &m_Transform);
- if (bClip)
- RestoreClip();
}
-FX_BOOL CFDE_RenderContext::ApplyClip(IFDE_VisualSet* pVisualSet,
- FDE_HVISUALOBJ hObj) {
- CFX_RectF rtClip;
- if (!pVisualSet->GetClip(hObj, rtClip))
- return FALSE;
-
- CFX_RectF rtObj;
- pVisualSet->GetRect(hObj, rtObj);
- rtClip.Offset(rtObj.left, rtObj.top);
- m_Transform.TransformRect(rtClip);
- const CFX_RectF& rtDevClip = m_pRenderDevice->GetClipRect();
- rtClip.Intersect(rtDevClip);
- m_pRenderDevice->SaveState();
- return m_pRenderDevice->SetClipRect(rtClip);
-}
-
-void CFDE_RenderContext::RestoreClip() {
- m_pRenderDevice->RestoreState();
-}
diff --git a/xfa/fde/fde_render.h b/xfa/fde/fde_render.h
index 302ae2d5b4..523aaee7c7 100644
--- a/xfa/fde/fde_render.h
+++ b/xfa/fde/fde_render.h
@@ -34,9 +34,7 @@ class CFDE_RenderContext : public CFX_Target {
FDE_RENDERSTATUS GetStatus() const { return m_eStatus; }
FDE_RENDERSTATUS DoRender(IFX_Pause* pPause = nullptr);
void StopRender();
- void RenderText(IFDE_TextSet* pTextSet, FDE_HVISUALOBJ hText);
- FX_BOOL ApplyClip(IFDE_VisualSet* pVisualSet, FDE_HVISUALOBJ hObj);
- void RestoreClip();
+ void RenderText(IFDE_TextSet* pTextSet, FDE_TEXTEDITPIECE* pText);
protected:
FDE_RENDERSTATUS m_eStatus;
diff --git a/xfa/fde/fde_visualset.h b/xfa/fde/fde_visualset.h
index 48b2ae7b94..e6898d83fa 100644
--- a/xfa/fde/fde_visualset.h
+++ b/xfa/fde/fde_visualset.h
@@ -20,40 +20,42 @@ enum FDE_VISUALOBJTYPE {
FDE_VISUALOBJ_Text = 0x01
};
-typedef struct FDE_HVISUALOBJ_ { void* pData; } const* FDE_HVISUALOBJ;
+struct FDE_TEXTEDITPIECE {
+ int32_t nStart;
+ int32_t nCount;
+ int32_t nBidiLevel;
+ CFX_RectF rtPiece;
+ uint32_t dwCharStyles;
+};
class IFDE_VisualSet {
public:
virtual ~IFDE_VisualSet() {}
virtual FDE_VISUALOBJTYPE GetType() = 0;
- virtual FX_BOOL GetBBox(FDE_HVISUALOBJ hVisualObj, CFX_RectF& bbox) = 0;
- virtual FX_BOOL GetMatrix(FDE_HVISUALOBJ hVisualObj, CFX_Matrix& matrix) = 0;
- virtual FX_BOOL GetRect(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) = 0;
- virtual FX_BOOL GetClip(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) = 0;
+ virtual void GetRect(FDE_TEXTEDITPIECE* hVisualObj, CFX_RectF& rt) = 0;
};
class IFDE_CanvasSet : public IFDE_VisualSet {
public:
- virtual FX_POSITION GetFirstPosition(FDE_HVISUALOBJ hCanvas) = 0;
- virtual FDE_HVISUALOBJ GetNext(FDE_HVISUALOBJ hCanvas,
- FX_POSITION& pos,
- IFDE_VisualSet*& pVisualSet) = 0;
- virtual FDE_HVISUALOBJ GetParentCanvas(FDE_HVISUALOBJ hCanvas,
- IFDE_VisualSet*& pVisualSet) = 0;
+ virtual FX_POSITION GetFirstPosition() = 0;
+ virtual FDE_TEXTEDITPIECE* GetNext(FX_POSITION& pos,
+ IFDE_VisualSet*& pVisualSet) = 0;
};
class IFDE_TextSet : public IFDE_VisualSet {
public:
- virtual int32_t GetString(FDE_HVISUALOBJ hText, CFX_WideString& wsText) = 0;
- virtual IFGAS_Font* GetFont(FDE_HVISUALOBJ hText) = 0;
- virtual FX_FLOAT GetFontSize(FDE_HVISUALOBJ hText) = 0;
- virtual FX_ARGB GetFontColor(FDE_HVISUALOBJ hText) = 0;
- virtual int32_t GetDisplayPos(FDE_HVISUALOBJ hText,
+ virtual int32_t GetString(FDE_TEXTEDITPIECE* hText,
+ CFX_WideString& wsText) = 0;
+ virtual IFGAS_Font* GetFont() = 0;
+ virtual FX_FLOAT GetFontSize() = 0;
+ virtual FX_ARGB GetFontColor() = 0;
+ virtual int32_t GetDisplayPos(FDE_TEXTEDITPIECE* hText,
FXTEXT_CHARPOS* pCharPos,
FX_BOOL bCharCode = FALSE,
- CFX_WideString* pWSForms = NULL) = 0;
- virtual int32_t GetCharRects(FDE_HVISUALOBJ hText,
- CFX_RectFArray& rtArray) = 0;
+ CFX_WideString* pWSForms = nullptr) = 0;
+ virtual int32_t GetCharRects(const FDE_TEXTEDITPIECE* hText,
+ CFX_RectFArray& rtArray,
+ FX_BOOL bbox) = 0;
};
#endif // XFA_FDE_FDE_VISUALSET_H_