summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpdfsdk/include/formfiller/FFL_CBA_Fontmap.h22
-rw-r--r--fpdfsdk/include/pdfwindow/PWL_FontMap.h14
-rw-r--r--fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp19
-rw-r--r--fpdfsdk/src/formfiller/FFL_ComboBox.cpp5
-rw-r--r--fpdfsdk/src/formfiller/FFL_ListBox.cpp4
-rw-r--r--fpdfsdk/src/formfiller/FFL_TextField.cpp4
-rw-r--r--fpdfsdk/src/fsdk_baseform.cpp35
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_FontMap.cpp9
8 files changed, 39 insertions, 73 deletions
diff --git a/fpdfsdk/include/formfiller/FFL_CBA_Fontmap.h b/fpdfsdk/include/formfiller/FFL_CBA_Fontmap.h
index 0215b868dd..c3e2e99646 100644
--- a/fpdfsdk/include/formfiller/FFL_CBA_Fontmap.h
+++ b/fpdfsdk/include/formfiller/FFL_CBA_Fontmap.h
@@ -15,39 +15,31 @@ class CPDFSDK_Annot;
class CBA_FontMap : public CPWL_FontMap {
public:
CBA_FontMap(CPDFSDK_Annot* pAnnot, IFX_SystemHandler* pSystemHandler);
- CBA_FontMap(CPDF_Document* pDocument,
- CPDF_Dictionary* pAnnotDict,
- IFX_SystemHandler* pSystemHandler);
-
~CBA_FontMap() override;
- virtual void Initial(const FX_CHAR* fontname = NULL);
-
- public:
void SetDefaultFont(CPDF_Font* pFont, const CFX_ByteString& sFontName);
void Reset();
void SetAPType(const CFX_ByteString& sAPType);
- protected:
- virtual CPDF_Font* FindFontSameCharset(CFX_ByteString& sFontAlias,
- int32_t nCharset);
- virtual void AddedFont(CPDF_Font* pFont, const CFX_ByteString& sFontAlias);
- virtual CPDF_Document* GetDocument();
-
private:
+ // CPWL_FontMap:
+ void Initialize() override;
+ CPDF_Document* GetDocument() override;
+ CPDF_Font* FindFontSameCharset(CFX_ByteString& sFontAlias,
+ int32_t nCharset) override;
+ void AddedFont(CPDF_Font* pFont, const CFX_ByteString& sFontAlias) override;
+
CPDF_Font* FindResFontSameCharset(CPDF_Dictionary* pResDict,
CFX_ByteString& sFontAlias,
int32_t nCharset);
CPDF_Font* GetAnnotDefaultFont(CFX_ByteString& csNameTag);
void AddFontToAnnotDict(CPDF_Font* pFont, const CFX_ByteString& sAlias);
- private:
CPDF_Document* m_pDocument;
CPDF_Dictionary* m_pAnnotDict;
CPDF_Font* m_pDefaultFont;
CFX_ByteString m_sDefaultFontName;
-
CFX_ByteString m_sAPType;
};
diff --git a/fpdfsdk/include/pdfwindow/PWL_FontMap.h b/fpdfsdk/include/pdfwindow/PWL_FontMap.h
index c17483439c..c8c8722c11 100644
--- a/fpdfsdk/include/pdfwindow/PWL_FontMap.h
+++ b/fpdfsdk/include/pdfwindow/PWL_FontMap.h
@@ -80,10 +80,11 @@ class CPWL_FontMap : public IFX_Edit_FontMap {
uint8_t nCharset);
protected:
- void Initial(const FX_CHAR* fontname = NULL);
- CPDF_Document* GetDocument();
- CPDF_Font* FindFontSameCharset(CFX_ByteString& sFontAlias, int32_t nCharset);
- void AddedFont(CPDF_Font* pFont, const CFX_ByteString& sFontAlias);
+ virtual void Initialize();
+ virtual CPDF_Document* GetDocument();
+ virtual CPDF_Font* FindFontSameCharset(CFX_ByteString& sFontAlias,
+ int32_t nCharset);
+ virtual void AddedFont(CPDF_Font* pFont, const CFX_ByteString& sFontAlias);
FX_BOOL KnowWord(int32_t nFontIndex, FX_WORD word);
@@ -126,9 +127,10 @@ class CPWL_DocFontMap : public CPWL_FontMap {
CPDF_Document* pAttachedDoc);
~CPWL_DocFontMap() override;
- virtual CPDF_Document* GetDocument();
-
private:
+ // CPWL_FontMap:
+ CPDF_Document* GetDocument() override;
+
CPDF_Document* m_pAttachedDoc;
};
diff --git a/fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp b/fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp
index dd58180e61..b08ce35d41 100644
--- a/fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp
+++ b/fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp
@@ -18,17 +18,9 @@ CBA_FontMap::CBA_FontMap(CPDFSDK_Annot* pAnnot,
m_pDocument = pPage->m_pDocument;
m_pAnnotDict = pAnnot->GetPDFAnnot()->GetAnnotDict();
+ Initialize();
}
-CBA_FontMap::CBA_FontMap(CPDF_Document* pDocument,
- CPDF_Dictionary* pAnnotDict,
- IFX_SystemHandler* pSystemHandler)
- : CPWL_FontMap(pSystemHandler),
- m_pDocument(pDocument),
- m_pAnnotDict(pAnnotDict),
- m_pDefaultFont(NULL),
- m_sAPType("N") {}
-
CBA_FontMap::~CBA_FontMap() {}
void CBA_FontMap::Reset() {
@@ -37,7 +29,7 @@ void CBA_FontMap::Reset() {
m_sDefaultFontName = "";
}
-void CBA_FontMap::Initial(const FX_CHAR* fontname) {
+void CBA_FontMap::Initialize() {
int32_t nCharset = DEFAULT_CHARSET;
if (!m_pDefaultFont) {
@@ -60,7 +52,7 @@ void CBA_FontMap::Initial(const FX_CHAR* fontname) {
}
if (nCharset != ANSI_CHARSET)
- CPWL_FontMap::Initial(fontname);
+ CPWL_FontMap::Initialize();
}
void CBA_FontMap::SetDefaultFont(CPDF_Font* pFont,
@@ -73,9 +65,6 @@ void CBA_FontMap::SetDefaultFont(CPDF_Font* pFont,
m_pDefaultFont = pFont;
m_sDefaultFontName = sFontName;
- // if (m_sDefaultFontName.IsEmpty())
- // m_sDefaultFontName = pFont->GetFontTypeName();
-
int32_t nCharset = DEFAULT_CHARSET;
if (const CFX_SubstFont* pSubstFont = m_pDefaultFont->GetSubstFont())
nCharset = pSubstFont->m_Charset;
@@ -278,5 +267,5 @@ void CBA_FontMap::SetAPType(const CFX_ByteString& sAPType) {
m_sAPType = sAPType;
Reset();
- Initial();
+ Initialize();
}
diff --git a/fpdfsdk/src/formfiller/FFL_ComboBox.cpp b/fpdfsdk/src/formfiller/FFL_ComboBox.cpp
index 9458a14764..9c9384b3f0 100644
--- a/fpdfsdk/src/formfiller/FFL_ComboBox.cpp
+++ b/fpdfsdk/src/formfiller/FFL_ComboBox.cpp
@@ -32,11 +32,8 @@ PWL_CREATEPARAM CFFL_ComboBox::GetCreateParam() {
cp.dwFlags |= PCBS_ALLOWCUSTOMTEXT;
}
- if (!m_pFontMap) {
+ if (!m_pFontMap)
m_pFontMap = new CBA_FontMap(m_pWidget, GetSystemHandler());
- m_pFontMap->Initial();
- }
-
cp.pFontMap = m_pFontMap;
cp.pFocusHandler = this;
diff --git a/fpdfsdk/src/formfiller/FFL_ListBox.cpp b/fpdfsdk/src/formfiller/FFL_ListBox.cpp
index d00bfb12ff..d9244e699f 100644
--- a/fpdfsdk/src/formfiller/FFL_ListBox.cpp
+++ b/fpdfsdk/src/formfiller/FFL_ListBox.cpp
@@ -36,10 +36,8 @@ PWL_CREATEPARAM CFFL_ListBox::GetCreateParam() {
if (cp.dwFlags & PWS_AUTOFONTSIZE)
cp.fFontSize = FFL_DEFAULTLISTBOXFONTSIZE;
- if (!m_pFontMap) {
+ if (!m_pFontMap)
m_pFontMap = new CBA_FontMap(m_pWidget, m_pApp->GetSysHandler());
- m_pFontMap->Initial();
- }
cp.pFontMap = m_pFontMap;
return cp;
diff --git a/fpdfsdk/src/formfiller/FFL_TextField.cpp b/fpdfsdk/src/formfiller/FFL_TextField.cpp
index 2e67ebf0f3..10a1339703 100644
--- a/fpdfsdk/src/formfiller/FFL_TextField.cpp
+++ b/fpdfsdk/src/formfiller/FFL_TextField.cpp
@@ -68,10 +68,8 @@ PWL_CREATEPARAM CFFL_TextField::GetCreateParam() {
break;
}
- if (!m_pFontMap) {
+ if (!m_pFontMap)
m_pFontMap = new CBA_FontMap(m_pWidget, m_pApp->GetSysHandler());
- m_pFontMap->Initial();
- }
cp.pFontMap = m_pFontMap;
cp.pFocusHandler = this;
diff --git a/fpdfsdk/src/fsdk_baseform.cpp b/fpdfsdk/src/fsdk_baseform.cpp
index 4c6fc4bafd..faab02af95 100644
--- a/fpdfsdk/src/fsdk_baseform.cpp
+++ b/fpdfsdk/src/fsdk_baseform.cpp
@@ -494,10 +494,8 @@ void CPDFSDK_Widget::ResetAppearance_PushButton() {
CPDFSDK_Document* pDoc = m_pInterForm->GetDocument();
CPDFDoc_Environment* pEnv = pDoc->GetEnv();
- CBA_FontMap FontMap(this, pEnv->GetSysHandler());
- FontMap.Initial();
-
- FontMap.SetAPType("N");
+ CBA_FontMap font_map(this, pEnv->GetSysHandler());
+ font_map.SetAPType("N");
CFX_ByteString csAP =
CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground) +
@@ -505,7 +503,7 @@ void CPDFSDK_Widget::ResetAppearance_PushButton() {
crLeftTop, crRightBottom, nBorderStyle,
dsBorder) +
CPWL_Utils::GetPushButtonAppStream(
- iconFit.GetFittingBounds() ? rcWindow : rcClient, &FontMap,
+ iconFit.GetFittingBounds() ? rcWindow : rcClient, &font_map,
pNormalIcon, iconFit, csNormalCaption, crText, fFontSize, nLayout);
WriteAppearance("N", GetRotatedRect(), GetMatrix(), csAP);
@@ -519,14 +517,14 @@ void CPDFSDK_Widget::ResetAppearance_PushButton() {
pRolloverIcon = pNormalIcon;
}
- FontMap.SetAPType("R");
+ font_map.SetAPType("R");
csAP = CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground) +
CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder,
crLeftTop, crRightBottom,
nBorderStyle, dsBorder) +
CPWL_Utils::GetPushButtonAppStream(
- iconFit.GetFittingBounds() ? rcWindow : rcClient, &FontMap,
+ iconFit.GetFittingBounds() ? rcWindow : rcClient, &font_map,
pRolloverIcon, iconFit, csRolloverCaption, crText, fFontSize,
nLayout);
@@ -551,7 +549,7 @@ void CPDFSDK_Widget::ResetAppearance_PushButton() {
break;
}
- FontMap.SetAPType("D");
+ font_map.SetAPType("D");
csAP = CPWL_Utils::GetRectFillAppStream(
rcWindow, CPWL_Utils::SubstractColor(crBackground, 0.25f)) +
@@ -559,7 +557,7 @@ void CPDFSDK_Widget::ResetAppearance_PushButton() {
crLeftTop, crRightBottom,
nBorderStyle, dsBorder) +
CPWL_Utils::GetPushButtonAppStream(
- iconFit.GetFittingBounds() ? rcWindow : rcClient, &FontMap,
+ iconFit.GetFittingBounds() ? rcWindow : rcClient, &font_map,
pDownIcon, iconFit, csDownCaption, crText, fFontSize, nLayout);
WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP);
@@ -875,9 +873,8 @@ void CPDFSDK_Widget::ResetAppearance_ComboBox(const FX_WCHAR* sValue) {
CPDFSDK_Document* pDoc = m_pInterForm->GetDocument();
CPDFDoc_Environment* pEnv = pDoc->GetEnv();
- CBA_FontMap FontMap(this, pEnv->GetSysHandler());
- FontMap.Initial();
- pEdit->SetFontMap(&FontMap);
+ CBA_FontMap font_map(this, pEnv->GetSysHandler());
+ pEdit->SetFontMap(&font_map);
CPDF_Rect rcEdit = rcClient;
rcEdit.right = rcButton.left;
@@ -947,9 +944,8 @@ void CPDFSDK_Widget::ResetAppearance_ListBox() {
CPDFSDK_Document* pDoc = m_pInterForm->GetDocument();
CPDFDoc_Environment* pEnv = pDoc->GetEnv();
- CBA_FontMap FontMap(this, pEnv->GetSysHandler());
- FontMap.Initial();
- pEdit->SetFontMap(&FontMap);
+ CBA_FontMap font_map(this, pEnv->GetSysHandler());
+ pEdit->SetFontMap(&font_map);
pEdit->SetPlateRect(CPDF_Rect(rcClient.left, 0.0f, rcClient.right, 0.0f));
@@ -1035,9 +1031,8 @@ void CPDFSDK_Widget::ResetAppearance_TextField(const FX_WCHAR* sValue) {
CPDFSDK_Document* pDoc = m_pInterForm->GetDocument();
CPDFDoc_Environment* pEnv = pDoc->GetEnv();
- CBA_FontMap FontMap(this, pEnv->GetSysHandler());
- FontMap.Initial();
- pEdit->SetFontMap(&FontMap);
+ CBA_FontMap font_map(this, pEnv->GetSysHandler());
+ pEdit->SetFontMap(&font_map);
CPDF_Rect rcClient = GetClientRect();
pEdit->SetPlateRect(rcClient);
@@ -1068,8 +1063,8 @@ void CPDFSDK_Widget::ResetAppearance_TextField(const FX_WCHAR* sValue) {
pEdit->SetCharArray(nMaxLen);
if (IsFloatZero(fFontSize)) {
- fFontSize = CPWL_Edit::GetCharArrayAutoFontSize(FontMap.GetPDFFont(0),
- rcClient, nMaxLen);
+ fFontSize = CPWL_Edit::GetCharArrayAutoFontSize(
+ font_map.GetPDFFont(0), rcClient, nMaxLen);
}
} else {
if (sValue)
diff --git a/fpdfsdk/src/pdfwindow/PWL_FontMap.cpp b/fpdfsdk/src/pdfwindow/PWL_FontMap.cpp
index d5ca376882..fadea905d4 100644
--- a/fpdfsdk/src/pdfwindow/PWL_FontMap.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_FontMap.cpp
@@ -151,13 +151,8 @@ void CPWL_FontMap::Empty() {
}
}
-void CPWL_FontMap::Initial(const FX_CHAR* fontname) {
- CFX_ByteString sFontName = fontname;
-
- if (sFontName.IsEmpty())
- sFontName = DEFAULT_FONT_NAME;
-
- GetFontIndex(sFontName, ANSI_CHARSET, FALSE);
+void CPWL_FontMap::Initialize() {
+ GetFontIndex(DEFAULT_FONT_NAME, ANSI_CHARSET, FALSE);
}
/*